-
Notifications
You must be signed in to change notification settings - Fork 2
Findings on the Redland internal implementation
-
Redland has OOP-style interfaces and implementations. Iterator is an abstract module that provides a generic interator interface in C.
-
Model provides an API to work with RDF graphs in an abstract way.
-
Redland has a single storage interface but multiple storage implementations. Storages implement backends for triple stores, such as MySQL, PostgreSQL, or key-value storages. Key-value storage is somewhat confusingly named
hashes. -
The
hashesstorage implementation depends on the hashes interface, which provides a hash-table functionality (basically, a general-purpose key-value based storage). It also has multiple implementations (memory- in-memory key-value storage andbdb- BerkelyDB-backed key-value storage). A bit confusingly, thehashesinterface also used for some internal purposes (such as handling the storage options, etc.). -
The
storageinterface is used internally bymodelto look up triples and iterate over the RDF statements. When iterating, a new iterator object is created inlibrdf_hash_get_alland each call tolibrdf_iterator_get_objectis delegated to the storage implementation. In case of thelibrdf_storage_hashesstorage, it relies on the internal representation of k/v pairs in thelibrdf_hashesmodule, decoding the value. -
The idea for Mutable Data storage is to copy the keys/values stored in
rdf_hashesand transform them intoVec<EntryAction>which can be applied directly in amutate_mdata_entriesoperation. This should allow efficient insertion and deletion operations, without overwriting an entire RDF graph. We should also account for updates; this, however, should be simple, as it must be sufficient to overwrite the values having the same keys.Data retrieval is more tricky, but not too much. We just need to restore a state of an
librdf_hashobject. For that, it should be sufficient to dump all MData keys & values, transform them intolibrdf_hash_datumstructs, and calllibrdf_hashes_put(item)for each one. Then, the internal state oflibrdf_storage_hashesobject has got to be synchronised with the internal state of thelibrdf_hashobject.It should be noted that the redland-rs hash table implementation supports storing multiple values for a single key (one-to-many). It needs to be translated into Mutable Data which supports only one-to-one mappings.
Subsequently, while iterating over the storage, the stored encoded values will be decoded into RDF terms and streamed into a model, providing the full scope of librdf functionality, including queries.