Merge pull request #73 from prometheus/refactor/storage/simplifications

Simplifications of GetFingerprintsForLabelSet.
This commit is contained in:
Matt T. Proud 2013-02-13 17:29:38 -08:00
commit 1f351d86c3
5 changed files with 15 additions and 15 deletions

View file

@ -31,7 +31,7 @@ type PersistenceAdapter struct {
var persistenceAdapter *PersistenceAdapter = nil var persistenceAdapter *PersistenceAdapter = nil
func (p *PersistenceAdapter) getMetricsWithLabels(labels model.LabelSet) ([]*model.Metric, error) { func (p *PersistenceAdapter) getMetricsWithLabels(labels model.LabelSet) ([]*model.Metric, error) {
fingerprints, err := p.persistence.GetFingerprintsForLabelSet(&labels) fingerprints, err := p.persistence.GetFingerprintsForLabelSet(labels)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -34,7 +34,7 @@ type MetricPersistence interface {
// Get all of the metric fingerprints that are associated with the provided // Get all of the metric fingerprints that are associated with the provided
// label set. // label set.
GetFingerprintsForLabelSet(labelSet *model.LabelSet) ([]*model.Fingerprint, error) GetFingerprintsForLabelSet(labelSet model.LabelSet) ([]*model.Fingerprint, error)
// Get all of the metric fingerprints that are associated for a given label // Get all of the metric fingerprints that are associated for a given label
// name. // name.

View file

@ -710,9 +710,9 @@ func TestGetFingerprintsForLabelSet(t *testing.T) {
t.Error(appendErr) t.Error(appendErr)
} }
result, getErr := persistence.GetFingerprintsForLabelSet(&(model.LabelSet{ result, getErr := persistence.GetFingerprintsForLabelSet(model.LabelSet{
model.LabelName("name"): model.LabelValue("my_metric"), model.LabelName("name"): model.LabelValue("my_metric"),
})) })
if getErr != nil { if getErr != nil {
t.Error(getErr) t.Error(getErr)
@ -722,9 +722,9 @@ func TestGetFingerprintsForLabelSet(t *testing.T) {
t.Errorf("Expected two elements.") t.Errorf("Expected two elements.")
} }
result, getErr = persistence.GetFingerprintsForLabelSet(&(model.LabelSet{ result, getErr = persistence.GetFingerprintsForLabelSet(model.LabelSet{
model.LabelName("request_type"): model.LabelValue("your_mom"), model.LabelName("request_type"): model.LabelValue("your_mom"),
})) })
if getErr != nil { if getErr != nil {
t.Error(getErr) t.Error(getErr)
@ -734,9 +734,9 @@ func TestGetFingerprintsForLabelSet(t *testing.T) {
t.Errorf("Expected one element.") t.Errorf("Expected one element.")
} }
result, getErr = persistence.GetFingerprintsForLabelSet(&(model.LabelSet{ result, getErr = persistence.GetFingerprintsForLabelSet(model.LabelSet{
model.LabelName("request_type"): model.LabelValue("your_dad"), model.LabelName("request_type"): model.LabelValue("your_dad"),
})) })
if getErr != nil { if getErr != nil {
t.Error(getErr) t.Error(getErr)
@ -875,9 +875,9 @@ func TestGetMetricForFingerprint(t *testing.T) {
t.Error(appendErr) t.Error(appendErr)
} }
result, getErr := persistence.GetFingerprintsForLabelSet(&(model.LabelSet{ result, getErr := persistence.GetFingerprintsForLabelSet(model.LabelSet{
model.LabelName("request_type"): model.LabelValue("your_mom"), model.LabelName("request_type"): model.LabelValue("your_mom"),
})) })
if getErr != nil { if getErr != nil {
t.Error(getErr) t.Error(getErr)
@ -900,9 +900,9 @@ func TestGetMetricForFingerprint(t *testing.T) {
t.Errorf("Expected metric to match.") t.Errorf("Expected metric to match.")
} }
result, getErr = persistence.GetFingerprintsForLabelSet(&(model.LabelSet{ result, getErr = persistence.GetFingerprintsForLabelSet(model.LabelSet{
model.LabelName("request_type"): model.LabelValue("your_dad"), model.LabelName("request_type"): model.LabelValue("your_dad"),
})) })
if getErr != nil { if getErr != nil {
t.Error(getErr) t.Error(getErr)

View file

@ -180,7 +180,7 @@ func (l *LevelDBMetricPersistence) GetLabelNameFingerprints(n *dto.LabelName) (c
return return
} }
func (l *LevelDBMetricPersistence) GetFingerprintsForLabelSet(labelSet *model.LabelSet) (fps []*model.Fingerprint, err error) { func (l *LevelDBMetricPersistence) GetFingerprintsForLabelSet(labelSet model.LabelSet) (fps []*model.Fingerprint, err error) {
begin := time.Now() begin := time.Now()
defer func() { defer func() {
@ -191,7 +191,7 @@ func (l *LevelDBMetricPersistence) GetFingerprintsForLabelSet(labelSet *model.La
sets := []utility.Set{} sets := []utility.Set{}
for _, labelSetDTO := range model.LabelSetToDTOs(labelSet) { for _, labelSetDTO := range model.LabelSetToDTOs(&labelSet) {
f, err := l.labelSetToFingerprints.Get(coding.NewProtocolBufferEncoder(labelSetDTO)) f, err := l.labelSetToFingerprints.Get(coding.NewProtocolBufferEncoder(labelSetDTO))
if err != nil { if err != nil {
return fps, err return fps, err

View file

@ -65,7 +65,7 @@ func TestGetFingerprintsForLabelSetUsesAnd(t *testing.T) {
"percentile": "0.010000", "percentile": "0.010000",
} }
fingerprints, err := persistence.GetFingerprintsForLabelSet(&labelSet) fingerprints, err := persistence.GetFingerprintsForLabelSet(labelSet)
if err != nil { if err != nil {
t.Errorf("could not get labels: %s", err) t.Errorf("could not get labels: %s", err)
} }