|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hp.hpl.jena.reasoner.transitiveReasoner.TransitiveGraphCache
Datastructure used to represent a closed transitive reflexive relation. This should be more efficient than dynamically computing the relation from a triple store. Designed to be space efficient and not too time inefficient - though more work could be done to pick a real closure algorithm. The cost of space efficiency is that we have to reconstruct the triple set from the core graph which turns over a lot of storage.
The current implementation stores the direct relations as real graph (objects linked together by pointers). As relations are added redundant ones which could be reconstructed from the closure are dropped. To access the direct "minimal" version of the relation we just have to read out these links. To access the transitively closed version we have to walk the graph, however the results of these walks can be optionally cached (switch on using setCaching method). An alternative implementation would represent the closure using adjacency matrices and construct the complete closure in one go using the standard algorithm. This would be more efficient but require more space unless we have a good sparse binary matrix package.
Constructor Summary | |
TransitiveGraphCache(Node directPredicate,
Node closedPredicate)
Constructor - create a new cache to hold the given relation information. |
Method Summary | |
void |
addRelation(Node start,
Node end)
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. |
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 |
isProperty(Node node)
Return true if the given Node is registered as a property |
ExtendedIterator |
listAllProperties()
Return an iterator over all registered property nodes |
void |
removeRelation(Node start,
Node end)
Remove an instance of a relation from the cache. |
void |
setCaching(boolean cacheOn)
Switch on/off caching of transitive closures. |
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 void addRelation(Node start, Node end)
public void removeRelation(Node start, Node end)
public void clear()
public void setCaching(boolean cacheOn)
cacheOn
- set to true to start cache, to false to stop cachingpublic 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 boolean contains(TriplePattern pattern)
contains
in interface Finder
public ExtendedIterator listAllProperties()
public boolean isProperty(Node node)
public TransitiveGraphCache deepCopy()
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 Node getClosedPredicate()
public Node getDirectPredicate()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |