public class GenericStorableCodec<S extends Storable> extends java.lang.Object implements StorableCodec<S>
GenericStorableCodecFactory
Modifier and Type | Class and Description |
---|---|
static interface |
GenericStorableCodec.Decoder<S extends Storable>
Used for decoding different generations of Storable.
|
static interface |
GenericStorableCodec.SearchKeyFactory<S extends Storable>
Creates custom raw search keys for
Storable types. |
Modifier and Type | Method and Description |
---|---|
void |
decode(S dest,
int generation,
byte[] data)
Used for decoding different generations of Storable.
|
byte[] |
encodePrimaryKey(java.lang.Object[] values)
Encode a key by extracting all the primary key properties from the given
storable.
|
byte[] |
encodePrimaryKey(java.lang.Object[] values,
int rangeStart,
int rangeEnd)
Encode a key by extracting all the primary key properties from the given
storable.
|
byte[] |
encodePrimaryKey(S storable)
Encode a key by extracting all the primary key properties from the given
storable.
|
byte[] |
encodePrimaryKey(S storable,
int rangeStart,
int rangeEnd)
Encode a key by extracting all the primary key properties from the given
storable.
|
byte[] |
encodePrimaryKeyPrefix()
Encode the primary key for when there are no values, but there may be a
prefix.
|
GenericStorableCodec.Decoder<S> |
getDecoder(int generation)
Deprecated.
use direct decode method
|
StorableIndex<S> |
getPrimaryKeyIndex()
Returns the sequence and directions of properties that make up the
primary key.
|
int |
getPrimaryKeyPrefixLength()
Returns the number of prefix bytes in the primary key, which may be
zero.
|
GenericStorableCodec.SearchKeyFactory<S> |
getSearchKeyFactory(OrderedProperty<S>[] properties)
Returns a search key factory, which is useful for implementing indexes
and queries.
|
java.lang.Class<? extends S> |
getStorableClass()
Returns a concrete Storable implementation, which is fully
thread-safe.
|
java.lang.Class<S> |
getStorableType()
Returns the type of Storable that code is generated for.
|
RawSupport<S> |
getSupport()
Returns the default
RawSupport object that is supplied to
Storable instances produced by this codec. |
S |
instantiate()
Instantiate a Storable with no key or value defined yet.
|
S |
instantiate(byte[] key)
Instantiate a Storable with no value defined yet.
|
S |
instantiate(byte[] key,
byte[] value)
Instantiate a Storable with a specific key and value.
|
S |
instantiate(RawSupport<S> support)
Instantiate a Storable with no key or value defined yet.
|
S |
instantiate(RawSupport<S> support,
byte[] key,
byte[] value)
Instantiate a Storable with a specific key and value.
|
public final java.lang.Class<S> getStorableType()
getStorableType
in interface StorableCodec<S extends Storable>
public S instantiate()
RawSupport
is supplied to the instance.instantiate
in interface StorableCodec<S extends Storable>
java.lang.IllegalStateException
- if no default support existspublic S instantiate(byte[] key) throws FetchException
RawSupport
is supplied to the instance.instantiate
in interface StorableCodec<S extends Storable>
java.lang.IllegalStateException
- if no default support existsFetchException
public S instantiate(byte[] key, byte[] value) throws FetchException
RawSupport
is supplied to the instance.instantiate
in interface StorableCodec<S extends Storable>
java.lang.IllegalStateException
- if no default support existsFetchException
public S instantiate(RawSupport<S> support)
RawSupport
can be supplied to the instance.instantiate
in interface StorableCodec<S extends Storable>
support
- binds generated storable with a storage layerpublic S instantiate(RawSupport<S> support, byte[] key, byte[] value) throws FetchException
RawSupport
can be supplied to the instance.instantiate
in interface StorableCodec<S extends Storable>
support
- binds generated storable with a storage layerFetchException
public StorableIndex<S> getPrimaryKeyIndex()
StorableCodec
getPrimaryKeyIndex
in interface StorableCodec<S extends Storable>
public int getPrimaryKeyPrefixLength()
StorableCodec
getPrimaryKeyPrefixLength
in interface StorableCodec<S extends Storable>
public byte[] encodePrimaryKey(S storable)
StorableCodec
encodePrimaryKey
in interface StorableCodec<S extends Storable>
storable
- extract primary key properties from this instancepublic byte[] encodePrimaryKey(S storable, int rangeStart, int rangeEnd)
StorableCodec
encodePrimaryKey
in interface StorableCodec<S extends Storable>
storable
- extract primary key properties from this instancerangeStart
- index of first property to use. Its value must be less
than the count of primary key properties.rangeEnd
- index of last property to use, exlusive. Its value must
be less than or equal to the count of primary key properties.public byte[] encodePrimaryKey(java.lang.Object[] values)
StorableCodec
encodePrimaryKey
in interface StorableCodec<S extends Storable>
values
- values to build into a key. It must be long enough to
accommodate all primary key properties.public byte[] encodePrimaryKey(java.lang.Object[] values, int rangeStart, int rangeEnd)
StorableCodec
encodePrimaryKey
in interface StorableCodec<S extends Storable>
values
- values to build into a key. The length may be less than
the amount of primary key properties used by this factory. It must not
be less than the difference between rangeStart and rangeEnd.rangeStart
- index of first property to use. Its value must be less
than the count of primary key properties.rangeEnd
- index of last property to use, exlusive. Its value must
be less than or equal to the count of primary key properties.public byte[] encodePrimaryKeyPrefix()
StorableCodec
encodePrimaryKeyPrefix
in interface StorableCodec<S extends Storable>
public RawSupport<S> getSupport()
StorableCodec
RawSupport
object that is supplied to
Storable instances produced by this codec.getSupport
in interface StorableCodec<S extends Storable>
public java.lang.Class<? extends S> getStorableClass()
public <init>(Storage, RawSupport); public <init>(Storage, RawSupport, byte[] key, byte[] value);Convenience methods are provided in this class to instantiate the generated Storable.
public GenericStorableCodec.SearchKeyFactory<S> getSearchKeyFactory(OrderedProperty<S>[] properties)
properties
- properties to build the search key frompublic void decode(S dest, int generation, byte[] data) throws CorruptEncodingException
StorableCodec
decode
in interface StorableCodec<S extends Storable>
dest
- storable to receive decoded propertiesgeneration
- storable layout generation numberdata
- decoded into properties, some of which may be dropped if
destination storable doesn't have itCorruptEncodingException
- if generation is unknown or if data cannot be decoded@Deprecated public GenericStorableCodec.Decoder<S> getDecoder(int generation) throws FetchNoneException, FetchException
FetchNoneException
- if generation is unknownFetchException
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.