Examples of SnappyInputStream


Examples of org.xerial.snappy.SnappyInputStream

        from = CompactEndpointSerializationHelper.deserialize(in);

        if (compressed)
        {
            logger.debug("Upgrading incoming connection to be compressed");
            in = new DataInputStream(new SnappyInputStream(socket.getInputStream()));
        }
        else
        {
            in = new DataInputStream(new BufferedInputStream(socket.getInputStream(), 4096));
        }
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

        if (compressed)
        {
            logger.debug("Upgrading incoming connection to be compressed");
            if (version < MessagingService.VERSION_21)
                in = new DataInputStream(new SnappyInputStream(socket.getInputStream()));
            else
            {
                LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
                Checksum checksum = XXHashFactory.fastestInstance().newStreamingHash32(OutboundTcpConnection.LZ4_HASH_SEED).asChecksum();
                in = new DataInputStream(new LZ4BlockInputStream(socket.getInputStream(),
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

    super(delegate);
  }

  @Override
  protected InputStream createInputStream(InputStream parent) throws IOException {
    return new SnappyInputStream(parent);
  }
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

    @Test
    public void snappyDecompress() throws IOException
    {
        // decompress normally.
        SnappyInputStream is = new SnappyInputStream(new BufferedInputStream(new FileInputStream("/tmp/test0.snp")));
        byte d[] = new byte[1024];
        FileOutputStream fos = new FileOutputStream("/tmp/compress-test-out-1.txt");
        BufferedOutputStream dest1 = new BufferedOutputStream(fos, 1024);
        int c;
        while ((c = is.read(d, 0, 1024)) != -1)
        {
            dest1.write(d, 0, c);
        }
        IOUtils.closeQuietly(dest1);
        IOUtils.closeQuietly(is);
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

        }
    }

    private void decompress(InputStream input, OutputStream output) throws IOException
    {
        SnappyInputStream is = new SnappyInputStream(new BufferedInputStream(input));
        byte data[] = new byte[BUFFER];
        BufferedOutputStream dest1 = new BufferedOutputStream(output, BUFFER);
        try
        {
            int c;
            while ((c = is.read(data, 0, BUFFER)) != -1)
            {
                dest1.write(data, 0, c);
            }
        }
        finally
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

        FileInputStream fis = new FileInputStream(file);
        fis.getChannel().position(8);

        final long count = fis.getChannel().map(MapMode.READ_ONLY, 0, 8).order(ByteOrder.nativeOrder()).getLong();

        SnappyInputStream sis = new SnappyInputStream(fis);

        DataInputStream dis = new DataInputStream(sis);

        if (op.equalsIgnoreCase("tail")) {
            long skip = count > tail ? count - tail : 0;
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

   * @return
   */
  @Override
  public BSPMessageBundle<M> decompressBundle(BSPCompressedBundle compMsgBundle) {
    ByteArrayInputStream bis = null;
    SnappyInputStream sis = null;
    DataInputStream dis = null;
    BSPMessageBundle<M> bundle = new BSPMessageBundle<M>();

    try {
      byte[] data = compMsgBundle.getData();
      bis = new ByteArrayInputStream(data);
      sis = new SnappyInputStream(bis);
      dis = new DataInputStream(sis);

      bundle.readFields(dis);

    } catch (IOException ioe) {
      LOG.error("Unable to decompress.", ioe);
    } finally {
      try {
        dis.close();
        sis.close();
        bis.close();
      } catch (IOException e) {
        LOG.warn("Failed to close decompression streams.", e);
      }
    }
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

    public String fromByteBuffer(ByteBuffer byteBuffer) {
        if (byteBuffer == null) {
            return null;
        }
       
        SnappyInputStream snappy = null;
        ByteArrayOutputStream baos = null;
        try {
            ByteBuffer dup = byteBuffer.duplicate();
            snappy = new SnappyInputStream(
                    new ByteArrayInputStream(dup.array(), 0,
                            dup.limit()));
           
            baos = new ByteArrayOutputStream();
            for (int value = 0; value != -1;) {
                value = snappy.read();
                if (value != -1) {
                    baos.write(value);
                }
            }
            snappy.close();
            baos.close();
            return StringUtils.newStringUtf8(baos.toByteArray());
        } catch (IOException e) {
            throw new RuntimeException("Error decompressing column data", e);
        } finally {
            if (snappy != null) {
                try {
                    snappy.close();
                } catch (IOException e) {
                }
            }
            if (baos != null) {
                try {
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.