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::ARTKey Class Reference

Public Member Functions

 ARTKey (data_ptr_t data, idx_t len)
 ARTKey (ArenaAllocator &allocator, idx_t len)
data_t & operator[] (idx_t i)
const data_t & operator[] (idx_t i) const
bool operator> (const ARTKey &key) const
bool operator>= (const ARTKey &key) const
bool operator== (const ARTKey &key) const
bool ByteMatches (const ARTKey &other, idx_t depth) const
bool Empty () const
void Concat (ArenaAllocator &allocator, const ARTKey &other)
row_t GetRowId () const
idx_t GetMismatchPos (const ARTKey &other, const idx_t start) const
template<>
ARTKey CreateARTKey (ArenaAllocator &allocator, string_t value)
template<>
ARTKey CreateARTKey (ArenaAllocator &allocator, const char *value)
template<>
void CreateARTKey (ArenaAllocator &allocator, ARTKey &key, string_t value)
template<>
ARTKey CreateARTKey (ArenaAllocator &allocator, string_t value)
template<>
ARTKey CreateARTKey (ArenaAllocator &allocator, const char *value)
template<>
void CreateARTKey (ArenaAllocator &allocator, ARTKey &key, string_t value)
template<>
void CreateARTKey (ArenaAllocator &allocator, ARTKey &key, const char *value)

Static Public Member Functions

template<class T>
static ARTKey CreateARTKey (ArenaAllocator &allocator, T value)
template<class T>
static ARTKey CreateARTKey (ArenaAllocator &allocator, Value &value)
template<class T>
static void CreateARTKey (ArenaAllocator &allocator, ARTKey &key, T value)
template<class T>
static void CreateARTKey (ArenaAllocator &allocator, ARTKey &key, Value value)
static ARTKey CreateARTKeyFromBytes (ArenaAllocator &allocator, const_data_ptr_t data, idx_t len)
static ARTKey CreateKey (ArenaAllocator &allocator, Value &value, optional_idx storage_version)

Public Attributes

idx_t len
data_ptr_t data

Static Private Member Functions

template<class T>
static data_ptr_t CreateData (ArenaAllocator &allocator, T value)

Constructor & Destructor Documentation

◆ ARTKey() [1/3]

duckdb::ARTKey::ARTKey ( )
152937 : len(0) {
152938}

◆ ARTKey() [2/3]

duckdb::ARTKey::ARTKey ( data_ptr_t data,
idx_t len )
152940 : len(len), data(data) {
152941}

◆ ARTKey() [3/3]

duckdb::ARTKey::ARTKey ( ArenaAllocator & allocator,
idx_t len )
152943 : len(len) {
152944 data = allocator.Allocate(len);
152945}

Member Function Documentation

◆ CreateARTKey() [1/8]

template<class T>
ARTKey duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
T value )
inlinestatic
58835 {
58836 auto data = ARTKey::CreateData<T>(allocator, value);
58837 return ARTKey(data, sizeof(value));
58838 }

◆ CreateARTKey() [2/8]

template<class T>
ARTKey duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
Value & value )
inlinestatic
58841 {
58842 return CreateARTKey(allocator, value.GetValueUnsafe<T>());
58843 }

◆ CreateARTKey() [3/8]

template<class T>
void duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
ARTKey & key,
T value )
inlinestatic
58846 {
58847 key.data = ARTKey::CreateData<T>(allocator, value);
58848 key.len = sizeof(value);
58849 }

◆ CreateARTKey() [4/8]

template<class T>
void duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
ARTKey & key,
Value value )
inlinestatic
58852 {
58853 key.data = ARTKey::CreateData<T>(allocator, value.GetValueUnsafe<T>());
58854 key.len = sizeof(value);
58855 }

◆ CreateARTKeyFromBytes()

ARTKey duckdb::ARTKey::CreateARTKeyFromBytes ( ArenaAllocator & allocator,
const_data_ptr_t data,
idx_t len )
inlinestatic
58857 {
58858 auto new_data = allocator.Allocate(len);
58859 memcpy(new_data, data, len);
58860 return ARTKey(new_data, len);
58861 }

◆ CreateKey()

