impala-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Behm (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (IMPALA-3497) Consider passing reference in JNI to java code
Date Tue, 13 Jun 2017 06:32:00 GMT

     [ https://issues.apache.org/jira/browse/IMPALA-3497?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexander Behm resolved IMPALA-3497.
------------------------------------
    Resolution: Duplicate

Duplicates IMPALA-3708

> Consider passing reference in JNI to java code
> ----------------------------------------------
>
>                 Key: IMPALA-3497
>                 URL: https://issues.apache.org/jira/browse/IMPALA-3497
>             Project: IMPALA
>          Issue Type: Improvement
>          Components: Backend
>    Affects Versions: Impala 2.5.0
>            Reporter: Huaisi Xu
>            Priority: Minor
>
> {code:java}
> template <class T>
> Status SerializeThriftMsg(JNIEnv* env, T* msg, jbyteArray* serialized_msg) {
>   int buffer_size = 100 * 1024;  // start out with 100KB
>   ThriftSerializer serializer(false, buffer_size);
>   uint8_t* buffer = NULL;
>   uint32_t size = 0;
>   RETURN_IF_ERROR(serializer.Serialize<T>(msg, &size, &buffer));
>   /// create jbyteArray given buffer
>   *serialized_msg = env->NewByteArray(size);
>   RETURN_ERROR_IF_EXC(env);
>   if (*serialized_msg == NULL) return Status("couldn't construct jbyteArray");
>   env->SetByteArrayRegion(*serialized_msg, 0, size, reinterpret_cast<jbyte*>(buffer));
>   RETURN_ERROR_IF_EXC(env);
>   return Status::OK();
> }
> {code}
> SetByteArrayRegion will copy everything in buffer to serialized_msg If java code will
make a copy of serialized_msg again? Is it possible to use other JNI api that only passes
reference?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message