Class ShortArrayCodec

java.lang.Object
io.deephaven.enterprise.codec.ShortArrayCodec
All Implemented Interfaces:
ObjectCodec<short[]>, ObjectDecoder<short[]>

public class ShortArrayCodec extends Object implements ObjectCodec<short[]>
An ObjectCodec that encodes a short[] using one integer to indicate the array size and then the array items sequentially.
  • Constructor Details

    • ShortArrayCodec

      public ShortArrayCodec()
    • ShortArrayCodec

      public ShortArrayCodec(String[] args)
    • ShortArrayCodec

      public ShortArrayCodec(String args)
  • Method Details

    • encodeAndGet

      public ByteBuffer encodeAndGet(short[] input)
      Encode the input array into the internal buffer and return it.
      Parameters:
      input - the array to encode
      Returns:
      a reference to the internal byte buffer
    • maybeGetResizedBuffer

      @NotNull public static ByteBuffer maybeGetResizedBuffer(@Nullable short[] input, @Nullable ByteBuffer origBuffer)
      Inspect the input buffer. If it is large enough to encode input, clear and return it, otherwise allocate a new buffer with an appropriate capacity and return that.
      Parameters:
      input - the input to encode
      origBuffer - the original buffer to maybe resize.
      Returns:
      a properly sized byte buffer to encode input.
    • encodeInto

      public static void encodeInto(@Nullable short[] input, @NotNull ByteBuffer byteBuffer)
      Encode the input values to the specified buffer.
      Parameters:
      input - the input, may be null.
      byteBuffer - the buffer to encode into
    • decode

      @Nullable public short[] decode(@NotNull ByteBuffer byteBuffer)
      Decode a short array from the input ByteBuffer
      Parameters:
      byteBuffer - the buffer containing the encoded short array
      Returns:
      the decoded short array
    • decodeStatic

      @Nullable public static short[] decodeStatic(@Nullable ByteBuffer byteBuffer)
    • encode

      @NotNull public byte[] encode(@Nullable short[] input)
      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 (e.g. CollectionUtil.ZERO_LENGTH_BYTE_ARRAY) is strongly encouraged.
      Specified by:
      encode in interface ObjectCodec<short[]>
      Parameters:
      input - The input object, possibly null
      Returns:
      The output byte array
    • isNullable

      public boolean isNullable()
      Description copied from interface: ObjectCodec
      Does this codec support encoding of null values?
      Specified by:
      isNullable in interface ObjectCodec<short[]>
      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 interface ObjectCodec<short[]>
      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 interface ObjectCodec<short[]>
      Returns:
      the numeric scale (digits after the decimal point) supported by this codec
    • decode

      @Nullable public short[] decode(@NotNull byte[] input, int offset, int length)
      Description copied from interface: ObjectDecoder
      Decode an object from an array of bytes.
      Specified by:
      decode in interface ObjectDecoder<short[]>
      Parameters:
      input - The input byte array containing bytes to decode
      offset - The offset into the byte array to start decoding from
      length - The length of the byte array to decode from, 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 interface ObjectDecoder<short[]>
      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.