Package org.apache.hadoop.hbase.types
Class TerminatedWrapper<T>
java.lang.Object
org.apache.hadoop.hbase.types.TerminatedWrapper<T>
- All Implemented Interfaces:
DataType<T>
- Direct Known Subclasses:
RawBytesTerminated
,RawStringTerminated
Wraps an existing
DataType
implementation as a terminated version of itself. This has the
useful side-effect of turning an existing DataType
which is not skippable
into a
skippable
variant.-
Field Summary
-
Constructor Summary
ConstructorDescriptionTerminatedWrapper
(DataType<T> wrapped, byte[] term) Create a terminated version of thewrapped
.TerminatedWrapper
(DataType<T> wrapped, String term) Create a terminated version of thewrapped
. -
Method Summary
Modifier and TypeMethodDescriptionRead an instance ofT
from the buffersrc
.int
encode
(PositionedByteRange dst, T val) Write instanceval
into bufferdst
.Inform consumers over what type thisDataType
operates.int
encodedLength
(T val) Inform consumers how long the encodedbyte[]
will be.getOrder()
Retrieve the sortOrder
imposed by this data type, or null when natural ordering is not preserved.boolean
Indicates whether this instance supports encoding null values.boolean
Indicates whether this instance writes encodedbyte[]
's which preserve the natural sort order of the unencoded value.boolean
Indicates whether this instance is able to skip over it's encoded value.int
skip
(PositionedByteRange src) Skipsrc
's position forward over one encoded value.protected int
Return the position at whichterm
begins withinsrc
, or-1
ifterm
is not found.
-
Field Details
-
wrapped
-
term
-
-
Constructor Details
-
TerminatedWrapper
Create a terminated version of thewrapped
.- Throws:
IllegalArgumentException
- whenterm
is null or empty.
-
TerminatedWrapper
Create a terminated version of thewrapped
.term
is converted to abyte[]
usingBytes.toBytes(String)
.- Throws:
IllegalArgumentException
- whenterm
is null or empty.
-
-
Method Details
-
isOrderPreserving
Description copied from interface:DataType
Indicates whether this instance writes encodedbyte[]
's which preserve the natural sort order of the unencoded value.- Specified by:
isOrderPreserving
in interfaceDataType<T>
- Returns:
true
when natural order is preserved,false
otherwise.
-
getOrder
Description copied from interface:DataType
Retrieve the sortOrder
imposed by this data type, or null when natural ordering is not preserved. Value is either ascending or descending. Default is assumed to beOrder.ASCENDING
. -
isNullable
Description copied from interface:DataType
Indicates whether this instance supports encoding null values. This depends on the implementation details of the encoding format. AllDataType
s that support null should treat null as comparing less than any non-null value for default sort ordering purposes.- Specified by:
isNullable
in interfaceDataType<T>
- Returns:
true
when null is supported,false
otherwise.
-
isSkippable
Description copied from interface:DataType
Indicates whether this instance is able to skip over it's encoded value.DataType
s that are not skippable can only be used as the right-most field of aStruct
.- Specified by:
isSkippable
in interfaceDataType<T>
-
encodedLength
Description copied from interface:DataType
Inform consumers how long the encodedbyte[]
will be.- Specified by:
encodedLength
in interfaceDataType<T>
- Parameters:
val
- The value to check.- Returns:
- the number of bytes required to encode
val
.a
-
encodedClass
Description copied from interface:DataType
Inform consumers over what type thisDataType
operates. Useful when working with bareDataType
instances.- Specified by:
encodedClass
in interfaceDataType<T>
-
terminatorPosition
Return the position at whichterm
begins withinsrc
, or-1
ifterm
is not found. -
skip
Skipsrc
's position forward over one encoded value.- Specified by:
skip
in interfaceDataType<T>
- Parameters:
src
- the buffer containing the encoded value.- Returns:
- number of bytes skipped.
- Throws:
IllegalArgumentException
- when the terminator sequence is not found.
-
decode
Description copied from interface:DataType
Read an instance ofT
from the buffersrc
. -
encode
Write instanceval
into bufferdst
.- Specified by:
encode
in interfaceDataType<T>
- Parameters:
dst
- the buffer containing the encoded value.val
- the value to encode ontodst
.- Returns:
- number of bytes written.
- Throws:
IllegalArgumentException
- when the encoded representation ofval
contains theterm
sequence.
-