com.bigdata.rdf.internal.impl.uri
Class VocabURIShortIV<V extends BigdataURI>

java.lang.Object
  extended by com.bigdata.rdf.internal.impl.AbstractIV<V,T>
      extended by com.bigdata.rdf.internal.impl.AbstractInlineIV<V,Short>
          extended by com.bigdata.rdf.internal.impl.uri.VocabURIShortIV<V>
All Implemented Interfaces:
IV<V,Short>, IVCache<V,Short>, Serializable, Comparable<IV>, Resource, URI, Value

public class VocabURIShortIV<V extends BigdataURI>
extends AbstractInlineIV<V,Short>
implements URI

A fully inlined representation of a URI based on a short code. The flags byte looks like: VTE=URI, inline=true, extension=false, DTE=XSDShort. It is followed by an unsigned short value which is the index of the URI in the Vocabulary class for the triple store.

Author:
thompsonbry
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.bigdata.rdf.internal.impl.AbstractIV
flags
 
Constructor Summary
VocabURIShortIV(short value)
           
 
Method Summary
 int _compareTo(IV o)
          Compare two IVs having the same intrinsic datatype.
 V asValue(LexiconRelation lex)
          If the value is not already cached, then inflate an inline RDF value to a BigdataValue and cache it on a private field.
 int byteLength()
          The byte length of the encoded IV.
 IV<V,Short> clone(boolean clearCache)
          Return a copy of this IV.
 boolean equals(Object o)
          Return true iff the two values are the same point in the same value space.
 Short getInlineValue()
          Return the Java Object corresponding to the inline value.
 String getLocalName()
          Implements URI.getLocalName().
 String getNamespace()
          Implements URI.getNamespace().
 int hashCode()
          Return the hash code of the short value.
 boolean isVocabulary()
          Return true iff this IV is a Vocabulary item.
 boolean needsMaterialization()
          Because we only store an index into the vocabulary, we need the materialized URI to answer the URI interface methods.
 String stringValue()
          Implements Value.stringValue().
 String toString()
           
 
Methods inherited from class com.bigdata.rdf.internal.impl.AbstractInlineIV
isInline
 
Methods inherited from class com.bigdata.rdf.internal.impl.AbstractIV
compareTo, encode, flags, getDTE, getInternalDataTypeEnum, getInternalValueTypeEnum, getValue, getValueCache, getVTE, getVTE, hasValue, isBigNumeric, isBNode, isExtension, isExtension, isFixedNumeric, isFloatingPointNumeric, isInline, isLiteral, isNullIV, isNumeric, isResource, isSignedNumeric, isStatement, isUnsignedNumeric, isURI, setValue, toFlags
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VocabURIShortIV

public VocabURIShortIV(short value)
Method Detail

clone

public IV<V,Short> clone(boolean clearCache)
Return a copy of this IV.

Note: This method exists to defeat the hard reference from the IV to the cached BigdataValue in order to avoid a memory leak when the IV is used as the key in a weak value cache whose value is the BigdataValue. Therefore, certain IV implementations MAY return this when they are used for limited collections. The vocabulary IVs are the primary example. For the same reason, we do not need to recursively break the link from the IV to the BigdataValue for IVs which embed other IVs.

Note: Always returns this. (The rationale is that the vocabulary IVs already pin their cached value so there is no point in creating a clone with the cleared cache reference.)

Specified by:
clone in interface IVCache<V extends BigdataURI,Short>
Parameters:
clearCache - When true the cached reference (if any) will NOT be set on the copy.
Returns:
The copy.
See Also:
(Thread-local cache combined with unbounded thread pools causes effective memory leak)

isVocabulary

public final boolean isVocabulary()
Return true iff this IV is a Vocabulary item.

The default implementation returns false.

Overridden to return true.

Specified by:
isVocabulary in interface IV<V extends BigdataURI,Short>
Overrides:
isVocabulary in class AbstractIV<V extends BigdataURI,Short>

_compareTo

public int _compareTo(IV o)
Description copied from class: AbstractIV
Compare two IVs having the same intrinsic datatype.

Specified by:
_compareTo in class AbstractIV<V extends BigdataURI,Short>

equals

public boolean equals(Object o)
Description copied from class: AbstractIV
Return true iff the two values 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.

Specified by:
equals in interface URI
Specified by:
equals in class AbstractIV<V extends BigdataURI,Short>

hashCode

public final int hashCode()
Return the hash code of the short value.

Specified by:
hashCode in interface URI
Specified by:
hashCode in class AbstractIV<V extends BigdataURI,Short>

asValue

public V asValue(LexiconRelation lex)
                             throws UnsupportedOperationException
Description copied from interface: IVCache
If the value is not already cached, then inflate an inline RDF value to a BigdataValue and cache it on a private field.

Note: Query plans are responsible for ensuring that IVs have been materialized before operators are evaluated which invoke this method. This pattern ensures that efficient batch operators are used to materialize Values, and thereby avoids heavy RMI overhead in scale-out, and provides operators which use IVCache.getValue() with a simple method signature which does not require access to the lexicon. Query plans are also responsible for dropping variables once they are no longer needed or, in the case of large values and BLOBs, dropping the cached BigdataValue when possible in order to avoid excess network and heap overhead.

Specified by:
asValue in interface IVCache<V extends BigdataURI,Short>
Parameters:
lex - The lexicon relation (this is required in order to access the BigdataValueFactory for the namespace associated with lexicon when we materialize an inline IV).
Returns:
The corresponding BigdataValue.
Throws:
UnsupportedOperationException - if the IV does not represent something which can be materialized. For example, a dummy value or a "null".

byteLength

public final int byteLength()
Description copied from interface: IV
The byte length of the encoded IV.

Specified by:
byteLength in interface IV<V extends BigdataURI,Short>

getInlineValue

public final Short getInlineValue()
Description copied from interface: IV
Return the Java Object corresponding to the inline value.

Specified by:
getInlineValue in interface IV<V extends BigdataURI,Short>
Returns:
The Object.

toString

public String toString()
Specified by:
toString in interface URI
Overrides:
toString in class Object

needsMaterialization

public boolean needsMaterialization()
Because we only store an index into the vocabulary, we need the materialized URI to answer the URI interface methods.

Specified by:
needsMaterialization in interface IV<V extends BigdataURI,Short>

stringValue

public String stringValue()
Implements Value.stringValue().

Specified by:
stringValue in interface Value

getLocalName

public String getLocalName()
Implements URI.getLocalName().

Specified by:
getLocalName in interface URI

getNamespace

public String getNamespace()
Implements URI.getNamespace().

Specified by:
getNamespace in interface URI


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