Module volksdata.store
Store module.
This module handles the backing storage for Volksdata graphs.
Two store types are available in the current implementation: an in-memory one, based on hash maps, and a persistent one based on the MDB embedded database. Only the latter is available for explicit creation and assignment to one or multiple graphs in this Lua binding. The in-memory store is used by default on graph creation, and each graph thus created has a separate, "embedded" hashmap store.
The MDB store supports multiple named graphs via RDF contexts, indexing, and fast lookups. Multiple stores can be created on separate files and managed at the same time.
An MDB store is identified by a local file URI (file://[...]). Such
store handle is a singleton that, once created, gets reused for each call to
new. The store handle is only released at the end of the program.
Functions
| new (store_type, id, clear) | Create a new store handle from an existing or new database. |
Class volksdata.Store
| volksdata.store.id | Get store ID. |
| volksdata.store.type | Get store type. |
| volksdata.store:__len (store) | Get the store size in triples. |
| volksdata.store:__tostring (store) | Display basic store information. |
| volksdata.store:begin (store, flags) | Begin a new transaction. |
Class volksdata.Transaction
| volksdata.transaction:abort (txn) | Abort a transaction and roll back all changes. |
| volksdata.transaction:commit (txn) | Commit a transaction and store all changes. |
Functions
- new (store_type, id, clear)
-
Create a new store handle from an existing or new database.
This function creates an entry in the global table to store the DB handle for re-usage.
Parameters:
- store_type
int
One of
store.T_*constants. Currently, onlyT_MDBis available for explicit creation. - id
string
URI of the store, in the
file://<path>format. The URI points to a directory. If the directory exists, the data in it are used; otherwise, a new database is created. - clear boolean If the database has already been created, wipe all data before creating the handle.
Returns:
- store_type
int
One of
Class volksdata.Store
- volksdata.store.id
-
Get store ID.
- id
- volksdata.store.type
-
Get store type.
- type
- volksdata.store:__len (store)
-
Get the store size in triples.
Parameters:
- store Store Store handle.
Returns:
-
int
- volksdata.store:__tostring (store)
-
Display basic store information.
Parameters:
- store Store Store handle.
Returns:
-
int
- volksdata.store:begin (store, flags)
-
Begin a new transaction.
A thread can have at most one open transaction at any time.
A transaction SHOULD be either committed with ??? or aborted with ???. Note that if an open transaction is garbage-collected, it is aborted.
Parameters:
- store Store Store to begin transaction in. The store MUST NOT have other transactions open by the same thread.
- flags int Transaction flags. The only supported flag at the moment is ???, which opens a read-only transaction.
Returns:
-
Transaction
An opaque transaction handle that can be passed to
store and graph functions.
Class volksdata.Transaction
- volksdata.transaction:abort (txn)
-
Abort a transaction and roll back all changes.
Parameters:
- txn Transaction Transaction object to abort.
Returns:
-
nil
- volksdata.transaction:commit (txn)
-
Commit a transaction and store all changes.
Parameters:
- txn Transaction Transaction object to commit.
Returns:
-
nil