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);
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
234051
234052
234053 output_child.SetAuxiliary(strings.GetAuxiliary());
234054
234055
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
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
234075
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
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);
234095 if (!pattern_valid || !strings_data.validity.RowIsValid(string_idx) || !GetGroupIndex(args, row, group_index)) {
234096
234097
234098 auto result_data = FlatVector::GetData<list_entry_t>(result);
234099 auto &result_validity = FlatVector::Validity(result);
234100 result_data[row].length = 0;
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}
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