Package org.iq80.leveldb.util

Examples of org.iq80.leveldb.util.SliceOutput


    }

    private static Slice generateRandomSlice(Random random, int length)
    {
        Slice rawData = Slices.allocate(length);
        SliceOutput sliceOutput = rawData.output();
        while (sliceOutput.isWritable()) {
            sliceOutput.writeByte((byte) ((int) ' ' + random.nextInt(95)));
        }
        return rawData;
    }
View Full Code Here


            // We use a limited amount of data over and over again and ensure
            // that it is larger than the compression window (32KB), and also
            // large enough to serve all typical value sizes we want to write.
            Random rnd = new Random(301);
            data = Slices.allocate(1048576 + 100);
            SliceOutput sliceOutput = data.output();
            while (sliceOutput.size() < 1048576) {
                // Add a short fragment that is as compressible as specified
                // by FLAGS_compression_ratio.
                sliceOutput.writeBytes(compressibleString(rnd, compressionRatio, 100));
            }
        }
View Full Code Here

    abstract protected Footer init() throws IOException;

    @Override
    public TableIterator iterator()
    {
        return new TableIterator(this, indexBlock.iterator());
    }
View Full Code Here

    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

        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

        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

    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

    public String getType() {
        return "snappy";
    }

    protected OutputStream wrapOutputStream(OutputStream underlying) throws IOException {
        return new SnappyOutputStream(underlying);
    }
View Full Code Here

        return byteArrayOutputStream.toByteArray();
    }

    public static void compress(byte[] in, OutputStream out) throws IOException {
        SnappyOutputStream snappyOutputStream = new SnappyOutputStream(out);
        snappyOutputStream.write(in);
        snappyOutputStream.close();
    }
View Full Code Here

        byte[] origBytes = messagePack.write(object);
        System.out.println("orig length: " + origBytes.length);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        SnappyOutputStream snappyOutputStream = new SnappyOutputStream(out);
        snappyOutputStream.write(origBytes);
        snappyOutputStream.close();

        byte[] comressedBytes = out.toByteArray();
        System.out.println("comressedBytes length: " + comressedBytes.length);

        byte[] bytes = cipherEncrypt.get().doFinal(comressedBytes);
View Full Code Here

TOP

Related Classes of org.iq80.leveldb.util.SliceOutput

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.