Add delete in segcore segment sealed (#10470)

Signed-off-by: fishpenguin <kun.yu@zilliz.com>
This commit is contained in:
yukun 2021-10-22 23:35:18 +08:00 committed by GitHub
parent 5c58924420
commit bc083950a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 6 deletions

View File

@ -248,12 +248,10 @@ SegmentGrowingImpl::Delete(int64_t reserved_begin,
std::vector<idx_t> uids(size);
std::vector<Timestamp> timestamps(size);
// #pragma omp parallel for
std::cout << "zzzz: " << size << std::endl;
for (int index = 0; index < size; ++index) {
auto [t, uid] = ordering[index];
timestamps[index] = t;
uids[index] = uid;
std::cout << "In Segcore Delete: " << uid << std::endl;
}
deleted_record_.timestamps_.set_data(reserved_begin, timestamps.data(), size);
deleted_record_.uids_.set_data(reserved_begin, uids.data(), size);

View File

@ -36,6 +36,8 @@ class SegmentSealed : public SegmentInternalInterface {
HasIndex(FieldId field_id) const = 0;
virtual bool
HasFieldData(FieldId field_id) const = 0;
virtual void
Delete(int64_t row_count, const int64_t* uids_raw, const Timestamp* timestamps_raw) = 0;
};
using SegmentSealedPtr = std::unique_ptr<SegmentSealed>;

View File

@ -557,9 +557,10 @@ SegmentSealedImpl::Delete(int64_t row_count, const int64_t* uids_raw, const Time
src_timestamps[i] = t;
src_uids[i] = uid;
}
deleted_record_.timestamps_.set_data(0, src_timestamps.data(), row_count);
deleted_record_.uids_.set_data(0, src_uids.data(), row_count);
deleted_record_.ack_responder_.AddSegment(0, row_count);
auto current_size = deleted_record_.record_size_;
deleted_record_.timestamps_.set_data(current_size, src_timestamps.data(), row_count);
deleted_record_.uids_.set_data(current_size, src_uids.data(), row_count);
deleted_record_.ack_responder_.AddSegment(current_size, row_count);
return;
}

View File

@ -155,7 +155,7 @@ class SegmentSealedImpl : public SegmentSealed {
search_ids(const boost::dynamic_bitset<>& view, Timestamp timestamp) const override;
void
Delete(int64_t row_count, const int64_t* uids_raw, const Timestamp* timestamps_raw);
Delete(int64_t row_count, const int64_t* uids_raw, const Timestamp* timestamps_raw) override;
// virtual void
// build_index_if_primary_key(FieldId field_id);

View File

@ -380,4 +380,9 @@ TEST(Sealed, Delete) {
auto view = BitsetView(tmp_block.data(), 10);
auto bitset = segment->get_filtered_bitmap(view, 10, 11);
ASSERT_EQ(bitset.size(), N);
int64_t new_count = 3;
std::vector<idx_t> new_pks{6, 7, 8};
std::vector<idx_t> new_timestamps{10, 10, 10};
segment->Delete(new_count, reinterpret_cast<const int64_t*>(new_pks.data()), reinterpret_cast<const Timestamp*>(new_timestamps.data()));
}