mirror of
https://github.com/xerial/snappy-java.git
synced 2025-05-05 15:30:16 +02:00
Add test for isValidCompressedBuffer. Add a comment on the usage of SnappyOutputStream
This commit is contained in:
parent
7795673e0c
commit
ae6a126d1c
@ -34,8 +34,14 @@ import java.io.OutputStream;
|
|||||||
* The input data is blocked into 32kb size (in default), and each block is
|
* The input data is blocked into 32kb size (in default), and each block is
|
||||||
* compressed and then passed to the given {@link OutputStream}.
|
* compressed and then passed to the given {@link OutputStream}.
|
||||||
*
|
*
|
||||||
* The output data format is a sequence of (compressed chunk size, compressed
|
* The output data format is a sequence of (compressed data size, compressed
|
||||||
* data chunk binary...) pair.
|
* data...) pair.
|
||||||
|
*
|
||||||
|
* Note that the compressed data created by {@link SnappyOutputStream} cannot be
|
||||||
|
* uncompressed by {@link Snappy#uncompress(byte[])} since the output formats of
|
||||||
|
* {@link Snappy#compress(byte[])} and {@link SnappyOutputStream} are different.
|
||||||
|
* Use {@link SnappyInputStream} for uncompress the data generated by
|
||||||
|
* {@link SnappyOutputStream}.
|
||||||
*
|
*
|
||||||
* @author leo
|
* @author leo
|
||||||
*
|
*
|
||||||
|
@ -283,4 +283,14 @@ public class SnappyTest
|
|||||||
assertEquals(s, uncompressedString);
|
assertEquals(s, uncompressedString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isValidCompressedData() throws Exception {
|
||||||
|
|
||||||
|
byte[] b = new byte[] { (byte) 91, (byte) 34, (byte) 80, (byte) 73, (byte) 34, (byte) 93 };
|
||||||
|
if (Snappy.isValidCompressedBuffer(b, 0, b.length)) {
|
||||||
|
byte[] uncompressed = Snappy.uncompress(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user