- java.lang.Object
-
- org.apache.lucene.util.GroupVIntUtil
-
public final class GroupVIntUtil extends java.lang.Object
This class contains utility methods and constants for group varint
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GroupVIntUtil.IntReader
Provides an abstraction for read int values, so that decoding logic can be reused in different DataInput.
-
Field Summary
Fields Modifier and Type Field Description private static long[]
MASKS
static int
MAX_LENGTH_PER_GROUP
-
Constructor Summary
Constructors Constructor Description GroupVIntUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static int
numBytes(int v)
static void
readGroupVInt(DataInput in, long[] dst, int offset)
Default implementation of read single group, for optimal performance, you should useDataInput.readGroupVInts(long[], int)
instead.static int
readGroupVInt(DataInput in, long remaining, GroupVIntUtil.IntReader reader, long pos, long[] dst, int offset)
Faster implementation of read single group, It read values from the buffer that would not cross boundaries.private static long
readLongInGroup(DataInput in, int numBytesMinus1)
private static int
toInt(long value)
static void
writeGroupVInts(DataOutput out, byte[] scratch, long[] values, int limit)
The implementation for group-varint encoding, It uses a maximum ofMAX_LENGTH_PER_GROUP
bytes scratch buffer.
-
-
-
Field Detail
-
MAX_LENGTH_PER_GROUP
public static final int MAX_LENGTH_PER_GROUP
- See Also:
- Constant Field Values
-
MASKS
private static final long[] MASKS
-
-
Method Detail
-
readGroupVInt
public static void readGroupVInt(DataInput in, long[] dst, int offset) throws java.io.IOException
Default implementation of read single group, for optimal performance, you should useDataInput.readGroupVInts(long[], int)
instead.- Parameters:
dst
- the array to read ints into.offset
- the offset in the array to start storing ints.- Throws:
java.io.IOException
-
readLongInGroup
private static long readLongInGroup(DataInput in, int numBytesMinus1) throws java.io.IOException
- Throws:
java.io.IOException
-
readGroupVInt
public static int readGroupVInt(DataInput in, long remaining, GroupVIntUtil.IntReader reader, long pos, long[] dst, int offset) throws java.io.IOException
Faster implementation of read single group, It read values from the buffer that would not cross boundaries.- Parameters:
in
- the input to use to read data.remaining
- the number of remaining bytes allowed to read for current block/segment.reader
- the supplier of read int.pos
- the start pos to read from the reader.dst
- the array to read ints into.offset
- the offset in the array to start storing ints.- Returns:
- the number of bytes read excluding the flag. this indicates the number of positions
should to be increased for caller, it is 0 or positive number and less than
MAX_LENGTH_PER_GROUP
- Throws:
java.io.IOException
-
numBytes
private static int numBytes(int v)
-
toInt
private static int toInt(long value)
-
writeGroupVInts
public static void writeGroupVInts(DataOutput out, byte[] scratch, long[] values, int limit) throws java.io.IOException
The implementation for group-varint encoding, It uses a maximum ofMAX_LENGTH_PER_GROUP
bytes scratch buffer.- Throws:
java.io.IOException
-
-