com.bigdata.rdf.lexicon
Class Id2TermTupleSerializer

java.lang.Object
  extended by com.bigdata.btree.DefaultTupleSerializer<IV,BigdataValue>
      extended by com.bigdata.rdf.lexicon.Id2TermTupleSerializer
All Implemented Interfaces:
ITupleSerializer<IV,BigdataValue>, IKeyBuilderFactory, Externalizable, Serializable

public class Id2TermTupleSerializer
extends DefaultTupleSerializer<IV,BigdataValue>

Encapsulates key and value formation for the reverse lexicon index.

Version:
$Id: Id2TermTupleSerializer.java 6116 2012-03-13 20:39:17Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Constructor Summary
Id2TermTupleSerializer()
          De-serialization ctor.
Id2TermTupleSerializer(String namespace, BigdataValueFactory valueFactory)
           
Id2TermTupleSerializer(String namespace, BigdataValueFactory valueFactory, IKeyBuilderFactory keyBuilderFactory, IRabaCoder leafKeysCoder, IRabaCoder leafValsCoder)
           
 
Method Summary
 BigdataValue deserialize(ITuple tuple)
          De-serializes the ITuple as a BigdataValue, including the term identifier extracted from the unsigned byte[] key, and sets the appropriate BigdataValueFactoryImpl reference on that object.
 IV deserializeKey(ITuple tuple)
          Decodes the term identifier key to a term identifier.
 byte[] id2key(TermId<?> tid)
          Generates an unsigned byte[] key from a TermId.
 void readExternal(ObjectInput in)
           
 byte[] serializeKey(Object obj)
          Return the unsigned byte[] key for a term identifier.
 byte[] serializeVal(BigdataValue obj)
          Return the byte[] value, which is the serialization of an RDF Value.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class com.bigdata.btree.DefaultTupleSerializer
getDefaultKeyBuilderFactory, getDefaultLeafKeysCoder, getDefaultValuesCoder, getKeyBuilder, getLeafKeysCoder, getLeafValuesCoder, newInstance, setLeafKeysCoder, setLeafValuesCoder, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Id2TermTupleSerializer

public Id2TermTupleSerializer()
De-serialization ctor.


Id2TermTupleSerializer

public Id2TermTupleSerializer(String namespace,
                              BigdataValueFactory valueFactory)
Parameters:
keyBuilderFactory - A factory that does not support unicode and has an initialCapacity of .

Id2TermTupleSerializer

public Id2TermTupleSerializer(String namespace,
                              BigdataValueFactory valueFactory,
                              IKeyBuilderFactory keyBuilderFactory,
                              IRabaCoder leafKeysCoder,
                              IRabaCoder leafValsCoder)
Method Detail

id2key

public byte[] id2key(TermId<?> tid)
Generates an unsigned byte[] key from a TermId.

Note: The code that handles efficient batch insertion of terms into the database replicates the logic for encoding the term identifier as an unsigned long integer.

Parameters:
id - The term identifier.
Returns:
The id expressed as an unsigned byte[] key of length 8.
See Also:
#key2Id()

deserializeKey

public IV deserializeKey(ITuple tuple)
Decodes the term identifier key to a term identifier.

Specified by:
deserializeKey in interface ITupleSerializer<IV,BigdataValue>
Overrides:
deserializeKey in class DefaultTupleSerializer<IV,BigdataValue>
Parameters:
key - The key for an entry in the id:term index.
Returns:
The term identifier.

serializeKey

public byte[] serializeKey(Object obj)
Return the unsigned byte[] key for a term identifier.

Specified by:
serializeKey in interface ITupleSerializer<IV,BigdataValue>
Overrides:
serializeKey in class DefaultTupleSerializer<IV,BigdataValue>
Parameters:
obj - The term identifier as a TermId.
Returns:
An unsigned byte[] which places the object into the total sort order for the index and never null ( null keys are not allowed into an index).

serializeVal

public byte[] serializeVal(BigdataValue obj)
Return the byte[] value, which is the serialization of an RDF Value.

Specified by:
serializeVal in interface ITupleSerializer<IV,BigdataValue>
Overrides:
serializeVal in class DefaultTupleSerializer<IV,BigdataValue>
Parameters:
obj - An RDF Value.
Returns:
The serialized representation of the object as a byte[] -or- null if the reference is null.

deserialize

public BigdataValue deserialize(ITuple tuple)
De-serializes the ITuple as a BigdataValue, including the term identifier extracted from the unsigned byte[] key, and sets the appropriate BigdataValueFactoryImpl reference on that object.

Specified by:
deserialize in interface ITupleSerializer<IV,BigdataValue>
Overrides:
deserialize in class DefaultTupleSerializer<IV,BigdataValue>
Parameters:
tuple - The tuple.
Returns:
The de-serialized object.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class DefaultTupleSerializer<IV,BigdataValue>
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class DefaultTupleSerializer<IV,BigdataValue>
Throws:
IOException


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