|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
@InterfaceAudience.Public @InterfaceStability.Evolving public interface DataType<T>
DataType is the base class for all HBase data types. Data
type implementations are designed to be serialized to and deserialized from
byte[]. Serialized representations can retain the natural sort ordering of
the source object, when a suitable encoding is supported by the underlying
implementation. This is a desirable feature for use in rowkeys and column
qualifiers.
DataTypes are different from Hadoop Writables in two
significant ways. First, DataType describes how to serialize a
value, it does not encapsulate a serialized value. Second, DataType
implementations provide hints to consumers about relationships between the
POJOs they represent and richness of the encoded representation.
Data type instances are designed to be stateless, thread-safe, and reused.
Implementations should provide static final instances corresponding
to each variation on configurable parameters. This is to encourage and
simplify instance reuse. For instance, order-preserving types should provide
static ASCENDING and DESCENDING instances. It is also encouraged for
implementations operating on Java primitive types to provide primitive
implementations of the encode and decode methods. This
advice is a performance consideration to clients reading and writing values
in tight loops.
| Method Summary | |
|---|---|
T |
decode(PositionedByteRange src)
Read an instance of T from the buffer src. |
int |
encode(PositionedByteRange dst,
T val)
Write instance val into buffer dst. |
Class<T> |
encodedClass()
Inform consumers over what type this DataType operates. |
int |
encodedLength(T val)
Inform consumers how long the encoded byte[] will be. |
Order |
getOrder()
Retrieve the sort Order imposed by this data type, or null when
natural ordering is not preserved. |
boolean |
isNullable()
Indicates whether this instance supports encoding null values. |
boolean |
isOrderPreserving()
Indicates whether this instance writes encoded byte[]'s
which preserve the natural sort order of the unencoded value. |
boolean |
isSkippable()
Indicates whether this instance is able to skip over it's encoded value. |
int |
skip(PositionedByteRange src)
Skip src's position forward over one encoded value. |
| Method Detail |
|---|
boolean isOrderPreserving()
byte[]'s
which preserve the natural sort order of the unencoded value.
true when natural order is preserved,
false otherwise.Order getOrder()
Order imposed by this data type, or null when
natural ordering is not preserved. Value is either ascending or
descending. Default is assumed to be Order.ASCENDING.
boolean isNullable()
DataTypes that support null should treat null as comparing
less than any non-null value for default sort ordering purposes.
true when null is supported, false otherwise.boolean isSkippable()
DataTypes that are not skippable can only be used as the
right-most field of a Struct.
int encodedLength(T val)
byte[] will be.
val - The value to check.
val.aClass<T> encodedClass()
DataType operates. Useful
when working with bare DataType instances.
int skip(PositionedByteRange src)
src's position forward over one encoded value.
src - the buffer containing the encoded value.
T decode(PositionedByteRange src)
T from the buffer src.
src - the buffer containing the encoded value.
int encode(PositionedByteRange dst,
T val)
val into buffer dst.
dst - the buffer containing the encoded value.val - the value to encode onto dst.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||