Class Struct
 Struct is a simple DataType for implementing "compound rowkey" and "compound
 qualifier" schema design strategies.
 
Encoding
 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.
 
Trailing Nulls
 Struct treats the right-most nullable field members as special. Rather than writing null
 values to the output buffer, Struct omits those records all together. When reading back a
 value, it will look for the scenario where the end of the buffer has been reached but there are
 still nullable fields remaining in the Struct definition. When this happens, it will
 produce null entries for the remaining values. For example:
 
 StructBuilder builder = new StructBuilder()
     .add(OrderedNumeric.ASCENDING) // nullable
     .add(OrderedString.ASCENDING)  // nullable
 Struct shorter = builder.toStruct();
 Struct longer = builder.add(OrderedNumeric.ASCENDING) // nullable
     .toStruct();
 PositionedByteRange buf1 = new SimplePositionedByteRange(7);
 PositionedByteRange buf2 = new SimplePositionedByteRange(7);
 Object[] val = new Object[] { BigDecimal.ONE, "foo" };
 shorter.encode(buf1, val); // write short value with short Struct
 buf1.setPosition(0); // reset position marker, prepare for read
 longer.decode(buf1); // => { BigDecimal.ONE, "foo", null } ; long Struct reads implied null
 longer.encode(buf2, val); // write short value with long struct
 Bytes.equals(buf1.getBytes(), buf2.getBytes()); // => true; long Struct skips writing null
 
 Sort Order
 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.
 
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final DataType[]protected final booleanprotected final boolean
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionObject[]Read an instance ofTfrom the buffersrc.decode(PositionedByteRange src, int index) Read the field atindex.intencode(PositionedByteRange dst, Object[] val) Write instancevalinto bufferdst.Inform consumers over what type thisDataTypeoperates.intencodedLength(Object[] val) Inform consumers how long the encodedbyte[]will be.getOrder()Retrieve the sortOrderimposed by this data type, or null when natural ordering is not preserved.booleanIndicates whether this instance supports encoding null values.booleanIndicates whether this instance writes encodedbyte[]'s which preserve the natural sort order of the unencoded value.booleanIndicates whether this instance is able to skip over it's encoded value.Retrieve anIteratorover the values encoded insrc.intskip(PositionedByteRange src) Skipsrc's position forward over one encoded value.
- 
Field Details- 
fields
- 
isOrderPreserving
- 
isSkippable
 
- 
- 
Constructor Details- 
StructCreate a newStructinstance defined as the sequence ofHDataTypes inmemberTypes.A StructisorderPreservingwhen all of its fields areorderPreserving. AStructisskippablewhen all of its fields areskippable.
 
- 
- 
Method Details- 
isOrderPreservingDescription copied from interface:DataTypeIndicates whether this instance writes encodedbyte[]'s which preserve the natural sort order of the unencoded value.- Specified by:
- isOrderPreservingin interface- DataType<Object[]>
- Returns:
- truewhen natural order is preserved,- falseotherwise.
 
- 
getOrderDescription copied from interface:DataTypeRetrieve the sortOrderimposed by this data type, or null when natural ordering is not preserved. Value is either ascending or descending. Default is assumed to beOrder.ASCENDING.
- 
isNullableDescription copied from interface:DataTypeIndicates whether this instance supports encoding null values. This depends on the implementation details of the encoding format. AllDataTypes that support null should treat null as comparing less than any non-null value for default sort ordering purposes.- Specified by:
- isNullablein interface- DataType<Object[]>
- Returns:
- truewhen null is supported,- falseotherwise.
 
- 
isSkippableDescription copied from interface:DataTypeIndicates whether this instance is able to skip over it's encoded value.DataTypes that are not skippable can only be used as the right-most field of aStruct.- Specified by:
- isSkippablein interface- DataType<Object[]>
 
- 
encodedLengthDescription copied from interface:DataTypeInform consumers how long the encodedbyte[]will be.- Specified by:
- encodedLengthin interface- DataType<Object[]>
- Parameters:
- val- The value to check.
- Returns:
- the number of bytes required to encode val.a
 
- 
encodedClassDescription copied from interface:DataTypeInform consumers over what type thisDataTypeoperates. Useful when working with bareDataTypeinstances.- Specified by:
- encodedClassin interface- DataType<Object[]>
 
- 
iteratorRetrieve anIteratorover the values encoded insrc.src's position is consumed by consuming this iterator.
- 
skipDescription copied from interface:DataTypeSkipsrc's position forward over one encoded value.
- 
decodeDescription copied from interface:DataTypeRead an instance ofTfrom the buffersrc.
- 
decodeRead the field atindex.src's position is not affected.
- 
encodeDescription copied from interface:DataTypeWrite instancevalinto bufferdst.
 
-