forked from grafana/loki
/
index.go
71 lines (56 loc) · 1.9 KB
/
index.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package index
import (
"context"
)
// QueryPagesCallback from an IndexQuery.
type QueryPagesCallback func(Query, ReadBatchResult) bool
// Client is a client for the storage of the index (e.g. DynamoDB or Bigtable).
type Client interface {
Stop()
// For the write path.
NewWriteBatch() WriteBatch
BatchWrite(context.Context, WriteBatch) error
// For the read path.
QueryPages(ctx context.Context, queries []Query, callback QueryPagesCallback) error
}
// ReadBatchResult represents the results of a QueryPages.
type ReadBatchResult interface {
Iterator() ReadBatchIterator
}
// ReadBatchIterator is an iterator over a ReadBatch.
type ReadBatchIterator interface {
Next() bool
RangeValue() []byte
Value() []byte
}
// WriteBatch represents a batch of writes.
type WriteBatch interface {
Add(tableName, hashValue string, rangeValue []byte, value []byte)
Delete(tableName, hashValue string, rangeValue []byte)
}
// Query describes a query for entries
type Query struct {
TableName string
HashValue string
// One of RangeValuePrefix or RangeValueStart might be set:
// - If RangeValuePrefix is not nil, must read all keys with that prefix.
// - If RangeValueStart is not nil, must read all keys from there onwards.
// - If neither is set, must read all keys for that row.
// RangeValueStart should only be used for querying Chunk IDs.
// If this is going to change then please take care of func isChunksQuery in pkg/chunk/storage/caching_index_client.go which relies on it.
RangeValuePrefix []byte
RangeValueStart []byte
// Filters for querying
ValueEqual []byte
// If the result of this lookup is immutable or not (for caching).
Immutable bool
}
// Entry describes an entry in the chunk index
type Entry struct {
TableName string
HashValue string
// For writes, RangeValue will always be set.
RangeValue []byte
// New for v6 schema, label value is not written as part of the range key.
Value []byte
}