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::RegexpExtractAllStruct 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::RegexpExtractAllStruct::Execute ( DataChunk & args,
ExpressionState & state,
Vector & result )
static
234173 {
234174#ifdef D_ASSERT_IS_ENABLED
234175 auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
234176 const auto &info = func_expr.bind_info->Cast<RegexpExtractAllStructBindData>();
234177 // Struct multi-match variant only supports constant pattern (enforced in Bind)
234178 D_ASSERT(info.constant_pattern);
234179#endif
234180
234181 // Expect arguments: string, pattern, list_of_group_names [, options]
234182 auto &strings = args.data[0];
234183
234184 D_ASSERT(result.GetType().id() == LogicalTypeId::LIST);
234185 auto &struct_vector = ListVector::GetEntry(result);
234186 D_ASSERT(struct_vector.GetType().id() == LogicalTypeId::STRUCT);
234187 auto &child_entries = StructVector::GetEntries(struct_vector);
234188 const idx_t group_count = child_entries.size();
234189
234190 // Reference original string buffer for zero-copy substring assignment
234191 for (auto &child : child_entries) {
234192 child->SetAuxiliary(strings.GetAuxiliary());
234193 child->SetVectorType(VectorType::FLAT_VECTOR);
234194 }
234195
234196 UnifiedVectorFormat strings_data;
234197 strings.ToUnifiedFormat(args.size(), strings_data);
234198 ListVector::Reserve(result, STANDARD_VECTOR_SIZE);
234199 idx_t tuple_count = args.AllConstant() ? 1 : args.size();
234200
234201 auto &lstate = ExecuteFunctionState::GetFunctionState(state)->Cast<RegexLocalState>();
234202
234203 auto &list_validity = FlatVector::Validity(result);
234204 auto list_entries = FlatVector::GetData<list_entry_t>(result);
234205
234206 vector<duckdb_re2::StringPiece> group_spans(group_count + 1);
234207
234208 for (idx_t row = 0; row < tuple_count; row++) {
234209 auto sindex = strings_data.sel->get_index(row);
234210 if (!strings_data.validity.RowIsValid(sindex)) {
234211 list_entries[row].offset = ListVector::GetListSize(result);
234212 list_entries[row].length = 0;
234213 list_validity.SetInvalid(row);
234214 continue;
234215 }
234216 auto &string_val = UnifiedVectorFormat::GetData<string_t>(strings_data)[sindex];
234217 ExtractStructAllSingleTuple(string_val, lstate.constant_pattern, group_spans, child_entries, result, row);
234218 }
234219 if (args.AllConstant()) {
234220 result.SetVectorType(VectorType::CONSTANT_VECTOR);
234221 }
234222}
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::RegexpExtractAllStruct::Bind ( ClientContext & context,
ScalarFunction & bound_function,
vector< unique_ptr< Expression > > & arguments )
static
234225 {
234226 // arguments: string, pattern, LIST<VARCHAR> group_names [, options]
234227 if (arguments.size() < 3) {
234228 throw BinderException("regexp_extract_all struct variant requires at least 3 arguments");
234229 }
234230 duckdb_re2::RE2::Options options;
234231 string constant_string;
234232 bool constant_pattern = TryParseConstantPattern(context, *arguments[1], constant_string);
234233 if (!constant_pattern) {
234234 throw BinderException("%s with LIST requires a constant pattern", bound_function.name);
234235 }
234236 if (arguments.size() >= 4) {
234237 ParseRegexOptions(context, *arguments[3], options);
234238 }
234239 options.set_log_errors(false);
234240 vector<string> group_names;
234241 child_list_t<LogicalType> struct_children;
234242 regexp_util::ParseGroupNameList(context, bound_function.name, *arguments[2], constant_string, options, true,
234243 group_names, struct_children);
234244 bound_function.SetReturnType(LogicalType::LIST(LogicalType::STRUCT(struct_children)));
234245 return make_uniq<RegexpExtractAllStructBindData>(options, std::move(constant_string), constant_pattern,
234246 std::move(group_names));
234247}

◆ InitLocalState()

unique_ptr< FunctionLocalState > duckdb::RegexpExtractAllStruct::InitLocalState ( ExpressionState & state,
const BoundFunctionExpression & expr,
FunctionData * bind_data )
static
233908 {
233909 auto &info = bind_data->Cast<RegexpExtractAllStructBindData>();
233910 if (info.constant_pattern) {
233911 return make_uniq<RegexLocalState>(info, true);
233912 }
233913 return nullptr;
233914}

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