29 #include "gen-cpp/Frontend_types.h"
33 const char*
EXECUTOR_CLASS =
"com/cloudera/impala/hive/executor/UdfExecutor";
69 input_buffer_size_(0) {
70 DCHECK_EQ(node.node_type, TExprNodeType::FUNCTION_CALL);
71 DCHECK_EQ(node.fn.binary_type, TFunctionBinaryType::HIVE);
78 DCHECK(jni_ctx != NULL);
83 ss <<
"Hive UDF path=" <<
fn_.hdfs_location <<
" class=" <<
fn_.scalar_fn.symbol
84 <<
" failed due to JNI issue getting the JNIEnv object";
103 memcpy(input_ptr, v, 1);
106 memcpy(input_ptr, v, 2);
110 memcpy(input_ptr, v, 4);
114 memcpy(input_ptr, v, 8);
119 memcpy(input_ptr, v, 16);
122 DCHECK(
false) <<
"NYI";
129 env->CallNonvirtualVoidMethodA(
135 ss <<
"Hive UDF path=" <<
fn_.hdfs_location <<
" class=" <<
fn_.scalar_fn.symbol
136 <<
" failed due to: " << status.
GetDetail();
186 if (env == NULL)
return Status(
"Failed to get/create JVM");
189 jmethodID executor_ctor = env->GetMethodID(
195 jni_ctx->
close_id = env->GetMethodID(
199 THiveUdfExecutorCtorParams ctor_params;
200 ctor_params.fn =
fn_;
213 jbyteArray ctor_params_bytes;
222 jni_ctx->
executor = env->NewObject(jni_ctx->
cl,
223 executor_ctor, ctor_params_bytes);
238 if (jni_ctx != NULL) {
241 env->CallNonvirtualVoidMethodA(
243 env->DeleteGlobalRef(jni_ctx->
executor);
277 out <<
"HiveUdfCall(hdfs_location=" <<
fn_.hdfs_location
278 <<
" classname=" <<
fn_.scalar_fn.symbol <<
" "
AnyVal * CreateAnyVal(ObjectPool *pool, const ColumnType &type)
Creates the corresponding AnyVal subclass for type. The object is added to the pool.
uint8_t * output_value_buffer
const std::string GetDetail() const
virtual TimestampVal GetTimestampVal(ExprContext *ctx, TupleRow *)
virtual BooleanVal GetBooleanVal(ExprContext *ctx, TupleRow *)
virtual Status Open(RuntimeState *state, ExprContext *context, FunctionContext::FunctionStateScope scope=FunctionContext::FRAGMENT_LOCAL)
static Status Open(const std::vector< ExprContext * > &ctxs, RuntimeState *state)
Convenience function for opening multiple expr trees.
#define RETURN_IF_ERROR(stmt)
some generally useful macros
void * GetValue(TupleRow *row)
AnyVal * Evaluate(ExprContext *ctx, TupleRow *row)
virtual IntVal GetIntVal(ExprContext *ctx, TupleRow *)
uint8_t * input_nulls_buffer
int GetSlotSize() const
Returns the size of a slot for this type.
This object has a compatible storage format with boost::ptime.
virtual DecimalVal GetDecimalVal(ExprContext *ctx, TupleRow *)
uint8_t * input_values_buffer
static void Close(const std::vector< ExprContext * > &ctxs, RuntimeState *state)
Convenience function for closing multiple expr trees.
virtual TinyIntVal GetTinyIntVal(ExprContext *ctx, TupleRow *)
bool AddWarning(const char *warning_msg)
static Status GetJniExceptionMsg(JNIEnv *env, bool log_stack=true, const std::string &prefix="")
const char * EXECUTOR_CLOSE_SIGNATURE
Status GetCodegendComputeFnWrapper(RuntimeState *state, llvm::Function **fn)
const char * EXECUTOR_CLASS
void * GetFunctionState(FunctionStateScope scope) const
static uint32_t RoundUpNumBytes(uint32_t bits)
std::vector< int > input_byte_offsets_
virtual FloatVal GetFloatVal(ExprContext *ctx, TupleRow *)
HiveUdfCall(const TExprNode &node)
This is the superclass of all expr evaluation nodes.
static LibCache * instance()
const char * EXECUTOR_EVALUATE_SIGNATURE
Status push(JNIEnv *env, int max_local_ref=10)
void SetFunctionState(FunctionStateScope scope, void *ptr)
virtual void Close(RuntimeState *state, ExprContext *context, FunctionContext::FunctionStateScope scope=FunctionContext::FRAGMENT_LOCAL)
Subclasses overriding this function should call Expr::Close().
virtual DoubleVal GetDoubleVal(ExprContext *ctx, TupleRow *)
Expr * GetChild(int i) const
const char * EXECUTOR_CTOR_SIGNATURE
const RowDescriptor & row_desc() const
virtual BigIntVal GetBigIntVal(ExprContext *ctx, TupleRow *)
TFunction fn_
Function description.
#define RETURN_ERROR_IF_EXC(env)
std::string local_location_
The path on the local FS to the UDF's jar.
virtual SmallIntVal GetSmallIntVal(ExprContext *ctx, TupleRow *)
const ColumnType & type() const
virtual Status Prepare(RuntimeState *state, const RowDescriptor &row_desc, ExprContext *ctx)
virtual std::string DebugString() const
static Status GetGlobalClassRef(JNIEnv *env, const char *class_str, jclass *class_ref)
uint8_t output_null_value
virtual Status GetCodegendComputeFn(RuntimeState *state, llvm::Function **fn)
const ColumnType type_
analysis is done, types are fixed at this point
FunctionContext * fn_context(int i)
virtual StringVal GetStringVal(ExprContext *ctx, TupleRow *)
static Status Prepare(const std::vector< ExprContext * > &ctxs, RuntimeState *state, const RowDescriptor &row_desc, MemTracker *tracker)
Status SerializeThriftMsg(JNIEnv *env, T *msg, jbyteArray *serialized_msg)
void SetError(const char *error_msg)
int input_buffer_size_
The size of the buffer for passing in input arguments.
virtual std::string DebugString() const
static void SetAnyVal(const void *slot, const ColumnType &type, AnyVal *dst)
Utility to put val into an AnyVal struct.
int GetNumChildren() const
FunctionContext * RegisterFunctionContext(ExprContext *ctx, RuntimeState *state, int varargs_buffer_size=0)
JNIEnv * getJNIEnv(void)
C linkage for helper functions in hdfsJniHelper.h.