Package com.datastax.driver.core

Examples of com.datastax.driver.core.FrameCompressor$LZ4Compressor


    byte[] data = "12345345234572".getBytes("UTF-8");
    final int decompressedLength = data.length;

    // compress data
    LZ4Compressor compressor = factory.fastCompressor();
    int maxCompressedLength = compressor.maxCompressedLength(decompressedLength);
    byte[] compressed = new byte[maxCompressedLength];
    int compressedLength = compressor.compress(data, 0, decompressedLength, compressed, 0, maxCompressedLength);

    // decompress data
    // - method 1: when the decompressed length is known
    LZ4FastDecompressor decompressor = factory.fastDecompressor();
    byte[] restored = new byte[decompressedLength];
View Full Code Here


                        out = new DataOutputStreamPlus(new SnappyOutputStream(socket.getOutputStream()));
                    }
                    else
                    {
                        // TODO: custom LZ4 OS that supports BB write methods
                        LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
                        Checksum checksum = XXHashFactory.fastestInstance().newStreamingHash32(LZ4_HASH_SEED).asChecksum();
                        out = new DataOutputStreamPlus(new LZ4BlockOutputStream(socket.getOutputStream(),
                                                                            1 << 14// 16k block size
                                                                            compressor,
                                                                            checksum,
View Full Code Here

                    {
                        out = new DataOutputStream(new SnappyOutputStream(new BufferedOutputStream(socket.getOutputStream())));
                    }
                    else
                    {
                        LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
                        Checksum checksum = XXHashFactory.fastestInstance().newStreamingHash32(LZ4_HASH_SEED).asChecksum();
                        out = new DataOutputStream(new LZ4BlockOutputStream(new BufferedOutputStream(socket.getOutputStream()),
                                                                            1 << 14// 16k block size
                                                                            compressor,
                                                                            checksum,
View Full Code Here

   @Override
   public byte[] getBytes(Object obj) {
      final LZ4Factory factory = lz4Factory.get();
      byte[] data = codecUncompressed.getBytes(obj);
      final int decompressedLength = data.length;
      LZ4Compressor compressor = factory.fastCompressor();
      int maxCompressedLength = compressor.maxCompressedLength(decompressedLength);
      byte[] compressed = new byte[4 + maxCompressedLength];
      compressor.compress(data, 0, decompressedLength, compressed, 4, maxCompressedLength);
      return compressed;
   }
View Full Code Here

      byte[] data = codecUncompressed.getBytes(obj);
      final int decompressedLength = data.length;

      // compress data
      LZ4Compressor compressor = factory.fastCompressor();
      int maxCompressedLength = compressor.maxCompressedLength(decompressedLength);
      byte[] compressed = new byte[8 + maxCompressedLength];
      int compressedLength = compressor.compress(data, 0, decompressedLength, compressed, 8, maxCompressedLength);

      // tcpreceiver decoder expects | x = message length (4B) | message    (x bytes)                           |
      // we are providing            | x = y + 4          (4B) | dec length (4 bytes) | comp. message (y bytes) |
      //
      //
View Full Code Here

  {
    if (in == null) {
      throw new NullPointerException("Can't compress null");
    }

    LZ4Compressor compressor = lz4Factory.fastCompressor();

    byte[] out = new byte[compressor.maxCompressedLength(in.length)];
    int compressedLength = compressor.compress(in, 0, in.length, out, 0);

    getLogger().debug("Compressed %d bytes to %d", in.length, compressedLength);

    return ByteBuffer.allocate(Ints.BYTES + compressedLength)
                     .putInt(in.length)
View Full Code Here

                        out = new DataOutputStreamPlus(new SnappyOutputStream(socket.getOutputStream()));
                    }
                    else
                    {
                        // TODO: custom LZ4 OS that supports BB write methods
                        LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
                        Checksum checksum = XXHashFactory.fastestInstance().newStreamingHash32(LZ4_HASH_SEED).asChecksum();
                        out = new DataOutputStreamPlus(new LZ4BlockOutputStream(socket.getOutputStream(),
                                                                            1 << 14// 16k block size
                                                                            compressor,
                                                                            checksum,
View Full Code Here

                        out = new DataOutputStreamPlus(new SnappyOutputStream(socket.getOutputStream()));
                    }
                    else
                    {
                        // TODO: custom LZ4 OS that supports BB write methods
                        LZ4Compressor compressor = LZ4Factory.fastestInstance().fastCompressor();
                        Checksum checksum = XXHashFactory.fastestInstance().newStreamingHash32(LZ4_HASH_SEED).asChecksum();
                        out = new DataOutputStreamPlus(new LZ4BlockOutputStream(socket.getOutputStream(),
                                                                            1 << 14// 16k block size
                                                                            compressor,
                                                                            checksum,
View Full Code Here

      throw new RuntimeException("native lz4 library not available");
    }
    int bufferSize = conf.getInt(
        CommonConfigurationKeys.IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_KEY,
        CommonConfigurationKeys.IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_DEFAULT);
    return new Lz4Compressor(bufferSize);
  }
View Full Code Here

  //test on NullPointerException in {@code compressor.setInput()}
  @Test
  public void testCompressorSetInputNullPointerException() {
    try {
      Lz4Compressor compressor = new Lz4Compressor();
      compressor.setInput(null, 0, 10);
      fail("testCompressorSetInputNullPointerException error !!!");
    } catch (NullPointerException ex) {
      // expected
    } catch (Exception e) {
      fail("testCompressorSetInputNullPointerException ex error !!!");
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.FrameCompressor$LZ4Compressor

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.