Difference between revisions of "Org.simantics.fastlz"

From Developer Documents
Jump to navigation Jump to search
Line 8: Line 8:
 
= Manual =
 
= Manual =
  
All use of the FastLZ java library happens through the [[svn:utils/trunk/org.simantics.fastlz/src/org/simantics/fastlz/FastLZ.java|org.simantics.fastlz.FastLZ]] facade class:
+
Use of both FastLZ and LZ4 codecs happens through the [[svn:utils/trunk/org.simantics.fastlz/src/org/simantics/fastlz/CompressionCodec.java|org.simantics.fastlz.CompressionCodec]] interface and the [[svn:utils/trunk/org.simantics.fastlz/src/org/simantics/fastlz/Compressions.java|org.simantics.fastlz.Compressions]] facade class:
 +
<div style="background-color:#f8f8f8; border: 1px dashed #cccccc; padding: 1ex; margin-left:2em; margin-top: 1em; margin-bottom:1em;">
 +
<syntaxhighlight lang="java">
 +
public final class Compressions {
  
    public static int compressBuffer(ByteBuffer input, int inputOffset, int length,
+
public static final String FASTLZ = "FastLZ";
                                      ByteBuffer output, int outputOffset);
+
public static final String LZ4    = "LZ4";
+
 
    public static int decompressBuffer(ByteBuffer input, int inputOffset, int length,  
+
public static CompressionCodec get(String codec);
                                        ByteBuffer output, int outputOffset, int maxout);
+
 
+
}
    public static InputStream read(File file) throws FileNotFoundException;
+
 
+
public interface CompressionCodec {
    public static OutputStream write(File file) throws FileNotFoundException;
+
 
 +
int compressBound(int inputSize);
 +
int compressBuffer(ByteBuffer input, int inputOffset, int length,
 +
ByteBuffer output, int outputOffset);
 +
 
 +
int decompressBuffer(ByteBuffer input, int inputOffset, int length,
 +
ByteBuffer output, int outputOffset, int maxout);
 +
 
 +
InputStream read(File file) throws FileNotFoundException;
 +
OutputStream write(File file) throws FileNotFoundException;
 +
 
 +
}
 +
</syntaxhighlight>
 +
</div>
  
 
ByteBuffers used in this interface can be either '''heap''' (ByteBuffer.allocate) or '''direct''' (ByteBuffer.allocateDirect). Use the same buffer type for both arguments for best performance.
 
ByteBuffers used in this interface can be either '''heap''' (ByteBuffer.allocate) or '''direct''' (ByteBuffer.allocateDirect). Use the same buffer type for both arguments for best performance.
 +
 +
See the [[svn:utils/trunk/org.simantics.fastlz/src/org/simantics/fastlz/|actual code]] for proper Javadoc.
  
 
= Download =
 
= Download =

Revision as of 08:12, 12 July 2012

org.simantics.fastlz is a simple JNI wrapper for the open-source FastLZ real-time data compression library. The native library is a pure C implementation. Our version is based on SVN revision 12. The library also contains a Java port of the algorithm which is employed by the front-end if the native library is not available or if arguments are java heap buffers instead of native direct buffers.

Dependencies

  • None, it is a self-sufficient JAR ready for deployment as OSGi bundle or POJO
  • Data to compress/decompress!

Manual

Use of both FastLZ and LZ4 codecs happens through the org.simantics.fastlz.CompressionCodec interface and the org.simantics.fastlz.Compressions facade class:

<syntaxhighlight lang="java"> public final class Compressions {

public static final String FASTLZ = "FastLZ"; public static final String LZ4 = "LZ4";

public static CompressionCodec get(String codec);

}

public interface CompressionCodec {

int compressBound(int inputSize); int compressBuffer(ByteBuffer input, int inputOffset, int length, ByteBuffer output, int outputOffset);

int decompressBuffer(ByteBuffer input, int inputOffset, int length, ByteBuffer output, int outputOffset, int maxout);

InputStream read(File file) throws FileNotFoundException; OutputStream write(File file) throws FileNotFoundException;

} </syntaxhighlight>

ByteBuffers used in this interface can be either heap (ByteBuffer.allocate) or direct (ByteBuffer.allocateDirect). Use the same buffer type for both arguments for best performance.

See the actual code for proper Javadoc.

Download

Version Date Download
1.1.0 now SVN

Current Development

  • Add LZ4 support