Description
Extract the total_count_ member variable from individual index implementations (HGraph, BruteForce) to the common InnerIndexInterface base class for unified management.
Background
Currently, total_count_ is defined separately in each index class:
HGraph: std::atomic<uint64_t> total_count_{0}
BruteForce: uint64_t total_count_{0}
This leads to code duplication and inconsistent management. By extracting to the base class, we can:
- Reduce code duplication
- Provide consistent interface for accessing total count
- Improve maintainability
Requirements
Technical Details
- Use
std::atomic<uint64_t> to ensure thread safety
- BruteForce operations converted to atomic operations:
total_count_++ → ++total_count_
total_count_-- → --total_count_
- Direct assignment →
total_count_.store()
- Read access →
total_count_.load()
Acceptance Criteria
Related
- Original task file: /home/tianlan.lht/code/workspace/total_count.md
- Branch: lht/total_count
- Commit: 5cd6acb
Notes
- IVF uses
total_elements_ with different semantics
- Pyramid uses
cur_element_count_ with different semantics
- Only HGraph and BruteForce have consistent usage patterns for extraction
Description
Extract the
total_count_member variable from individual index implementations (HGraph, BruteForce) to the commonInnerIndexInterfacebase class for unified management.Background
Currently,
total_count_is defined separately in each index class:HGraph:std::atomic<uint64_t> total_count_{0}BruteForce:uint64_t total_count_{0}This leads to code duplication and inconsistent management. By extracting to the base class, we can:
Requirements
GetTotalCount()method toInnerIndexInterfacestd::atomic<uint64_t> total_count_member toInnerIndexInterfacetotal_count_fromHGraphandBruteForceTechnical Details
std::atomic<uint64_t>to ensure thread safetytotal_count_++→++total_count_total_count_--→--total_count_total_count_.store()total_count_.load()Acceptance Criteria
Related
Notes
total_elements_with different semanticscur_element_count_with different semantics