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::VectorStringToArray Struct Reference

Static Public Member Functions

static bool StringToNestedTypeCastLoop (const string_t *source_data, ValidityMask &source_mask, Vector &result, ValidityMask &result_mask, idx_t count, CastParameters &parameters, const SelectionVector *sel)

Member Function Documentation

◆ StringToNestedTypeCastLoop()

bool duckdb::VectorStringToArray::StringToNestedTypeCastLoop ( const string_t * source_data,
ValidityMask & source_mask,
Vector & result,
ValidityMask & result_mask,
idx_t count,
CastParameters & parameters,
const SelectionVector * sel )
static
214990 {
214991 idx_t array_size = ArrayType::GetSize(result.GetType());
214992 bool all_lengths_match = true;
214993
214994 for (idx_t i = 0; i < count; i++) {
214995 idx_t idx = i;
214996 if (sel) {
214997 idx = sel->get_index(i);
214998 }
214999 if (!source_mask.RowIsValid(idx)) {
215000 continue;
215001 }
215002 auto str_array_size = VectorStringToList::CountPartsList(source_data[idx]);
215003 if (array_size != str_array_size) {
215004 if (all_lengths_match) {
215005 all_lengths_match = false;
215006 auto msg = StringUtil::Format("Type VARCHAR with value '%s' can't be cast to the destination type %s"
215007 ", the size of the array must match the destination type",
215008 source_data[idx].GetString(), result.GetType().ToString());
215009 if (parameters.strict) {
215010 throw ConversionException(msg);
215011 }
215012 HandleCastError::AssignError(msg, parameters);
215013 }
215014 result_mask.SetInvalid(i);
215015 }
215016 }
215017
215018 auto child_count = array_size * count;
215019 Vector varchar_vector(LogicalType::VARCHAR, child_count);
215020 auto child_data = FlatVector::GetData<string_t>(varchar_vector);
215021
215022 VectorTryCastData vector_cast_data(result, parameters);
215023 idx_t total = 0;
215024 for (idx_t i = 0; i < count; i++) {
215025 idx_t idx = i;
215026 if (sel) {
215027 idx = sel->get_index(i);
215028 }
215029
215030 if (!source_mask.RowIsValid(idx) || !result_mask.RowIsValid(i)) {
215031 // The source is null, or there was a size-mismatch above, so dont try to split the string
215032 result_mask.SetInvalid(i);
215033
215034 // Null the entire array
215035 for (idx_t j = 0; j < array_size; j++) {
215036 FlatVector::SetNull(varchar_vector, i * array_size + j, true);
215037 }
215038
215039 total += array_size;
215040 continue;
215041 }
215042
215043 if (!VectorStringToList::SplitStringList(source_data[idx], child_data, total, varchar_vector)) {
215044 auto error = StringUtil::Format("Type VARCHAR with value '%s' can't be cast to the destination type %s",
215045 source_data[idx].GetString(), result.GetType().ToString());
215046 HandleVectorCastError::Operation<string_t>(error, result_mask, i, vector_cast_data);
215047 }
215048 }
215049 D_ASSERT(total == child_count);
215050
215051 auto &result_child = ArrayVector::GetEntry(result);
215052 auto &cast_data = parameters.cast_data->Cast<ArrayBoundCastData>();
215053 CastParameters child_parameters(parameters, cast_data.child_cast_info.cast_data, parameters.local_state);
215054 bool cast_result = cast_data.child_cast_info.function(varchar_vector, result_child, child_count, child_parameters);
215055
215056 return all_lengths_match && cast_result && vector_cast_data.all_converted;
215057}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
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 an array.
Definition duckdb.cpp:138574

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