/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
/** * Creates a new LZF encoder with specified settings. * * @param safeInstance * If {@code true} encoder will use {@link ChunkEncoder} that only uses standard JDK access methods, * and should work on all Java platforms and JVMs. * Otherwise encoder will try to use highly optimized {@link ChunkEncoder} implementation that uses * Sun JDK's {@link sun.misc.Unsafe} class (which may be included by other JDK's as well). * @param totalLength * Expected total length of content to compress; only matters for outgoing messages that is smaller * than maximum chunk size (64k), to optimize encoding hash tables. */ public LzfEncoder(boolean safeInstance, int totalLength) { super(false); if (totalLength < MIN_BLOCK_TO_COMPRESS || totalLength > MAX_CHUNK_LEN) { throw new IllegalArgumentException("totalLength: " + totalLength + " (expected: " + MIN_BLOCK_TO_COMPRESS + '-' + MAX_CHUNK_LEN + ')'); } encoder = safeInstance ? ChunkEncoderFactory.safeNonAllocatingInstance(totalLength) : ChunkEncoderFactory.optimalNonAllocatingInstance(totalLength); recycler = BufferRecycler.instance(); }
_encoder = ChunkEncoderFactory.optimalNonAllocatingInstance(bufferLen, _recycler);