com.bigdata.rdf.rules
Class BackchainAccessPath

java.lang.Object
  extended by com.bigdata.rdf.rules.BackchainAccessPath
All Implemented Interfaces:
IAccessPath<ISPO>, Iterable<ISPO>

public class BackchainAccessPath
extends Object
implements IAccessPath<ISPO>

A read-only IAccessPath that backchains certain inferences.

Note: Low level methods may not behave quite as expected since some elements will be generated by the backchainer and hence present in the underlying SPORelation. See the notes on the various methods in the API for more details.

Version:
$Id: BackchainAccessPath.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static boolean DEBUG
           
protected static boolean INFO
           
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
BackchainAccessPath(AbstractTripleStore database, IAccessPath<ISPO> accessPath)
           
BackchainAccessPath(AbstractTripleStore database, IAccessPath<ISPO> accessPath, Boolean isOwlSameAsUsed)
           
 
Method Summary
 IIndex getIndex()
          The IIndex for the source IAccessPath.
 IKeyOrder<ISPO> getKeyOrder()
          The order in which the elements will be visited.
 IPredicate<ISPO> getPredicate()
          The constraints on the IAccessPath.
 IAccessPath<ISPO> getSource()
          The source IAccessPath.
 boolean isEmpty()
          True iff the access path is empty (there are no matches for the IPredicate) This is more conclusive than #rangeCount() since you MAY have a non-zero range count when the key range is in fact empty (there may be "deleted" index entries within the key range).
 IChunkedOrderedIterator<ISPO> iterator()
          Visits elements in the source IAccessPath plus all entailments licensed by the InferenceEngine.
 IChunkedOrderedIterator<ISPO> iterator(int limit, int capacity)
          Visits elements in the source IAccessPath plus all entailments licensed by the InferenceEngine as configured.
 IChunkedOrderedIterator<ISPO> iterator(long offset, long limit, int capacity)
          An iterator visiting elements using the natural order of the index selected for the IPredicate.
 long rangeCount(boolean exact)
          When exact == false this does not count the backchained entailments.
 ITupleIterator<ISPO> rangeIterator()
          Delegated to the source IAccessPath (does not visit any entailments).
 long removeAll()
          Delegated to the source IAccessPath.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final transient org.apache.log4j.Logger log

INFO

protected static final boolean INFO

DEBUG

protected static final boolean DEBUG
Constructor Detail

BackchainAccessPath

public BackchainAccessPath(AbstractTripleStore database,
                           IAccessPath<ISPO> accessPath)
Parameters:
database - The database whose entailments will be backchained.
accessPath - The source IAccessPath.

BackchainAccessPath

public BackchainAccessPath(AbstractTripleStore database,
                           IAccessPath<ISPO> accessPath,
                           Boolean isOwlSameAsUsed)
Parameters:
database - The database whose entailments will be backchained.
accessPath - The source IAccessPath.
isOwlSameAsUsed - When non-null, this Boolean indicates whether the statement pattern (x owl:sameAs y) is known to be empty in the data. Specify null if you do not know this up front. This parameter is used to factor out the test for this statement pattern, but that test is only performed if Axioms.isOwlSameAs() is true.
Method Detail

getSource

public final IAccessPath<ISPO> getSource()
The source IAccessPath.


getIndex

public final IIndex getIndex()
The IIndex for the source IAccessPath.

Specified by:
getIndex in interface IAccessPath<ISPO>

getKeyOrder

public final IKeyOrder<ISPO> getKeyOrder()
Description copied from interface: IAccessPath
The order in which the elements will be visited.

Specified by:
getKeyOrder in interface IAccessPath<ISPO>

getPredicate

public final IPredicate<ISPO> getPredicate()
Description copied from interface: IAccessPath
The constraints on the IAccessPath.

Specified by:
getPredicate in interface IAccessPath<ISPO>

isEmpty

