Interface ObjectCodec<TYPE>

All Superinterfaces:
ObjectDecoder<TYPE>
All Known Implementing Classes:
BigDecimalCodec, BigDecimalParquetBytesCodec, BigIntegerCodec, BigIntegerParquetBytesCodec, ByteArrayCodec, ByteArrayCodec, CharArrayCodec, DoubleArrayCodec, ExternalizableCodec, FloatArrayCodec, IndexCodec, IntArrayCodec, IntArrayCodec, LocalDateCodec, LocalTimeCodec, LongArrayCodec, LongArrayCodec, MapCodec, SerializableCodec, ShortArrayCodec, StringArrayCodec, 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

      @NotNull byte[] 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 (e.g. CollectionUtil.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