com.bigdata.search
Class FullTextIndexTupleSerializer<V extends Comparable<V>>

java.lang.Object
  extended by com.bigdata.btree.DefaultTupleSerializer<ITermDocKey<V>,ITermDocVal>
      extended by com.bigdata.search.FullTextIndexTupleSerializer<V>
All Implemented Interfaces:
ITupleSerializer<ITermDocKey<V>,ITermDocVal>, IKeyBuilderFactory, Externalizable, Serializable

public class FullTextIndexTupleSerializer<V extends Comparable<V>>
extends DefaultTupleSerializer<ITermDocKey<V>,ITermDocVal>

Class manages the encoding and decoding of keys for the full text index. You can override this class to change the way in which the keys and/or values of the index are stored. For example, the RDF database does this to use variable length document identifiers.

Version:
$Id: FullTextIndexTupleSerializer.java 4702 2011-06-13 16:25:38Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Constructor Summary
FullTextIndexTupleSerializer()
          De-serialization constructor.
FullTextIndexTupleSerializer(IKeyBuilderFactory keyBuilderFactory, IRabaCoder leafKeysCoder, IRabaCoder leafValsCoder, boolean fieldsEnabled)
           
 
Method Summary
 ITermDocRecord<V> deserialize(ITuple tuple)
          De-serializes an object from the value stored in the tuple (ignores the key stored in the tuple).
protected  ITermDocKey<V> deserialize(ITuple tuple, boolean keyOnly)
           
 ITermDocKey<V> deserializeKey(ITuple tuple)
          This is an unsupported operation.
 boolean isFieldsEnabled()
           
 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(ITermDocVal obj)
          Serializes the object as a byte[] using Java default serialization.
 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

FullTextIndexTupleSerializer

public FullTextIndexTupleSerializer()
De-serialization constructor.


FullTextIndexTupleSerializer

public FullTextIndexTupleSerializer(IKeyBuilderFactory keyBuilderFactory,
                                    IRabaCoder leafKeysCoder,
                                    IRabaCoder leafValsCoder,
                                    boolean fieldsEnabled)
Parameters:
keyBuilderFactory - This factory governs the Unicode collation order that will be imposed on the indexed tokens.
leafKeysCoder - The coder used for the leaf keys (prefix coding is fine).
leafValsCoder - The coder used for the leaf values (custom coding may provide tighter representations of the ITermDocVals in the index entries).
fieldsEnabled - When true the fieldId will be included as a component in the generated key. When false it will not be present in the generated key.
Method Detail

isFieldsEnabled

public boolean isFieldsEnabled()

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<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Overrides:
serializeKey in class DefaultTupleSerializer<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
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(ITermDocVal obj)
Description copied from class: DefaultTupleSerializer
Serializes the object as a byte[] using Java default serialization.

Specified by:
serializeVal in interface ITupleSerializer<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Overrides:
serializeVal in class DefaultTupleSerializer<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Parameters:
obj - The object to be serialized (MAY be null).
Returns:
The serialized representation of the object as a byte[] -or- null if the reference is null.

deserializeKey

public ITermDocKey<V> 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<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Overrides:
deserializeKey in class DefaultTupleSerializer<ITermDocKey<V extends Comparable<V>>,ITermDocVal>

deserialize

public ITermDocRecord<V> 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<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Overrides:
deserialize in class DefaultTupleSerializer<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Parameters:
tuple - The tuple.
Returns:
The de-serialized object.

deserialize

protected ITermDocKey<V> deserialize(ITuple tuple,
                                     boolean keyOnly)

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class DefaultTupleSerializer<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class DefaultTupleSerializer<ITermDocKey<V extends Comparable<V>>,ITermDocVal>
Throws:
IOException


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