Class PForUtil
java.lang.Object
org.apache.lucene.backward_codecs.lucene90.PForUtil
Utility class to encode sequences of 128 small positive integers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
private final ForUtil
private static final int
private static final long[]
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static boolean
allEqual
(long[] l) private void
applyExceptions32
(int bitsPerValue, int numExceptions, DataInput in, long[] longs) Apply the exceptions where the values are packed two-per-long inlongs
.(package private) void
Decode 128 integers intolongs
.(package private) void
decodeAndPrefixSum
(DataInput in, long base, long[] longs) Decode deltas, compute the prefix sum and addbase
to all decoded longs.(package private) void
encode
(long[] longs, DataOutput out) Encode 128 integers fromlongs
intoout
.private static void
expand32
(long[] longs) Expand the values packed two-per-long inlongs
into 128 individual long values stored back intolongs
.private static void
fillSameValue32
(long[] longs, long val) Fills thelongs
with the providedval
, packed two values per long (using 32 bits per value).private static void
innerPrefixSum32
(long[] longs) Unrolled "inner" prefix sum logic where the values are packed two-per-long inlongs
.private static void
prefixSum32
(long[] longs, long base) Apply prefix sum logic where the values are packed two-per-long inlongs
.private static void
prefixSumOf
(long[] longs, long base, long val) Filllongs
with the final values for the case of all deltas beingval
.private static void
prefixSumOfOnes
(long[] longs, long base) Filllongs
with the final values for the case of all deltas being 1.(package private) void
Skip 128 integers.
-
Field Details
-
MAX_EXCEPTIONS
private static final int MAX_EXCEPTIONS- See Also:
-
HALF_BLOCK_SIZE
private static final int HALF_BLOCK_SIZE- See Also:
-
IDENTITY_PLUS_ONE
private static final long[] IDENTITY_PLUS_ONE -
forUtil
-
exceptionBuff
private final byte[] exceptionBuff
-
-
Constructor Details
-
PForUtil
PForUtil(ForUtil forUtil)
-
-
Method Details
-
allEqual
static boolean allEqual(long[] l) -
encode
Encode 128 integers fromlongs
intoout
.- Throws:
IOException
-
decode
Decode 128 integers intolongs
.- Throws:
IOException
-
decodeAndPrefixSum
Decode deltas, compute the prefix sum and addbase
to all decoded longs.- Throws:
IOException
-
skip
Skip 128 integers.- Throws:
IOException
-
prefixSumOfOnes
private static void prefixSumOfOnes(long[] longs, long base) Filllongs
with the final values for the case of all deltas being 1. Note this assumes there are no exceptions to apply. -
prefixSumOf
private static void prefixSumOf(long[] longs, long base, long val) Filllongs
with the final values for the case of all deltas beingval
. Note this assumes there are no exceptions to apply. -
fillSameValue32
private static void fillSameValue32(long[] longs, long val) Fills thelongs
with the providedval
, packed two values per long (using 32 bits per value). -
applyExceptions32
private void applyExceptions32(int bitsPerValue, int numExceptions, DataInput in, long[] longs) throws IOException Apply the exceptions where the values are packed two-per-long inlongs
.- Throws:
IOException
-
prefixSum32
private static void prefixSum32(long[] longs, long base) Apply prefix sum logic where the values are packed two-per-long inlongs
. -
expand32
private static void expand32(long[] longs) Expand the values packed two-per-long inlongs
into 128 individual long values stored back intolongs
. -
innerPrefixSum32
private static void innerPrefixSum32(long[] longs) Unrolled "inner" prefix sum logic where the values are packed two-per-long inlongs
. After this method, the final values will be correct for all high-order bits (values [0..63]) but a final prefix loop will still need to run to "correct" the values of [64..127] in the low-order bits, which need the 64th value added to all of them.
-