Skip to content

Commit

Permalink
Fix formating and build on linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhubner committed Dec 6, 2023
1 parent ac645b0 commit 4ee45b5
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 176 deletions.
2 changes: 2 additions & 0 deletions java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ set(JAVA_TEST_CLASSES
src/test/java/org/rocksdb/WalFilterTest.java
src/test/java/org/rocksdb/AbstractTransactionTest.java
src/test/java/org/rocksdb/MergeTest.java
src/test/java/org/rocksdb/MergeOperatorV2Test.java
src/test/java/org/rocksdb/OptionsTest.java
src/test/java/org/rocksdb/WriteBatchThreadedTest.java
src/test/java/org/rocksdb/MultiGetManyKeysTest.java
Expand Down Expand Up @@ -430,6 +431,7 @@ set(JAVA_TEST_RUNNING_CLASSES
org.rocksdb.SnapshotTest
org.rocksdb.CompactionJobStatsTest
org.rocksdb.MemTableTest
org.rocksdb.MergeOperatorV2Test
org.rocksdb.CompactionFilterFactoryTest
# org.rocksdb.DefaultEnvTest
org.rocksdb.DBOptionsTest
Expand Down
15 changes: 5 additions & 10 deletions java/rocksjni/jni_merge_operator_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// Created by rhubner on 29-Nov-23.
//

#include "include/org_rocksdb_MergeOperatorV2.h"
#include "jni_merge_operator_v2.h"
#include "include/org_rocksdb_MergeOperatorV2.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
#include <iostream>


jlong Java_org_rocksdb_MergeOperatorV2_toCString
(JNIEnv* env, jclass, jstring operator_name) {
Expand All @@ -18,7 +16,7 @@ jlong Java_org_rocksdb_MergeOperatorV2_toCString
auto operator_name_len = env->GetStringUTFLength(operator_name);

char* ret_value = new char[operator_name_len + 1];
strcpy_s(ret_value, operator_name_len + 1, operator_name_utf);
memcpy(ret_value, operator_name_utf, operator_name_len + 1);

env->ReleaseStringUTFChars(operator_name, operator_name_utf);

Expand Down Expand Up @@ -105,7 +103,6 @@ JniMergeOperatorV2::JniMergeOperatorV2(JNIEnv* env, jobject java_merge_operator,
return ;
}


return ;
}

Expand All @@ -120,13 +117,11 @@ bool JniMergeOperatorV2::FullMergeV2(const MergeOperationInput &merge_in, MergeO
return clean_and_return_error(attached_thread, merge_out);
}

for(int i = 0; i < merge_in.operand_list.size(); i++) {
//TODO - Setup array
for (auto i = 0u; i < merge_in.operand_list.size(); i++) {
auto operand = merge_in.operand_list[i];
//auto byte_buffer = env->NewDirectByteBuffer((void *)operand.data(), operand.size()); //TODO - replace with C++ cast
auto byte_buffer = env->NewDirectByteBuffer(
const_cast<void*>(reinterpret_cast<const void*>(operand.data())),
operand.size()); //TODO - replace with C++ cast
operand.size());

if(byte_buffer == nullptr) {
return clean_and_return_error(attached_thread, merge_out);
Expand Down Expand Up @@ -204,7 +199,7 @@ bool JniMergeOperatorV2::clean_and_return_error(jboolean& attached_thread, Merge
return false;
}

const MergeOperator::OpFailureScope JniMergeOperatorV2::javaToOpFailureScope(jint failure) const {
MergeOperator::OpFailureScope JniMergeOperatorV2::javaToOpFailureScope(jint failure) const {
switch (failure) {
case 0: return MergeOperator::OpFailureScope::kDefault;
case 1: return MergeOperator::OpFailureScope::kTryMerge;
Expand Down
2 changes: 1 addition & 1 deletion java/rocksjni/jni_merge_operator_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class JniMergeOperatorV2 : public JniCallback,
~JniMergeOperatorV2() override;

private:
const MergeOperator::OpFailureScope javaToOpFailureScope(jint failure) const;
MergeOperator::OpFailureScope javaToOpFailureScope(jint failure) const;
bool clean_and_return_error(jboolean& attached_thread, MergeOperationOutput *merge_out) const;
jclass j_merge_class;
jclass j_byte_buffer_class;
Expand Down
Loading

0 comments on commit 4ee45b5

Please sign in to comment.