Package io.deephaven.util.codec
Class MapCodec<K,V>
java.lang.Object
io.deephaven.util.codec.MapCodec<K,V>
- All Implemented Interfaces:
ObjectCodec<Map<K,
,V>> ObjectDecoder<Map<K,
V>>
- Direct Known Subclasses:
StringBooleanMapCodec
,StringDoubleMapCodec
,StringFloatMapCodec
,StringIntMapCodec
,StringLongMapCodec
,StringStringMapCodec
ObjectCodec implementation for Maps of type K to V.
Each map is encoded as an integer length, followed by encoded pairs of key values.
A null map is represented as an array of zero bytes.
-
Field Summary
Fields inherited from interface io.deephaven.util.codec.ObjectDecoder
VARIABLE_WIDTH_SENTINEL
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(byte @NotNull [] input, int offset, int length) Decode an object from an array of bytes.decode
(@NotNull ByteBuffer byteBuffer) Decode an object from a ByteBuffer.byte @NotNull []
Encode the specified input as an array of bytes.int
What width byte array does this ObjectCodec expect to encode and decode?int
If applicable, the maximum encodable precision.int
getScale()
If applicable, the maximum encodable scale.boolean
Does this codec support encoding of null values?Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.deephaven.util.codec.ObjectDecoder
checkWidth
-
Method Details
-
isNullable
public boolean isNullable()Description copied from interface:ObjectCodec
Does this codec support encoding of null values?- Specified by:
isNullable
in interfaceObjectCodec<K>
- Returns:
- if null values are supported
-
getPrecision
public int getPrecision()Description copied from interface:ObjectCodec
If applicable, the maximum encodable precision. If precision is not applicable (i.e. for non-numeric types) this method should return zero.- Specified by:
getPrecision
in interfaceObjectCodec<K>
- Returns:
- the numeric precision supported by this codec
-
getScale
public int getScale()Description copied from interface:ObjectCodec
If applicable, the maximum encodable scale. If scale is not applicable (i.e. for non-numeric types) this method should return zero.- Specified by:
getScale
in interfaceObjectCodec<K>
- Returns:
- the numeric scale (digits after the decimal point) supported by this codec
-
encode
Description copied from interface:ObjectCodec
Encode the specified input as an array of bytes. Note that it is up to the implementation how to encode null inputs. The use of a zero-length byte array is strongly encouraged.- Specified by:
encode
in interfaceObjectCodec<K>
- Parameters:
input
- The input object, possibly null- Returns:
- The output byte array
-
decode
Description copied from interface:ObjectDecoder
Decode an object from a ByteBuffer. The position of the input buffer may or may not be modified by this method.- Specified by:
decode
in interfaceObjectDecoder<K>
- Parameters:
byteBuffer
- The input ByteBuffer containing bytes to decode- Returns:
- The output object, possibly null
-
decode
Description copied from interface:ObjectDecoder
Decode an object from an array of bytes.- Specified by:
decode
in interfaceObjectDecoder<K>
- Parameters:
input
- The input byte array containing bytes to decodeoffset
- The offset into the byte array to start decoding fromlength
- The number of bytes to decode, starting at the offset- Returns:
- The output object, possibly null
-
expectedObjectWidth
public int expectedObjectWidth()Description copied from interface:ObjectDecoder
What width byte array does this ObjectCodec expect to encode and decode?- Specified by:
expectedObjectWidth
in interfaceObjectDecoder<K>
- Returns:
- VARIABLE_WIDTH_SENTINEL if the codec must encode and decode variable width columns, otherwise the fixed size of byte array that must be decoded and encoded.
-