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::SelectionVector Struct Reference
Collaboration diagram for duckdb::SelectionVector:

Public Member Functions

 SelectionVector (sel_t *sel)
 SelectionVector (idx_t count)
 SelectionVector (idx_t start, idx_t count)
 SelectionVector (const SelectionVector &sel_vector)
 SelectionVector (buffer_ptr< SelectionData > data)
SelectionVector & operator= (SelectionVector &&other) noexcept
void Initialize (sel_t *sel)
void Initialize (idx_t count=STANDARD_VECTOR_SIZE)
void Initialize (buffer_ptr< SelectionData > data)
void Initialize (const SelectionVector &other)
void set_index (idx_t idx, idx_t loc)
void swap (idx_t i, idx_t j)
idx_t get_index (idx_t idx) const
idx_t get_index_unsafe (idx_t idx) const
sel_t * data ()
const sel_t * data () const
buffer_ptr< SelectionData > sel_data ()
buffer_ptr< SelectionData > Slice (const SelectionVector &sel, idx_t count) const
idx_t SliceInPlace (const SelectionVector &sel, idx_t count)
string ToString (idx_t count=0) const
void Print (idx_t count=0) const
const sel_t & operator[] (idx_t index) const
sel_t & operator[] (idx_t index)
bool IsSet () const
void Verify (idx_t count, idx_t vector_size) const
void Sort (idx_t count)

Static Public Member Functions

static idx_t Inverted (const SelectionVector &src, SelectionVector &dst, idx_t source_size, idx_t count)

Private Attributes

sel_t * sel_vector
buffer_ptr< SelectionData > selection_data

Constructor & Destructor Documentation

◆ SelectionVector() [1/6]

duckdb::SelectionVector::SelectionVector ( )
inline
8772 : sel_vector(nullptr) {
8773 }

◆ SelectionVector() [2/6]

duckdb::SelectionVector::SelectionVector ( sel_t * sel)
inlineexplicit
8774 {
8775 Initialize(sel);
8776 }

◆ SelectionVector() [3/6]

duckdb::SelectionVector::SelectionVector ( idx_t count)
inlineexplicit
8777 {
8778 Initialize(count);
8779 }

◆ SelectionVector() [4/6]

duckdb::SelectionVector::SelectionVector ( idx_t start,
idx_t count )
inline
8780 {
8781 Initialize(MaxValue<idx_t>(count, STANDARD_VECTOR_SIZE));
8782 for (idx_t i = 0; i < count; i++) {
8783 set_index(i, start + i);
8784 }
8785 }
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ SelectionVector() [5/6]

duckdb::SelectionVector::SelectionVector ( const SelectionVector & sel_vector)
inline
8786 {
8787 Initialize(sel_vector);
8788 }

◆ SelectionVector() [6/6]

duckdb::SelectionVector::SelectionVector ( buffer_ptr< SelectionData > data)
inlineexplicit
8789 {
8790 Initialize(std::move(data));
8791 }

Member Function Documentation

◆ operator=()

SelectionVector & duckdb::SelectionVector::operator= ( SelectionVector && other)
inlinenoexcept
8792 {
8793 sel_vector = other.sel_vector;
8794 other.sel_vector = nullptr;
8795 selection_data = std::move(other.selection_data);
8796 return *this;
8797 }

◆ Inverted()

idx_t duckdb::SelectionVector::Inverted ( const SelectionVector & src,
SelectionVector & dst,
idx_t source_size,
idx_t count )
inlinestatic
8800 {
8801 idx_t src_idx = 0;
8802 idx_t dst_idx = 0;
8803 for (idx_t i = 0; i < count; i++) {
8804 if (src_idx < source_size && src.get_index(src_idx) == i) {
8805 src_idx++;
8806 // This index is selected by 'src', skip it in 'dst'
8807 continue;
8808 }
8809 // This index does not exist in 'src', add it to the selection of 'dst'
8810 dst.set_index(dst_idx++, i);
8811 }
8812 return dst_idx;
8813 }

◆ Initialize() [1/4]

void duckdb::SelectionVector::Initialize ( sel_t * sel)
inline
8815 {
8816 selection_data.reset();
8817 sel_vector = sel;
8818 }

◆ Initialize() [2/4]

void duckdb::SelectionVector::Initialize ( idx_t count = STANDARD_VECTOR_SIZE)
inline
8819 {
8820 selection_data = make_shared_ptr<SelectionData>(count);
8821 sel_vector = reinterpret_cast<sel_t *>(selection_data->owned_data.get());
8822 }
uint32_t sel_t
Type used for the selection vector.
Definition duckdb.hpp:251

◆ Initialize() [3/4]

void duckdb::SelectionVector::Initialize ( buffer_ptr< SelectionData > data)
inline
8823 {
8824 selection_data = std::move(data);
8825 sel_vector = reinterpret_cast<sel_t *>(selection_data->owned_data.get());
8826 }

