[enhance] buffer storage (#83)

This commit is contained in:
ZeFeng Yin
2026-03-19 15:24:46 +08:00
committed by GitHub
parent d4ffbf06af
commit 432de52c5f
19 changed files with 5377 additions and 339 deletions
@@ -190,10 +190,18 @@ class FlatStreamerContext : public IndexStreamer::Context {
group_topk_heaps_.clear();
}
void reset() override {}
void reset() override {
for (auto &it : results_) {
it.clear();
}
for (auto &it : group_results_) {
it.clear();
}
}
//! Reset the context
void reset(const FlatStreamer<BATCH_SIZE> *owner) {
this->reset();
magic_ = owner->magic();
feature_size_ = owner->meta().element_size();
+4
View File
@@ -335,6 +335,7 @@ class HnswContext : public IndexContext {
//! Reset context
void reset(void) override {
this->clear();
set_filter(nullptr);
reset_threshold();
set_fetch_vector(false);
@@ -422,6 +423,9 @@ class HnswContext : public IndexContext {
for (auto &it : results_) {
it.clear();
}
for (auto &it : group_results_) {
it.clear();
}
}
uint32_t *mutable_stats_get_neighbors() {
+2 -2
View File
@@ -147,8 +147,8 @@ struct Neighbors {
Neighbors(uint32_t cnt_in, const node_id_t *data_in)
: cnt{cnt_in}, data{data_in} {}
Neighbors(IndexStorage::MemoryBlock &&mem_block)
: neighbor_block{std::move(mem_block)} {
Neighbors(const IndexStorage::MemoryBlock &mem_block)
: neighbor_block{mem_block} {
auto hd = reinterpret_cast<const NeighborsHeader *>(neighbor_block.data());
cnt = hd->neighbor_cnt;
data = hd->neighbors;
@@ -127,7 +127,7 @@ const Neighbors HnswStreamerEntity::get_neighbors(level_t level,
LOG_ERROR("Read neighbor header failed, ret=%zu", size);
return Neighbors();
}
return Neighbors(std::move(neighbor_block));
return Neighbors(neighbor_block);
}
//! Get vector data by key