Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-5939

StringConcatUpdate() UDA example uses StringVal::CopyFrom() incorrectly.

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: Impala 2.10.0
    • Fix Version/s: None
    • Component/s: Backend
    • Labels:
      None

      Description

      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().

      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;
        }
      }
      

      The bug was fixed in a different repo years ago.
      https://github.com/cloudera/impala-udf-samples/commit/3fce648fddb6c41e09572e0de89d3a83b394d47a

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tarmstrong Tim Armstrong
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: