V
- The generic type for the RDF Value
implementation.T
- The generic type for the inline value.public abstract class AbstractIV<V extends BigdataValue,T> extends Object implements IV<V,T>
VTE
and the DTE
together into the flags byte used as a common prefix for all keys formed from
RDF Values regardless of whether they are based on an assigned term
identifier or the inlining of the RDF Value.
Literals which are projected onto primitive data types with a natural order
(int, float, double, long, etc.) are in total order within that segment of
the statement index and such segments are partitioned into non-overlapping
key ranges. Thus key range scans may be used for where the primitive data
type allows it while filtering on the value must be used where the data type
does not have a natural ordering. Unicode values do not have a "natural"
ordering within the statement indices as they are modeled by a reversible
compression rather than a collation sort key. Therefore, when a high level
query is constrained such that a variable is known to be of a given data type
you can use IV
aware operations. Otherwise, the IV
s must be
materialized and operations performed on BigdataValue
s instead.
DTE
).
Each of those types has a natural order which we can encode and decode from
the B+Tree key. In general, there is a relatively limited set of interesting
intrinsic codings, which is important since we will dedicate just 4 bits for
to code the natural order of the value space, which is just only 16
distinctions. Given that we have 14 intrinsic data types, that leaves room
for just two more. One of those bits provides for Unicode data (see
DTE.XSDString
without a collation order). The other bit provides
extensibility in the framework itself as described below (see
DTE.Extension
).
The header byte contains various bit flags which are laid out as follows:
[valueType] : 2 bits [inline] : 1 bit [extension] : 1 bit [dataTypeCode] : 4 bits
VTE
which governs
these bits.true
, this bit signals that information about the actual
RDF Value data type will follow (see below). When false
, the
datatype URI is directly recoverable (for a data type Literal) from the
dataTypeCode
.extension
bit
comes first this will not interleave inline values for intrinsic and extended
data types having the same dataTypeCode
. dataTypeCode
0xf
(DTE#Extension)
is reserved for extending the set of intrinsic data types. When the code is
0xf
the next byte must be considered as well to determine the
actual intrinsic data type code.---------- byte boundary (IFF DTE == DTE.Extension) ----------If the DTE value was
DTE.Extension
was, then the next byte(s) encode
the DTEExtension (extended intrinsic datatype aka primitive datatype).
---------- byte boundary ----------If
extension
was true, then the next byte(s) encode
information about the source data type URI (its IV
) and the key space
will be partitioned based on the extended data type URI.
---------- byte boundary ----------The unsigned byte[] representation of the value in the value space for one of the intrinsic types. The length of this byte[] may be directly determined from the [dataTypeCode] for most data types. However, for xsd:integer and xsd:decimal, the length is part of the representation.
---------- byte boundary and end of the record ----------
foo:milliseconds
representing milliseconds since the
epoch, then the value space of that data type can be projected onto an
xsd:long
.byte
(256 distinctions) or short
(64k
distinctions). Enumerations make it possible to inline application specific
data types while benefiting from XSD validation of those RDF Values. When an
enumeration is registered, the order in which the members of the enumeration
are given may optionally specify the natural order of that enumeration. The
natural order is imposed by projecting the first member of the enumeration
one ZERO, the second member onto ONE, etc. An enumeration with a natural
order will be sorted based on that defined order and query optimizations may
perform key-range scans informed by that natural order.Modifier and Type | Field and Description |
---|---|
protected byte |
flags
Bit flags indicating the kind of RDF Value (
VTE ), whether the RDF
Value is inline, whether this is an extension datatype, and the natural
order and binary representation of the inline value (#DTE ). |
Modifier | Constructor and Description |
---|---|
protected |
AbstractIV(byte flags)
Constructor used when decoding since you already have the flags.
|
protected |
AbstractIV(VTE vte,
boolean inline,
boolean extension,
DTE dte)
The RDF Value type (URI, BNode, Literal or Statement) and the data type
are combined and stored in a single byte together with whether the RDF
value has been inlined (an inline bit) and whether the RDF Value
is an extended data type (the extension> bit).
|
Modifier and Type | Method and Description |
---|---|
abstract int |
_compareTo(IV o)
Compare two
IV s having the same intrinsic datatype. |
int |
compareTo(IV o)
Imposes an ordering of IVs based on their natural sort ordering in the
index as unsigned byte[]s.
|
IKeyBuilder |
encode(IKeyBuilder keyBuilder)
Encode the
IV as an unsigned byte[]. |
abstract boolean |
equals(Object o)
Return true iff the two
IV s are the same point in the same value
space. |
byte |
flags()
|
DTE |
getDTE()
|
static DTE |
getDTE(byte flags)
Helper method decodes a flags byte as found in a statement index key to
an
DTE . |
DTEExtension |
getDTEX()
IFF
IV.getDTE() returns DTE.Extension then this method will
report the DTEExtension value that specifies the intrinsic
datatype for this IV. |
static VTE |
getInternalValueTypeEnum(byte flags)
Helper method decodes a flags byte as found in a statement index key to
an
VTE . |
V |
getValue()
Return a pre-materialized RDF
BigdataValue which has been cached
on this IV by a previous invocation of
IVCache.asValue(LexiconRelation) . |
protected V |
getValueCache()
Return the cached
BigdataValue or -null if it is not
cached. |
VTE |
getVTE()
|
static VTE |
getVTE(byte flags)
Return the
VTE encoding in a flags byte. |
abstract int |
hashCode()
Return a hash code based on the value of the point in the value space.
|
boolean |
hasValue()
Returns true if the RDF
BigdataValue has been pre-materialized
and cached on this IV . |
boolean |
isBigNumeric()
true for xsd:integer and xsd:decimal. |
boolean |
isBNode()
Return
true iff this is an RDF BlankNode. |
boolean |
isExtension()
|
static boolean |
isExtension(byte flags)
Return
true if the flags byte has its extension
bit set. |
boolean |
isFixedNumeric()
This is
!isBigNumeric() and is true for any of
the fixed length numeric data types (xsd:byte, xsd:unsignedByte,
xsd:short, xsd:unsignedShort, xsd:int, xsd:unsignedInt, xsd:long,
xsd:unsignedLong, xsd:float, xsd:double). |
boolean |
isFloatingPointNumeric()
true for xsd:float, xsd:double, and xsd:decimal |
boolean |
isInline()
true iff the RDF value is directly represented inline. |
static boolean |
isInline(byte flags)
Return
true if the flags byte has its inline
bit set. |
boolean |
isLiteral()
Return
true iff this is an RDF Literal. |
boolean |
isNullIV()
|
boolean |
isNumeric()
true for any of the numeric data types (xsd:byte,
xsd:unsignedByte, xsd:short, xsd:unsignedShort, xsd:int, xsd:unsignedInt,
xsd:long, xsd:unsignedLong, xsd:float, xsd:double, xsd:integer, and
xsd:decimal). |
boolean |
isResource()
Return
true iff this is a URI or a bnode. |
boolean |
isSignedNumeric()
true for an signed numeric datatype ( xsd:byte,
xsd:short, xsd:int, xsd:long, xsd:float, xsd:double, xsd:integer, and
xsd:decimal). |
boolean |
isStatement()
Return
true iff this is a statement identifier (this feature
is enabled with AbstractTripleStore.Options.STATEMENT_IDENTIFIERS ). |
boolean |
isUnsignedNumeric()
true for an unsigned numeric datatype ( xsd:unsignedByte,
xsd:unsignedShort, xsd:unsignedInt, xsd:unsignedLong). |
boolean |
isURI()
Return
true iff this is an RDF URI . |
boolean |
isVocabulary()
|
V |
setValue(V v)
Set the
BigdataValue on the cache. |
static byte |
toFlags(VTE vte,
boolean inline,
boolean extension,
DTE dte)
Return the
flags byte that encodes the provided metadata
about an internal value . |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
byteLength, getInlineValue, needsMaterialization
protected AbstractIV(VTE vte, boolean inline, boolean extension, DTE dte)
[vviedddd]where
v
is a VTE
bit, i
is the
inline bit, e
is the extension bit, and
d
is a DTE
bit.vte
- The RDF Value type (URI, BNode, Literal, or Statement).inline
- true
iff the RDF value will be represented inline
in the key. When false
, the term identifier of
the RDF Value will be represented inline instead of its actual
value.extension
- When true
, the actual RDF data type URI differs
from the intrinsic data type (the DTE
) but has been
projected onto the natural order of the intrinsic data type.dte
- The internal datatype for the RDF value (termId, xsd:int,
xsd:long, xsd:float, xsd:double, etc).VTE
,
DTE
protected AbstractIV(byte flags)
flags
- The flags.public static byte toFlags(VTE vte, boolean inline, boolean extension, DTE dte)
flags
byte that encodes the provided metadata
about an internal value
.vte
- The value typeinline
- true
iff the value is inline (no index access is
required to materialize the value).extension
- true
iff the value is an extension data type (a
user specific data type defined whose underlying data type is
specified by the DTE
).dte
- The basic data type.public final byte flags()
IV
VTE
and the DTE
.
The upper TWO (2) bits code the VTE
while the lower SIX (6) bits
code the DTE
.flags
in interface IV<V extends BigdataValue,T>
public static boolean isInline(byte flags)
true
if the flags byte has its inline
bit set.flags
- The flags byte.public static boolean isExtension(byte flags)
true
if the flags byte has its extension
bit set.flags
- The flags byte.public static final VTE getVTE(byte flags)
VTE
encoding in a flags byte.
Note: VTE.valueOf(byte)
assumes that the VTE bits are in the TWO
(2) LSB bits of the byte. However, the VTE bits are actually stored in
the TWO (2) MSB bits of the flags byte. This method is responsible
for shifting the VTE bits down before invoking VTE.valueOf(byte)
.
flags
- A flags byte.VTE
encoded in the flags byte.public final VTE getVTE()
IV
getVTE
in interface IV<V extends BigdataValue,T>
public DTEExtension getDTEX()
IV
IV.getDTE()
returns DTE.Extension
then this method will
report the DTEExtension
value that specifies the intrinsic
datatype for this IV.getDTEX
in interface IV<V extends BigdataValue,T>
(Implement support for DTE extension types for URIs)
,
( DTEExtension for compressed timestamp)
public static final VTE getInternalValueTypeEnum(byte flags)
VTE
.flags
- The flags byte.VTE
public static DTE getDTE(byte flags)
DTE
.flags
- The flags byte.DTE
public final boolean isLiteral()
IV
true
iff this is an RDF Literal. Note that some kinds
of RDF Literals MAY be represented inline.isLiteral
in interface IV<V extends BigdataValue,T>
public final boolean isBNode()
IV
true
iff this is an RDF BlankNode.isBNode
in interface IV<V extends BigdataValue,T>
public final boolean isURI()
IV
true
iff this is an RDF URI
.isURI
in interface IV<V extends BigdataValue,T>
public final boolean isStatement()
IV
true
iff this is a statement identifier (this feature
is enabled with AbstractTripleStore.Options.STATEMENT_IDENTIFIERS
).isStatement
in interface IV<V extends BigdataValue,T>
public final boolean isResource()
IV
true
iff this is a URI or a bnode.isResource
in interface IV<V extends BigdataValue,T>
public boolean isInline()
true
iff the RDF value is directly represented inline. When
an RDF Value is "inline" its value can be directly decoded from its
representation in the keys of the statement indices.
This implementation based on the inline
bit flag. This can
be overridden in many derived classes which have compile time knowledge
of whether the RDF value is inline or not.
isInline
in interface IV<V extends BigdataValue,T>
public boolean isExtension()
true
iff the flags
byte is followed by an
IV
which defines how the subsequent value (represented according
to the DTE
) will be interpreted. This is used to support
projections of value spaces for data type literals onto the intrinsic
types. It is also used to support indirect resolution of the namespace
associated with a URI.
This implementation based on the extension
bit flag. Since
the extension flag is only used for specific kinds of IV
s, this
method can be overridden in many derived classes which have compile time
knowledge of whether the value is an RDF Literal
or not.
isExtension
in interface IV<V extends BigdataValue,T>
public boolean isVocabulary()
isVocabulary
in interface IV<V extends BigdataValue,T>
public boolean isNullIV()
true
iff the IV
represents a null
IV
reference. null
IV
s are somewhat special.
They get used as wild cards for the keys in the justifications index and
perhaps (?) in a few other locations.
This implementation returns false
. It is overridden by
TermId
.
isNullIV
in interface IV<V extends BigdataValue,T>
public boolean isNumeric()
IV
true
for any of the numeric data types (xsd:byte,
xsd:unsignedByte, xsd:short, xsd:unsignedShort, xsd:int, xsd:unsignedInt,
xsd:long, xsd:unsignedLong, xsd:float, xsd:double, xsd:integer, and
xsd:decimal).isNumeric
in interface IV<V extends BigdataValue,T>
public final boolean isSignedNumeric()
IV
true
for an signed numeric datatype ( xsd:byte,
xsd:short, xsd:int, xsd:long, xsd:float, xsd:double, xsd:integer, and
xsd:decimal).isSignedNumeric
in interface IV<V extends BigdataValue,T>
public final boolean isUnsignedNumeric()
IV
true
for an unsigned numeric datatype ( xsd:unsignedByte,
xsd:unsignedShort, xsd:unsignedInt, xsd:unsignedLong).isUnsignedNumeric
in interface IV<V extends BigdataValue,T>
public final boolean isFixedNumeric()
IV
!isBigNumeric()
and is true
for any of
the fixed length numeric data types (xsd:byte, xsd:unsignedByte,
xsd:short, xsd:unsignedShort, xsd:int, xsd:unsignedInt, xsd:long,
xsd:unsignedLong, xsd:float, xsd:double).isFixedNumeric
in interface IV<V extends BigdataValue,T>
public final boolean isBigNumeric()
IV
true
for xsd:integer and xsd:decimal.isBigNumeric
in interface IV<V extends BigdataValue,T>
public final boolean isFloatingPointNumeric()
IV
true
for xsd:float, xsd:double, and xsd:decimalisFloatingPointNumeric
in interface IV<V extends BigdataValue,T>
public abstract int hashCode()
Note: The IV
implementations typically DO NOT return hash codes
that are consistent with BigdataValue#hashCode()
. Therefore you
MUST NOT mix IV
s and BigdataValue
s in the keys of a map
or the values of a set.
public abstract boolean equals(Object o)
IV
s are the same point in the same value
space. Points in different value spaces (as identified by different
datatype URIs) are NOT equal even if they have the same value in the
corresponding primitive data type.
Note: The IV
implementations typically DO NOT compare equals()
with BigdataValue
s. Therefore you MUST NOT mix IV
s and
BigdataValue
s in the keys of a map or the values of a set.
public final int compareTo(IV o)
compareTo
in interface Comparable<IV>
public IKeyBuilder encode(IKeyBuilder keyBuilder)
IV
IV
as an unsigned byte[].public final V getValue()
IVCache
BigdataValue
which has been cached
on this IV
by a previous invocation of
IVCache.asValue(LexiconRelation)
.getValue
in interface IVCache<V extends BigdataValue,T>
BigdataValue
.public final V setValue(V v)
IVCache
BigdataValue
on the cache.
Note: This is normally invoked by IVCache.asValue(LexiconRelation)
during a lexicon join cache a newly materialized Value
on the
IV
.
setValue
in interface IVCache<V extends BigdataValue,T>
v
- The BigdataValue
.protected final V getValueCache()
BigdataValue
or -null
if it is not
cached.public final boolean hasValue()
IVCache
BigdataValue
has been pre-materialized
and cached on this IV
.hasValue
in interface IVCache<V extends BigdataValue,T>
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.