ARTKey duckdb::ARTKey::CreateKey ( ArenaAllocator & allocator,
Value & value,
optional_idx storage_version )
static
152993 {
152994 const auto &type = value.type();
152995 D_ASSERT(type.InternalType() == value.type().InternalType());
152996
152997 if (type.id() == LogicalTypeId::GEOMETRY && (!storage_version.IsValid() || (storage_version.GetIndex() < 7))) {
152998 // Convert to old-style geometry for older storage versions.
152999 string buffer;
153000 Geometry::ToSpatialGeometry(value.GetValueUnsafe<string>(), buffer);
153001 return ARTKey::CreateARTKey(allocator, string_t(buffer));
153002 }
153003
153004 switch (type.InternalType()) {
153005 case PhysicalType::BOOL:
153006 return ARTKey::CreateARTKey<bool>(allocator, value);
153007 case PhysicalType::INT8:
153008 return ARTKey::CreateARTKey<int8_t>(allocator, value);
153009 case PhysicalType::INT16:
153010 return ARTKey::CreateARTKey<int16_t>(allocator, value);
153011 case PhysicalType::INT32:
153012 return ARTKey::CreateARTKey<int32_t>(allocator, value);
153013 case PhysicalType::INT64:
153014 return ARTKey::CreateARTKey<int64_t>(allocator, value);
153015 case PhysicalType::UINT8:
153016 return ARTKey::CreateARTKey<uint8_t>(allocator, value);
153018 return ARTKey::CreateARTKey<uint16_t>(allocator, value);
153020 return ARTKey::CreateARTKey<uint32_t>(allocator, value);
153022 return ARTKey::CreateARTKey<uint64_t>(allocator, value);
153023 case PhysicalType::INT128:
153024 return ARTKey::CreateARTKey<hugeint_t>(allocator, value);
153025 case PhysicalType::UINT128:
153026 return ARTKey::CreateARTKey<uhugeint_t>(allocator, value);
153027 case PhysicalType::FLOAT:
153028 return ARTKey::CreateARTKey<float>(allocator, value);
153030 return ARTKey::CreateARTKey<double>(allocator, value);
153032 return ARTKey::CreateARTKey<string_t>(allocator, value);
153033 default:
153034 throw InternalException("Invalid type for the ART key.");
153035 }
153036}
@ UINT32
Unsigned 32-bit little-endian integer.
Definition duckdb.hpp:2758
@ UINT16
Unsigned 16-bit little-endian integer.
Definition duckdb.hpp:2752
@ INT64
Signed 64-bit little-endian integer.
Definition duckdb.hpp:2767
@ INT16
Signed 16-bit little-endian integer.
Definition duckdb.hpp:2755
@ INT32
Signed 32-bit little-endian integer.
Definition duckdb.hpp:2761
@ UINT64
Unsigned 64-bit little-endian integer.
Definition duckdb.hpp:2764
@ BOOL
Boolean as 8 bit "bool" value.
Definition duckdb.hpp:2743
@ VARCHAR
DuckDB Extensions.
Definition duckdb.hpp:2847
@ FLOAT
4-byte floating point value
Definition duckdb.hpp:2773
@ UINT8
Unsigned 8-bit little-endian integer.
Definition duckdb.hpp:2746
@ INT8
Signed 8-bit little-endian integer.
Definition duckdb.hpp:2749
@ DOUBLE
8-byte floating point value
Definition duckdb.hpp:2776

◆ operator[]() [1/2]

data_t & duckdb::ARTKey::operator[] ( idx_t i)
inline
58866 {
58867 return data[i];
58868 }

◆ operator[]() [2/2]

const data_t & duckdb::ARTKey::operator[] ( idx_t i) const
inline
58869 {
58870 return data[i];
58871 }

◆ operator>()

bool duckdb::ARTKey::operator> ( const ARTKey & key) const
153038 {
153039 for (idx_t i = 0; i < MinValue(len, key.len); i++) {
153040 if (data[i] > key.data[i]) {
153041 return true;
153042 } else if (data[i] < key.data[i]) {
153043 return false;
153044 }
153045 }
153046 return len > key.len;
153047}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ operator>=()

bool duckdb::ARTKey::operator>= ( const ARTKey & key) const
153049 {
153050 for (idx_t i = 0; i < MinValue(len, key.len); i++) {
153051 if (data[i] > key.data[i]) {
153052 return true;
153053 } else if (data[i] < key.data[i]) {
153054 return false;
153055 }
153056 }
153057 return len >= key.len;
153058}

