public class BackchainTypeResourceIterator extends Object implements IChunkedOrderedIterator<ISPO>
Note: You only need to do this on read from a high level query language since
the rest of the RDFS rules will run correctly without the (x rdf:type
rdfs:Resource) entailments being present. Further, you only need to do this
when the InferenceEngine
was instructed to NOT store the (x rdf:type
rdfs:Resource) entailments.
Note: This iterator will NOT generate an inferred (x rdf:type rdfs:Resource) entailment iff there is an explicit statement (x rdf:type rdfs:Resource) in the database.
InferenceEngine
,
InferenceEngine.Options
Modifier and Type | Class and Description |
---|---|
static class |
BackchainTypeResourceIterator.PushbackFilter<E>
Filterator style construct that allows push back of a single visited
element.
|
static class |
BackchainTypeResourceIterator.PushbackIterator<E>
Implementation class for
BackchainTypeResourceIterator.PushbackFilter . |
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
log |
DEFAULT_CHUNK_SIZE
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the iterator, releasing any associated resources.
|
IKeyOrder<ISPO> |
getKeyOrder()
The natural order in which elements are being visited.
|
boolean |
hasNext() |
static IChunkedOrderedIterator<ISPO> |
newInstance(IChunkedOrderedIterator<ISPO> _src,
IAccessPath<ISPO> accessPath,
AbstractTripleStore db,
IV rdfType,
IV rdfsResource)
Returns a suitably configured
BackchainTypeResourceIterator -or-
src iff the accessPath does not require the materialization
of (x rdf:type rdfs:Resource) entailments. |
ISPO |
next()
Visits all
SPO s visited by the source iterator and then begins to
backchain ( x rdf:type: rdfs:Resource ) statements. |
ISPO[] |
nextChunk()
Note: This method preserves the
IKeyOrder of the source iterator
iff it is reported by getKeyOrder() . |
ISPO[] |
nextChunk(IKeyOrder<ISPO> keyOrder)
Return the next "chunk" of elements.
|
void |
remove()
Note: You can not "remove" the backchained entailments.
|
public static IChunkedOrderedIterator<ISPO> newInstance(IChunkedOrderedIterator<ISPO> _src, IAccessPath<ISPO> accessPath, AbstractTripleStore db, IV rdfType, IV rdfsResource)
BackchainTypeResourceIterator
-or-
src iff the accessPath does not require the materialization
of (x rdf:type rdfs:Resource)
entailments._src
- The source iterator. nextChunk()
will sort statements
into the IKeyOrder
reported by this iterator (as long
as the IKeyOrder
is non-null
).accessPath
- The IAccessPath
from which the src iterator was
derived. Note that src is NOT necessarily equivalent to
IAccessPath.iterator()
since it MAY have been layered
already to backchain other entailments, e.g.,
owl:sameAs
.db
- The database from which we will read the distinct subject
identifiers from its SPORelation
. This parameter is
used iff this is an all unbound triple pattern.rdfType
- The term identifier that corresponds to rdf:Type for the
database.rdfsResource
- The term identifier that corresponds to rdf:Resource for the
database.(x rdf:type rdfs:Resource)
entailments.public IKeyOrder<ISPO> getKeyOrder()
IChunkedOrderedIterator
getKeyOrder
in interface IChunkedOrderedIterator<ISPO>
null
if not known.public void close()
ICloseableIterator
ICloseableIterator.close()
if Iterator.hasNext()
method returns false
to ensure that the iterator is closed
(and its resources release) as soon as it is exhausted.
Note: Implementations that support Iterator.remove()
MUST NOT
eagerly close the iterator when it is exhausted since that would make it
impossible to remove the last visited statement. Instead they MUST wait
for an explicit ICloseableIterator.close()
by the application.
close
in interface ICloseable
close
in interface ICloseableIterator<ISPO>
public ISPO next()
SPO
s visited by the source iterator and then begins to
backchain ( x rdf:type: rdfs:Resource ) statements.
The "backchain" scans two iterators: an IChunkedOrderedIterator
on ( ? rdf:type
rdfs:Resource )
that reads on the database (this tells us whether
we have an explicit (x rdf:type rdfs:Resource)
in the
database for a given subject) and iterator that reads on the term
identifiers for the distinct resources in the database (this bounds the
#of backchained statements that we will emit).
For each value visited by the resourceIds
iterator we examine
the statement iterator. If the next value that would be visited by the
statement iterator is an explicit statement for the current subject, then
we emit the explicit statement. Otherwise we emit an inferred statement.
public ISPO[] nextChunk()
IKeyOrder
of the source iterator
iff it is reported by getKeyOrder()
. Otherwise chunks read from
the source iterator will be in whatever order that iterator is using
while chunks containing backchained entailments will be in
SPOKeyOrder.POS
order.
Note: In order to ensure that a consistent ordering is always used within a chunk the backchained entailments will always begin on a chunk boundary.
nextChunk
in interface IChunkedIterator<ISPO>
public ISPO[] nextChunk(IKeyOrder<ISPO> keyOrder)
IChunkedOrderedIterator
IChunkedOrderedIterator.getKeyOrder()
would return non-null
and the request order corresponds to the value that would be returned by
IChunkedOrderedIterator.getKeyOrder()
then the elements in the next chunk are NOT
sorted. Otherwise the elements in the next chunk are sorted before they
are returned. The size of the chunk is up to the implementation.nextChunk
in interface IChunkedOrderedIterator<ISPO>
keyOrder
- The natural order for the elements in the chunk.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.