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

Static Public Member Functions

template<class SRC, class DST, class OP>
static bool TemplatedCastLoop (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<class SRC, class DST, class OP>
static bool TemplatedTryCastLoop (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<class SRC, class DST, class OP>
static bool TryCastLoop (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<class SRC, class DST, class OP>
static bool TryCastStrictLoop (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<class SRC, class DST, class OP>
static bool TryCastErrorLoop (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<class SRC, class DST, class OP>
static bool TryCastStringLoop (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<class SRC, class OP, class RES = string_t>
static bool StringCast (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<class SRC, class T, class OP>
static bool TemplatedDecimalCast (Vector &source, Vector &result, idx_t count, CastParameters &parameters, uint8_t width, uint8_t scale)
template<class T>
static bool ToDecimalCast (Vector &source, Vector &result, idx_t count, CastParameters &parameters)
template<bool STRUCT_KEY>
static idx_t CalculateEscapedStringLength (const string_t &string, bool &needs_quotes)
static idx_t CalculateStringLength (const string_t &string, bool &needs_quotes)
template<bool STRUCT_KEY>
static idx_t WriteEscapedString (void *dest, const string_t &string, bool needs_quotes)
static idx_t WriteString (void *dest, const string_t &string, bool needs_quotes)

Member Function Documentation

◆ TemplatedCastLoop()

template<class SRC, class DST, class OP>
bool duckdb::VectorCastHelpers::TemplatedCastLoop ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212410 {
212411 UnaryExecutor::Execute<SRC, DST, OP>(source, result, count);
212412 return true;
212413 }

◆ TemplatedTryCastLoop()

template<class SRC, class DST, class OP>
bool duckdb::VectorCastHelpers::TemplatedTryCastLoop ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212416 {
212417 VectorTryCastData input(result, parameters);
212418 UnaryExecutor::GenericExecute<SRC, DST, OP>(source, result, count, &input, parameters.error_message);
212419 return input.all_converted;
212420 }

◆ TryCastLoop()

template<class SRC, class DST, class OP>
bool duckdb::VectorCastHelpers::TryCastLoop ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212423 {
212424 return TemplatedTryCastLoop<SRC, DST, VectorTryCastOperator<OP>>(source, result, count, parameters);
212425 }

◆ TryCastStrictLoop()

template<class SRC, class DST, class OP>
bool duckdb::VectorCastHelpers::TryCastStrictLoop ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212428 {
212429 return TemplatedTryCastLoop<SRC, DST, VectorTryCastStrictOperator<OP>>(source, result, count, parameters);
212430 }

◆ TryCastErrorLoop()

template<class SRC, class DST, class OP>
bool duckdb::VectorCastHelpers::TryCastErrorLoop ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212433 {
212434 return TemplatedTryCastLoop<SRC, DST, VectorTryCastErrorOperator<OP>>(source, result, count, parameters);
212435 }

◆ TryCastStringLoop()

template<class SRC, class DST, class OP>
bool duckdb::VectorCastHelpers::TryCastStringLoop ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212438 {
212439 return TemplatedTryCastLoop<SRC, DST, VectorTryCastStringOperator<OP>>(source, result, count, parameters);
212440 }

◆ StringCast()

template<class SRC, class OP, class RES = string_t>
bool duckdb::VectorCastHelpers::StringCast ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212443 {
212444 D_ASSERT(result.GetType().InternalType() == PhysicalType::VARCHAR);
212445 UnaryExecutor::GenericExecute<SRC, RES, VectorStringCastOperator<OP>>(source, result, count, (void *)&result);
212446 return true;
212447 }
@ VARCHAR
DuckDB Extensions.
Definition duckdb.hpp:2847

◆ TemplatedDecimalCast()

template<class SRC, class T, class OP>
bool duckdb::VectorCastHelpers::TemplatedDecimalCast ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters,
uint8_t width,
uint8_t scale )
inlinestatic
212451 {
212452 VectorDecimalCastData input(result, parameters, width, scale);
212453 UnaryExecutor::GenericExecute<SRC, T, VectorDecimalCastOperator<OP>>(source, result, count, (void *)&input,
212454 parameters.error_message);
212455 return input.vector_cast_data.all_converted;
212456 }

◆ ToDecimalCast()

template<class T>
bool duckdb::VectorCastHelpers::ToDecimalCast ( Vector & source,
Vector & result,
idx_t count,
CastParameters & parameters )
inlinestatic
212459 {
212460 auto &result_type = result.GetType();
212461 auto width = DecimalType::GetWidth(result_type);
212462 auto scale = DecimalType::GetScale(result_type);
212463 switch (result_type.InternalType()) {
212464 case PhysicalType::INT16:
212465 return TemplatedDecimalCast<T, int16_t, TryCastToDecimal>(source, result, count, parameters, width, scale);
212466 case PhysicalType::INT32:
212467 return TemplatedDecimalCast<T, int32_t, TryCastToDecimal>(source, result, count, parameters, width, scale);
212468 case PhysicalType::INT64:
212469 return TemplatedDecimalCast<T, int64_t, TryCastToDecimal>(source, result, count, parameters, width, scale);
212470 case PhysicalType::INT128:
212471 return TemplatedDecimalCast<T, hugeint_t, TryCastToDecimal>(source, result, count, parameters, width,
212472 scale);
212473 default:
212474 throw InternalException("Unimplemented internal type for decimal");
212475 }
212476 }
void scale(cv::Mat &mat, const cv::Mat &range, const T min, const T max)
@ 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

◆ CalculateEscapedStringLength()

template<bool STRUCT_KEY>
idx_t duckdb::VectorCastHelpers::CalculateEscapedStringLength ( const string_t & string,
bool & needs_quotes )
inlinestatic

Empty quotes

212479 {
212480 auto base_length = string.GetSize();
212481 idx_t length = 0;
212482 auto string_data = string.GetData();
212483 needs_quotes = false;
212484
212485 if (base_length == 0) {
212487 needs_quotes = true;
212488 return 2;
212489 }
212490
212491 if (STRUCT_KEY) {
212492 needs_quotes = true;
212493 } else if (StringUtil::CharacterIsSpace(string_data[0])) {
212494 needs_quotes = true;
212495 } else if (base_length >= 2 && StringUtil::CharacterIsSpace(string_data[base_length - 1])) {
212496 needs_quotes = true;
212497 } else if (StringUtil::CIEquals(string_data, base_length, "null", 4)) {
212498 needs_quotes = true;
212499 } else {
212500 const bool *table = NestedToVarcharCast::LOOKUP_TABLE;
212501 for (idx_t i = 0; i < base_length; i++) {
212502 needs_quotes |= table[(uint8_t)string_data[i]];
212503 }
212504 }
212505
212506 if (!needs_quotes) {
212507 return base_length;
212508 }
212509
212510 for (idx_t i = 0; i < base_length; i++) {
212511 length += 1 + (string_data[i] == '\'' || string_data[i] == '\\');
212512 }
212513 length += 2;
212514 return length;
212515 }
static DUCKDB_API bool CIEquals(const string &l1, const string &l2)
Case insensitive equals.
Definition duckdb.cpp:109696
::uint8_t uint8_t
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateStringLength()

idx_t duckdb::VectorCastHelpers::CalculateStringLength ( const string_t & string,
bool & needs_quotes )
inlinestatic
212517 {
212518 needs_quotes = false;
212519 return string.GetSize();
212520 }

◆ WriteEscapedString()

template<bool STRUCT_KEY>
idx_t duckdb::VectorCastHelpers::WriteEscapedString ( void * dest,
const string_t & string,
bool needs_quotes )
inlinestatic
212523 {
212524 auto base_length = string.GetSize();
212525 if (base_length == 0) {
212526 D_ASSERT(needs_quotes);
212527 memcpy(dest, "''", 2);
212528 return 2;
212529 }
212530
212531 auto string_start = string.GetData();
212532 auto string_data = string_start;
212533
212534 auto destination = reinterpret_cast<char *>(dest);
212535 if (!needs_quotes) {
212536 memcpy(destination, string_data, base_length);
212537 return base_length;
212538 }
212539
212540 idx_t offset = 0;
212541 destination[offset++] = '\'';
212542
212543 for (idx_t i = 0; i < base_length; i++) {
212544 const bool needs_quote = string_data[i] == '\\' || string_data[i] == '\'';
212545 destination[offset] = '\\';
212546 destination[offset + needs_quote] = string_data[i];
212547 offset += 1 + needs_quote;
212548 }
212549
212550 destination[offset++] = '\'';
212551 return offset;
212552 }

◆ WriteString()

idx_t duckdb::VectorCastHelpers::WriteString ( void * dest,
const string_t & string,
bool needs_quotes )
inlinestatic
212554 {
212555 D_ASSERT(needs_quotes == false);
212556 auto len = string.GetSize();
212557 memcpy(dest, string.GetData(), len);
212558 return len;
212559 }

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