Package org.xerial.snappy

Examples of org.xerial.snappy.SnappyOutputStream


                CompactEndpointSerializationHelper.serialize(FBUtilities.getBroadcastAddress(), out);
                if (shouldCompressConnection())
                {
                    out.flush();
                    logger.trace("Upgrading OutputStream to be compressed");
                    out = new DataOutputStream(new SnappyOutputStream(new BufferedOutputStream(socket.getOutputStream())));
                }

                return true;
            }
            catch (IOException e)
View Full Code Here


                    out.flush();
                    logger.trace("Upgrading OutputStream to be compressed");
                    if (targetVersion < MessagingService.VERSION_21)
                    {
                        // Snappy is buffered, so no need for extra buffering output stream
                        out = new DataOutputStreamPlus(new SnappyOutputStream(socket.getOutputStream()));
                    }
                    else
                    {
                        // TODO: custom LZ4 OS that supports BB write methods
                        LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
View Full Code Here

                    CompactEndpointSerializationHelper.serialize(FBUtilities.getBroadcastAddress(), out);
                    if (shouldCompressConnection())
                    {
                        out.flush();
                        logger.trace("Upgrading OutputStream to be compressed");
                        out = new DataOutputStream(new SnappyOutputStream(new BufferedOutputStream(socket.getOutputStream())));
                    }
                }

                return true;
            }
View Full Code Here

    return new SnappyInputStream(parent);
  }

  @Override
  protected OutputStream createOutputStream(OutputStream parent) throws IOException {
    return new SnappyOutputStream(parent);
  }
View Full Code Here

    @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

    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

        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

  @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

        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

Related Classes of org.xerial.snappy.SnappyOutputStream

Copyright © 2018 www.massapicom. 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.