PackedInts

object PackedInts

Simplistic compression for array of unsigned long values. Each value is >= 0 and <= a specified maximum value. The values are stored as packed ints, with each value consuming a fixed number of bits.

Types

Link copied to clipboard
interface Decoder

A decoder for packed integers.

Link copied to clipboard
interface Encoder

An encoder for packed integers.

Link copied to clipboard

A format to write packed ints.

Link copied to clipboard
data class FormatAndBits(val format: PackedInts.Format, val bitsPerValue: Int)

Simple class that holds a format and a number of bits per value.

Link copied to clipboard
abstract class Mutable : PackedInts.Reader

A packed integer array that can be modified.

Link copied to clipboard

A Reader which has all its values equal to 0 (bitsPerValue = 0).

Link copied to clipboard
abstract class Reader : Accountable

A read-only random access array of positive integers.

Link copied to clipboard
interface ReaderIterator

Run-once iterator interface, to decode previously saved PackedInts.

Link copied to clipboard
abstract class Writer

A write-once Writer.

Properties

Link copied to clipboard
const val CODEC_NAME: String
Link copied to clipboard
const val COMPACT: Float = 0.0f

No memory overhead at all, but the returned implementation may be slow.

Link copied to clipboard
const val DEFAULT: Float = 0.25f

At most 25% memory overhead.

Link copied to clipboard
const val DEFAULT_BUFFER_SIZE: Int = 1024

Default amount of memory to use for bulk operations.

Link copied to clipboard
const val FAST: Float = 0.5f

At most 50% memory overhead, always select a reasonably fast implementation.

Link copied to clipboard
const val FASTEST: Float = 7.0f

At most 700% memory overhead, always select a direct implementation.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun bitsRequired(maxValue: Long): Int

Returns how many bits are required to hold values up to and including maxValue NOTE: This method returns at least 1.

Link copied to clipboard
fun checkBlockSize(blockSize: Int, minBlockSize: Int, maxBlockSize: Int): Int

Check that the block size is a power of 2, in the right bounds, and return its log in base 2.

Link copied to clipboard
fun checkVersion(version: Int)

Check the validity of a version number.

Link copied to clipboard
fun copy(src: PackedInts.Reader, srcPos: Int, dest: PackedInts.Mutable, destPos: Int, len: Int, mem: Int)

Copy src[srcPos:srcPos+len] into dest[destPos:destPos+len] using at most mem bytes.

fun copy(src: PackedInts.Reader, srcPos: Int, dest: PackedInts.Mutable, destPos: Int, len: Int, buf: LongArray)

Same as .copy but using a pre-allocated buffer.

Link copied to clipboard
fun fastestFormatAndBits(valueCount: Int, bitsPerValue: Int, acceptableOverheadRatio: Float): PackedInts.FormatAndBits

Try to find the Format and number of bits per value that would restore from disk the fastest reader whose overhead is less than acceptableOverheadRatio.

Link copied to clipboard
fun getDecoder(format: PackedInts.Format, version: Int, bitsPerValue: Int): PackedInts.Decoder

Get a Decoder.

Link copied to clipboard
fun getEncoder(format: PackedInts.Format, version: Int, bitsPerValue: Int): PackedInts.Encoder

Get an Encoder.

Link copied to clipboard
fun getMutable(valueCount: Int, bitsPerValue: Int, acceptableOverheadRatio: Float): PackedInts.Mutable

Create a packed integer array with the given amount of values initialized to 0. the valueCount and the bitsPerValue cannot be changed after creation. All Mutables known by this factory are kept fully in RAM.

fun getMutable(valueCount: Int, bitsPerValue: Int, format: PackedInts.Format): PackedInts.Mutable

Same as .getMutable with a pre-computed number of bits per value and format.

Link copied to clipboard
fun getReaderIteratorNoHeader(in: DataInput, format: PackedInts.Format, version: Int, valueCount: Int, bitsPerValue: Int, mem: Int): PackedInts.ReaderIterator

Expert: Restore a ReaderIterator from a stream without reading metadata at the beginning of the stream. This method is useful to restore data from streams which have been created using PackedInts.getWriterNoHeader.

Link copied to clipboard
fun getWriterNoHeader(out: DataOutput, format: PackedInts.Format, valueCount: Int, bitsPerValue: Int, mem: Int): PackedInts.Writer

Expert: Create a packed integer array writer for the given output, format, value count, and number of bits per value.

Link copied to clipboard
fun maxValue(bitsPerValue: Int): Long

Calculates the maximum unsigned long that can be expressed with the given number of bits.

Link copied to clipboard
fun numBlocks(size: Long, blockSize: Int): Int

Return the number of blocks required to store size values on blockSize * .

Link copied to clipboard

Returns how many bits are required to store bits, interpreted as an unsigned value. NOTE: This method returns at least 1.