Merge branch 'release/1.1.0-M1'

This commit is contained in:
Taro L. Saito 2013-03-27 18:14:58 +09:00
commit aba95c4c40
21 changed files with 2063 additions and 9 deletions

View File

@ -68,7 +68,7 @@ Linux-i386_SNAPPY_FLAGS:=
Linux-amd64_CXX := $(CROSS_PREFIX)g++
Linux-amd64_STRIP := $(CROSS_PREFIX)strip
Linux-amd64_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -m64
Linux-amd64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
Linux-amd64_LINKFLAGS := -shared -static-libgcc # -static-libstdc++
Linux-amd64_LIBNAME := libsnappyjava.so
Linux-amd64_SNAPPY_FLAGS :=

View File

@ -77,6 +77,6 @@ test:
ssh $(AMD_SERVER) "source .zprofile && cd $(WORK) && $(TEST_CMD)"
release:
mvn deploy -DperformRelease=true
mvn deploy -DperformRelease=true

View File

@ -2,6 +2,11 @@
* `SnappyIndexer` for parallel compression/decompression
* CUI commands (snap/unsnap)
## snappy-java-1.1.0-M1 (27 March, 2013)
* Upgrade to snappy-1.1.0
* Add zero-copy compression (rawCompress, rawUncompress) that can be used with LArray <https://github.com/xerial/larray>
* Drop 32-bit Mac support
## snappy-java-1.0.5-M2 (27 September 2012)
* Upgrade release for snappy-1.0.5

View File

