Search in sources :

Example 1 with SnappyCompressor

use of com.linkedin.r2.filter.compression.streaming.SnappyCompressor in project rest.li by linkedin.

the class TestStreamingCompression method testSnappyCompressor.

@Test
public void testSnappyCompressor() throws IOException, InterruptedException, CompressionException, ExecutionException {
    StreamingCompressor compressor = new SnappyCompressor(_executor);
    final byte[] origin = new byte[BUF_SIZE];
    Arrays.fill(origin, (byte) 'a');
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    SnappyFramedOutputStream snappy = new SnappyFramedOutputStream(out);
    IOUtils.write(origin, snappy);
    snappy.close();
    byte[] compressed = out.toByteArray();
    testCompress(compressor, origin, compressed);
    testDecompress(compressor, origin, compressed);
    testCompressThenDecompress(compressor, origin);
}
Also used : SnappyCompressor(com.linkedin.r2.filter.compression.streaming.SnappyCompressor) SnappyFramedOutputStream(org.iq80.snappy.SnappyFramedOutputStream) StreamingCompressor(com.linkedin.r2.filter.compression.streaming.StreamingCompressor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 2 with SnappyCompressor

use of com.linkedin.r2.filter.compression.streaming.SnappyCompressor in project rest.li by linkedin.

the class TestStreamingCompression method testSnappyCompressor.

@Test
public void testSnappyCompressor() throws IOException, InterruptedException, CompressionException, ExecutionException {
    StreamingCompressor compressor = new SnappyCompressor(_executor);
    final byte[] origin = new byte[BUF_SIZE];
    Arrays.fill(origin, (byte) 'a');
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    SnappyFramedOutputStream snappy = new SnappyFramedOutputStream(out);
    IOUtils.write(origin, snappy);
    snappy.close();
    byte[] compressed = out.toByteArray();
    testCompress(compressor, origin, compressed);
    testDecompress(compressor, origin, compressed);
    testCompressThenDecompress(compressor, origin);
}
Also used : SnappyCompressor(com.linkedin.r2.filter.compression.streaming.SnappyCompressor) SnappyFramedOutputStream(org.iq80.snappy.SnappyFramedOutputStream) StreamingCompressor(com.linkedin.r2.filter.compression.streaming.StreamingCompressor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Aggregations

SnappyCompressor (com.linkedin.r2.filter.compression.streaming.SnappyCompressor)2 StreamingCompressor (com.linkedin.r2.filter.compression.streaming.StreamingCompressor)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 SnappyFramedOutputStream (org.iq80.snappy.SnappyFramedOutputStream)2 Test (org.testng.annotations.Test)2