Package org.xerial.snappy

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

Related Classes of org.xerial.snappy.SnappyInputStream

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.