Examples of SnappyInputStream


Examples of org.iq80.snappy.SnappyInputStream

    protected OutputStream wrapOutputStream(OutputStream underlying) throws IOException {
        return new SnappyOutputStream(underlying);
    }

    protected InputStream wrapInputStream(InputStream underlying) throws IOException {
        return new SnappyInputStream(underlying);
    }
View Full Code Here

Examples of org.iq80.snappy.SnappyInputStream

        snappyOutputStream.close();
    }

    public static ChannelBuffer decompress(ChannelBuffer in) throws IOException {
        ChannelBufferInputStream channelBufferInputStream = new ChannelBufferInputStream(in);
        SnappyInputStream inputStream = new SnappyInputStream(channelBufferInputStream);
        ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer(ByteStreams.toByteArray(inputStream));
        return channelBuffer;
    }
View Full Code Here

Examples of org.iq80.snappy.SnappyInputStream

        return channelBuffer;
    }

    public static byte[] decompress(byte[] in) throws IOException {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(in);
        SnappyInputStream inputStream = new SnappyInputStream(byteArrayInputStream);
        return ByteStreams.toByteArray(inputStream);
    }
View Full Code Here

Examples of org.iq80.snappy.SnappyInputStream

    public static <T> T decode(byte[] cryptedBytes, Class<T> clazz) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, DecoderException, IOException {
        byte[] bytes = cipherDecrypt.get().doFinal(cryptedBytes);


        SnappyInputStream snappyInputStream = new SnappyInputStream(new ByteArrayInputStream(bytes));


        //MessagePack messagePack = new MessagePack();
        return messagePack.read(ByteStreams.toByteArray(snappyInputStream), clazz);
    }
View Full Code Here

Examples of org.iq80.snappy.SnappyInputStream

    /**
     * {@inheritDoc}
     */
    @Override
    protected InputStream wrapDecompressInternal(InputStream in) throws IOException {
        return new SnappyInputStream(in);
    }
View Full Code Here

Examples of org.iq80.snappy.SnappyInputStream

  public RequestType requestFromBytes(byte[] compressedBytes) {
    ByteArrayInputStream bais = new ByteArrayInputStream(compressedBytes);

    byte[] uncompressedBytes = null;
    try {
      SnappyInputStream snappyInputStream = new SnappyInputStream(bais);
      uncompressedBytes = IOUtils.toByteArray(snappyInputStream);
    } catch (IOException e) {
      // This should not happen
      logger.warn("Could not decompress sensei request", e);
    }
View Full Code Here

Examples of org.iq80.snappy.SnappyInputStream

  public ResponseType responseFromBytes(byte[] compressedBytes) {
    ByteArrayInputStream bais = new ByteArrayInputStream(compressedBytes);

    byte[] uncompressedBytes = null;
    try {
      SnappyInputStream snappyInputStream = new SnappyInputStream(bais);
      uncompressedBytes = IOUtils.toByteArray(snappyInputStream);
    } catch (IOException e) {
      // This should not happen
      logger.warn("Could not decompress sensei request", e);
    }
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

    Preconditions.checkState(!decompressed.exists(),
      "Decompressed file: " + decompressed.toString() +
        " unexpectedly exists.");

    BufferedInputStream in = null;
    SnappyInputStream snappyIn = null;
    FileOutputStream out = null;
    try {
      in = new BufferedInputStream(new FileInputStream(compressed));
      snappyIn = new SnappyInputStream(in);
      out = new FileOutputStream(decompressed);

      byte[] buf = new byte[FILE_BUFFER_SIZE];
      while(true) {
        int read = snappyIn.read(buf);
        if (read == -1) {
          break;
        }
        out.write(buf, 0, read);
      }
      out.getFD().sync();
      return true;
    } catch (Exception ex) {
      LOG.error("Error while attempting to compress " +
        compressed.toString() + " to " + decompressed.toString() +
        ".", ex);
      Throwables.propagate(ex);
    } finally {
      Throwable th = null;
      try {
        if (in != null) {
          in.close();
        }
      } catch (Throwable ex) {
        LOG.error("Error while closing input file.", ex);
        th = ex;
      }
      try {
        if (snappyIn != null) {
          snappyIn.close();
        }
      } catch (IOException ex) {
        LOG.error("Error while closing output file.", ex);
        Throwables.propagate(ex);
      }
View Full Code Here

Examples of org.xerial.snappy.SnappyInputStream

        boolean compressed = MessagingService.getBits(header, 2, 1) == 1;

        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

   * @return
   */
  @Override
  public byte[] decompress(byte[] compressedBytes) {
    ByteArrayInputStream bis = null;
    SnappyInputStream sis = null;
    DataInputStream dis = null;
    byte[] bytes = null;

    try {
      bis = new ByteArrayInputStream(compressedBytes);
      sis = new SnappyInputStream(bis);
      dis = new DataInputStream(sis);

      bytes = IOUtils.toByteArray(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
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.