public static int maskedCrc32c(byte[] data, int offset, int length) { final PureJavaCrc32C crc32c = new PureJavaCrc32C(); crc32c.update(data, offset, length); return mask(crc32c.getIntegerValue()); }
static synchronized SnappyNative loadSnappyApi() { if (snappyApi != null) { return snappyApi; } loadNativeLibrary(); setSnappyApi(new SnappyNative()); return snappyApi; }
static synchronized BitShuffleNative loadBitShuffleApi() { if (bitshuffleApi != null) { return bitshuffleApi; } loadNativeLibrary(); bitshuffleApi = new BitShuffleNative(); return bitshuffleApi; }
/** * Compress the input array data * * @param f * @throws IOException */ public void write(float[] f) throws IOException { write(f, 0, f.length); }
/** * Compress the input char array * * @param input * @return the compressed data */ public static byte[] compress(char[] input) throws IOException { return rawCompress(input, input.length * 2); // char uses 2 bytes }
/** * Uncompress the input data as a long array * * @param input * @return the uncompressed data * @throws IOException */ public static long[] uncompressLongArray(byte[] input) throws IOException { return uncompressLongArray(input, 0, input.length); }
/** Create a new PureJavaCrc32 object. */ public PureJavaCrc32C() { reset(); }
public void stop(BundleContext context) throws Exception { SnappyLoader.setSnappyApi(null); SnappyLoader.cleanUpExtractedNativeLib(); } }
/** * Uncompress the input data as char array * * @param input * @return the uncompressed data * @throws IOException */ public static char[] uncompressCharArray(byte[] input) throws IOException { return uncompressCharArray(input, 0, input.length); }
/** * Uncompress the input as a short array * * @param input * @return the uncompressed data * @throws IOException */ public static short[] uncompressShortArray(byte[] input) throws IOException { return uncompressShortArray(input, 0, input.length); }
@Override public int read() throws IOException { if (closed) { return -1; } if (!ensureBuffer()) { return -1; } return buffer[position++] & 0xFF; }
public static void throwException(int errorCode) throws SnappyException { throw new SnappyException(errorCode); }
public static SnappyErrorCode getErrorCode(int id) { for (SnappyErrorCode code : SnappyErrorCode.values()) { if (code.id == id) { return code; } } return UNKNOWN; }
/** * Create a filter for reading compressed data as a uncompressed stream * * @param input * @throws IOException */ public SnappyInputStream(InputStream input) throws IOException { this.in = input; readHeader(); }
/** * Compress the input array data * * @param f * @throws IOException */ public void write(double[] f) throws IOException { write(f, 0, f.length); }
/** * Compress the input double array * * @param input * @return the compressed data */ public static byte[] compress(double[] input) throws IOException { return rawCompress(input, input.length * 8); // double uses 8 bytes }
/** * Compress the input array data * * @param f * @throws IOException */ public void write(int[] f) throws IOException { write(f, 0, f.length); }
/** * Compress the input int array * * @param input * @return the compressed data */ public static byte[] compress(int[] input) throws IOException { return rawCompress(input, input.length * 4); // int uses 4 bytes }
/** * Compress the input short array * * @param input * @return the compressed data */ public static byte[] compress(short[] input) throws IOException { return rawCompress(input, input.length * 2); // short uses 2 bytes }