Ensure that all extracted samples are added to view.

The current behavior only adds those samples to the view that are extracted by
the last pass of the last processed op and throws other ones away. This is a
bug. We need to append all samples that are extracted by each op pass.

This also makes view.appendSamples() take an array of samples.
This commit is contained in:
Julius Volz 2013-05-21 23:19:39 +02:00 committed by Julius Volz
parent 556be84c73
commit 008314b5a8
3 changed files with 13 additions and 13 deletions

View file

@ -181,21 +181,23 @@ func (s *memorySeriesStorage) AppendSample(sample model.Sample) error {
return nil
}
// Append raw sample, bypassing indexing. Only used to add data to views, which
// don't need to lookup by metric.
func (s *memorySeriesStorage) appendSampleWithoutIndexing(f *model.Fingerprint, timestamp time.Time, value model.SampleValue) {
// Append raw samples, bypassing indexing. Only used to add data to views,
// which don't need to lookup by metric.
func (s *memorySeriesStorage) appendSamplesWithoutIndexing(fingerprint *model.Fingerprint, samples model.Values) {
s.RLock()
series, ok := s.fingerprintToSeries[*f]
series, ok := s.fingerprintToSeries[*fingerprint]
s.RUnlock()
if !ok {
series = newStream(model.Metric{})
s.Lock()
s.fingerprintToSeries[*f] = series
s.fingerprintToSeries[*fingerprint] = series
s.Unlock()
}
series.add(timestamp, value)
for _, sample := range samples {
series.add(sample.Timestamp, sample.Value)
}
}
func (s *memorySeriesStorage) GetFingerprintsForLabelSet(l model.LabelSet) (fingerprints model.Fingerprints, err error) {

View file

@ -348,12 +348,10 @@ func (t *TieredStorage) renderView(viewJob viewJob) {
for op.CurrentTime() != nil && !op.CurrentTime().After(targetTime) {
out = op.ExtractSamples(model.Values(currentChunk))
}
}
// Append the extracted samples to the materialized view.
for _, sample := range out {
view.appendSample(scanJob.fingerprint, sample.Timestamp, sample.Value)
view.appendSamples(scanJob.fingerprint, out)
}
}
// Throw away standing ops which are finished.

View file

@ -105,8 +105,8 @@ type view struct {
*memorySeriesStorage
}
func (v view) appendSample(fingerprint *model.Fingerprint, timestamp time.Time, value model.SampleValue) {
v.memorySeriesStorage.appendSampleWithoutIndexing(fingerprint, timestamp, value)
func (v view) appendSamples(fingerprint *model.Fingerprint, samples model.Values) {
v.memorySeriesStorage.appendSamplesWithoutIndexing(fingerprint, samples)
}
func newView() view {