public class DefaultTupleSerializer<K,V> extends Object implements ITupleSerializer<K,V>, Externalizable
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 and Description |
---|
DefaultTupleSerializer()
De-serialization ctor only.
|
DefaultTupleSerializer(IKeyBuilderFactory keyBuilderFactory) |
DefaultTupleSerializer(IKeyBuilderFactory keyBuilderFactory,
IRabaCoder leafKeysCoder,
IRabaCoder leafValsCoder) |
Modifier and Type | Method and Description |
---|---|
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.
|
static IRabaCoder |
getDefaultLeafKeysCoder()
Deprecated.
|
static IRabaCoder |
getDefaultValuesCoder()
Deprecated.
|
IKeyBuilder |
getKeyBuilder()
A thread-local
IKeyBuilder instance. |
IRabaCoder |
getLeafKeysCoder()
|
IRabaCoder |
getLeafValuesCoder()
|
IKeyBuilder |
getPrimaryKeyBuilder()
Return an instance of the configured
IKeyBuilder that has been
overridden to have StrengthEnum.Primary collation strength. |
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) |
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)
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()
ITupleSerializer
ILeafData
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()
ITupleSerializer
ILeafData
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 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 IKeyBuilderFactory
public final IKeyBuilder getPrimaryKeyBuilder()
IKeyBuilderFactory
IKeyBuilder
that has been
overridden to have StrengthEnum.Primary
collation strength. This
may be used to form successors for Unicode prefix scans without having
the secondary sort ordering characteristics mucking things up.getPrimaryKeyBuilder
in interface IKeyBuilderFactory
public byte[] serializeKey(Object obj)
ITupleSerializer
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.
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 Externalizable
IOException
ClassNotFoundException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.