Add aggregator backfill, pulling fine+coarse buckets from collectors
This commit is contained in:
@@ -90,6 +90,26 @@ func (c *Cache) mergeFineBuckets(now time.Time) st.Snapshot {
|
||||
return st.Snapshot{Timestamp: now, Entries: st.TopKFromMap(merged, st.CoarseTopK)}
|
||||
}
|
||||
|
||||
// LoadHistorical pre-populates the ring buffers from backfill data before live
|
||||
// streaming begins. fine and coarse must be sorted oldest-first; each slice
|
||||
// must not exceed the respective ring size. Called once at startup, before Run.
|
||||
func (c *Cache) LoadHistorical(fine, coarse []st.Snapshot) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
for i, snap := range fine {
|
||||
c.fineRing[i] = snap
|
||||
}
|
||||
c.fineFilled = len(fine)
|
||||
c.fineHead = len(fine) % st.FineRingSize
|
||||
|
||||
for i, snap := range coarse {
|
||||
c.coarseRing[i] = snap
|
||||
}
|
||||
c.coarseFilled = len(coarse)
|
||||
c.coarseHead = len(coarse) % st.CoarseRingSize
|
||||
}
|
||||
|
||||
// QueryTopN answers a TopN request from the ring buffers.
|
||||
func (c *Cache) QueryTopN(filter *pb.Filter, groupBy pb.GroupBy, n int, window pb.Window) []st.Entry {
|
||||
cf := st.CompileFilter(filter)
|
||||
|
||||
Reference in New Issue
Block a user