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

Static Public Member Functions

static DUCKDB_API const Vector & GetKeys (const Vector &vector)
static DUCKDB_API const Vector & GetValues (const Vector &vector)
static DUCKDB_API Vector & GetKeys (Vector &vector)
static DUCKDB_API Vector & GetValues (Vector &vector)
static DUCKDB_API MapInvalidReason CheckMapValidity (Vector &map, idx_t count, const SelectionVector &sel= *FlatVector::IncrementalSelectionVector())
static DUCKDB_API void EvalMapInvalidReason (MapInvalidReason reason)
static DUCKDB_API void MapConversionVerify (Vector &vector, idx_t count)

Member Function Documentation

◆ GetKeys() [1/2]

const Vector & duckdb::MapVector::GetKeys ( const Vector & vector)
static
138090 {
138091 return GetKeys((Vector &)vector);
138092}

◆ GetValues() [1/2]

const Vector & duckdb::MapVector::GetValues ( const Vector & vector)
static
138093 {
138094 return GetValues((Vector &)vector);
138095}

◆ GetKeys() [2/2]

Vector & duckdb::MapVector::GetKeys ( Vector & vector)
static
138079 {
138080 auto &entries = StructVector::GetEntries(ListVector::GetEntry(vector));
138081 D_ASSERT(entries.size() == 2);
138082 return *entries[0];
138083}
static DUCKDB_API const Vector & GetEntry(const Vector &vector)
Gets a reference to the underlying child-vector of a list.
Definition duckdb.cpp:138203

◆ GetValues() [2/2]

Vector & duckdb::MapVector::GetValues ( Vector & vector)
static
138084 {
138085 auto &entries = StructVector::GetEntries(ListVector::GetEntry(vector));
138086 D_ASSERT(entries.size() == 2);
138087 return *entries[1];
138088}

◆ CheckMapValidity()

MapInvalidReason duckdb::MapVector::CheckMapValidity ( Vector & map,
idx_t count,
const SelectionVector & sel = *FlatVector::IncrementalSelectionVector() )
static
138097 {
138098 D_ASSERT(map.GetType().id() == LogicalTypeId::MAP);
138099
138100 // unify the MAP vector, which is a physical LIST vector
138101 UnifiedVectorFormat map_data;
138102 map.ToUnifiedFormat(count, map_data);
138103 auto map_entries = UnifiedVectorFormat::GetDataNoConst<list_entry_t>(map_data);
138104 auto maps_length = ListVector::GetListSize(map);
138105
138106 // unify the child vector containing the keys
138107 auto &keys = MapVector::GetKeys(map);
138108 UnifiedVectorFormat key_data;
138109 keys.ToUnifiedFormat(maps_length, key_data);
138110
138111 for (idx_t row_idx = 0; row_idx < count; row_idx++) {
138112 auto mapped_row = sel.get_index(row_idx);
138113 auto map_idx = map_data.sel->get_index(mapped_row);
138114
138115 if (!map_data.validity.RowIsValid(map_idx)) {
138116 continue;
138117 }
138118
138119 value_set_t unique_keys;
138120 auto length = map_entries[map_idx].length;
138121 auto offset = map_entries[map_idx].offset;
138122
138123 for (idx_t child_idx = 0; child_idx < length; child_idx++) {
138124 auto key_idx = key_data.sel->get_index(offset + child_idx);
138125
138126 if (!key_data.validity.RowIsValid(key_idx)) {
138127 return MapInvalidReason::NULL_KEY;
138128 }
138129
138130 auto value = keys.GetValue(key_idx);
138131 auto unique = unique_keys.insert(value).second;
138132 if (!unique) {
138133 return MapInvalidReason::DUPLICATE_KEY;
138134 }
138135 }
138136 }
138137
138138 return MapInvalidReason::VALID;
138139}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
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

◆ EvalMapInvalidReason()

void duckdb::MapVector::EvalMapInvalidReason ( MapInvalidReason reason)
static
138146 {
138147 switch (reason) {
138148 case MapInvalidReason::VALID:
138149 return;
138150 case MapInvalidReason::DUPLICATE_KEY:
138151 throw InvalidInputException("Map keys must be unique.");
138152 case MapInvalidReason::NULL_KEY:
138153 throw InvalidInputException("Map keys can not be NULL.");
138154 case MapInvalidReason::NOT_ALIGNED:
138155 throw InvalidInputException("The map key list does not align with the map value list.");
138156 case MapInvalidReason::INVALID_PARAMS:
138157 throw InvalidInputException("Invalid map argument(s). Valid map arguments are a list of key-value pairs (MAP "
138158 "{'key1': 'val1', ...}), two lists (MAP ([1, 2], [10, 11])), or no arguments.");
138159 default:
138160 throw InternalException("MapInvalidReason not implemented");
138161 }
138162}

◆ MapConversionVerify()

void duckdb::MapVector::MapConversionVerify ( Vector & vector,
idx_t count )
static
138141 {
138142 auto reason = MapVector::CheckMapValidity(vector, count);
138143 EvalMapInvalidReason(reason);
138144}

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