Class BitTableUtil

java.lang.Object
org.apache.lucene.util.fst.BitTableUtil

class BitTableUtil extends Object
Static helper methods for FST.Arc.BitTable.
  • Constructor Details

    • BitTableUtil

      BitTableUtil()
  • Method Details

    • isBitSet

      static boolean isBitSet(int bitIndex, FST.BytesReader reader) throws IOException
      Returns whether the bit at given zero-based index is set.
      Example: bitIndex 10 means the third bit on the right of the second byte.
      Parameters:
      bitIndex - The bit zero-based index. It must be greater than or equal to 0, and strictly less than number of bit-table bytes * Byte.SIZE.
      reader - The FST.BytesReader to read. It must be positioned at the beginning of the bit-table.
      Throws:
      IOException
    • countBits

      static int countBits(int bitTableBytes, FST.BytesReader reader) throws IOException
      Counts all bits set in the bit-table.
      Parameters:
      bitTableBytes - The number of bytes in the bit-table.
      reader - The FST.BytesReader to read. It must be positioned at the beginning of the bit-table.
      Throws:
      IOException
    • countBitsUpTo

      static int countBitsUpTo(int bitIndex, FST.BytesReader reader) throws IOException
      Counts the bits set up to the given bit zero-based index, exclusive.
      In other words, how many 1s there are up to the bit at the given index excluded.
      Example: bitIndex 10 means the third bit on the right of the second byte.
      Parameters:
      bitIndex - The bit zero-based index, exclusive. It must be greater than or equal to 0, and less than or equal to number of bit-table bytes * Byte.SIZE.
      reader - The FST.BytesReader to read. It must be positioned at the beginning of the bit-table.
      Throws:
      IOException
    • nextBitSet

      static int nextBitSet(int bitIndex, int bitTableBytes, FST.BytesReader reader) throws IOException
      Returns the index of the next bit set following the given bit zero-based index.
      For example with bits 100011: the next bit set after index=-1 is at index=0; the next bit set after index=0 is at index=1; the next bit set after index=1 is at index=5; there is no next bit set after index=5.
      Parameters:
      bitIndex - The bit zero-based index. It must be greater than or equal to -1, and strictly less than number of bit-table bytes * Byte.SIZE.
      bitTableBytes - The number of bytes in the bit-table.
      reader - The FST.BytesReader to read. It must be positioned at the beginning of the bit-table.
      Returns:
      The zero-based index of the next bit set after the provided bitIndex; or -1 if none.
      Throws:
      IOException
    • previousBitSet

      static int previousBitSet(int bitIndex, FST.BytesReader reader) throws IOException
      Returns the index of the previous bit set preceding the given bit zero-based index.
      For example with bits 100011: there is no previous bit set before index=0. the previous bit set before index=1 is at index=0; the previous bit set before index=5 is at index=1; the previous bit set before index=64 is at index=5;
      Parameters:
      bitIndex - The bit zero-based index. It must be greater than or equal to 0, and less than or equal to number of bit-table bytes * Byte.SIZE.
      reader - The FST.BytesReader to read. It must be positioned at the beginning of the bit-table.
      Returns:
      The zero-based index of the previous bit set before the provided bitIndex; or -1 if none.
      Throws:
      IOException
    • readByte

      private static long readByte(FST.BytesReader reader) throws IOException
      Throws:
      IOException
    • readUpTo8Bytes

      private static long readUpTo8Bytes(int numBytes, FST.BytesReader reader) throws IOException
      Throws:
      IOException
    • bitCount8Bytes

      private static int bitCount8Bytes(FST.BytesReader reader) throws IOException
      Throws:
      IOException