def __init__(self, configuration=None, identifier=None): """ identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore. """ self.__node_pickler = None self.dispatcher = Dispatcher() if configuration: self.open(configuration)
def __init__(self, store, filename): self.stream = file(filename, "rb") self.store = store dispatcher = Dispatcher() dispatcher.subscribe(TripleAddedEvent, self.add) dispatcher.subscribe(TripleRemovedEvent, self.remove) dispatcher.subscribe(StoreCreatedEvent, self.store_created) loads = store.node_pickler.loads dispatch = dispatcher.dispatch lines = [] for line in self.stream: if line == "\n": try: event = loads("".join(lines)) dispatch(event) lines = [] except Exception, e: _logger.exception(e) _logger.debug("lines: '%s'" % lines) lines = [] else: lines.append(line)
def __init__(self, store, filename): self.stream = file(filename, "rb") self.store = store dispatcher = Dispatcher() dispatcher.subscribe(TripleAddedEvent, self.add) dispatcher.subscribe(TripleRemovedEvent, self.remove) dispatcher.subscribe(StoreCreatedEvent, self.store_created) loads = store.node_pickler.loads dispatch = dispatcher.dispatch lines = [] for line in self.stream: if line=="\n": try: event = loads("".join(lines)) dispatch(event) lines = [] except Exception, e: _logger.exception(e) _logger.debug("lines: '%s'" % lines) lines = [] else: lines.append(line)
class Store(object): # Properties context_aware = False formula_aware = False transaction_aware = False batch_unification = False def __init__(self, configuration=None, identifier=None): """ identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore. """ self.__node_pickler = None self.dispatcher = Dispatcher() if configuration: self.open(configuration) def __get_node_pickler(self): if self.__node_pickler is None: from rdflib.term import URIRef from rdflib.term import BNode from rdflib.term import Literal from rdflib.graph import Graph, QuotedGraph, GraphValue from rdflib.term import Variable from rdflib.term import Statement self.__node_pickler = np = NodePickler() np.register(self, "S") np.register(URIRef, "U") np.register(BNode, "B") np.register(Literal, "L") np.register(Graph, "G") np.register(QuotedGraph, "Q") np.register(Variable, "V") np.register(Statement, "s") np.register(GraphValue, "v") return self.__node_pickler node_pickler = property(__get_node_pickler) # Database management methods def create(self, configuration): self.dispatcher.dispatch( StoreCreatedEvent(configuration=configuration)) def open(self, configuration, create=False): """ Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of: VALID_STORE, CORRUPTED_STORE, or NO_STORE """ return UNKNOWN def close(self, commit_pending_transaction=False): """ This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional). """ def destroy(self, configuration): """ This destroys the instance of the store identified by the configuration string. """ def gc(self): """ Allows the store to perform any needed garbage collection """ pass # RDF APIs def add(self, (subject, predicate, object), context, quoted=False):
class Store(object): #Properties context_aware = False formula_aware = False transaction_aware = False batch_unification = False def __init__(self, configuration=None, identifier=None): """ identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore. """ self.__node_pickler = None self.dispatcher = Dispatcher() if configuration: self.open(configuration) def __get_node_pickler(self): if self.__node_pickler is None: from rdflib.term import URIRef from rdflib.term import BNode from rdflib.term import Literal from rdflib.graph import Graph, QuotedGraph, GraphValue from rdflib.term import Variable from rdflib.term import Statement self.__node_pickler = np = NodePickler() np.register(self, "S") np.register(URIRef, "U") np.register(BNode, "B") np.register(Literal, "L") np.register(Graph, "G") np.register(QuotedGraph, "Q") np.register(Variable, "V") np.register(Statement, "s") np.register(GraphValue, "v") return self.__node_pickler node_pickler = property(__get_node_pickler) #Database management methods def create(self, configuration): self.dispatcher.dispatch(StoreCreatedEvent(configuration=configuration)) def open(self, configuration, create=False): """ Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of VALID_STORE,CORRUPTED_STORE,or NO_STORE """ return UNKNOWN def close(self, commit_pending_transaction=False): """ This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional). """ def destroy(self, configuration): """ This destroys the instance of the store identified by the configuration string. """ def gc(self): """ Allows the store to perform any needed garbage collection """ pass #RDF APIs def add(self, (subject, predicate, object), context, quoted=False):
class Store(object): #Properties context_aware = False formula_aware = False transaction_aware = False batch_unification = False def __init__(self, configuration=None, identifier=None): """ identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore. """ self.__node_pickler = None self.dispatcher = Dispatcher() if configuration: self.open(configuration) def __get_node_pickler(self): if self.__node_pickler is None: from rdflib.store.NodePickler import NodePickler from rdflib.URIRef import URIRef from rdflib.BNode import BNode from rdflib.Literal import Literal from rdflib.Graph import Graph, QuotedGraph, GraphValue from rdflib.Variable import Variable from rdflib.Statement import Statement self.__node_pickler = np = NodePickler() np.register(self, "S") np.register(URIRef, "U") np.register(BNode, "B") np.register(Literal, "L") np.register(Graph, "G") np.register(QuotedGraph, "Q") np.register(Variable, "V") np.register(Statement, "s") np.register(GraphValue, "v") return self.__node_pickler node_pickler = property(__get_node_pickler) #Database management methods def create(self, configuration): self.dispatcher.dispatch(StoreCreatedEvent(configuration=configuration)) def open(self, configuration, create=False): """ Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of VALID_STORE,CORRUPTED_STORE,or NO_STORE """ return UNKNOWN def close(self, commit_pending_transaction=False): """ This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional). """ def destroy(self, configuration): """ This destroys the instance of the store identified by the configuration string. """ def gc(self): """ Allows the store to perform any needed garbage collection """ pass def sparql_query(self, queryString, queryObj, graph, dataSetBase, extensionFunctions, initBindings={}, initNs={}, DEBUG=False): """ The default 'native' SPARQL implementation is based on sparql-p's expansion trees layered on top of the read-only RDF APIs of the underlying store """ from rdflib.sparql.Algebra import TopEvaluate from rdflib.QueryResult import QueryResult from rdflib import plugin rt = TopEvaluate(queryObj, graph, initBindings, DEBUG=DEBUG, dataSetBase=dataSetBase, extensionFunctions=extensionFunctions) return plugin.get('SPARQLQueryResult',QueryResult)(rt) #RDF APIs def add(self, (subject, predicate, object), context, quoted=False):
class Store(object): # Properties context_aware = False formula_aware = False transaction_aware = False graph_aware = False def __init__(self, configuration=None, identifier=None): """ identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore. """ self.__node_pickler = None self.dispatcher = Dispatcher() if configuration: self.open(configuration) def __get_node_pickler(self): if self.__node_pickler is None: from rdflib.term import URIRef from rdflib.term import BNode from rdflib.term import Literal from rdflib.graph import Graph, QuotedGraph from rdflib.term import Variable from rdflib.term import Statement self.__node_pickler = np = NodePickler() np.register(self, "S") np.register(URIRef, "U") np.register(BNode, "B") np.register(Literal, "L") np.register(Graph, "G") np.register(QuotedGraph, "Q") np.register(Variable, "V") np.register(Statement, "s") return self.__node_pickler node_pickler = property(__get_node_pickler) # Database management methods def create(self, configuration): self.dispatcher.dispatch(StoreCreatedEvent(configuration=configuration)) def open(self, configuration, create=False): """ Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of: VALID_STORE, CORRUPTED_STORE, or NO_STORE """ return UNKNOWN def close(self, commit_pending_transaction=False): """ This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional). """ def destroy(self, configuration): """ This destroys the instance of the store identified by the configuration string. """ def gc(self): """ Allows the store to perform any needed garbage collection """ pass # RDF APIs def add(self, triple, context, quoted=False): """ Adds the given statement to a specific context or to the model. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical It should be an error to not specify a context and have the quoted argument be True. It should also be an error for the quoted argument to be True when the store is not formula-aware. """ self.dispatcher.dispatch(TripleAddedEvent(triple=triple, context=context)) def addN(self, quads): """ Adds each item in the list of statements to a specific context. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical. Note that the default implementation is a redirect to add """ for s, p, o, c in quads: assert c is not None, "Context associated with %s %s %s is None!" % ( s, p, o, ) self.add((s, p, o), c) def remove(self, triple, context=None): """ Remove the set of triples matching the pattern from the store """ self.dispatcher.dispatch(TripleRemovedEvent(triple=triple, context=context)) def triples_choices(self, triple, context=None): """ A variant of triples that can take a list of terms instead of a single term in any slot. Stores can implement this to optimize the response time from the default 'fallback' implementation, which will iterate over each term in the list and dispatch to triples """ subject, predicate, object_ = triple if isinstance(object_, list): assert not isinstance(subject, list), "object_ / subject are both lists" assert not isinstance(predicate, list), "object_ / predicate are both lists" if object_: for obj in object_: for (s1, p1, o1), cg in self.triples( (subject, predicate, obj), context ): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples( (subject, predicate, None), context ): yield (s1, p1, o1), cg elif isinstance(subject, list): assert not isinstance(predicate, list), "subject / predicate are both lists" if subject: for subj in subject: for (s1, p1, o1), cg in self.triples( (subj, predicate, object_), context ): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples( (None, predicate, object_), context ): yield (s1, p1, o1), cg elif isinstance(predicate, list): assert not isinstance(subject, list), "predicate / subject are both lists" if predicate: for pred in predicate: for (s1, p1, o1), cg in self.triples( (subject, pred, object_), context ): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples((subject, None, object_), context): yield (s1, p1, o1), cg def triples(self, triple_pattern, context=None): """ A generator over all the triples matching the pattern. Pattern can include any objects for used for comparing against nodes in the store, for example, REGEXTerm, URIRef, Literal, BNode, Variable, Graph, QuotedGraph, Date? DateRange? :param context: A conjunctive query can be indicated by either providing a value of None, or a specific context can be queries by passing a Graph instance (if store is context aware). """ subject, predicate, object = triple_pattern # variants of triples will be done if / when optimization is needed def __len__(self, context=None): """ Number of statements in the store. This should only account for non- quoted (asserted) statements if the context is not specified, otherwise it should return the number of statements in the formula or context given. :param context: a graph instance to query or None """ def contexts(self, triple=None): """ Generator over all contexts in the graph. If triple is specified, a generator over all contexts the triple is in. if store is graph_aware, may also return empty contexts :returns: a generator over Nodes """ def query(self, query, initNs, initBindings, queryGraph, **kwargs): """ If stores provide their own SPARQL implementation, override this. queryGraph is None, a URIRef or '__UNION__' If None the graph is specified in the query-string/object If URIRef it specifies the graph to query, If '__UNION__' the union of all named graphs should be queried (This is used by ConjunctiveGraphs Values other than None obviously only makes sense for context-aware stores.) """ raise NotImplementedError def update(self, update, initNs, initBindings, queryGraph, **kwargs): """ If stores provide their own (SPARQL) Update implementation, override this. queryGraph is None, a URIRef or '__UNION__' If None the graph is specified in the query-string/object If URIRef it specifies the graph to query, If '__UNION__' the union of all named graphs should be queried (This is used by ConjunctiveGraphs Values other than None obviously only makes sense for context-aware stores.) """ raise NotImplementedError # Optional Namespace methods def bind(self, prefix, namespace): """ """ def prefix(self, namespace): """ """ def namespace(self, prefix): """ """ def namespaces(self): """ """ if False: yield None # Optional Transactional methods def commit(self): """ """ def rollback(self): """ """ # Optional graph methods def add_graph(self, graph): """ Add a graph to the store, no effect if the graph already exists. :param graph: a Graph instance """ raise Exception("Graph method called on non-graph_aware store") def remove_graph(self, graph): """ Remove a graph from the store, this shoud also remove all triples in the graph :param graphid: a Graph instance """ raise Exception("Graph method called on non-graph_aware store")
def dispatcher(self): if not hasattr(self, '_v_dispatcher'): self._v_dispatcher = Dispatcher() return self._v_dispatcher
class Store(object): # Properties context_aware = False formula_aware = False transaction_aware = False graph_aware = False def __init__(self, configuration=None, identifier=None): """ identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore. """ self.__node_pickler = None self.dispatcher = Dispatcher() if configuration: self.open(configuration) def __get_node_pickler(self): if self.__node_pickler is None: from rdflib.term import URIRef from rdflib.term import BNode from rdflib.term import Literal from rdflib.graph import Graph, QuotedGraph from rdflib.term import Variable from rdflib.term import Statement self.__node_pickler = np = NodePickler() np.register(self, "S") np.register(URIRef, "U") np.register(BNode, "B") np.register(Literal, "L") np.register(Graph, "G") np.register(QuotedGraph, "Q") np.register(Variable, "V") np.register(Statement, "s") return self.__node_pickler node_pickler = property(__get_node_pickler) # Database management methods def create(self, configuration): self.dispatcher.dispatch( StoreCreatedEvent(configuration=configuration)) def open(self, configuration, create=False): """ Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of: VALID_STORE, CORRUPTED_STORE, or NO_STORE """ return UNKNOWN def close(self, commit_pending_transaction=False): """ This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional). """ def destroy(self, configuration): """ This destroys the instance of the store identified by the configuration string. """ def gc(self): """ Allows the store to perform any needed garbage collection """ pass # RDF APIs def add(self, triple, context, quoted=False): """ Adds the given statement to a specific context or to the model. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical It should be an error to not specify a context and have the quoted argument be True. It should also be an error for the quoted argument to be True when the store is not formula-aware. """ self.dispatcher.dispatch( TripleAddedEvent( triple=triple, context=context)) def addN(self, quads): """ Adds each item in the list of statements to a specific context. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical. Note that the default implementation is a redirect to add """ for s, p, o, c in quads: assert c is not None, \ "Context associated with %s %s %s is None!" % (s, p, o) self.add((s, p, o), c) def remove(self, triple, context=None): """ Remove the set of triples matching the pattern from the store """ self.dispatcher.dispatch( TripleRemovedEvent( triple=triple, context=context)) def triples_choices(self, triple, context=None): """ A variant of triples that can take a list of terms instead of a single term in any slot. Stores can implement this to optimize the response time from the default 'fallback' implementation, which will iterate over each term in the list and dispatch to triples """ subject, predicate, object_ = triple if isinstance(object_, list): assert not isinstance( subject, list), "object_ / subject are both lists" assert not isinstance( predicate, list), "object_ / predicate are both lists" if object_: for obj in object_: for (s1, p1, o1), cg in self.triples( (subject, predicate, obj), context): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples( (subject, predicate, None), context): yield (s1, p1, o1), cg elif isinstance(subject, list): assert not isinstance( predicate, list), "subject / predicate are both lists" if subject: for subj in subject: for (s1, p1, o1), cg in self.triples( (subj, predicate, object_), context): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples( (None, predicate, object_), context): yield (s1, p1, o1), cg elif isinstance(predicate, list): assert not isinstance( subject, list), "predicate / subject are both lists" if predicate: for pred in predicate: for (s1, p1, o1), cg in self.triples( (subject, pred, object_), context): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples( (subject, None, object_), context): yield (s1, p1, o1), cg def triples(self, triple_pattern, context=None): """ A generator over all the triples matching the pattern. Pattern can include any objects for used for comparing against nodes in the store, for example, REGEXTerm, URIRef, Literal, BNode, Variable, Graph, QuotedGraph, Date? DateRange? :param context: A conjunctive query can be indicated by either providing a value of None, or a specific context can be queries by passing a Graph instance (if store is context aware). """ subject, predicate, object = triple_pattern # variants of triples will be done if / when optimization is needed def __len__(self, context=None): """ Number of statements in the store. This should only account for non- quoted (asserted) statements if the context is not specified, otherwise it should return the number of statements in the formula or context given. :param context: a graph instance to query or None """ def contexts(self, triple=None): """ Generator over all contexts in the graph. If triple is specified, a generator over all contexts the triple is in. if store is graph_aware, may also return empty contexts :returns: a generator over Nodes """ def query(self, query, initNs, initBindings, queryGraph, **kwargs): """ If stores provide their own SPARQL implementation, override this. queryGraph is None, a URIRef or '__UNION__' If None the graph is specified in the query-string/object If URIRef it specifies the graph to query, If '__UNION__' the union of all named graphs should be queried (This is used by ConjunctiveGraphs Values other than None obviously only makes sense for context-aware stores.) """ raise NotImplementedError def update(self, update, initNs, initBindings, queryGraph, **kwargs): """ If stores provide their own (SPARQL) Update implementation, override this. queryGraph is None, a URIRef or '__UNION__' If None the graph is specified in the query-string/object If URIRef it specifies the graph to query, If '__UNION__' the union of all named graphs should be queried (This is used by ConjunctiveGraphs Values other than None obviously only makes sense for context-aware stores.) """ raise NotImplementedError # Optional Namespace methods def bind(self, prefix, namespace): """ """ def prefix(self, namespace): """ """ def namespace(self, prefix): """ """ def namespaces(self): """ """ if False: yield None # Optional Transactional methods def commit(self): """ """ def rollback(self): """ """ # Optional graph methods def add_graph(self, graph): """ Add a graph to the store, no effect if the graph already exists. :param graph: a Graph instance """ raise Exception("Graph method called on non-graph_aware store") def remove_graph(self, graph): """ Remove a graph from the store, this shoud also remove all triples in the graph :param graphid: a Graph instance """ raise Exception("Graph method called on non-graph_aware store")
class Store(object): #Properties context_aware = False formula_aware = False transaction_aware = False def __init__(self, configuration=None, identifier=None): """ identifier: URIRef of the Store. Defaults to CWD configuration: string containing infomation open can use to connect to datastore. """ self.__node_pickler = None self.dispatcher = Dispatcher() if configuration: self.open(configuration) def __get_node_pickler(self): if self.__node_pickler is None: from rdflib.store.NodePickler import NodePickler from rdflib.URIRef import URIRef from rdflib.BNode import BNode from rdflib.Literal import Literal from rdflib.Graph import Graph, QuotedGraph, GraphValue from rdflib.Variable import Variable from rdflib.Statement import Statement self.__node_pickler = np = NodePickler() np.register(self, "S") np.register(URIRef, "U") np.register(BNode, "B") np.register(Literal, "L") np.register(Graph, "G") np.register(QuotedGraph, "Q") np.register(Variable, "V") np.register(Statement, "s") np.register(GraphValue, "v") return self.__node_pickler node_pickler = property(__get_node_pickler) #Database management methods def create(self, configuration): self.dispatcher.dispatch( StoreCreatedEvent(configuration=configuration)) def open(self, configuration, create=False): """ Opens the store specified by the configuration string. If create is True a store will be created if it does not already exist. If create is False and a store does not already exist an exception is raised. An exception is also raised if a store exists, but there is insufficient permissions to open the store. This should return one of VALID_STORE,CORRUPTED_STORE,or NO_STORE """ return UNKNOWN def close(self, commit_pending_transaction=False): """ This closes the database connection. The commit_pending_transaction parameter specifies whether to commit all pending transactions before closing (if the store is transactional). """ def destroy(self, configuration): """ This destroys the instance of the store identified by the configuration string. """ def gc(self): """ Allows the store to perform any needed garbage collection """ pass #RDF APIs def add(self, xxx_todo_changeme, context, quoted=False): """ Adds the given statement to a specific context or to the model. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical It should be an error to not specify a context and have the quoted argument be True. It should also be an error for the quoted argument to be True when the store is not formula-aware. """ (subject, predicate, object) = xxx_todo_changeme self.dispatcher.dispatch( TripleAddedEvent(triple=(subject, predicate, object), context=context)) def addN(self, quads): """ Adds each item in the list of statements to a specific context. The quoted argument is interpreted by formula-aware stores to indicate this statement is quoted/hypothetical. Note that the default implementation is a redirect to add """ for s, p, o, c in quads: assert c is not None, "Context associated with %s %s %s is None!" % ( s, p, o) self.add((s, p, o), c) def remove(self, xxx_todo_changeme1, context=None): """ Remove the set of triples matching the pattern from the store """ (subject, predicate, object) = xxx_todo_changeme1 self.dispatcher.dispatch( TripleRemovedEvent(triple=(subject, predicate, object), context=context)) def triples_choices(self, xxx_todo_changeme2, context=None): """ A variant of triples that can take a list of terms instead of a single term in any slot. Stores can implement this to optimize the response time from the default 'fallback' implementation, which will iterate over each term in the list and dispatch to tripless """ (subject, predicate, object_) = xxx_todo_changeme2 if isinstance(object_, list): assert not isinstance(subject, list), "object_ / subject are both lists" assert not isinstance(predicate, list), "object_ / predicate are both lists" if object_: for obj in object_: for (s1, p1, o1), cg in self.triples( (subject, predicate, obj), context): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples( (subject, predicate, None), context): yield (s1, p1, o1), cg elif isinstance(subject, list): assert not isinstance(predicate, list), "subject / predicate are both lists" if subject: for subj in subject: for (s1, p1, o1), cg in self.triples( (subj, predicate, object_), context): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples( (None, predicate, object_), context): yield (s1, p1, o1), cg elif isinstance(predicate, list): assert not isinstance(subject, list), "predicate / subject are both lists" if predicate: for pred in predicate: for (s1, p1, o1), cg in self.triples( (subject, pred, object_), context): yield (s1, p1, o1), cg else: for (s1, p1, o1), cg in self.triples((subject, None, object_), context): yield (s1, p1, o1), cg def triples(self, xxx_todo_changeme3, context=None): """ A generator over all the triples matching the pattern. Pattern can include any objects for used for comparing against nodes in the store, for example, REGEXTerm, URIRef, Literal, BNode, Variable, Graph, QuotedGraph, Date? DateRange? A conjunctive query can be indicated by either providing a value of None for the context or the identifier associated with the Conjunctive Graph (if it's context aware). """ (subject, predicate, object) = xxx_todo_changeme3 pass # variants of triples will be done if / when optimization is needed def __len__(self, context=None): """ Number of statements in the store. This should only account for non-quoted (asserted) statements if the context is not specified, otherwise it should return the number of statements in the formula or context given. """ pass def contexts(self, triple=None): """ Generator over all contexts in the graph. If triple is specified, a generator over all contexts the triple is in. """ pass # Optional Namespace methods def bind(self, prefix, namespace): """ """ pass def prefix(self, namespace): """ """ pass def namespace(self, prefix): """ """ pass def namespaces(self): """ """ pass # Optional Transactional methods def commit(self): """ """ pass def rollback(self): """ """ pass