public abstract class AbstractTripleStore extends AbstractResource<IDatabase<AbstractTripleStore>> implements ITripleStore, IRawTripleStore, IMutableDatabase<AbstractTripleStore>
ITripleStore
interface that is invariant across the choice of the backing store.
By default, this class supports RDFS inference plus optional support for
owl:sameAs
, owl:equivalentProperty
, and
owl:equivalentClass
. The IRule
s are declarative, and
it is easy to write new rules. Those IRule
s can be introduced using
custom BaseClosure
implementations. See AbstractTripleStore.Options.CLOSURE_CLASS
.
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractTripleStore.Options
Configuration options.
|
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEBUG |
protected static boolean |
INFO |
protected boolean |
lexicon
This is used to conditionally disable the lexicon support, principally in
conjunction with a
TempTripleStore . |
indexManager
NULLSTR
Modifier | Constructor and Description |
---|---|
protected |
AbstractTripleStore(IIndexManager indexManager,
String namespace,
Long timestamp,
Properties properties)
Ctor specified by
DefaultResourceLocator . |
Modifier and Type | Method and Description |
---|---|
void |
__tearDownUnitTest()
DO NOT INVOKE FROM APPLICATION CODE - this method
deletes the KB instance and destroys the backing database instance.
|
void |
abort()
Clears hard references to any indices, relations, etc.
|
void |
addNamespace(String namespace,
String prefix)
Defines a transient mapping from a URI to a namespace prefix that will be
used for that URI by
AbstractResource.toString() . |
void |
addStatement(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o) |
void |
addStatement(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c)
Add a single
StatementEnum.Explicit statement by lookup and/or
insert into the various indices (non-batch api). |
long |
addStatements(AbstractTripleStore statementStore,
boolean copyOnly,
IChunkedOrderedIterator<ISPO> itr,
IElementFilter<ISPO> filter)
Add statements to the statementStore.
|
long |
addStatements(IChunkedOrderedIterator<ISPO> itr,
IElementFilter<ISPO> filter)
Writes the statements onto the statement indices (batch, parallel, NO
truth maintenance).
|
long |
addStatements(ISPO[] stmts,
int numStmts)
Writes the statements onto the statements indices (batch, parallel, NO
truth maintenance).
|
long |
addStatements(ISPO[] stmts,
int numStmts,
IElementFilter<ISPO> filter)
Writes the statements onto the statement indices (batch, parallel, NO
truth maintenance).
|
IV |
addTerm(org.openrdf.model.Value value)
Add a term into the term:id index and the id:term index, returning the
assigned term identifier (non-batch API).
|
void |
addTerms(BigdataValue[] terms)
Batch insert of terms into the database.
|
BigdataStatement |
asStatement(ISPO spo)
Convert an internal
ISPO into a Sesame Statement . |
BigdataStatementIterator |
asStatementIterator(IChunkedOrderedIterator<ISPO> src)
Wraps an
IChunkedOrderedIterator as a
BigdataStatementIterator . |
BigdataValue |
asValue(org.openrdf.model.Value value)
Converts a
BigdataValue to a Sesame Value object. |
IChunkedOrderedIterator<ISPO> |
bulkCompleteStatements(IChunkedOrderedIterator<ISPO> itr)
This method fills out the statement metadata (type and sid) for
ISPO s that are present in the database. |
ISPO[] |
bulkCompleteStatements(ISPO[] stmts) |
IChunkedOrderedIterator<ISPO> |
bulkCompleteStatements(SPO[] stmts,
int numStmts) |
IChunkedOrderedIterator<ISPO> |
bulkFilterStatements(IChunkedOrderedIterator<ISPO> itr,
boolean present)
Efficiently filter the supplied set of
SPO objects for whether
they are "present" or "not present" in the database, depending on the
value of the supplied boolean variable (batch api). |
IChunkedOrderedIterator<ISPO> |
bulkFilterStatements(ISPO[] stmts,
int numStmts,
boolean present)
Filter the supplied set of
ISPO objects for whether they are
"present" or "not present" in the database, depending on the value of the
supplied boolean variable (batch API). |
void |
clearNamespaces()
Clears the namespace map.
|
void |
close()
Close the connection to the
ITripleStore . |
long |
commit()
Commit changes on the database.
|
IChunkedOrderedIterator<ISPO> |
computeClosureForStatementIdentifiers(IChunkedOrderedIterator<ISPO> src)
Return an iterator which will visit the closure of the statements visited
by the source iterator plus any statements in the database made using a
statement identifier found on any of the statements visited by the source
iterator (only explicit statements have statement identifiers and then
iff
statementIdentifiers are enabled). |
long |
copyStatements(AbstractTripleStore dst,
IElementFilter<ISPO> filter,
boolean copyJustifications)
Copies the statements from this store into the specified store
using the same term identifiers (the lexicon is neither
copied to nor asserted on the target).
|
long |
copyStatements(AbstractTripleStore dst,
IElementFilter<ISPO> filter,
boolean copyJustifications,
IChangeLog changeLog) |
void |
create()
Create any logically contained resources (relations, indices).
|
void |
destroy()
Destroy any logically contained resources (relations, indices).
|
protected Class |
determineAxiomClass() |
protected Class |
determineVocabularyClass() |
StringBuilder |
dumpStatements(IAccessPath<ISPO> accessPath)
Dumps the access path, efficiently resolving term identifiers to terms.
|
StringBuilder |
dumpStore()
Utility method dumps the statements in the store using the SPO index
(subject order).
|
StringBuilder |
dumpStore(AbstractTripleStore resolveTerms,
boolean explicit,
boolean inferred,
boolean axioms) |
StringBuilder |
dumpStore(AbstractTripleStore resolveTerms,
boolean explicit,
boolean inferred,
boolean axioms,
boolean justifications)
Dumps the store in a human readable format (not suitable for
interchange).
|
StringBuilder |
dumpStore(AbstractTripleStore resolveTerms,
boolean explicit,
boolean inferred,
boolean axioms,
boolean history,
boolean justifications) |
StringBuilder |
dumpStore(AbstractTripleStore resolveTerms,
boolean explicit,
boolean inferred,
boolean axioms,
boolean history,
boolean justifications,
boolean sids,
IKeyOrder<ISPO> keyOrder)
Dumps the store in a human readable format (not suitable for
interchange).
|
StringBuilder |
dumpStore(boolean history) |
StringBuilder |
dumpStore(boolean explicit,
boolean inferred,
boolean axioms) |
static void |
fixPointStatementIdentifiers(AbstractTripleStore db,
AbstractTripleStore tempStore)
Computes the fixed point of those statements in the database which make
assertions about statement identifiers in the tmp store.
|
IAccessPath<ISPO> |
getAccessPath(IKeyOrder<ISPO> keyOrder)
Return the
IAccessPath for the specified IKeyOrder and a
fully unbound triple pattern. |
IAccessPath<ISPO> |
getAccessPath(IKeyOrder<ISPO> keyOrder,
IElementFilter<ISPO> filter) |
IAccessPath<ISPO> |
getAccessPath(IV s,
IV p,
IV o)
Chooses and returns the best
IAccessPath for the given triple
pattern. |
IAccessPath<ISPO> |
getAccessPath(IV s,
IV p,
IV o,
IElementFilter<ISPO> filter) |
IAccessPath<ISPO> |
getAccessPath(IV s,
IV p,
IV o,
IV c) |
IAccessPath<ISPO> |
getAccessPath(IV s,
IV p,
IV o,
IV c,
IElementFilter<ISPO> filter) |
IAccessPath<ISPO> |
getAccessPath(IV s,
IV p,
IV o,
IV c,
RangeBOp range) |
IAccessPath<ISPO> |
getAccessPath(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o) |
IAccessPath<ISPO> |
getAccessPath(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
IElementFilter<ISPO> filter) |
IAccessPath<ISPO> |
getAccessPath(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c)
Returns an
IAccessPath matching the triple pattern. |
IAccessPath<ISPO> |
getAccessPath(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c,
IElementFilter<ISPO> filter,
RangeBOp range) |
Axioms |
getAxioms()
The configured axioms.
|
long |
getBNodeCount()
The #of BNodes in the lexicon (this is not specific to any named graph).
|
BaseClosure |
getClosureInstance()
Return an instance of the class that is used to compute the closure of
the database.
|
DataLoader |
getDataLoader()
Return a
DataLoader singleton configured using the properties
that were used to configure the database. |
long |
getExplicitStatementCount(org.openrdf.model.Resource c)
The #of explicit statements in the database (exact count based on
key-range scan).
|
GeoSpatialConfig |
getGeoSpatialConfig()
Return the configured
GeoSpatialConfig . |
InferenceEngine |
getInferenceEngine()
Return an
InferenceEngine singleton configured using the
properties that were used to configure the database. |
IV |
getIV(org.openrdf.model.Value value)
Deprecated.
Not even the unit tests should be doing this.
|
long |
getJustificationCount() |
LexiconRelation |
getLexiconRelation()
The
LexiconRelation handles all things related to the indices
mapping RDF Value s onto internal 64-bit term identifiers. |
long |
getLiteralCount()
The #of Literals in the lexicon (this is not specific to any named
graph).
|
protected Program |
getMatchProgram(org.openrdf.model.Literal[] lits,
IConstant<IV>[] _preds,
IV _cls)
Generate a program from the possible completions of the literals.
|
long |
getNamedGraphCount()
The #of named graphs.
|
String |
getNamespace(String prefix)
Return the namespace for the given prefix.
|
Map<String,String> |
getNamespaces()
Return an unmodifiable view of the mapping from namespaces to namespace
prefixes.
|
IPredicate<ISPO> |
getPredicate(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o) |
IPredicate<ISPO> |
getPredicate(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c) |
IPredicate<ISPO> |
getPredicate(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c,
IElementFilter<ISPO> filter,
RangeBOp range)
Convert a Sesame Value based triple pattern into a bigdata Predicate.
|
RDRHistory |
getRDRHistoryInstance()
Return an instance of the
RDRHistory class. |
int |
getSPOKeyArity()
Indicate whether this is a triple or a quad store (3 is a triple store, 4
is a quad store).
|
SPORelation |
getSPORelation()
The
SPORelation (triples and their access paths). |
ISPO |
getStatement(IV s,
IV p,
IV o) |
ISPO |
getStatement(IV s,
IV p,
IV o,
IV c)
Return the statement from the database (fully bound s:p:o only).
|
BigdataStatement |
getStatement(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o) |
BigdataStatement |
getStatement(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c)
Return the statement from the database matching the fully bound query.
|
BigdataStatement |
getStatement(org.openrdf.model.Statement s) |
long |
getStatementCount()
The #of triples in the store.
|
long |
getStatementCount(boolean exact)
The #of triples in the store.
|
long |
getStatementCount(org.openrdf.model.Resource c)
The #of triples in the named graph, or in the database if c is not
specified.
|
long |
getStatementCount(org.openrdf.model.Resource c,
boolean exact)
The #of triples in the named graph or in the database if no context is
specified.
|
boolean |
getStatementIdentifiers()
When
true the database will support statement identifiers. |
BigdataStatementIterator |
getStatements(IChunkedOrderedIterator<BigdataTriplePattern> triplePatterns)
Efficient batched, streaming resolution of triple patterns to statements
spanned by those triple patterns that are present in the data.
|
BigdataStatementIterator |
getStatements(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o) |
BigdataStatementIterator |
getStatements(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c)
Return an iterator that will visit all
BigdataStatement s in the
database matching the triple pattern. |
BigdataValue |
getTerm(IV iv)
This method is extremely inefficient for scale-out as it does one RMI per
request!
|
long |
getTermCount()
The #of RDF
Value s in the lexicon (this is not specific to any
named graph). |
long |
getURICount()
The #of URIs in the lexicon (this is not specific to any named graph).
|
BigdataValueFactory |
getValueFactory()
The
BigdataValueFactoryImpl for namespace of the
LexiconRelation associated with this AbstractTripleStore . |
Vocabulary |
getVocabulary()
Return the configured
Vocabulary . |
boolean |
hasStatement(IV s,
IV p,
IV o)
Deprecated.
|
boolean |
hasStatement(IV s,
IV p,
IV o,
IV c)
Return true if the statement pattern matches any statement(s) in the store
(non-batch API).
|
boolean |
hasStatement(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o)
This method is extremely inefficient for scale-out as it does one RMI per
request!
|
boolean |
hasStatement(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c)
Return true if the triple pattern matches any statements in the store
(non-batch API).
|
AbstractTripleStore |
init()
The default implementation only logs the event.
|
boolean |
isAxiom(IV s,
IV p,
IV o)
Return
true iff the fully bound statement is an axiom. |
boolean |
isBottomUpEvaluation() |
abstract boolean |
isConcurrent()
Return
true iff the store is safe for concurrent readers
and writers. |
boolean |
isConstrainXXXCShards() |
boolean |
isInlineLiterals()
Returns
true when the database is in inline terms mode. |
boolean |
isJustify()
True iff justification chains are being recorded for entailments and used
to support truth maintenance.
|
boolean |
isOpen() |
boolean |
isQuads()
Return
true iff this is a quad store. |
boolean |
isRDRHistory()
Return true if the RDR history feature is enabled (experimental).
|
abstract boolean |
isStable()
True iff the backing store is stable (exists on disk somewhere and may be
closed and re-opened).
|
boolean |
isStatementIdentifiers()
When
true the database will support statement identifiers. |
ICloseableIterator<IBindingSet> |
match(org.openrdf.model.Literal[] lits,
org.openrdf.model.URI[] preds,
org.openrdf.model.URI cls)
Specialized
IRule execution using the full text index to identify
possible completions of the given literals for which there exists a
subject s such that: |
IJoinNexusFactory |
newJoinNexusFactory(RuleContextEnum ruleContext,
ActionEnum action,
int solutionFlags,
IElementFilter filter) |
IJoinNexusFactory |
newJoinNexusFactory(RuleContextEnum ruleContext,
ActionEnum action,
int solutionFlags,
IElementFilter filter,
boolean justify,
boolean backchain,
IEvaluationPlanFactory planFactory) |
IJoinNexusFactory |
newJoinNexusFactory(RuleContextEnum ruleContext,
ActionEnum action,
int solutionFlags,
IElementFilter filter,
boolean justify,
boolean backchain,
IEvaluationPlanFactory planFactory,
Properties overrides) |
Iterator<IRelation> |
relations()
Visits the logically contained
IRelation resources. |
String |
removeNamespace(String prefix)
Removes the namespace associated with the prefix.
|
long |
removeStatements(IChunkedOrderedIterator<ISPO> itr)
Removes the statements from the statement indices (batch, parallel, NO
truth maintenance).
|
long |
removeStatements(IChunkedOrderedIterator<ISPO> itr,
boolean computeClosureForStatementIdentifiers)
This processes a chunk of
SPO s at a time and then submits tasks
to parallel threads to remove those statements from each of the statement
indices. |
long |
removeStatements(ISPO[] stmts,
int numStmts)
Removes the statements from the statement indices (batch, parallel, NO
truth maintenance).
|
long |
removeStatements(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o) |
long |
removeStatements(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource c)
Unconditionally removes statement(s) matching the triple pattern (NO
truth maintenance).
|
protected void |
shutdown()
Default is a NOP - invoked by
close() and
__tearDownUnitTest() |
String |
toString(ISPO spo) |
String |
toString(IV iv)
Externalizes a term using an abbreviated syntax.
|
String |
toString(IV s,
IV p,
IV o)
Externalizes a triple using an abbreviated syntax.
|
String |
toString(IV s,
IV p,
IV o,
IV c)
Externalizes a quad or a triple with a statement identifier using an
abbreviated syntax.
|
acquireExclusiveLock, assertWritable, getBareProperties, getChunkCapacity, getChunkOfChunksCapacity, getChunkTimeout, getCommitTime, getContainer, getContainerNamespace, getExecutorService, getFullyBufferedReadThreshold, getIndexManager, getMaxParallelSubqueries, getNamespace, getProperties, getProperty, getProperty, getTimestamp, isForceSerialExecution, isReadOnly, toString, unlock
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isReadOnly
getContainerNamespace, getNamespace, getTimestamp
protected static final boolean INFO
protected static final boolean DEBUG
protected final boolean lexicon
TempTripleStore
.protected AbstractTripleStore(IIndexManager indexManager, String namespace, Long timestamp, Properties properties)
DefaultResourceLocator
.AbstractTripleStore.Options
public final boolean isJustify()
Note: This is the same value that is reported by SPORelation.justify
.
AbstractTripleStore.Options.JUSTIFY
public final int getSPOKeyArity()
SPORelation
(3 or 4).public final boolean isQuads()
true
iff this is a quad store.isQuads
in interface ITripleStore
AbstractTripleStore.Options.QUADS
public final boolean isStatementIdentifiers()
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.public BaseClosure getClosureInstance()
public RDRHistory getRDRHistoryInstance()
RDRHistory
class.public boolean isRDRHistory()
public boolean isAxiom(IV s, IV p, IV o)
true
iff the fully bound statement is an axiom.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 boolean isInlineLiterals()
true
when the database is in inline terms mode. In
this mode, certain types of terms (numerics in particular) are inlined
into the statement indices rather than being mapped to and from term
identifiers in the lexicon.public final boolean isConstrainXXXCShards()
public final boolean isBottomUpEvaluation()
public final BigdataValueFactory getValueFactory()
BigdataValueFactoryImpl
for namespace of the
LexiconRelation
associated with this AbstractTripleStore
.UnsupportedOperationException
- if there is no associated lexicon.public Iterator<IRelation> relations()
IDatabase
IRelation
resources.relations
in interface IDatabase<AbstractTripleStore>
protected Class determineAxiomClass()
protected Class determineVocabularyClass()
public abstract boolean isConcurrent()
true
iff the store is safe for concurrent readers
and writers. This property depends on primarily on the concurrency
control mechanisms (if any) that are used to prevent concurrent access to
an unisolated index while a thread is writing on that index. Stores based
on the IBigdataFederation
automatically inherent the
appropriate concurrency controls as would a store whose index access was
intermediated by the executor service of an IConcurrencyManager
.
Note: if isConcurrent()
returns true
then the
database will provide concurrency control for write tasks submitted
against the same index. However, concurrent writers are always supported
on distinct indices and concurrent readers on an index are always
supported IF there is no concurrent writer on the index. If
isConcurrent()
is false
then you need to avoid
submitting a write task concurrently with ANY other task for the same
index (concurrent reads or concurrent writes will both cause problems
with a write task in the absence of concurrency controls).
The main place where this is an issue is rule execution, where the
entailments are being written back onto the database while reads are
proceeding concurrently. The new rule execution layer finesses this by
have a read view and a write view, so an IProgram
will read from
an historical state and write on the ITx.UNISOLATED
indices. This
also works for closure - each round of closure updates the read-behind
point so that all writes from the last round become visible during the
next round.
Note that closure must read against a stable state of the database and
that concurrent writes on the database NOT related to the closure
operation are disallowed. With these guidelines, you can force the
application to use a single thread for all mutation operations on the
AbstractTripleStore
(readers from historical states may be
concurrent) and concurrency problems will not arise.
public final void __tearDownUnitTest()
public boolean isOpen()
public void close()
ITripleStore
ITripleStore
.close
in interface ITripleStore
protected final void shutdown()
close()
and
__tearDownUnitTest()
public abstract boolean isStable()
Note: This is mainly used by the test suites.
public AbstractTripleStore init()
AbstractResource
init
in interface ILocatableResource<IDatabase<AbstractTripleStore>>
init
in class AbstractResource<IDatabase<AbstractTripleStore>>
public void create()
IMutableResource
ILocatableResource.init()
is suitable for invocation from
IMutableResource.create()
. Instead, you are responsible for invoking ILocatableResource.init()
from this method IFF it is appropriate to reuse its initialization logic.create
in interface IMutableResource<IDatabase<AbstractTripleStore>>
create
in class AbstractResource<IDatabase<AbstractTripleStore>>
public final void destroy()
IMutableResource
destroy
in interface ITripleStore
destroy
in interface IMutableResource<IDatabase<AbstractTripleStore>>
destroy
in class AbstractResource<IDatabase<AbstractTripleStore>>
public final Axioms getAxioms()
Properties
. Otherwise it is
set by create()
.IllegalStateException
- if there is no lexicon.AbstractTripleStore.Options.LEXICON
,
AbstractTripleStore.Options.AXIOMS_CLASS
public final Vocabulary getVocabulary()
Vocabulary
. This consists of
BigdataValue
s of interest that have been pre-evaluated against
the lexicon and are associated with their correct term identifiers.IllegalStateException
- if there is no lexicon.AbstractTripleStore.Options.LEXICON
,
AbstractTripleStore.Options.VOCABULARY_CLASS
public final GeoSpatialConfig getGeoSpatialConfig()
GeoSpatialConfig
. The GeoSpatialConfig
defines the structure and storage details of registered geospatial
datatypes.IllegalStateException
- if there is no lexicon.GeoSpatialConfigOptions.Options#GEO_SPATIAL
,
GeoSpatialConfigOptions.Options#GEO_SPATIAL_DATATYPE_CONFIG
,
GeoSpatialConfigOptions.Options#GEO_SPATIAL_DEFAULT_DATATYPE
,
GeoSpatialConfigOptions.Options#GEO_SPATIAL_INCLUDE_BUILTIN_DATATYPES
public final SPORelation getSPORelation()
SPORelation
(triples and their access paths).public final LexiconRelation getLexiconRelation()
LexiconRelation
handles all things related to the indices
mapping RDF Value
s onto internal 64-bit term identifiers.public final long getNamedGraphCount()
ITripleStore
getNamedGraphCount
in interface ITripleStore
public final long getStatementCount()
ITripleStore
getStatementCount
in interface ITripleStore
ITripleStore.getStatementCount(boolean)
public final long getStatementCount(boolean exact)
ITripleStore
getStatementCount
in interface ITripleStore
exact
- When true
the result will be an exact count,
which may require a full key-range scan of one of the
statement indices.false
and either transactions or key-range
partitioned indices are being used, then this will be an upper
bound.public final long getStatementCount(org.openrdf.model.Resource c)
ITripleStore
getStatementCount
in interface ITripleStore
c
- The context (optional).public final long getStatementCount(org.openrdf.model.Resource c, boolean exact)
Core implementation.
getStatementCount
in interface ITripleStore
c
- The context (optional).exact
- When true
the result will be an exact count,
which may require a full key-range scan of one of the
statement indices.null
. When exact is
false
and either transactions or key-range
partitioned indices are being used, then this will be an upper
bound.public long getExplicitStatementCount(org.openrdf.model.Resource c)
Note: In order to get the #of explicit statements in the repository we have to actually do a range scan and figure out for each statement whether or not it is explicit.
c
- The context (optional). When not given, the count is reported
across all named graphs.public void abort()
abort
in interface ITripleStore
IllegalStateException
- if the view is read only.public long commit()
Note: The semantics of this operation depend on whether the database is embedded (does a commit), temporary (ignored), or a federation (ignored since unisolated writes on the federation are atomic and auto-committed).
Note: This method MUST be extended to perform commit for implementations with live indices.
commit
in interface ITripleStore
IllegalStateException
- if the view is read only.public final long getJustificationCount()
public final long getTermCount()
ITripleStore
Value
s in the lexicon (this is not specific to any
named graph).
This may be an estimate when using partitioned indices.
Many RDF Value
s are inlined into the statement indices. Inlined
values are not be reported by this method.
getTermCount
in interface ITripleStore
public final long getURICount()
ITripleStore
This may be an estimate when using partitioned indices.
Many RDF Value
s are inlined into the statement indices. Inlined
values are not be reported by this method.
getURICount
in interface ITripleStore
public final long getLiteralCount()
ITripleStore
This may be an estimate when using partitioned indices.
Many RDF Value
s are inlined into the statement indices. Inlined
values are not be reported by this method.
getLiteralCount
in interface ITripleStore
public final long getBNodeCount()
This may be an estimate when using partitioned indices.
This will always return ZERO (0) if
AbstractTripleStore.Options.STORE_BLANK_NODES
is
false
since there will not be any blank nodes in the
lexicon.
Many RDF Value
s are inlined into the statement indices. Inlined
values are not be reported by this method.
Note: Will always return zero (0) if
is false
.
getBNodeCount
in interface ITripleStore
public IV addTerm(org.openrdf.model.Value value)
IRawTripleStore
Note: This method delegates to the batch API, but it is extremely inefficient for scale-out as it does one RMI per request!
addTerm
in interface IRawTripleStore
value
- The term.public final BigdataValue getTerm(IV iv)
getTerm
in interface IRawTripleStore
BigdataValue
if found and
null
if not found or if the LexiconRelation
is not available (e.g., a TempTripleStore
.public final IV getIV(org.openrdf.model.Value value)
getIV
in interface IRawTripleStore
value
- Any Value
reference (MAY be null
).public void addTerms(BigdataValue[] terms)
IRawTripleStore
addTerms
in interface IRawTripleStore
terms
- An array to be inserted.LexiconRelation.addTerms(BigdataValue[], int, boolean)
public final InferenceEngine getInferenceEngine()
ITripleStore
InferenceEngine
singleton configured using the
properties that were used to configure the database.
Note: The first time this object is requested it will attempt to write the axioms on the database.
getInferenceEngine
in interface ITripleStore
DataLoader.Options
public final DataLoader getDataLoader()
ITripleStore
DataLoader
singleton configured using the properties
that were used to configure the database.getDataLoader
in interface ITripleStore
DataLoader.Options
public final void addStatement(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
addStatement
in interface ITripleStore
public final void addStatement(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c)
ITripleStore
StatementEnum.Explicit
statement by lookup and/or
insert into the various indices (non-batch api).
Note: The non-batch API is horridly inefficient and can not be used to
co-reference blank nodes. The batch load API for Sesame Value
objects is:
StatementBuffer buffer = new StatementBuffer(store, ...); buffer.add( s, p, o ); ... buffer.flush();
addStatement
in interface ITripleStore
s
- The subject (required).p
- The predicate (required).o
- The object (required).c
- The context (required IFF a quad store and otherwise ignored).public final ISPO getStatement(IV s, IV p, IV o)
getStatement
in interface IRawTripleStore
public final ISPO getStatement(IV s, IV p, IV o, IV c)
IRawTripleStore
Note: This may be used to examine the StatementEnum
.
getStatement
in interface IRawTripleStore
s
- The internal value (IV
) for the subject.p
- The internal value (IV
) for the predicate.o
- The internal value (IV
) for the object.c
- The internal value (IV
) for the context (required for
quads and ignored for triples).SPO
for that statement, including its
StatementEnum
-or- null
iff the statement is
not in the database.public final boolean hasStatement(IV s, IV p, IV o)
hasStatement(IV, IV, IV, IV)
Note: This method does not verify whether or not the statement is explicit.
s
- p
- o
- public final boolean hasStatement(IV s, IV p, IV o, IV c)
Note: This method does not verify whether or not the statement is explicit.
s
- p
- o
- c
- public final boolean hasStatement(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
hasStatement
in interface ITripleStore
public final boolean hasStatement(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c)
Note: This does not verify whether or not the statement is explicit.
This method is extremely inefficient for scale-out as it does multiple RMIs per request (one for each Value and one or more for the statement indices)!
hasStatement
in interface ITripleStore
s
- The subject (optional).p
- The predicate (optional).o
- The object (optional).c
- The context (optional and ignored unless a quad store).public final long removeStatements(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
removeStatements
in interface ITripleStore
public final long removeStatements(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c)
ITripleStore
removeStatements
in interface ITripleStore
s
- The subject (optional).p
- The predicate (optional).o
- The object (optional).c
- The context (optional).public final BigdataStatement getStatement(org.openrdf.model.Statement s)
public final BigdataStatement getStatement(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
getStatement
in interface ITripleStore
public final BigdataStatement getStatement(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c)
ITripleStore
Note: If the parameters are from an AbstractTripleStore
using a
different lexicon then you MUST either
BigdataValue.clearInternalValue()
or create a new Value
object which either is not aware of the term identifier or does not have
its term identifier set in order to avoid lookup using the term
identifier rather than indirecting through the lexicon.
getStatement
in interface ITripleStore
s
- The subject (required).p
- The predicate (required).o
- The object (required).c
- The context (required iff a quad store and otherwise ignored).null
iff the triple is not
defined in the database.ITripleStore.asValue(Value)
public final BigdataStatementIterator getStatements(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
getStatements
in interface ITripleStore
public final BigdataStatementIterator getStatements(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c)
ITripleStore
BigdataStatement
s in the
database matching the triple pattern.getStatements
in interface ITripleStore
s
- The subject (optional).p
- The predicate (optional).o
- The object (optional).c
- The context (optional and ignored unless a quad store).public BigdataStatementIterator getStatements(IChunkedOrderedIterator<BigdataTriplePattern> triplePatterns)
Note: If the input contains triple patterns that have a high cardinality in the data, then a large number of statements may be returned.
triplePatterns
- A collection of triple patterns or fully bound statements. If
this collection contains triple patterns that have a high
cardinality in the data, then a large number of statements may
be returned.public final BigdataValue asValue(org.openrdf.model.Value value)
ITripleStore
BigdataValue
to a Sesame Value
object.asValue
in interface ITripleStore
value
- Either a BigdataValue
, a Sesame Value
object, or null
.Value
object -or-
null
iff value is null
.public BigdataStatement asStatement(ISPO spo)
ITripleStore
ISPO
into a Sesame Statement
.
Note: The object returned will be a BigdataStatement
asStatement
in interface ITripleStore
spo
- The ISPO
.Statement
-or- null
.public BigdataStatementIterator asStatementIterator(IChunkedOrderedIterator<ISPO> src)
ITripleStore
IChunkedOrderedIterator
as a
BigdataStatementIterator
.
Note: The object visited will be BigdataStatementImpl
s.
asStatementIterator
in interface ITripleStore
src
- An IChunkedOrderedIterator
visiting SPO
sBigdataStatementIterator
.IAccessPath
,
ITripleStore.getAccessPath(Resource, URI, Value)
public IAccessPath<ISPO> getAccessPath(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
getAccessPath
in interface ITripleStore
public IAccessPath<ISPO> getAccessPath(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, IElementFilter<ISPO> filter)
public final IAccessPath<ISPO> getAccessPath(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c)
ITripleStore
IAccessPath
matching the triple pattern.getAccessPath
in interface ITripleStore
s
- The subject (optional).p
- The predicate (optional).o
- The object (optional).c
- The context (optional).Value
s is not known to the
database this method will return an EmptyAccessPath
.IAccessPath
,
ITripleStore.asStatementIterator(IChunkedOrderedIterator)
public final IAccessPath<ISPO> getAccessPath(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c, IElementFilter<ISPO> filter, RangeBOp range)
public IPredicate<ISPO> getPredicate(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
public IPredicate<ISPO> getPredicate(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c)
public final IPredicate<ISPO> getPredicate(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource c, IElementFilter<ISPO> filter, RangeBOp range)
public final IAccessPath<ISPO> getAccessPath(IV s, IV p, IV o)
IRawTripleStore
IAccessPath
for the given triple
pattern.getAccessPath
in interface IRawTripleStore
s
- The internal value for the subject -or- null.p
- The internal value for the predicate -or- null.o
- The internal value for the object -or- null.public final IAccessPath<ISPO> getAccessPath(IV s, IV p, IV o, IElementFilter<ISPO> filter)
public final IAccessPath<ISPO> getAccessPath(IV s, IV p, IV o, IV c, IElementFilter<ISPO> filter)
public final IAccessPath<ISPO> getAccessPath(IKeyOrder<ISPO> keyOrder)
IRawTripleStore
IAccessPath
for the specified IKeyOrder
and a
fully unbound triple pattern. This is generally used only when you want
to perform a IAccessPath#distinctTermScan()
.getAccessPath
in interface IRawTripleStore
public final IAccessPath<ISPO> getAccessPath(IKeyOrder<ISPO> keyOrder, IElementFilter<ISPO> filter)
keyOrder
- filter
- The filter will be incorporated as a constraint on the
IPredicate
for the IAccessPath
and will be
evaluated close to the data.public final void addNamespace(String namespace, String prefix)
AbstractResource.toString()
.namespace
- prefix
- public final Map<String,String> getNamespaces()
Note: this is NOT a persistent map. It is used by toString(IV)
when externalizing URIs.
public final String getNamespace(String prefix)
prefix
- The prefix.null
if no namespace
was mapped to that prefix.public final String removeNamespace(String prefix)
prefix
- The prefix.null
otherwise.public final void clearNamespaces()
public final String toString(IV s, IV p, IV o)
IRawTripleStore
toString
in interface IRawTripleStore
public final String toString(IV s, IV p, IV o, IV c)
IRawTripleStore
toString
in interface IRawTripleStore
public final String toString(IV iv)
IRawTripleStore
toString
in interface IRawTripleStore
iv
- The term identifier.public final StringBuilder dumpStore()
public final StringBuilder dumpStore(boolean explicit, boolean inferred, boolean axioms)
public final StringBuilder dumpStore(boolean history)
public final StringBuilder dumpStore(AbstractTripleStore resolveTerms, boolean explicit, boolean inferred, boolean axioms)
public final StringBuilder dumpStore(AbstractTripleStore resolveTerms, boolean explicit, boolean inferred, boolean axioms, boolean justifications)
resolveTerms
- Used to resolve term identifiers to terms (you can use this to
dump a TempTripleStore
that is using the term
dictionary of the main database).explicit
- Show statements marked as explicit.inferred
- Show statements marked inferred.axioms
- Show statements marked as axioms.justifications
- Dump the justifications index also.public final StringBuilder dumpStore(AbstractTripleStore resolveTerms, boolean explicit, boolean inferred, boolean axioms, boolean history, boolean justifications)
public StringBuilder dumpStore(AbstractTripleStore resolveTerms, boolean explicit, boolean inferred, boolean axioms, boolean history, boolean justifications, boolean sids, IKeyOrder<ISPO> keyOrder)
resolveTerms
- Used to resolve term identifiers to terms (you can use this to
dump a TempTripleStore
that is using the term
dictionary of the main database).explicit
- Show statements marked as explicit.inferred
- Show statements marked inferred.axioms
- Show statements marked as axioms.justifications
- Dump the justifications index also.keyOrder
- The access path to use.public StringBuilder dumpStatements(IAccessPath<ISPO> accessPath)
accessPath
- public long copyStatements(AbstractTripleStore dst, IElementFilter<ISPO> filter, boolean copyJustifications)
Note: This method MUST NOT be used unless it is known in advance that the statements in this store use term identifiers that are consistent with (term for term identical to) those in the destination store. If statement identifiers are enabled, then they MUST be enabled for both stores (statement identifiers are assigned by, and stored in, the foward lexicon and replicated into the statement indices).
Note: The statements in this store are NOT removed.
dst
- The persistent database (destination).filter
- An optional filter to be applied. Statements in this
matching the filter will NOT be copied.copyJustifications
- When true, the justifications will be copied as well.public long copyStatements(AbstractTripleStore dst, IElementFilter<ISPO> filter, boolean copyJustifications, IChangeLog changeLog)
public IChunkedOrderedIterator<ISPO> bulkFilterStatements(ISPO[] stmts, int numStmts, boolean present)
IRawTripleStore
ISPO
objects for whether they are
"present" or "not present" in the database, depending on the value of the
supplied boolean variable (batch API).bulkFilterStatements
in interface IRawTripleStore
stmts
- the statements to testnumStmts
- the number of statements to testpresent
- if true, filter for statements that exist in the db, otherwise
filter for statements that do not existpublic IChunkedOrderedIterator<ISPO> bulkFilterStatements(IChunkedOrderedIterator<ISPO> itr, boolean present)
IRawTripleStore
SPO
objects for whether
they are "present" or "not present" in the database, depending on the
value of the supplied boolean variable (batch api).bulkFilterStatements
in interface IRawTripleStore
itr
- an iterator over the set of statements to testpresent
- if true, filter for statements that exist in the db, otherwise
filter for statements that do not existpublic IChunkedOrderedIterator<ISPO> bulkCompleteStatements(SPO[] stmts, int numStmts)
public IChunkedOrderedIterator<ISPO> bulkCompleteStatements(IChunkedOrderedIterator<ISPO> itr)
IRawTripleStore
ISPO
s that are present in the database. ISPO
s not present
in the database are left as-is.bulkCompleteStatements
in interface IRawTripleStore
ISPO
s. Any
ISPO
s that were not found will be present but their
statement metadata (type and sid) will be unchanged.public long addStatements(ISPO[] stmts, int numStmts)
IRawTripleStore
addStatements
in interface IRawTripleStore
stmts
- The statements (sorted into IKeyOrder#SPO
order as a
side-effect).numStmts
- The #of entries in stmts that are valid.public long addStatements(ISPO[] stmts, int numStmts, IElementFilter<ISPO> filter)
IRawTripleStore
addStatements
in interface IRawTripleStore
stmts
- The statements.numStmts
- The #of entries in stmts that are valid.filter
- Optional statement filter. Statements matching the filter are
NOT added to the database.public long addStatements(IChunkedOrderedIterator<ISPO> itr, IElementFilter<ISPO> filter)
IRawTripleStore
addStatements
in interface IRawTripleStore
itr
- An iterator visiting the statements to be added.filter
- Optional statement filter. Statements matching the filter are
NOT added to the database. The iterator is closed by this
operation.public long addStatements(AbstractTripleStore statementStore, boolean copyOnly, IChunkedOrderedIterator<ISPO> itr, IElementFilter<ISPO> filter)
Note: If AbstractTripleStore.Options.STATEMENT_IDENTIFIERS
was specified, then
statement identifiers are assigned using the lexicon associated with
this database. This is done in a preprocessing stage for each
"chunk" reported by the source itr. This step sets the statement
identifier on the SPO
so that it is present when we write on the
statement indices.
statementStore
- Either this database or the focusStore (the latter
option is used only during truth maintenance).copyOnly
- When true
, it is assumed that the SPO
s
are being copied from another store using a consistent lexicon
(or onto a store that uses the same lexicon). The flag only
has an effect when statement identifiers are enabled, since it
is then presumed that SPO.getStatementIdentifier()
will return a pre-assigned statement identifier and that we do
NOT need to invoke
#addStatementIdentifiers(SPO[], int)
. This is only an
optimization - the value false
is always safe
for this flag, but it will do some extra work in the case
described here. See StatementWriter
, which uses this
flag and
copyStatements(AbstractTripleStore, IElementFilter, boolean)
which always specifies true
for this flag.itr
- The source from which the SPO
s are read.filter
- An optional filter.public long removeStatements(ISPO[] stmts, int numStmts)
IRawTripleStore
Note: The StatementEnum
on the SPO
s is ignored by this
method. It will delete all statements having the same bindings regardless
of whether they are inferred, explicit, or axioms.
removeStatements
in interface IRawTripleStore
public long removeStatements(IChunkedOrderedIterator<ISPO> itr)
IRawTripleStore
Note: The StatementEnum
on the SPO
s is ignored by this
method. It will delete all statements having the same bindings regardless
of whether they are inferred, explicit, or axioms.
removeStatements
in interface IRawTripleStore
itr
- The iteratorpublic long removeStatements(IChunkedOrderedIterator<ISPO> itr, boolean computeClosureForStatementIdentifiers)
SPO
s at a time and then submits tasks
to parallel threads to remove those statements from each of the statement
indices. This continues until all statements visited by the iterator have
been removed.
Note: If justifications
are being used to support truth
maintenance, then all justifications for the removed statements are also
removed.
itr
- An iterator visiting SPO
s to be removed from the
database.computeClosureForStatementIdentifiers
- When false
the caller asserts that they have
pre-computed the closure of the statements that assert
metadata about statement identifiers to be deleted. When
true
this method will compute that closure on
behalf of the caller with the effect that any statements made
about statements to be removed are also removed. This option
has no effect when statementIdentifiers
are not
enabled. See AbstractTripleStore.Options.STATEMENT_IDENTIFIERS
public IChunkedOrderedIterator<ISPO> computeClosureForStatementIdentifiers(IChunkedOrderedIterator<ISPO> src)
statementIdentifiers
are enabled).
Note: This uses a TempTripleStore
which is iteratively populated
until a fix point is obtained. The TempTripleStore
is released
when the returned iterator is closed
or
when it is finalized.
src
- The source iterator.(NPE during read-only namespace resolution caused by RDR
Truth Maintenance and GRS concurrent modification)
public static void fixPointStatementIdentifiers(AbstractTripleStore db, AbstractTripleStore tempStore)
db
- The database.tempStore
- The temporary store.public IJoinNexusFactory newJoinNexusFactory(RuleContextEnum ruleContext, ActionEnum action, int solutionFlags, IElementFilter filter)
solutionFlags
- See IJoinNexus.ELEMENT
and friends.filter
- Optional filter.public IJoinNexusFactory newJoinNexusFactory(RuleContextEnum ruleContext, ActionEnum action, int solutionFlags, IElementFilter filter, boolean justify, boolean backchain, IEvaluationPlanFactory planFactory)
solutionFlags
- See IJoinNexus.ELEMENT
and friends.filter
- Optional filter.public IJoinNexusFactory newJoinNexusFactory(RuleContextEnum ruleContext, ActionEnum action, int solutionFlags, IElementFilter filter, boolean justify, boolean backchain, IEvaluationPlanFactory planFactory, Properties overrides)
solutionFlags
- See IJoinNexus.ELEMENT
and friends.filter
- Optional filter.overrides
- Optional overrides of the properties controlling the rule
execution layer. When given, the property values will override
those inherited from AbstractResource
.public ICloseableIterator<IBindingSet> match(org.openrdf.model.Literal[] lits, org.openrdf.model.URI[] preds, org.openrdf.model.URI cls)
IRule
execution using the full text index to identify
possible completions of the given literals for which there exists a
subject s
such that:
SELECT ?s, ?t, ?lit (?lit completionOf, lits) AND (?s ?p ?lit) AND (?s rdf:type ?t) AND (?t rdfs:subClassOf cls) WHERE p IN {preds}Note: The JOIN runs asynchronously.
lits
- One or more literals. The completions of these literals will
be discovered using the FullTextIndex
. (A completion
is any literal having one of the given literals as a prefix
and includes an exact match on the litteral as a degenerate
case.)preds
- One or more predicates that link the subjects of interest to
the completions of the given literals. Typically this array
will include rdf:label
.cls
- All subjects visited by the iterator will be instances of this
class.ICloseableIterator
visiting IBindingSet
s. Each
IBindingSet
will have bound BigdataValue
s for
s
, t
, p
, and
lit
where those variables are defined per the
pseudo-code JOIN above.InterruptedException
- if the operation is interrupted.
FIXME quads : Modify match() to allow an optional context
argument. When present, the match would be restricted to the
specified context.protected Program getMatchProgram(org.openrdf.model.Literal[] lits, IConstant<IV>[] _preds, IV _cls)
lits
- One or more literals. The completions of these literals will
be discovered using the FullTextIndex
. (A completion
is any literal having one of the given literals as a prefix
and includes an exact match on the litteral as a degenerate
case.)_preds
- One or more term identifiers for predicates that link the
subjects of interest to the completions of the given literals.
Typically this array will include the term identifier for
rdf:label
._cls
- All subjects visited by the iterator will be instances of the
class assigned this term identifier.ISolution
s corresponding to the head of the
MatchRule
.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.