Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into chore/boolean-query-wand
Browse files Browse the repository at this point in the history
  • Loading branch information
MBkkt committed Aug 2, 2023
2 parents a95de2c + e051faa commit c7b55b7
Show file tree
Hide file tree
Showing 9 changed files with 372 additions and 124 deletions.
4 changes: 4 additions & 0 deletions core/formats/columnstore2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,9 @@ void column::flush_block() {
math::ceil64(docs_count, packed::BLOCK_SIZE_64);
auto* begin = addr_table_.begin();
auto* end = begin + addr_table_size;
if (auto* it = addr_table_.current(); it != end) {
std::memset(it, 0, (end - it) * sizeof(*it));
}

bool all_equal = !data_.file.length();
if (!all_equal) {
Expand Down Expand Up @@ -1431,6 +1434,7 @@ column::column(const context& ctx, field_id id, const type_info& compression,
blocks_{{resource_manager}},
data_{resource_manager},
docs_{resource_manager},
addr_table_{{resource_manager}},
id_{id} {
IRS_ASSERT(field_limits::valid(id_));
}
Expand Down
37 changes: 19 additions & 18 deletions core/formats/columnstore2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,45 +82,46 @@ class column final : public irs::column_output {

class address_table {
public:
address_table(ManagedTypedAllocator<uint64_t> alloc) : alloc_{alloc} {
offsets_ = alloc_.allocate(kBlockSize);
offset_ = offsets_;
}

~address_table() { alloc_.deallocate(offsets_, kBlockSize); }

uint64_t back() const noexcept {
IRS_ASSERT(offset_ > offsets_);
return *(offset_ - 1);
IRS_ASSERT(offsets_ < offset_);
return offset_[-1];
}

void push_back(uint64_t offset) noexcept {
IRS_ASSERT(offset_ >= offsets_);
IRS_ASSERT(offset_ < offsets_ + kBlockSize);
*offset_++ = offset;
IRS_ASSERT(offset >= offset_[-1]);
}

void pop_back() noexcept {
IRS_ASSERT(offset_ > offsets_);
*--offset_ = 0;
IRS_ASSERT(offsets_ < offset_);
--offset_;
}

// returns number of items to be flushed
uint32_t size() const noexcept {
IRS_ASSERT(offset_ >= offsets_);
return uint32_t(offset_ - offsets_);
return static_cast<uint32_t>(offset_ - offsets_);
}

bool empty() const noexcept { return offset_ == offsets_; }

bool full() const noexcept { return offset_ == std::end(offsets_); }
bool full() const noexcept { return offset_ == offsets_ + kBlockSize; }

void reset() noexcept {
std::memset(offsets_, 0, sizeof offsets_);
offset_ = std::begin(offsets_);
}
void reset() noexcept { offset_ = offsets_; }

uint64_t* begin() noexcept { return std::begin(offsets_); }
uint64_t* begin() noexcept { return offsets_; }
uint64_t* current() noexcept { return offset_; }
uint64_t* end() noexcept { return std::end(offsets_); }
uint64_t* end() noexcept { return offsets_ + kBlockSize; }

private:
uint64_t offsets_[kBlockSize]{};
uint64_t* offset_{offsets_};
ManagedTypedAllocator<uint64_t> alloc_;
uint64_t* offsets_{nullptr};
uint64_t* offset_{nullptr};
};

void Prepare(doc_id_t key) final;
Expand Down
Loading

0 comments on commit c7b55b7

Please sign in to comment.