Skip to content

Commit 08a20b7

Browse files
ARROW-17086: [C++] Install java/dataset include file and fix debug build failed by compiler flag (apache#13614)
Arrow8 will install jni_util.h, but Arrow9 not, cause our project fail when upgraded to Arrow 9 And if use cmake --preset ninja-debug \ -DARROW_BUILD_SHARED=ON \ -DARROW_GANDIVA_JAVA=ON \ -DARROW_GANDIVA=ON it will failed with this error, fix it arrow/cpp/src/gandiva/jni/expression_registry_helper.cc:157:78: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32] gandiva_data_types.SerializeToArray(reinterpret_cast<void*>(buffer.get()), size); Lead-authored-by: Chengcheng Jin <chengcheng.jin@intel.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
1 parent b309834 commit 08a20b7

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎cpp/src/gandiva/jni/expression_registry_helper.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Java_org_apache_arrow_gandiva_evaluator_ExpressionRegistryJniHelper_getGandivaSu
152152
types::ExtGandivaType* gandiva_data_type = gandiva_data_types.add_datatype();
153153
ArrowToProtobuf(type, gandiva_data_type);
154154
}
155-
auto size = gandiva_data_types.ByteSizeLong();
155+
auto size = static_cast<int>(gandiva_data_types.ByteSizeLong());
156156
std::unique_ptr<jbyte[]> buffer{new jbyte[size]};
157157
gandiva_data_types.SerializeToArray(reinterpret_cast<void*>(buffer.get()), size);
158158
jbyteArray ret = env->NewByteArray(size);
@@ -181,7 +181,7 @@ Java_org_apache_arrow_gandiva_evaluator_ExpressionRegistryJniHelper_getGandivaSu
181181
ArrowToProtobuf(param_type, proto_param_type);
182182
}
183183
}
184-
auto size = gandiva_functions.ByteSizeLong();
184+
auto size = static_cast<int>(gandiva_functions.ByteSizeLong());
185185
std::unique_ptr<jbyte[]> buffer{new jbyte[size]};
186186
gandiva_functions.SerializeToArray(reinterpret_cast<void*>(buffer.get()), size);
187187
jbyteArray ret = env->NewByteArray(size);

‎java/dataset/src/main/cpp/CMakeLists.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ add_arrow_test(dataset_jni_test
6363
jni_util.cc
6464
EXTRA_INCLUDES
6565
${JNI_INCLUDE_DIRS})
66+
67+
install(FILES jni_util.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/jni/dataset")

‎java/dataset/src/main/cpp/jni_util.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ arrow::Result<jbyteArray> ToSchemaByteArray(JNIEnv* env,
321321
std::shared_ptr<arrow::Buffer> buffer,
322322
arrow::ipc::SerializeSchema(*schema, arrow::default_memory_pool()))
323323

324-
jbyteArray out = env->NewByteArray(buffer->size());
324+
jbyteArray out = env->NewByteArray(static_cast<int>(buffer->size()));
325325
auto src = reinterpret_cast<const jbyte*>(buffer->data());
326-
env->SetByteArrayRegion(out, 0, buffer->size(), src);
326+
env->SetByteArrayRegion(out, 0, static_cast<int>(buffer->size()), src);
327327
return out;
328328
}
329329

‎java/dataset/src/main/cpp/jni_wrapper.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class JniPendingException : public std::runtime_error {
4949
explicit JniPendingException(const std::string& arg, jthrowable cause)
5050
: runtime_error(arg), cause_(cause) {}
5151

52-
const jthrowable GetCause() const { return cause_; }
53-
const bool HasCause() const { return cause_ != nullptr; }
52+
jthrowable GetCause() const { return cause_; }
53+
bool HasCause() const { return cause_ != nullptr; }
5454

5555
private:
5656
jthrowable cause_;

0 commit comments

Comments
 (0)