[RocksJava] Merged & rebased to HEAD

main
fyrz 10 years ago
parent 74057d6d2d
commit b6abab8b77
  1. 44
      java/org/rocksdb/test/KeyMayExistTest.java
  2. 15
      java/org/rocksdb/test/WriteBatchHandlerTest.java

@ -26,9 +26,10 @@ public class KeyMayExistTest {
@Test @Test
public void keyMayExist() throws RocksDBException { public void keyMayExist() throws RocksDBException {
<<<<<<< HEAD RocksDB db = null;
RocksDB db; DBOptions options = null;
DBOptions options = new DBOptions(); try {
options = new DBOptions();
options.setCreateIfMissing(true) options.setCreateIfMissing(true)
.setCreateMissingColumnFamilies(true); .setCreateMissingColumnFamilies(true);
// open database using cf names // open database using cf names
@ -50,32 +51,6 @@ public class KeyMayExistTest {
assertThat(exists).isTrue(); assertThat(exists).isTrue();
assertThat(retValue.toString()). assertThat(retValue.toString()).
isEqualTo("value"); isEqualTo("value");
=======
RocksDB db = null;
Options options = null;
try {
options = new Options();
options.setCreateIfMissing(true)
.setCreateMissingColumnFamilies(true);
// open database using cf names
List<String> cfNames = new ArrayList<>();
List<ColumnFamilyHandle> columnFamilyHandleList =
new ArrayList<>();
cfNames.add("default");
cfNames.add("new_cf");
db = RocksDB.open(options,
dbFolder.getRoot().getAbsolutePath(),
cfNames, columnFamilyHandleList);
assertThat(columnFamilyHandleList.size()).
isEqualTo(2);
db.put("key".getBytes(), "value".getBytes());
// Test without column family
StringBuffer retValue = new StringBuffer();
boolean exists = db.keyMayExist("key".getBytes(), retValue);
assertThat(exists).isTrue();
assertThat(retValue.toString()).
isEqualTo("value");
>>>>>>> [RocksJava] Integrated review comments from D28209
// Test without column family but with readOptions // Test without column family but with readOptions
retValue = new StringBuffer(); retValue = new StringBuffer();
@ -93,16 +68,6 @@ public class KeyMayExistTest {
assertThat(retValue.toString()). assertThat(retValue.toString()).
isEqualTo("value"); isEqualTo("value");
<<<<<<< HEAD
// Test with column family and readOptions
retValue = new StringBuffer();
exists = db.keyMayExist(new ReadOptions(),
columnFamilyHandleList.get(0), "key".getBytes(),
retValue);
assertThat(exists).isTrue();
assertThat(retValue.toString()).
isEqualTo("value");
=======
// Test with column family and readOptions // Test with column family and readOptions
retValue = new StringBuffer(); retValue = new StringBuffer();
exists = db.keyMayExist(new ReadOptions(), exists = db.keyMayExist(new ReadOptions(),
@ -111,7 +76,6 @@ public class KeyMayExistTest {
assertThat(exists).isTrue(); assertThat(exists).isTrue();
assertThat(retValue.toString()). assertThat(retValue.toString()).
isEqualTo("value"); isEqualTo("value");
>>>>>>> [RocksJava] Integrated review comments from D28209
// KeyMayExist in CF1 must return false // KeyMayExist in CF1 must return false
assertThat(db.keyMayExist(columnFamilyHandleList.get(1), assertThat(db.keyMayExist(columnFamilyHandleList.get(1),

@ -13,13 +13,20 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.ClassRule;
import org.junit.Test;
import org.rocksdb.WriteOptions;
import static org.assertj.core.api.Assertions.assertThat;
public class WriteBatchHandlerTest { public class WriteBatchHandlerTest {
static { @ClassRule
RocksDB.loadLibrary(); public static final RocksMemoryResource rocksMemoryResource =
} new RocksMemoryResource();
public static void main(final String[] args) throws IOException, RocksDBException { @Test
public void writeBatchHandler() throws IOException, RocksDBException {
// setup test data // setup test data
final List<Tuple<Action, Tuple<byte[], byte[]>>> testEvents = new ArrayList<>(); final List<Tuple<Action, Tuple<byte[], byte[]>>> testEvents = new ArrayList<>();

Loading…
Cancel
Save