Java Code Examples for org.xerial.snappy.SnappyOutputStream#write()

The following examples show how to use org.xerial.snappy.SnappyOutputStream#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnappyUtils.java    From vertexium with Apache License 2.0 6 votes vote down vote up
public static boolean testSnappySupport() {
    try {
        String testString = "Hello World";

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SnappyOutputStream out = new SnappyOutputStream(baos);
        out.write(testString.getBytes());
        out.close();
        byte[] bytes = baos.toByteArray();

        ByteArrayInputStream bain = new ByteArrayInputStream(bytes);
        SnappyInputStream in = new SnappyInputStream(bain);
        String result = new String(IOUtils.toBytes(in));
        if (!result.equals(testString)) {
            throw new VertexiumException("uncompressed string did not match compressed string");
        }
        return true;
    } catch (Throwable ex) {
        LOGGER.error("Could not verify support for snappy compression", ex);
        return false;
    }
}
 
Example 2
Source File: SnappyCompressionProviderTest.java    From hop with Apache License 2.0 5 votes vote down vote up
private SnappyInputStream createSnappyInputStream() throws IOException {
  // Create an in-memory ZIP output stream for use by the input stream (to avoid exceptions)
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  SnappyOutputStream sos = new SnappyOutputStream( baos );
  byte[] testBytes = "Test".getBytes();
  sos.write( testBytes );
  ByteArrayInputStream in = new ByteArrayInputStream( baos.toByteArray() );
  sos.close();

  return new SnappyInputStream( in );
}
 
Example 3
Source File: SnappyCompressionInputStreamTest.java    From hop with Apache License 2.0 5 votes vote down vote up
private SnappyInputStream createSnappyInputStream() throws IOException {
  // Create an in-memory ZIP output stream for use by the input stream (to avoid exceptions)
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  SnappyOutputStream sos = new SnappyOutputStream( baos );
  byte[] testBytes = "Test".getBytes();
  sos.write( testBytes );
  ByteArrayInputStream in = new ByteArrayInputStream( baos.toByteArray() );
  sos.close();

  return new SnappyInputStream( in );
}
 
Example 4
Source File: SnappyCompressionProviderTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private SnappyInputStream createSnappyInputStream() throws IOException {
  // Create an in-memory ZIP output stream for use by the input stream (to avoid exceptions)
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  SnappyOutputStream sos = new SnappyOutputStream( baos );
  byte[] testBytes = "Test".getBytes();
  sos.write( testBytes );
  ByteArrayInputStream in = new ByteArrayInputStream( baos.toByteArray() );
  sos.close();

  return new SnappyInputStream( in );
}
 
Example 5
Source File: SnappyCompressionInputStreamTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private SnappyInputStream createSnappyInputStream() throws IOException {
  // Create an in-memory ZIP output stream for use by the input stream (to avoid exceptions)
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  SnappyOutputStream sos = new SnappyOutputStream( baos );
  byte[] testBytes = "Test".getBytes();
  sos.write( testBytes );
  ByteArrayInputStream in = new ByteArrayInputStream( baos.toByteArray() );
  sos.close();

  return new SnappyInputStream( in );
}