|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.types.Struct
@InterfaceAudience.Public @InterfaceStability.Evolving public class Struct
Struct is a simple DataType for implementing "compound
rowkey" and "compound qualifier" schema design strategies.
Struct member values are encoded onto the target byte[] in the order
in which they are declared. A Struct may be used as a member of
another Struct. Structs are not nullable but their
component fields may be.
Struct instances sort according to the composite order of their
fields, that is, left-to-right and depth-first. This can also be thought of
as lexicographic comparison of concatenated members.
StructIterator is provided as a convenience for consuming the
sequence of values. Users may find it more appropriate to provide their own
custom DataType for encoding application objects rather than using
this Object[] implementation. Examples are provided in test.
StructIterator,
DataType.isNullable()| Field Summary | |
|---|---|
protected DataType[] |
fields
|
protected boolean |
isOrderPreserving
|
protected boolean |
isSkippable
|
| Constructor Summary | |
|---|---|
Struct(DataType[] memberTypes)
Create a new Struct instance defined as the sequence of
HDataTypes in memberTypes. |
|
| Method Summary | |
|---|---|
Object[] |
decode(PositionedByteRange src)
Read an instance of T from the buffer src. |
Object |
decode(PositionedByteRange src,
int index)
Read the field at index. |
int |
encode(PositionedByteRange dst,
Object[] val)
Write instance val into buffer dst. |
Class<Object[]> |
encodedClass()
Inform consumers over what type this DataType operates. |
int |
encodedLength(Object[] 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. |
StructIterator |
iterator(PositionedByteRange src)
Retrieve an Iterator over the values encoded in src. |
int |
skip(PositionedByteRange src)
Skip src's position forward over one encoded value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final DataType[] fields
protected final boolean isOrderPreserving
protected final boolean isSkippable
| Constructor Detail |
|---|
public Struct(DataType[] memberTypes)
Struct instance defined as the sequence of
HDataTypes in memberTypes.
A Struct is orderPreserving when all of its fields
are orderPreserving. A Struct is skippable when
all of its fields are skippable.
| Method Detail |
|---|
public boolean isOrderPreserving()
DataTypebyte[]'s
which preserve the natural sort order of the unencoded value.
isOrderPreserving in interface DataType<Object[]>true when natural order is preserved,
false otherwise.public Order getOrder()
DataTypeOrder 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.
getOrder in interface DataType<Object[]>public boolean isNullable()
DataTypeDataTypes that support null should treat null as comparing
less than any non-null value for default sort ordering purposes.
isNullable in interface DataType<Object[]>true when null is supported, false otherwise.public boolean isSkippable()
DataTypeDataTypes that are not skippable can only be used as the
right-most field of a Struct.
isSkippable in interface DataType<Object[]>public int encodedLength(Object[] val)
DataTypebyte[] will be.
encodedLength in interface DataType<Object[]>val - The value to check.
val.apublic Class<Object[]> encodedClass()
DataTypeDataType operates. Useful
when working with bare DataType instances.
encodedClass in interface DataType<Object[]>public StructIterator iterator(PositionedByteRange src)
Iterator over the values encoded in src.
src's position is consumed by consuming this iterator.
public int skip(PositionedByteRange src)
DataTypesrc's position forward over one encoded value.
skip in interface DataType<Object[]>src - the buffer containing the encoded value.
public Object[] decode(PositionedByteRange src)
DataTypeT from the buffer src.
decode in interface DataType<Object[]>src - the buffer containing the encoded value.
public Object decode(PositionedByteRange src,
int index)
index. src's position is not affected.
public int encode(PositionedByteRange dst,
Object[] val)
DataTypeval into buffer dst.
encode in interface DataType<Object[]>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 | |||||||||