uda-sample.cc
// A serialize function is necesary to free the intermediate state allocation. We use the
// StringVal constructor to allocate memory owned by Impala, copy the intermediate state,
// and free the original allocation. Note that memory allocated by the StringVal ctor is
// not necessarily persisted across UDA function calls, which is why we don't use it in
// AvgInit().
A serialize function is necesary to free the intermediate state allocation. We use the
StringVal constructor to allocate memory owned by Impala, copy the intermediate state,
and free the original allocation. Note that memory allocated by the StringVal ctor is
not necessarily persisted across UDA function calls, which is why we don't use it in
AvgInit().
A serialize function is necesary to free the intermediate state allocation . We use the StringVal constructor to allocate memory owned by Impala copy the intermediate state and free the original allocation . Note that memory allocated by the StringVal ctor is not necessarily persisted across UDA function calls which is why we don ' t use it in AvgInit () .
StringVal AvgSerialize(FunctionContext* context, const StringVal& val) {
  if (val.is_null) return StringVal::null();
  StringVal result = StringVal::CopyFrom(context, val.ptr, val.len);
  context->Free(val.ptr);
  return result;
}
StringVal AvgSerialize ( FunctionContext * context , const StringVal & val ) { if ( val . is_null ) return StringVal :: null ( ) ; StringVal result = StringVal :: CopyFrom ( context , val . ptr , val . len ) ; context -> Free ( val . ptr ) ; return result ; }
A serialize function is necesary to free the intermediate state allocation.
A serialize function is necesary to free the intermediate state allocation .
// Copy the value into Impala-managed memory with StringVal::CopyFrom(). // NB: CopyFrom() will return a null StringVal and and fail the query if the allocation // fails because of lack of memory.