@ -6,7 +6,7 @@ The snappy-java is a Java port of the snappy
* Fast compression/decompression tailored to 64-bit CPU architecture.
* JNI-based implementation to achieve comparable performance to the native C++ version.
* Although snappy-java uses JNI, it can be used safely with multiple class loaders (e.g. Tomcat, etc.).
* Portable across various operating systems; Snappy-java contains native libraries built for Window/Mac/Linux (32/64-bit). At runtime, snappy-java loads one of these libraries according to your machine environment (It looks system properties, `os.name` and `os.arch`).
* Portable across various operating systems; Snappy-java contains native libraries built for Window/Mac/Linux (64-bit). At runtime, snappy-java loads one of these libraries according to your machine environment (It looks system properties, `os.name` and `os.arch`).
* Simple usage. Add the snappy-java-(version).jar file to your classpath. Then call compression/decompression methods in org.xerial.snappy.Snappy.
## Performance
@ -51,6 +51,8 @@ In addition, high-level methods (`Snappy.compress(String)`, `Snappy.compress(flo
### Stream-based API
Stream-based compressor/decompressor `SnappyOutputStream`/`SnappyInputStream` are also available for reading/writing large data sets.
* [Javadoc API](https://oss.sonatype.org/service/local/repositories/snapshots/archive/org/xerial/snappy/snappy-java/1.0.5-M5-SNAPSHOT/snappy-java-1.0.5-M5-20130319.150524-2-javadoc.jar/!/index.html)
### Setting classpath
If you have snappy-java-(VERSION).jar in the current directory, use `-classpath` option as follows:

1959
lib/inc_linux/jni.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.0.5-M4</version>
<version>1.1.0-M1</version>
<name>Snappy for Java</name>
<description>snappy-java: A fast compression/decompression library</description>
<packaging>bundle</packaging>
@ -103,8 +103,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
@ -184,7 +184,6 @@
<Bundle-NativeCode>
org/xerial/snappy/native/Windows/amd64/snappyjava.dll;selection-filter="(&amp;(osgi.arch=x86_64)(osgi.os=win32))",
org/xerial/snappy/native/Windows/x86/snappyjava.dll;selection-filter="(&amp;(osgi.arch=x86)(osgi.os=win32))",
org/xerial/snappy/native/Mac/i386/libsnappyjava.jnilib;selection-filter="(&amp;(osgi.arch=x86)(osgi.os=macosx))",
org/xerial/snappy/native/Mac/x86_64/libsnappyjava.jnilib;selection-filter="(&amp;(osgi.arch=x86_64)(osgi.os=macosx))",
org/xerial/snappy/native/Linux/amd64/libsnappyjava.so;selection-filter="(&amp;(osgi.arch=x86_64)(osgi.os=linux))",
org/xerial/snappy/native/Linux/i386/libsnappyjava.so;selection-filter="(&amp;(osgi.arch=x86)(osgi.os=linux))",

View File

@ -320,6 +320,31 @@ public class Snappy
return ((SnappyNativeAPI) impl).maxCompressedLength(byteSize);
}
/**
* Zero-copy compress using memory addresses.
* @param inputAddr input memory address
* @param inputSize input byte size
* @param destAddr destination address of the compressed data
* @return the compressed data size
* @throws IOException
*/
public static long rawCompress(long inputAddr, long inputSize, long destAddr) throws IOException {
return ((SnappyNativeAPI) impl).rawCompress(inputAddr, inputSize, destAddr);
}
/**
* Zero-copy decompress using memory addresses.
* @param inputAddr input memory address
* @param inputSize input byte size
* @param destAddr destination address of the uncompressed data
* @return the uncompressed data size
* @throws IOException
*/
public static long rawUncompress(long inputAddr, long inputSize, long destAddr) throws IOException {
return ((SnappyNativeAPI) impl).rawUncompress(inputAddr, inputSize, destAddr);
}
/**
* Compress the input data and produce a byte array of the uncompressed data
*
@ -547,7 +572,7 @@ public class Snappy
/**
* Get the uncompressed byte size of the given compressed input. This
* operation taks O(1) time.
* operation takes O(1) time.
*
* @param compressed
* input data [pos() ... limit())
@ -565,6 +590,18 @@ public class Snappy
return ((SnappyNativeAPI) impl).uncompressedLength(compressed, compressed.position(), compressed.remaining());
}
/**
* Get the uncompressed byte size of the given compressed input. This operation takes O(1) time.
* @param inputAddr compressed data address
* @param len byte length of the input
* @return uncompressed byte length of the given input
* @throws IOException when failed to uncompress the given input. The error code is
* {@link SnappyErrorCode#PARSING_ERROR}
*/
public static long uncompressedLength(long inputAddr, long len) throws IOException {
return ((SnappyNativeAPI) impl).uncompressedLength(inputAddr, len);
}
/**
* Uncompress the input as a float array
*

View File

@ -36,6 +36,32 @@ JNIEXPORT jstring JNICALL Java_org_xerial_snappy_SnappyNative_nativeLibraryVersi
return env->NewStringUTF("1.0.4");
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawCompress__JJJ
(JNIEnv* env, jobject self, jlong srcAddr, jlong length, jlong destAddr) {
size_t compressedLength;
snappy::RawCompress((char*) srcAddr, (size_t) length, (char*) destAddr, &compressedLength);
return (jlong) compressedLength;
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_rawUncompress__JJJ
(JNIEnv* env, jobject self, jlong srcAddr, jlong length, jlong destAddr) {
size_t uncompressedLength;
snappy::GetUncompressedLength((char*) srcAddr, (size_t) length, &uncompressedLength);
bool ret = snappy::RawUncompress((char*) srcAddr, (size_t) length, (char*) destAddr);
if(!ret) {
throw_exception(env, self, 5);
return 0;
}
return (jlong) uncompressedLength;
}
/*
* Class: org_xerial_snappy_Snappy
* Method: compress
@ -190,6 +216,21 @@ JNIEXPORT jint JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__L
return (jint) result;
}
JNIEXPORT jlong JNICALL Java_org_xerial_snappy_SnappyNative_uncompressedLength__JJ
(JNIEnv *env, jobject self, jlong inputAddr, jlong len) {
size_t result;
bool ret = snappy::GetUncompressedLength((char*) inputAddr, (size_t) len, &result);
if(!ret) {
throw_exception(env, self, 2);
return 0;
}
return (jint) result;
}
JNIEXPORT jboolean JNICALL Java_org_xerial_snappy_SnappyNative_isValidCompressedBuffer__Ljava_nio_ByteBuffer_2II
(JNIEnv * env, jobject self, jobject compressed, jint cpos, jint clen)
{

View File

@ -48,6 +48,9 @@ public class SnappyNative implements SnappyNativeAPI
// ------------------------------------------------------------------------
// Generic compression/decompression routines.
// ------------------------------------------------------------------------
public native long rawCompress(long inputAddr, long inputSize, long destAddr) throws IOException;
public native long rawUncompress(long inputAddr, long inputSize, long destAddr) throws IOException;
public native int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed,
int outputOffset) throws IOException;
@ -68,6 +71,8 @@ public class SnappyNative implements SnappyNativeAPI
public native int uncompressedLength(Object input, int offset, int len) throws IOException;
public native long uncompressedLength(long inputAddr, long len) throws IOException;
public native boolean isValidCompressedBuffer(ByteBuffer compressed, int offset, int len) throws IOException;
public native boolean isValidCompressedBuffer(Object input, int offset, int len) throws IOException;

View File

@ -45,6 +45,9 @@ public interface SnappyNativeAPI
// ------------------------------------------------------------------------
// Generic compression/decompression routines.
// ------------------------------------------------------------------------
public long rawCompress(long inputAddr, long inputSize, long destAddr) throws IOException;
public long rawUncompress(long inputAddr, long inputSize, long destAddr) throws IOException;
public int rawCompress(ByteBuffer input, int inputOffset, int inputLength, ByteBuffer compressed, int outputOffset)
throws IOException;
@ -65,6 +68,9 @@ public interface SnappyNativeAPI
public int uncompressedLength(Object input, int offset, int len) throws IOException;
public long uncompressedLength(long inputAddr, long len) throws IOException;
public boolean isValidCompressedBuffer(ByteBuffer compressed, int offset, int len) throws IOException;
public boolean isValidCompressedBuffer(Object input, int offset, int len) throws IOException;

View File

@ -1,2 +1,2 @@
VERSION=1.0.5
VERSION=1.1.0