|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.relation.AbstractResource<IRelation<E>>
com.bigdata.relation.AbstractRelation<ISPO>
com.bigdata.rdf.spo.SPORelation
public class SPORelation
The SPORelation handles all things related to the indices
representing the triples stored in the database. Statements are first
converted to term identifiers using the LexiconRelation and then
inserted into the statement indices in parallel. There is one statement index
for each of the three possible access paths for a triple store. The key is
formed from the corresponding permutation of the subject, predicate, and
object, e.g., {s,p,o}, {p,o,s}, and {o,s,p} for triples or {s,p,o,c}, etc for
quads. The statement type (inferred, axiom, or explicit) and the optional
statement identifier are stored under the key. All state for a statement is
replicated in each of the statement indices.
* @todo integration with package providing magic set rewrites of rules in order
to test whether or not a statement is still provable when it is
retracted during TM. this will reduce the cost of loading data, since
much of that is writing the justifications index.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.bigdata.relation.AbstractResource |
|---|
AbstractResource.Options |
| Field Summary | |
|---|---|
protected boolean |
bloomFilter
true iff the SPO index will maintain a bloom filter. |
boolean |
justify
This is used to conditionally enable the logic to retract justifications when the corresponding statements is retracted. |
protected static org.apache.log4j.Logger |
log
|
static String |
NAME_SPO_RELATION
Constant for the SPORelation namespace component. |
boolean |
oneAccessPath
This is used to conditionally disable all but a single statement index (aka access path). |
boolean |
statementIdentifiers
When true the database will support statement identifiers. |
| Constructor Summary | |
|---|---|
SPORelation(IIndexManager indexManager,
String namespace,
Long timestamp,
Properties properties)
|
|
| Method Summary | |
|---|---|
long |
addJustifications(IChunkedIterator<Justification> itr)
Adds justifications to the store. |
void |
create()
Create any logically contained resources (relations, indices). |
long |
delete(IChunkedOrderedIterator<ISPO> itr)
Deletes SPOs, writing on the statement indices in parallel. |
long |
delete(ISPO[] stmts,
int numStmts)
Delete the SPOs from the statement indices. |
void |
destroy()
Destroy any logically contained resources (relations, indices). |
ICloseableIterator<ISPO> |
distinctSPOIterator(ICloseableIterator<ISPO> src)
Return an iterator that will visit the distinct (s,p,o) tuples in the source iterator. |
IChunkedIterator<Long> |
distinctTermScan(IKeyOrder<ISPO> keyOrder)
Efficient scan of the distinct term identifiers that appear in the first position of the keys for the statement index corresponding to the specified IKeyOrder. |
IChunkedIterator<Long> |
distinctTermScan(IKeyOrder<ISPO> keyOrder,
ITermIdFilter termIdFilter)
Efficient scan of the distinct term identifiers that appear in the first position of the keys for the statement index corresponding to the specified IKeyOrder. |
StringBuilder |
dump(IKeyOrder<ISPO> keyOrder)
Dumps the specified index. |
boolean |
exists()
|
SPOAccessPath |
getAccessPath(IKeyOrder<ISPO> keyOrder,
IPredicate<ISPO> predicate)
Core impl. |
IAccessPath<ISPO> |
getAccessPath(IPredicate<ISPO> predicate)
Return the IAccessPath that is most efficient for the specified
predicate based on an analysis of the bound and unbound positions in the
predicate. |
IAccessPath<ISPO> |
getAccessPath(long s,
long p,
long o)
Deprecated. by getAccessPath(long, long, long, long) |
IAccessPath<ISPO> |
getAccessPath(long s,
long p,
long o,
long c)
Return the access path for a triple or quad pattern with an optional filter. |
IAccessPath<ISPO> |
getAccessPath(long s,
long p,
long o,
long c,
IElementFilter<ISPO> filter)
Return the access path for a triple or quad pattern with an optional filter (core implementation). |
AbstractTripleStore |
getContainer()
Strengthened return type. |
Class<ISPO> |
getElementClass()
Return the class for the generic type of this relation. |
IIndex |
getIndex(IKeyOrder<? extends ISPO> keyOrder)
Overridden to return the hard reference for the index, which is cached the first time it is resolved. |
Set<String> |
getIndexNames()
Return the fully qualified name of each index maintained by this relation. |
IIndex |
getJustificationIndex()
The optional index on which Justifications are stored. |
protected IndexMetadata |
getJustIndexMetadata(String name)
Overrides for the IRawTripleStore#getJustificationIndex(). |
int |
getKeyArity()
The arity of the key for the statement indices: 3 is a
triple store, with or without statement identifiers; 4 is a
quad store, which does not support statement identifiers as the 4th
position of the (s,p,o,c) is interpreted as context and located in the
B+Tree statement index key rather than the value associated with the key. |
IIndex |
getPrimaryIndex()
|
SPOKeyOrder |
getPrimaryKeyOrder()
|
BTree |
getSPOOnlyBTree(boolean bloomFilter)
Return a new unnamed BTree instance for the
SPOKeyOrder.SPO key order backed by a TemporaryStore. |
boolean |
getStatementIdentifiers()
When true the database will support statement identifiers. |
protected IndexMetadata |
getStatementIndexMetadata(SPOKeyOrder keyOrder)
Overrides for the statement indices. |
long |
insert(IChunkedOrderedIterator<ISPO> itr)
Inserts SPOs, writing on the statement indices in parallel. |
long |
insert(ISPO[] a,
int numStmts,
IElementFilter<ISPO> filter)
Note: The statements are inserted into each index in parallel. |
SPO |
newElement(IPredicate<ISPO> predicate,
IBindingSet bindingSet)
Create and return a new element. |
Iterator<SPOKeyOrder> |
statementKeyOrderIterator()
Return an iterator visiting each IKeyOrder maintained by this
relation. |
| Methods inherited from class com.bigdata.relation.AbstractRelation |
|---|
getFQN, getIndex, newIndexMetadata |
| Methods inherited from class com.bigdata.relation.AbstractResource |
|---|
acquireExclusiveLock, getChunkCapacity, getChunkOfChunksCapacity, getChunkTimeout, getContainerNamespace, getExecutorService, getFullyBufferedReadThreshold, getIndexManager, getMaxParallelSubqueries, getNamespace, getProperties, getProperty, getProperty, getTimestamp, isForceSerialExecution, isNestedSubquery, toString, unlock |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.bigdata.relation.IRelation |
|---|
getExecutorService, getIndexManager |
| Methods inherited from interface com.bigdata.relation.locator.ILocatableResource |
|---|
getContainerNamespace, getNamespace, getTimestamp |
| Field Detail |
|---|
protected static final transient org.apache.log4j.Logger log
public static final String NAME_SPO_RELATION
SPORelation namespace component.
Note: To obtain the fully qualified name of an index in the
SPORelation you need to append a "." to the relation's namespace,
then this constant, then a "." and then the local name of the index.
AbstractRelation.getFQN(IKeyOrder),
Constant Field Valuespublic final boolean justify
public final boolean oneAccessPath
protected final boolean bloomFilter
true iff the SPO index will maintain a bloom filter.
Options#BLOOM_FILTERpublic final boolean statementIdentifiers
true the database will support statement identifiers.
A statement identifier is a unique 64-bit integer taken from the same
space as the term identifiers and which uniquely identifiers a statement
in the database regardless of the graph in which that statement appears.
The purpose of statement identifiers is to allow statements about
statements without recourse to RDF style reification.
| Constructor Detail |
|---|
public SPORelation(IIndexManager indexManager,
String namespace,
Long timestamp,
Properties properties)
| Method Detail |
|---|
public int getKeyArity()
3 is a
triple store, with or without statement identifiers; 4 is a
quad store, which does not support statement identifiers as the 4th
position of the (s,p,o,c) is interpreted as context and located in the
B+Tree statement index key rather than the value associated with the key.
public boolean getStatementIdentifiers()
true the database will support statement identifiers.
A statement identifier is a unique 64-bit integer taken from the same space as the term identifiers and which uniquely identifiers a statement in the database regardless of the graph in which that statement appears. The purpose of statement identifiers is to allow statements about statements without recourse to RDF style reification.
Only explicit statements will have a statement identifier. Statements made about statements using their statement identifiers will automatically be retracted if a statement they describe is retracted (a micro form of truth maintenance that is always enabled when statement identifiers are enabled).
public AbstractTripleStore getContainer()
getContainer in class AbstractResource<IRelation<ISPO>>null if there is no container.public boolean exists()
LocalTripleStore
constructor and a unit test's main() method. This method
IS NOT part of any public API at this time.public void create()
IMutableResource
create in interface IMutableResource<IRelation<ISPO>>create in class AbstractResource<IRelation<ISPO>>public void destroy()
IMutableResource
destroy in interface IMutableResource<IRelation<ISPO>>destroy in class AbstractResource<IRelation<ISPO>>public IIndex getIndex(IKeyOrder<? extends ISPO> keyOrder)
ITx.UNISOLATED AbstractTask where the index was not
declared and hence can not be materialized.
getIndex in class AbstractRelation<ISPO>keyOrder - The natural index order.
null iff the index does not exist
as of the timestamp for this view of the relation.FIXME For efficiency the concrete implementations need to override this
saving a hard reference to the index and then using a switch like
construct to return the correct hard reference. This behavior should be
encapsulated.public final SPOKeyOrder getPrimaryKeyOrder()
public final IIndex getPrimaryIndex()
public final IIndex getJustificationIndex()
Justifications are stored.
This would cause the justification index namespace to change to be a peer of the SPORelation namespace.
public ICloseableIterator<ISPO> distinctSPOIterator(ICloseableIterator<ISPO> src)
ISPOs. The iterator will be backed by a
BTree on a TemporaryStore and will use a bloom filter for
fast point tests. The BTree and the source iterator will be
closed when the returned iterator is closed.
src - The source iterator.
public BTree getSPOOnlyBTree(boolean bloomFilter)
BTree instance for the
SPOKeyOrder.SPO key order backed by a TemporaryStore. The
index will only store (s,p,o) triples (not quads) and will not store
either the SID or StatementEnum. This is a good choice when you
need to impose a "distinct" filter on (s,p,o) triples.
bloomFilter - When true, a bloom filter is enabled for the
index. The bloom filter provides fast correct rejection tests
for point lookups up to ~2M triples and then shuts off
automatically. See BloomFilterFactory.DEFAULT for more
details.
protected IndexMetadata getStatementIndexMetadata(SPOKeyOrder keyOrder)
protected IndexMetadata getJustIndexMetadata(String name)
IRawTripleStore#getJustificationIndex().
public Set<String> getIndexNames()
IRelation
public Iterator<SPOKeyOrder> statementKeyOrderIterator()
IKeyOrder maintained by this
relation.
public IAccessPath<ISPO> getAccessPath(long s,
long p,
long o)
getAccessPath(long, long, long, long)
s - p - o -
UnsupportedOperationException - unless the getKeyArity() is 3.
public IAccessPath<ISPO> getAccessPath(long s,
long p,
long o,
long c)
public IAccessPath<ISPO> getAccessPath(long s,
long p,
long o,
long c,
IElementFilter<ISPO> filter)
s - The subject position (optional).p - The predicate position (optional).o - The object position (optional).c - The context position (optional and ignored for a triple
store).filter - The filter (optional).
UnsupportedOperationException - for a triple store without statement identifiers if the
c is non-NULL.public IAccessPath<ISPO> getAccessPath(IPredicate<ISPO> predicate)
IAccessPath that is most efficient for the specified
predicate based on an analysis of the bound and unbound positions in the
predicate.
Note: When statement identifiers are enabled, the only way to bind the
context position is to already have an SPO on hand. There is no
index which can be used to look up an SPO by its context and the
context is always a blank node.
Note: This method is a hot spot, especially when the maximum parallelism for subqueries is large. A variety of caching techniques are being evaluated to address this.
pred - The predicate.
public SPOAccessPath getAccessPath(IKeyOrder<ISPO> keyOrder,
IPredicate<ISPO> predicate)
keyOrder - The natural order of the selected index (this identifies the
index).predicate - The predicate specifying the query constraint on the access
path.
public IChunkedIterator<Long> distinctTermScan(IKeyOrder<ISPO> keyOrder)
IKeyOrder. For example, using SPOKeyOrder.POS
will give you the term identifiers for the distinct predicates actually
in use within statements in the SPORelation.
keyOrder - The selected index order.
public IChunkedIterator<Long> distinctTermScan(IKeyOrder<ISPO> keyOrder,
ITermIdFilter termIdFilter)
IKeyOrder. For example, using SPOKeyOrder.POS
will give you the term identifiers for the distinct predicates actually
in use within statements in the SPORelation.
keyOrder - The selected index order.
public SPO newElement(IPredicate<ISPO> predicate,
IBindingSet bindingSet)
IRelationISolution for an IRule during either a query or mutation
operations. The element is NOT inserted into the relation.
predicate - The predicate that is the head of some IRule.bindingSet - A set of bindings for that IRule.
public Class<ISPO> getElementClass()
IRelation
public long insert(IChunkedOrderedIterator<ISPO> itr)
SPOs, writing on the statement indices in parallel.
Note: This does NOT write on the justifications index. If justifications
are being maintained then the ISolutions MUST report binding
sets and an AbstractSolutionBuffer.InsertSolutionBuffer MUST be used that knows how to
write on the justifications index AND delegate writes on the statement
indices to this method.
Note: This does NOT assign statement identifiers. The SPORelation
does not have direct access to the LexiconRelation and the latter
is responsible for assigning term identifiers. Code that writes explicit
statements onto the statement indices MUST use
AbstractTripleStore.addStatements(AbstractTripleStore, boolean, IChunkedOrderedIterator, IElementFilter),
which knows how to generate the statement identifiers. In turn, that
method will delegate each "chunk" to this method.
itr - An iterator visiting the elements to be written.
public long delete(IChunkedOrderedIterator<ISPO> itr)
SPOs, writing on the statement indices in parallel.
Note: This does NOT write on the justifications index. If justifications
are being maintained then the ISolutions MUST report binding
sets and an AbstractSolutionBuffer.InsertSolutionBuffer MUST be used that knows how to
write on the justifications index AND delegate writes on the statement
indices to this method.
Note: This does NOT perform truth maintenance!
Note: This does NOT compute the closure for statement identifiers (statements that need to be deleted because they are about a statement that is being deleted).
itr - An iterator visiting the elements to be removed. Existing
elements in the relation having a key equal to the key formed
from the visited elements will be removed from the relation.
AbstractTripleStore.removeStatements(IChunkedOrderedIterator, boolean),
SPOAccessPath.removeAll()
public long insert(ISPO[] a,
int numStmts,
IElementFilter<ISPO> filter)
a - An SPO[].numStmts - The #of elements of that array that will be written.filter - An optional filter on the elements to be written.
public long delete(ISPO[] stmts,
int numStmts)
SPOs from the statement indices. Any justifications
for those statements will also be deleted.
stmts - The SPOs.numStmts - The #of elements in that array to be processed.
BatchRemove only removes those
statements that it finds and that there is no constraint in place to
assure that this method only sees SPOs known to exist (but
perhaps it does since you can only do this safely for explicit
statements).public long addJustifications(IChunkedIterator<Justification> itr)
itr - The iterator from which we will read the Justifications
to be added. The iterator is closed by this operation.
Justifications written on the justifications
index.public StringBuilder dump(IKeyOrder<ISPO> keyOrder)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||