jpountz/lz4-java — pull request #49 by blambov (2014-08-25 12:53:01+00:00)
Title: Implements ByteBuffer support for all LZ4 methods

Covers all implementations:
* JNI interfaces are extended to deal with direct buffer addresses.
* Unsafe implementations work on the underlying arrays. Direct buffers are handled by converting the address of the block to an offset from a null reference.
* Safe Java implementations work on the ByteBuffer interfaces directly.

Additional changes applied:
* As memory addresses can be larger than int, unsafe implementations require long offsets. As this has a very noticeable performance impact on 32-bit hardware, the patch provides a separate 'Long' version of each unsafe class which is chosen when the address size is longer than 32 bits.
* Range checks are removed from Safe classes, as the JVM will already do the verification at each access.

The efficiency of the JNI and Unsafe methods on byte buffers is on par with those on arrays, with some benefits in the case of JNI, direct buffers and active garbage collection. Safe methods are slower due to the ByteBuffer access overheads.