All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.lucene.util.packed.package.html Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version






Packed integer arrays and streams.

The packed package provides

  • sequential and random access capable arrays of positive longs,
  • routines for efficient serialization and deserialization of streams of packed integers.
The implementations provide different trade-offs between memory usage and access speed. The standard usage scenario is replacing large int or long arrays in order to reduce the memory footprint.

The main access point is the {@link org.apache.lucene.util.packed.PackedInts} factory.

In-memory structures

  • {@link org.apache.lucene.util.packed.PackedInts.Mutable}
    • Only supports positive longs.
    • Requires the number of bits per value to be known in advance.
    • Random-access for both writing and reading.
  • {@link org.apache.lucene.util.packed.GrowableWriter}
    • Same as PackedInts.Mutable but grows the number of bits per values when needed.
    • Useful to build a PackedInts.Mutable from a read-once stream of longs.
  • {@link org.apache.lucene.util.packed.PagedGrowableWriter}
    • Slices data into fixed-size blocks stored in GrowableWriters.
    • Supports more than 2B values.
    • You should use Appending(Delta)PackedLongBuffer instead if you don't need random write access.
  • {@link org.apache.lucene.util.packed.AppendingDeltaPackedLongBuffer}
    • Can store any sequence of longs.
    • Compression is good when values are close to each other.
    • Supports random reads, but only sequential writes.
    • Can address up to 2^42 values.
  • {@link org.apache.lucene.util.packed.AppendingPackedLongBuffer}
    • Same as AppendingDeltaPackedLongBuffer but assumes values are 0-based.
  • {@link org.apache.lucene.util.packed.MonotonicAppendingLongBuffer}
    • Same as AppendingDeltaPackedLongBuffer except that compression is good when the stream is a succession of affine functions.

Disk-based structures

  • {@link org.apache.lucene.util.packed.PackedInts.Writer}, {@link org.apache.lucene.util.packed.PackedInts.Reader}, {@link org.apache.lucene.util.packed.PackedInts.ReaderIterator}
    • Only supports positive longs.
    • Requires the number of bits per value to be known in advance.
    • Supports both fast sequential access with low memory footprint with ReaderIterator and random-access by either loading values in memory or leaving them on disk with Reader.
  • {@link org.apache.lucene.util.packed.BlockPackedWriter}, {@link org.apache.lucene.util.packed.BlockPackedReader}, {@link org.apache.lucene.util.packed.BlockPackedReaderIterator}
    • Splits the stream into fixed-size blocks.
    • Compression is good when values are close to each other.
    • Can address up to 2B * blockSize values.
  • {@link org.apache.lucene.util.packed.MonotonicBlockPackedWriter}, {@link org.apache.lucene.util.packed.MonotonicBlockPackedReader}
    • Same as the non-monotonic variants except that compression is good when the stream is a succession of affine functions.
    • The reason why there is no sequential access is that if you need sequential access, you should rather delta-encode and use BlockPackedWriter.
  • {@link org.apache.lucene.util.packed.PackedDataOutput}, {@link org.apache.lucene.util.packed.PackedDataInput}
    • Writes sequences of longs where each long can use any number of bits.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy