com.bigdata.rdf.spo
Class JustificationTupleSerializer

java.lang.Object
  extended by com.bigdata.btree.DefaultTupleSerializer<Justification,Justification>
      extended by com.bigdata.rdf.spo.JustificationTupleSerializer
All Implemented Interfaces:
ITupleSerializer<Justification,Justification>, IKeyBuilderFactory, Externalizable, Serializable

public class JustificationTupleSerializer
extends DefaultTupleSerializer<Justification,Justification>

(De-)serializes Justifications.

Note: the encoded key for a Justification is formed from the 64-bit long term identifier for the head of the rule (the entailment) followed by the term identifier bindings for the tail(s) of the rule. The bindings are represented as a long[] and indexing into the bindings is by position. Bindings in the tail of a rule MAY be ZERO (0L) in which case they are interpreted as wildcards.

Note: No values are stored for this index - all the information is in the keys.

Note: While the static methods used to decode an existing key are safe for concurrent readers, concurrent readers also form keys using Justification.getKey(IKeyBuilder, Justification) and therefore require a thread-local IKeyBuilder.

Version:
$Id: JustificationTupleSerializer.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Constructor Summary
JustificationTupleSerializer()
          De-serialization constructor.
JustificationTupleSerializer(int N)
           
 
Method Summary
 Justification deserialize(ITuple tuple)
          De-serializes an object from the value stored in the tuple (ignores the key stored in the tuple).
 Justification deserializeKey(ITuple tuple)
          This is an unsupported operation.
 void readExternal(ObjectInput in)
           
 byte[] serializeKey(Object obj)
          Serialize a facet of an object's state that places the object into the total sort order for the index.
 byte[] serializeVal(Justification jst)
          There is no value for the justifications index.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class com.bigdata.btree.DefaultTupleSerializer
getDefaultKeyBuilderFactory, getDefaultLeafKeysCoder, getDefaultValuesCoder, getKeyBuilder, getLeafKeysCoder, getLeafValuesCoder, newInstance, serializeVal, setLeafKeysCoder, setLeafValuesCoder, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JustificationTupleSerializer

public JustificationTupleSerializer()
De-serialization constructor.


JustificationTupleSerializer

public JustificationTupleSerializer(int N)
Parameters:
N - The #of slots in a statement (3 or 4).
Method Detail

deserialize

public Justification deserialize(ITuple tuple)
Description copied from class: DefaultTupleSerializer
De-serializes an object from the value stored in the tuple (ignores the key stored in the tuple).

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

deserializeKey

public Justification deserializeKey(ITuple tuple)
Description copied from class: DefaultTupleSerializer
This is an unsupported operation. Additional information is required to either decode the internal unsigned byte[] keys or to extract the key from the de-serialized value (if it is being stored in that value). You can either write your own ITupleSerializer or you can specialize this one so that it can de-serialize your keys using whichever approach makes the most sense for your data.

Specified by:
deserializeKey in interface ITupleSerializer<Justification,Justification>
Overrides:
deserializeKey in class DefaultTupleSerializer<Justification,Justification>

serializeKey

public byte[] serializeKey(Object obj)
Description copied from interface: ITupleSerializer
Serialize a facet of an object's state that places the object into the total sort order for the index. This method is automatically applied by IAutoboxBTree.insert(Object, Object) and friends to convert the key object into an unsigned variable length byte[].

Note: This handles the conversion between an object and the unsigned variable length byte[] representation of that object which determines its place within the total index order. Since this transform imposes the total order of the index, different techniques are applied here than are applied to the serialization of the index values.

Specified by:
serializeKey in interface ITupleSerializer<Justification,Justification>
Overrides:
serializeKey in class DefaultTupleSerializer<Justification,Justification>
Parameters:
obj - A object (MAY NOT be null).
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(Justification jst)
There is no value for the justifications index. All data is in the key.

Parameters:
jst - An object (MAY NOT be null).
Returns:
A byte[] containing the serialized state of the object -or- null if no value will be stored under the serialized key.
Throws:
UnsupportedOperationException - always

readExternal

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

writeExternal

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


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