fix: Maintain the edge count in the CSR#209
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan Review Summary by QodoMaintain edge count with atomic counter for O(1) access
WalkthroughsDescription• Replace expensive edge counting logic with atomic counter - Removed O(n) iteration through all edges in edge_num() method - Replaced with O(1) atomic load from edge_num_ member • Maintain edge count across all CSR operations - Add fetch_add/fetch_sub calls in batch operations and single edge modifications - Track edge count in batch_delete_vertices, batch_delete_edges, delete_edge, revert_delete_edge, batch_put_edges • Persist edge count to metadata file - Update load_meta and dump_meta to read/write edge count - Replace C-style FILE I/O with C++ ifstream/ofstream • Add validation checks for edge count consistency - Verify edge count matches degree list during open operations - Check consistency after compaction operations Diagramflowchart LR
A["Edge Operations<br/>delete/put/revert"] -->|fetch_add/fetch_sub| B["Atomic Counter<br/>edge_num_"]
B -->|O(1) load| C["edge_num() method"]
D["load_meta()"] -->|read from file| B
B -->|write to file| E["dump_meta()"]
F["Validation"] -->|verify consistency| B
File Changes1. src/storages/csr/immutable_csr.cc
|
Code Review by Qodo
1.
|
Fixes