15 KUZU_API static const std::array<sel_t, DEFAULT_VECTOR_CAPACITY> INCREMENTAL_SELECTED_POS;
32 : selectedSize{0}, capacity{capacity}, selectedPositions{nullptr}, state{State::STATIC} {
33 selectedPositionsBuffer = std::make_unique<sel_t[]>(capacity);
39 bool isUnfiltered()
const {
return state == State::STATIC && selectedPositions[0] == 0; }
42 selectedPositions =
const_cast<sel_t*
>(INCREMENTAL_SELECTED_POS.data());
43 state = State::STATIC;
47 selectedPositions =
const_cast<sel_t*
>(INCREMENTAL_SELECTED_POS.data());
49 state = State::STATIC;
53 selectedPositions =
const_cast<sel_t*
>(INCREMENTAL_SELECTED_POS.data()) + startPos;
55 state = State::STATIC_FILTERED;
60 selectedPositions = selectedPositionsBuffer.get();
61 state = State::DYNAMIC;
64 KU_ASSERT(size <= capacity && selectedPositionsBuffer);
71 memcpy(selectedPositionsBuffer.get(), selectedPositions, selectedSize *
sizeof(
sel_t));
72 state = State::DYNAMIC;
73 selectedPositions = selectedPositionsBuffer.get();
77 return std::span<sel_t>(selectedPositionsBuffer.get(), capacity);
80 return std::span<const sel_t>(selectedPositions, selectedSize);
85 if (state == State::DYNAMIC) {
86 for (
size_t i = 0; i < selectedSize; i++) {
87 func(selectedPositions[i]);
90 const auto start = selectedPositions[0];
91 for (
size_t i = start; i < start + selectedSize; i++) {
104 selectedSize += increment;
109 return selectedPositions[index];
113 return selectedPositions[index];
119 std::unique_ptr<sel_t[]> selectedPositionsBuffer;
120 sel_t* selectedPositions;
#define KUZU_API
Definition api.h:25
#define KU_ASSERT(condition)
Definition assert.h:19
Definition sel_vector.h:14
void setToUnfiltered()
Definition sel_vector.h:41
void forEach(Func &&func) const
Definition sel_vector.h:84
void setToFiltered()
Definition sel_vector.h:59
void makeDynamic()
Definition sel_vector.h:70
SelectionVector()
Definition sel_vector.h:37
sel_t & operator[](sel_t index)
Definition sel_vector.h:111
void setRange(sel_t startPos, sel_t size)
Definition sel_vector.h:51
void setToUnfiltered(sel_t size)
Definition sel_vector.h:45
bool isUnfiltered() const
Definition sel_vector.h:39
std::span< const sel_t > getSelectedPositions() const
Definition sel_vector.h:79
void setToFiltered(sel_t size)
Definition sel_vector.h:63
sel_t getSelSize() const
Definition sel_vector.h:97
void incrementSelSize(sel_t increment=1)
Definition sel_vector.h:102
std::span< sel_t > getMutableBuffer() const
Definition sel_vector.h:76
SelectionVector(sel_t capacity)
Definition sel_vector.h:31
sel_t operator[](sel_t index) const
Definition sel_vector.h:107
void setSelSize(sel_t size)
Definition sel_vector.h:98
constexpr uint64_t DEFAULT_VECTOR_CAPACITY
Definition constants.h:24
uint64_t sel_t
Definition types.h:30
Definition array_utils.h:7