Skip to content

Commit 55ddadb

Browse files
committed
removes noops struct embedding strategy in schema, provides noop impls on all schemas instead
Signed-off-by: Owen Diehl <[email protected]>
1 parent 00ff5ab commit 55ddadb

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

pkg/chunk/schema.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,11 @@ type entries interface {
238238
FilterReadQueries(queries []IndexQuery, shard *astmapper.ShardAnnotation) []IndexQuery
239239
}
240240

241-
// noops is a placeholder which can be embedded to provide default implementations
242-
type noops struct{}
243-
244-
func (n noops) FilterReadQueries(queries []IndexQuery, shard *astmapper.ShardAnnotation) []IndexQuery {
245-
return queries
246-
}
247-
248241
// original entries:
249242
// - hash key: <userid>:<bucket>:<metric name>
250243
// - range key: <label name>\0<label value>\0<chunk name>
251244

252-
type originalEntries struct {
253-
noops
254-
}
245+
type originalEntries struct{}
255246

256247
func (originalEntries) GetWriteEntries(bucket Bucket, metricName string, labels labels.Labels, chunkID string) ([]IndexEntry, error) {
257248
chunkIDBytes := []byte(chunkID)
@@ -320,6 +311,10 @@ func (originalEntries) GetLabelNamesForSeries(_ Bucket, _ []byte) ([]IndexQuery,
320311
return nil, ErrNotSupported
321312
}
322313

314+
func (originalEntries) FilterReadQueries(queries []IndexQuery, shard *astmapper.ShardAnnotation) []IndexQuery {
315+
return queries
316+
}
317+
323318
// v3Schema went to base64 encoded label values & a version ID
324319
// - range key: <label name>\0<base64(label value)>\0<chunk name>\0<version 1>
325320

@@ -368,9 +363,7 @@ func (base64Entries) GetReadMetricLabelValueQueries(bucket Bucket, metricName st
368363
// - range key: \0<base64(label value)>\0<chunk name>\0<version 2>
369364
// 2) - hash key: <userid>:<hour bucket>:<metric name>
370365
// - range key: \0\0<chunk name>\0<version 3>
371-
type labelNameInHashKeyEntries struct {
372-
noops
373-
}
366+
type labelNameInHashKeyEntries struct{}
374367

375368
func (labelNameInHashKeyEntries) GetWriteEntries(bucket Bucket, metricName string, labels labels.Labels, chunkID string) ([]IndexEntry, error) {
376369
chunkIDBytes := []byte(chunkID)
@@ -441,12 +434,14 @@ func (labelNameInHashKeyEntries) GetLabelNamesForSeries(_ Bucket, _ []byte) ([]I
441434
return nil, ErrNotSupported
442435
}
443436

437+
func (labelNameInHashKeyEntries) FilterReadQueries(queries []IndexQuery, shard *astmapper.ShardAnnotation) []IndexQuery {
438+
return queries
439+
}
440+
444441
// v5 schema is an extension of v4, with the chunk end time in the
445442
// range key to improve query latency. However, it did it wrong
446443
// so the chunk end times are ignored.
447-
type v5Entries struct {
448-
noops
449-
}
444+
type v5Entries struct{}
450445

451446
func (v5Entries) GetWriteEntries(bucket Bucket, metricName string, labels labels.Labels, chunkID string) ([]IndexEntry, error) {
452447
chunkIDBytes := []byte(chunkID)
@@ -517,11 +512,13 @@ func (v5Entries) GetLabelNamesForSeries(_ Bucket, _ []byte) ([]IndexQuery, error
517512
return nil, ErrNotSupported
518513
}
519514

515+
func (v5Entries) FilterReadQueries(queries []IndexQuery, shard *astmapper.ShardAnnotation) []IndexQuery {
516+
return queries
517+
}
518+
520519
// v6Entries fixes issues with v5 time encoding being wrong (see #337), and
521520
// moves label value out of range key (see #199).
522-
type v6Entries struct {
523-
noops
524-
}
521+
type v6Entries struct{}
525522

526523
func (v6Entries) GetWriteEntries(bucket Bucket, metricName string, labels labels.Labels, chunkID string) ([]IndexEntry, error) {
527524
chunkIDBytes := []byte(chunkID)
@@ -599,11 +596,13 @@ func (v6Entries) GetLabelNamesForSeries(_ Bucket, _ []byte) ([]IndexQuery, error
599596
return nil, ErrNotSupported
600597
}
601598

602-
// v9Entries adds a layer of indirection between labels -> series -> chunks.
603-
type v9Entries struct {
604-
noops
599+
func (v6Entries) FilterReadQueries(queries []IndexQuery, shard *astmapper.ShardAnnotation) []IndexQuery {
600+
return queries
605601
}
606602

603+
// v9Entries adds a layer of indirection between labels -> series -> chunks.
604+
type v9Entries struct{}
605+
607606
func (v9Entries) GetWriteEntries(bucket Bucket, metricName string, labels labels.Labels, chunkID string) ([]IndexEntry, error) {
608607
return nil, ErrNotSupported
609608
}
@@ -699,6 +698,10 @@ func (v9Entries) GetLabelNamesForSeries(_ Bucket, _ []byte) ([]IndexQuery, error
699698
return nil, ErrNotSupported
700699
}
701700

701+
func (v9Entries) FilterReadQueries(queries []IndexQuery, shard *astmapper.ShardAnnotation) []IndexQuery {
702+
return queries
703+
}
704+
702705
// v10Entries builds on v9 by sharding index rows to reduce their size.
703706
type v10Entries struct {
704707
rowShards uint32

0 commit comments

Comments
 (0)