Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::RegexpExtractAll Struct Reference

Static Public Member Functions

static void Execute (DataChunk &args, ExpressionState &state, Vector &result)
static unique_ptr< FunctionData > Bind (ClientContext &context, ScalarFunction &bound_function, vector< unique_ptr< Expression > > &arguments)
static unique_ptr< FunctionLocalState > InitLocalState (ExpressionState &state, const BoundFunctionExpression &expr, FunctionData *bind_data)

Member Function Documentation

◆ Execute()

void duckdb::RegexpExtractAll::Execute ( DataChunk & args,
ExpressionState & state,
Vector & result )
static
234035 {
234036 auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
234037 const auto &info = func_expr.bind_info->Cast<RegexpBaseBindData>();
234038
234039 auto &strings = args.data[0];
234040 auto &patterns = args.data[1];
234041 D_ASSERT(result.GetType().id() == LogicalTypeId::LIST);
234042 auto &output_child = ListVector::GetEntry(result);
234043
234044 UnifiedVectorFormat strings_data;
234045 strings.ToUnifiedFormat(args.size(), strings_data);
234046
234047 UnifiedVectorFormat pattern_data;
234048 patterns.ToUnifiedFormat(args.size(), pattern_data);
234049
234050 ListVector::Reserve(result, STANDARD_VECTOR_SIZE);
234051 // Reference the 'strings' StringBuffer, because we won't need to allocate new data
234052 // for the result, all returned strings are substrings of the originals
234053 output_child.SetAuxiliary(strings.GetAuxiliary());
234054
234055 // Avoid doing extra work if all the inputs are constant
234056 idx_t tuple_count = args.AllConstant() ? 1 : args.size();
234057
234058 unique_ptr<RegexStringPieceArgs> non_const_args;
234059 unique_ptr<duckdb_re2::RE2> stored_re;
234060 if (!info.constant_pattern) {
234061 non_const_args = make_uniq<RegexStringPieceArgs>();
234062 } else {
234063 // Verify that the constant pattern is valid
234064 auto &re = GetPattern(info, state, stored_re);
234065 auto group_count_p = re.NumberOfCapturingGroups();
234066 if (group_count_p == -1) {
234067 throw InvalidInputException("Pattern failed to parse, error: '%s'", re.error());
234068 }
234069 }
234070
234071 for (idx_t row = 0; row < tuple_count; row++) {
234072 bool pattern_valid = true;
234073 if (!info.constant_pattern) {
234074 // Check if the pattern is NULL or not,
234075 // and compile the pattern if it's not constant
234076 auto pattern_idx = pattern_data.sel->get_index(row);
234077 if (!pattern_data.validity.RowIsValid(pattern_idx)) {
234078 pattern_valid = false;
234079 } else {
234080 auto &pattern_p = UnifiedVectorFormat::GetData<string_t>(pattern_data)[pattern_idx];
234081 auto pattern_strpiece = CreateStringPiece(pattern_p);
234082 stored_re = make_uniq<duckdb_re2::RE2>(pattern_strpiece, info.options);
234083
234084 // Increase the size of the args buffer if needed
234085 auto group_count_p = stored_re->NumberOfCapturingGroups();
234086 if (group_count_p == -1) {
234087 throw InvalidInputException("Pattern failed to parse, error: '%s'", stored_re->error());
234088 }
234089 non_const_args->SetSize(UnsafeNumericCast<idx_t>(group_count_p));
234090 }
234091 }
234092
234093 auto string_idx = strings_data.sel->get_index(row);
234094 int32_t group_index;
234095 if (!pattern_valid || !strings_data.validity.RowIsValid(string_idx) || !GetGroupIndex(args, row, group_index)) {
234096 // If something is NULL, the result is NULL
234097 // FIXME: do we even need 'SPECIAL_HANDLING'?
234098 auto result_data = FlatVector::GetData<list_entry_t>(result);
234099 auto &result_validity = FlatVector::Validity(result);
234100 result_data[row].length = 0;
234101 result_data[row].offset = ListVector::GetListSize(result);
234102 result_validity.SetInvalid(row);
234103 continue;
234104 }
234105
234106 auto &re = GetPattern(info, state, stored_re);
234107 auto &groups = GetGroupsBuffer(info, state, non_const_args);
234108 auto &string = UnifiedVectorFormat::GetData<string_t>(strings_data)[string_idx];
234109 ExtractSingleTuple(string, re, group_index, groups, result, row);
234110 }
234111
234112 if (args.AllConstant()) {
234113 result.SetVectorType(VectorType::CONSTANT_VECTOR);
234114 }
234115}
::int32_t int32_t
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static DUCKDB_API const Vector & GetEntry(const Vector &vector)
Gets a reference to the underlying child-vector of a list.
Definition duckdb.cpp:138203
static DUCKDB_API void Reserve(Vector &vec, idx_t required_capacity)
Sets the total capacity of the underlying child-vector of a list.
Definition duckdb.cpp:138211
static DUCKDB_API idx_t GetListSize(const Vector &vector)
Gets the total size of the underlying child-vector of a list.
Definition duckdb.cpp:138221

◆ Bind()

unique_ptr< FunctionData > duckdb::RegexpExtractAll::Bind ( ClientContext & context,
ScalarFunction & bound_function,
vector< unique_ptr< Expression > > & arguments )
static
234250 {
234251 D_ASSERT(arguments.size() >= 2);
234252
234253 duckdb_re2::RE2::Options options;
234254
234255 string constant_string;
234256 bool constant_pattern = TryParseConstantPattern(context, *arguments[1], constant_string);
234257
234258 if (arguments.size() >= 4) {
234259 ParseRegexOptions(context, *arguments[3], options);
234260 }
234261 return make_uniq<RegexpExtractBindData>(options, std::move(constant_string), constant_pattern, "");
234262}

◆ InitLocalState()

unique_ptr< FunctionLocalState > duckdb::RegexpExtractAll::InitLocalState ( ExpressionState & state,
const BoundFunctionExpression & expr,
FunctionData * bind_data )
static
233898 {
233899 auto &info = bind_data->Cast<RegexpBaseBindData>();
233900 if (info.constant_pattern) {
233901 return make_uniq<RegexLocalState>(info, true);
233902 }
233903 return nullptr;
233904}

The documentation for this struct was generated from the following file: