Merge pull request #132 from prometheus/julius-leveldb-sorting

Make LevelDB sample keys fixed-length to ensure correct sort-order.
This commit is contained in:
Matt T. Proud 2013-04-11 09:25:02 -07:00
commit 2d70e75c52
3 changed files with 8 additions and 5 deletions

View File

@ -38,11 +38,14 @@ message LabelSet {
repeated LabelPair member = 1;
}
// The default LevelDB comparator sorts not only lexicographically, but also by
// key length (which takes precedence). Thus, no variable-length fields may be
// introduced into the key definition below.
message SampleKey {
optional Fingerprint fingerprint = 1;
optional bytes timestamp = 2;
optional int64 last_timestamp = 3;
optional uint32 sample_count = 4;
optional sfixed64 last_timestamp = 3;
optional fixed32 sample_count = 4;
}
message SampleValueSeries {
@ -89,4 +92,4 @@ message CurationValue {
// which the curator last completed its duty cycle for a given metric
// fingerprint.
optional int64 last_completion_timestamp = 1;
}
}

View File

@ -106,7 +106,7 @@ func NewFingerprintFromMetric(metric Metric) (f Fingerprint) {
return fingerprint{
firstCharacterOfFirstLabelName: firstCharacterOfFirstLabelName,
hash: binary.LittleEndian.Uint64(summer.Sum(nil)),
labelMatterLength: uint(labelMatterLength),
labelMatterLength: uint(labelMatterLength % 10),
lastCharacterOfLastLabelValue: lastCharacterOfLastLabelValue,
}
}

View File

@ -35,7 +35,7 @@ func testMetric(t test.Tester) {
"occupation": "robot",
"manufacturer": "westinghouse",
},
rowkey: "04776841610193542734-f-56-t",
rowkey: "04776841610193542734-f-6-t",
hash: 4776841610193542734,
},
{