From 9e0ab427b8356d450312cd89ccc76b96f8247d6c Mon Sep 17 00:00:00 2001 From: Ankit Gupta Date: Fri, 25 Apr 2014 22:39:33 -0700 Subject: [PATCH] Fix bug + formatting --- java/Makefile | 2 +- java/RocksDBSample.java | 20 ++++++++++++++++++++ java/rocksjni/rocksjni.cc | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/java/Makefile b/java/Makefile index 1013d99e5..1a199e1df 100644 --- a/java/Makefile +++ b/java/Makefile @@ -16,7 +16,7 @@ sample: java javac -cp $(ROCKSDB_JAR) RocksDBSample.java @rm -rf /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni_not_found - java -ea -Djava.library.path=. -cp ".:./*" -Xcheck:jni RocksDBSample /tmp/rocksdbjni + java -ea -Djava.library.path=.:../ -cp ".:./*" -Xcheck:jni RocksDBSample /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni_not_found diff --git a/java/RocksDBSample.java b/java/RocksDBSample.java index 741a88422..f8c1c6038 100644 --- a/java/RocksDBSample.java +++ b/java/RocksDBSample.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.ArrayList; import org.rocksdb.*; import org.rocksdb.util.SizeUnit; @@ -219,6 +220,25 @@ public class RocksDBSample { iterator.close(); System.out.println("iterator tests passed."); + + iterator = db.newIterator(); + List keys = new ArrayList(); + for (iterator.seekToLast(); iterator.isValid(); iterator.prev()) { + keys.add(iterator.key()); + } + iterator.close(); + + Map values = db.multiGet(keys); + assert(values.size() == keys.size()); + for(byte[] value1 : values.values()) { + assert(value1 != null); + } + + values = db.multiGet(new ReadOptions(), keys); + assert(values.size() == keys.size()); + for(byte[] value1 : values.values()) { + assert(value1 != null); + } } catch (RocksDBException e) { System.err.println(e); } diff --git a/java/rocksjni/rocksjni.cc b/java/rocksjni/rocksjni.cc index 639c54ade..94c41392d 100644 --- a/java/rocksjni/rocksjni.cc +++ b/java/rocksjni/rocksjni.cc @@ -310,7 +310,7 @@ jobject multi_get_helper(JNIEnv* env, jobject jdb, rocksdb::DB* db, * Method: multiGet * Signature: (JLjava/util/List;I)Ljava/util/List; */ -jobject Java_org_rocksdb_RocksDB_multiGet( +jobject Java_org_rocksdb_RocksDB_multiGet__JLjava_util_List_2I( JNIEnv* env, jobject jdb, jlong jdb_handle, jobject jkey_list, jint jkeys_count) { return multi_get_helper(env, jdb, reinterpret_cast(jdb_handle), @@ -322,7 +322,7 @@ jobject Java_org_rocksdb_RocksDB_multiGet( * Method: multiGet * Signature: (JJLjava/util/List;I)Ljava/util/List; */ -jobject Java_org_rocksdb_RocksDB_multiGet( +jobject Java_org_rocksdb_RocksDB_multiGet__JJLjava_util_List_2I( JNIEnv* env, jobject jdb, jlong jdb_handle, jlong jropt_handle, jobject jkey_list, jint jkeys_count) { return multi_get_helper(env, jdb, reinterpret_cast(jdb_handle),