MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / ensure_sorted

Method ensure_sorted

nodedb/src/engine/timeseries/o3_buffer.rs:90–103  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

88 }
89
90 fn ensure_sorted(&mut self) {
91 if !self.sorted {
92 // Radix-style: group by partition first (few distinct values),
93 // then sort within groups by timestamp. This is faster than a
94 // full comparison sort when partition_start has low cardinality.
95 self.rows.sort_unstable_by(|a, b| {
96 a.target_partition_start
97 .cmp(&b.target_partition_start)
98 .then(a.timestamp_ms.cmp(&b.timestamp_ms))
99 .then(a.series_id.cmp(&b.series_id))
100 });
101 self.sorted = true;
102 }
103 }
104
105 pub fn len(&self) -> usize {
106 self.rows.len()

Callers 2

query_rangeMethod · 0.80
dedupMethod · 0.80

Calls 1

cmpMethod · 0.45

Tested by

no test coverage detected