Package org.lealone.compress

Examples of org.lealone.compress.Compressor


    public byte[] compress(byte[] in, String algorithm) {
        int len = in.length;
        if (in.length < 5) {
            algorithm = "NO";
        }
        Compressor compress = getCompressor(algorithm);
        byte[] buff = getBuffer((len < 100 ? len + 100 : len) * 2);
        int newLen = compress(in, in.length, compress, buff);
        byte[] out = DataUtils.newBytes(newLen);
        System.arraycopy(buff, 0, out, 0, newLen);
        return out;
View Full Code Here


     * @param in the byte array with the compressed data
     * @return the uncompressed data
     */
    public byte[] expand(byte[] in) {
        int algorithm = in[0];
        Compressor compress = getCompressor(algorithm);
        try {
            int len = readVariableInt(in, 1);
            int start = 1 + getVariableIntLength(len);
            byte[] buff = DataUtils.newBytes(len);
            compress.expand(in, start, in.length - start, buff, 0, len);
            return buff;
        } catch (Exception e) {
            throw DbException.get(ErrorCode.COMPRESSION_ERROR, e);
        }
    }
View Full Code Here

    /**
     * INTERNAL
     */
    public static void expand(byte[] in, byte[] out, int outPos) {
        int algorithm = in[0];
        Compressor compress = getCompressor(algorithm);
        try {
            int len = readVariableInt(in, 1);
            int start = 1 + getVariableIntLength(len);
            compress.expand(in, start, in.length - start, out, outPos, len);
        } catch (Exception e) {
            throw DbException.get(ErrorCode.COMPRESSION_ERROR, e);
        }
    }
View Full Code Here

        if (idx > 0) {
            options = algorithm.substring(idx + 1);
            algorithm = algorithm.substring(0, idx);
        }
        int a = getCompressAlgorithm(algorithm);
        Compressor compress = getCompressor(a);
        compress.setOptions(options);
        return compress;
    }
View Full Code Here

TOP

Related Classes of org.lealone.compress.Compressor

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.