◆ operator==()

bool duckdb::ARTKey::operator== ( const ARTKey & key) const
153060 {
153061 if (len != key.len) {
153062 return false;
153063 }
153064 for (idx_t i = 0; i < len; i++) {
153065 if (data[i] != key.data[i]) {
153066 return false;
153067 }
153068 }
153069 return true;
153070}

◆ ByteMatches()

bool duckdb::ARTKey::ByteMatches ( const ARTKey & other,
idx_t depth ) const
inline
58876 {
58877 return data[depth] == other[depth];
58878 }
double depth(InputArray R, InputArray t, InputArray X)

◆ Empty()

bool duckdb::ARTKey::Empty ( ) const
inline
58879 {
58880 return len == 0;
58881 }

◆ Concat()

void duckdb::ARTKey::Concat ( ArenaAllocator & allocator,
const ARTKey & other )
153072 {
153073 auto compound_data = allocator.Allocate(len + other.len);
153074 memcpy(compound_data, data, len);
153075 memcpy(compound_data + len, other.data, other.len);
153076 len += other.len;
153077 data = compound_data;
153078}

◆ GetRowId()

row_t duckdb::ARTKey::GetRowId ( ) const
153080 {
153081 D_ASSERT(len == sizeof(row_t));
153082 return Radix::DecodeData<row_t>(data);
153083}
int64_t row_t
The type used for row identifiers.
Definition duckdb.hpp:240

◆ GetMismatchPos()

idx_t duckdb::ARTKey::GetMismatchPos ( const ARTKey & other,
const idx_t start ) const
153085 {
153086 D_ASSERT(len <= other.len);
153087 D_ASSERT(start <= len);
153088 for (idx_t i = start; i < other.len; i++) {
153089 if (data[i] != other.data[i]) {
153090 return i;
153091 }
153092 }
153093 throw FatalException("Corrupted ART index - likely the same row id was inserted twice into the same ART");
153094}

◆ CreateData()

template<class T>
data_ptr_t duckdb::ARTKey::CreateData ( ArenaAllocator & allocator,
T value )
inlinestaticprivate
58889 {
58890 auto data = allocator.Allocate(sizeof(value));
58891 Radix::EncodeData<T>(data, value);
58892 return data;
58893 }

◆ CreateARTKey() [5/8]

template<>
ARTKey duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
string_t value )
152948 {
152949 auto string_data = const_data_ptr_cast(value.GetData());
152950 auto string_len = value.GetSize();
152951
152952 // We escape \00 and \01.
152953 idx_t escape_count = 0;
152954 for (idx_t i = 0; i < string_len; i++) {
152955 if (string_data[i] <= 1) {
152956 escape_count++;
152957 }
152958 }
152959
152960 idx_t key_len = string_len + escape_count + 1;
152961 auto key_data = allocator.Allocate(key_len);
152962
152963 // Copy over the data and add escapes.
152964 idx_t pos = 0;
152965 for (idx_t i = 0; i < string_len; i++) {
152966 if (string_data[i] <= 1) {
152967 // Add escape.
152968 key_data[pos++] = '\01';
152969 }
152970 key_data[pos++] = string_data[i];
152971 }
152972
152973 // End with a null-terminator.
152974 key_data[pos] = '\0';
152975 return ARTKey(key_data, key_len);
152976}

◆ CreateARTKey() [6/8]

template<>
ARTKey duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
const char * value )
152979 {
152980 return ARTKey::CreateARTKey(allocator, string_t(value, UnsafeNumericCast<uint32_t>(strlen(value))));
152981}

◆ CreateARTKey() [7/8]

template<>
void duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
ARTKey & key,
string_t value )
152984 {
152985 key = ARTKey::CreateARTKey<string_t>(allocator, value);
152986}

◆ CreateARTKey() [8/8]

template<>
void duckdb::ARTKey::CreateARTKey ( ArenaAllocator & allocator,
ARTKey & key,
const char * value )
152989 {
152990 ARTKey::CreateARTKey(allocator, key, string_t(value, UnsafeNumericCast<uint32_t>(strlen(value))));
152991}

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