Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add test for isValidCompressedBuffer. Add a comment on the usage of S…
…nappyOutputStream
  • Loading branch information
xerial committed Jun 20, 2011
1 parent 7795673 commit ae6a126
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/xerial/snappy/SnappyOutputStream.java
Expand Up @@ -34,8 +34,14 @@
* The input data is blocked into 32kb size (in default), and each block is
* compressed and then passed to the given {@link OutputStream}.
*
* The output data format is a sequence of (compressed chunk size, compressed
* data chunk binary...) pair.
* The output data format is a sequence of (compressed data size, compressed
* 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
*
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/xerial/snappy/SnappyTest.java
Expand Up @@ -283,4 +283,14 @@ public void string() throws Exception {
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);
}

}

}

0 comments on commit ae6a126

Please sign in to comment.