java.lang.Object
org.apache.lucene.util.fst.BitTableUtil
Static helper methods for
FST.Arc.BitTable
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
bitCount8Bytes
(FST.BytesReader reader) (package private) static int
countBits
(int bitTableBytes, FST.BytesReader reader) Counts all bits set in the bit-table.(package private) static int
countBitsUpTo
(int bitIndex, FST.BytesReader reader) Counts the bits set up to the given bit zero-based index, exclusive.(package private) static boolean
isBitSet
(int bitIndex, FST.BytesReader reader) Returns whether the bit at given zero-based index is set.(package private) static int
nextBitSet
(int bitIndex, int bitTableBytes, FST.BytesReader reader) Returns the index of the next bit set following the given bit zero-based index.(package private) static int
previousBitSet
(int bitIndex, FST.BytesReader reader) Returns the index of the previous bit set preceding the given bit zero-based index.private static long
readByte
(FST.BytesReader reader) private static long
readUpTo8Bytes
(int numBytes, FST.BytesReader reader)
-
Constructor Details
-
BitTableUtil
BitTableUtil()
-
-
Method Details
-
isBitSet
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 thannumber of bit-table bytes * Byte.SIZE
.reader
- TheFST.BytesReader
to read. It must be positioned at the beginning of the bit-table.- Throws:
IOException
-
countBits
Counts all bits set in the bit-table.- Parameters:
bitTableBytes
- The number of bytes in the bit-table.reader
- TheFST.BytesReader
to read. It must be positioned at the beginning of the bit-table.- Throws:
IOException
-
countBitsUpTo
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 tonumber of bit-table bytes * Byte.SIZE
.reader
- TheFST.BytesReader
to read. It must be positioned at the beginning of the bit-table.- Throws:
IOException
-
nextBitSet
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 thannumber of bit-table bytes * Byte.SIZE
.bitTableBytes
- The number of bytes in the bit-table.reader
- TheFST.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
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 tonumber of bit-table bytes * Byte.SIZE
.reader
- TheFST.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
- Throws:
IOException
-
readUpTo8Bytes
- Throws:
IOException
-
bitCount8Bytes
- Throws:
IOException
-