|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.rdf.spo.SPO
public class SPO
Represents a triple, triple+SID, or quad. When used to represent a triple,
the statement identifier MAY be set on the triple after the object has been
instantiated. When used to represent a quad, the context position SHOULD be
treated as immutable and setStatementIdentifier(long) will reject
arguments if they can not be validated as statement identifiers (based on
their bit pattern).
| Field Summary | |
|---|---|
long |
o
The term identifier for the object position. |
long |
p
The term identifier for the predicate position. |
long |
s
The term identifier for the subject position. |
| Fields inherited from interface com.bigdata.rdf.spo.ISPO |
|---|
NULL |
| Constructor Summary | |
|---|---|
SPO(BigdataResource s,
BigdataURI p,
BigdataValue o,
StatementEnum type)
Construct a triple from BigdataValues and the specified statement
type. |
|
SPO(BigdataStatement stmt)
Construct a triple/quad from a BigdataStatement. |
|
SPO(IConstant<Long> s,
IConstant<Long> p,
IConstant<Long> o,
StatementEnum type)
Variant to create an SPO from constants (used by the unit tests). |
|
SPO(IPredicate<ISPO> predicate)
Variant to create an SPO from a predicate - the StatementEnum and
statement identifier are not specified. |
|
SPO(long s,
long p,
long o)
Triple constructor for a statement whose type is NOT known. |
|
SPO(long s,
long p,
long o,
byte[] val)
Constructor used when you know the {s,p,o} and have done a lookup in the index to determine whether or not the statement exists, its StatementEnum type, and its statement identifier (if assigned). |
|
SPO(long s,
long p,
long o,
long c)
Quads constructor. |
|
SPO(long s,
long p,
long o,
long c,
StatementEnum type)
Quads constructor with StatementEnum. |
|
SPO(long s,
long p,
long o,
StatementEnum type)
Construct a triple. |
|
| Method Summary | |
|---|---|
long |
c()
The term identifier for the SID/context position (slot 3) -or- ISPO.NULL. |
int |
compareTo(SPO stmt2)
Imposes s:p:o ordering based on termIds. |
static ISPO |
decodeValue(ISPO spo,
byte[] val)
Sets the statement type and optionally the statement identifier by decoding the value associated with the key one of the statement indices. |
boolean |
equals(ISPO stmt2)
True iff the ISPOs are the same object or if the same term
identifiers are assigned for the subject, predicate and object positions,
and the same StatementEnum are the same. |
boolean |
equals(Object o)
|
long |
get(int index)
Return the s,p,o, or c value corresponding to the given index. |
long |
getStatementIdentifier()
The statement identifier (optional). |
StatementEnum |
getStatementType()
Whether the statement is StatementEnum.Explicit,
StatementEnum.Inferred or an StatementEnum.Axiom. |
int |
hashCode()
Hash code for the (s,p,o) per Sesame's Statement.hashCode(). |
boolean |
hasStatementIdentifier()
true IFF AbstractTripleStore.isStatement(long)
returns true for ISPO.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- ISPO.NULL. |
boolean |
isInferred()
Return true IFF the SPO is marked as StatementEnum.Inferred. |
boolean |
isOverride()
When true the statement will be written onto the database
with exactly its current ISPO.getStatementType() (default
false). |
long |
o()
The term identifier for the object position (slot 2) -or- ISPO.NULL. |
long |
p()
The term identifier for the predicate position (slot 1) -or- ISPO.NULL. |
long |
s()
The term identifier for the subject position (slot 0) -or- ISPO.NULL. |
byte[] |
serializeValue(ByteArrayBuffer buf)
Return the byte[] that would be written into a statement index for this ISPO, including the optional StatementEnum.MASK_OVERRIDE
bit. |
static byte[] |
serializeValue(ByteArrayBuffer buf,
boolean override,
StatementEnum type,
long c)
Return the byte[] that would be written into a statement index for this SPO, including the optional StatementEnum.MASK_OVERRIDE
bit. |
void |
setOverride(boolean override)
Set the override flag. |
void |
setStatementIdentifier(long sid)
Set the statement identifier. |
void |
setStatementType(StatementEnum type)
Set the statement type for this statement. |
String |
toString()
Return a representation of the statement using the term identifiers (the identifiers are NOT resolved to terms). |
String |
toString(IRawTripleStore store)
Resolves the term identifiers to terms against the store and returns a representation of the statement using IRawTripleStore.toString(long, long, long). |
static String |
toString(long id)
Represents the term identifier together with its type (literal, bnode, uri, or statement identifier). |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final long s
public final long p
public final long o
| Constructor Detail |
|---|
public SPO(long s,
long p,
long o)
Note: This is primarily used when you want to discover the type of the statement.
AbstractTripleStore#bulkCompleteStatements(ISPOIterator)
public SPO(long s,
long p,
long o,
long c)
s - p - o - c -
public SPO(long s,
long p,
long o,
StatementEnum type)
Note: When the statement is StatementEnum.Inferred you MUST also
construct the appropriate Justification.
s - p - o - type - The statement type.
public SPO(long s,
long p,
long o,
long c,
StatementEnum type)
StatementEnum.
s - p - o - c - type -
public SPO(long s,
long p,
long o,
byte[] val)
StatementEnum type, and its statement identifier (if assigned).
s - p - o - val -
public SPO(IConstant<Long> s,
IConstant<Long> p,
IConstant<Long> o,
StatementEnum type)
SPO from constants (used by the unit tests).
s - p - o - type - public SPO(IPredicate<ISPO> predicate)
StatementEnum and
statement identifier are not specified. This may be used as a convenience
to extract the {s, p, o, c} from an IPredicate or from an
IAccessPath when the predicate is not known to be an
SPOPredicate or the IAccessPath is not known to be an
SPOAccessPath.
predicate - The predicate.
public SPO(BigdataResource s,
BigdataURI p,
BigdataValue o,
StatementEnum type)
BigdataValues and the specified statement
type.
s - p - o - type - public SPO(BigdataStatement stmt)
BigdataStatement. The term
identifiers and statement type information available on the
BigdataStatement will be used to initialize the SPO.
stmt - The statement.| Method Detail |
|---|
public final long get(int index)
ISPO
get in interface ISPOindex - The legal values are: s=0, p=1, o=2, c=3.public final long s()
ISPOISPO.NULL.
s in interface ISPOpublic final long p()
ISPOISPO.NULL.
p in interface ISPOpublic final long o()
ISPOISPO.NULL.
o in interface ISPOpublic final long c()
ISPOISPO.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 ISPO.NULL iff the context was not bound.
c in interface ISPOAbstractTripleStore.Options#STATEMENT_IDENTIFIERS,
AbstractTripleStore.Options#QUADSpublic final void setStatementIdentifier(long sid)
setStatementIdentifier in interface ISPOsid - The statement identifier.
IllegalArgumentException - if id is ISPO.NULL.
IllegalStateException - if the statement identifier is already set.public final long getStatementIdentifier()
ISPOISPO.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.
getStatementIdentifier in interface ISPOpublic final boolean hasStatementIdentifier()
ISPOtrue IFF AbstractTripleStore.isStatement(long)
returns true for ISPO.c().
hasStatementIdentifier in interface ISPOpublic void setOverride(boolean override)
ISPO
setOverride in interface ISPOoverride - the new value.public boolean isOverride()
ISPOtrue the statement will be written onto the database
with exactly its current ISPO.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 ISPO.setOverride(boolean) you could not downgrade the
StatementEnum in the database without first deleting the
statement (which would also delete its justifications).
isOverride in interface ISPO
public static ISPO decodeValue(ISPO spo,
byte[] val)
val - The value associated with the key one of the statement
indices.
public byte[] serializeValue(ByteArrayBuffer buf)
ISPOISPO, including the optional StatementEnum.MASK_OVERRIDE
bit. If the ISPO.hasStatementIdentifier() would return
true, then the SID will be included in the returned byte[].
Note that ISPO.hasStatementIdentifier() is defined in terms of the
bit pattern of the SID identifiers and therefore will be
true ONLY for a statement identifier and NOT for an RDF
Value identifier.
serializeValue in interface ISPObuf - A buffer supplied by the caller. The buffer will be reset
before the value is written on the buffer.
ISPO.
public static byte[] serializeValue(ByteArrayBuffer buf,
boolean override,
StatementEnum type,
long c)
SPO, including the optional StatementEnum.MASK_OVERRIDE
bit. If the statement identifier is non-ISPO.NULL then it will be
included in the returned byte[].
buf - A buffer supplied by the caller. The buffer will be reset
before the value is written on the buffer.override - true iff you want the
StatementEnum.MASK_OVERRIDE bit set (this is only set
when serializing values for a remote procedure that will write
on the index, it is never set in the index itself).type - The StatementEnum.c - The term identifier associated with the context position. This
will be included in the returned byte[] value IFF
AbstractTripleStore.isStatement(long) returns
true for c AND the type is
StatementEnum.Explicit.
SPO.public final boolean isExplicit()
true IFF the SPO is marked as StatementEnum.Explicit.
isExplicit in interface ISPOpublic final boolean isInferred()
true IFF the SPO is marked as StatementEnum.Inferred.
isInferred in interface ISPOpublic final boolean isAxiom()
true IFF the SPO is marked as StatementEnum.Axiom.
isAxiom in interface ISPOpublic int hashCode()
Statement.hashCode(). It
DOES NOT consider the context position.
hashCode in class Objectpublic int compareTo(SPO stmt2)
Note: By design, this does NOT differentiate between statements with the
different StatementEnum values.
FIXME quads : compare [c]?
compareTo in interface Comparable<SPO>public boolean equals(Object o)
equals in class Objectpublic boolean equals(ISPO stmt2)
ISPOs are the same object or if the same term
identifiers are assigned for the subject, predicate and object positions,
and the same StatementEnum are the same.
Note: This is NOT the same test as
BigdataStatementImpl.equals(Object) since the latter is
implemented per the Statement interface.
FIXME quads : compare [c]?
public String toString()
toString in class ObjectITripleStore#toString(long, long, long)public static String toString(long id)
id - The term identifier.
public String toString(IRawTripleStore store)
IRawTripleStore.toString(long, long, long).
toString in interface ISPOstore - The store (optional). When non-null the store
will be used to resolve term identifiers to terms.
public final boolean isFullyBound()
ISPOISPO.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.
FIXME quads : this method might need to be aware of the database mode,
e.g., pass in [boolean quads]. if its semantics are restricted to whether
the triple pattern is fully bound, then clarify that here.
isFullyBound in interface ISPOpublic final StatementEnum getStatementType()
ISPOStatementEnum.Explicit,
StatementEnum.Inferred or an StatementEnum.Axiom.
getStatementType in interface ISPOStatementEnum type -or- null if the
statement type has not been specified.public final void setStatementType(StatementEnum type)
ISPO
setStatementType in interface ISPOtype - The statement type.public final boolean hasStatementType()
ISPOtrue iff the statement type is known.
true iff the statement type is known for this statement.
hasStatementType in interface ISPO
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||