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

Static Public Member Functions

template<class T>
static void VerifyVectorType (const Vector &vector)
static const_data_ptr_t GetData (const Vector &vector)
static data_ptr_t GetData (Vector &vector)
template<class T>
static const T * GetDataUnsafe (const Vector &vector)
template<class T>
static T * GetDataUnsafe (Vector &vector)
template<class T>
static const T * GetData (const Vector &vector)
template<class T>
static T * GetData (Vector &vector)
static bool IsNull (const Vector &vector)
static DUCKDB_API void SetNull (Vector &vector, bool is_null)
static ValidityMask & Validity (Vector &vector)
static DUCKDB_API const SelectionVector * ZeroSelectionVector (idx_t count, SelectionVector &owned_sel)
static DUCKDB_API const SelectionVector * ZeroSelectionVector ()
static DUCKDB_API void Reference (Vector &vector, Vector &source, idx_t position, idx_t count)
 Turns "vector" into a constant vector by referencing a value within the source vector.

Static Public Attributes

static const sel_t ZERO_VECTOR [STANDARD_VECTOR_SIZE] = {0}

Member Function Documentation

◆ VerifyVectorType()

template<class T>
void duckdb::ConstantVector::VerifyVectorType ( const Vector & vector)
inlinestatic
10797 {
10798#ifdef DUCKDB_DEBUG_NO_SAFETY
10799 D_ASSERT(StorageTypeCompatible<T>(vector.GetType().InternalType()));
10800#else
10801 if (!StorageTypeCompatible<T>(vector.GetType().InternalType())) {
10802 throw InternalException("Expected vector of type %s, but found vector of type %s", GetTypeId<T>(),
10803 vector.GetType().InternalType());
10804 }
10805#endif
10806 }
PhysicalType GetTypeId()
Returns the PhysicalType for the given type.
Definition duckdb.hpp:10381

◆ GetData() [1/4]

const_data_ptr_t duckdb::ConstantVector::GetData ( const Vector & vector)
inlinestatic
10808 {
10809 D_ASSERT(vector.GetVectorType() == VectorType::CONSTANT_VECTOR ||
10810 vector.GetVectorType() == VectorType::FLAT_VECTOR);
10811 return vector.data;
10812 }

◆ GetData() [2/4]

data_ptr_t duckdb::ConstantVector::GetData ( Vector & vector)
inlinestatic
10813 {
10814 D_ASSERT(vector.GetVectorType() == VectorType::CONSTANT_VECTOR ||
10815 vector.GetVectorType() == VectorType::FLAT_VECTOR);
10816 return vector.data;
10817 }

◆ GetDataUnsafe() [1/2]

template<class T>
const T * duckdb::ConstantVector::GetDataUnsafe ( const Vector & vector)
inlinestatic
10819 {
10820 return reinterpret_cast<const T *>(GetData(vector));
10821 }

◆ GetDataUnsafe() [2/2]

template<class T>
T * duckdb::ConstantVector::GetDataUnsafe ( Vector & vector)
inlinestatic
10823 {
10824 return reinterpret_cast<T *>(GetData(vector));
10825 }

◆ GetData() [3/4]

template<class T>
const T * duckdb::ConstantVector::GetData ( const Vector & vector)
inlinestatic
10827 {
10828 VerifyVectorType<T>(vector);
10829 return GetDataUnsafe<T>(vector);
10830 }

◆ GetData() [4/4]

template<class T>
T * duckdb::ConstantVector::GetData ( Vector & vector)
inlinestatic
10832 {
10833 VerifyVectorType<T>(vector);
10834 return GetDataUnsafe<T>(vector);
10835 }

◆ IsNull()

bool duckdb::ConstantVector::IsNull ( const Vector & vector)
inlinestatic
10836 {
10837 D_ASSERT(vector.GetVectorType() == VectorType::CONSTANT_VECTOR);
10838 return !vector.validity.RowIsValid(0);
10839 }

◆ SetNull()

void duckdb::ConstantVector::SetNull ( Vector & vector,
bool is_null )
static
137752 {
137753 D_ASSERT(vector.GetVectorType() == VectorType::CONSTANT_VECTOR);
137754 vector.validity.Set(0, !is_null);
137755 if (is_null) {
137756 auto &type = vector.GetType();
137757 auto internal_type = type.InternalType();
137758 if (internal_type == PhysicalType::STRUCT) {
137759 // set all child entries to null as well
137760 auto &entries = StructVector::GetEntries(vector);
137761 for (auto &entry : entries) {
137762 entry->SetVectorType(VectorType::CONSTANT_VECTOR);
137763 ConstantVector::SetNull(*entry, is_null);
137764 }
137765 } else if (internal_type == PhysicalType::ARRAY) {
137766 auto &child = ArrayVector::GetEntry(vector);
137767 D_ASSERT(child.GetVectorType() == VectorType::CONSTANT_VECTOR ||
137768 child.GetVectorType() == VectorType::FLAT_VECTOR);
137769 auto array_size = ArrayType::GetSize(type);
137770 if (child.GetVectorType() == VectorType::CONSTANT_VECTOR) {
137771 D_ASSERT(array_size == 1);
137772 ConstantVector::SetNull(child, is_null);
137773 } else {
137774 for (idx_t i = 0; i < array_size; i++) {
137775 FlatVector::SetNull(child, i, is_null);
137776 }
137777 }
137778 }
137779 }
137780}
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816
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

◆ Validity()

