com.bigdata.rdf.spo
Interface ISPO

All Superinterfaces:
IElement
All Known Subinterfaces:
BigdataStatement
All Known Implementing Classes:
BigdataStatementImpl, SPO

public interface ISPO
extends IElement

A interface representing an RDF triple, an RDF triple with a statement identifier, or an RDF quad. The slots are 64-bit long term identifiers assigned by a lexicon. The 4th position is either unused (triples), the statement identifier (triples with the provenance mode enabled), or the context/named graph position of a quad. This interface treats all four positions as "data" and requires the caller to be aware of the database mode (triples, triples+SIDs, or quads). The (s,p,o) of the interface are immutable. The (c) position is mutable because its value is not knowable until after the other three values have been bound in the triples+SIDs database mode. When using this interface for a quads mode database, the context position SHOULD be set by the appropriate constructor and NOT modified thereafter.

Two additional data are carried by this interface for use with inference and truth maintenance. First, this interface may also carry an indication of whether the triple/quad is an explicit statement, an inferred statement or an axiom. Second, the isOverride() flag is used during truth maintenance when an explicit statement is retracted and we need to downgrade the statement in the database to an inference because it is still provable by other statements in the knowledge base.

Version:
$Id: ISPO.java 6151 2012-03-16 17:56:22Z thompsonbry $
Author:
Bryan Thompson

Method Summary
 IV c()
          The term identifier for the SID/context position (slot 3) -or- #NULL.
 IV get(int index)
          Return the s,p,o, or c value corresponding to the given index.
 ModifiedEnum getModified()
          Return the state of the transient modified flag.
 IV getStatementIdentifier()
          The statement identifier (optional).
 StatementEnum getStatementType()
          Whether the statement is StatementEnum.Explicit, StatementEnum.Inferred or an StatementEnum.Axiom.
 boolean getUserFlag()
          Return true IFF the SPO user flag is set
 boolean hasStatementIdentifier()
          true IFF AbstractTripleStore#isStatement(IV) returns true for c().
 boolean hasStatementType()
          Return true iff the statement type is known.
 boolean isAxiom()
          Return true IFF the SPO is marked as StatementEnum.Axiom.
 boolean isExplicit()
          Return true IFF the SPO is marked as StatementEnum.Explicit.
 boolean isFullyBound()
          Return true iff all position (s,p,o) are non-#NULL.
 boolean isInferred()
          Return true IFF the SPO is marked as StatementEnum.Inferred.
 boolean isModified()
           
 boolean isOverride()
          When true the statement will be written onto the database with exactly its current getStatementType() (default false).
 IV o()
          The term identifier for the object position (slot 2) -or- #NULL.
 IV p()
          The term identifier for the predicate position (slot 1) -or- #NULL.
 IV s()
          The term identifier for the subject position (slot 0) -or- #NULL.
 void setModified(ModifiedEnum modified)
          Set a transient flag indicating whether or not the persistent state of the statement was modified when it was last written onto the database.
 void setOverride(boolean override)
          Set the override flag.
 void setStatementIdentifier(boolean sidable)
          Mark whether or not the SPO will permit the statement identifier to be lazily materialized (default false).
 void setStatementType(StatementEnum type)
          Set the statement type for this statement.
 void setUserFlag(boolean userFlag)
          Set SPO user flag
 String toString(IRawTripleStore db)
          Method may be used to externalize the BigdataValues in the ISPO.
 

Method Detail

s

IV s()
The term identifier for the subject position (slot 0) -or- #NULL.


p

IV p()
The term identifier for the predicate position (slot 1) -or- #NULL.


o

IV o()
The term identifier for the object position (slot 2) -or- #NULL.


c

IV c()
The term identifier for the SID/context position (slot 3) -or- #NULL. The semantics of the returned value depend on the database mode. For triples, it is unused. For triples+SIDs, it is the statement identifier as assigned by the lexicon. For quads, it is the context (aka named graph) and #NULL iff the context was not bound.

See Also:
AbstractTripleStore.Options#STATEMENT_IDENTIFIERS, AbstractTripleStore.Options#QUADS

get

IV get(int index)
Return the s,p,o, or c value corresponding to the given index.

