15 #ifndef IMPALA_RPC_JNI_THRIFT_UTIL_H
16 #define IMPALA_RPC_JNI_THRIFT_UTIL_H
28 int buffer_size = 100 * 1024;
31 uint8_t* buffer = NULL;
36 *serialized_msg = env->NewByteArray(size);
38 if (*serialized_msg == NULL)
return Status(
"couldn't construct jbyteArray");
39 env->SetByteArrayRegion(*serialized_msg, 0, size, reinterpret_cast<jbyte*>(buffer));
46 jboolean is_copy =
false;
47 uint32_t buf_size = env->GetArrayLength(serialized_msg);
48 jbyte* buf = env->GetByteArrayElements(serialized_msg, &is_copy);
51 reinterpret_cast<uint8_t*>(buf), &buf_size,
false, deserialized_msg));
55 env->ReleaseByteArrayElements(serialized_msg, buf, JNI_ABORT);
#define RETURN_IF_ERROR(stmt)
some generally useful macros
Status Serialize(T *obj, std::vector< uint8_t > *result)
Serializes obj into result. Result will contain a copy of the memory.
#define RETURN_ERROR_IF_EXC(env)
Status DeserializeThriftMsg(JNIEnv *env, jbyteArray serialized_msg, T *deserialized_msg)
Status SerializeThriftMsg(JNIEnv *env, T *msg, jbyteArray *serialized_msg)