Difference between revisions of "Org.simantics.fastlz"
(→Manual) |
|||
(17 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | '''org.simantics.fastlz''' is a simple JNI wrapper for | + | '''org.simantics.fastlz''' is a simple JNI wrapper for different open-source real-time data compression libraries. The native library contains pure C implementations. The library also contains pure Java ports of the algorithms which are employed by the front-end if the native library is not available or if arguments are java heap buffers instead of native direct buffers. |
+ | |||
+ | Current codecs: | ||
+ | ;[http://www.fastlz.org/ FastLZ]: Our version is based on [http://fastlz.googlecode.com/svn/trunk/ SVN revision 12]. | ||
+ | ;[http://code.google.com/p/lz4/ LZ4]: Our version is based on [http://lz4.googlecode.com/svn/trunk/ SVN revision 68]. | ||
= Dependencies = | = Dependencies = | ||
− | * | + | * No Java or native dependencies. It is a self-sufficient JAR ready for deployment as OSGi bundle or POJO. Native DLL's only depend on standard libraries that are always available. |
− | |||
= Manual = | = Manual = | ||
− | + | 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 final String FASTLZ = "FastLZ"; | ||
+ | public static final String LZ4 = "LZ4"; | ||
+ | |||
+ | public static CompressionCodec get(String codec); | ||
+ | public static OutputStream write(String codec, File file) throws FileNotFoundException; | ||
+ | public static InputStream read(String codec, File file) throws FileNotFoundException; | ||
+ | |||
+ | } | ||
+ | |||
+ | 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> | ||
+ | </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. Output buffers must be writable or IllegalArgumentException is thrown. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | See the [[svn:utils/trunk/org.simantics.fastlz/src/org/simantics/fastlz/|actual code]] for proper Javadoc. | |
= Download = | = Download = | ||
Line 29: | Line 52: | ||
| '''Download''' | | '''Download''' | ||
|- style="background-color: #f9f9f9; " | | |- style="background-color: #f9f9f9; " | | ||
− | | 1. | + | | 1.2.0 |
− | | | + | | 12.7.2012 |
| [https://www.simantics.org/svn/simantics/utils/trunk/org.simantics.fastlz/ SVN] | | [https://www.simantics.org/svn/simantics/utils/trunk/org.simantics.fastlz/ SVN] | ||
|} | |} | ||
− | = | + | = Future Development = |
− | + | * Add pure Java implementation of LZ4 as a fallback | |
+ | * Rename plug-in to org.simantics.compression |
Latest revision as of 06:00, 1 August 2012
org.simantics.fastlz is a simple JNI wrapper for different open-source real-time data compression libraries. The native library contains pure C implementations. The library also contains pure Java ports of the algorithms which are employed by the front-end if the native library is not available or if arguments are java heap buffers instead of native direct buffers.
Current codecs:
- FastLZ
- Our version is based on SVN revision 12.
- LZ4
- Our version is based on SVN revision 68.
Dependencies
- No Java or native dependencies. It is a self-sufficient JAR ready for deployment as OSGi bundle or POJO. Native DLL's only depend on standard libraries that are always available.
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 static OutputStream write(String codec, File file) throws FileNotFoundException; public static InputStream read(String codec, File file) throws FileNotFoundException;
}
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. Output buffers must be writable or IllegalArgumentException is thrown.
See the actual code for proper Javadoc.
Download
Version | Date | Download |
1.2.0 | 12.7.2012 | SVN |
Future Development
- Add pure Java implementation of LZ4 as a fallback
- Rename plug-in to org.simantics.compression