Fix stuff because of rebase

Signed-off-by: Dipack P Panjabi <dipack.panjabi@gmail.com>
This commit is contained in:
Dipack P Panjabi 2020-03-31 19:30:35 -07:00
parent c1e293fb0f
commit 9ae7dd06b6
2 changed files with 26 additions and 29 deletions

View File

@ -46,7 +46,7 @@ func testBlocks(t *testing.T, blocks []tsdb.BlockReader, metricLabels []string,
maxt, mint := int64(math.MinInt64), int64(math.MaxInt64)
for _, block := range blocks {
maxt, mint = value.MaxInt64(maxt, block.Meta().MaxTime), value.MinInt64(mint, block.Meta().MinTime)
indexr, err := block.Index(math.MinInt64, math.MaxInt64)
indexr, err := block.Index()
testutil.Ok(t, err)
symbols := indexr.Symbols()
for symbols.Next() {
@ -88,9 +88,8 @@ func sortSamples(samples []tsdb.MetricSample) {
// If timestamps are equal, sort based on values.
if sx.Timestamp != sy.Timestamp {
return sx.Timestamp < sy.Timestamp
} else {
return sx.Value < sy.Value
}
return sx.Value < sy.Value
})
}
@ -100,7 +99,7 @@ func sortSamples(samples []tsdb.MetricSample) {
// even if the other labels b/w the metrics are different.
func readSeries(block tsdb.BlockReader, lbls labels2.Labels) ([]tsdb.MetricSample, error) {
series := make([]tsdb.MetricSample, 0)
ir, err := block.Index(math.MinInt64, math.MaxInt64)
ir, err := block.Index()
if err != nil {
return series, err
}

View File

@ -167,11 +167,11 @@ func writeSamples(
meta := metas[blockIndex]
meta.mint = value.MinInt64(meta.mint, sample.Timestamp)
meta.maxt = value.MaxInt64(meta.maxt, sample.Timestamp)
meta.count += 1
meta.count++
blocks[blockIndex] = append(blocks[blockIndex], &sample)
currentPassCount += 1
currentPassCount++
// Have enough samples to write to disk.
if currentPassCount == maxSamplesInMemory {
if err := flushBlocks(dir, blocks, metas, maxBlockChildren, logger); err != nil {
@ -281,28 +281,27 @@ func sampleStreamer(buf *bytes.Buffer) func([]byte, bool) (int, []byte, error) {
_, ctime, cvalue := parser.Series()
if ctime == nil {
return 0, nil, NoTimestampError
} else {
// OpenMetrics parser multiples times by 1000 - undoing that.
ctimeCorrected := *ctime / 1000
var clabels labels.Labels
_ = parser.Metric(&clabels)
sample := tsdb.MetricSample{
Timestamp: ctimeCorrected,
Value: cvalue,
Labels: labels.FromMap(clabels.Map()),
}
buf.Reset()
enc := gob.NewEncoder(buf)
if err = enc.Encode(sample); err != nil {
return 0, nil, err
}
advance += lineLength
return advance, buf.Bytes(), nil
}
// OpenMetrics parser multiples times by 1000 - undoing that.
ctimeCorrected := *ctime / 1000
var clabels labels.Labels
_ = parser.Metric(&clabels)
sample := tsdb.MetricSample{
Timestamp: ctimeCorrected,
Value: cvalue,
Labels: labels.FromMap(clabels.Map()),
}
buf.Reset()
enc := gob.NewEncoder(buf)
if err = enc.Encode(sample); err != nil {
return 0, nil, err
}
advance += lineLength
return advance, buf.Bytes(), nil
}
}
}
@ -597,8 +596,7 @@ func sortBlocks(blocks []*newBlockMeta) {
bx, by := blocks[x], blocks[y]
if bx.mint != by.mint {
return bx.mint < by.mint
} else {
return bx.maxt < by.maxt
}
return bx.maxt < by.maxt
})
}