Package net.jpountz.lz4

Examples of net.jpountz.lz4.LZ4FactoryTest


        private final net.jpountz.lz4.LZ4Compressor compressor;
        private final net.jpountz.lz4.LZ4Decompressor decompressor;

        private LZ4Compressor()
        {
            final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
            compressor = lz4Factory.fastCompressor();
            decompressor = lz4Factory.decompressor();
        }
View Full Code Here


        private final net.jpountz.lz4.LZ4Compressor compressor;
        private final net.jpountz.lz4.LZ4Decompressor decompressor;

        private LZ4Compressor()
        {
            final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
            compressor = lz4Factory.fastCompressor();
            decompressor = lz4Factory.decompressor();
        }
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

   public Object createObjectFromBytes(byte[] bytes) {
      // decompress
     
      // received format = | decompressed len (4B) | compressed bytes (bytes.length - 4) |
     
      final LZ4Factory factory = lz4Factory.get();
      int compressedLength = bytes.length - 4;
      ByteBuffer compbb = ByteBuffer.wrap(bytes);
      int decompressedLength = compbb.getInt();

     
      LZ4FastDecompressor decompressor = factory.fastDecompressor();
      byte[] decompressedBytes = new byte[decompressedLength];
      int compressedLength2 = decompressor.decompress(bytes, 4, decompressedBytes, 0, decompressedLength);
     
      assert(compressedLength == compressedLength2);
     
View Full Code Here

      return codecUncompressed.createObjectFromBytes(decompressedBytes);
   }

   @Override
   public ByteBuffer getByteBufferWithLengthHeader(Object obj) {
      final LZ4Factory factory = lz4Factory.get();

      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)                           |
View Full Code Here

      // decompress
      //                                                [-------------------- LENGTH IN HEADER -----------------------]
      //                                                                        [-----------COMPRESSED LENGTH---------]
      // received format = | compressed length + 4 (4B) | decompressed len (4B) | compressed bytes (bytes.length - 4) |
     
      final LZ4Factory factory = lz4Factory.get();
     
      int compressedLength      = buffer.getInt() - 4;
      int decompressedLength    = buffer.getInt();
      int compressedBytesOffset = buffer.arrayOffset() + buffer.position();
      byte[] compressedBytes    = buffer.array();
     
      LZ4FastDecompressor decompressor = factory.fastDecompressor();
      byte[] decompressedBytes = new byte[decompressedLength];
      int compressedLength2 = decompressor.decompress(compressedBytes, compressedBytesOffset, decompressedBytes, 0, decompressedLength);
     
      assert(compressedLength == compressedLength2);
     
View Full Code Here

        private final net.jpountz.lz4.LZ4Compressor compressor;
        private final net.jpountz.lz4.LZ4Decompressor decompressor;

        private LZ4Compressor()
        {
            final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
            compressor = lz4Factory.fastCompressor();
            decompressor = lz4Factory.decompressor();
        }
View Full Code Here

    private final net.jpountz.lz4.LZ4Compressor compressor;
    private final net.jpountz.lz4.LZ4Decompressor decompressor;

    private LZ4Compressor()
    {
        final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
        compressor = lz4Factory.fastCompressor();
        decompressor = lz4Factory.decompressor();
    }
View Full Code Here

        private final net.jpountz.lz4.LZ4Compressor compressor;
        private final net.jpountz.lz4.LZ4Decompressor decompressor;

        private LZ4Compressor()
        {
            final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
            compressor = lz4Factory.fastCompressor();
            decompressor = lz4Factory.decompressor();
        }
View Full Code Here

        private final net.jpountz.lz4.LZ4Compressor compressor;
        private final net.jpountz.lz4.LZ4Decompressor decompressor;

        private LZ4Compressor()
        {
            final LZ4Factory lz4Factory = LZ4Factory.fastestInstance();
            compressor = lz4Factory.fastCompressor();
            decompressor = lz4Factory.decompressor();
        }
View Full Code Here

TOP

Related Classes of net.jpountz.lz4.LZ4FactoryTest

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.