Kill AppendSample interface definition.

AppendSample will be repcated with AppendSamples, which will take
advantage of bulks appends.  This is a necessary step for indexing
pipeline decoupling.

Change-Id: Ia83811a87bcc89973d3b64d64b85a28710253ebc
This commit is contained in:
Matt T. Proud 2013-08-15 11:35:50 +02:00
parent 9c8112a053
commit b23acccea8
7 changed files with 24 additions and 24 deletions

View file

@ -23,7 +23,7 @@ import (
)
func GetFingerprintsForLabelSetTests(p MetricPersistence, t test.Tester) {
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: 0,
Timestamp: time.Time{},
Metric: clientmodel.Metric{
@ -32,7 +32,7 @@ func GetFingerprintsForLabelSetTests(p MetricPersistence, t test.Tester) {
},
}, t)
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: 0,
Timestamp: time.Time{},
Metric: clientmodel.Metric{
@ -79,7 +79,7 @@ func GetFingerprintsForLabelSetTests(p MetricPersistence, t test.Tester) {
}
func GetFingerprintsForLabelNameTests(p MetricPersistence, t test.Tester) {
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: 0,
Timestamp: time.Time{},
Metric: clientmodel.Metric{
@ -89,7 +89,7 @@ func GetFingerprintsForLabelNameTests(p MetricPersistence, t test.Tester) {
},
}, t)
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: 0,
Timestamp: time.Time{},
Metric: clientmodel.Metric{
@ -145,7 +145,7 @@ func GetFingerprintsForLabelNameTests(p MetricPersistence, t test.Tester) {
}
func GetMetricForFingerprintTests(p MetricPersistence, t test.Tester) {
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: 0,
Timestamp: time.Time{},
Metric: clientmodel.Metric{
@ -153,7 +153,7 @@ func GetMetricForFingerprintTests(p MetricPersistence, t test.Tester) {
},
}, t)
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: 0,
Timestamp: time.Time{},
Metric: clientmodel.Metric{
@ -264,7 +264,7 @@ func AppendRepeatingValuesTests(p MetricPersistence, t test.Tester) {
for i := 0; i < increments; i++ {
for j := 0; j < repetitions; j++ {
time := time.Time{}.Add(time.Duration(i) * time.Hour).Add(time.Duration(j) * time.Second)
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: clientmodel.SampleValue(i),
Timestamp: time,
Metric: metric,

View file

@ -28,8 +28,8 @@ var (
testInstant = time.Date(1972, 7, 18, 19, 5, 45, 0, usEastern).In(time.UTC)
)
func testAppendSample(p MetricPersistence, s *clientmodel.Sample, t test.Tester) {
err := p.AppendSample(s)
func testAppendSamples(p MetricPersistence, s *clientmodel.Sample, t test.Tester) {
err := p.AppendSamples(clientmodel.Samples{s})
if err != nil {
t.Fatal(err)
}

View file

@ -21,6 +21,9 @@ import (
"github.com/prometheus/prometheus/storage"
)
// AppendBatch models a batch of samples to be stored.
type AppendBatch map[clientmodel.Fingerprint]SampleSet
// MetricPersistence is a system for storing metric samples in a persistence
// layer.
type MetricPersistence interface {
@ -32,9 +35,6 @@ type MetricPersistence interface {
// queue work on channels and operate on it in bulk.
// Flush() error
// Record a new sample in the storage layer.
AppendSample(*clientmodel.Sample) error
// Record a group of new samples in the storage layer.
AppendSamples(clientmodel.Samples) error

View file

@ -47,7 +47,7 @@ func BenchmarkStreamAdd(b *testing.B) {
b.Logf("%d cycles with %f bytes per cycle, totalling %d", b.N, float32(post.TotalAlloc-pre.TotalAlloc)/float32(b.N), post.TotalAlloc-pre.TotalAlloc)
}
func benchmarkAppendSample(b *testing.B, labels int) {
func benchmarkAppendSamples(b *testing.B, labels int) {
b.StopTimer()
s := NewMemorySeriesStorage(MemorySeriesOptions{})
@ -80,17 +80,17 @@ func benchmarkAppendSample(b *testing.B, labels int) {
}
func BenchmarkAppendSample1(b *testing.B) {
benchmarkAppendSample(b, 1)
benchmarkAppendSamples(b, 1)
}
func BenchmarkAppendSample10(b *testing.B) {
benchmarkAppendSample(b, 10)
benchmarkAppendSamples(b, 10)
}
func BenchmarkAppendSample100(b *testing.B) {
benchmarkAppendSample(b, 100)
benchmarkAppendSamples(b, 100)
}
func BenchmarkAppendSample1000(b *testing.B) {
benchmarkAppendSample(b, 1000)
benchmarkAppendSamples(b, 1000)
}

View file

@ -38,7 +38,7 @@ func GetFingerprintsForLabelSetUsesAndForLabelMatchingTests(p MetricPersistence,
m[clientmodel.LabelName(k)] = clientmodel.LabelValue(v)
}
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: clientmodel.SampleValue(0.0),
Timestamp: time.Now(),
Metric: m,

View file

@ -327,7 +327,7 @@ func GetValueAtTimeTests(persistenceMaker func() (MetricPersistence, test.Closer
}
for _, value := range context.values {
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: clientmodel.SampleValue(value.value),
Timestamp: time.Date(value.year, value.month, value.day, value.hour, 0, 0, 0, time.UTC),
Metric: m,
@ -819,7 +819,7 @@ func GetRangeValuesTests(persistenceMaker func() (MetricPersistence, test.Closer
}
for _, value := range context.values {
testAppendSample(p, &clientmodel.Sample{
testAppendSamples(p, &clientmodel.Sample{
Value: clientmodel.SampleValue(value.value),
Timestamp: time.Date(value.year, value.month, value.day, value.hour, 0, 0, 0, time.UTC),
Metric: m,

View file

@ -107,7 +107,7 @@ func AppendSampleAsPureSparseAppendTests(p MetricPersistence, t test.Tester) {
Metric: l,
}
err := p.AppendSample(sample)
err := p.AppendSamples(clientmodel.Samples{sample})
success = err == nil
if !success {
@ -136,7 +136,7 @@ func AppendSampleAsSparseAppendWithReadsTests(p MetricPersistence, t test.Tester
Metric: l,
}
err := p.AppendSample(sample)
err := p.AppendSamples(clientmodel.Samples{sample})
if err != nil {
t.Error(err)
return
@ -180,7 +180,7 @@ func AppendSampleAsPureSingleEntityAppendTests(p MetricPersistence, t test.Teste
Metric: clientmodel.Metric{clientmodel.MetricNameLabel: "my_metric"},
}
err := p.AppendSample(sample)
err := p.AppendSamples(clientmodel.Samples{sample})
return err == nil
}
@ -321,7 +321,7 @@ func StochasticTests(persistenceMaker func() (MetricPersistence, test.Closer), t
sample.Timestamp = sortedTimestamps[sampleIndex]
sample.Value = clientmodel.SampleValue(sampleIndex)
err := p.AppendSample(sample)
err := p.AppendSamples(clientmodel.Samples{sample})
if err != nil {
t.Error(err)