Class DoubleArrayEncoding

All Implemented Interfaces:
Encoding<double[]>, NaturalSortAware, Serializable, Comparator<double[]>

public class DoubleArrayEncoding extends Base64ArrayEncoding<double[],Double>
double[] array type. Does not support null arrays.

Array elements are encoded using DoubleEncoding, and the array is terminated by 0x0000000000000000L, which is an encoded value that can never be emitted by DoubleEncoding.

See Also:
  • Constructor Details

    • DoubleArrayEncoding

      public DoubleArrayEncoding(EncodingId encodingId)
  • Method Details

    • withEncodingId

      public DoubleArrayEncoding withEncodingId(EncodingId encodingId)
      Description copied from interface: Encoding
      Build an encoding that has the given EncodingId but is otherwise equivalent to this encoding.

      If this encoding already has encodingId, then this method may (but is not required to) return this same instance.

      Parameters:
      encodingId - new encoding's EncodingId, or null for an anonymized encoding
      Returns:
      a version of this encoding with the given EncodingId
    • read

      public double[] read(ByteReader reader)
      Description copied from interface: Encoding
      Read a value from the given input.
      Parameters:
      reader - byte input
      Returns:
      field value (possibly null)
    • write

      public void write(ByteWriter writer, double[] array)
      Description copied from interface: Encoding
      Write a value to the given output.
      Parameters:
      writer - byte output
      array - value to write (possibly null)
    • skip

      public void skip(ByteReader reader)
      Description copied from interface: Encoding
      Read and discard a byte[] encoded value from the given input.
      Parameters:
      reader - byte input
    • hasPrefix0xff

      public boolean hasPrefix0xff()
      Description copied from interface: Encoding
      Determine whether any of this encoding's encoded values start with a 0xff byte. Certain optimizations are possible when this is not the case. It is safe for this method to always return true.

      Note: changing the result of this method may result in an incompatible encoding if this encoding is wrapped in another class.

      The implementation in Encoding returns true.

      Returns:
      true if an encoded value starting with 0xff exists
    • getArrayLength

      protected int getArrayLength(double[] array)
      Description copied from class: ArrayEncoding
      Get the length of the given array.
      Specified by:
      getArrayLength in class ArrayEncoding<double[],Double>
      Parameters:
      array - non-null array
      Returns:
      array length
    • getArrayElement

      protected Double getArrayElement(double[] array, int index)
      Description copied from class: ArrayEncoding
      Get an element from the given array.
      Specified by:
      getArrayElement in class ArrayEncoding<double[],Double>
      Parameters:
      array - non-null array
      index - index of target element in array
      Returns:
      array element at index index
    • createArray

      protected double[] createArray(List<Double> elements)
      Description copied from class: ArrayEncoding
      Create a new array instance containing the given elements.
      Specified by:
      createArray in class ArrayEncoding<double[],Double>
      Parameters:
      elements - content for the new array
      Returns:
      newly created array
    • encode

      protected void encode(double[] array, DataOutputStream output) throws IOException
      Specified by:
      encode in class Base64ArrayEncoding<double[],Double>
      Throws:
      IOException
    • decode

      protected double[] decode(DataInputStream input, int numBytes) throws IOException
      Specified by:
      decode in class Base64ArrayEncoding<double[],Double>
      Throws:
      IOException