ValidityMask & duckdb::ConstantVector::Validity ( Vector & vector)
inlinestatic
10841 {
10842 D_ASSERT(vector.GetVectorType() == VectorType::CONSTANT_VECTOR);
10843 return vector.validity;
10844 }

◆ ZeroSelectionVector() [1/2]

const SelectionVector * duckdb::ConstantVector::ZeroSelectionVector ( idx_t count,
SelectionVector & owned_sel )
static
137782 {
137783 if (count <= STANDARD_VECTOR_SIZE) {
137784 return ConstantVector::ZeroSelectionVector();
137785 }
137786 owned_sel.Initialize(count);
137787 for (idx_t i = 0; i < count; i++) {
137788 owned_sel.set_index(i, 0);
137789 }
137790 return &owned_sel;
137791}

◆ ZeroSelectionVector() [2/2]

const SelectionVector * duckdb::ConstantVector::ZeroSelectionVector ( )
static
139002 {
139003 static const SelectionVector ZERO_SELECTION_VECTOR =
139004 SelectionVector(const_cast<sel_t *>(ConstantVector::ZERO_VECTOR)); // NOLINT
139005 return &ZERO_SELECTION_VECTOR;
139006}
uint32_t sel_t
Type used for the selection vector.
Definition duckdb.hpp:251

◆ Reference()

void duckdb::ConstantVector::Reference ( Vector & vector,
Vector & source,
idx_t position,
idx_t count )
static

Turns "vector" into a constant vector by referencing a value within the source vector.

137793 {
137794 auto &source_type = source.GetType();
137795 switch (source_type.InternalType()) {
137796 case PhysicalType::LIST: {
137797 // retrieve the list entry from the source vector
137798 UnifiedVectorFormat vdata;
137799 source.ToUnifiedFormat(count, vdata);
137800
137801 auto list_index = vdata.sel->get_index(position);
137802 if (!vdata.validity.RowIsValid(list_index)) {
137803 // list is null: create null value
137804 Value null_value(source_type);
137805 vector.Reference(null_value);
137806 break;
137807 }
137808
137809 auto list_data = UnifiedVectorFormat::GetData<list_entry_t>(vdata);
137810 auto list_entry = list_data[list_index];
137811
137812 // add the list entry as the first element of "vector"
137813 // FIXME: we only need to allocate space for 1 tuple here
137814 auto target_data = FlatVector::GetData<list_entry_t>(vector);
137815 target_data[0] = list_entry;
137816
137817 // create a reference to the child list of the source vector
137818 auto &child = ListVector::GetEntry(vector);
137819 child.Reference(ListVector::GetEntry(source));
137820
137822 vector.SetVectorType(VectorType::CONSTANT_VECTOR);
137823 break;
137824 }
137825 case PhysicalType::ARRAY: {
137826 UnifiedVectorFormat vdata;
137827 source.ToUnifiedFormat(count, vdata);
137828 auto source_idx = vdata.sel->get_index(position);
137829 if (!vdata.validity.RowIsValid(source_idx)) {
137830 // list is null: create null value
137831 Value null_value(source_type);
137832 vector.Reference(null_value);
137833 break;
137834 }
137835
137836 // Reference the child vector
137837 auto &target_child = ArrayVector::GetEntry(vector);
137838 auto &source_child = ArrayVector::GetEntry(source);
137839 target_child.Reference(source_child);
137840
137841 // Only take the element at the given position
137842 auto array_size = ArrayType::GetSize(source_type);
137843 SelectionVector sel(array_size);
137844 for (idx_t i = 0; i < array_size; i++) {
137845 sel.set_index(i, array_size * source_idx + i);
137846 }
137847 target_child.Slice(sel, array_size);
137848 target_child.Flatten(array_size); // since its constant we only have to flatten this much
137849
137850 vector.SetVectorType(VectorType::CONSTANT_VECTOR);
137851 vector.validity.Set(0, true);
137852 break;
137853 }
137854 case PhysicalType::STRUCT: {
137855 UnifiedVectorFormat vdata;
137856 source.ToUnifiedFormat(count, vdata);
137857
137858 auto struct_index = vdata.sel->get_index(position);
137859 if (!vdata.validity.RowIsValid(struct_index)) {
137860 // null struct: create null value
137861 Value null_value(source_type);
137862 vector.Reference(null_value);
137863 break;
137864 }
137865
137866 // struct: pass constant reference into child entries
137867 auto &source_entries = StructVector::GetEntries(source);
137868 auto &target_entries = StructVector::GetEntries(vector);
137869 for (idx_t i = 0; i < source_entries.size(); i++) {
137870 ConstantVector::Reference(*target_entries[i], *source_entries[i], position, count);
137871 }
137872 vector.SetVectorType(VectorType::CONSTANT_VECTOR);
137873 vector.validity.Set(0, true);
137874 break;
137875 }
137876 default:
137877 // default behavior: get a value from the vector and reference it
137878 // this is not that expensive for scalar types
137879 auto value = source.GetValue(position);
137880 vector.Reference(value);
137881 D_ASSERT(vector.GetVectorType() == VectorType::CONSTANT_VECTOR);
137882 break;
137883 }
137884}
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
static DUCKDB_API void Reference(Vector &vector, Vector &source, idx_t position, idx_t count)
Turns "vector" into a constant vector by referencing a value within the source vector.
Definition duckdb.cpp:137793
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 SetListSize(Vector &vec, idx_t size)
Sets the total size of the underlying child-vector of a list.
Definition duckdb.cpp:138248
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
Here is the call graph for this function:
Here is the caller graph for this function:

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