Windows JNI build fixes (#4015)
Summary: Fixing compilation, unsatisfied link exceptions (updated list of files that needs to be linked) and warnings for Windows build. ```C++ //MSVC 2015 does not support dynamic arrays like: rocksdb::Slice key_parts[jkey_parts_len]; //I have converted to: std::vector<rocksdb::Slice> key_parts; ``` Also reusing `free_key_parts` that does the same as `free_key_value_parts` that was removed. Java elapsedTime unit test increase of sleep to 2 ms. Otherwise it was failing. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4015 Differential Revision: D8558215 Pulled By: sagar0 fbshipit-source-id: d3c34f846343f9218424da2402a2bd367bbd0aa2
This commit is contained in:
parent
4bb1e239b5
commit
80afa84903
@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.4)
|
|||||||
set(JNI_NATIVE_SOURCES
|
set(JNI_NATIVE_SOURCES
|
||||||
rocksjni/backupablejni.cc
|
rocksjni/backupablejni.cc
|
||||||
rocksjni/backupenginejni.cc
|
rocksjni/backupenginejni.cc
|
||||||
|
rocksjni/cassandra_compactionfilterjni.cc
|
||||||
|
rocksjni/cassandra_value_operator.cc
|
||||||
rocksjni/checkpoint.cc
|
rocksjni/checkpoint.cc
|
||||||
rocksjni/clock_cache.cc
|
rocksjni/clock_cache.cc
|
||||||
rocksjni/columnfamilyhandle.cc
|
rocksjni/columnfamilyhandle.cc
|
||||||
@ -25,14 +27,14 @@ set(JNI_NATIVE_SOURCES
|
|||||||
rocksjni/memtablejni.cc
|
rocksjni/memtablejni.cc
|
||||||
rocksjni/merge_operator.cc
|
rocksjni/merge_operator.cc
|
||||||
rocksjni/native_comparator_wrapper_test.cc
|
rocksjni/native_comparator_wrapper_test.cc
|
||||||
|
rocksjni/optimistic_transaction_db.cc
|
||||||
|
rocksjni/optimistic_transaction_options.cc
|
||||||
rocksjni/options.cc
|
rocksjni/options.cc
|
||||||
rocksjni/options_util.cc
|
rocksjni/options_util.cc
|
||||||
rocksjni/ratelimiterjni.cc
|
rocksjni/ratelimiterjni.cc
|
||||||
rocksjni/remove_emptyvalue_compactionfilterjni.cc
|
rocksjni/remove_emptyvalue_compactionfilterjni.cc
|
||||||
rocksjni/rocks_callback_object.cc
|
|
||||||
rocksjni/cassandra_compactionfilterjni.cc
|
|
||||||
rocksjni/cassandra_value_operator.cc
|
|
||||||
rocksjni/restorejni.cc
|
rocksjni/restorejni.cc
|
||||||
|
rocksjni/rocks_callback_object.cc
|
||||||
rocksjni/rocksdb_exception_test.cc
|
rocksjni/rocksdb_exception_test.cc
|
||||||
rocksjni/rocksjni.cc
|
rocksjni/rocksjni.cc
|
||||||
rocksjni/slice.cc
|
rocksjni/slice.cc
|
||||||
@ -42,28 +44,33 @@ set(JNI_NATIVE_SOURCES
|
|||||||
rocksjni/statistics.cc
|
rocksjni/statistics.cc
|
||||||
rocksjni/statisticsjni.cc
|
rocksjni/statisticsjni.cc
|
||||||
rocksjni/table.cc
|
rocksjni/table.cc
|
||||||
|
rocksjni/transaction.cc
|
||||||
|
rocksjni/transaction_db.cc
|
||||||
|
rocksjni/transaction_db_options.cc
|
||||||
rocksjni/transaction_log.cc
|
rocksjni/transaction_log.cc
|
||||||
|
rocksjni/transaction_notifier.cc
|
||||||
|
rocksjni/transaction_notifier_jnicallback.cc
|
||||||
|
rocksjni/transaction_options.cc
|
||||||
rocksjni/ttl.cc
|
rocksjni/ttl.cc
|
||||||
rocksjni/write_batch.cc
|
rocksjni/write_batch.cc
|
||||||
|
rocksjni/writebatchhandlerjnicallback.cc
|
||||||
rocksjni/write_batch_test.cc
|
rocksjni/write_batch_test.cc
|
||||||
rocksjni/write_batch_with_index.cc
|
rocksjni/write_batch_with_index.cc
|
||||||
rocksjni/writebatchhandlerjnicallback.cc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(NATIVE_JAVA_CLASSES
|
set(NATIVE_JAVA_CLASSES
|
||||||
org.rocksdb.AbstractCompactionFilter
|
org.rocksdb.AbstractCompactionFilter
|
||||||
org.rocksdb.AbstractCompactionFilterFactory
|
org.rocksdb.AbstractCompactionFilterFactory
|
||||||
|
org.rocksdb.AbstractComparator
|
||||||
org.rocksdb.AbstractImmutableNativeReference
|
org.rocksdb.AbstractImmutableNativeReference
|
||||||
org.rocksdb.AbstractNativeReference
|
org.rocksdb.AbstractNativeReference
|
||||||
org.rocksdb.AbstractRocksIterator
|
org.rocksdb.AbstractRocksIterator
|
||||||
org.rocksdb.AbstractSlice
|
org.rocksdb.AbstractSlice
|
||||||
org.rocksdb.AbstractWriteBatch
|
org.rocksdb.AbstractTransactionNotifier
|
||||||
org.rocksdb.BackupableDBOptions
|
org.rocksdb.BackupableDBOptions
|
||||||
org.rocksdb.BackupEngine
|
org.rocksdb.BackupEngine
|
||||||
org.rocksdb.BackupEngineTest
|
|
||||||
org.rocksdb.BlockBasedTableConfig
|
org.rocksdb.BlockBasedTableConfig
|
||||||
org.rocksdb.BloomFilter
|
org.rocksdb.BloomFilter
|
||||||
org.rocksdb.Cache
|
|
||||||
org.rocksdb.CassandraCompactionFilter
|
org.rocksdb.CassandraCompactionFilter
|
||||||
org.rocksdb.CassandraValueMergeOperator
|
org.rocksdb.CassandraValueMergeOperator
|
||||||
org.rocksdb.Checkpoint
|
org.rocksdb.Checkpoint
|
||||||
@ -88,10 +95,10 @@ set(NATIVE_JAVA_CLASSES
|
|||||||
org.rocksdb.Logger
|
org.rocksdb.Logger
|
||||||
org.rocksdb.LRUCache
|
org.rocksdb.LRUCache
|
||||||
org.rocksdb.MemTableConfig
|
org.rocksdb.MemTableConfig
|
||||||
org.rocksdb.MergeOperator
|
|
||||||
org.rocksdb.NativeComparatorWrapper
|
org.rocksdb.NativeComparatorWrapper
|
||||||
org.rocksdb.NativeComparatorWrapperTest.NativeStringComparatorWrapper
|
|
||||||
org.rocksdb.NativeLibraryLoader
|
org.rocksdb.NativeLibraryLoader
|
||||||
|
org.rocksdb.OptimisticTransactionDB
|
||||||
|
org.rocksdb.OptimisticTransactionOptions
|
||||||
org.rocksdb.Options
|
org.rocksdb.Options
|
||||||
org.rocksdb.OptionsUtil
|
org.rocksdb.OptionsUtil
|
||||||
org.rocksdb.PlainTableConfig
|
org.rocksdb.PlainTableConfig
|
||||||
@ -101,7 +108,6 @@ set(NATIVE_JAVA_CLASSES
|
|||||||
org.rocksdb.RestoreOptions
|
org.rocksdb.RestoreOptions
|
||||||
org.rocksdb.RocksCallbackObject
|
org.rocksdb.RocksCallbackObject
|
||||||
org.rocksdb.RocksDB
|
org.rocksdb.RocksDB
|
||||||
org.rocksdb.RocksDBExceptionTest
|
|
||||||
org.rocksdb.RocksEnv
|
org.rocksdb.RocksEnv
|
||||||
org.rocksdb.RocksIterator
|
org.rocksdb.RocksIterator
|
||||||
org.rocksdb.RocksIteratorInterface
|
org.rocksdb.RocksIteratorInterface
|
||||||
@ -111,24 +117,29 @@ set(NATIVE_JAVA_CLASSES
|
|||||||
org.rocksdb.SkipListMemTableConfig
|
org.rocksdb.SkipListMemTableConfig
|
||||||
org.rocksdb.Slice
|
org.rocksdb.Slice
|
||||||
org.rocksdb.Snapshot
|
org.rocksdb.Snapshot
|
||||||
org.rocksdb.SnapshotTest
|
|
||||||
org.rocksdb.SstFileManager
|
org.rocksdb.SstFileManager
|
||||||
org.rocksdb.SstFileWriter
|
org.rocksdb.SstFileWriter
|
||||||
org.rocksdb.Statistics
|
org.rocksdb.Statistics
|
||||||
org.rocksdb.StringAppendOperator
|
org.rocksdb.StringAppendOperator
|
||||||
org.rocksdb.TableFormatConfig
|
org.rocksdb.TableFormatConfig
|
||||||
|
org.rocksdb.Transaction
|
||||||
|
org.rocksdb.TransactionDB
|
||||||
|
org.rocksdb.TransactionDBOptions
|
||||||
org.rocksdb.TransactionLogIterator
|
org.rocksdb.TransactionLogIterator
|
||||||
|
org.rocksdb.TransactionOptions
|
||||||
org.rocksdb.TtlDB
|
org.rocksdb.TtlDB
|
||||||
org.rocksdb.VectorMemTableConfig
|
org.rocksdb.VectorMemTableConfig
|
||||||
org.rocksdb.WBWIRocksIterator
|
org.rocksdb.WBWIRocksIterator
|
||||||
org.rocksdb.WriteBatch
|
org.rocksdb.WriteBatch
|
||||||
org.rocksdb.WriteBatch.Handler
|
org.rocksdb.WriteBatch.Handler
|
||||||
org.rocksdb.WriteBatchTest
|
org.rocksdb.WriteBatchInterface
|
||||||
org.rocksdb.WriteBatchTestInternalHelper
|
|
||||||
org.rocksdb.WriteBatchWithIndex
|
org.rocksdb.WriteBatchWithIndex
|
||||||
org.rocksdb.WriteOptions
|
org.rocksdb.WriteOptions
|
||||||
org.rocksdb.util.CapturingWriteBatchHandler
|
org.rocksdb.NativeComparatorWrapperTest
|
||||||
org.rocksdb.util.WriteBatchGetter
|
org.rocksdb.RocksDBExceptionTest
|
||||||
|
org.rocksdb.SnapshotTest
|
||||||
|
org.rocksdb.WriteBatchTest
|
||||||
|
org.rocksdb.WriteBatchTestInternalHelper
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindJava)
|
include(FindJava)
|
||||||
@ -150,13 +161,14 @@ set(JAVA_TESTCLASSPATH ${JAVA_JUNIT_JAR} ${JAVA_HAMCR_JAR} ${JAVA_MOCKITO_JAR} $
|
|||||||
add_jar(
|
add_jar(
|
||||||
rocksdbjni_classes
|
rocksdbjni_classes
|
||||||
SOURCES
|
SOURCES
|
||||||
src/main/java/org/rocksdb/AbstractCompactionFilter.java
|
|
||||||
src/main/java/org/rocksdb/AbstractCompactionFilterFactory.java
|
src/main/java/org/rocksdb/AbstractCompactionFilterFactory.java
|
||||||
|
src/main/java/org/rocksdb/AbstractCompactionFilter.java
|
||||||
src/main/java/org/rocksdb/AbstractComparator.java
|
src/main/java/org/rocksdb/AbstractComparator.java
|
||||||
src/main/java/org/rocksdb/AbstractImmutableNativeReference.java
|
src/main/java/org/rocksdb/AbstractImmutableNativeReference.java
|
||||||
src/main/java/org/rocksdb/AbstractNativeReference.java
|
src/main/java/org/rocksdb/AbstractNativeReference.java
|
||||||
src/main/java/org/rocksdb/AbstractRocksIterator.java
|
src/main/java/org/rocksdb/AbstractRocksIterator.java
|
||||||
src/main/java/org/rocksdb/AbstractSlice.java
|
src/main/java/org/rocksdb/AbstractSlice.java
|
||||||
|
src/main/java/org/rocksdb/AbstractTransactionNotifier.java
|
||||||
src/main/java/org/rocksdb/AbstractWriteBatch.java
|
src/main/java/org/rocksdb/AbstractWriteBatch.java
|
||||||
src/main/java/org/rocksdb/AccessHint.java
|
src/main/java/org/rocksdb/AccessHint.java
|
||||||
src/main/java/org/rocksdb/AdvancedColumnFamilyOptionsInterface.java
|
src/main/java/org/rocksdb/AdvancedColumnFamilyOptionsInterface.java
|
||||||
@ -175,8 +187,8 @@ add_jar(
|
|||||||
src/main/java/org/rocksdb/ClockCache.java
|
src/main/java/org/rocksdb/ClockCache.java
|
||||||
src/main/java/org/rocksdb/ColumnFamilyDescriptor.java
|
src/main/java/org/rocksdb/ColumnFamilyDescriptor.java
|
||||||
src/main/java/org/rocksdb/ColumnFamilyHandle.java
|
src/main/java/org/rocksdb/ColumnFamilyHandle.java
|
||||||
src/main/java/org/rocksdb/ColumnFamilyOptions.java
|
|
||||||
src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java
|
src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java
|
||||||
|
src/main/java/org/rocksdb/ColumnFamilyOptions.java
|
||||||
src/main/java/org/rocksdb/CompactionOptionsFIFO.java
|
src/main/java/org/rocksdb/CompactionOptionsFIFO.java
|
||||||
src/main/java/org/rocksdb/CompactionOptionsUniversal.java
|
src/main/java/org/rocksdb/CompactionOptionsUniversal.java
|
||||||
src/main/java/org/rocksdb/CompactionPriority.java
|
src/main/java/org/rocksdb/CompactionPriority.java
|
||||||
@ -187,8 +199,8 @@ add_jar(
|
|||||||
src/main/java/org/rocksdb/ComparatorType.java
|
src/main/java/org/rocksdb/ComparatorType.java
|
||||||
src/main/java/org/rocksdb/CompressionOptions.java
|
src/main/java/org/rocksdb/CompressionOptions.java
|
||||||
src/main/java/org/rocksdb/CompressionType.java
|
src/main/java/org/rocksdb/CompressionType.java
|
||||||
src/main/java/org/rocksdb/DBOptions.java
|
|
||||||
src/main/java/org/rocksdb/DBOptionsInterface.java
|
src/main/java/org/rocksdb/DBOptionsInterface.java
|
||||||
|
src/main/java/org/rocksdb/DBOptions.java
|
||||||
src/main/java/org/rocksdb/DbPath.java
|
src/main/java/org/rocksdb/DbPath.java
|
||||||
src/main/java/org/rocksdb/DirectComparator.java
|
src/main/java/org/rocksdb/DirectComparator.java
|
||||||
src/main/java/org/rocksdb/DirectSlice.java
|
src/main/java/org/rocksdb/DirectSlice.java
|
||||||
@ -209,10 +221,12 @@ add_jar(
|
|||||||
src/main/java/org/rocksdb/LRUCache.java
|
src/main/java/org/rocksdb/LRUCache.java
|
||||||
src/main/java/org/rocksdb/MemTableConfig.java
|
src/main/java/org/rocksdb/MemTableConfig.java
|
||||||
src/main/java/org/rocksdb/MergeOperator.java
|
src/main/java/org/rocksdb/MergeOperator.java
|
||||||
src/main/java/org/rocksdb/MutableColumnFamilyOptions.java
|
|
||||||
src/main/java/org/rocksdb/MutableColumnFamilyOptionsInterface.java
|
src/main/java/org/rocksdb/MutableColumnFamilyOptionsInterface.java
|
||||||
|
src/main/java/org/rocksdb/MutableColumnFamilyOptions.java
|
||||||
src/main/java/org/rocksdb/NativeComparatorWrapper.java
|
src/main/java/org/rocksdb/NativeComparatorWrapper.java
|
||||||
src/main/java/org/rocksdb/NativeLibraryLoader.java
|
src/main/java/org/rocksdb/NativeLibraryLoader.java
|
||||||
|
src/main/java/org/rocksdb/OptimisticTransactionDB.java
|
||||||
|
src/main/java/org/rocksdb/OptimisticTransactionOptions.java
|
||||||
src/main/java/org/rocksdb/Options.java
|
src/main/java/org/rocksdb/Options.java
|
||||||
src/main/java/org/rocksdb/OptionsUtil.java
|
src/main/java/org/rocksdb/OptionsUtil.java
|
||||||
src/main/java/org/rocksdb/PlainTableConfig.java
|
src/main/java/org/rocksdb/PlainTableConfig.java
|
||||||
@ -223,11 +237,11 @@ add_jar(
|
|||||||
src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java
|
src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java
|
||||||
src/main/java/org/rocksdb/RestoreOptions.java
|
src/main/java/org/rocksdb/RestoreOptions.java
|
||||||
src/main/java/org/rocksdb/RocksCallbackObject.java
|
src/main/java/org/rocksdb/RocksCallbackObject.java
|
||||||
src/main/java/org/rocksdb/RocksDB.java
|
|
||||||
src/main/java/org/rocksdb/RocksDBException.java
|
src/main/java/org/rocksdb/RocksDBException.java
|
||||||
|
src/main/java/org/rocksdb/RocksDB.java
|
||||||
src/main/java/org/rocksdb/RocksEnv.java
|
src/main/java/org/rocksdb/RocksEnv.java
|
||||||
src/main/java/org/rocksdb/RocksIterator.java
|
|
||||||
src/main/java/org/rocksdb/RocksIteratorInterface.java
|
src/main/java/org/rocksdb/RocksIteratorInterface.java
|
||||||
|
src/main/java/org/rocksdb/RocksIterator.java
|
||||||
src/main/java/org/rocksdb/RocksMemEnv.java
|
src/main/java/org/rocksdb/RocksMemEnv.java
|
||||||
src/main/java/org/rocksdb/RocksMutableObject.java
|
src/main/java/org/rocksdb/RocksMutableObject.java
|
||||||
src/main/java/org/rocksdb/RocksObject.java
|
src/main/java/org/rocksdb/RocksObject.java
|
||||||
@ -236,22 +250,36 @@ add_jar(
|
|||||||
src/main/java/org/rocksdb/Snapshot.java
|
src/main/java/org/rocksdb/Snapshot.java
|
||||||
src/main/java/org/rocksdb/SstFileManager.java
|
src/main/java/org/rocksdb/SstFileManager.java
|
||||||
src/main/java/org/rocksdb/SstFileWriter.java
|
src/main/java/org/rocksdb/SstFileWriter.java
|
||||||
|
src/main/java/org/rocksdb/StatisticsCollectorCallback.java
|
||||||
|
src/main/java/org/rocksdb/StatisticsCollector.java
|
||||||
src/main/java/org/rocksdb/Statistics.java
|
src/main/java/org/rocksdb/Statistics.java
|
||||||
|
src/main/java/org/rocksdb/StatsCollectorInput.java
|
||||||
src/main/java/org/rocksdb/StatsLevel.java
|
src/main/java/org/rocksdb/StatsLevel.java
|
||||||
src/main/java/org/rocksdb/Status.java
|
src/main/java/org/rocksdb/Status.java
|
||||||
src/main/java/org/rocksdb/StringAppendOperator.java
|
src/main/java/org/rocksdb/StringAppendOperator.java
|
||||||
src/main/java/org/rocksdb/TableFormatConfig.java
|
src/main/java/org/rocksdb/TableFormatConfig.java
|
||||||
src/main/java/org/rocksdb/TickerType.java
|
src/main/java/org/rocksdb/TickerType.java
|
||||||
|
src/main/java/org/rocksdb/TransactionalDB.java
|
||||||
|
src/main/java/org/rocksdb/TransactionalOptions.java
|
||||||
|
src/main/java/org/rocksdb/TransactionDB.java
|
||||||
|
src/main/java/org/rocksdb/TransactionDBOptions.java
|
||||||
|
src/main/java/org/rocksdb/Transaction.java
|
||||||
src/main/java/org/rocksdb/TransactionLogIterator.java
|
src/main/java/org/rocksdb/TransactionLogIterator.java
|
||||||
|
src/main/java/org/rocksdb/TransactionOptions.java
|
||||||
src/main/java/org/rocksdb/TtlDB.java
|
src/main/java/org/rocksdb/TtlDB.java
|
||||||
src/main/java/org/rocksdb/util/Environment.java
|
src/main/java/org/rocksdb/TxnDBWritePolicy.java
|
||||||
src/main/java/org/rocksdb/VectorMemTableConfig.java
|
src/main/java/org/rocksdb/VectorMemTableConfig.java
|
||||||
src/main/java/org/rocksdb/WALRecoveryMode.java
|
src/main/java/org/rocksdb/WALRecoveryMode.java
|
||||||
src/main/java/org/rocksdb/WBWIRocksIterator.java
|
src/main/java/org/rocksdb/WBWIRocksIterator.java
|
||||||
src/main/java/org/rocksdb/WriteBatch.java
|
|
||||||
src/main/java/org/rocksdb/WriteBatchInterface.java
|
src/main/java/org/rocksdb/WriteBatchInterface.java
|
||||||
|
src/main/java/org/rocksdb/WriteBatch.java
|
||||||
src/main/java/org/rocksdb/WriteBatchWithIndex.java
|
src/main/java/org/rocksdb/WriteBatchWithIndex.java
|
||||||
src/main/java/org/rocksdb/WriteOptions.java
|
src/main/java/org/rocksdb/WriteOptions.java
|
||||||
|
src/main/java/org/rocksdb/util/BytewiseComparator.java
|
||||||
|
src/main/java/org/rocksdb/util/DirectBytewiseComparator.java
|
||||||
|
src/main/java/org/rocksdb/util/Environment.java
|
||||||
|
src/main/java/org/rocksdb/util/ReverseBytewiseComparator.java
|
||||||
|
src/main/java/org/rocksdb/util/SizeUnit.java
|
||||||
src/test/java/org/rocksdb/BackupEngineTest.java
|
src/test/java/org/rocksdb/BackupEngineTest.java
|
||||||
src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java
|
src/test/java/org/rocksdb/IngestExternalFileOptionsTest.java
|
||||||
src/test/java/org/rocksdb/NativeComparatorWrapperTest.java
|
src/test/java/org/rocksdb/NativeComparatorWrapperTest.java
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4503) // identifier' : decorated name length exceeded, name was truncated
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_rocksdb_Transaction
|
* Class: org_rocksdb_Transaction
|
||||||
* Method: setSnapshot
|
* Method: setSnapshot
|
||||||
@ -264,15 +269,14 @@ typedef std::function<std::vector<rocksdb::Status>(
|
|||||||
std::vector<std::string>*)>
|
std::vector<std::string>*)>
|
||||||
FnMultiGet;
|
FnMultiGet;
|
||||||
|
|
||||||
void free_key_parts(
|
void free_parts(
|
||||||
JNIEnv* env,
|
JNIEnv* env,
|
||||||
std::vector<std::tuple<jbyteArray, jbyte*, jobject>> key_parts_to_free) {
|
std::vector<std::tuple<jbyteArray, jbyte*, jobject>> &parts_to_free) {
|
||||||
for (std::vector<std::tuple<jbyteArray, jbyte*, jobject>>::size_type i = 0;
|
for (auto &value : parts_to_free) {
|
||||||
i < key_parts_to_free.size(); i++) {
|
|
||||||
jobject jk;
|
jobject jk;
|
||||||
jbyteArray jk_ba;
|
jbyteArray jk_ba;
|
||||||
jbyte* jk_val;
|
jbyte* jk_val;
|
||||||
std::tie(jk_ba, jk_val, jk) = key_parts_to_free[i];
|
std::tie(jk_ba, jk_val, jk) = value;
|
||||||
env->ReleaseByteArrayElements(jk_ba, jk_val, JNI_ABORT);
|
env->ReleaseByteArrayElements(jk_ba, jk_val, JNI_ABORT);
|
||||||
env->DeleteLocalRef(jk);
|
env->DeleteLocalRef(jk);
|
||||||
}
|
}
|
||||||
@ -295,7 +299,7 @@ jobjectArray txn_multi_get_helper(JNIEnv* env, const FnMultiGet& fn_multi_get,
|
|||||||
const jobject jk = env->GetObjectArrayElement(jkey_parts, i);
|
const jobject jk = env->GetObjectArrayElement(jkey_parts, i);
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
// exception thrown: ArrayIndexOutOfBoundsException
|
// exception thrown: ArrayIndexOutOfBoundsException
|
||||||
free_key_parts(env, key_parts_to_free);
|
free_parts(env, key_parts_to_free);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
jbyteArray jk_ba = reinterpret_cast<jbyteArray>(jk);
|
jbyteArray jk_ba = reinterpret_cast<jbyteArray>(jk);
|
||||||
@ -303,14 +307,14 @@ jobjectArray txn_multi_get_helper(JNIEnv* env, const FnMultiGet& fn_multi_get,
|
|||||||
if (env->EnsureLocalCapacity(len_key) != 0) {
|
if (env->EnsureLocalCapacity(len_key) != 0) {
|
||||||
// out of memory
|
// out of memory
|
||||||
env->DeleteLocalRef(jk);
|
env->DeleteLocalRef(jk);
|
||||||
free_key_parts(env, key_parts_to_free);
|
free_parts(env, key_parts_to_free);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
jbyte* jk_val = env->GetByteArrayElements(jk_ba, nullptr);
|
jbyte* jk_val = env->GetByteArrayElements(jk_ba, nullptr);
|
||||||
if (jk_val == nullptr) {
|
if (jk_val == nullptr) {
|
||||||
// exception thrown: OutOfMemoryError
|
// exception thrown: OutOfMemoryError
|
||||||
env->DeleteLocalRef(jk);
|
env->DeleteLocalRef(jk);
|
||||||
free_key_parts(env, key_parts_to_free);
|
free_parts(env, key_parts_to_free);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +331,7 @@ jobjectArray txn_multi_get_helper(JNIEnv* env, const FnMultiGet& fn_multi_get,
|
|||||||
fn_multi_get(*read_options, key_parts, &value_parts);
|
fn_multi_get(*read_options, key_parts, &value_parts);
|
||||||
|
|
||||||
// free up allocated byte arrays
|
// free up allocated byte arrays
|
||||||
free_key_parts(env, key_parts_to_free);
|
free_parts(env, key_parts_to_free);
|
||||||
|
|
||||||
// prepare the results
|
// prepare the results
|
||||||
const jclass jcls_ba = env->FindClass("[B");
|
const jclass jcls_ba = env->FindClass("[B");
|
||||||
@ -600,28 +604,6 @@ typedef std::function<rocksdb::Status(const rocksdb::SliceParts&,
|
|||||||
const rocksdb::SliceParts&)>
|
const rocksdb::SliceParts&)>
|
||||||
FnWriteKVParts;
|
FnWriteKVParts;
|
||||||
|
|
||||||
void free_key_value_parts(
|
|
||||||
JNIEnv* env, const int32_t len,
|
|
||||||
std::tuple<jbyteArray, jbyte*, jobject> jkey_parts_to_free[],
|
|
||||||
std::tuple<jbyteArray, jbyte*, jobject> jvalue_parts_to_free[]) {
|
|
||||||
for (int32_t i = len - 1; i >= 0; --i) {
|
|
||||||
jbyteArray jba_value_part;
|
|
||||||
jbyte* jvalue_part;
|
|
||||||
jobject jobj_value_part;
|
|
||||||
std::tie(jba_value_part, jvalue_part, jobj_value_part) =
|
|
||||||
jvalue_parts_to_free[i];
|
|
||||||
env->ReleaseByteArrayElements(jba_value_part, jvalue_part, JNI_ABORT);
|
|
||||||
env->DeleteLocalRef(jobj_value_part);
|
|
||||||
|
|
||||||
jbyteArray jba_key_part;
|
|
||||||
jbyte* jkey_part;
|
|
||||||
jobject jobj_key_part;
|
|
||||||
std::tie(jba_key_part, jkey_part, jobj_key_part) = jkey_parts_to_free[i];
|
|
||||||
env->ReleaseByteArrayElements(jba_key_part, jkey_part, JNI_ABORT);
|
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(AR) consider refactoring to share this between here and rocksjni.cc
|
// TODO(AR) consider refactoring to share this between here and rocksjni.cc
|
||||||
void txn_write_kv_parts_helper(JNIEnv* env,
|
void txn_write_kv_parts_helper(JNIEnv* env,
|
||||||
const FnWriteKVParts& fn_write_kv_parts,
|
const FnWriteKVParts& fn_write_kv_parts,
|
||||||
@ -631,27 +613,23 @@ void txn_write_kv_parts_helper(JNIEnv* env,
|
|||||||
const jint& jvalue_parts_len) {
|
const jint& jvalue_parts_len) {
|
||||||
assert(jkey_parts_len == jvalue_parts_len);
|
assert(jkey_parts_len == jvalue_parts_len);
|
||||||
|
|
||||||
rocksdb::Slice key_parts[jkey_parts_len];
|
auto key_parts = std::vector<rocksdb::Slice>();
|
||||||
rocksdb::Slice value_parts[jvalue_parts_len];
|
auto value_parts = std::vector<rocksdb::Slice>();
|
||||||
std::tuple<jbyteArray, jbyte*, jobject> jkey_parts_to_free[jkey_parts_len];
|
auto jparts_to_free = std::vector<std::tuple<jbyteArray, jbyte*, jobject>>();
|
||||||
std::tuple<jbyteArray, jbyte*, jobject>
|
|
||||||
jvalue_parts_to_free[jvalue_parts_len];
|
|
||||||
|
|
||||||
// convert java key_parts/value_parts byte[][] to Slice(s)
|
// convert java key_parts/value_parts byte[][] to Slice(s)
|
||||||
for (jsize i = 0; i < jkey_parts_len; ++i) {
|
for (jsize i = 0; i < jkey_parts_len; ++i) {
|
||||||
const jobject jobj_key_part = env->GetObjectArrayElement(jkey_parts, i);
|
const jobject jobj_key_part = env->GetObjectArrayElement(jkey_parts, i);
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
// exception thrown: ArrayIndexOutOfBoundsException
|
// exception thrown: ArrayIndexOutOfBoundsException
|
||||||
free_key_value_parts(env, jkey_parts_len, jkey_parts_to_free,
|
free_parts(env, jparts_to_free);
|
||||||
jvalue_parts_to_free);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const jobject jobj_value_part = env->GetObjectArrayElement(jvalue_parts, i);
|
const jobject jobj_value_part = env->GetObjectArrayElement(jvalue_parts, i);
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
// exception thrown: ArrayIndexOutOfBoundsException
|
// exception thrown: ArrayIndexOutOfBoundsException
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
env->DeleteLocalRef(jobj_key_part);
|
||||||
free_key_value_parts(env, jkey_parts_len, jkey_parts_to_free,
|
free_parts(env, jparts_to_free);
|
||||||
jvalue_parts_to_free);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,8 +639,7 @@ void txn_write_kv_parts_helper(JNIEnv* env,
|
|||||||
// out of memory
|
// out of memory
|
||||||
env->DeleteLocalRef(jobj_value_part);
|
env->DeleteLocalRef(jobj_value_part);
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
env->DeleteLocalRef(jobj_key_part);
|
||||||
free_key_value_parts(env, jkey_parts_len, jkey_parts_to_free,
|
free_parts(env, jparts_to_free);
|
||||||
jvalue_parts_to_free);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jbyte* jkey_part = env->GetByteArrayElements(jba_key_part, nullptr);
|
jbyte* jkey_part = env->GetByteArrayElements(jba_key_part, nullptr);
|
||||||
@ -670,8 +647,7 @@ void txn_write_kv_parts_helper(JNIEnv* env,
|
|||||||
// exception thrown: OutOfMemoryError
|
// exception thrown: OutOfMemoryError
|
||||||
env->DeleteLocalRef(jobj_value_part);
|
env->DeleteLocalRef(jobj_value_part);
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
env->DeleteLocalRef(jobj_key_part);
|
||||||
free_key_value_parts(env, jkey_parts_len, jkey_parts_to_free,
|
free_parts(env, jparts_to_free);
|
||||||
jvalue_parts_to_free);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,8 +658,7 @@ void txn_write_kv_parts_helper(JNIEnv* env,
|
|||||||
// out of memory
|
// out of memory
|
||||||
env->DeleteLocalRef(jobj_value_part);
|
env->DeleteLocalRef(jobj_value_part);
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
env->DeleteLocalRef(jobj_key_part);
|
||||||
free_key_value_parts(env, jkey_parts_len, jkey_parts_to_free,
|
free_parts(env, jparts_to_free);
|
||||||
jvalue_parts_to_free);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jbyte* jvalue_part = env->GetByteArrayElements(jba_value_part, nullptr);
|
jbyte* jvalue_part = env->GetByteArrayElements(jba_value_part, nullptr);
|
||||||
@ -692,30 +667,28 @@ void txn_write_kv_parts_helper(JNIEnv* env,
|
|||||||
env->ReleaseByteArrayElements(jba_value_part, jvalue_part, JNI_ABORT);
|
env->ReleaseByteArrayElements(jba_value_part, jvalue_part, JNI_ABORT);
|
||||||
env->DeleteLocalRef(jobj_value_part);
|
env->DeleteLocalRef(jobj_value_part);
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
env->DeleteLocalRef(jobj_key_part);
|
||||||
free_key_value_parts(env, jkey_parts_len, jkey_parts_to_free,
|
free_parts(env, jparts_to_free);
|
||||||
jvalue_parts_to_free);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
jkey_parts_to_free[i] = std::tuple<jbyteArray, jbyte*, jobject>(
|
jparts_to_free.push_back(std::make_tuple(
|
||||||
jba_key_part, jkey_part, jobj_key_part);
|
jba_key_part, jkey_part, jobj_key_part));
|
||||||
jvalue_parts_to_free[i] = std::tuple<jbyteArray, jbyte*, jobject>(
|
jparts_to_free.push_back(std::make_tuple(
|
||||||
jba_value_part, jvalue_part, jobj_value_part);
|
jba_value_part, jvalue_part, jobj_value_part));
|
||||||
|
|
||||||
key_parts[i] =
|
key_parts.push_back(
|
||||||
rocksdb::Slice(reinterpret_cast<char*>(jkey_part), jkey_part_len);
|
rocksdb::Slice(reinterpret_cast<char*>(jkey_part), jkey_part_len));
|
||||||
value_parts[i] =
|
value_parts.push_back(
|
||||||
rocksdb::Slice(reinterpret_cast<char*>(jvalue_part), jvalue_part_len);
|
rocksdb::Slice(reinterpret_cast<char*>(jvalue_part), jvalue_part_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
// call the write_multi function
|
// call the write_multi function
|
||||||
rocksdb::Status s =
|
rocksdb::Status s = fn_write_kv_parts(
|
||||||
fn_write_kv_parts(rocksdb::SliceParts(key_parts, jkey_parts_len),
|
rocksdb::SliceParts(key_parts.data(), (int)key_parts.size()),
|
||||||
rocksdb::SliceParts(value_parts, jvalue_parts_len));
|
rocksdb::SliceParts(value_parts.data(), (int)value_parts.size()));
|
||||||
|
|
||||||
// cleanup temporary memory
|
// cleanup temporary memory
|
||||||
free_key_value_parts(env, jkey_parts_len, jkey_parts_to_free,
|
free_parts(env, jparts_to_free);
|
||||||
jvalue_parts_to_free);
|
|
||||||
|
|
||||||
// return
|
// return
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
@ -857,33 +830,22 @@ void Java_org_rocksdb_Transaction_delete__J_3BI(JNIEnv* env, jobject /*jobj*/,
|
|||||||
typedef std::function<rocksdb::Status(const rocksdb::SliceParts&)>
|
typedef std::function<rocksdb::Status(const rocksdb::SliceParts&)>
|
||||||
FnWriteKParts;
|
FnWriteKParts;
|
||||||
|
|
||||||
void free_key_parts(
|
|
||||||
JNIEnv* env, const int32_t len,
|
|
||||||
std::tuple<jbyteArray, jbyte*, jobject> jkey_parts_to_free[]) {
|
|
||||||
for (int32_t i = len - 1; i >= 0; --i) {
|
|
||||||
jbyteArray jba_key_part;
|
|
||||||
jbyte* jkey;
|
|
||||||
jobject jobj_key_part;
|
|
||||||
std::tie(jba_key_part, jkey, jobj_key_part) = jkey_parts_to_free[i];
|
|
||||||
env->ReleaseByteArrayElements(jba_key_part, jkey, JNI_ABORT);
|
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(AR) consider refactoring to share this between here and rocksjni.cc
|
// TODO(AR) consider refactoring to share this between here and rocksjni.cc
|
||||||
void txn_write_k_parts_helper(JNIEnv* env,
|
void txn_write_k_parts_helper(JNIEnv* env,
|
||||||
const FnWriteKParts& fn_write_k_parts,
|
const FnWriteKParts& fn_write_k_parts,
|
||||||
const jobjectArray& jkey_parts,
|
const jobjectArray& jkey_parts,
|
||||||
const jint& jkey_parts_len) {
|
const jint& jkey_parts_len) {
|
||||||
rocksdb::Slice key_parts[jkey_parts_len];
|
|
||||||
std::tuple<jbyteArray, jbyte*, jobject> jkey_parts_to_free[jkey_parts_len];
|
std::vector<rocksdb::Slice> key_parts;
|
||||||
|
std::vector<std::tuple<jbyteArray, jbyte*, jobject>> jkey_parts_to_free;
|
||||||
|
|
||||||
// convert java key_parts byte[][] to Slice(s)
|
// convert java key_parts byte[][] to Slice(s)
|
||||||
for (jint i = 0; i < jkey_parts_len; ++i) {
|
for (jint i = 0; i < jkey_parts_len; ++i) {
|
||||||
const jobject jobj_key_part = env->GetObjectArrayElement(jkey_parts, i);
|
const jobject jobj_key_part = env->GetObjectArrayElement(jkey_parts, i);
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
// exception thrown: ArrayIndexOutOfBoundsException
|
// exception thrown: ArrayIndexOutOfBoundsException
|
||||||
free_key_parts(env, jkey_parts_len, jkey_parts_to_free);
|
free_parts(env, jkey_parts_to_free);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,30 +854,29 @@ void txn_write_k_parts_helper(JNIEnv* env,
|
|||||||
if (env->EnsureLocalCapacity(jkey_part_len) != 0) {
|
if (env->EnsureLocalCapacity(jkey_part_len) != 0) {
|
||||||
// out of memory
|
// out of memory
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
env->DeleteLocalRef(jobj_key_part);
|
||||||
free_key_parts(env, jkey_parts_len, jkey_parts_to_free);
|
free_parts(env, jkey_parts_to_free);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jbyte* jkey_part = env->GetByteArrayElements(jba_key_part, nullptr);
|
jbyte* jkey_part = env->GetByteArrayElements(jba_key_part, nullptr);
|
||||||
if (jkey_part == nullptr) {
|
if (jkey_part == nullptr) {
|
||||||
// exception thrown: OutOfMemoryError
|
// exception thrown: OutOfMemoryError
|
||||||
env->DeleteLocalRef(jobj_key_part);
|
env->DeleteLocalRef(jobj_key_part);
|
||||||
free_key_parts(env, jkey_parts_len, jkey_parts_to_free);
|
free_parts(env, jkey_parts_to_free);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
jkey_parts_to_free[i] = std::tuple<jbyteArray, jbyte*, jobject>(
|
jkey_parts_to_free.push_back(std::tuple<jbyteArray, jbyte*, jobject>(
|
||||||
jba_key_part, jkey_part, jobj_key_part);
|
jba_key_part, jkey_part, jobj_key_part));
|
||||||
|
|
||||||
key_parts[i] =
|
key_parts.push_back(rocksdb::Slice(reinterpret_cast<char*>(jkey_part), jkey_part_len));
|
||||||
rocksdb::Slice(reinterpret_cast<char*>(jkey_part), jkey_part_len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call the write_multi function
|
// call the write_multi function
|
||||||
rocksdb::Status s =
|
rocksdb::Status s =
|
||||||
fn_write_k_parts(rocksdb::SliceParts(key_parts, jkey_parts_len));
|
fn_write_k_parts(rocksdb::SliceParts(key_parts.data(), (int)key_parts.size()));
|
||||||
|
|
||||||
// cleanup temporary memory
|
// cleanup temporary memory
|
||||||
free_key_parts(env, jkey_parts_len, jkey_parts_to_free);
|
free_parts(env, jkey_parts_to_free);
|
||||||
|
|
||||||
// return
|
// return
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
@ -1582,7 +1543,7 @@ jbyte Java_org_rocksdb_Transaction_getState(JNIEnv* /*env*/, jobject /*jobj*/,
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
return 0xFF;
|
return static_cast<jbyte>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -269,7 +269,7 @@ jlongArray Java_org_rocksdb_TransactionDB_getAllPreparedTransactions(
|
|||||||
assert(size < UINT32_MAX); // does it fit in a jint?
|
assert(size < UINT32_MAX); // does it fit in a jint?
|
||||||
|
|
||||||
const jsize len = static_cast<jsize>(size);
|
const jsize len = static_cast<jsize>(size);
|
||||||
jlong tmp[len];
|
std::vector<jlong> tmp(len);
|
||||||
for (jsize i = 0; i < len; ++i) {
|
for (jsize i = 0; i < len; ++i) {
|
||||||
tmp[i] = reinterpret_cast<jlong>(txns[i]);
|
tmp[i] = reinterpret_cast<jlong>(txns[i]);
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ jlongArray Java_org_rocksdb_TransactionDB_getAllPreparedTransactions(
|
|||||||
// exception thrown: OutOfMemoryError
|
// exception thrown: OutOfMemoryError
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
env->SetLongArrayRegion(jtxns, 0, len, tmp);
|
env->SetLongArrayRegion(jtxns, 0, len, tmp.data());
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
// exception thrown: ArrayIndexOutOfBoundsException
|
// exception thrown: ArrayIndexOutOfBoundsException
|
||||||
env->DeleteLocalRef(jtxns);
|
env->DeleteLocalRef(jtxns);
|
||||||
|
@ -688,7 +688,7 @@ public abstract class AbstractTransactionTest {
|
|||||||
final long preStartTxnTime = System.currentTimeMillis();
|
final long preStartTxnTime = System.currentTimeMillis();
|
||||||
try(final DBContainer dbContainer = startDb();
|
try(final DBContainer dbContainer = startDb();
|
||||||
final Transaction txn = dbContainer.beginTransaction()) {
|
final Transaction txn = dbContainer.beginTransaction()) {
|
||||||
Thread.sleep(1);
|
Thread.sleep(2);
|
||||||
|
|
||||||
final long txnElapsedTime = txn.getElapsedTime();
|
final long txnElapsedTime = txn.getElapsedTime();
|
||||||
assertThat(txnElapsedTime).isLessThan(System.currentTimeMillis()
|
assertThat(txnElapsedTime).isLessThan(System.currentTimeMillis()
|
||||||
|
Loading…
Reference in New Issue
Block a user