java.lang.Object
org.apache.lucene.backward_codecs.lucene50.ForUtil

final class ForUtil extends Object
Encode all values in normal area with fixed bit width, which is determined by the max value in this block.
  • Field Details

    • ALL_VALUES_EQUAL

      private static final int ALL_VALUES_EQUAL
      Special number of bits per value used whenever all values to encode are equal.
      See Also:
    • MAX_ENCODED_SIZE

      static final int MAX_ENCODED_SIZE
      Upper limit of the number of bytes that might be required to stored BLOCK_SIZE encoded values.
      See Also:
    • MAX_DATA_SIZE

      static final int MAX_DATA_SIZE
      Upper limit of the number of values that might be decoded in a single call to readBlock(IndexInput, byte[], int[]). Although values after BLOCK_SIZE are garbage, it is necessary to allocate value buffers whose size is >= MAX_DATA_SIZE to avoid ArrayIndexOutOfBoundsExceptions.
    • encodedSizes

      private final int[] encodedSizes
    • encoders

      private final PackedInts.Encoder[] encoders
    • decoders

      private final PackedInts.Decoder[] decoders
    • iterations

      private final int[] iterations
  • Constructor Details

  • Method Details

    • computeIterations

      private static int computeIterations(PackedInts.Decoder decoder)
      Compute the number of iterations required to decode BLOCK_SIZE values with the provided PackedInts.Decoder.
    • encodedSize

      private static int encodedSize(PackedInts.Format format, int packedIntsVersion, int bitsPerValue)
      Compute the number of bytes required to encode a block of values that require bitsPerValue bits per value with format format.
    • writeBlock

      void writeBlock(int[] data, byte[] encoded, IndexOutput out) throws IOException
      Write a block of data (For format).
      Parameters:
      data - the data to write
      encoded - a buffer to use to encode data
      out - the destination output
      Throws:
      IOException - If there is a low-level I/O error
    • readBlock

      void readBlock(IndexInput in, byte[] encoded, int[] decoded) throws IOException
      Read the next block of data (For format).
      Parameters:
      in - the input to use to read data
      encoded - a buffer that can be used to store encoded data
      decoded - where to write decoded data
      Throws:
      IOException - If there is a low-level I/O error
    • skipBlock

      void skipBlock(IndexInput in) throws IOException
      Skip the next block of data.
      Parameters:
      in - the input where to read data
      Throws:
      IOException - If there is a low-level I/O error
    • isAllEqual

      private static boolean isAllEqual(int[] data)
    • bitsRequired

      private static int bitsRequired(int[] data)
      Compute the number of bits required to serialize any of the longs in data.