@@ -34,9 +34,9 @@ type Schema interface {
34
34
GetWriteEntries (from , through model.Time , userID string , metricName string , labels labels.Labels , chunkID string ) ([]IndexEntry , error )
35
35
36
36
// Should only be used with the seriesStore. TODO: Make seriesStore implement a different interface altogether.
37
- GetLabelWriteEntries (from , through model.Time , userID string , metricName string , labels labels.Labels , chunkID string ) ([]IndexEntry , error )
37
+ // returns cache key string and []IndexEntry per bucket, matched in order
38
+ GetCacheKeysAndLabelWriteEntries (from , through model.Time , userID string , metricName string , labels labels.Labels , chunkID string ) ([]string , [][]IndexEntry , error )
38
39
GetChunkWriteEntries (from , through model.Time , userID string , metricName string , labels labels.Labels , chunkID string ) ([]IndexEntry , error )
39
- GetLabelEntryCacheKeys (from , through model.Time , userID string , labels labels.Labels ) []string
40
40
41
41
// When doing a read, use these methods to return the list of entries you should query
42
42
GetReadQueriesForMetric (from , through model.Time , userID string , metricName string ) ([]IndexQuery , error )
@@ -97,17 +97,31 @@ func (s schema) GetWriteEntries(from, through model.Time, userID string, metricN
97
97
return result , nil
98
98
}
99
99
100
- func (s schema ) GetLabelWriteEntries (from , through model.Time , userID string , metricName string , labels labels.Labels , chunkID string ) ([]IndexEntry , error ) {
101
- var result []IndexEntry
100
+ // returns cache key string and []IndexEntry per bucket, matched in order
101
+ func (s schema ) GetCacheKeysAndLabelWriteEntries (from , through model.Time , userID string , metricName string , labels labels.Labels , chunkID string ) ([]string , [][]IndexEntry , error ) {
102
+ var keys []string
103
+ var indexEntries [][]IndexEntry
102
104
103
105
for _ , bucket := range s .buckets (from , through , userID ) {
106
+ key := strings .Join ([]string {
107
+ bucket .tableName ,
108
+ bucket .hashKey ,
109
+ string (labelsSeriesID (labels )),
110
+ },
111
+ "-" ,
112
+ )
113
+ // This is just encoding to remove invalid characters so that we can put them in memcache.
114
+ // We're not hashing them as the length of the key is well within memcache bounds. tableName + userid + day + 32Byte(seriesID)
115
+ key = hex .EncodeToString ([]byte (key ))
116
+ keys = append (keys , key )
117
+
104
118
entries , err := s .entries .GetLabelWriteEntries (bucket , metricName , labels , chunkID )
105
119
if err != nil {
106
- return nil , err
120
+ return nil , nil , err
107
121
}
108
- result = append (result , entries ... )
122
+ indexEntries = append (indexEntries , entries )
109
123
}
110
- return result , nil
124
+ return keys , indexEntries , nil
111
125
}
112
126
113
127
func (s schema ) GetChunkWriteEntries (from , through model.Time , userID string , metricName string , labels labels.Labels , chunkID string ) ([]IndexEntry , error ) {
@@ -124,27 +138,6 @@ func (s schema) GetChunkWriteEntries(from, through model.Time, userID string, me
124
138
125
139
}
126
140
127
- // Should only used for v9Schema
128
- func (s schema ) GetLabelEntryCacheKeys (from , through model.Time , userID string , labels labels.Labels ) []string {
129
- var result []string
130
- for _ , bucket := range s .buckets (from , through , userID ) {
131
- key := strings .Join ([]string {
132
- bucket .tableName ,
133
- bucket .hashKey ,
134
- string (labelsSeriesID (labels )),
135
- },
136
- "-" ,
137
- )
138
- // This is just encoding to remove invalid characters so that we can put them in memcache.
139
- // We're not hashing them as the length of the key is well within memcache bounds. tableName + userid + day + 32Byte(seriesID)
140
- key = hex .EncodeToString ([]byte (key ))
141
-
142
- result = append (result , key )
143
- }
144
-
145
- return result
146
- }
147
-
148
141
func (s schema ) GetReadQueriesForMetric (from , through model.Time , userID string , metricName string ) ([]IndexQuery , error ) {
149
142
var result []IndexQuery
150
143
0 commit comments