[redland-dev] Documentation on Implementing a Model-wrapper for an RDBMS in Perl?

Dave Beckett dave.beckett at bristol.ac.uk
Mon Oct 25 11:27:09 BST 2004


On Fri, 22 Oct 2004 17:47:34 +0200, Jan Algermissen <jalgermissen at topicmapping.com> wrote:

> Hi,
> 
> I am using the Perl binding of redland and have to create my own
> model wrapper to a particular MySQL database.
> 
> Is there any documentation about how to do this?

Not if I understand what you mean - you want to create a new Perl
class that implements the RDF::Redland::Model interface?

> So far I think I simply have to subclass the Perl classes
> that Model uses and that do not provide public constructors
> (e.g Stream) and Model itself of course.

Since Perl's class API is rather weak, you don't really need to do
that; plus I don't check the types of the items in the Redland Perl
API.  So all you need to do is provide a new class that implements
all the methods (perl subs) of RDF::Redland::Model.  If my typing was
stronger, subclassing RDF::Redland::Model and then overloading all
the methods would have sufficed.

> I read that some of the Model methods are optional; is there
> any documentation which those are?

That's true internally in the C API - librdf_model implementations
can omit optional methods and the librdf_model.c code will handle
them - think of it as a base class.  The optional methods are listed
in rdf_model.h for the struct librdf_model_factory_s:
  http://cvs.librdf.org/cvsweb/*checkout*/redland/librdf/librdf/rdf_model.h
if you search for OPTIONAL.

If you were writing a new C API implemenation of the model class,
that's what you'd need to know.  

At present there is only one such implementation rdf_model_storage.c
which provides a model with a storage backend but there is scope for
adding more, such as a read-only model that maps to another system to
produce triples on demand, or a model that is a union of multiple
models.

> BTW: Kudos to Dave for the overall design, it is exactly the
> flexibility that is needed for bringing together diverse data
> sources.

Thanks

Dave



More information about the redland-dev mailing list