Merge branch 'release/1.0.5-M1'

This commit is contained in:
Taro L. Saito 2012-09-27 11:10:57 +09:00
commit 7b2546911b
12 changed files with 503 additions and 406 deletions

20
.gitignore vendored Normal file
View File

@ -0,0 +1,20 @@
*~
*.class
*.log
# IntelliJ
.idea
.idea_modules
# sbt specific
bin/.lib
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
# Scala-IDE specific
.scala_dependencies

View File

@ -82,7 +82,11 @@ test: $(NATIVE_DLL)
$(MVN) test $(MVN) test
win32: win32:
$(MAKE) native CXX=mingw32-g++ OS_NAME=Windows OS_ARCH=x86 $(MAKE) native CROSS_PREFIX=i686-w64-mingw32- OS_NAME=Windows OS_ARCH=x86
# for cross-compilation on Ubuntu, install the g++-mingw-w64-x86-64 package
win64:
$(MAKE) native CROSS_PREFIX=x86_64-w64-mingw32- OS_NAME=Windows OS_ARCH=amd64
mac32: mac32:
$(MAKE) native OS_NAME=Mac OS_ARCH=i386 $(MAKE) native OS_NAME=Mac OS_ARCH=i386
@ -90,6 +94,14 @@ mac32:
linux32: linux32:
$(MAKE) native OS_NAME=Linux OS_ARCH=i386 $(MAKE) native OS_NAME=Linux OS_ARCH=i386
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabi package
linux-arm:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabi- OS_NAME=Linux OS_ARCH=arm
# for cross-compilation on Ubuntu, install the g++-arm-linux-gnueabihf package
linux-armhf:
$(MAKE) native CROSS_PREFIX=arm-linux-gnueabihf- OS_NAME=Linux OS_ARCH=armhf
clean-native-linux32: clean-native-linux32:
$(MAKE) clean-native OS_NAME=Linux OS_ARCH=i386 $(MAKE) clean-native OS_NAME=Linux OS_ARCH=i386

View File

@ -105,15 +105,15 @@ Mac-x86_64_LINKFLAGS := -dynamiclib -static-libgcc
Mac-x86_64_LIBNAME := libsnappyjava.jnilib Mac-x86_64_LIBNAME := libsnappyjava.jnilib
Mac-x86_64_SNAPPY_FLAGS := Mac-x86_64_SNAPPY_FLAGS :=
Windows-x86_CXX := mingw32-g++ Windows-x86_CXX := $(CROSS_PREFIX)g++
Windows-x86_STRIP := strip Windows-x86_STRIP := $(CROSS_PREFIX)strip
Windows-x86_CXXFLAGS := -Ilib/inc_win -O2 Windows-x86_CXXFLAGS := -Ilib/inc_win -O2
Windows-x86_LINKFLAGS := -Wl,--kill-at -shared -static Windows-x86_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-x86_LIBNAME := snappyjava.dll Windows-x86_LIBNAME := snappyjava.dll
Windows-x86_SNAPPY_FLAGS := Windows-x86_SNAPPY_FLAGS :=
Windows-amd64_CXX := x86_64-w64-mingw32-g++ Windows-amd64_CXX := $(CROSS_PREFIX)g++
Windows-amd64_STRIP := x86_64-w64-mingw32-strip Windows-amd64_STRIP := $(CROSS_PREFIX)strip
Windows-amd64_CXXFLAGS := -Ilib/inc_win -O2 Windows-amd64_CXXFLAGS := -Ilib/inc_win -O2
Windows-amd64_LINKFLAGS := -Wl,--kill-at -shared -static Windows-amd64_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-amd64_LIBNAME := snappyjava.dll Windows-amd64_LIBNAME := snappyjava.dll

59
Milestone.md Normal file
View File

