Skip to content

Commit

Permalink
Add LevelDb's JNI wrapper
Browse files Browse the repository at this point in the history
Summary: This implement the Java interface by using JNI

Test Plan: compile test

Reviewers: dhruba

Reviewed By: dhruba

Differential Revision: https://reviews.facebook.net/D5925
  • Loading branch information
thawan committed Oct 5, 2012
1 parent fc23714 commit 696b290
Show file tree
Hide file tree
Showing 45 changed files with 5,609 additions and 0 deletions.
13 changes: 13 additions & 0 deletions java/leveldbjni/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*~
*.swp
.idea
.idea/*
*.iml
*.ipr
*.iws
target
.DS_Store
.project
.classpath
.settings
eclipse-classes
42 changes: 42 additions & 0 deletions java/leveldbjni/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# [LevelDBJNI](https://github.com/fusesource/leveldbjni)

## [leveldbjni 1.3][1_3], released 2012-09-24
[1_3]: http://repo.fusesource.com/nexus/content/groups/public/org/fusesource/leveldbjni/leveldbjni/1.3

* Make Util.link work on windows too.
* Expose the CreateHardLinkW windows API call.
* Added Windows LevelDB Support
* Update to hawtjni 1.6.
* Support the db.compactRange method to force compaction of the leveldb files.
* Fixed bug need to get leveldbjni workin on the Zing JVM

## [leveldbjni 1.2][1_2], released 2012-02-27
[1_2]: http://repo.fusesource.com/nexus/content/groups/public/org/fusesource/leveldbjni/leveldbjni/1.2

* Document how to use the memory pools.
* Fixes issue #6 Support using a memory pool to reduce native memory allocation overhead.
* Update leveldb, hawtjni, and leveldb-api versions.
* Store the version in the factory class.
* Added a release guide.

## [leveldbjni 1.1][1_1], released 2011-09-29
[1_1]: http://repo.fusesource.com/nexus/content/groups/public/org/fusesource/leveldbjni/leveldbjni/1.1

* the all module needs at least one java file so that it produces a javadoc and src.zip
* Try to load the native lib when the JniDBFactory class is loaded.
* Fixes issue #1 : Bug on NativeBuffer offset
* Switch the license from CDDL to the New BSD license to match the license used in the leveldb project.
* Add the sonatype snapshot repo since that's where the leveldb-api is at currently.
* Pickup updates in the api module.
* Updating build instructions.
* implement repair and destroy.
* api updated
* Cleaner java package structure. We only need to expose one public class now since we are using the org.iq80.leveldb abstract api.
* Refactored so that the main user API is the abstract API defined in 'org.iq80.leveldb.api' package.

## [leveldbjni 1.0][1_0], released 2011-08-08
[1_0]: http://repo.fusesource.com/nexus/content/groups/public/org/fusesource/leveldbjni/leveldbjni/1.0

* Initial Release
* OS X Intel 32 and 64 bit support
* Linux Intel 32 and 64 bit support
29 changes: 29 additions & 0 deletions java/leveldbjni/leveldb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/build_detect_platform b/build_detect_platform
index 959a7d6..388d225 100755
--- a/build_detect_platform
+++ b/build_detect_platform
@@ -171,9 +171,9 @@ echo "CC=$CC" >> $OUTPUT
echo "CXX=$CXX" >> $OUTPUT
echo "PLATFORM=$PLATFORM" >> $OUTPUT
echo "PLATFORM_LDFLAGS=$PLATFORM_LDFLAGS" >> $OUTPUT
-echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS" >> $OUTPUT
-echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> $OUTPUT
-echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT
+echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS $PLATFORM_SHARED_CFLAGS" >> $OUTPUT
+echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS $PLATFORM_SHARED_CFLAGS" >> $OUTPUT
+echo "PLATFORM_SHARED_CFLAGS=" >> $OUTPUT
echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT
echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT
echo "PLATFORM_SHARED_VERSIONED=$PLATFORM_SHARED_VERSIONED" >> $OUTPUT
diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h
index 74ea8fa..135bbd7 100644
--- a/include/leveldb/slice.h
+++ b/include/leveldb/slice.h
@@ -77,7 +77,6 @@ class Slice {
(memcmp(data_, x.data_, x.size_) == 0));
}

- private:
const char* data_;
size_t size_;

95 changes: 95 additions & 0 deletions java/leveldbjni/leveldbjni-all/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2011, FuseSource Corp. All rights reserved.
http://fusesource.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of FuseSource Corp. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<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>
<parent>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-project</artifactId>
<version>99-master-SNAPSHOT</version>
</parent>

<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-all</artifactId>
<version>99-master-SNAPSHOT</version>

<name>${project.artifactId}</name>
<description>An uber jar which contains all the leveldbjni platform libraries and dependencies</description>

<dependencies>
<dependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-osx</artifactId>
<version>99-master-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-linux32</artifactId>
<version>99-master-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-linux64</artifactId>
<version>99-master-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-win32</artifactId>
<version>99-master-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-win64</artifactId>
<version>99-master-SNAPSHOT</version>
</dependency>

</dependencies>

<build>

<plugins>
<plugin>
<groupId>org.fusesource.mvnplugins</groupId>
<artifactId>maven-uberize-plugin</artifactId>
<version>1.15</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>uberize</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.fusesource.leveldbjni;

public class All {
}
100 changes: 100 additions & 0 deletions java/leveldbjni/leveldbjni-linux32/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2011, FuseSource Corp. All rights reserved.
http://fusesource.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of FuseSource Corp. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<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>
<parent>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-project</artifactId>
<version>99-master-SNAPSHOT</version>
</parent>

<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-linux32</artifactId>
<version>99-master-SNAPSHOT</version>

<name>${project.artifactId}</name>
<description>The leveldbjni linux 32 native libraries</description>

<dependencies>
<dependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni</artifactId>
<version>99-master-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
<testSourceDirectory>${basedir}/../leveldbjni/src/test/java</testSourceDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<classesDirectory>${basedir}/target/generated-sources/hawtjni/lib</classesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.fusesource.hawtjni</groupId>
<artifactId>maven-hawtjni-plugin</artifactId>
<version>${hawtjni-version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<name>leveldbjni</name>
<classified>false</classified>
<nativeSrcDependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni</artifactId>
<version>${project.version}</version>
<classifier>native-src</classifier>
<type>zip</type>
</nativeSrcDependency>
<configureArgs>
<arg>--with-leveldb=${env.LEVELDB_HOME}</arg>
<arg>--with-snappy=${env.SNAPPY_HOME}</arg>
</configureArgs>
</configuration>
</plugin>
</plugins>
</build>

</project>
99 changes: 99 additions & 0 deletions java/leveldbjni/leveldbjni-linux64/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2011, FuseSource Corp. All rights reserved.
http://fusesource.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of FuseSource Corp. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<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>
<parent>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-project</artifactId>
<version>99-master-SNAPSHOT</version>
</parent>

<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni-linux64</artifactId>
<version>99-master-SNAPSHOT</version>

<name>${project.artifactId}</name>
<description>The leveldbjni linux 64 native libraries</description>

<dependencies>
<dependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni</artifactId>
<version>99-master-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
<testSourceDirectory>${basedir}/../leveldbjni/src/test/java</testSourceDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<classesDirectory>${basedir}/target/generated-sources/hawtjni/lib</classesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.fusesource.hawtjni</groupId>
<artifactId>maven-hawtjni-plugin</artifactId>
<version>${hawtjni-version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<name>leveldbjni</name>
<classified>false</classified>
<nativeSrcDependency>
<groupId>org.fusesource.leveldbjni</groupId>
<artifactId>leveldbjni</artifactId>
<version>${project.version}</version>
<classifier>native-src</classifier>
<type>zip</type>
</nativeSrcDependency>
<configureArgs>
<arg>--with-leveldb=${env.LEVELDB_HOME}</arg>
<arg>--with-snappy=${env.SNAPPY_HOME}</arg>
</configureArgs>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 696b290

Please sign in to comment.