in below/store/src/cursor.rs [615:637]
fn jump_near_key(&mut self, key: &u64, _direction: Direction) {
let time_offset = key % SHARD_TIME;
let shard = key - time_offset;
self.set_offset(StoreOffset::new(Some(shard), None));
// Move to the end of the shard.
if self.advance_index(Direction::Reverse) {
if let Some(last_entry) = self.get_index_entry() {
let last_entry_index_offset = self
.get_offset()
.get_index_offset()
.expect("get_index_offset should return Some if get_index_entry returns Some");
let last_entry_time_offset = last_entry.timestamp % SHARD_TIME;
if last_entry_time_offset != 0 {
// Assume samples are recorded in constant interval and
// scale index offset by time offset
let index_offset_hint = (last_entry_index_offset as f64
/ last_entry_time_offset as f64
* time_offset as f64) as usize;
self.set_offset(StoreOffset::new(Some(shard), Some(index_offset_hint)));
}
}
}
}