Specified by:
get in interface IElement
Parameters:
index - The legal values are: s=0, p=1, o=2, c=3.
Returns:
The value at the specified index.

isFullyBound

boolean isFullyBound()
Return true iff all position (s,p,o) are non-#NULL.

Note: SPOs are sometimes used to represent triple patterns, e.g., in the tail of a Justification. This method will return true if the "triple pattern" is fully bound and false if there are any unbound positions.

Note: BigdataStatements are not fully bound when they are instantiated during parsing until their term identifiers have been resolved against a database's lexicon.


getStatementType

StatementEnum getStatementType()
Whether the statement is StatementEnum.Explicit, StatementEnum.Inferred or an StatementEnum.Axiom.

Returns:
The StatementEnum type -or- null if the statement type has not been specified.

setStatementType

void setStatementType(StatementEnum type)
Set the statement type for this statement.

Parameters:
type - The statement type.
Throws:
IllegalArgumentException - if type is null.
IllegalStateException - if the statement type is already set to a different non- null value.

hasStatementType

boolean hasStatementType()
Return true iff the statement type is known. true iff the statement type is known for this statement.


isExplicit

boolean isExplicit()
Return true IFF the SPO is marked as StatementEnum.Explicit.


getUserFlag

boolean getUserFlag()
Return true IFF the SPO user flag is set


setUserFlag

void setUserFlag(boolean userFlag)
Set SPO user flag

Parameters:
userFlag -

isInferred

boolean isInferred()
Return true IFF the SPO is marked as StatementEnum.Inferred.


isAxiom

boolean isAxiom()
Return true IFF the SPO is marked as StatementEnum.Axiom.


setStatementIdentifier

void setStatementIdentifier(boolean sidable)
Mark whether or not the SPO will permit the statement identifier to be lazily materialized (default false).

Parameters:
sid - If sid is true, this ISPO will produce a sid on-demand when requested.
Throws:
IllegalStateException - unless this is a StatementEnum.Explicit ISPO.

getStatementIdentifier

IV getStatementIdentifier()
The statement identifier (optional). This has nearly identical semantics to c(), but will throw an exception if the 4th position is not bound.

Statement identifiers are a unique per-triple identifier assigned when a statement is first asserted against the database and are are defined iff AbstractTripleStore.Options#STATEMENT_IDENTIFIERS was specified.

Throws:
IllegalStateException - unless a statement identifier is assigned to this ISPO.

hasStatementIdentifier

boolean hasStatementIdentifier()
true IFF AbstractTripleStore#isStatement(IV) returns true for c().


setOverride

void setOverride(boolean override)
Set the override flag.

Parameters:
override - the new value.

isOverride

boolean isOverride()
When true the statement will be written onto the database with exactly its current getStatementType() (default false).

Note: This feature is used by TruthMaintenance when we need to downgrade an ISPO from "Explicit" to "Inferred". Normally, a statement is automatically upgraded from "Inferred" to "Explicit" so without setOverride(boolean) you could not downgrade the StatementEnum in the database without first deleting the statement (which would also delete its justifications).


setModified

void setModified(ModifiedEnum modified)
Set a transient flag indicating whether or not the persistent state of the statement was modified when it was last written onto the database. Modification can indicate that the statement was inserted, retracted, or had its associated StatementEnum in the database updated.


getModified

ModifiedEnum getModified()
Return the state of the transient modified flag. This flag indicates whether or not the persistent state of the statement was modified when it was written onto the database. Modification can indicate that the statement was inserted, retracted, or had its associated StatementEnum in the database updated.

TODO:
This flag is set by SPORelation.insert(ISPO[], int, IElementFilter) and SPORelation.delete(IChunkedOrderedIterator). The state of this flag generally DOES NOT survive across higher level APIs such as the StatementBuffer because they formulate new ISPO objects which are distinct from the caller's ISPO objects.

In order to use take advantage of this information right now, you should batch resolve the RDF values to their term identifiers, construct the appropriate SPO[], and invoke the corresponding method on SPORelation.

Because this information is set at a low-level it can not currently be used in combination with truth maintenance mechanisms.


isModified

boolean isModified()

toString

String toString(IRawTripleStore db)
Method may be used to externalize the BigdataValues in the ISPO.

Parameters:
db - The database whose lexicon will be used.


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