|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ITupleSerializer<K,V>
An interface that provides for the (de)-serialization of the value of a tuple stored in an index and, when possible, the key under which that value is stored.
The encoded key is always a variable length unsigned byte[]s. The purpose of
the encoded key is to determine the total order over the tuple in the B+Tree.
While some key encodings are reversible without less (e.g., int, long, float
or double), many key encodings are simply not decodable (including Unicode
keys). Applications that require the ability to decode complex keys may need
to resort to storing the unencoded key state redundantly in the tuple value.
FIXME extSer integration. There are two broad setups. (1) Local: when running
without an IMetadataService and hence on a single
AbstractJournal, the serializer state should be stored in a record
whose address is available from the CommitRecordIndex of the
Journal. (2) Distributed: when running a distributed federation the
serializer state should be stored globally so that the serialized values can
be consistently interpreted as they are moved from BTree to
IndexSegment and from IndexSegment to IndexSegment.
I am inclined to store the serializer state for the distributed federation on a per-scale-out index basis. This means that you must de-serialize the keys and values in order to copy tuples from one scale-out index to another. However, when copying tuples from one federation to another de-serialization and re-serialization will be required regardless since the serializer state will not be shared and, in fact, could be different for the two indices (this is also true within a single federation or even within a scale-up instance). (There should probably be a utility class to do index copies that handles these various cases).
The critical point is being able to recover the reference to the (potentially
remote) extSer object from within both the AbstractBTree and the
various ITupleIterator implementations, including the
AbstractChunkedTupleIterator. Further, the recovered object must
cache the extSer state, must have a reasonable life cycle so that it is
efficient, and must be linked into the commit protocol such that assigned
class identifiers are always made persistent if a commit could have included
data written using those class identifiers.
| Method Summary | |
|---|---|
V |
deserialize(ITuple tuple)
De-serialize an object from an ITuple. |
K |
deserializeKey(ITuple tuple)
De-serialize the application key from an ITuple (optional
operation). |
IKeyBuilder |
getKeyBuilder()
Factory for thread-safe IKeyBuilder objects for use by
serializeKey(Object) and possibly others. |
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. |
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)
Serialize the persistent state of the object (the value stored in the index under the key for that object). |
| Method Detail |
|---|
IKeyBuilder getKeyBuilder()
Factory for thread-safe IKeyBuilder objects for use by
serializeKey(Object) and possibly others.
Note: A mutable B+Tree is always single-threaded. However, read-only B+Trees allow concurrent readers. Therefore, thread-safety requirement is safe for either a single writers -or- for concurrent readers.
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.
Note: This IKeyBuilder SHOULD be used to form all keys for
this index. This is critical for indices that have Unicode data
in their application keys as the formation of Unicode sort keys from
Unicode data depends on the IKeyBuilderFactory. If you use a
locally configured IKeyBuilder then your Unicode keys will be
encoded based on the Locale configured for the JVM NOT the
factory specified for this index.
getKeyBuilder in interface IKeyBuilderFactorybyte[] serializeKey(Object obj)
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.
obj - A object (MAY NOT be null).
null (
null keys are not allowed into an index).
IllegalArgumentException - if obj is null.byte[] serializeVal(V obj)
IAutoboxBTree.insert(Object, Object) and friends to
convert the value object into an byte[].
obj - An object (MAY NOT be null).
null if no value will be stored under the
serialized key.
IllegalArgumentException - if obj is null.V deserialize(ITuple tuple)
ITuple. This method is
automatically applied by methods on the IAutoboxBTree interface
that return the object stored under a key and by
ITuple.getObject().
tuple - The tuple.
IllegalArgumentException - if tuple is null.K deserializeKey(ITuple tuple)
ITuple (optional
operation).
Note: There is no general means to recover the application key from the B+Tree. However, there are two approaches, either of which may work for your data.
deserialize(ITuple) and return
the appropriate field or synthetic property value. KeyBuilder. For example, int, long, float, double, etc. However
this is NOT possible for Unicode Strings.
Note: The B+Tree does NOT rely on this method. It is used to support the
materialization of the key required to allow BigdataMap and
BigdataSet to fulfill their respective APIs.
UnsupportedOperationException - if this operation is not implemented.IRabaCoder getLeafKeysCoder()
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.
IRabaCoder getLeafValuesCoder()
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||