From ab513afbdcd16a51f892a265691722d30a1c5f9f Mon Sep 17 00:00:00 2001 From: Sagar Vemuri Date: Tue, 2 May 2017 16:24:41 -0700 Subject: [PATCH] Revert adding SstFileWriter construtor w/o explicit comparator to JNI Revert commit 491fa696fa8d2676b1f424b06734d7a823d6ea79 in 5.3 branch, as this breaks the java build. --- java/rocksjni/sst_file_writerjni.cc | 18 +------- .../main/java/org/rocksdb/SstFileWriter.java | 8 ---- .../java/org/rocksdb/SstFileWriterTest.java | 42 +++++-------------- 3 files changed, 11 insertions(+), 57 deletions(-) diff --git a/java/rocksjni/sst_file_writerjni.cc b/java/rocksjni/sst_file_writerjni.cc index 879f93e07..fe3ec3940 100644 --- a/java/rocksjni/sst_file_writerjni.cc +++ b/java/rocksjni/sst_file_writerjni.cc @@ -22,7 +22,7 @@ * Method: newSstFileWriter * Signature: (JJJ)J */ -jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJ(JNIEnv *env, jclass jcls, +jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter(JNIEnv *env, jclass jcls, jlong jenvoptions, jlong joptions, jlong jcomparator) { @@ -35,22 +35,6 @@ jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJJ(JNIEnv *env, jclass j return reinterpret_cast(sst_file_writer); } -/* - * Class: org_rocksdb_SstFileWriter - * Method: newSstFileWriter - * Signature: (JJ)J - */ -jlong Java_org_rocksdb_SstFileWriter_newSstFileWriter__JJ(JNIEnv *env, jclass jcls, - jlong jenvoptions, - jlong joptions) { - auto *env_options = - reinterpret_cast(jenvoptions); - auto *options = reinterpret_cast(joptions); - rocksdb::SstFileWriter *sst_file_writer = - new rocksdb::SstFileWriter(*env_options, *options); - return reinterpret_cast(sst_file_writer); -} - /* * Class: org_rocksdb_SstFileWriter * Method: open diff --git a/java/src/main/java/org/rocksdb/SstFileWriter.java b/java/src/main/java/org/rocksdb/SstFileWriter.java index 130a49620..38d819aaa 100644 --- a/java/src/main/java/org/rocksdb/SstFileWriter.java +++ b/java/src/main/java/org/rocksdb/SstFileWriter.java @@ -16,11 +16,6 @@ public class SstFileWriter extends RocksObject { envOptions.nativeHandle_, options.nativeHandle_, comparator.getNativeHandle())); } - public SstFileWriter(final EnvOptions envOptions, final Options options) { - super(newSstFileWriter( - envOptions.nativeHandle_, options.nativeHandle_)); - } - public void open(final String filePath) throws RocksDBException { open(nativeHandle_, filePath); } @@ -40,9 +35,6 @@ public class SstFileWriter extends RocksObject { private native static long newSstFileWriter( final long envOptionsHandle, final long optionsHandle, final long userComparatorHandle); - private native static long newSstFileWriter(final long envOptionsHandle, - final long optionsHandle); - private native void open(final long handle, final String filePath) throws RocksDBException; private native void add(final long handle, final long keyHandle, final long valueHandle) diff --git a/java/src/test/java/org/rocksdb/SstFileWriterTest.java b/java/src/test/java/org/rocksdb/SstFileWriterTest.java index 5f2a4b10e..eb8c76d34 100644 --- a/java/src/test/java/org/rocksdb/SstFileWriterTest.java +++ b/java/src/test/java/org/rocksdb/SstFileWriterTest.java @@ -27,23 +27,13 @@ public class SstFileWriterTest { @Rule public TemporaryFolder parentFolder = new TemporaryFolder(); - private File newSstFile(final TreeMap keyValues, - boolean useJavaBytewiseComparator) + private File newSstFile(final TreeMap keyValues) throws IOException, RocksDBException { final EnvOptions envOptions = new EnvOptions(); - final Options options = new Options(); - SstFileWriter sstFileWriter = null; - ComparatorOptions comparatorOptions = null; - BytewiseComparator comparator = null; - if (useJavaBytewiseComparator) { - comparatorOptions = new ComparatorOptions(); - comparator = new BytewiseComparator(comparatorOptions); - options.setComparator(comparator); - sstFileWriter = new SstFileWriter(envOptions, options, comparator); - } else { - sstFileWriter = new SstFileWriter(envOptions, options); - } - + final ComparatorOptions comparatorOptions = new ComparatorOptions(); + final BytewiseComparator comparator = new BytewiseComparator(comparatorOptions); + final Options options = new Options().setComparator(comparator); + final SstFileWriter sstFileWriter = new SstFileWriter(envOptions, options, comparator); final File sstFile = parentFolder.newFile(SST_FILE_NAME); try { sstFileWriter.open(sstFile.getAbsolutePath()); @@ -60,30 +50,18 @@ public class SstFileWriterTest { sstFileWriter.close(); options.close(); envOptions.close(); - if (comparatorOptions != null) { - comparatorOptions.close(); - } - if (comparator != null) { - comparator.close(); - } + comparatorOptions.close(); + comparator.close(); } return sstFile; } @Test - public void generateSstFileWithJavaComparator() throws RocksDBException, IOException { + public void generateSstFile() throws RocksDBException, IOException { final TreeMap keyValues = new TreeMap<>(); keyValues.put("key1", "value1"); keyValues.put("key2", "value2"); - newSstFile(keyValues, true); - } - - @Test - public void generateSstFileWithNativeComparator() throws RocksDBException, IOException { - final TreeMap keyValues = new TreeMap<>(); - keyValues.put("key1", "value1"); - keyValues.put("key2", "value2"); - newSstFile(keyValues, false); + newSstFile(keyValues); } @Test @@ -91,7 +69,7 @@ public class SstFileWriterTest { final TreeMap keyValues = new TreeMap<>(); keyValues.put("key1", "value1"); keyValues.put("key2", "value2"); - final File sstFile = newSstFile(keyValues, false); + final File sstFile = newSstFile(keyValues); final File dbFolder = parentFolder.newFolder(DB_DIRECTORY_NAME); final Options options = new Options().setCreateIfMissing(true); final RocksDB db = RocksDB.open(options, dbFolder.getAbsolutePath());