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

Method DoTrimPrepare

be/src/exprs/string-functions-ir.cc:757–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755}
756
757void StringFunctions::DoTrimPrepare(FunctionContext* context,
758 FunctionContext::FunctionStateScope scope, bool utf8_mode) {
759 if (scope != FunctionContext::THREAD_LOCAL) return;
760 TrimContext* trim_ctx = new TrimContext(utf8_mode);
761 context->SetFunctionState(scope, trim_ctx);
762
763 // If the caller didn't specify the set of characters to trim, it means
764 // that we're only trimming whitespace. Return early in that case.
765 // There can be either 1 or 2 arguments.
766 DCHECK(context->GetNumArgs() == 1 || context->GetNumArgs() == 2);
767 if (context->GetNumArgs() == 1) {
768 trim_ctx->Reset(StringVal(" "));
769 return;
770 }
771 if (!context->IsArgConstant(1)) return;
772 DCHECK_EQ(context->GetArgType(1)->type, FunctionContext::TYPE_STRING);
773 StringVal* chars_to_trim = reinterpret_cast<StringVal*>(context->GetConstantArg(1));
774 if (chars_to_trim->is_null) return; // We shouldn't peek into Null StringVals
775 trim_ctx->Reset(*chars_to_trim);
776}
777
778void StringFunctions::TrimClose(
779 FunctionContext* context, FunctionContext::FunctionStateScope scope) {

Callers

nothing calls this directly

Calls 7

StringValClass · 0.85
SetFunctionStateMethod · 0.80
GetNumArgsMethod · 0.80
IsArgConstantMethod · 0.80
GetArgTypeMethod · 0.80
GetConstantArgMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected