Class LongAs2IntsCodec

java.lang.Object
me.lemire.longcompression.LongAs2IntsCodec
All Implemented Interfaces:
LongCODEC

public class LongAs2IntsCodec extends Object implements LongCODEC
A LongCODEC which split each long in a highpart (32 first bits) and a low part (32 last bits).
Author:
Benoit Lacelle
  • Constructor Details

    • LongAs2IntsCodec

      public LongAs2IntsCodec(IntegerCODEC highPartsCodec, IntegerCODEC lowPartsCodec)
    • LongAs2IntsCodec

      public LongAs2IntsCodec()
      By default, we expect longs to be slightly above Integer.MAX_VALUE. Hence highParts to be small and positive integers. For lowParts, we rely on IntCompressor default IntegerCODEC
  • Method Details

    • compress

      public void compress(long[] in, IntWrapper inpos, int inlength, long[] out, IntWrapper outpos)
      Description copied from interface: LongCODEC
      Compress data from an array to another array. Both inpos and outpos are modified to represent how much data was read and written to. If 12 longs (inlength = 12) are compressed to 3 longs, then inpos will be incremented by 12 while outpos will be incremented by 3. We use IntWrapper to pass the values by reference.
      Specified by:
      compress in interface LongCODEC
      Parameters:
      in - input array
      inpos - where to start reading in the array
      inlength - how many longs to compress
      out - output array
      outpos - where to write in the output array
    • uncompress

      public void uncompress(long[] in, IntWrapper inpos, int inlength, long[] out, IntWrapper outpos)
      inlength is ignored by this codec. We may rely on it instead of storing the compressedLowPart length
      Specified by:
      uncompress in interface LongCODEC
      Parameters:
      in - array containing data in compressed form
      inpos - where to start reading in the array
      inlength - length of the compressed data (ignored by some schemes)
      out - array where to write the uncompressed output
      outpos - where to start writing the uncompressed output in out