org.hypergraphdb.query.impl
Class RABasedPredicate

java.lang.Object
  extended by org.hypergraphdb.query.impl.RABasedPredicate
All Implemented Interfaces:
HGAtomPredicate, CloseMe

public class RABasedPredicate
extends java.lang.Object
implements HGAtomPredicate, CloseMe

Make a random access result set as a predicate. Random access result sets don't always have a constant time (like "true" random access structures), but are always assumed to have at least sublinear time. In other words, their goTo method should have complexity smaller than O(N). In practice, RA sets are usually B-Tree or "B-Forests" accessed in O(logN).

If an RABasedPredicate is initialized with a HGQuery instead of a result set, the query will be executed the first time satisfies is called.

The close method will only close the result set if this RABasedPredicate was created by calling the HGQuery based constructor.

Author:
Borislav Iordanov

Constructor Summary
RABasedPredicate(HGQuery query)
           
RABasedPredicate(HGRandomAccessResult ras)
           
 
Method Summary
 void close()
           
 boolean satisfies(HyperGraph hg, HGHandle handle)
          Return true if handle is a member of the HGRandomAccessResult set on which this predicate is based.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RABasedPredicate

public RABasedPredicate(HGRandomAccessResult ras)

RABasedPredicate

public RABasedPredicate(HGQuery query)
Method Detail

satisfies

public boolean satisfies(HyperGraph hg,
                         HGHandle handle)

Return true if handle is a member of the HGRandomAccessResult set on which this predicate is based. Return false otherwise.

Specified by:
satisfies in interface HGAtomPredicate
Parameters:
hg - The HyperGraph instance.
handle - The atom on which to test the query condition.
Returns:
true if the passed in parameter satisfies the condition and false otherwise.

close

public void close()
Specified by:
close in interface CloseMe