Interface ObjectCodec<TYPE>

All Superinterfaces:
ObjectDecoder<TYPE>
All Known Implementing Classes:
BigDecimalCodec, BigDecimalParquetBytesCodec, BigIntegerCodec, BigIntegerParquetBytesCodec, ExternalizableCodec, LocalDateCodec, LocalTimeCodec, MapCodec, RowSetCodec, SerializableCodec, SimpleByteArrayCodec, StringBooleanMapCodec, StringDoubleMapCodec, StringFloatMapCodec, StringIntMapCodec, StringLongMapCodec, StringStringMapCodec, UTF8StringAsByteArrayCodec, ZonedDateTimeCodec

public interface ObjectCodec<TYPE> extends ObjectDecoder<TYPE>

Codec interface for Object translation to/from byte arrays for serialization and deserialization.

Implementations must follow several rules to enable correct usage:

  1. They must be stateless or designed for concurrent use (e.g. by using only ThreadLocal state), as they will generally be cached and re-used.
  2. They must not modify their inputs in any way, retain references to their inputs, or return results that retain references to their inputs.
  3. They should provide a public constructor that takes a single String argument, in order to allow configuration-driven reflective instantiation.
  • Method Details

    • encode

      byte @NotNull [] encode(@Nullable TYPE input)
      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.
      Parameters:
      input - The input object, possibly null
      Returns:
      The output byte array
    • isNullable

      boolean isNullable()
      Does this codec support encoding of null values?
      Returns:
      if null values are supported
    • getPrecision

      int getPrecision()
      If applicable, the maximum encodable precision. If precision is not applicable (i.e. for non-numeric types) this method should return zero.
      Returns:
      the numeric precision supported by this codec
    • getScale

      int getScale()
      If applicable, the maximum encodable scale. If scale is not applicable (i.e. for non-numeric types) this method should return zero.
      Returns:
      the numeric scale (digits after the decimal point) supported by this codec