This class implements a stream filter for reading compressed data in the SNZ file format.
The data format is compatible to the snzip tool, which is available as a patch to the official Snappy source code.
3738394041424344454647484950
int iterations = 2500; long t0 = System.nanoTime(); for(int i=0; i<iterations; i++) { SnzInputStream sis = mt ? new SnzMTInputStream(new ByteArrayInputStream(compressed)) : new SnzInputStream(new ByteArrayInputStream(compressed)); while((r = sis.read(dummy)) >= 0) { l += r; } } long t1 = System.nanoTime(); lall += l;
5657585960616263646566
SnzOutputStream sos = new SnzOutputStream(compressedData); sos.write(originalData); sos.close(); ByteArrayOutputStream decompressedData = new ByteArrayOutputStream(); SnzInputStream sis = new SnzInputStream(new ByteArrayInputStream(compressedData.toByteArray())); TestUtil.pipe(sis, decompressedData); Assert.assertArrayEquals(originalData, decompressedData.toByteArray()); } }
828384858687888990919293
for (File org : testdataDirectory.listFiles()) { if (org.isFile()) { System.out.println("comparing " + org.getName()); byte[] originalData = TestUtil.readFully(org); ByteArrayOutputStream decompressedData = new ByteArrayOutputStream(); SnzInputStream sis = new SnzInputStream(new FileInputStream(new File(tmpDirectory, org.getName() + ".snz"))); TestUtil.pipe(sis, decompressedData); sis.close(); Assert.assertArrayEquals(originalData, decompressedData.toByteArray()); } } }