Class TransitiveGraphCache
- All Implemented Interfaces:
Finder
The implementation stores the reduced and closed relations as real graph (objects linked together by pointers). For each graph node we store its direct predecessors and successors and its closed successors. A cost penalty is the storage turnover involved in turning the graph representation back into triples to answer queries. We could avoid this by optionally also storing the manifested triples for the links.
Cycles are currently handled by collapsing strongly connected components. Incremental deletes would be possible but at the price of substanially more storage and code complexity. We compromise by doing the easy cases incrementally but some deletes (those that break strongly connected components) will trigger a fresh rebuild.
TODO Combine this with interval indexes (Agrawal, Borigda and Jagadish 1989) for storing the closure of the predecessor relationship. Typical graphs will be nearly tree shaped so the successor closure is modest (L^2 where L is the depth of the tree branch) but the predecessor closure would be expensive. The interval index would handle predecessor closure nicely.
-
Constructor Summary
ConstructorDescriptionTransitiveGraphCache
(Node directPredicate, Node closedPredicate) Constructor - create a new cache to hold the given relation information. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Register a new relation instance in the cacheboolean
Cache all instances of the given predicate which are present in the given Graph.void
clear()
Clear the entire cache contents.boolean
contains
(TriplePattern pattern) Return true if the given pattern occurs somewhere in the find sequence.deepCopy()
Create a deep copy of the cache contents.dump()
Dump a description of the cache to a string for debug.find
(TriplePattern pattern) Basic pattern lookup interface.findWithContinuation
(TriplePattern pattern, Finder continuation) Extended find interface used in situations where the implementator may or may not be able to answer the complete query.Returns the closedPredicate.Returns the directPredicate.boolean
Return true if the given Node is registered as a subject nodeReturn an iterator over all registered subject nodesvoid
Remove an instance of a relation from the cache.void
setCaching
(boolean enable) Enable/disabling caching of the Triples representing the relationships.
-
Constructor Details
-
TransitiveGraphCache
Constructor - create a new cache to hold the given relation information.- Parameters:
directPredicate
- The RDF predicate representing the direct relationclosedPredicate
- The RDF predicate representing the closed relation
-
-
Method Details
-
getClosedPredicate
Returns the closedPredicate.- Returns:
- Node
-
getDirectPredicate
Returns the directPredicate.- Returns:
- Node
-
addRelation
Register a new relation instance in the cache -
removeRelation
Remove an instance of a relation from the cache. -
findWithContinuation
Extended find interface used in situations where the implementator may or may not be able to answer the complete query.In this case any query on the direct or closed predicates will be assumed complete, any other query will pass on to the continuation.
- Specified by:
findWithContinuation
in interfaceFinder
- Parameters:
pattern
- a TriplePattern to be matched against the datacontinuation
- either a Finder or a normal Graph which will be asked for additional match results if the implementor may not have completely satisfied the query.
-
contains
Return true if the given pattern occurs somewhere in the find sequence. -
listAllSubjects
Return an iterator over all registered subject nodes -
isSubject
Return true if the given Node is registered as a subject node -
cacheAll
Cache all instances of the given predicate which are present in the given Graph.- Parameters:
graph
- the searchable set of triples to cachepredicate
- the predicate to cache, need not be the registered predicate due to subProperty declarations- Returns:
- returns true if new information has been cached
-
find
Basic pattern lookup interface. -
deepCopy
Create a deep copy of the cache contents. Works by creating a completely new cache and just adding in the direct links. -
clear
public void clear()Clear the entire cache contents. -
setCaching
public void setCaching(boolean enable) Enable/disabling caching of the Triples representing the relationships. If this is enabled then a number of triples quadratic in the graph depth will be stored. If it is disabled then all queries will turn over storage dynamically creating the result triples. -
dump
Dump a description of the cache to a string for debug.
-