public class PackedInts extends Object
Modifier and Type  Class and Description 

static interface 
PackedInts.Mutable
A packed integer array that can be modified.

static interface 
PackedInts.Reader
A readonly random access array of positive integers.

static class 
PackedInts.ReaderImpl
A simple base for Readers that keeps track of valueCount and bitsPerValue.

static class 
PackedInts.Writer
A writeonce Writer.

Constructor and Description 

PackedInts() 
Modifier and Type  Method and Description 

static int 
bitsRequired(long maxValue)
Returns how many bits are required to hold values up
to and including maxValue

static PackedInts.Mutable 
getMutable(int valueCount,
int bitsPerValue)
Create a packed integer array with the given amount of values initialized
to 0.

static int 
getNextFixedSize(int bitsPerValue)
Rounds bitsPerValue up to 8, 16, 32 or 64.

static PackedInts.Reader 
getReader(DataInput in)
Retrieve PackedInt data from the DataInput and return a packed int
structure based on it.

static int 
getRoundedFixedSize(int bitsPerValue)
Possibly wastes some storage in exchange for faster lookups

static PackedInts.Writer 
getWriter(DataOutput out,
int valueCount,
int bitsPerValue)
Create a packed integer array writer for the given number of values at the
given bits/value.

static long 
maxValue(int bitsPerValue)
Calculates the maximum unsigned long that can be expressed with the given
number of bits.

public static PackedInts.Reader getReader(DataInput in) throws IOException
in
 positioned at the beginning of a stored packed int structure.IOException
 if the structure could not be retrieved.public static PackedInts.Mutable getMutable(int valueCount, int bitsPerValue)
valueCount
 the number of elements.bitsPerValue
 the number of bits available for any given value.IOException
 if the Mutable could not be created. With the
current implementations, this never happens, but the method
signature allows for future persistencebacked Mutables.public static PackedInts.Writer getWriter(DataOutput out, int valueCount, int bitsPerValue) throws IOException
out
 the destination for the produced bits.valueCount
 the number of elements.bitsPerValue
 the number of bits available for any given value.IOException
 if bits could not be written to out.public static int bitsRequired(long maxValue)
maxValue
 the maximum value that should be representable.public static long maxValue(int bitsPerValue)
bitsPerValue
 the number of bits available for any given value.public static int getNextFixedSize(int bitsPerValue)
public static int getRoundedFixedSize(int bitsPerValue)