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

Method RegexpMatchCountPrepare

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

Source from the content-addressed store, hash-verified

1150}
1151
1152void StringFunctions::RegexpMatchCountPrepare(FunctionContext* context,
1153 FunctionContext::FunctionStateScope scope) {
1154 if (scope != FunctionContext::THREAD_LOCAL) return;
1155 int num_args = context->GetNumArgs();
1156 DCHECK(num_args == 2 || num_args == 4);
1157 if (!context->IsArgConstant(1) || (num_args == 4 && !context->IsArgConstant(3))) return;
1158
1159 DCHECK_EQ(context->GetArgType(1)->type, FunctionContext::TYPE_STRING);
1160 StringVal* pattern = reinterpret_cast<StringVal*>(context->GetConstantArg(1));
1161 if (pattern->is_null) return;
1162
1163 StringVal* match_parameter = NULL;
1164 if (num_args == 4) {
1165 DCHECK_EQ(context->GetArgType(3)->type, FunctionContext::TYPE_STRING);
1166 match_parameter = reinterpret_cast<StringVal*>(context->GetConstantArg(3));
1167 }
1168 string error_str;
1169 re2::RE2* re = CompileRegex(*pattern, &error_str, match_parameter == NULL ?
1170 StringVal::null() : *match_parameter);
1171 if (re == NULL) {
1172 context->SetError(error_str.c_str());
1173 return;
1174 }
1175 context->SetFunctionState(scope, re);
1176}
1177
1178IntVal StringFunctions::RegexpMatchCount2Args(FunctionContext* context,
1179 const StringVal& str, const StringVal& pattern) {

Callers

nothing calls this directly

Calls 7

CompileRegexFunction · 0.85
GetNumArgsMethod · 0.80
IsArgConstantMethod · 0.80
GetArgTypeMethod · 0.80
GetConstantArgMethod · 0.80
SetFunctionStateMethod · 0.80
SetErrorMethod · 0.45

Tested by

no test coverage detected