-
Notifications
You must be signed in to change notification settings - Fork 3
/
storage.go
40 lines (33 loc) · 995 Bytes
/
storage.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
package logqlengine
import (
"context"
"github.com/go-faster/oteldb/internal/logql"
)
// SupportedOps is a bitset defining ops supported by Querier.
type SupportedOps uint64
// Add sets capability.
func (caps *SupportedOps) Add(ops ...logql.BinOp) {
for _, op := range ops {
*caps |= SupportedOps(1 << op)
}
}
// Supports checks if storage supports given ops.
func (caps SupportedOps) Supports(op logql.BinOp) bool {
mask := SupportedOps(1 << op)
return caps&mask != 0
}
// QuerierCapabilities defines what operations storage can do.
type QuerierCapabilities struct {
Label SupportedOps
Line SupportedOps
}
// Querier does queries to storage.
type Querier interface {
// Capabilities returns Querier capabilities.
//
// NOTE: engine would call once and then save value.
// Capabilities should not change over time.
Capabilities() QuerierCapabilities
// Query creates new [PipelineNode].
Query(ctx context.Context, selector []logql.LabelMatcher) (PipelineNode, error)
}