MCPcopy Create free account
hub / github.com/apache/impala / CopyStringVal

Function CopyStringVal

be/src/exprs/aggregate-functions-ir.cc:167–181  ·  view source on GitHub ↗

This function initializes StringVal 'dst' with a newly allocated buffer of 'buf_len' bytes and copies the content of StringVal 'src' into it. If allocation fails, 'dst' will be set to a null string.

Source from the content-addressed store, hash-verified

165// 'buf_len' bytes and copies the content of StringVal 'src' into it.
166// If allocation fails, 'dst' will be set to a null string.
167static void CopyStringVal(FunctionContext* ctx, const StringVal& src, StringVal* dst) {
168 if (src.is_null) {
169 *dst = StringVal::null();
170 } else {
171 uint8_t* copy = ctx->Allocate(src.len);
172 if (UNLIKELY(copy == NULL)) {
173 // Zero-length allocation always returns a hard-coded pointer.
174 DCHECK(src.len != 0 && !ctx->impl()->state()->GetQueryStatus().ok());
175 *dst = StringVal::null();
176 } else {
177 *dst = StringVal(copy, src.len);
178 memcpy(dst->ptr, src.ptr, src.len);
179 }
180 }
181}
182
183// Converts any UDF Val Type to a string representation
184template <typename T>

Callers 7

MinMethod · 0.85
MaxMethod · 0.85
AggIfUpdateMethod · 0.85
AggIfMergeMethod · 0.85
FirstValUpdateMethod · 0.85
OffsetFnInitMethod · 0.85

Calls 6

StringValClass · 0.85
implMethod · 0.80
AllocateMethod · 0.45
okMethod · 0.45
GetQueryStatusMethod · 0.45
stateMethod · 0.45

Tested by

no test coverage detected