You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@impala.apache.org by "Tim Armstrong (JIRA)" <ji...@apache.org> on 2017/09/14 21:36:00 UTC
[jira] [Created] (IMPALA-5939) StringConcatUpdate() UDA example
uses StringVal::CopyFrom() incorrectly.
Tim Armstrong created IMPALA-5939:
-------------------------------------
Summary: StringConcatUpdate() UDA example uses StringVal::CopyFrom() incorrectly.
Key: IMPALA-5939
URL: https://issues.apache.org/jira/browse/IMPALA-5939
Project: IMPALA
Issue Type: Bug
Components: Backend
Affects Versions: Impala 2.10.0
Reporter: Tim Armstrong
http://community.cloudera.com/t5/Interactive-Short-cycle-SQL/Memory-handling-in-Impala-UDA-functions/m-p/59877#M3574?eid=1&aid=1 pointed out that StringConcatUpdate() uses a local allocation to store the intermediate value (returned from StringVal::CopyFrom()) when it show be using a non-local allocation from Allocate().
{code}
void StringConcatUpdate(FunctionContext* context, const StringVal& arg1,
const StringVal& arg2, StringVal* val) {
if (val->is_null) {
val->is_null = false;
*val = StringVal::CopyFrom(context, arg1.ptr, arg1.len);
} else {
int new_len = val->len + arg1.len + arg2.len;
StringVal new_val(context, new_len);
if (!new_val.is_null) {
memcpy(new_val.ptr, val->ptr, val->len);
memcpy(new_val.ptr + val->len, arg2.ptr, arg2.len);
memcpy(new_val.ptr + val->len + arg2.len, arg1.ptr, arg1.len);
}
*val = new_val;
}
}
{code}
The bug was fixed in a different repo years ago.
https://github.com/cloudera/impala-udf-samples/commit/3fce648fddb6c41e09572e0de89d3a83b394d47a
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)