| 322 | } |
| 323 | |
| 324 | void Segment::FreeEntry(::fedb::base::Node<Slice, void*>* entry_node, |
| 325 | uint64_t& gc_idx_cnt, uint64_t& gc_record_cnt, |
| 326 | uint64_t& gc_record_byte_size) { |
| 327 | if (entry_node == NULL) { |
| 328 | return; |
| 329 | } |
| 330 | // free pk memory |
| 331 | delete[] entry_node->GetKey().data(); |
| 332 | if (ts_cnt_ > 1) { |
| 333 | KeyEntry** entry_arr = (KeyEntry**)entry_node->GetValue(); // NOLINT |
| 334 | for (uint32_t i = 0; i < ts_cnt_; i++) { |
| 335 | uint64_t old = gc_idx_cnt; |
| 336 | KeyEntry* entry = entry_arr[i]; |
| 337 | TimeEntries::Iterator* it = entry->entries.NewIterator(); |
| 338 | it->SeekToFirst(); |
| 339 | if (it->Valid()) { |
| 340 | uint64_t ts = it->GetKey(); |
| 341 | ::fedb::base::Node<uint64_t, DataBlock*>* data_node = |
| 342 | entry->entries.Split(ts); |
| 343 | FreeList(data_node, gc_idx_cnt, gc_record_cnt, |
| 344 | gc_record_byte_size); |
| 345 | } |
| 346 | delete it; |
| 347 | delete entry; |
| 348 | idx_cnt_vec_[i]->fetch_sub(gc_idx_cnt - old, |
| 349 | std::memory_order_relaxed); |
| 350 | } |
| 351 | delete[] entry_arr; |
| 352 | uint64_t byte_size = GetRecordPkMultiIdxSize( |
| 353 | entry_node->Height(), entry_node->GetKey().size(), |
| 354 | key_entry_max_height_, ts_cnt_); |
| 355 | idx_byte_size_.fetch_sub(byte_size, std::memory_order_relaxed); |
| 356 | } else { |
| 357 | uint64_t old = gc_idx_cnt; |
| 358 | KeyEntry* entry = (KeyEntry*)entry_node->GetValue(); // NOLINT |
| 359 | TimeEntries::Iterator* it = entry->entries.NewIterator(); |
| 360 | it->SeekToFirst(); |
| 361 | if (it->Valid()) { |
| 362 | uint64_t ts = it->GetKey(); |
| 363 | ::fedb::base::Node<uint64_t, DataBlock*>* data_node = |
| 364 | entry->entries.Split(ts); |
| 365 | FreeList(data_node, gc_idx_cnt, gc_record_cnt, gc_record_byte_size); |
| 366 | } |
| 367 | delete it; |
| 368 | delete entry; |
| 369 | uint64_t byte_size = GetRecordPkIdxSize(entry_node->Height(), |
| 370 | entry_node->GetKey().size(), |
| 371 | key_entry_max_height_); |
| 372 | idx_byte_size_.fetch_sub(byte_size, std::memory_order_relaxed); |
| 373 | idx_cnt_.fetch_sub(gc_idx_cnt - old, std::memory_order_relaxed); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | void Segment::GcEntryFreeList(uint64_t version, uint64_t& gc_idx_cnt, |
| 378 | uint64_t& gc_record_cnt, |
nothing calls this directly
no test coverage detected