Query oracle and API freeze

Label matchers (equal, not-equal, regexp, not-regexp) in labels/,
postings intersection/union/difference in internal/postings/,
LabelValues and AllPostings on index, block, and head readers.

ingot.go wired to real DB backed by head + block readers. Querier
snapshots overlapping blocks, Select resolves matchers to postings,
merged iterator chains blocks then head with block-wins dedup.

Oracle tests compare every query against a naive []sample reference
across head-only, block-only, head+block merge seam, multiple blocks,
all four matcher types, and time range filtering.
This commit is contained in:
2026-07-04 15:19:09 -04:00
parent 42b03db2fa
commit 323a6f2951
11 changed files with 1585 additions and 0 deletions
+27
View File
@@ -3,6 +3,7 @@ package index
import (
"encoding/binary"
"hash/crc32"
"sort"
"git.dvdt.dev/david/ingot/labels"
)
@@ -213,3 +214,29 @@ func (r *Reader) SeriesByRef(ref uint64) (SeriesEntry, bool) {
func (r *Reader) Postings(name, value string) []uint64 {
return r.postings[labelPair{name, value}]
}
// LabelValues returns sorted unique values for the given label name.
func (r *Reader) LabelValues(name string) []string {
seen := make(map[string]struct{})
for key := range r.postings {
if key.name == name {
seen[key.value] = struct{}{}
}
}
vals := make([]string, 0, len(seen))
for v := range seen {
vals = append(vals, v)
}
sort.Strings(vals)
return vals
}
// AllPostings returns sorted refs for all series in the index.
func (r *Reader) AllPostings() []uint64 {
refs := make([]uint64, len(r.series))
for i, s := range r.series {
refs[i] = s.Ref
}
sort.Slice(refs, func(i, j int) bool { return refs[i] < refs[j] })
return refs
}