Skip to content

Commit 1d284db

Browse files
author
Naveen
committed
Addressing review comments
1 parent 343e98a commit 1d284db

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

Makefile

+14-13
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ unity: unity.cc unity.o
245245
clean:
246246
-rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) build_config.mk unity.cc
247247
-rm -rf ios-x86/* ios-arm/*
248-
-find . -name "*.[od]" -exec rm {} \;
248+
-find . -name "*.[oda]" -exec rm {} \;
249249
-find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;
250250
tags:
251251
ctags * -R
@@ -480,29 +480,30 @@ ROCKSDBJNILIB = librocksdbjni.jnilib
480480
JAVA_INCLUDE = -I/System/Library/Frameworks/JavaVM.framework/Headers/
481481
endif
482482

483-
484-
rocksdbjavastatic:
485-
#build zlib
483+
libz.a:
484+
-rm -rf zlib-1.2.8
486485
curl -O http://zlib.net/zlib-1.2.8.tar.gz
487486
tar xvzf zlib-1.2.8.tar.gz
488487
cd zlib-1.2.8 && CFLAGS='-fPIC' ./configure --static && make
489-
cp zlib-1.2.8/libz.a .
490-
rm -rf zlib-1.2.8.tar.gz zlib-1.2.8
491-
492-
#build bzip
493-
curl -O http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
488+
cp zlib-1.2.8/libz.a .
489+
490+
libbz2.a:
491+
-rm -rf bzip2-1.0.6
492+
curl -O http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
494493
tar xvzf bzip2-1.0.6.tar.gz
495494
cd bzip2-1.0.6 && make CFLAGS='-fPIC -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64'
496495
cp bzip2-1.0.6/libbz2.a .
497-
rm -rf bzip2-1.0.6.tar.gz bzip2-1.0.6
498496

499-
#build snappy
497+
libsnappy.a:
498+
-rm -rf snappy-1.1.1
500499
curl -O https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz
501500
tar xvzf snappy-1.1.1.tar.gz
502-
cd snappy-1.1.1 && ./configure --with-pic --enable-static
501+
cd snappy-1.1.1 && ./configure --with-pic --enable-static
503502
cd snappy-1.1.1 && make
504503
cp snappy-1.1.1/.libs/libsnappy.a .
505-
rm -rf snappy-1.1.1 snappy-1.1.1.tar.gz
504+
505+
506+
rocksdbjavastatic: libz.a libbz2.a libsnappy.a
506507
OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j
507508
cd java;$(MAKE) java;
508509
rm -f ./java/$(ROCKSDBJNILIB)

java/org/rocksdb/NativeLibraryLoader.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import java.io.*;
44

5-
public class NativeLibraryLoader
6-
{
5+
public class NativeLibraryLoader {
76

87
private static String sharedLibraryName = "librocksdbjni.so";
98
private static String tempFilePrefix = "librocksdbjni";
@@ -14,21 +13,22 @@ public class NativeLibraryLoader
1413
private NativeLibraryLoader() {
1514
}
1615

17-
public static void loadLibraryFromJar() throws IOException {
16+
public static void loadLibraryFromJar()
17+
throws IOException {
1818

1919
File temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
2020
temp.deleteOnExit();
2121

2222
if (!temp.exists()) {
23-
throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist.");
23+
throw new RuntimeException("File " + temp.getAbsolutePath() + " does not exist.");
2424
}
2525

2626
byte[] buffer = new byte[1024];
2727
int readBytes;
2828

2929
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(sharedLibraryName);
3030
if (is == null) {
31-
throw new FileNotFoundException(sharedLibraryName + " was not found inside JAR.");
31+
throw new RuntimeException(sharedLibraryName + " was not found inside JAR.");
3232
}
3333

3434
OutputStream os = new FileOutputStream(temp);

java/org/rocksdb/Options.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* native resources will be released as part of the process.
1414
*/
1515
public class Options extends RocksObject {
16-
static{
16+
static {
1717
RocksDB.loadLibrary();
1818
}
1919
static final long DEFAULT_CACHE_SIZE = 8 << 20;

java/org/rocksdb/RocksDB.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
* All methods of this class could potentially throw RocksDBException, which
2020
* indicates sth wrong at the rocksdb library side and the call failed.
2121
*/
22-
public class RocksDB extends RocksObject
23-
{
22+
public class RocksDB extends RocksObject {
2423

2524
public static final int NOT_FOUND = -1;
2625
private static final String[] compressionLibs_ = {
@@ -35,8 +34,7 @@ public class RocksDB extends RocksObject
3534
* Loads the necessary library files.
3635
* Calling this method twice will have no effect.
3736
*/
38-
public static synchronized void loadLibrary()
39-
{
37+
public static synchronized void loadLibrary() {
4038
// loading possibly necessary libraries.
4139
for (String lib : compressionLibs_) {
4240
try {
@@ -45,14 +43,13 @@ public static synchronized void loadLibrary()
4543
// since it may be optional, we ignore its loading failure here.
4644
}
4745
}
48-
4946
try
5047
{
5148
NativeLibraryLoader.loadLibraryFromJar();
5249
}
5350
catch (IOException e)
5451
{
55-
e.printStackTrace();
52+
throw new RuntimeException("Unable to load the RocksDB shared library" + e);
5653
}
5754
}
5855

0 commit comments

Comments
 (0)