@ -0,0 +1,59 @@
## Features under consideration
* `SnappyIndexer` for parallel compression/decompression
* CUI commands (snap/unsnap)
## snappy-java-1.0.4.1 (5 September 2011)
* Fixes issue 33: Fixes a problem when reading incomplete input stream
## snappy-java-1.0.4 (September 22nd, 2011)
* Upgrade to snappy-1.0.4
* Enhanced the Javadoc
## snappy-java-1.0.3.3 (September 10th, 2011)
* Add support for Oracle JRockit JVM. (issue 28)
## snappy-java-1.0.3.2 (August 23rd, 2011)
* Upgrade from the previous release is optional
* Add system properites to switch sytem installed native library or bundled
library (issue 20, issue 26)
* source code tar ball (issue 25)
* primitive array read/write support (issue 24)
## snappy-java-1.0.3.1 (August 2nd, 2011)
* Maintenance release (no significant change)
* Refactoring code
* Rebuild win32 binary
## snappy-java-1.0.3 (July 11st, 2011)
* Deprected SnappyException. Instead snappy-java uses IOException to issue
errors. This change is necessary to support JNI code injection to a parent
class loader.
## snappy-java-1.0.3-rc4 (June 27th, 2011)
* JNI interface injection so that multiple applications can share the native
code. Issue 21
## snappy-java-1.0.3-rc3 (June 21st, 2011)
* Fixes issue 18, issue 19
* Reduces memory footprint (contribution from Arec Wysoker)
## snappy-java-1.0.3-rc2 (June 7th, 2011)
* Fixes issue 17
## snappy-java-1.0.3-rc1 (June 4th, 2011)
* Upgrade to snappy-1.0.3 done.
* libstdc++ embedding (only for Linux version) done.
* Minor bug fixes
## snappy-java-1.0.1-rc4 (April 11th, 2011)
* Primitive array support (e.g. `int[]`, `float[]`, etc.) issue 10
* String compression/decompression
## snappy-java-1.0.1-rc3 (April 4th, 2011)
* Running tests under win32/mac32, etc.
## snappy-java-1.0.1-rc2 (April 2nd, 2011)
* Adding `SnappyOutputStream` `SnappyInputStream` issue 3
* March 29th. Started snappy-java project

102
README
View File

