mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
Pointerize memorySeriesArena.
This commit is contained in:
parent
e54edb16a5
commit
e1f20de2e9
|
@ -110,20 +110,18 @@ type memorySeriesStorage struct {
|
||||||
labelNameToFingerprints map[model.LabelName]model.Fingerprints
|
labelNameToFingerprints map[model.LabelName]model.Fingerprints
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) AppendSamples(samples model.Samples) (err error) {
|
func (s *memorySeriesStorage) AppendSamples(samples model.Samples) error {
|
||||||
for _, sample := range samples {
|
for _, sample := range samples {
|
||||||
s.AppendSample(sample)
|
s.AppendSample(sample)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) AppendSample(sample model.Sample) (err error) {
|
func (s *memorySeriesStorage) AppendSample(sample model.Sample) error {
|
||||||
var (
|
metric := sample.Metric
|
||||||
metric = sample.Metric
|
fingerprint := model.NewFingerprintFromMetric(metric)
|
||||||
fingerprint = model.NewFingerprintFromMetric(metric)
|
series, ok := s.fingerprintToSeries[fingerprint]
|
||||||
series, ok = s.fingerprintToSeries[fingerprint]
|
|
||||||
)
|
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
series = newStream(metric)
|
series = newStream(metric)
|
||||||
|
@ -144,12 +142,12 @@ func (s memorySeriesStorage) AppendSample(sample model.Sample) (err error) {
|
||||||
|
|
||||||
series.add(sample.Timestamp, sample.Value)
|
series.add(sample.Timestamp, sample.Value)
|
||||||
|
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append raw sample, bypassing indexing. Only used to add data to views, which
|
// Append raw sample, bypassing indexing. Only used to add data to views, which
|
||||||
// don't need to lookup by metric.
|
// don't need to lookup by metric.
|
||||||
func (s memorySeriesStorage) appendSampleWithoutIndexing(f model.Fingerprint, timestamp time.Time, value model.SampleValue) {
|
func (s *memorySeriesStorage) appendSampleWithoutIndexing(f model.Fingerprint, timestamp time.Time, value model.SampleValue) {
|
||||||
series, ok := s.fingerprintToSeries[f]
|
series, ok := s.fingerprintToSeries[f]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -160,7 +158,7 @@ func (s memorySeriesStorage) appendSampleWithoutIndexing(f model.Fingerprint, ti
|
||||||
series.add(timestamp, value)
|
series.add(timestamp, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) GetFingerprintsForLabelSet(l model.LabelSet) (fingerprints model.Fingerprints, err error) {
|
func (s *memorySeriesStorage) GetFingerprintsForLabelSet(l model.LabelSet) (fingerprints model.Fingerprints, err error) {
|
||||||
|
|
||||||
sets := []utility.Set{}
|
sets := []utility.Set{}
|
||||||
|
|
||||||
|
@ -191,7 +189,7 @@ func (s memorySeriesStorage) GetFingerprintsForLabelSet(l model.LabelSet) (finge
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) GetFingerprintsForLabelName(l model.LabelName) (fingerprints model.Fingerprints, err error) {
|
func (s *memorySeriesStorage) GetFingerprintsForLabelName(l model.LabelName) (fingerprints model.Fingerprints, err error) {
|
||||||
values := s.labelNameToFingerprints[l]
|
values := s.labelNameToFingerprints[l]
|
||||||
|
|
||||||
fingerprints = append(fingerprints, values...)
|
fingerprints = append(fingerprints, values...)
|
||||||
|
@ -199,7 +197,7 @@ func (s memorySeriesStorage) GetFingerprintsForLabelName(l model.LabelName) (fin
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) GetMetricForFingerprint(f model.Fingerprint) (metric model.Metric, err error) {
|
func (s *memorySeriesStorage) GetMetricForFingerprint(f model.Fingerprint) (metric model.Metric, err error) {
|
||||||
series, ok := s.fingerprintToSeries[f]
|
series, ok := s.fingerprintToSeries[f]
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
@ -213,7 +211,7 @@ func (s memorySeriesStorage) GetMetricForFingerprint(f model.Fingerprint) (metri
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) GetValueAtTime(f model.Fingerprint, t time.Time) (samples model.Values) {
|
func (s *memorySeriesStorage) GetValueAtTime(f model.Fingerprint, t time.Time) (samples model.Values) {
|
||||||
series, ok := s.fingerprintToSeries[f]
|
series, ok := s.fingerprintToSeries[f]
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
@ -254,13 +252,13 @@ func (s memorySeriesStorage) GetValueAtTime(f model.Fingerprint, t time.Time) (s
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) GetBoundaryValues(f model.Fingerprint, i model.Interval) (first model.Values, second model.Values) {
|
func (s *memorySeriesStorage) GetBoundaryValues(f model.Fingerprint, i model.Interval) (first model.Values, second model.Values) {
|
||||||
first = s.GetValueAtTime(f, i.OldestInclusive)
|
first = s.GetValueAtTime(f, i.OldestInclusive)
|
||||||
second = s.GetValueAtTime(f, i.NewestInclusive)
|
second = s.GetValueAtTime(f, i.NewestInclusive)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) GetRangeValues(f model.Fingerprint, i model.Interval) (samples model.Values) {
|
func (s *memorySeriesStorage) GetRangeValues(f model.Fingerprint, i model.Interval) (samples model.Values) {
|
||||||
series, ok := s.fingerprintToSeries[f]
|
series, ok := s.fingerprintToSeries[f]
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
@ -302,13 +300,13 @@ func (s memorySeriesStorage) GetRangeValues(f model.Fingerprint, i model.Interva
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) Close() {
|
func (s *memorySeriesStorage) Close() {
|
||||||
s.fingerprintToSeries = map[model.Fingerprint]stream{}
|
s.fingerprintToSeries = map[model.Fingerprint]stream{}
|
||||||
s.labelPairToFingerprints = map[string]model.Fingerprints{}
|
s.labelPairToFingerprints = map[string]model.Fingerprints{}
|
||||||
s.labelNameToFingerprints = map[model.LabelName]model.Fingerprints{}
|
s.labelNameToFingerprints = map[model.LabelName]model.Fingerprints{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) GetAllValuesForLabel(labelName model.LabelName) (values model.LabelValues, err error) {
|
func (s *memorySeriesStorage) GetAllValuesForLabel(labelName model.LabelName) (values model.LabelValues, err error) {
|
||||||
valueSet := map[model.LabelValue]bool{}
|
valueSet := map[model.LabelValue]bool{}
|
||||||
for _, series := range s.fingerprintToSeries {
|
for _, series := range s.fingerprintToSeries {
|
||||||
if value, ok := series.metric[labelName]; ok {
|
if value, ok := series.metric[labelName]; ok {
|
||||||
|
@ -321,7 +319,7 @@ func (s memorySeriesStorage) GetAllValuesForLabel(labelName model.LabelName) (va
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s memorySeriesStorage) ForEachSample(builder IteratorsForFingerprintBuilder) (err error) {
|
func (s *memorySeriesStorage) ForEachSample(builder IteratorsForFingerprintBuilder) (err error) {
|
||||||
for _, stream := range s.fingerprintToSeries {
|
for _, stream := range s.fingerprintToSeries {
|
||||||
decoder, filter, operator := builder.ForStream(stream)
|
decoder, filter, operator := builder.ForStream(stream)
|
||||||
|
|
||||||
|
@ -331,8 +329,8 @@ func (s memorySeriesStorage) ForEachSample(builder IteratorsForFingerprintBuilde
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMemorySeriesStorage() memorySeriesStorage {
|
func NewMemorySeriesStorage() *memorySeriesStorage {
|
||||||
return memorySeriesStorage{
|
return &memorySeriesStorage{
|
||||||
fingerprintToSeries: make(map[model.Fingerprint]stream),
|
fingerprintToSeries: make(map[model.Fingerprint]stream),
|
||||||
labelPairToFingerprints: make(map[string]model.Fingerprints),
|
labelPairToFingerprints: make(map[string]model.Fingerprints),
|
||||||
labelNameToFingerprints: make(map[model.LabelName]model.Fingerprints),
|
labelNameToFingerprints: make(map[model.LabelName]model.Fingerprints),
|
||||||
|
|
|
@ -61,7 +61,7 @@ type TieredStorage struct {
|
||||||
|
|
||||||
diskFrontier *diskFrontier
|
diskFrontier *diskFrontier
|
||||||
|
|
||||||
memoryArena memorySeriesStorage
|
memoryArena *memorySeriesStorage
|
||||||
memoryTTL time.Duration
|
memoryTTL time.Duration
|
||||||
flushMemoryInterval time.Duration
|
flushMemoryInterval time.Duration
|
||||||
|
|
||||||
|
|
|
@ -101,11 +101,11 @@ func (v viewRequestBuilder) ScanJobs() (j scanJobs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type view struct {
|
type view struct {
|
||||||
memorySeriesStorage
|
*memorySeriesStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v view) appendSample(fingerprint model.Fingerprint, timestamp time.Time, value model.SampleValue) {
|
func (v view) appendSample(fingerprint model.Fingerprint, timestamp time.Time, value model.SampleValue) {
|
||||||
v.appendSampleWithoutIndexing(fingerprint, timestamp, value)
|
v.memorySeriesStorage.appendSampleWithoutIndexing(fingerprint, timestamp, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newView() view {
|
func newView() view {
|
||||||
|
|
Loading…
Reference in a new issue