databendlabs / openraft

rust raft with improvements
Apache License 2.0
1.41k stars 158 forks source link

Feature: Retrieve Key Log IDs via `RaftLogReader::get_key_log_ids()` #1264

Closed drmingdrmer closed 3 weeks ago

drmingdrmer commented 3 weeks ago

Changelog

Feature: Retrieve Key Log IDs via RaftLogReader::get_key_log_ids()

Key log IDs represent the first log IDs proposed by each Leader. These IDs enable Openraft to efficiently access log IDs at each index with a succinct storage.

Previously, key log IDs were obtained using a binary-search-like algorithm through RaftLogReader. This commit introduces the RaftLogReader::get_key_log_ids() method, allowing implementations to directly return a list of key log IDs if the RaftLogStorage can provide them.

For backward compatibility, a default implementation using the original binary-search method is provided. No application changes are required when upgrading to this version.

Tests verifying the implementation are included in openraft::testing::log::suite::Suite.


This change is Reviewable