|
|
@ -175,14 +175,28 @@ func (s *memorySeriesStorage) AppendSample(sample model.Sample) error { |
|
|
|
s.Lock() |
|
|
|
s.Lock() |
|
|
|
defer s.Unlock() |
|
|
|
defer s.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
metric := sample.Metric |
|
|
|
fingerprint := model.NewFingerprintFromMetric(sample.Metric) |
|
|
|
fingerprint := model.NewFingerprintFromMetric(metric) |
|
|
|
series := s.getOrCreateSeries(sample.Metric, fingerprint) |
|
|
|
series, ok := s.fingerprintToSeries[*fingerprint] |
|
|
|
series.add(sample.Timestamp, sample.Value) |
|
|
|
|
|
|
|
|
|
|
|
if s.wmCache != nil { |
|
|
|
if s.wmCache != nil { |
|
|
|
s.wmCache.Set(fingerprint, &Watermarks{High: sample.Timestamp}) |
|
|
|
s.wmCache.Set(fingerprint, &Watermarks{High: sample.Timestamp}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *memorySeriesStorage) CreateEmptySeries(metric model.Metric) { |
|
|
|
|
|
|
|
s.Lock() |
|
|
|
|
|
|
|
defer s.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fingerprint := model.NewFingerprintFromMetric(metric) |
|
|
|
|
|
|
|
s.getOrCreateSeries(metric, fingerprint) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *memorySeriesStorage) getOrCreateSeries(metric model.Metric, fingerprint *model.Fingerprint) *stream { |
|
|
|
|
|
|
|
series, ok := s.fingerprintToSeries[*fingerprint] |
|
|
|
|
|
|
|
|
|
|
|
if !ok { |
|
|
|
if !ok { |
|
|
|
series = newStream(metric) |
|
|
|
series = newStream(metric) |
|
|
|
s.fingerprintToSeries[*fingerprint] = series |
|
|
|
s.fingerprintToSeries[*fingerprint] = series |
|
|
@ -201,10 +215,7 @@ func (s *memorySeriesStorage) AppendSample(sample model.Sample) error { |
|
|
|
s.labelNameToFingerprints[k] = labelNameValues |
|
|
|
s.labelNameToFingerprints[k] = labelNameValues |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return series |
|
|
|
series.add(sample.Timestamp, sample.Value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Append raw samples, bypassing indexing. Only used to add data to views,
|
|
|
|
// Append raw samples, bypassing indexing. Only used to add data to views,
|
|
|
|