[RocksJava] Test-framework integration
This commit is contained in:
parent
04ca7481d2
commit
1fe7a4c62f
@ -32,8 +32,8 @@ NATIVE_JAVA_CLASSES = org.rocksdb.AbstractComparator\
|
||||
org.rocksdb.StringAppendOperator\
|
||||
org.rocksdb.WriteBatch\
|
||||
org.rocksdb.WriteBatch.Handler\
|
||||
org.rocksdb.WriteBatchInternal\
|
||||
org.rocksdb.WriteBatchTest\
|
||||
org.rocksdb.test.WriteBatchInternal\
|
||||
org.rocksdb.test.WriteBatchTest\
|
||||
org.rocksdb.WriteOptions\
|
||||
|
||||
ROCKSDB_MAJOR = $(shell egrep "ROCKSDB_MAJOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3)
|
||||
@ -43,18 +43,51 @@ ROCKSDB_PATCH = $(shell egrep "ROCKSDB_PATCH.[0-9]" ../include/rocksdb/version.h
|
||||
NATIVE_INCLUDE = ./include
|
||||
ARCH := $(shell getconf LONG_BIT)
|
||||
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux$(ARCH).jar
|
||||
|
||||
ifeq ($(PLATFORM), OS_MACOSX)
|
||||
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar
|
||||
endif
|
||||
|
||||
JAVA_TESTS = org.rocksdb.test.AbstractComparatorTest\
|
||||
org.rocksdb.test.BackupableDBTest\
|
||||
org.rocksdb.test.BlockBasedTableConfigTest\
|
||||
org.rocksdb.test.ColumnFamilyOptionsTest\
|
||||
org.rocksdb.test.ColumnFamilyTest\
|
||||
org.rocksdb.test.ComparatorOptionsTest\
|
||||
org.rocksdb.test.ComparatorTest\
|
||||
org.rocksdb.test.DBOptionsTest\
|
||||
org.rocksdb.test.DirectComparatorTest\
|
||||
org.rocksdb.test.FilterTest\
|
||||
org.rocksdb.test.FlushTest\
|
||||
org.rocksdb.test.KeyMayExistTest\
|
||||
org.rocksdb.test.MemTableTest\
|
||||
org.rocksdb.test.MergeTest\
|
||||
org.rocksdb.test.MixedOptionsTest\
|
||||
org.rocksdb.test.OptionsTest\
|
||||
org.rocksdb.test.PlainTableConfigTest\
|
||||
org.rocksdb.test.ReadOnlyTest\
|
||||
org.rocksdb.test.ReadOptionsTest\
|
||||
org.rocksdb.test.RocksIteratorTest\
|
||||
org.rocksdb.test.SnapshotTest\
|
||||
org.rocksdb.test.StatisticsCollectorTest\
|
||||
org.rocksdb.test.WirteBatchHandlerTest\
|
||||
org.rocksdb.test.WriteBatchTest\
|
||||
|
||||
JAVA_TEST_LIBDIR = ./test-libs/
|
||||
JAVA_JUNIT_JAR = $(JAVA_TEST_LIBDIR)junit-4.12-beta-2.jar
|
||||
JAVA_HAMCR_JAR = $(JAVA_TEST_LIBDIR)hamcrest-core-1.3.jar
|
||||
JAVA_MOCKITO_JAR = $(JAVA_TEST_LIBDIR)mockito-all-1.9.5.jar
|
||||
JAVA_CGLIB_JAR = $(JAVA_TEST_LIBDIR)cglib-2.2.2.jar
|
||||
JAVA_ASSERTJ_JAR = $(JAVA_TEST_LIBDIR)assertj-core-1.7.0.jar
|
||||
JAVA_TESTCLASSPATH = $(ROCKSDB_JAR):$(JAVA_JUNIT_JAR):$(JAVA_HAMCR_JAR):$(JAVA_MOCKITO_JAR):$(JAVA_CGLIB_JAR):$(JAVA_ASSERTJ_JAR):.:./*
|
||||
|
||||
clean:
|
||||
-find . -name "*.class" -exec rm {} \;
|
||||
-find . -name "hs*.log" -exec rm {} \;
|
||||
rm -rf javadoc/*
|
||||
rm -rf test-libs/
|
||||
|
||||
javadocs:
|
||||
mkdir -p javadoc; javadoc -d javadoc -sourcepath . -subpackages org
|
||||
mkdir -p javadoc; javadoc -d javadoc -sourcepath . -subpackages org -exclude org.rocksdb.test
|
||||
|
||||
java: javadocs
|
||||
javac org/rocksdb/util/*.java org/rocksdb/*.java
|
||||
@ -76,33 +109,17 @@ column_family_sample: java
|
||||
java -ea -Djava.library.path=.:../ -cp ".:./*" -Xcheck:jni RocksDBColumnFamilySample /tmp/rocksdbjni
|
||||
@rm -rf /tmp/rocksdbjni
|
||||
|
||||
test: java
|
||||
@rm -rf /tmp/rocksdbjni_*
|
||||
javac org/rocksdb/test/*.java
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.WriteBatchTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.BackupableDBTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.BlockBasedTableConfigTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.DBOptionsTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.ColumnFamilyTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.ColumnFamilyOptionsTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.FilterTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.FlushTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.KeyMayExistTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.MemTableTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.MergeTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.MixedOptionsTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.OptionsTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.PlainTableConfigTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.ReadOnlyTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.ReadOptionsTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.RocksIteratorTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.SnapshotTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.StatisticsCollectorTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.ComparatorOptionsTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.ComparatorTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.DirectComparatorTest
|
||||
java -ea -Djava.library.path=.:../ -cp "$(ROCKSDB_JAR):.:./*" org.rocksdb.test.WriteBatchHandlerTest
|
||||
@rm -rf /tmp/rocksdbjni_*
|
||||
resolve_test_deps:
|
||||
mkdir -p "$(JAVA_TEST_LIBDIR)"
|
||||
test -s "$(JAVA_JUNIT_JAR)" || curl -L -o $(JAVA_JUNIT_JAR) http://search.maven.org/remotecontent?filepath=junit/junit/4.12-beta-2/junit-4.12-beta-2.jar
|
||||
test -s "$(JAVA_HAMCR_JAR)" || curl -L -o $(JAVA_HAMCR_JAR) http://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
|
||||
test -s "$(JAVA_MOCKITO_JAR)" || curl -L -o "$(JAVA_MOCKITO_JAR)" http://search.maven.org/remotecontent?filepath=org/mockito/mockito-all/1.9.5/mockito-all-1.9.5.jar
|
||||
test -s "$(JAVA_CGLIB_JAR)" || curl -L -o "$(JAVA_CGLIB_JAR)" http://search.maven.org/remotecontent?filepath=cglib/cglib/2.2.2/cglib-2.2.2.jar
|
||||
test -s "$(JAVA_ASSERTJ_JAR)" || curl -L -o "$(JAVA_ASSERTJ_JAR)" http://central.maven.org/maven2/org/assertj/assertj-core/1.7.0/assertj-core-1.7.0.jar
|
||||
|
||||
test: java resolve_test_deps
|
||||
javac -cp $(JAVA_TESTCLASSPATH) org/rocksdb/test/*.java
|
||||
java -ea -Djava.library.path=.:../ -cp "$(JAVA_TESTCLASSPATH)" org.junit.runner.JUnitCore $(JAVA_TESTS)
|
||||
|
||||
db_bench: java
|
||||
javac org/rocksdb/benchmark/*.java
|
||||
|
@ -30,9 +30,11 @@ public class ColumnFamilyHandle extends RocksObject {
|
||||
* before freeing the native handle.</p>
|
||||
*/
|
||||
@Override protected void disposeInternal() {
|
||||
assert(isInitialized());
|
||||
if (rocksDB_.isInitialized()) {
|
||||
disposeInternal(nativeHandle_);
|
||||
synchronized (rocksDB_) {
|
||||
assert (isInitialized());
|
||||
if (rocksDB_.isInitialized()) {
|
||||
disposeInternal(nativeHandle_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,8 +363,10 @@ public class RocksDB extends RocksObject {
|
||||
}
|
||||
|
||||
@Override protected void disposeInternal() {
|
||||
assert(isInitialized());
|
||||
disposeInternal(nativeHandle_);
|
||||
synchronized (this) {
|
||||
assert (isInitialized());
|
||||
disposeInternal(nativeHandle_);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1150,6 +1152,8 @@ public class RocksDB extends RocksObject {
|
||||
throws RocksDBException, IllegalArgumentException {
|
||||
// throws RocksDBException if something goes wrong
|
||||
dropColumnFamily(nativeHandle_, columnFamilyHandle.nativeHandle_);
|
||||
// After the drop the native handle is not valid anymore
|
||||
columnFamilyHandle.nativeHandle_ = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,9 +143,11 @@ public class RocksIterator extends RocksObject {
|
||||
* before freeing the native handle.</p>
|
||||
*/
|
||||
@Override protected void disposeInternal() {
|
||||
assert(isInitialized());
|
||||
if (rocksDB_.isInitialized()) {
|
||||
disposeInternal(nativeHandle_);
|
||||
synchronized (rocksDB_) {
|
||||
assert (isInitialized());
|
||||
if (rocksDB_.isInitialized()) {
|
||||
disposeInternal(nativeHandle_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,13 +221,3 @@ public class WriteBatch extends RocksObject {
|
||||
private native void disposeInternal(long handle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Package-private class which provides java api to access
|
||||
* c++ WriteBatchInternal.
|
||||
*/
|
||||
class WriteBatchInternal {
|
||||
static native void setSequence(WriteBatch batch, long sn);
|
||||
static native long sequence(WriteBatch batch);
|
||||
static native void append(WriteBatch b1, WriteBatch b2);
|
||||
}
|
||||
|
@ -1,124 +0,0 @@
|
||||
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||
package org.rocksdb;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* This class mimics the db/write_batch_test.cc in the c++ rocksdb library.
|
||||
*/
|
||||
public class WriteBatchTest {
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("Testing WriteBatchTest.Empty ===");
|
||||
Empty();
|
||||
|
||||
System.out.println("Testing WriteBatchTest.Multiple ===");
|
||||
Multiple();
|
||||
|
||||
System.out.println("Testing WriteBatchTest.Append ===");
|
||||
Append();
|
||||
|
||||
System.out.println("Testing WriteBatchTest.Blob ===");
|
||||
Blob();
|
||||
|
||||
// The following tests have not yet ported.
|
||||
// Continue();
|
||||
// PutGatherSlices();
|
||||
|
||||
System.out.println("Passed all WriteBatchTest!");
|
||||
}
|
||||
|
||||
static void Empty() {
|
||||
WriteBatch batch = new WriteBatch();
|
||||
assert(batch.count() == 0);
|
||||
}
|
||||
|
||||
static void Multiple() {
|
||||
try {
|
||||
WriteBatch batch = new WriteBatch();
|
||||
batch.put("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII"));
|
||||
batch.remove("box".getBytes("US-ASCII"));
|
||||
batch.put("baz".getBytes("US-ASCII"), "boo".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.setSequence(batch, 100);
|
||||
assert(100 == WriteBatchInternal.sequence(batch));
|
||||
assert(3 == batch.count());
|
||||
assert(("Put(baz, boo)@102" +
|
||||
"Delete(box)@101" +
|
||||
"Put(foo, bar)@100")
|
||||
.equals(new String(getContents(batch), "US-ASCII")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.err.println(e);
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void Append() {
|
||||
WriteBatch b1 = new WriteBatch();
|
||||
WriteBatch b2 = new WriteBatch();
|
||||
WriteBatchInternal.setSequence(b1, 200);
|
||||
WriteBatchInternal.setSequence(b2, 300);
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assert(getContents(b1).length == 0);
|
||||
assert(b1.count() == 0);
|
||||
try {
|
||||
b2.put("a".getBytes("US-ASCII"), "va".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assert("Put(a, va)@200".equals(new String(getContents(b1), "US-ASCII")));
|
||||
assert(1 == b1.count());
|
||||
b2.clear();
|
||||
b2.put("b".getBytes("US-ASCII"), "vb".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assert(("Put(a, va)@200" +
|
||||
"Put(b, vb)@201")
|
||||
.equals(new String(getContents(b1), "US-ASCII")));
|
||||
assert(2 == b1.count());
|
||||
b2.remove("foo".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assert(("Put(a, va)@200" +
|
||||
"Put(b, vb)@202" +
|
||||
"Put(b, vb)@201" +
|
||||
"Delete(foo)@203")
|
||||
.equals(new String(getContents(b1), "US-ASCII")));
|
||||
assert(4 == b1.count());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.err.println(e);
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void Blob() {
|
||||
WriteBatch batch = new WriteBatch();
|
||||
try {
|
||||
batch.put("k1".getBytes("US-ASCII"), "v1".getBytes("US-ASCII"));
|
||||
batch.put("k2".getBytes("US-ASCII"), "v2".getBytes("US-ASCII"));
|
||||
batch.put("k3".getBytes("US-ASCII"), "v3".getBytes("US-ASCII"));
|
||||
batch.putLogData("blob1".getBytes("US-ASCII"));
|
||||
batch.remove("k2".getBytes("US-ASCII"));
|
||||
batch.putLogData("blob2".getBytes("US-ASCII"));
|
||||
batch.merge("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII"));
|
||||
assert(5 == batch.count());
|
||||
assert(("Merge(foo, bar)@4" +
|
||||
"Put(k1, v1)@0" +
|
||||
"Delete(k2)@3" +
|
||||
"Put(k2, v2)@1" +
|
||||
"Put(k3, v3)@2")
|
||||
.equals(new String(getContents(batch), "US-ASCII")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.err.println(e);
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static native byte[] getContents(WriteBatch batch);
|
||||
}
|
@ -5,28 +5,41 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BackupableDBTest {
|
||||
static final String db_path = "/tmp/rocksdbjni_backupable_db_test";
|
||||
static final String backup_path = "/tmp/rocksdbjni_backupable_db_backup_test";
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder backupFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void shouldTestBackupableDb() {
|
||||
|
||||
Options opt = new Options();
|
||||
opt.setCreateIfMissing(true);
|
||||
|
||||
BackupableDBOptions bopt = new BackupableDBOptions(backup_path, false,
|
||||
BackupableDBOptions bopt = new BackupableDBOptions(
|
||||
backupFolder.getRoot().getAbsolutePath(), false,
|
||||
true, false, true, 0, 0);
|
||||
BackupableDB bdb = null;
|
||||
List<BackupInfo> backupInfos;
|
||||
List<BackupInfo> restoreInfos;
|
||||
try {
|
||||
bdb = BackupableDB.open(opt, bopt, db_path);
|
||||
bdb = BackupableDB.open(opt, bopt,
|
||||
dbFolder.getRoot().getAbsolutePath());
|
||||
|
||||
bdb.put("abc".getBytes(), "def".getBytes());
|
||||
bdb.put("ghi".getBytes(), "jkl".getBytes());
|
||||
@ -74,7 +87,9 @@ public class BackupableDBTest {
|
||||
assert(restoreInfos.get(0).numberFiles() ==
|
||||
backupInfos.get(0).numberFiles());
|
||||
|
||||
rdb.restoreDBFromLatestBackup(db_path, db_path,
|
||||
rdb.restoreDBFromLatestBackup(
|
||||
dbFolder.getRoot().getAbsolutePath(),
|
||||
dbFolder.getRoot().getAbsolutePath(),
|
||||
ropt);
|
||||
// do nothing because there is only one backup
|
||||
rdb.purgeOldBackups(1);
|
||||
@ -84,7 +99,8 @@ public class BackupableDBTest {
|
||||
ropt.dispose();
|
||||
|
||||
// verify that backed up data contains deleted record
|
||||
bdb = BackupableDB.open(opt, bopt, db_path);
|
||||
bdb = BackupableDB.open(opt, bopt,
|
||||
dbFolder.getRoot().getAbsolutePath());
|
||||
value = bdb.get("abc".getBytes());
|
||||
assert(new String(value).equals("def"));
|
||||
|
||||
@ -110,7 +126,6 @@ public class BackupableDBTest {
|
||||
assert(backupInfos.size() == 2);
|
||||
assert(backupInfos.get(0).backupId() == 4);
|
||||
assert(backupInfos.get(1).backupId() == 5);
|
||||
System.out.println("Backup and restore test passed");
|
||||
} catch (RocksDBException e) {
|
||||
System.err.format("[ERROR]: %s%n", e);
|
||||
e.printStackTrace();
|
||||
@ -121,5 +136,6 @@ public class BackupableDBTest {
|
||||
bdb.close();
|
||||
}
|
||||
}
|
||||
System.out.println("Passed BackupableDBTest.");
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,19 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.BlockBasedTableConfig;
|
||||
import org.rocksdb.ChecksumType;
|
||||
import org.rocksdb.IndexType;
|
||||
|
||||
public class BlockBasedTableConfigTest {
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
public static void main(String[] args) {
|
||||
@Test
|
||||
public void shouldTestBlockBasedTableConfig() {
|
||||
BlockBasedTableConfig blockBasedTableConfig =
|
||||
new BlockBasedTableConfig();
|
||||
blockBasedTableConfig.setNoBlockCache(true);
|
||||
@ -42,6 +48,6 @@ public class BlockBasedTableConfigTest {
|
||||
== 4);
|
||||
blockBasedTableConfig.setCacheNumShardBits(5);
|
||||
assert(blockBasedTableConfig.cacheNumShardBits() == 5);
|
||||
System.out.println("BlockBasedTableConfig test passed");
|
||||
System.out.println("Passed BlockBasedTableConfigTest.");
|
||||
}
|
||||
}
|
||||
|
@ -9,16 +9,25 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
public class ColumnFamilyTest {
|
||||
static final String db_path = "/tmp/rocksdbjni_columnfamily_test";
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void shouldTestColumnFamilies() {
|
||||
String db_path = dbFolder.getRoot().getAbsolutePath();
|
||||
RocksDB db = null;
|
||||
Options options = new Options();
|
||||
options.setCreateIfMissing(true);
|
||||
@ -274,7 +283,6 @@ public class ColumnFamilyTest {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
System.out.println("Passed ColumnFamilyTest");
|
||||
// free cf handles before database close
|
||||
for (ColumnFamilyHandle columnFamilyHandle : columnFamilyHandleList) {
|
||||
columnFamilyHandle.dispose();
|
||||
@ -283,5 +291,6 @@ public class ColumnFamilyTest {
|
||||
db.close();
|
||||
// be sure to dispose c++ pointers
|
||||
options.dispose();
|
||||
System.out.println("Passed ColumnFamilyTest.");
|
||||
}
|
||||
}
|
||||
|
@ -5,27 +5,30 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.ComparatorOptions;
|
||||
import org.rocksdb.RocksDB;
|
||||
|
||||
import java.util.Random;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ComparatorOptionsTest {
|
||||
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
public static void main(String[] args) {
|
||||
@Test
|
||||
public void shouldTestComparatorOptions() {
|
||||
final ComparatorOptions copt = new ComparatorOptions();
|
||||
Random rand = new Random();
|
||||
|
||||
assertThat(copt).isNotNull();
|
||||
|
||||
{ // UseAdaptiveMutex test
|
||||
copt.setUseAdaptiveMutex(true);
|
||||
assert(copt.useAdaptiveMutex() == true);
|
||||
assertThat(copt.useAdaptiveMutex()).isTrue();
|
||||
|
||||
copt.setUseAdaptiveMutex(false);
|
||||
assert(copt.useAdaptiveMutex() == false);
|
||||
assertThat(copt.useAdaptiveMutex()).isFalse();
|
||||
}
|
||||
|
||||
copt.dispose();
|
||||
|
@ -5,19 +5,26 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
|
||||
public class ComparatorTest {
|
||||
private static final String db_path = "/tmp/comparator_db";
|
||||
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void shouldTestComparator() throws IOException {
|
||||
|
||||
final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() {
|
||||
@Override
|
||||
@ -38,7 +45,8 @@ public class ComparatorTest {
|
||||
};
|
||||
|
||||
// test the round-tripability of keys written and read with the Comparator
|
||||
comparatorTest.testRoundtrip(FileSystems.getDefault().getPath(db_path));
|
||||
comparatorTest.testRoundtrip(FileSystems.getDefault().getPath(
|
||||
dbFolder.getRoot().getAbsolutePath()));
|
||||
|
||||
System.out.println("Passed ComparatorTest");
|
||||
}
|
||||
|
@ -5,19 +5,25 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
|
||||
public class DirectComparatorTest {
|
||||
private static final String db_path = "/tmp/direct_comparator_db";
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
@Test
|
||||
public void shouldTestDirectComparator() throws IOException {
|
||||
|
||||
final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() {
|
||||
@Override
|
||||
@ -41,7 +47,8 @@ public class DirectComparatorTest {
|
||||
};
|
||||
|
||||
// test the round-tripability of keys written and read with the DirectComparator
|
||||
comparatorTest.testRoundtrip(FileSystems.getDefault().getPath(db_path));
|
||||
comparatorTest.testRoundtrip(FileSystems.getDefault().getPath(
|
||||
dbFolder.getRoot().getAbsolutePath()));
|
||||
|
||||
System.out.println("Passed DirectComparatorTest");
|
||||
}
|
||||
|
@ -5,13 +5,18 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.*;
|
||||
|
||||
public class FilterTest {
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Test
|
||||
public void shouldTestFilter() {
|
||||
Options options = new Options();
|
||||
// test table config
|
||||
BlockBasedTableConfig blockConfig = new BlockBasedTableConfig();
|
||||
@ -37,6 +42,6 @@ public class FilterTest {
|
||||
blockConfig = null;
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
System.out.println("Filter test passed");
|
||||
System.out.println("Passed FilterTest.");
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,18 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.*;
|
||||
|
||||
public class MemTableTest {
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Test
|
||||
public void shouldTestMemTable() throws RocksDBException {
|
||||
Options options = new Options();
|
||||
// Test HashSkipListMemTableConfig
|
||||
HashSkipListMemTableConfig memTableConfig =
|
||||
@ -25,11 +30,7 @@ public class MemTableTest {
|
||||
assert(memTableConfig.branchingFactor() == 4);
|
||||
memTableConfig.setBranchingFactor(6);
|
||||
assert(memTableConfig.branchingFactor() == 6);
|
||||
try {
|
||||
options.setMemTableConfig(memTableConfig);
|
||||
} catch (RocksDBException e) {
|
||||
assert(false);
|
||||
}
|
||||
options.setMemTableConfig(memTableConfig);
|
||||
memTableConfig = null;
|
||||
options.dispose();
|
||||
System.gc();
|
||||
@ -41,11 +42,7 @@ public class MemTableTest {
|
||||
assert(skipMemTableConfig.lookahead() == 0);
|
||||
skipMemTableConfig.setLookahead(20);
|
||||
assert(skipMemTableConfig.lookahead() == 20);
|
||||
try {
|
||||
options.setMemTableConfig(skipMemTableConfig);
|
||||
} catch (RocksDBException e) {
|
||||
assert(false);
|
||||
}
|
||||
options.setMemTableConfig(skipMemTableConfig);
|
||||
skipMemTableConfig = null;
|
||||
options.dispose();
|
||||
System.gc();
|
||||
@ -67,21 +64,17 @@ public class MemTableTest {
|
||||
assert(hashLinkedListMemTableConfig.
|
||||
bucketEntriesLoggingThreshold() == 200);
|
||||
assert(hashLinkedListMemTableConfig.
|
||||
ifLogBucketDistWhenFlush() == true);
|
||||
ifLogBucketDistWhenFlush());
|
||||
hashLinkedListMemTableConfig.
|
||||
setIfLogBucketDistWhenFlush(false);
|
||||
assert(hashLinkedListMemTableConfig.
|
||||
ifLogBucketDistWhenFlush() == false);
|
||||
assert(!hashLinkedListMemTableConfig.
|
||||
ifLogBucketDistWhenFlush());
|
||||
assert(hashLinkedListMemTableConfig.
|
||||
thresholdUseSkiplist() == 256);
|
||||
hashLinkedListMemTableConfig.setThresholdUseSkiplist(29);
|
||||
assert(hashLinkedListMemTableConfig.
|
||||
thresholdUseSkiplist() == 29);
|
||||
try {
|
||||
options.setMemTableConfig(hashLinkedListMemTableConfig);
|
||||
} catch (RocksDBException e) {
|
||||
assert(false);
|
||||
}
|
||||
options.setMemTableConfig(hashLinkedListMemTableConfig);
|
||||
hashLinkedListMemTableConfig = null;
|
||||
options.dispose();
|
||||
System.gc();
|
||||
@ -93,15 +86,11 @@ public class MemTableTest {
|
||||
assert(vectorMemTableConfig.reservedSize() == 0);
|
||||
vectorMemTableConfig.setReservedSize(123);
|
||||
assert(vectorMemTableConfig.reservedSize() == 123);
|
||||
try {
|
||||
options.setMemTableConfig(vectorMemTableConfig);
|
||||
} catch (RocksDBException e) {
|
||||
assert(false);
|
||||
}
|
||||
options.setMemTableConfig(vectorMemTableConfig);
|
||||
vectorMemTableConfig = null;
|
||||
options.dispose();
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
System.out.println("Mem-table test passed");
|
||||
System.out.println("Passed MemTableTest.");
|
||||
}
|
||||
}
|
||||
|
@ -7,19 +7,33 @@ package org.rocksdb.test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
public class MergeTest {
|
||||
static final String db_path_string = "/tmp/rocksdbjni_mergestring_db";
|
||||
static final String db_cf_path_string = "/tmp/rocksdbjni_mergecfstring_db";
|
||||
static final String db_path_operator = "/tmp/rocksdbjni_mergeoperator_db";
|
||||
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@AfterClass
|
||||
public static void printMergePass(){
|
||||
System.out.println("Passed MergeTest.");
|
||||
}
|
||||
|
||||
public static void testStringOption()
|
||||
@Test
|
||||
public void shouldTestStringOption()
|
||||
throws InterruptedException, RocksDBException {
|
||||
String db_path_string =
|
||||
dbFolder.getRoot().getAbsolutePath();
|
||||
Options opt = new Options();
|
||||
opt.setCreateIfMissing(true);
|
||||
opt.setMergeOperatorName("stringappend");
|
||||
@ -38,23 +52,26 @@ public class MergeTest {
|
||||
assert(strValue.equals("aa,bb"));
|
||||
}
|
||||
|
||||
public static void testCFStringOption()
|
||||
@Test
|
||||
public void shouldTestCFStringOption()
|
||||
throws InterruptedException, RocksDBException {
|
||||
DBOptions opt = new DBOptions();
|
||||
String db_path_string =
|
||||
dbFolder.getRoot().getAbsolutePath();
|
||||
opt.setCreateIfMissing(true);
|
||||
opt.setCreateMissingColumnFamilies(true);
|
||||
|
||||
List<ColumnFamilyDescriptor> cfDescr =
|
||||
new ArrayList<ColumnFamilyDescriptor>();
|
||||
new ArrayList<>();
|
||||
List<ColumnFamilyHandle> columnFamilyHandleList =
|
||||
new ArrayList<ColumnFamilyHandle>();
|
||||
new ArrayList<>();
|
||||
cfDescr.add(new ColumnFamilyDescriptor("default",
|
||||
new ColumnFamilyOptions().setMergeOperatorName(
|
||||
"stringappend")));
|
||||
cfDescr.add(new ColumnFamilyDescriptor("default",
|
||||
new ColumnFamilyOptions().setMergeOperatorName(
|
||||
"stringappend")));
|
||||
RocksDB db = RocksDB.open(opt, db_cf_path_string,
|
||||
RocksDB db = RocksDB.open(opt, db_path_string,
|
||||
cfDescr, columnFamilyHandleList);
|
||||
|
||||
// writing aa under key
|
||||
@ -75,8 +92,11 @@ public class MergeTest {
|
||||
assert(strValue.equals("aa,bb"));
|
||||
}
|
||||
|
||||
public static void testOperatorOption()
|
||||
@Test
|
||||
public void shouldTestOperatorOption()
|
||||
throws InterruptedException, RocksDBException {
|
||||
String db_path_string =
|
||||
dbFolder.getRoot().getAbsolutePath();
|
||||
Options opt = new Options();
|
||||
opt.setCreateIfMissing(true);
|
||||
|
||||
@ -98,26 +118,29 @@ public class MergeTest {
|
||||
assert(strValue.equals("aa,bb"));
|
||||
}
|
||||
|
||||
public static void testCFOperatorOption()
|
||||
@Test
|
||||
public void shouldTestCFOperatorOption()
|
||||
throws InterruptedException, RocksDBException {
|
||||
DBOptions opt = new DBOptions();
|
||||
String db_path_string =
|
||||
dbFolder.getRoot().getAbsolutePath();
|
||||
|
||||
opt.setCreateIfMissing(true);
|
||||
opt.setCreateMissingColumnFamilies(true);
|
||||
StringAppendOperator stringAppendOperator = new StringAppendOperator();
|
||||
|
||||
List<ColumnFamilyDescriptor> cfDescr =
|
||||
new ArrayList<ColumnFamilyDescriptor>();
|
||||
new ArrayList<>();
|
||||
List<ColumnFamilyHandle> columnFamilyHandleList =
|
||||
new ArrayList<ColumnFamilyHandle>();
|
||||
new ArrayList<>();
|
||||
cfDescr.add(new ColumnFamilyDescriptor("default",
|
||||
new ColumnFamilyOptions().setMergeOperator(
|
||||
stringAppendOperator)));
|
||||
cfDescr.add(new ColumnFamilyDescriptor("new_cf",
|
||||
new ColumnFamilyOptions().setMergeOperator(
|
||||
stringAppendOperator)));
|
||||
RocksDB db = RocksDB.open(opt, db_path_operator,
|
||||
RocksDB db = RocksDB.open(opt, db_path_string,
|
||||
cfDescr, columnFamilyHandleList);
|
||||
|
||||
// writing aa under key
|
||||
db.put(columnFamilyHandleList.get(1),
|
||||
"cfkey".getBytes(), "aa".getBytes());
|
||||
@ -139,14 +162,18 @@ public class MergeTest {
|
||||
value = db.get(columnFamilyHandle, "cfkey2".getBytes());
|
||||
String strValueTmpCf = new String(value);
|
||||
|
||||
columnFamilyHandle.dispose();
|
||||
db.close();
|
||||
opt.dispose();
|
||||
assert(strValue.equals("aa,bb"));
|
||||
assert(strValueTmpCf.equals("xx,yy"));
|
||||
}
|
||||
|
||||
public static void testOperatorGcBehaviour()
|
||||
@Test
|
||||
public void shouldTestOperatorGcBehaviour()
|
||||
throws RocksDBException {
|
||||
String db_path_string =
|
||||
dbFolder.getRoot().getAbsolutePath();
|
||||
Options opt = new Options();
|
||||
opt.setCreateIfMissing(true);
|
||||
StringAppendOperator stringAppendOperator = new StringAppendOperator();
|
||||
@ -185,14 +212,4 @@ public class MergeTest {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
throws InterruptedException, RocksDBException {
|
||||
testStringOption();
|
||||
testCFStringOption();
|
||||
testOperatorOption();
|
||||
testCFOperatorOption();
|
||||
testOperatorGcBehaviour();
|
||||
System.out.println("Passed MergeTest.");
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,19 @@
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.EncodingType;
|
||||
import org.rocksdb.PlainTableConfig;
|
||||
|
||||
public class PlainTableConfigTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Test
|
||||
public void shouldTestPlainTableConfig() {
|
||||
PlainTableConfig plainTableConfig = new PlainTableConfig();
|
||||
plainTableConfig.setKeySize(5);
|
||||
assert(plainTableConfig.keySize() == 5);
|
||||
@ -29,6 +36,6 @@ public class PlainTableConfigTest {
|
||||
assert(plainTableConfig.fullScanMode());
|
||||
plainTableConfig.setStoreIndexInFile(true);
|
||||
assert(plainTableConfig.storeIndexInFile());
|
||||
System.out.println("PlainTableConfig test passed");
|
||||
System.out.println("Passed PlainTableConfigTest.");
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ public class PlatformRandomHelper {
|
||||
* @return boolean value indicating if operating system is 64 Bit.
|
||||
*/
|
||||
public static boolean isOs64Bit(){
|
||||
boolean is64Bit = false;
|
||||
boolean is64Bit;
|
||||
if (System.getProperty("os.name").contains("Windows")) {
|
||||
is64Bit = (System.getenv("ProgramFiles(x86)") != null);
|
||||
} else {
|
||||
is64Bit = (System.getProperty("os.arch").indexOf("64") != -1);
|
||||
is64Bit = (System.getProperty("os.arch").contains("64"));
|
||||
}
|
||||
return is64Bit;
|
||||
}
|
||||
|
@ -4,31 +4,41 @@
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReadOnlyTest {
|
||||
static final String DB_PATH = "/tmp/rocksdbjni_readonly_test";
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void shouldTestReadOnlyOpen() {
|
||||
RocksDB db = null, db2 = null, db3 = null;
|
||||
List<ColumnFamilyHandle> columnFamilyHandleList =
|
||||
new ArrayList<ColumnFamilyHandle>();
|
||||
new ArrayList<>();
|
||||
List<ColumnFamilyHandle> db2ColumnFamilyHandleList =
|
||||
new ArrayList<ColumnFamilyHandle>();
|
||||
new ArrayList<>();
|
||||
List<ColumnFamilyHandle> db3ColumnFamilyHandleList =
|
||||
new ArrayList<ColumnFamilyHandle>();
|
||||
new ArrayList<>();
|
||||
Options options = new Options();
|
||||
options.setCreateIfMissing(true);
|
||||
try {
|
||||
db = RocksDB.open(options, DB_PATH);
|
||||
db = RocksDB.open(options,
|
||||
dbFolder.getRoot().getAbsolutePath());
|
||||
db.put("key".getBytes(), "value".getBytes());
|
||||
db2 = RocksDB.openReadOnly(DB_PATH);
|
||||
db2 = RocksDB.openReadOnly(
|
||||
dbFolder.getRoot().getAbsolutePath());
|
||||
assert("value".equals(new String(db2.get("key".getBytes()))));
|
||||
db.close();
|
||||
db2.close();
|
||||
@ -38,7 +48,7 @@ public class ReadOnlyTest {
|
||||
new ArrayList<ColumnFamilyDescriptor>();
|
||||
cfNames.add(new ColumnFamilyDescriptor("default"));
|
||||
|
||||
db = RocksDB.open(DB_PATH, cfNames, columnFamilyHandleList);
|
||||
db = RocksDB.open(dbFolder.getRoot().getAbsolutePath(), cfNames, columnFamilyHandleList);
|
||||
columnFamilyHandleList.add(db.createColumnFamily(
|
||||
new ColumnFamilyDescriptor("new_cf", new ColumnFamilyOptions())));
|
||||
columnFamilyHandleList.add(db.createColumnFamily(
|
||||
@ -46,15 +56,16 @@ public class ReadOnlyTest {
|
||||
db.put(columnFamilyHandleList.get(2), "key2".getBytes(),
|
||||
"value2".getBytes());
|
||||
|
||||
db2 = RocksDB.openReadOnly(DB_PATH, cfNames, db2ColumnFamilyHandleList);
|
||||
db2 = RocksDB.openReadOnly(
|
||||
dbFolder.getRoot().getAbsolutePath(), cfNames, db2ColumnFamilyHandleList);
|
||||
assert(db2.get("key2".getBytes())==null);
|
||||
assert(db2.get(columnFamilyHandleList.get(0), "key2".getBytes())==null);
|
||||
|
||||
List<ColumnFamilyDescriptor> cfNewName =
|
||||
new ArrayList<ColumnFamilyDescriptor>();
|
||||
new ArrayList<>();
|
||||
cfNewName.add(new ColumnFamilyDescriptor("default"));
|
||||
cfNewName.add(new ColumnFamilyDescriptor("new_cf2"));
|
||||
db3 = RocksDB.openReadOnly(DB_PATH, cfNewName, db3ColumnFamilyHandleList);
|
||||
db3 = RocksDB.openReadOnly(dbFolder.getRoot().getAbsolutePath(), cfNewName, db3ColumnFamilyHandleList);
|
||||
assert(new String(db3.get(db3ColumnFamilyHandleList.get(1),
|
||||
"key2".getBytes())).equals("value2"));
|
||||
}catch (RocksDBException e){
|
||||
@ -125,6 +136,6 @@ public class ReadOnlyTest {
|
||||
columnFamilyHandle.dispose();
|
||||
}
|
||||
db3.close();
|
||||
System.out.println("Passed ReadOnlyTest");
|
||||
System.out.println("Passed ReadOnlyTest.");
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,20 @@
|
||||
package org.rocksdb.test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.RocksDB;
|
||||
import org.rocksdb.ReadOptions;
|
||||
|
||||
public class ReadOptionsTest {
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Test
|
||||
public void shouldTestReadOptions() {
|
||||
ReadOptions opt = new ReadOptions();
|
||||
Random rand = new Random();
|
||||
{ // VerifyChecksums test
|
||||
@ -33,8 +39,7 @@ public class ReadOptionsTest {
|
||||
opt.setTailing(boolValue);
|
||||
assert(opt.tailing() == boolValue);
|
||||
}
|
||||
|
||||
opt.dispose();
|
||||
System.out.println("Passed ReadOptionsTest");
|
||||
System.out.println("Passed ReadOptionsTest.");
|
||||
}
|
||||
}
|
||||
|
@ -4,45 +4,46 @@
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.rocksdb.ColumnFamilyHandle;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.Options;
|
||||
import org.rocksdb.RocksDB;
|
||||
import org.rocksdb.RocksDBException;
|
||||
import org.rocksdb.RocksIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RocksIteratorTest {
|
||||
static final String DB_PATH = "/tmp/rocksdbjni_iterator_test";
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void shouldTestRocksIteratorGc()
|
||||
throws RocksDBException {
|
||||
RocksDB db;
|
||||
Options options = new Options();
|
||||
options.setCreateIfMissing(true)
|
||||
.setCreateMissingColumnFamilies(true);
|
||||
try {
|
||||
db = RocksDB.open(options, DB_PATH);
|
||||
db.put("key".getBytes(), "value".getBytes());
|
||||
RocksIterator iter = db.newIterator();
|
||||
RocksIterator iter2 = db.newIterator();
|
||||
RocksIterator iter3 = db.newIterator();
|
||||
iter = null;
|
||||
db.close();
|
||||
db = null;
|
||||
iter2 = null;
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
System.out.println("Passed RocksIterator Test");
|
||||
iter3.dispose();
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}catch (RocksDBException e){
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
db = RocksDB.open(options,
|
||||
dbFolder.getRoot().getAbsolutePath());
|
||||
db.put("key".getBytes(), "value".getBytes());
|
||||
RocksIterator iter = db.newIterator();
|
||||
RocksIterator iter2 = db.newIterator();
|
||||
RocksIterator iter3 = db.newIterator();
|
||||
iter = null;
|
||||
db.close();
|
||||
db = null;
|
||||
iter2 = null;
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
iter3.dispose();
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
System.out.println("Passed RocksIteratorTest.");
|
||||
}
|
||||
}
|
||||
|
21
java/org/rocksdb/test/RocksMemoryResource.java
Normal file
21
java/org/rocksdb/test/RocksMemoryResource.java
Normal file
@ -0,0 +1,21 @@
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.rules.ExternalResource;
|
||||
import org.rocksdb.RocksDB;
|
||||
|
||||
/**
|
||||
* Resource to trigger garbage collection after each test
|
||||
* run.
|
||||
*/
|
||||
public class RocksMemoryResource extends ExternalResource {
|
||||
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void after() {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
}
|
@ -4,84 +4,79 @@
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
package org.rocksdb.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.rocksdb.ColumnFamilyHandle;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.Options;
|
||||
import org.rocksdb.ReadOptions;
|
||||
import org.rocksdb.RocksDB;
|
||||
import org.rocksdb.RocksDBException;
|
||||
import org.rocksdb.Snapshot;
|
||||
import org.rocksdb.WriteBatch;
|
||||
import org.rocksdb.WriteOptions;
|
||||
|
||||
public class SnapshotTest {
|
||||
|
||||
public class SnapshotTest
|
||||
{
|
||||
static final String DB_PATH = "/tmp/rocksdbjni_snapshot_test";
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
public static void main(String[] args){
|
||||
RocksDB db = null;
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void shouldTestSnapshots() throws RocksDBException {
|
||||
RocksDB db;
|
||||
Options options = new Options();
|
||||
options.setCreateIfMissing(true);
|
||||
try {
|
||||
db = RocksDB.open(options, DB_PATH);
|
||||
db.put("key".getBytes(), "value".getBytes());
|
||||
// Get new Snapshot of database
|
||||
Snapshot snapshot = db.getSnapshot();
|
||||
ReadOptions readOptions = new ReadOptions();
|
||||
// set snapshot in ReadOptions
|
||||
readOptions.setSnapshot(snapshot);
|
||||
// retrieve key value pair
|
||||
assert(new String(db.get("key".getBytes()))
|
||||
.equals("value"));
|
||||
// retrieve key value pair created before
|
||||
// the snapshot was made
|
||||
assert(new String(db.get(readOptions,
|
||||
"key".getBytes())).equals("value"));
|
||||
// add new key/value pair
|
||||
db.put("newkey".getBytes(), "newvalue".getBytes());
|
||||
// using no snapshot the latest db entries
|
||||
// will be taken into account
|
||||
assert(new String(db.get("newkey".getBytes()))
|
||||
.equals("newvalue"));
|
||||
// snapshopot was created before newkey
|
||||
assert(db.get(readOptions, "newkey".getBytes())
|
||||
== null);
|
||||
// Retrieve snapshot from read options
|
||||
Snapshot sameSnapshot = readOptions.snapshot();
|
||||
readOptions.setSnapshot(sameSnapshot);
|
||||
// results must be the same with new Snapshot
|
||||
// instance using the same native pointer
|
||||
assert(new String(db.get(readOptions,
|
||||
"key".getBytes())).equals("value"));
|
||||
// update key value pair to newvalue
|
||||
db.put("key".getBytes(), "newvalue".getBytes());
|
||||
// read with previously created snapshot will
|
||||
// read previous version of key value pair
|
||||
assert(new String(db.get(readOptions,
|
||||
"key".getBytes())).equals("value"));
|
||||
// read for newkey using the snapshot must be
|
||||
// null
|
||||
assert(db.get(readOptions, "newkey".getBytes())
|
||||
== null);
|
||||
// setting null to snapshot in ReadOptions leads
|
||||
// to no Snapshot being used.
|
||||
readOptions.setSnapshot(null);
|
||||
assert(new String(db.get(readOptions,
|
||||
"newkey".getBytes())).equals("newvalue"));
|
||||
// release Snapshot
|
||||
db.releaseSnapshot(snapshot);
|
||||
// Close database
|
||||
db.close();
|
||||
}catch (RocksDBException e){
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
System.out.println("Passed SnapshotTest");
|
||||
|
||||
db = RocksDB.open(options, dbFolder.getRoot().getAbsolutePath());
|
||||
db.put("key".getBytes(), "value".getBytes());
|
||||
// Get new Snapshot of database
|
||||
Snapshot snapshot = db.getSnapshot();
|
||||
ReadOptions readOptions = new ReadOptions();
|
||||
// set snapshot in ReadOptions
|
||||
readOptions.setSnapshot(snapshot);
|
||||
// retrieve key value pair
|
||||
assert(new String(db.get("key".getBytes()))
|
||||
.equals("value"));
|
||||
// retrieve key value pair created before
|
||||
// the snapshot was made
|
||||
assert(new String(db.get(readOptions,
|
||||
"key".getBytes())).equals("value"));
|
||||
// add new key/value pair
|
||||
db.put("newkey".getBytes(), "newvalue".getBytes());
|
||||
// using no snapshot the latest db entries
|
||||
// will be taken into account
|
||||
assert(new String(db.get("newkey".getBytes()))
|
||||
.equals("newvalue"));
|
||||
// snapshopot was created before newkey
|
||||
assert(db.get(readOptions, "newkey".getBytes())
|
||||
== null);
|
||||
// Retrieve snapshot from read options
|
||||
Snapshot sameSnapshot = readOptions.snapshot();
|
||||
readOptions.setSnapshot(sameSnapshot);
|
||||
// results must be the same with new Snapshot
|
||||
// instance using the same native pointer
|
||||
assert(new String(db.get(readOptions,
|
||||
"key".getBytes())).equals("value"));
|
||||
// update key value pair to newvalue
|
||||
db.put("key".getBytes(), "newvalue".getBytes());
|
||||
// read with previously created snapshot will
|
||||
// read previous version of key value pair
|
||||
assert(new String(db.get(readOptions,
|
||||
"key".getBytes())).equals("value"));
|
||||
// read for newkey using the snapshot must be
|
||||
// null
|
||||
assert(db.get(readOptions, "newkey".getBytes())
|
||||
== null);
|
||||
// setting null to snapshot in ReadOptions leads
|
||||
// to no Snapshot being used.
|
||||
readOptions.setSnapshot(null);
|
||||
assert(new String(db.get(readOptions,
|
||||
"newkey".getBytes())).equals("newvalue"));
|
||||
// release Snapshot
|
||||
db.releaseSnapshot(snapshot);
|
||||
// Close database
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
@ -6,20 +6,32 @@
|
||||
package org.rocksdb.test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
public class StatisticsCollectorTest {
|
||||
static final String db_path = "/tmp/rocksdbjni_statistics_collector_test";
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public static void main(String[] args)
|
||||
public class StatisticsCollectorTest {
|
||||
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void shouldTestStatisticsCollector()
|
||||
throws InterruptedException, RocksDBException {
|
||||
Options opt = new Options().createStatistics().setCreateIfMissing(true);
|
||||
Statistics stats = opt.statisticsPtr();
|
||||
|
||||
RocksDB db = RocksDB.open(opt, db_path);
|
||||
RocksDB db = RocksDB.open(opt,
|
||||
dbFolder.getRoot().getAbsolutePath());
|
||||
|
||||
StatsCallbackMock callback = new StatsCallbackMock();
|
||||
StatsCollectorInput statsInput = new StatsCollectorInput(stats, callback);
|
||||
@ -30,8 +42,8 @@ public class StatisticsCollectorTest {
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
assert(callback.tickerCallbackCount > 0);
|
||||
assert(callback.histCallbackCount > 0);
|
||||
assertThat(callback.tickerCallbackCount).isGreaterThan(0);
|
||||
assertThat(callback.histCallbackCount).isGreaterThan(0);
|
||||
|
||||
statsCollector.shutDown(1000);
|
||||
|
||||
|
130
java/org/rocksdb/test/WriteBatchTest.java
Normal file
130
java/org/rocksdb/test/WriteBatchTest.java
Normal file
@ -0,0 +1,130 @@
|
||||
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.WriteBatch;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* This class mimics the db/write_batch_test.cc
|
||||
* in the c++ rocksdb library.
|
||||
*
|
||||
* Not ported yet:
|
||||
*
|
||||
* Continue();
|
||||
* PutGatherSlices();
|
||||
*/
|
||||
public class WriteBatchTest {
|
||||
@ClassRule
|
||||
public static final RocksMemoryResource rocksMemoryResource =
|
||||
new RocksMemoryResource();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder dbFolder = new TemporaryFolder();
|
||||
|
||||
@AfterClass
|
||||
public static void printMergePass(){
|
||||
System.out.println("Passed WriteBatchTest.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTestEmptyWriteBatch() {
|
||||
WriteBatch batch = new WriteBatch();
|
||||
assertThat(batch.count()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTestMultipleBatchOperations()
|
||||
throws UnsupportedEncodingException {
|
||||
WriteBatch batch = new WriteBatch();
|
||||
batch.put("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII"));
|
||||
batch.remove("box".getBytes("US-ASCII"));
|
||||
batch.put("baz".getBytes("US-ASCII"), "boo".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.setSequence(batch, 100);
|
||||
assertThat(WriteBatchInternal.sequence(batch)).
|
||||
isNotNull().
|
||||
isEqualTo(100);
|
||||
assertThat(batch.count()).isEqualTo(3);
|
||||
assertThat(new String(getContents(batch), "US-ASCII")).
|
||||
isEqualTo("Put(baz, boo)@102" +
|
||||
"Delete(box)@101" +
|
||||
"Put(foo, bar)@100");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTestAppendOperation()
|
||||
throws UnsupportedEncodingException {
|
||||
WriteBatch b1 = new WriteBatch();
|
||||
WriteBatch b2 = new WriteBatch();
|
||||
WriteBatchInternal.setSequence(b1, 200);
|
||||
WriteBatchInternal.setSequence(b2, 300);
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assertThat(getContents(b1).length).isEqualTo(0);
|
||||
assertThat(b1.count()).isEqualTo(0);
|
||||
b2.put("a".getBytes("US-ASCII"), "va".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assertThat("Put(a, va)@200".equals(new String(getContents(b1), "US-ASCII")));
|
||||
assertThat(b1.count()).isEqualTo(1);
|
||||
b2.clear();
|
||||
b2.put("b".getBytes("US-ASCII"), "vb".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assertThat(("Put(a, va)@200" +
|
||||
"Put(b, vb)@201")
|
||||
.equals(new String(getContents(b1), "US-ASCII")));
|
||||
assertThat(b1.count()).isEqualTo(2);
|
||||
b2.remove("foo".getBytes("US-ASCII"));
|
||||
WriteBatchInternal.append(b1, b2);
|
||||
assertThat(("Put(a, va)@200" +
|
||||
"Put(b, vb)@202" +
|
||||
"Put(b, vb)@201" +
|
||||
"Delete(foo)@203")
|
||||
.equals(new String(getContents(b1), "US-ASCII")));
|
||||
assertThat(b1.count()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTestBlobOperation()
|
||||
throws UnsupportedEncodingException {
|
||||
WriteBatch batch = new WriteBatch();
|
||||
batch.put("k1".getBytes("US-ASCII"), "v1".getBytes("US-ASCII"));
|
||||
batch.put("k2".getBytes("US-ASCII"), "v2".getBytes("US-ASCII"));
|
||||
batch.put("k3".getBytes("US-ASCII"), "v3".getBytes("US-ASCII"));
|
||||
batch.putLogData("blob1".getBytes("US-ASCII"));
|
||||
batch.remove("k2".getBytes("US-ASCII"));
|
||||
batch.putLogData("blob2".getBytes("US-ASCII"));
|
||||
batch.merge("foo".getBytes("US-ASCII"), "bar".getBytes("US-ASCII"));
|
||||
assertThat(batch.count()).isEqualTo(5);
|
||||
assertThat(("Merge(foo, bar)@4" +
|
||||
"Put(k1, v1)@0" +
|
||||
"Delete(k2)@3" +
|
||||
"Put(k2, v2)@1" +
|
||||
"Put(k3, v3)@2")
|
||||
.equals(new String(getContents(batch), "US-ASCII")));
|
||||
}
|
||||
|
||||
static native byte[] getContents(WriteBatch batch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Package-private class which provides java api to access
|
||||
* c++ WriteBatchInternal.
|
||||
*/
|
||||
class WriteBatchInternal {
|
||||
static native void setSequence(WriteBatch batch, long sn);
|
||||
static native long sequence(WriteBatch batch);
|
||||
static native void append(WriteBatch b1, WriteBatch b2);
|
||||
}
|
@ -1,34 +1,164 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>RocksDB JNI</name>
|
||||
<url>http://rocksdb.org/</url>
|
||||
<groupId>org.rocksdb</groupId>
|
||||
<artifactId>rocksdbjni</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<description>RocksDB fat jar that contains .so files for linux32 and linux64, and jnilib files for Mac OSX.</description>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/dropwizard/metrics.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:dropwizard/metrics.git</developerConnection>
|
||||
<url>http://github.com/dropwizard/metrics/</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Facebook</name>
|
||||
<email>help@facebook.com</email>
|
||||
<timezone>America/New_York</timezone>
|
||||
<roles>
|
||||
<role>architect</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>RocksDB JNI</name>
|
||||
<url>http://rocksdb.org/</url>
|
||||
<groupId>org.rocksdb</groupId>
|
||||
<artifactId>rocksdbjni</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<description>RocksDB fat jar that contains .so files for linux32 and linux64, and jnilib files
|
||||
for Mac OSX.
|
||||
</description>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/dropwizard/metrics.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:dropwizard/metrics.git</developerConnection>
|
||||
<url>http://github.com/dropwizard/metrics/</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Facebook</name>
|
||||
<email>help@facebook.com</email>
|
||||
<timezone>America/New_York</timezone>
|
||||
<roles>
|
||||
<role>architect</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<!-- Use custom maven folder layout -->
|
||||
<!-- Set folder for src root -->
|
||||
<sourceDirectory>${project.basedir}</sourceDirectory>
|
||||
<!-- main resources, nothing shall be excluded -->
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}</directory>
|
||||
<excludes>
|
||||
<exclude>**/*</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<!-- Set folder for test root -->
|
||||
<testSourceDirectory>${project.basedir}</testSourceDirectory>
|
||||
<!-- Bring libraries on classpath -->
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>*.so</include>
|
||||
<include>*.jar</include>
|
||||
<include>*.jnilib</include>
|
||||
</includes>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<!-- Exclude all tests from classes -->
|
||||
<excludes>
|
||||
<!-- Exclude Sample -->
|
||||
<exclude>*.java</exclude>
|
||||
<!-- Exclude Benchmark -->
|
||||
<exclude>org/rocksdb/benchmark/*.java</exclude>
|
||||
<!-- Exclude Tests -->
|
||||
<exclude>org/rocksdb/test/*.java</exclude>
|
||||
<exclude>org/rocksdb/WriteBatchTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-testCompile</id>
|
||||
<phase>test-compile</phase>
|
||||
<configuration>
|
||||
<!-- Include only tests in test-classes -->
|
||||
<testExcludes>
|
||||
<!-- Exclude everything but WriteBatchTest -->
|
||||
<exclude>%regex[org/rocksdb/[^WriteBatchTest].*java]</exclude>
|
||||
<!-- Exclude WriteBatchTest -->
|
||||
<exclude>*.java</exclude>
|
||||
<!-- Exclude Benchmark -->
|
||||
<exclude>org/rocksdb/benchmark/*.java</exclude>
|
||||
<!-- Exclude Utilities -->
|
||||
<exclude>org/rocksdb/util/*.java</exclude>
|
||||
</testExcludes>
|
||||
<testIncludes>
|
||||
<!-- Include Tests -->
|
||||
<include>org/rocksdb/test/*.java</include>
|
||||
</testIncludes>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<configuration>
|
||||
<argLine>${argLine}</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.1.201405082137</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12-beta-2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
#include "include/org_rocksdb_WriteBatch.h"
|
||||
#include "include/org_rocksdb_WriteBatch_Handler.h"
|
||||
#include "include/org_rocksdb_WriteBatchInternal.h"
|
||||
#include "include/org_rocksdb_WriteBatchTest.h"
|
||||
#include "include/org_rocksdb_test_WriteBatchInternal.h"
|
||||
#include "include/org_rocksdb_test_WriteBatchTest.h"
|
||||
#include "rocksjni/portal.h"
|
||||
#include "rocksjni/writebatchhandlerjnicallback.h"
|
||||
#include "rocksdb/db.h"
|
||||
@ -257,11 +257,11 @@ void Java_org_rocksdb_WriteBatch_disposeInternal(
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_WriteBatchInternal
|
||||
* Class: org_rocksdb_test_WriteBatchInternal
|
||||
* Method: setSequence
|
||||
* Signature: (Lorg/rocksdb/WriteBatch;J)V
|
||||
*/
|
||||
void Java_org_rocksdb_WriteBatchInternal_setSequence(
|
||||
void Java_org_rocksdb_test_WriteBatchInternal_setSequence(
|
||||
JNIEnv* env, jclass jclazz, jobject jobj, jlong jsn) {
|
||||
rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj);
|
||||
assert(wb != nullptr);
|
||||
@ -271,11 +271,11 @@ void Java_org_rocksdb_WriteBatchInternal_setSequence(
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_WriteBatchInternal
|
||||
* Class: org_rocksdb_test_WriteBatchInternal
|
||||
* Method: sequence
|
||||
* Signature: (Lorg/rocksdb/WriteBatch;)J
|
||||
*/
|
||||
jlong Java_org_rocksdb_WriteBatchInternal_sequence(
|
||||
jlong Java_org_rocksdb_test_WriteBatchInternal_sequence(
|
||||
JNIEnv* env, jclass jclazz, jobject jobj) {
|
||||
rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj);
|
||||
assert(wb != nullptr);
|
||||
@ -284,11 +284,11 @@ jlong Java_org_rocksdb_WriteBatchInternal_sequence(
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_WriteBatchInternal
|
||||
* Class: org_rocksdb_test_WriteBatchInternal
|
||||
* Method: append
|
||||
* Signature: (Lorg/rocksdb/WriteBatch;Lorg/rocksdb/WriteBatch;)V
|
||||
*/
|
||||
void Java_org_rocksdb_WriteBatchInternal_append(
|
||||
void Java_org_rocksdb_test_WriteBatchInternal_append(
|
||||
JNIEnv* env, jclass jclazz, jobject jwb1, jobject jwb2) {
|
||||
rocksdb::WriteBatch* wb1 = rocksdb::WriteBatchJni::getHandle(env, jwb1);
|
||||
assert(wb1 != nullptr);
|
||||
@ -321,11 +321,11 @@ void Java_org_rocksdb_WriteBatch_00024Handler_disposeInternal(
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_rocksdb_WriteBatchTest
|
||||
* Class: org_rocksdb_test_WriteBatchTest
|
||||
* Method: getContents
|
||||
* Signature: (Lorg/rocksdb/WriteBatch;)[B
|
||||
*/
|
||||
jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
|
||||
jbyteArray Java_org_rocksdb_test_WriteBatchTest_getContents(
|
||||
JNIEnv* env, jclass jclazz, jobject jobj) {
|
||||
rocksdb::WriteBatch* b = rocksdb::WriteBatchJni::getHandle(env, jobj);
|
||||
assert(b != nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user