Addressing review comments
This commit is contained in:
parent
343e98a7d1
commit
1d284db213
27
Makefile
27
Makefile
@ -245,7 +245,7 @@ unity: unity.cc unity.o
|
|||||||
clean:
|
clean:
|
||||||
-rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) build_config.mk unity.cc
|
-rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) build_config.mk unity.cc
|
||||||
-rm -rf ios-x86/* ios-arm/*
|
-rm -rf ios-x86/* ios-arm/*
|
||||||
-find . -name "*.[od]" -exec rm {} \;
|
-find . -name "*.[oda]" -exec rm {} \;
|
||||||
-find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;
|
-find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;
|
||||||
tags:
|
tags:
|
||||||
ctags * -R
|
ctags * -R
|
||||||
@ -480,29 +480,30 @@ ROCKSDBJNILIB = librocksdbjni.jnilib
|
|||||||
JAVA_INCLUDE = -I/System/Library/Frameworks/JavaVM.framework/Headers/
|
JAVA_INCLUDE = -I/System/Library/Frameworks/JavaVM.framework/Headers/
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
libz.a:
|
||||||
rocksdbjavastatic:
|
-rm -rf zlib-1.2.8
|
||||||
#build zlib
|
|
||||||
curl -O http://zlib.net/zlib-1.2.8.tar.gz
|
curl -O http://zlib.net/zlib-1.2.8.tar.gz
|
||||||
tar xvzf zlib-1.2.8.tar.gz
|
tar xvzf zlib-1.2.8.tar.gz
|
||||||
cd zlib-1.2.8 && CFLAGS='-fPIC' ./configure --static && make
|
cd zlib-1.2.8 && CFLAGS='-fPIC' ./configure --static && make
|
||||||
cp zlib-1.2.8/libz.a .
|
cp zlib-1.2.8/libz.a .
|
||||||
rm -rf zlib-1.2.8.tar.gz zlib-1.2.8
|
|
||||||
|
libbz2.a:
|
||||||
#build bzip
|
-rm -rf bzip2-1.0.6
|
||||||
curl -O http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
|
curl -O http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
|
||||||
tar xvzf bzip2-1.0.6.tar.gz
|
tar xvzf bzip2-1.0.6.tar.gz
|
||||||
cd bzip2-1.0.6 && make CFLAGS='-fPIC -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64'
|
cd bzip2-1.0.6 && make CFLAGS='-fPIC -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64'
|
||||||
cp bzip2-1.0.6/libbz2.a .
|
cp bzip2-1.0.6/libbz2.a .
|
||||||
rm -rf bzip2-1.0.6.tar.gz bzip2-1.0.6
|
|
||||||
|
|
||||||
#build snappy
|
libsnappy.a:
|
||||||
|
-rm -rf snappy-1.1.1
|
||||||
curl -O https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz
|
curl -O https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz
|
||||||
tar xvzf snappy-1.1.1.tar.gz
|
tar xvzf snappy-1.1.1.tar.gz
|
||||||
cd snappy-1.1.1 && ./configure --with-pic --enable-static
|
cd snappy-1.1.1 && ./configure --with-pic --enable-static
|
||||||
cd snappy-1.1.1 && make
|
cd snappy-1.1.1 && make
|
||||||
cp snappy-1.1.1/.libs/libsnappy.a .
|
cp snappy-1.1.1/.libs/libsnappy.a .
|
||||||
rm -rf snappy-1.1.1 snappy-1.1.1.tar.gz
|
|
||||||
|
|
||||||
|
rocksdbjavastatic: libz.a libbz2.a libsnappy.a
|
||||||
OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j
|
OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j
|
||||||
cd java;$(MAKE) java;
|
cd java;$(MAKE) java;
|
||||||
rm -f ./java/$(ROCKSDBJNILIB)
|
rm -f ./java/$(ROCKSDBJNILIB)
|
||||||
|
@ -2,8 +2,7 @@ package org.rocksdb;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class NativeLibraryLoader
|
public class NativeLibraryLoader {
|
||||||
{
|
|
||||||
|
|
||||||
private static String sharedLibraryName = "librocksdbjni.so";
|
private static String sharedLibraryName = "librocksdbjni.so";
|
||||||
private static String tempFilePrefix = "librocksdbjni";
|
private static String tempFilePrefix = "librocksdbjni";
|
||||||
@ -14,13 +13,14 @@ public class NativeLibraryLoader
|
|||||||
private NativeLibraryLoader() {
|
private NativeLibraryLoader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadLibraryFromJar() throws IOException {
|
public static void loadLibraryFromJar()
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
File temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
|
File temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
|
||||||
temp.deleteOnExit();
|
temp.deleteOnExit();
|
||||||
|
|
||||||
if (!temp.exists()) {
|
if (!temp.exists()) {
|
||||||
throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist.");
|
throw new RuntimeException("File " + temp.getAbsolutePath() + " does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
@ -28,7 +28,7 @@ public class NativeLibraryLoader
|
|||||||
|
|
||||||
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(sharedLibraryName);
|
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(sharedLibraryName);
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
throw new FileNotFoundException(sharedLibraryName + " was not found inside JAR.");
|
throw new RuntimeException(sharedLibraryName + " was not found inside JAR.");
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream os = new FileOutputStream(temp);
|
OutputStream os = new FileOutputStream(temp);
|
||||||
|
@ -13,7 +13,7 @@ package org.rocksdb;
|
|||||||
* native resources will be released as part of the process.
|
* native resources will be released as part of the process.
|
||||||
*/
|
*/
|
||||||
public class Options extends RocksObject {
|
public class Options extends RocksObject {
|
||||||
static{
|
static {
|
||||||
RocksDB.loadLibrary();
|
RocksDB.loadLibrary();
|
||||||
}
|
}
|
||||||
static final long DEFAULT_CACHE_SIZE = 8 << 20;
|
static final long DEFAULT_CACHE_SIZE = 8 << 20;
|
||||||
|
@ -19,8 +19,7 @@ import org.rocksdb.NativeLibraryLoader;
|
|||||||
* All methods of this class could potentially throw RocksDBException, which
|
* All methods of this class could potentially throw RocksDBException, which
|
||||||
* indicates sth wrong at the rocksdb library side and the call failed.
|
* indicates sth wrong at the rocksdb library side and the call failed.
|
||||||
*/
|
*/
|
||||||
public class RocksDB extends RocksObject
|
public class RocksDB extends RocksObject {
|
||||||
{
|
|
||||||
|
|
||||||
public static final int NOT_FOUND = -1;
|
public static final int NOT_FOUND = -1;
|
||||||
private static final String[] compressionLibs_ = {
|
private static final String[] compressionLibs_ = {
|
||||||
@ -35,8 +34,7 @@ public class RocksDB extends RocksObject
|
|||||||
* Loads the necessary library files.
|
* Loads the necessary library files.
|
||||||
* Calling this method twice will have no effect.
|
* Calling this method twice will have no effect.
|
||||||
*/
|
*/
|
||||||
public static synchronized void loadLibrary()
|
public static synchronized void loadLibrary() {
|
||||||
{
|
|
||||||
// loading possibly necessary libraries.
|
// loading possibly necessary libraries.
|
||||||
for (String lib : compressionLibs_) {
|
for (String lib : compressionLibs_) {
|
||||||
try {
|
try {
|
||||||
@ -45,14 +43,13 @@ public class RocksDB extends RocksObject
|
|||||||
// since it may be optional, we ignore its loading failure here.
|
// since it may be optional, we ignore its loading failure here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NativeLibraryLoader.loadLibraryFromJar();
|
NativeLibraryLoader.loadLibraryFromJar();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
throw new RuntimeException("Unable to load the RocksDB shared library" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user