|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.btree.DefaultTupleSerializer<K,V>
public class DefaultTupleSerializer<K,V>
Default implementation uses the KeyBuilder to format the object as a
key and uses Java default serialization for the value. You only need to
subclass this if you want to use custom (de-)serialization of the value,
custom conversion of the application key to an unsigned byte[], or if you
have a special type of application key such that you are able to decode the
unsigned byte[] and materialize the corresponding application key.
| Constructor Summary | |
|---|---|
DefaultTupleSerializer()
De-serialization ctor only. |
|
DefaultTupleSerializer(IKeyBuilderFactory keyBuilderFactory)
|
|
DefaultTupleSerializer(IKeyBuilderFactory keyBuilderFactory,
IRabaCoder leafKeysCoder,
IRabaCoder leafValsCoder)
|
|
| Method Summary | |
|---|---|
V |
deserialize(ITuple tuple)
De-serializes an object from the value stored
in the tuple (ignores the key stored in the tuple). |
K |
deserializeKey(ITuple tuple)
This is an unsupported operation. |
static IKeyBuilderFactory |
getDefaultKeyBuilderFactory()
Deprecated. by IndexMetadata.Options.KEY_BUILDER_FACTORY |
static IRabaCoder |
getDefaultLeafKeysCoder()
Deprecated. by IndexMetadata.Options.LEAF_KEYS_CODER |
static IRabaCoder |
getDefaultValuesCoder()
Deprecated. by IndexMetadata.Options.LEAF_VALUES_CODER |
IKeyBuilder |
getKeyBuilder()
A thread-local IKeyBuilder instance. |
IRabaCoder |
getLeafKeysCoder()
The object used to code (compress) an ordered array of keys such as found in a B+Tree ILeafData record or in a ResultSet. |
IRabaCoder |
getLeafValuesCoder()
The object used to code (compress) an unordered array of values ordered array of keys such as found in a B+Tree ILeafData record or in a
ResultSet. |
static ITupleSerializer |
newInstance()
Factory for a new instance using default values for the getKeyBuilder(), the getLeafKeysCoder(), and the
getLeafValuesCoder(). |
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(V obj)
Serializes the object as a byte[] using Java default serialization. |
void |
setLeafKeysCoder(IRabaCoder leafKeysCoder)
Override the getLeafKeysCoder(). |
void |
setLeafValuesCoder(IRabaCoder valuesCoder)
Override the getLeafValuesCoder(). |
String |
toString()
|
void |
writeExternal(ObjectOutput out)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultTupleSerializer()
public DefaultTupleSerializer(IKeyBuilderFactory keyBuilderFactory)
keyBuilderFactory - The IKeyBuilderFactory, which will be automatically
wrapped up by a ThreadLocalKeyBuilderFactory.
public DefaultTupleSerializer(IKeyBuilderFactory keyBuilderFactory,
IRabaCoder leafKeysCoder,
IRabaCoder leafValsCoder)
| Method Detail |
|---|
public static final IKeyBuilderFactory getDefaultKeyBuilderFactory()
IndexMetadata.Options.KEY_BUILDER_FACTORY
IKeyBuilderFactory.
public static final IRabaCoder getDefaultLeafKeysCoder()
IndexMetadata.Options.LEAF_KEYS_CODER
getLeafKeysCoder() (compression for the keys
stored in a leaf).
public static final IRabaCoder getDefaultValuesCoder()
IndexMetadata.Options.LEAF_VALUES_CODER
getLeafValuesCoder() (compression for
the values stored in a leaf).
public final IRabaCoder getLeafKeysCoder()
ITupleSerializerILeafData record or in a ResultSet.
Note: If you change this value in a manner that is not backward compatible once entries have been written on the index then you may be unable to any read data already written.
getLeafKeysCoder in interface ITupleSerializer<K,V>public final IRabaCoder getLeafValuesCoder()
ITupleSerializerILeafData record or in a
ResultSet.
Note: If you change this value in a manner that is not backward compatible once entries have been written on the index then you may be unable to any read data already written.
getLeafValuesCoder in interface ITupleSerializer<K,V>public final void setLeafKeysCoder(IRabaCoder leafKeysCoder)
getLeafKeysCoder(). It is NOT safe to change
this value once data have been stored in an IIndex using another
value as existing data MAY become unreadable.
leafKeysCoder - The new value.public final void setLeafValuesCoder(IRabaCoder valuesCoder)
getLeafValuesCoder(). It is NOT safe to change
this value once data have been stored in an IIndex using another
value as existing data MAY become unreadable.
valuesCoder - The new value.public static ITupleSerializer newInstance()
getKeyBuilder(), the getLeafKeysCoder(), and the
getLeafValuesCoder().
public String toString()
toString in class Objectpublic final IKeyBuilder getKeyBuilder()
IKeyBuilder instance.
Note: By default, the getKeyBuilder() uses whatever default is
in place on the host/JVM where the DefaultTupleSerializer
instance was first created. That backing IKeyBuilderFactory
object is serialized along with the DefaultTupleSerializer so
that the specific configuration values are persisted, even when the
DefaultTupleSerializer is de-serialized on a different host.
getKeyBuilder in interface ITupleSerializer<K,V>getKeyBuilder in interface IKeyBuilderFactorypublic byte[] serializeKey(Object obj)
ITupleSerializerIAutoboxBTree.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.
serializeKey in interface ITupleSerializer<K,V>obj - A object (MAY NOT be null).
null (
null keys are not allowed into an index).public byte[] serializeVal(V obj)
serializeVal in interface ITupleSerializer<K,V>obj - The object to be serialized (MAY be null).
null if the reference is null.public V deserialize(ITuple tuple)
value stored
in the tuple (ignores the key stored in the tuple).
deserialize in interface ITupleSerializer<K,V>tuple - The tuple.
public K deserializeKey(ITuple tuple)
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.
deserializeKey in interface ITupleSerializer<K,V>UnsupportedOperationException - always.
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
readExternal in interface ExternalizableIOException
ClassNotFoundException
public void writeExternal(ObjectOutput out)
throws IOException
writeExternal in interface ExternalizableIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||