|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hp.hpl.jena.reasoner.transitiveReasoner.TransitiveGraphCache
public class TransitiveGraphCache
Datastructure used to represent a closed transitive reflexive relation. It (mostly) incrementally maintains a transitive reduction and transitive closure of the relationship and so queries should be faster than dynamically computing the closed or reduced relations.
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 | |
---|---|
TransitiveGraphCache(Node directPredicate,
Node closedPredicate)
Constructor - create a new cache to hold the given relation information. |
Method Summary | |
---|---|
void |
addRelation(Triple t)
Register a new relation instance in the cache |
boolean |
cacheAll(Finder graph,
Node predicate)
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. |
TransitiveGraphCache |
deepCopy()
Create a deep copy of the cache contents. |
java.lang.String |
dump()
Dump a description of the cache to a string for debug. |
ExtendedIterator |
find(TriplePattern pattern)
Basic pattern lookup interface. |
ExtendedIterator |
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. |
Node |
getClosedPredicate()
Returns the closedPredicate. |
Node |
getDirectPredicate()
Returns the directPredicate. |
boolean |
isSubject(Node node)
Return true if the given Node is registered as a subject node |
ExtendedIterator |
listAllSubjects()
Return an iterator over all registered subject nodes |
void |
removeRelation(Triple t)
Remove an instance of a relation from the cache. |
void |
setCaching(boolean enable)
Enable/disabling caching of the Triples representing the relationships. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TransitiveGraphCache(Node directPredicate, Node closedPredicate)
directPredicate
- The RDF predicate representing the direct relationclosedPredicate
- The RDF predicate representing the closed relationMethod Detail |
---|
public Node getClosedPredicate()
public Node getDirectPredicate()
public void addRelation(Triple t)
public void removeRelation(Triple t)
public ExtendedIterator findWithContinuation(TriplePattern pattern, Finder continuation)
In this case any query on the direct or closed predicates will be assumed complete, any other query will pass on to the continuation.
findWithContinuation
in interface Finder
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.public boolean contains(TriplePattern pattern)
contains
in interface Finder
public ExtendedIterator listAllSubjects()
public boolean isSubject(Node node)
public boolean cacheAll(Finder graph, Node predicate)
graph
- the searchable set of triples to cachepredicate
- the predicate to cache, need not be the registered
predicate due to subProperty declarations
public ExtendedIterator find(TriplePattern pattern)
find
in interface Finder
pattern
- a TriplePattern to be matched against the data
public TransitiveGraphCache deepCopy()
public void clear()
public void setCaching(boolean enable)
public java.lang.String dump()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |