210211 {
210212
210213 const bool nulls_last =
210214 input_data.bind_data ? input_data.bind_data->Cast<ArgMinMaxFunctionData>().nulls_last : true;
210215
210216 UnifiedVectorFormat state_format;
210217 state_vector.ToUnifiedFormat(count, state_format);
210218
210219 const auto states = UnifiedVectorFormat::GetData<STATE *>(state_format);
210220 auto &
mask = FlatVector::Validity(result);
210221
210223
210224
210225 idx_t new_entries = 0;
210226 for (
idx_t i = 0; i < count; i++) {
210227 const auto state_idx = state_format.sel->get_index(i);
210228 auto &state = *states[state_idx];
210229 new_entries += state.heap.Size();
210230 }
210231
210232
210234
210235 const auto list_entries = FlatVector::GetData<list_entry_t>(result);
210237
210238 idx_t current_offset = old_len;
210239 for (
idx_t i = 0; i < count; i++) {
210240 const auto rid = i + offset;
210241 const auto state_idx = state_format.sel->get_index(i);
210242 auto &state = *states[state_idx];
210243
210244 if (!state.is_initialized || state.heap.IsEmpty()) {
210245 mask.SetInvalid(rid);
210246 continue;
210247 }
210248
210249
210250 auto &list_entry = list_entries[rid];
210251 list_entry.offset = current_offset;
210252 list_entry.length = state.heap.Size();
210253
210254
210255 auto heap = state.heap.SortAndGetHeap();
210256
210257 for (
idx_t slot = 0; slot < state.heap.Size(); slot++) {
210258 STATE::VAL_TYPE::Assign(child_data, current_offset++, state.heap.GetValue(heap[slot]), nulls_last);
210259 }
210260 }
210261
210262 D_ASSERT(current_offset == old_len + new_entries);
210264 result.Verify(count);
210265 }
GMat mask(const GMat &src, const GMat &mask)
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 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 void Reserve(Vector &vec, idx_t required_capacity)
Sets the total capacity of the underlying child-vector of a list.
Definition duckdb.cpp:138211
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