@ -1,102 +0,0 @@
This document is a copy of http://code.google.com/p/snappy-java/
---------------------------------------
The snappy-java is a Java port of the snappy http://code.google.com/p/snappy/, a fast compresser/decompresser written in C++ developed by Google.
== Features ==
* [http://www.apache.org/licenses/LICENSE-2.0 Apache Licence Version 2.0]. Free for both commercial and non-commercial use.
* 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`).
* Simple usage. Add the snappy-java-(version).jar file to your classpath. Then call compression/decompression methods in org.xerial.snappy.Snappy.
== Performance ==
* Snappy's main target is very high-speed compression/decompression with reasonable compression size. So the compression ratio of snappy-java is modest and about the same as `LZF` (ranging 20%-100% according to the dataset).
* Here are some [https://github.com/ning/jvm-compressor-benchmark/wiki benchmark results], comparing snappy-java and the other compressors `LZO-java`/`LZF`/`QuickLZ`/`Gzip`/`Bzip2`. Thanks [http://twitter.com/#!/cowtowncoder Tatu Saloranta @cowtowncoder] for providing the benchmark suite.
* The benchmark result indicates snappy-java is the fastest compreesor/decompressor in Java:
* http://ning.github.com/jvm-compressor-benchmark/results/canterbury-roundtrip-2011-07-28/index.html
* The decompression speed is twice as fast as the others:
* http://ning.github.com/jvm-compressor-benchmark/results/canterbury-uncompress-2011-07-28/index.html
== Download ==
The current stable version 1.0.3.1 is available from here:
* Release version: http://maven.xerial.org/repository/artifact/org/xerial/snappy/snappy-java
* [Milestone] release plans
* Snapshot version (the latest beta version): http://maven.xerial.org/repository/snapshot/org/xerial/snappy/snappy-java/
If you are a Maven user, see [#Using_with_Maven]
== Usage ==
First, import `org.xerial.snapy.Snappy` in your Java code:
{{{
import org.xerial.snappy.Snappy;
}}}
Then use `Snappy.compress(byte[])` and `Snappy.uncompress(byte[])`:
{{{
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of "
+ "Snappy, a fast compresser/decompresser.";
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
}}}
In addition, high-level methods (`Snappy.compress(String)`, `Snappy.compress(float[] ..)` etc. ) and low-level ones (e.g. `Snappy.rawCompress(.. )`, `Snappy.rawUncompress(..)`, etc.), which minimize memory copies, can be used. See also
[http://code.google.com/p/snappy-java/source/browse/src/main/java/org/xerial/snappy/Snappy.java Snappy.java]
===Stream-based API===
Stream-based compressor/decompressor `SnappyOutputStream`/`SnappyInputStream` are also available for reading/writing large data sets.
===Setting classpath==
If you have snappy-java-(VERSION).jar in the current directory, use `-classpath` option as follows:
{{{
$ javac -classpath ".;snappy-java-(VERSION).jar" Sample.java # in Windows
or
$ javac -classpath ".:snappy-java-(VERSION).jar" Sample.java # in Mac or Linux
}}}
===Using with Maven===
* Snappy-java is available from Maven's central repository: http://repo1.maven.org/maven2/org/xerial/snappy/snappy-java
Add the following dependency to your pom.xml:
{{{
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>(version)</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
}}}
==Public discussion group==
Post bug reports or feature request to the Issue Tracker: http://code.google.com/p/snappy-java/issues/list
Public discussion forum is here: [http://groups.google.com/group/xerial?hl=en Xerial Public Discussion Group].
== Building from the source code ==
See the [http://code.google.com/p/snappy-java/source/browse/INSTALL installation instruction]. Building from the source code is an option when your OS platform and CPU architecture is not supported. To build snappy-java, you need Mercurial(hg), JDK (1.6 or higher), Maven (3.x or higher is required), g++ compiler (mingw in Windows) etc.
{{{
$ hg clone https://snappy-java.googlecode.com/hg/ snappy-java
$ cd snappy-java
$ make
}}}
A file `target/snappy-java-$(version).jar` is the product additionally containing the native library built for your platform.
==Miscellaneous Notes==
===Using snappy-java with Tomcat 6 (or higher) Web Server===
Simply put the snappy-java's jar to WEB-INF/lib folder of your web application. Usual JNI-library specific problem no longer exists since snappy-java version 1.0.3 or higher can be loaded by multiple class loaders in the same JVM by using native code injection to the parent class loader (Issue 21).
----
Snappy-java is developed by [http://www.xerial.org/leo Taro L. Saito]. Twitter [http://twitter.com/#!/taroleo @taroleo]

119
README.md Executable file
View File

@ -0,0 +1,119 @@
The snappy-java is a Java port of the snappy
<http://code.google.com/p/snappy/>, a fast C++ compresser/decompresser developed by Google.
## Features
* [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). Free for both commercial and non-commercial use.
* 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`).
* Simple usage. Add the snappy-java-(version).jar file to your classpath. Then call compression/decompression methods in org.xerial.snappy.Snappy.
## Performance
* Snappy's main target is very high-speed compression/decompression with reasonable compression size. So the compression ratio of snappy-java is modest and about the same as `LZF` (ranging 20%-100% according to the dataset).
* Here are some [benchmark results](https://github.com/ning/jvm-compressor-benchmark/wiki), comparing
snappy-java and the other compressors
`LZO-java`/`LZF`/`QuickLZ`/`Gzip`/`Bzip2`. Thanks [Tatu Saloranta @cotowncoder](http://twitter.com/#!/cowtowncoder) for providing the benchmark suite.
* The benchmark result indicates snappy-java is the fastest compreesor/decompressor in Java:
* <http://ning.github.com/jvm-compressor-benchmark/results/canterbury-roundtrip-2011-07-28/index.html>
* The decompression speed is twice as fast as the others:
* <http://ning.github.com/jvm-compressor-benchmark/results/canterbury-uncompress-2011-07-28/index.html>
## Download
The current stable version is available from here:
* Release version: http://maven.xerial.org/repository/artifact/org/xerial/snappy/snappy-java
* [release plans](./snappy-java/Milestone.md)
* Snapshot version (the latest beta version): https://oss.sonatype.org/content/repositories/snapshots/org/xerial/snappy/snappy-java/
If you are a Maven user, see [#Using_with_Maven]
## Usage
First, import `org.xerial.snapy.Snappy` in your Java code:
import org.xerial.snappy.Snappy;
Then use `Snappy.compress(byte[])` and `Snappy.uncompress(byte[])`:
String input = "Hello snappy-java! Snappy-java is a JNI-based wrapper of "
+ "Snappy, a fast compresser/decompresser.";
byte[] compressed = Snappy.compress(input.getBytes("UTF-8"));
byte[] uncompressed = Snappy.uncompress(compressed);
String result = new String(uncompressed, "UTF-8");
System.out.println(result);
In addition, high-level methods (`Snappy.compress(String)`, `Snappy.compress(float[] ..)` etc. ) and low-level ones (e.g. `Snappy.rawCompress(.. )`, `Snappy.rawUncompress(..)`, etc.), which minimize memory copies, can be used. See also
[Snappy.java](https://github.com/xerial/snappy-java/blob/master/src/main/java/org/xerial/snappy/Snappy.java)
### Stream-based API
Stream-based compressor/decompressor `SnappyOutputStream`/`SnappyInputStream` are also available for reading/writing large data sets.
### Setting classpath
If you have snappy-java-(VERSION).jar in the current directory, use `-classpath` option as follows:
$ javac -classpath ".;snappy-java-(VERSION).jar" Sample.java # in Windows
or
$ javac -classpath ".:snappy-java-(VERSION).jar" Sample.java # in Mac or Linux
### Using with Maven
* Snappy-java is available from Maven's central repository: <http://repo1.maven.org/maven2/org/xerial/snappy/snappy-java>
Add the following dependency to your pom.xml:
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>(version)</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
## Public discussion group
Post bug reports or feature request to the Issue Tracker: <https://github.com/xerial/snappy-java/issues>
Public discussion forum is here: <http://groups.google.com/group/xerial?hl=en Xerial Public Discussion Group>
## Building from the source code
See the [installation instruction](https://github.com/xerial/snappy-java/blob/develop/INSTALL). Building from the source code is an option when your OS platform and CPU architecture is not supported. To build snappy-java, you need Git, JDK (1.6 or higher), Maven (3.x or higher is required), g++ compiler (mingw in Windows) etc.
$ git clone https://github.com/xerial/snappy-java.git
$ cd snappy-java
$ make
A file `target/snappy-java-$(version).jar` is the product additionally containing the native library built for your platform.
## Cross-compiling for other platforms
The Makefile contains rules for cross-compiling the native library for other platforms so that the snappy-java JAR can support multiple platforms. For example, to build the native libraries for x86 Linux, x86 and x86-64 Windows, and soft- and hard-float ARM:
$ make linux32 win32 win64 linux-arm linux-armhf
If you append `snappy` to the line above, it will also build the native library for the current platform and then build the snappy-java JAR (containing all native libraries built so far).
Of course, you must first have the necessary cross-compilers and development libraries installed for each target CPU and OS. For example, on Ubuntu 12.04 for x86-64, install the following packages for each target:
* linux32: `sudo apt-get install g++-multilib libc6-dev-i386 lib32stdc++6`
* win32: `sudo apt-get install g++-mingw-w64-i686`
* win64: `sudo apt-get install g++-mingw-w64-x86-64`
* arm: `sudo apt-get install g++-arm-linux-gnueabi`
* armhf: `sudo apt-get install g++-arm-linux-gnueabihf`
Unfortunately, cross-compiling for Mac OS X is not currently possible; you must compile within OS X.
If you are using Mac and openjdk7 (or higher), use the following option:
$ make native LIBNAME=libsnappyjava.dylib
## Miscellaneous Notes
### Using snappy-java with Tomcat 6 (or higher) Web Server
Simply put the snappy-java's jar to WEB-INF/lib folder of your web application. Usual JNI-library specific problem no longer exists since snappy-java version 1.0.3 or higher can be loaded by multiple class loaders in the same JVM by using native code injection to the parent class loader (Issue 21).
----
Snappy-java is developed by [Taro L. Saito](http://www.xerial.org/leo). Twitter [@taroleo](http://twitter.com/#!/taroleo)

581
pom.xml
View File

@ -1,298 +1,283 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.xerial.snappy</groupId> <groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId> <artifactId>snappy-java</artifactId>
<version>1.0.5-SNAPSHOT</version> <version>1.0.5-M1</version>
<name>Snappy for Java</name> <name>Snappy for Java</name>
<description>snappy-java: A fast compression/decompression library</description> <description>snappy-java: A fast compression/decompression library</description>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<properties> <parent>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <groupId>org.sonatype.oss</groupId>
</properties> <artifactId>oss-parent</artifactId>
<version>7</version>
<licenses> </parent>
<license>
<name>The Apache Software License, Version 2.0</name> <properties>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<distribution>repo</distribution> </properties>
</license>
</licenses> <licenses>
<license>
<developers> <name>The Apache Software License, Version 2.0</name>
<developer> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<id>leo</id> <distribution>repo</distribution>
<name>Taro L. Saito</name> </license>
<email>leo@xerial.org</email> </licenses>
<organization>Xerial Project</organization>
<roles> <developers>
<role>Architect</role> <developer>
<role>Project Manager</role> <id>leo</id>
<role>Chief Developer</role> <name>Taro L. Saito</name>
</roles> <email>leo@xerial.org</email>
<timezone>+9</timezone> <organization>Xerial Project</organization>
</developer> <roles>
</developers> <role>Architect</role>
<role>Project Manager</role>
<organization> <role>Chief Developer</role>
<name>xerial.org</name> </roles>
<url>http://www.xerial.org/</url> <timezone>+9</timezone>
</organization> </developer>
</developers>
<build>
<resources> <organization>
<resource> <name>xerial.org</name>
<directory>src/main/java</directory> <url>http://www.xerial.org/</url>
<includes> </organization>
<include>org/xerial/snappy/VERSION</include>
</includes> <build>
</resource> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/java</directory>
<includes> <includes>
<include>org/xerial/snappy/*.bytecode</include> <include>org/xerial/snappy/VERSION</include>
<include>org/xerial/snappy/native/**</include> </includes>
</includes> </resource>
</resource> <resource>
<resource> <directory>src/main/resources</directory>
<directory>${basedir}</directory> <includes>
<targetPath>META-INF/maven/${project.groupId}/${project.artifactId}</targetPath> <include>org/xerial/snappy/*.bytecode</include>
<includes> <include>org/xerial/snappy/native/**</include>
<include>LICENSE*</include> </includes>
</includes> </resource>
</resource> <resource>
</resources> <directory>${basedir}</directory>
<testResources> <targetPath>META-INF/maven/${project.groupId}/${project.artifactId}</targetPath>
<testResource> <includes>
<directory>src/test/java</directory> <include>LICENSE*</include>
<excludes> </includes>
<exclude>**/*.java</exclude> </resource>
</excludes> </resources>
</testResource> <testResources>
<testResource> <testResource>
<directory>src/test/resources</directory> <directory>src/test/java</directory>
</testResource> <excludes>
</testResources> <exclude>**/*.java</exclude>
</excludes>
</testResource>
<plugins> <testResource>
<plugin> <directory>src/test/resources</directory>
<groupId>org.apache.maven.plugins</groupId> </testResource>
<artifactId>maven-resources-plugin</artifactId> </testResources>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding> <plugins>
</configuration> <plugin>
</plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<plugin> <version>2.5</version>
<groupId>org.apache.maven.plugins</groupId> <configuration>
<artifactId>maven-compiler-plugin</artifactId> <encoding>UTF-8</encoding>
<version>2.0.2</version> </configuration>
<configuration> </plugin>
<source>1.5</source>
<target>1.5</target> <plugin>
</configuration> <groupId>org.apache.maven.plugins</groupId>
</plugin> <artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<plugin> <configuration>
<artifactId>maven-release-plugin</artifactId> <source>1.5</source>
<version>2.1</version> <target>1.5</target>
<configuration> </configuration>
<!-- do not run site-deploy goal, included in the default settings --> </plugin>
<goals>deploy</goals>
<connectionUrl>scm:hg:https://snappy-java.googlecode.com/hg/</connectionUrl> <plugin>
</configuration> <artifactId>maven-release-plugin</artifactId>
</plugin> <version>2.1</version>
<configuration>
<plugin> <!-- do not run site-deploy goal, included in the default settings -->
<groupId>org.apache.maven.plugins</groupId> <goals>deploy</goals>
<artifactId>maven-javadoc-plugin</artifactId> <pushChanges>false</pushChanges>
<version>2.8</version> <localCheckout>true</localCheckout>
<configuration> </configuration>
<charset>UTF-8</charset> </plugin>
<locale>en_US</locale>
<show>public</show> <plugin>
<stylesheetfile>stylesheet.css</stylesheetfile> <groupId>org.apache.maven.plugins</groupId>
</configuration> <artifactId>maven-gpg-plugin</artifactId>
<executions> <version>1.4</version>
<execution> <configuration>
<id>attach-javadocs</id> <useAgent>true</useAgent>
<phase>verify</phase> </configuration>
<goals> <executions>
<goal>jar</goal> <execution>
</goals> <id>sign-artifacts</id>
</execution> <phase>verify</phase>
</executions> <goals>
</plugin> <goal>sign</goal>
</goals>
<plugin> </execution>
<groupId>org.apache.maven.plugins</groupId> </executions>
<artifactId>maven-source-plugin</artifactId> </plugin>
<version>2.1.2</version>
<configuration> <plugin>
<excludeResources>true</excludeResources> <groupId>org.apache.maven.plugins</groupId>
</configuration> <artifactId>maven-javadoc-plugin</artifactId>
<executions> <version>2.8</version>
<execution> <configuration>
<id>attach-sources</id> <charset>UTF-8</charset>
<phase>verify</phase> <locale>en_US</locale>
<goals> <show>public</show>
<goal>jar</goal> <stylesheetfile>stylesheet.css</stylesheetfile>
</goals> </configuration>
</execution> </plugin>
</executions>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<plugin> <artifactId>maven-source-plugin</artifactId>
<groupId>org.apache.felix</groupId> <version>2.1.2</version>
<artifactId>maven-bundle-plugin</artifactId> <configuration>
<version>2.3.4</version> <excludeResources>true</excludeResources>
<extensions>true</extensions> </configuration>
<configuration> <executions>
<instructions> <execution>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName> <id>attach-sources</id>
<Bundle-Name>${pproject.name}</Bundle-Name> <phase>verify</phase>
<Bundle-Version>${project.version}</Bundle-Version> <goals>
<Bundle-Activator>org.xerial.snappy.SnappyBundleActivator</Bundle-Activator> <goal>jar-no-fork</goal>
<Export-Package>org.xerial.snappy</Export-Package> </goals>
<Import-Package>org.osgi.framework;version="[1.5,2)"</Import-Package> </execution>
</instructions> </executions>
</configuration> </plugin>
</plugin>
<plugin>
<plugin> <groupId>org.apache.felix</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<version>2.2.1</version> <version>2.3.4</version>
<configuration> <extensions>true</extensions>
<descriptors> <configuration>
<descriptor>src/assembly/project.xml</descriptor> <instructions>
</descriptors> <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<appendAssemblyId>false</appendAssemblyId> <Bundle-Name>${pproject.name}</Bundle-Name>
<attach>false</attach> <Bundle-Version>${project.version}</Bundle-Version>
</configuration> <Bundle-Activator>org.xerial.snappy.SnappyBundleActivator</Bundle-Activator>
<executions> <Export-Package>org.xerial.snappy</Export-Package>
<execution> <Import-Package>org.osgi.framework;version="[1.5,2)"</Import-Package>
<id>make-assembly</id> </instructions>
<phase>package</phase> </configuration>
<goals> </plugin>
<goal>single</goal>
</goals> <plugin>
</execution> <artifactId>maven-assembly-plugin</artifactId>
</executions> <version>2.2.1</version>
</plugin> <configuration>
</plugins> <descriptors>
<descriptor>src/assembly/project.xml</descriptor>
<extensions> </descriptors>
<extension> <appendAssemblyId>false</appendAssemblyId>
<groupId>org.apache.maven.wagon</groupId> <attach>false</attach>
<artifactId>wagon-ssh-external</artifactId> </configuration>
<version>1.0-beta-7</version> <executions>
</extension> <execution>
</extensions> <id>make-assembly</id>
<phase>package</phase>
</build> <goals>
<goal>single</goal>
</goals>
<url>http://code.google.com/p/snappy-java/</url> </execution>
<issueManagement> </executions>
<system>Google Code</system> </plugin>
<url>http://code.google.com/p/snappy-java/issues/list</url> </plugins>
</issueManagement>
<inceptionYear>2011</inceptionYear> <extensions>
<scm> <extension>
<connection>scm:hg:https://snappy-java.googlecode.com/hg/</connection> <groupId>org.apache.maven.wagon</groupId>
<developerConnection>scm:hg:default</developerConnection> <artifactId>wagon-ssh-external</artifactId>
<url>scm:hg:https://snappy-java.googlecode.com/hg/</url> <version>1.0-beta-7</version>
</scm> </extension>
</extensions>
<distributionManagement>
<!-- for development releases --> </build>
<site>
<id>xerial.scp</id>
<url>scpexe://www.xerial.org/home/web/maven.xerial.org/repository/site</url> <url>http://github.com/xerial/snappy-java/</url>
</site> <issueManagement>
<repository> <system>GitHub</system>
<id>xerial.scp</id> <url>http://github.com/xerial/snappy-java/issues/list</url>
<name>Xerial Maven Repository</name> </issueManagement>
<url>scpexe://www.xerial.org/home/web/maven.xerial.org/repository/artifact</url> <inceptionYear>2011</inceptionYear>
</repository> <scm>
<snapshotRepository> <connection>scm:git@github.com:xerial/snappy-java.git</connection>
<id>xerial.scp</id> <developerConnection>scm:git:git@github.com:xerial/snappy-java.git</developerConnection>
<name>Xerial Maven Snapshot Repository</name> <url>git@github.com:xerial/snappy-java.git</url>
<url>scpexe://www.xerial.org/home/web/maven.xerial.org/repository/snapshot</url> </scm>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository> <profiles>
</distributionManagement> <!-- for local updates -->
<profile>
<profiles> <id>xerial.local</id>
<!-- for directly sending artifacts to sourceforge.net repository --> <distributionManagement>
<profile> <repository>
<id>sourceforge</id> <id>xerial.local</id>
<distributionManagement> <name>Xerial Maven Repository</name>
<repository> <url>file:///home/web/maven.xerial.org/repository/artifact</url>
<id>xerial.sourceforge</id> </repository>
<name>Xerial maven repository at sourceforge.jp</name> <snapshotRepository>
<url>scpexe://shell.sourceforge.jp/home/groups/x/xe/xerial/htdocs/maven/release</url> <id>xerial.local</id>
</repository> <name>Xerial Maven Snapshot Repository</name>
</distributionManagement> <url>file:///home/web/maven.xerial.org/repository/snapshot</url>
</profile> <uniqueVersion>false</uniqueVersion>
</snapshotRepository>
<!-- for local updates --> <site>
<profile> <id>xerial.local</id>
<id>xerial.local</id> <url>file:///home/web/maven.xerial.org/repository/site</url>
<distributionManagement> </site>
<repository> </distributionManagement>
<id>xerial.local</id> </profile>
<name>Xerial Maven Repository</name> </profiles>
<url>file:///home/web/maven.xerial.org/repository/artifact</url>
</repository>
<snapshotRepository>
<id>xerial.local</id> <dependencies>
<name>Xerial Maven Snapshot Repository</name> <dependency>
<url>file:///home/web/maven.xerial.org/repository/snapshot</url> <groupId>junit</groupId>
<uniqueVersion>false</uniqueVersion> <artifactId>junit</artifactId>
</snapshotRepository> <version>4.8.2</version>
<site> <type>jar</type>
<id>xerial.local</id> <scope>test</scope>
<url>file:///home/web/maven.xerial.org/repository/site</url> </dependency>
</site>
</distributionManagement> <dependency>
</profile> <groupId>org.codehaus.plexus</groupId>
</profiles> <artifactId>plexus-classworlds</artifactId>
<version>2.4</version>
<type>jar</type>
<scope>test</scope>
<dependencies> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.osgi</groupId>
<artifactId>junit</artifactId> <artifactId>core</artifactId>
<version>4.8.2</version> <version>4.3.0</version>
<type>jar</type> <type>jar</type>
<scope>test</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<dependency> <groupId>org.xerial</groupId>
<groupId>org.codehaus.plexus</groupId> <artifactId>xerial-core</artifactId>
<artifactId>plexus-classworlds</artifactId> <version>1.0.21</version>
<version>2.4</version> <type>jar</type>
<type>jar</type> <scope>test</scope>
<scope>test</scope> </dependency>
</dependency> </dependencies>
<dependency> </project>
<groupId>org.osgi</groupId>
<artifactId>core</artifactId>
<version>4.3.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>xerial-core</artifactId>
<version>1.0.21</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -26,6 +26,7 @@ package org.xerial.snappy;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.ExceptionInInitializerError;
import java.net.URL; import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -33,6 +34,9 @@ import java.util.Properties;
/** /**
* Snappy API for data compression/decompression * Snappy API for data compression/decompression
*
* Note: if the native libraries cannot be loaded, then an ExceptionInInitializerError
* will be thrown at first use of this class.
* *
* @author leo * @author leo
* *
@ -44,7 +48,7 @@ public class Snappy
impl = SnappyLoader.load(); impl = SnappyLoader.load();
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); throw new ExceptionInInitializerError(e);
} }
} }