Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 914 Bytes

File metadata and controls

22 lines (17 loc) · 914 Bytes

Pcodec JVM API

Pcodec is a codec for numerical sequences. Example usage:

import io.github.pcodec.ChunkConfig;
import io.github.pcodec.NumArray;
import io.github.pcodec.Standalone;

int[] src = { 1, 2, 3 };
NumArray numArray = NumArray.i32Array(src);
byte[] compressed = Standalone.simple_compress(numArray, new ChunkConfig());
// simple_decompress returns Optional.empty when there is no data,
// but in this example we know there is some.
NumArray recovered = Standalone.simple_decompress(compressed).get();
assertArrayEquals(src, recovered.as_i32_array());

For pcodec's uses, design, and benchmarks, see the main repo.

Since Java does not natively support all data types, we transmute to the most appropriate Java integer type when necessary. For instance, 32-bit unsigned integers are decompressed as ints, and 16-bit floats are decompressed as shorts.