public boolean isEmpty()
Description copied from interface: IAccessPath
True iff the access path is empty (there are no matches for the IPredicate) This is more conclusive than #rangeCount() since you MAY have a non-zero range count when the key range is in fact empty (there may be "deleted" index entries within the key range).

Specified by:
isEmpty in interface IAccessPath<ISPO>

iterator

public IChunkedOrderedIterator<ISPO> iterator()
Visits elements in the source IAccessPath plus all entailments licensed by the InferenceEngine.

Specified by:
iterator in interface IAccessPath<ISPO>
Specified by:
iterator in interface Iterable<ISPO>
Returns:
The iterator.
See Also:
IRelation.getAccessPath(IPredicate)

iterator

public IChunkedOrderedIterator<ISPO> iterator(long offset,
                                              long limit,
                                              int capacity)
Description copied from interface: IAccessPath
An iterator visiting elements using the natural order of the index selected for the IPredicate.

The offset and limit together describe an optional slice that will be visited by the iterator. When a slice is specified, the iterator will count off the elements accepted by the IPredicate up to the offset, but not materialize them. Elements by the IPredicate starting with the offset and up to (but not including) offset+limit will be materialized for the client. The iterator will halt processing after observing offset+limit accepted elements. Note that slices for JOINs (vs a simple IAccessPath scan) are handled by IQueryOptions for an IRule.

The meaning of "accepted" is that: (a) the elements lie in the key-range constraint implied by the IPredicate; and (b) the elements pass any optional constraints that the IPredicate imposes.

Specified by:
iterator in interface IAccessPath<ISPO>
Parameters:
offset - The first element accepted by the iterator that it will visit (materialize for the client). The offset must be non-negative. This is ZERO (0L) to visit all accepted elements.
limit - The last element accepted by the iterator that it will visit (materialize for the client). The limit must be non-negative. This is ZERO (0L) to visit all accepted elements (the value Long.MAX_VALUE is interpreted exactly like ZERO(0L)).
capacity - The maximum capacity for the buffer used by the iterator. When ZERO(0), a default capacity will be used. When a limit is specified, the capacity will never exceed the limit.
Returns:
The iterator. FIXME The offset and limit should probably be rolled into the predicate and removed from the IAccessPath. This way they will be correctly applied when IAccessPath.isEmpty() is implemented using the IAccessPath.iterator() to determine if any elements can be visited.
TODO:
handle non-zero offset and larger limits?

iterator

public IChunkedOrderedIterator<ISPO> iterator(int limit,
                                              int capacity)
Visits elements in the source IAccessPath plus all entailments licensed by the InferenceEngine as configured.

Specified by:
iterator in interface IAccessPath<ISPO>
Parameters:
limit - The maximum #of elements that will be visited -or- ZERO (0) if there is no limit.
capacity - The maximum capacity for the buffer used by the iterator. When ZERO(0), a default capacity will be used. When a limit is specified, the capacity will never exceed the limit.
Returns:
The iterator.

rangeCount

public long rangeCount(boolean exact)
When exact == false this does not count the backchained entailments. When exact == true traverses the iterator() so as to produce an exact count of the #of elements that would in fact be visited, which combines those from the database with those generated dynamically (NOT efficient).

Specified by:
rangeCount in interface IAccessPath<ISPO>
Parameters:
exact - When true, the result will be an exact count and may require a key-range scan. When false, the result will be an upper bound IFF delete markers are provisioned for the backing index (delete markers are required for transactions and for scale-out indices).
See Also:
IRangeQuery

rangeIterator

public ITupleIterator<ISPO> rangeIterator()
Delegated to the source IAccessPath (does not visit any entailments).

Specified by:
rangeIterator in interface IAccessPath<ISPO>

removeAll

public long removeAll()
Delegated to the source IAccessPath.

Specified by:
removeAll in interface IAccessPath<ISPO>
Returns:
The #of elements that were removed.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.