◆ Initialize() [4/4]

void duckdb::SelectionVector::Initialize ( const SelectionVector & other)
inline
8827 {
8828 selection_data = other.selection_data;
8829 sel_vector = other.sel_vector;
8830 }

◆ set_index()

void duckdb::SelectionVector::set_index ( idx_t idx,
idx_t loc )
inline
8832 { // NOLINT: allow casing for legacy reasons
8833 sel_vector[idx] = UnsafeNumericCast<sel_t>(loc);
8834 }

◆ swap()

void duckdb::SelectionVector::swap ( idx_t i,
idx_t j )
inline
8835 { // NOLINT: allow casing for legacy reasons
8836 sel_t tmp = sel_vector[i];
8837 sel_vector[i] = sel_vector[j];
8838 sel_vector[j] = tmp;
8839 }

◆ get_index()

idx_t duckdb::SelectionVector::get_index ( idx_t idx) const
inline
8840 { // NOLINT: allow casing for legacy reasons
8841 return sel_vector ? get_index_unsafe(idx) : idx;
8842 }

◆ get_index_unsafe()

idx_t duckdb::SelectionVector::get_index_unsafe ( idx_t idx) const
inline
8843 { // NOLINT: allow casing for legacy reasons
8844 return sel_vector[idx];
8845 }

◆ data() [1/2]

sel_t * duckdb::SelectionVector::data ( )
inline
8846 { // NOLINT: allow casing for legacy reasons
8847 return sel_vector;
8848 }

◆ data() [2/2]

const sel_t * duckdb::SelectionVector::data ( ) const
inline
8849 { // NOLINT: allow casing for legacy reasons
8850 return sel_vector;
8851 }

◆ sel_data()

buffer_ptr< SelectionData > duckdb::SelectionVector::sel_data ( )
inline
8852 { // NOLINT: allow casing for legacy reasons
8853 return selection_data;
8854 }

◆ Slice()

buffer_ptr< SelectionData > duckdb::SelectionVector::Slice ( const SelectionVector & sel,
idx_t count ) const
128920 {
128921 auto data = make_buffer<SelectionData>(count);
128922 auto result_ptr = reinterpret_cast<sel_t *>(data->owned_data.get());
128923 // for every element, we perform result[i] = target[new[i]]
128924 for (idx_t i = 0; i < count; i++) {
128925 auto new_idx = sel.get_index(i);
128926 auto idx = this->get_index(new_idx);
128927 result_ptr[i] = UnsafeNumericCast<sel_t>(idx);
128928 }
128929 return data;
128930}

◆ SliceInPlace()

idx_t duckdb::SelectionVector::SliceInPlace ( const SelectionVector & sel,
idx_t count )
128932 {
128933 for (idx_t i = 0; i < count; ++i) {
128934 set_index(i, get_index(source.get_index(i)));
128935 }
128936
128937 return count;
128938}

◆ ToString()

string duckdb::SelectionVector::ToString ( idx_t count = 0) const
128899 {
128900 string result = "Selection Vector (" + to_string(count) + ") [";
128901 for (idx_t i = 0; i < count; i++) {
128902 if (i != 0) {
128903 result += ", ";
128904 }
128905 result += to_string(get_index(i));
128906 }
128907 result += "]";
128908 return result;
128909}
std::string to_string(const T &value)
Definition duckdb.cpp:19425

◆ Print()

void duckdb::SelectionVector::Print ( idx_t count = 0) const
128915 {
128916 Printer::Print(ToString(count));
128917}
static DUCKDB_API void Print(OutputStream stream, const string &str)
Print the object to the stream.
Definition duckdb.cpp:92556

◆ operator[]() [1/2]

const sel_t & duckdb::SelectionVector::operator[] ( idx_t index) const
inline
8861 {
8862 return sel_vector[index];
8863 }
index

◆ operator[]() [2/2]

sel_t & duckdb::SelectionVector::operator[] ( idx_t index)
inline
8864 {
8865 return sel_vector[index];
8866 }

◆ IsSet()

bool duckdb::SelectionVector::IsSet ( ) const
inline
8867 {
8868 return sel_vector;
8869 }

◆ Verify()

void duckdb::SelectionVector::Verify ( idx_t count,
idx_t vector_size ) const
128940 {
128941#ifdef DEBUG
128942 D_ASSERT(vector_size >= 1);
128943 for (idx_t i = 0; i < count; i++) {
128944 auto index = get_index(i);
128945 if (index >= vector_size) {
128946 throw InternalException(
128947 "Provided SelectionVector is invalid, index %d points to %d, which is out of range. "
128948 "the valid range (0-%d)",
128949 i, index, vector_size - 1);
128950 }
128951 }
128952#endif
128953}

◆ Sort()

void duckdb::SelectionVector::Sort ( idx_t count)
128911 {
128912 std::sort(sel_vector, sel_vector + count);
128913}

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