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

Static Public Member Functions

static void AddInPlace (Vector &left, int64_t delta, idx_t count)
 left += delta
static void IsNotNull (Vector &arg, Vector &result, idx_t count)
 result = IS NOT NULL(input)
static void IsNull (Vector &input, Vector &result, idx_t count)
 result = IS NULL (input)
static bool HasNull (Vector &input, idx_t count)
static bool HasNotNull (Vector &input, idx_t count)
static idx_t CountNotNull (Vector &input, const idx_t count)
 Count the number of not-NULL values.
static void And (Vector &left, Vector &right, Vector &result, idx_t count)
static void Or (Vector &left, Vector &right, Vector &result, idx_t count)
static void Not (Vector &left, Vector &result, idx_t count)
static void Equals (Vector &left, Vector &right, Vector &result, idx_t count)
static void NotEquals (Vector &left, Vector &right, Vector &result, idx_t count)
static void GreaterThan (Vector &left, Vector &right, Vector &result, idx_t count)
static void GreaterThanEquals (Vector &left, Vector &right, Vector &result, idx_t count)
static void LessThan (Vector &left, Vector &right, Vector &result, idx_t count)
static void LessThanEquals (Vector &left, Vector &right, Vector &result, idx_t count)
static void DistinctFrom (Vector &left, Vector &right, Vector &result, idx_t count)
static void NotDistinctFrom (Vector &left, Vector &right, Vector &result, idx_t count)
static void DistinctGreaterThan (Vector &left, Vector &right, Vector &result, idx_t count)
static void DistinctGreaterThanEquals (Vector &left, Vector &right, Vector &result, idx_t count)
static void DistinctLessThan (Vector &left, Vector &right, Vector &result, idx_t count)
static void DistinctLessThanEquals (Vector &left, Vector &right, Vector &result, idx_t count)
static idx_t Equals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t NotEquals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t GreaterThan (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t GreaterThanEquals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t LessThan (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t LessThanEquals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t DistinctFrom (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel)
static idx_t NotDistinctFrom (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel)
static idx_t DistinctGreaterThan (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t DistinctGreaterThanEquals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t DistinctLessThan (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t DistinctLessThanEquals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t DistinctGreaterThanNullsFirst (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t DistinctLessThanNullsFirst (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t NestedNotEquals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static idx_t NestedEquals (Vector &left, Vector &right, optional_ptr< const SelectionVector > sel, idx_t count, optional_ptr< SelectionVector > true_sel, optional_ptr< SelectionVector > false_sel, optional_ptr< ValidityMask > null_mask=nullptr)
static void Hash (Vector &input, Vector &hashes, idx_t count)
static void Hash (Vector &input, Vector &hashes, const SelectionVector &rsel, idx_t count)
static void CombineHash (Vector &hashes, Vector &input, idx_t count)
static void CombineHash (Vector &hashes, Vector &input, const SelectionVector &rsel, idx_t count)
static void GenerateSequence (Vector &result, idx_t count, int64_t start=0, int64_t increment=1)
static void GenerateSequence (Vector &result, idx_t count, const SelectionVector &sel, int64_t start=0, int64_t increment=1)
static DUCKDB_API bool TryCast (CastFunctionSet &set, GetCastFunctionInput &input, Vector &source, Vector &result, idx_t count, string *error_message, bool strict=false, const bool nullify_parent=false)
static DUCKDB_API bool DefaultTryCast (Vector &source, Vector &result, idx_t count, string *error_message, bool strict=false)
static DUCKDB_API bool TryCast (ClientContext &context, Vector &source, Vector &result, idx_t count, string *error_message, bool strict=false, const bool nullify_parent=false)
static DUCKDB_API void Cast (ClientContext &context, Vector &source, Vector &result, idx_t count, bool strict=false)
 Cast the data from the source type to the target type. Throws an exception if the cast fails.
static DUCKDB_API void DefaultCast (Vector &source, Vector &result, idx_t count, bool strict=false)
static void Copy (const Vector &source, Vector &target, idx_t source_count, idx_t source_offset, idx_t target_offset)
static void Copy (const Vector &source, Vector &target, const SelectionVector &sel, idx_t source_count, idx_t source_offset, idx_t target_offset)
static void Copy (const Vector &source, Vector &target, const SelectionVector &sel, idx_t source_count, idx_t source_offset, idx_t target_offset, idx_t copy_count)
static void WriteToStorage (Vector &source, idx_t count, data_ptr_t target)
static void ReadFromStorage (data_ptr_t source, idx_t count, Vector &result)

Member Function Documentation

◆ AddInPlace()

void duckdb::VectorOperations::AddInPlace ( Vector & left,
int64_t delta,
idx_t count )
static

left += delta

143413 {
143414 D_ASSERT(input.GetType().id() == LogicalTypeId::POINTER);
143415 if (right == 0) {
143416 return;
143417 }
143418 switch (input.GetVectorType()) {
143419 case VectorType::CONSTANT_VECTOR: {
143420 D_ASSERT(!ConstantVector::IsNull(input));
143421 auto data = ConstantVector::GetData<uintptr_t>(input);
143422 *data += UnsafeNumericCast<uintptr_t>(right);
143423 break;
143424 }
143425 default: {
143426 D_ASSERT(input.GetVectorType() == VectorType::FLAT_VECTOR);
143427 auto data = FlatVector::GetData<uintptr_t>(input);
143428 for (idx_t i = 0; i < count; i++) {
143429 data[i] = UnsafeNumericCast<uintptr_t>(UnsafeNumericCast<int64_t>(data[i]) + right);
143430 }
143431 break;
143432 }
143433 }
143434}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the caller graph for this function:

◆ IsNotNull()

void duckdb::VectorOperations::IsNotNull ( Vector & arg,
Vector & result,
idx_t count )
static

result = IS NOT NULL(input)

143316 {
143317 IsNullLoop<true>(input, result, count);
143318}

◆ IsNull()

void duckdb::VectorOperations::IsNull ( Vector & input,
Vector & result,
idx_t count )
static

result = IS NULL (input)

143320 {
143321 IsNullLoop<false>(input, result, count);
143322}

◆ HasNull()

bool duckdb::VectorOperations::HasNull ( Vector & input,
idx_t count )
static
143347 {
143348 if (count == 0) {
143349 return false;
143350 }
143351 if (input.GetVectorType() == VectorType::CONSTANT_VECTOR) {
143352 return ConstantVector::IsNull(input);
143353 } else {
143354 UnifiedVectorFormat data;
143355 input.ToUnifiedFormat(count, data);
143356
143357 if (data.validity.AllValid()) {
143358 return false;
143359 }
143360 for (idx_t i = 0; i < count; i++) {
143361 auto idx = data.sel->get_index(i);
143362 if (!data.validity.RowIsValid(idx)) {
143363 return true;
143364 }
143365 }
143366 return false;
143367 }
143368}

◆ HasNotNull()

bool duckdb::VectorOperations::HasNotNull ( Vector & input,
idx_t count )
static
143324 {
143325 if (count == 0) {
143326 return false;
143327 }
143328 if (input.GetVectorType() == VectorType::CONSTANT_VECTOR) {
143329 return !ConstantVector::IsNull(input);
143330 } else {
143331 UnifiedVectorFormat data;
143332 input.ToUnifiedFormat(count, data);
143333
143334 if (data.validity.AllValid()) {
143335 return true;
143336 }
143337 for (idx_t i = 0; i < count; i++) {
143338 auto idx = data.sel->get_index(i);
143339 if (data.validity.RowIsValid(idx)) {
143340 return true;
143341 }
143342 }
143343 return false;
143344 }
143345}

◆ CountNotNull()

idx_t duckdb::VectorOperations::CountNotNull ( Vector & input,
const idx_t count )
static

Count the number of not-NULL values.

143370 {
143371 idx_t valid = 0;
143372
143373 UnifiedVectorFormat vdata;
143374 input.ToUnifiedFormat(count, vdata);
143375 if (vdata.validity.AllValid()) {
143376 return count;
143377 }
143378 switch (input.GetVectorType()) {
143379 case VectorType::FLAT_VECTOR:
143380 valid += vdata.validity.CountValid(count);
143381 break;
143382 case VectorType::CONSTANT_VECTOR:
143383 valid += vdata.validity.CountValid(1) * count;
143384 break;
143385 default:
143386 for (idx_t i = 0; i < count; ++i) {
143387 const auto row_idx = vdata.sel->get_index(i);
143388 valid += idx_t(vdata.validity.RowIsValid(row_idx));
143389 }
143390 break;
143391 }
143392
143393 return valid;
143394}
Here is the call graph for this function:

◆ And()

void duckdb::VectorOperations::And ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141589 {
141590 TemplatedBooleanNullmask<TernaryAnd>(left, right, result, count);
141591}

◆ Or()

void duckdb::VectorOperations::Or ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141593 {
141594 TemplatedBooleanNullmask<TernaryOr>(left, right, result, count);
141595}

◆ Not()

void duckdb::VectorOperations::Not ( Vector & left,
Vector & result,
idx_t count )
static
141597 {
141598 D_ASSERT(input.GetType() == LogicalType::BOOLEAN && result.GetType() == LogicalType::BOOLEAN);
141599 UnaryExecutor::Execute<bool, bool, NotOperator>(input, result, count);
141600}

◆ Equals() [1/2]

void duckdb::VectorOperations::Equals ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141887 {
141888 ComparisonExecutor::Execute<duckdb::Equals>(left, right, result, count);
141889}

◆ NotEquals() [1/2]

void duckdb::VectorOperations::NotEquals ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141891 {
141892 ComparisonExecutor::Execute<duckdb::NotEquals>(left, right, result, count);
141893}

◆ GreaterThan() [1/2]

void duckdb::VectorOperations::GreaterThan ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141903 {
141904 ComparisonExecutor::Execute<duckdb::GreaterThan>(left, right, result, count);
141905}

◆ GreaterThanEquals() [1/2]

void duckdb::VectorOperations::GreaterThanEquals ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141895 {
141896 ComparisonExecutor::Execute<duckdb::GreaterThanEquals>(left, right, result, count);
141897}

◆ LessThan() [1/2]

void duckdb::VectorOperations::LessThan ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141907 {
141908 ComparisonExecutor::Execute<duckdb::GreaterThan>(right, left, result, count);
141909}

◆ LessThanEquals() [1/2]

void duckdb::VectorOperations::LessThanEquals ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
141899 {
141900 ComparisonExecutor::Execute<duckdb::GreaterThanEquals>(right, left, result, count);
141901}

◆ DistinctFrom() [1/2]

void duckdb::VectorOperations::DistinctFrom ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
143192 {
143193 ExecuteDistinct<duckdb::DistinctFrom>(left, right, result, count);
143194}

◆ NotDistinctFrom() [1/2]

void duckdb::VectorOperations::NotDistinctFrom ( Vector & left,
Vector & right,
Vector & result,
idx_t count )
static
143196 {
143197 ExecuteDistinct<duckdb::NotDistinctFrom>(left, right, result, count);
143198}

◆ Equals() [2/2]

idx_t duckdb::VectorOperations::Equals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
148774 {
148775 return TemplatedSelectOperation<duckdb::Equals>(left, right, sel, count, true_sel, false_sel, null_mask);
148776}

◆ NotEquals() [2/2]

idx_t duckdb::VectorOperations::NotEquals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
148780 {
148781 return TemplatedSelectOperation<duckdb::NotEquals>(left, right, sel, count, true_sel, false_sel, null_mask);
148782}

◆ GreaterThan() [2/2]

idx_t duckdb::VectorOperations::GreaterThan ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
148786 {
148787 return TemplatedSelectOperation<duckdb::GreaterThan>(left, right, sel, count, true_sel, false_sel, null_mask);
148788}

◆ GreaterThanEquals() [2/2]

idx_t duckdb::VectorOperations::GreaterThanEquals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
148793 {
148794 return TemplatedSelectOperation<duckdb::GreaterThanEquals>(left, right, sel, count, true_sel, false_sel, null_mask);
148795}

◆ LessThan() [2/2]

idx_t duckdb::VectorOperations::LessThan ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
148799 {
148800 return TemplatedSelectOperation<duckdb::GreaterThan>(right, left, sel, count, true_sel, false_sel, null_mask);
148801}

◆ LessThanEquals() [2/2]

idx_t duckdb::VectorOperations::LessThanEquals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
148805 {
148806 return TemplatedSelectOperation<duckdb::GreaterThanEquals>(right, left, sel, count, true_sel, false_sel, null_mask);
148807}

◆ DistinctFrom() [2/2]

idx_t duckdb::VectorOperations::DistinctFrom ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel )
static
143202 {
143203 return TemplatedDistinctSelectOperation<duckdb::DistinctFrom>(left, right, sel, count, true_sel, false_sel,
143204 nullptr);
143205}

◆ NotDistinctFrom() [2/2]

idx_t duckdb::VectorOperations::NotDistinctFrom ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel )
static
143209 {
143210 return count - TemplatedDistinctSelectOperation<duckdb::DistinctFrom>(left, right, sel, count, false_sel, true_sel,
143211 nullptr);
143212}

◆ DistinctGreaterThan()

idx_t duckdb::VectorOperations::DistinctGreaterThan ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143218 {
143219 return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan>(left, right, sel, count, true_sel, false_sel,
143220 null_mask);
143221}

◆ DistinctGreaterThanEquals()

idx_t duckdb::VectorOperations::DistinctGreaterThanEquals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143237 {
143238 return count - TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan>(right, left, sel, count, false_sel,
143239 true_sel, null_mask);
143240}

◆ DistinctLessThan()

idx_t duckdb::VectorOperations::DistinctLessThan ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143245 {
143246 return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan>(right, left, sel, count, true_sel, false_sel,
143247 null_mask);
143248}

◆ DistinctLessThanEquals()

idx_t duckdb::VectorOperations::DistinctLessThanEquals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143263 {
143264 return count - TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan>(left, right, sel, count, false_sel,
143265 true_sel, null_mask);
143266}

◆ DistinctGreaterThanNullsFirst()

idx_t duckdb::VectorOperations::DistinctGreaterThanNullsFirst ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143228 {
143229 return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanNullsFirst>(left, right, sel, count, true_sel,
143230 false_sel, null_mask);
143231}

◆ DistinctLessThanNullsFirst()

idx_t duckdb::VectorOperations::DistinctLessThanNullsFirst ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143254 {
143255 return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanNullsFirst>(right, left, sel, count, true_sel,
143256 false_sel, nullptr);
143257}

◆ NestedNotEquals()

idx_t duckdb::VectorOperations::NestedNotEquals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143271 {
143272 return TemplatedDistinctSelectOperation<duckdb::DistinctFrom>(left, right, sel, count, true_sel, false_sel,
143273 null_mask);
143274}

◆ NestedEquals()

idx_t duckdb::VectorOperations::NestedEquals ( Vector & left,
Vector & right,
optional_ptr< const SelectionVector > sel,
idx_t count,
optional_ptr< SelectionVector > true_sel,
optional_ptr< SelectionVector > false_sel,
optional_ptr< ValidityMask > null_mask = nullptr )
static
143278 {
143279 return count - TemplatedDistinctSelectOperation<duckdb::DistinctFrom>(left, right, sel, count, false_sel, true_sel,
143280 null_mask);
143281}

◆ Hash() [1/2]

void duckdb::VectorOperations::Hash ( Vector & input,
Vector & hashes,
idx_t count )
static
144246 {
144247 if (input.GetVectorType() == VectorType::DICTIONARY_VECTOR && DictionaryVector::CanCacheHashes(input)) {
144248 Vector input_hashes(DictionaryVector::GetCachedHashes(input), DictionaryVector::SelVector(input), count);
144249 TemplatedLoopHash<false, hash_t, true>(input_hashes, result, nullptr, count);
144250 } else {
144251 HashTypeSwitch<false>(input, result, nullptr, count);
144252 }
144253}

◆ Hash() [2/2]

void duckdb::VectorOperations::Hash ( Vector & input,
Vector & hashes,
const SelectionVector & rsel,
idx_t count )
static
144255 {
144256 if (input.GetVectorType() == VectorType::DICTIONARY_VECTOR && DictionaryVector::CanCacheHashes(input)) {
144257 Vector input_hashes(DictionaryVector::GetCachedHashes(input), DictionaryVector::SelVector(input), count);
144258 TemplatedLoopHash<true, hash_t, true>(input_hashes, result, &sel, count);
144259 } else {
144260 HashTypeSwitch<true>(input, result, &sel, count);
144261 }
144262}

◆ CombineHash() [1/2]

void duckdb::VectorOperations::CombineHash ( Vector & hashes,
Vector & input,
idx_t count )
static
144264 {
144265 if (input.GetVectorType() == VectorType::DICTIONARY_VECTOR && DictionaryVector::CanCacheHashes(input)) {
144266 Vector input_hashes(DictionaryVector::GetCachedHashes(input), DictionaryVector::SelVector(input), count);
144267 TemplatedLoopCombineHash<false, hash_t, true>(input_hashes, hashes, nullptr, count);
144268 } else {
144269 CombineHashTypeSwitch<false>(hashes, input, nullptr, count);
144270 }
144271}

◆ CombineHash() [2/2]

void duckdb::VectorOperations::CombineHash ( Vector & hashes,
Vector & input,
const SelectionVector & rsel,
idx_t count )
static
144273 {
144274 if (input.GetVectorType() == VectorType::DICTIONARY_VECTOR && DictionaryVector::CanCacheHashes(input)) {
144275 Vector input_hashes(DictionaryVector::GetCachedHashes(input), DictionaryVector::SelVector(input), count);
144276 TemplatedLoopCombineHash<true, hash_t, true>(input_hashes, hashes, &rsel, count);
144277 } else {
144278 CombineHashTypeSwitch<true>(hashes, input, &rsel, count);
144279 }
144280}

◆ GenerateSequence() [1/2]

void duckdb::VectorOperations::GenerateSequence ( Vector & result,
idx_t count,
int64_t start = 0,
int64_t increment = 1 )
static
141941 {
141942 if (!result.GetType().IsNumeric()) {
141943 throw InvalidTypeException(result.GetType(), "Can only generate sequences for numeric values!");
141944 }
141945 switch (result.GetType().InternalType()) {
141946 case PhysicalType::INT8:
141947 TemplatedGenerateSequence<int8_t>(result, count, start, increment);
141948 break;
141949 case PhysicalType::INT16:
141950 TemplatedGenerateSequence<int16_t>(result, count, start, increment);
141951 break;
141952 case PhysicalType::INT32:
141953 TemplatedGenerateSequence<int32_t>(result, count, start, increment);
141954 break;
141955 case PhysicalType::INT64:
141956 TemplatedGenerateSequence<int64_t>(result, count, start, increment);
141957 break;
141958 default:
141959 throw NotImplementedException("Unimplemented type for generate sequence");
141960 }
141961}
@ 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
@ INT8
Signed 8-bit little-endian integer.
Definition duckdb.hpp:2749

◆ GenerateSequence() [2/2]

void duckdb::VectorOperations::GenerateSequence ( Vector & result,
idx_t count,
const SelectionVector & sel,
int64_t start = 0,
int64_t increment = 1 )
static
141980 {
141981 if (!result.GetType().IsNumeric()) {
141982 throw InvalidTypeException(result.GetType(), "Can only generate sequences for numeric values!");
141983 }
141984 switch (result.GetType().InternalType()) {
141985 case PhysicalType::INT8:
141986 TemplatedGenerateSequence<int8_t>(result, count, sel, start, increment);
141987 break;
141988 case PhysicalType::INT16:
141989 TemplatedGenerateSequence<int16_t>(result, count, sel, start, increment);
141990 break;
141991 case PhysicalType::INT32:
141992 TemplatedGenerateSequence<int32_t>(result, count, sel, start, increment);
141993 break;
141994 case PhysicalType::INT64:
141995 TemplatedGenerateSequence<int64_t>(result, count, sel, start, increment);
141996 break;
141997 default:
141998 throw NotImplementedException("Unimplemented type for generate sequence");
141999 }
142000}

◆ TryCast() [1/2]

bool duckdb::VectorOperations::TryCast ( CastFunctionSet & set,
GetCastFunctionInput & input,
Vector & source,
Vector & result,
idx_t count,
string * error_message,
bool strict = false,
const bool nullify_parent = false )
static

Cast the data from the source type to the target type. Any elements that could not be converted are turned into NULLs. If any elements cannot be converted, returns false and fills in the error_message. If no error message is provided, an exception is thrown instead.

143446 {
143447 auto cast_function = set.GetCastFunction(source.GetType(), result.GetType(), input);
143448 unique_ptr<FunctionLocalState> local_state;
143449 if (cast_function.init_local_state) {
143450 CastLocalStateParameters lparameters(input.context, cast_function.cast_data);
143451 local_state = cast_function.init_local_state(lparameters);
143452 }
143453 CastParameters parameters(cast_function.cast_data.get(), strict, error_message, local_state.get(), nullify_parent);
143454 return cast_function.function(source, result, count, parameters);
143455}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultTryCast()

bool duckdb::VectorOperations::DefaultTryCast ( Vector & source,
Vector & result,
idx_t count,
string * error_message,
bool strict = false )
static
143457 {
143458 CastFunctionSet set;
143459 GetCastFunctionInput input;
143460 return VectorOperations::TryCast(set, input, source, result, count, error_message, strict);
143461}
static DUCKDB_API bool TryCast(CastFunctionSet &set, GetCastFunctionInput &input, Vector &source, Vector &result, idx_t count, string *error_message, bool strict=false, const bool nullify_parent=false)
Definition duckdb.cpp:143445

◆ TryCast() [2/2]

bool duckdb::VectorOperations::TryCast ( ClientContext & context,
Vector & source,
Vector & result,
idx_t count,
string * error_message,
bool strict = false,
const bool nullify_parent = false )
static
143468 {
143469 auto &config = DBConfig::GetConfig(context);
143470 auto &set = config.GetCastFunctions();
143471 GetCastFunctionInput get_input(context);
143472 return VectorOperations::TryCast(set, get_input, source, result, count, error_message, strict, nullify_parent);
143473}

◆ Cast()

void duckdb::VectorOperations::Cast ( ClientContext & context,
Vector & source,
Vector & result,
idx_t count,
bool strict = false )
static

Cast the data from the source type to the target type. Throws an exception if the cast fails.

143475 {
143476 VectorOperations::TryCast(context, source, result, count, nullptr, strict);
143477}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultCast()

void duckdb::VectorOperations::DefaultCast ( Vector & source,
Vector & result,
idx_t count,
bool strict = false )
static
143463 {
143464 VectorOperations::DefaultTryCast(source, result, count, nullptr, strict);
143465}

◆ Copy() [1/3]

void duckdb::VectorOperations::Copy ( const Vector & source,
Vector & target,
idx_t source_count,
idx_t source_offset,
idx_t target_offset )
static
143757 {
143758 VectorOperations::Copy(source, target, *FlatVector::IncrementalSelectionVector(), source_count, source_offset,
143759 target_offset);
143760}

◆ Copy() [2/3]

void duckdb::VectorOperations::Copy ( const Vector & source,
Vector & target,
const SelectionVector & sel,
idx_t source_count,
idx_t source_offset,
idx_t target_offset )
static
143749 {
143750 D_ASSERT(source_offset <= source_count);
143751 D_ASSERT(source_p.GetType() == target.GetType());
143752 idx_t copy_count = source_count - source_offset;
143753 VectorOperations::Copy(source_p, target, sel_p, source_count, source_offset, target_offset, copy_count);
143754}

◆ Copy() [3/3]

void duckdb::VectorOperations::Copy ( const Vector & source,
Vector & target,
const SelectionVector & sel,
idx_t source_count,
idx_t source_offset,
idx_t target_offset,
idx_t copy_count )
static

overwrite constant target vectors.

if the source has list offsets, we need to append them to the target build a selection vector for the copied child elements

append to list itself

now write the list offsets

143520 {
143521 SelectionVector owned_sel;
143522 const SelectionVector *sel = &sel_p;
143523
143524 const Vector *source = &source_p;
143525 bool finished = false;
143526 while (!finished) {
143527 switch (source->GetVectorType()) {
143528 case VectorType::DICTIONARY_VECTOR: {
143529 // dictionary vector: merge selection vectors
143530 auto &child = DictionaryVector::Child(*source);
143531 auto &dict_sel = DictionaryVector::SelVector(*source);
143532 // merge the selection vectors and verify the child
143533 auto new_buffer = dict_sel.Slice(*sel, source_count);
143534 owned_sel.Initialize(new_buffer);
143535 sel = &owned_sel;
143536 source = &child;
143537 break;
143538 }
143539 case VectorType::SEQUENCE_VECTOR: {
143540 int64_t start, increment;
143541 Vector seq(source->GetType());
143542 SequenceVector::GetSequence(*source, start, increment);
143543 VectorOperations::GenerateSequence(seq, source_count, *sel, start, increment);
143544 VectorOperations::Copy(seq, target, *sel, source_count, source_offset, target_offset);
143545 return;
143546 }
143547 case VectorType::CONSTANT_VECTOR:
143548 sel = ConstantVector::ZeroSelectionVector(copy_count, owned_sel);
143549 finished = true;
143550 break;
143551 case VectorType::FSST_VECTOR:
143552 finished = true;
143553 break;
143554 case VectorType::FLAT_VECTOR:
143555 finished = true;
143556 break;
143557 default:
143558 throw NotImplementedException("FIXME unimplemented vector type for VectorOperations::Copy");
143559 }
143560 }
143561
143562 if (copy_count == 0) {
143563 return;
143564 }
143565
143566 // Allow copying of a single value to constant vectors
143567 const auto target_vector_type = target.GetVectorType();
143568 if (copy_count == 1 && target_vector_type == VectorType::CONSTANT_VECTOR) {
143569 target_offset = 0;
143570 target.SetVectorType(VectorType::FLAT_VECTOR);
143571 }
143572 D_ASSERT(target.GetVectorType() == VectorType::FLAT_VECTOR);
143573
143574 // first copy the nullmask
143575 auto &tmask = FlatVector::Validity(target);
143576 if (source->GetVectorType() == VectorType::CONSTANT_VECTOR) {
143577 const bool valid = !ConstantVector::IsNull(*source);
143578 for (idx_t i = 0; i < copy_count; i++) {
143579 tmask.Set(target_offset + i, valid);
143580 }
143581 } else {
143582 auto &smask = ExtractValidityMask(*source);
143583 tmask.CopySel(smask, *sel, source_offset, target_offset, copy_count);
143584 }
143585
143586 D_ASSERT(sel);
143587
143588 // For FSST Vectors we decompress instead of copying.
143589 if (source->GetVectorType() == VectorType::FSST_VECTOR) {
143590 FSSTVector::DecompressVector(*source, target, source_offset, target_offset, copy_count, sel);
143591 return;
143592 }
143593
143594 // now copy over the data
143595 switch (source->GetType().InternalType()) {
143596 case PhysicalType::BOOL:
143597 case PhysicalType::INT8:
143598 TemplatedCopy<int8_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143599 break;
143600 case PhysicalType::INT16:
143601 TemplatedCopy<int16_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143602 break;
143603 case PhysicalType::INT32:
143604 TemplatedCopy<int32_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143605 break;
143606 case PhysicalType::INT64:
143607 TemplatedCopy<int64_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143608 break;
143609 case PhysicalType::UINT8:
143610 TemplatedCopy<uint8_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143611 break;
143613 TemplatedCopy<uint16_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143614 break;
143616 TemplatedCopy<uint32_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143617 break;
143619 TemplatedCopy<uint64_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143620 break;
143621 case PhysicalType::INT128:
143622 TemplatedCopy<hugeint_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143623 break;
143624 case PhysicalType::UINT128:
143625 TemplatedCopy<uhugeint_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143626 break;
143627 case PhysicalType::FLOAT:
143628 TemplatedCopy<float>(*source, *sel, target, source_offset, target_offset, copy_count);
143629 break;
143631 TemplatedCopy<double>(*source, *sel, target, source_offset, target_offset, copy_count);
143632 break;
143634 TemplatedCopy<interval_t>(*source, *sel, target, source_offset, target_offset, copy_count);
143635 break;
143636 case PhysicalType::VARCHAR: {
143637 auto ldata = FlatVector::GetData<string_t>(*source);
143638 auto tdata = FlatVector::GetData<string_t>(target);
143639 for (idx_t i = 0; i < copy_count; i++) {
143640 auto source_idx = sel->get_index(source_offset + i);
143641 auto target_idx = target_offset + i;
143642 if (tmask.RowIsValid(target_idx)) {
143643 tdata[target_idx] = StringVector::AddStringOrBlob(target, ldata[source_idx]);
143644 }
143645 }
143646 break;
143647 }
143648 case PhysicalType::STRUCT: {
143649 auto &source_children = StructVector::GetEntries(*source);
143650 auto &target_children = StructVector::GetEntries(target);
143651 D_ASSERT(source_children.size() == target_children.size());
143652 for (idx_t i = 0; i < source_children.size(); i++) {
143653 VectorOperations::Copy(*source_children[i], *target_children[i], sel_p, source_count, source_offset,
143654 target_offset, copy_count);
143655 }
143656 break;
143657 }
143658 case PhysicalType::ARRAY: {
143659 D_ASSERT(target.GetType().InternalType() == PhysicalType::ARRAY);
143660 D_ASSERT(ArrayType::GetSize(source->GetType()) == ArrayType::GetSize(target.GetType()));
143661
143662 auto &source_child = ArrayVector::GetEntry(*source);
143663 auto &target_child = ArrayVector::GetEntry(target);
143664 auto array_size = ArrayType::GetSize(source->GetType());
143665
143666 // Create a selection vector for the child elements
143667 SelectionVector child_sel(source_count * array_size);
143668 for (idx_t i = 0; i < copy_count; i++) {
143669 auto source_idx = sel->get_index(source_offset + i);
143670 for (idx_t j = 0; j < array_size; j++) {
143671 child_sel.set_index((source_offset * array_size) + (i * array_size + j), source_idx * array_size + j);
143672 }
143673 }
143674 VectorOperations::Copy(source_child, target_child, child_sel, source_count * array_size,
143675 source_offset * array_size, target_offset * array_size);
143676 break;
143677 }
143678 case PhysicalType::LIST: {
143679 D_ASSERT(target.GetType().InternalType() == PhysicalType::LIST);
143680
143681 auto &source_child = ListVector::GetEntry(*source);
143682 auto sdata = FlatVector::GetData<list_entry_t>(*source);
143683 auto tdata = FlatVector::GetData<list_entry_t>(target);
143684
143685 if (target_vector_type == VectorType::CONSTANT_VECTOR) {
143686 // If we are only writing one value, then the copied values (if any) are contiguous
143687 // and we can just Append from the offset position
143688 if (!tmask.RowIsValid(target_offset)) {
143689 break;
143690 }
143691 auto source_idx = sel->get_index(source_offset);
143692 auto &source_entry = sdata[source_idx];
143693 const idx_t source_child_size = source_entry.length + source_entry.offset;
143694
143696 ListVector::SetListSize(target, 0);
143697 ListVector::Append(target, source_child, source_child_size, source_entry.offset);
143698
143699 auto &target_entry = tdata[target_offset];
143700 target_entry.length = source_entry.length;
143701 target_entry.offset = 0;
143702 } else {
143705 vector<sel_t> child_rows;
143706 for (idx_t i = 0; i < copy_count; ++i) {
143707 if (tmask.RowIsValid(target_offset + i)) {
143708 auto source_idx = sel->get_index(source_offset + i);
143709 auto &source_entry = sdata[source_idx];
143710 for (idx_t j = 0; j < source_entry.length; ++j) {
143711 child_rows.emplace_back(source_entry.offset + j);
143712 }
143713 }
143714 }
143715 idx_t source_child_size = child_rows.size();
143716 SelectionVector child_sel(child_rows.data());
143717
143718 idx_t old_target_child_len = ListVector::GetListSize(target);
143719
143721 ListVector::Append(target, source_child, child_sel, source_child_size);
143722
143724 for (idx_t i = 0; i < copy_count; i++) {
143725 auto source_idx = sel->get_index(source_offset + i);
143726 auto &source_entry = sdata[source_idx];
143727 auto &target_entry = tdata[target_offset + i];
143728
143729 target_entry.length = source_entry.length;
143730 target_entry.offset = old_target_child_len;
143731 if (tmask.RowIsValid(target_offset + i)) {
143732 old_target_child_len += target_entry.length;
143733 }
143734 }
143735 }
143736 break;
143737 }
143738 default:
143739 throw NotImplementedException("Unimplemented type '%s' for copy!",
143740 TypeIdToString(source->GetType().InternalType()));
143741 }
143742
143743 if (target_vector_type != VectorType::FLAT_VECTOR) {
143744 target.SetVectorType(target_vector_type);
143745 }
143746}
::int64_t int64_t
@ UINT32
Unsigned 32-bit little-endian integer.
Definition duckdb.hpp:2758
@ INTERVAL
YEAR_MONTH or DAY_TIME interval in SQL style.
Definition duckdb.hpp:2806
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813
@ UINT16
Unsigned 16-bit little-endian integer.
Definition duckdb.hpp:2752
@ UINT64
Unsigned 64-bit little-endian integer.
Definition duckdb.hpp:2764
@ BOOL
Boolean as 8 bit "bool" value.
Definition duckdb.hpp:2743
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816
@ 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
@ DOUBLE
8-byte floating point value
Definition duckdb.hpp:2776
static DUCKDB_API const Vector & GetEntry(const Vector &vector)
Gets a reference to the underlying child-vector of an array.
Definition duckdb.cpp:138574
static void DecompressVector(const Vector &src, Vector &dst, idx_t src_offset, idx_t dst_offset, idx_t copy_count, const SelectionVector *sel)
Decompresses an FSST_VECTOR into a FLAT_VECTOR. Note: validity is not copied.
Definition duckdb.cpp:138054
static DUCKDB_API void Append(Vector &target, const Vector &source, idx_t source_size, idx_t source_offset=0)
Definition duckdb.cpp:138257
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
static DUCKDB_API string_t AddStringOrBlob(Vector &vector, const char *data, idx_t len)
Definition duckdb.cpp:137893
Here is the call graph for this function:

◆ WriteToStorage()

void duckdb::VectorOperations::WriteToStorage ( Vector & source,
idx_t count,
data_ptr_t target )
static
144317 {
144318 if (count == 0) {
144319 return;
144320 }
144321 UnifiedVectorFormat vdata;
144322 source.ToUnifiedFormat(count, vdata);
144323
144324 switch (source.GetType().InternalType()) {
144325 case PhysicalType::BOOL:
144326 case PhysicalType::INT8:
144327 CopyToStorageLoop<int8_t>(vdata, count, target);
144328 break;
144329 case PhysicalType::INT16:
144330 CopyToStorageLoop<int16_t>(vdata, count, target);
144331 break;
144332 case PhysicalType::INT32:
144333 CopyToStorageLoop<int32_t>(vdata, count, target);
144334 break;
144335 case PhysicalType::INT64:
144336 CopyToStorageLoop<int64_t>(vdata, count, target);
144337 break;
144338 case PhysicalType::UINT8:
144339 CopyToStorageLoop<uint8_t>(vdata, count, target);
144340 break;
144342 CopyToStorageLoop<uint16_t>(vdata, count, target);
144343 break;
144345 CopyToStorageLoop<uint32_t>(vdata, count, target);
144346 break;
144348 CopyToStorageLoop<uint64_t>(vdata, count, target);
144349 break;
144350 case PhysicalType::INT128:
144351 CopyToStorageLoop<hugeint_t>(vdata, count, target);
144352 break;
144353 case PhysicalType::UINT128:
144354 CopyToStorageLoop<uhugeint_t>(vdata, count, target);
144355 break;
144356 case PhysicalType::FLOAT:
144357 CopyToStorageLoop<float>(vdata, count, target);
144358 break;
144360 CopyToStorageLoop<double>(vdata, count, target);
144361 break;
144363 CopyToStorageLoop<interval_t>(vdata, count, target);
144364 break;
144365 default:
144366 throw NotImplementedException("Unimplemented type for WriteToStorage");
144367 }
144368}

◆ ReadFromStorage()

void duckdb::VectorOperations::ReadFromStorage ( data_ptr_t source,
idx_t count,
Vector & result )
static
144370 {
144371 result.SetVectorType(VectorType::FLAT_VECTOR);
144372 switch (result.GetType().InternalType()) {
144373 case PhysicalType::BOOL:
144374 case PhysicalType::INT8:
144375 ReadFromStorageLoop<int8_t>(source, count, result);
144376 break;
144377 case PhysicalType::INT16:
144378 ReadFromStorageLoop<int16_t>(source, count, result);
144379 break;
144380 case PhysicalType::INT32:
144381 ReadFromStorageLoop<int32_t>(source, count, result);
144382 break;
144383 case PhysicalType::INT64:
144384 ReadFromStorageLoop<int64_t>(source, count, result);
144385 break;
144386 case PhysicalType::UINT8:
144387 ReadFromStorageLoop<uint8_t>(source, count, result);
144388 break;
144390 ReadFromStorageLoop<uint16_t>(source, count, result);
144391 break;
144393 ReadFromStorageLoop<uint32_t>(source, count, result);
144394 break;
144396 ReadFromStorageLoop<uint64_t>(source, count, result);
144397 break;
144398 case PhysicalType::INT128:
144399 ReadFromStorageLoop<hugeint_t>(source, count, result);
144400 break;
144401 case PhysicalType::UINT128:
144402 ReadFromStorageLoop<uhugeint_t>(source, count, result);
144403 break;
144404 case PhysicalType::FLOAT:
144405 ReadFromStorageLoop<float>(source, count, result);
144406 break;
144408 ReadFromStorageLoop<double>(source, count, result);
144409 break;
144411 ReadFromStorageLoop<interval_t>(source, count, result);
144412 break;
144413 default:
144414 throw NotImplementedException("Unimplemented type for ReadFromStorage");
144415 }
144416}

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