Examples of SnappyOutputStream


Examples of org.xerial.snappy.SnappyOutputStream

    @Test
    public void snappyCompress() throws IOException
    {
        FileInputStream fi = new FileInputStream("/tmp/compress-test.txt");
        SnappyOutputStream out = new SnappyOutputStream(new BufferedOutputStream(new FileOutputStream("/tmp/test0.snp")));
        BufferedInputStream origin = new BufferedInputStream(fi, 1024);
        byte data[] = new byte[1024];
        int count;
        while ((count = origin.read(data, 0, 1024)) != -1)
        {
            out.write(data, 0, count);
        }
        IOUtils.closeQuietly(origin);
        IOUtils.closeQuietly(fi);
        IOUtils.closeQuietly(out);
View Full Code Here

Examples of org.xerial.snappy.SnappyOutputStream

    public ChunkedStream(InputStream is, long chunkSize) throws IOException
    {
        this.origin = is;
        this.bos = new ByteArrayOutputStream();
        this.compress = new SnappyOutputStream(bos);
        this.chunkSize = chunkSize;
    }
View Full Code Here

Examples of org.xerial.snappy.SnappyOutputStream

        if (s == null) {
            File f = new VoltFile(path, name);
            f.delete();
            RandomAccessFile ras = new RandomAccessFile(f, "rw");
            ras.seek(8);
            SnappyOutputStream sos = new SnappyOutputStream(new FileOutputStream(ras.getFD()));
            DataOutputStream dos = new DataOutputStream(sos);
            s = new Stuff();
            s.dos = dos;
            s.count = ras.getChannel().map(MapMode.READ_WRITE, 0, 8);
            s.count.order(ByteOrder.nativeOrder());
View Full Code Here

Examples of org.xerial.snappy.SnappyOutputStream

  @Override
  public BSPCompressedBundle compressBundle(BSPMessageBundle<M> bundle) {
    BSPCompressedBundle compMsgBundle = null;
    ByteArrayOutputStream bos = null;
    SnappyOutputStream sos = null;
    DataOutputStream dos = null;

    try {
      bos = new ByteArrayOutputStream();
      sos = new SnappyOutputStream(bos);
      dos = new DataOutputStream(sos);

      bundle.write(dos);
      dos.close(); // Flush the stream as no more data will be sent.

      byte[] data = bos.toByteArray();
      compMsgBundle = new BSPCompressedBundle(data);

    } catch (IOException ioe) {
      LOG.error("Unable to compress", ioe);
    } finally {
      try {
        sos.close();
        bos.close();
      } catch (IOException e) {
        LOG.warn("Failed to close compression streams.", e);
      }
    }
View Full Code Here

Examples of org.xerial.snappy.SnappyOutputStream

        if (obj == null) {
            return null;
        }
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        SnappyOutputStream snappy;
        try {
            snappy = new SnappyOutputStream(out);
            snappy.write(StringUtils.getBytesUtf8(obj));
            snappy.close();
            return ByteBuffer.wrap(out.toByteArray());
        } catch (IOException e) {
            throw new RuntimeException("Error compressing column data", e);
        }       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.