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