Fix bug + formatting

This commit is contained in:
Ankit Gupta 2014-04-25 22:39:33 -07:00
parent 3f8b4129ef
commit 9e0ab427b8
3 changed files with 23 additions and 3 deletions

View File

@ -16,7 +16,7 @@ sample: java
javac -cp $(ROCKSDB_JAR) RocksDBSample.java javac -cp $(ROCKSDB_JAR) RocksDBSample.java
@rm -rf /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni
@rm -rf /tmp/rocksdbjni_not_found @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
@rm -rf /tmp/rocksdbjni_not_found @rm -rf /tmp/rocksdbjni_not_found

View File

@ -5,6 +5,7 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.ArrayList; import java.util.ArrayList;
import org.rocksdb.*; import org.rocksdb.*;
import org.rocksdb.util.SizeUnit; import org.rocksdb.util.SizeUnit;
@ -219,6 +220,25 @@ public class RocksDBSample {
iterator.close(); iterator.close();
System.out.println("iterator tests passed."); System.out.println("iterator tests passed.");
iterator = db.newIterator();
List<byte[]> keys = new ArrayList<byte[]>();
for (iterator.seekToLast(); iterator.isValid(); iterator.prev()) {
keys.add(iterator.key());
}
iterator.close();
Map<byte[], byte[]> 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) { } catch (RocksDBException e) {
System.err.println(e); System.err.println(e);
} }

View File

@ -310,7 +310,7 @@ jobject multi_get_helper(JNIEnv* env, jobject jdb, rocksdb::DB* db,
* Method: multiGet * Method: multiGet
* Signature: (JLjava/util/List;I)Ljava/util/List; * 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, JNIEnv* env, jobject jdb, jlong jdb_handle,
jobject jkey_list, jint jkeys_count) { jobject jkey_list, jint jkeys_count) {
return multi_get_helper(env, jdb, reinterpret_cast<rocksdb::DB*>(jdb_handle), return multi_get_helper(env, jdb, reinterpret_cast<rocksdb::DB*>(jdb_handle),
@ -322,7 +322,7 @@ jobject Java_org_rocksdb_RocksDB_multiGet(
* Method: multiGet * Method: multiGet
* Signature: (JJLjava/util/List;I)Ljava/util/List; * 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, JNIEnv* env, jobject jdb, jlong jdb_handle,
jlong jropt_handle, jobject jkey_list, jint jkeys_count) { jlong jropt_handle, jobject jkey_list, jint jkeys_count) {
return multi_get_helper(env, jdb, reinterpret_cast<rocksdb::DB*>(jdb_handle), return multi_get_helper(env, jdb, reinterpret_cast<rocksdb::DB*>(jdb_handle),