public static int[] compressHeadless(SkippableIntegerCODEC codec, int[] data) { int[] outBuf = new int[data.Length * 4]; IntWrapper inPos = new IntWrapper(); IntWrapper outPos = new IntWrapper(); codec.headlessCompress(data, inPos, data.Length, outBuf, outPos); return(Arrays.copyOf(outBuf, outPos.get())); }
public static int[] uncompressHeadless(SkippableIntegerCODEC codec, int[] data, int len) { int[] outBuf = new int[len + 1024]; IntWrapper inPos = new IntWrapper(); IntWrapper outPos = new IntWrapper(); codec.headlessUncompress(data, inPos, data.Length, outBuf, outPos, len); if (outPos.get() < len) { throw new Exception("Insufficient output."); } return(Arrays.copyOf(outBuf, outPos.get())); }
/** * Compose a scheme from a first one (f1) and a second one (f2). The first * one is called first and then the second one tries to compress whatever * remains from the first run. * * By convention, the first scheme should be such that if, during decoding, * a 32-bit zero is first encountered, then there is no output. * * @param f1 * first codec * @param f2 * second codec */ public SkippableComposition(SkippableIntegerCODEC f1, SkippableIntegerCODEC f2) { F1 = f1; F2 = f2; }
/** * Constructor with default codec. */ public IntCompressor() { codec = new SkippableComposition(new BinaryPacking(), new VariableByte()); }
/** * Constructor wrapping a codec. * * @param c the underlying codec */ public IntCompressor(SkippableIntegerCODEC c) { codec = c; }