aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/triple_store/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsfs/triple_store/base.py')
-rw-r--r--bsfs/triple_store/base.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/bsfs/triple_store/base.py b/bsfs/triple_store/base.py
index 942a16b..6561262 100644
--- a/bsfs/triple_store/base.py
+++ b/bsfs/triple_store/base.py
@@ -21,7 +21,21 @@ __all__: typing.Sequence[str] = (
## code ##
class TripleStoreBase(abc.ABC):
- """
+ """TripleStore base class.
+
+ Use the `Open` method to create a new instance and to initialize
+ the required structures.
+
+ Triple stores express a graph via its (subject, predicate, object) triples.
+ They provides methods to add and remove triples, and to query the storage
+ for given graph structures. The subject is always a node in the graph,
+ whereas nodes are identifiable by a unique URI. Note that blank nodes
+ (without an explicit URI) are not supported. The object can be another
+ Node or a Literal value. The relation between a subject and an object
+ is expressed via a Predicate. The graph structures are governed by a
+ schema that defines which Node, Literal, and Predicate classes exist
+ and how they can interact (see `bsfs.schema.Schema`).
+
"""
# storage's URI. None implies a temporary location.
@@ -99,9 +113,8 @@ class TripleStoreBase(abc.ABC):
self,
node_type: _schema.Node,
guids: typing.Iterable[URI],
- ):
- """
- """
+ ) -> typing.Iterable[URI]:
+ """Return those *guids* that exist and have type *node_type* or a subclass thereof."""
@abc.abstractmethod
def create(
@@ -119,7 +132,17 @@ class TripleStoreBase(abc.ABC):
predicate: _schema.Predicate,
values: typing.Iterable[typing.Any],
):
- """
+ """Add triples to the graph.
+
+ It is assumed that all of *guids* exist and have *node_type*.
+ This method adds a triple (guid, predicate, value) for every guid in
+ *guids* and each value in *values* (cartesian product). Note that
+ *values* must have length one for unique predicates, and that
+ currently existing values will be overwritten in this case.
+ It also verifies that all symbols are part of the schema and that
+ the *predicate* matches the *node_type*.
+ Raises `bsfs.errors.ConsistencyError` if these assumptions are violated.
+
"""
## EOF ##