lakesuperior.store package

Submodules

lakesuperior.store.base_lmdb_store module

class lakesuperior.store.base_lmdb_store.BaseLmdbStore(env_path, open_env=True, create=True)

Bases: object

Generic LMDB store abstract class.

This class contains convenience method to create an LMDB store for any purpose and provides some convenience methods to wrap cursors and transactions into contexts.

Example usage:

>>> class MyStore(BaseLmdbStore):
...     path = '/base/store/path'
...     dbi_flags = ('db1', 'db2')
...
>>> ms = MyStore()
>>> # "with" wraps the operation in a transaction.
>>> with ms.cur(index='db1', write=True):
...     cur.put(b'key1', b'val1')
True
abort

Abort main transaction.

begin

Begin a transaction manually if not already in a txn context.

The txn_ctx() context manager should be used whenever
possible rather than this method.
close_env
commit

Commit main transaction.

dbi_flags = {}
dbi_labels = []
delete

Delete one single value by key. Python-facing method.

destroy

Destroy the store.

https://www.youtube.com/watch?v=lIVq7FJnPwg

Parameters:_path (str) – unused. Left for RDFLib API compatibility. (actually quite dangerous if it were used: it could turn into a general-purpose recursive file and folder delete method!)
env_flags = 0
env_path
env_perms = 416
get_data

Get a single value (non-dup) for a key (Python-facing method).

is_open
is_txn_open
is_txn_rw
key_exists

Return whether a key exists in a database (Python-facing method).

Wrap in a new transaction. Only use this if a transaction has not been opened.

open_env

Open, and optionally create, store environment.

options = {}
put

Put one key/value pair (Python-facing method).

readers
rollback

Alias for abort()

stats

Gather statistics about the database.

txn_ctx(self, write=False)

Transaction context manager.

Open and close a transaction for the duration of the functions in the context. If a transaction has already been opened in the store, a new one is opened only if the current transaction is read-only and the new requested transaction is read-write.

If a new write transaction is opened, the old one is kept on hold until the new transaction is closed, then restored. All cursors are invalidated and must be restored as well if one needs to reuse them.

Parameters:write (bool) – Whether a write transaction is to be opened.
Return type:lmdb.Transaction
txn_id
exception lakesuperior.store.base_lmdb_store.InvalidParamError

Bases: lakesuperior.store.base_lmdb_store.LmdbError

exception lakesuperior.store.base_lmdb_store.KeyExistsError

Bases: lakesuperior.store.base_lmdb_store.LmdbError

exception lakesuperior.store.base_lmdb_store.KeyNotFoundError

Bases: lakesuperior.store.base_lmdb_store.LmdbError

exception lakesuperior.store.base_lmdb_store.LmdbError

Bases: Exception

lakesuperior.store.metadata_store module

class lakesuperior.store.metadata_store.MetadataStore[source]

Bases: lakesuperior.store.base_lmdb_store.BaseLmdbStore

LMDB store for RDF metadata.

Note that even though this store connector uses LMDB as the :py:LmdbStore class, it is separate because it is not part of the RDFLib store implementation and carries higher-level concepts such as LDP resource URIs.

dbi_labels = ['checksums', 'event_queue']

Currently implemented:

  • checksums: registry of LDP resource graphs, indicated in the key by their UID, and their cryptographic hashes.
delete_checksum(uri)[source]

Delete the stored checksum of a resource.

Parameters:uri (str) – Resource URI (info:fcres...).
get_checksum(uri)[source]

Get the checksum of a resource.

Parameters:uri (str) – Resource URI (info:fcres...).
Return type:bytes
update_checksum(uri, cksum)[source]

Update the stored checksum of a resource.

Parameters:
  • uri (str) – Resource URI (info:fcres...).
  • cksum (bytes) – Checksum bytestring.