v1.2.0: skip unchanged writes, transactional schema/root counters, snapshot replay for meta:events 0-0 (drops boot republish), collect-once search driver
Build and Push Docker Image / build (push) Successful in 7m38s

This commit is contained in:
Worph
2026-10-19 21:41:55 +00:00
parent dc5cbdfb9b
commit fb4bdad61b
21 changed files with 897 additions and 540 deletions
+34 -6
View File
@@ -294,13 +294,14 @@ func TestSearchCombinedPlanProbesByPrimaryKey(t *testing.T) {
}
seed(t, c, recs)
filters := []SearchFilter{{Property: "fileType", Values: []string{"video"}}}
driver, probes, err := c.planCandidates(context.Background(), c.Store(), "naruto", filters)
plan, err := c.planCandidates(context.Background(), c.Store(), "naruto", filters)
if err != nil {
t.Fatal(err)
}
if !strings.HasPrefix(driver.sql, "SELECT rid FROM fts") || len(probes) != 1 {
t.Fatalf("free text should drive with the filter as a probe, got driver %q, %d probes", driver.sql, len(probes))
if plan.walk || len(plan.ordered) != 1 || len(plan.probes) != 1 {
t.Fatalf("the rare text should drive (1 rid) with the filter as a probe, got %+v", plan)
}
probes := plan.probes
q, pargs := probeSQL(probes)
args := append([]any{`["R0000"]`}, pargs...)
rows, err := c.Store().DB().QueryContext(context.Background(), "EXPLAIN QUERY PLAN "+q, args...)
@@ -308,16 +309,16 @@ func TestSearchCombinedPlanProbesByPrimaryKey(t *testing.T) {
t.Fatal(err)
}
defer rows.Close()
var plan []string
var steps []string
for rows.Next() {
var id, parent, notused int
var detail string
if err := rows.Scan(&id, &parent, &notused, &detail); err != nil {
t.Fatal(err)
}
plan = append(plan, detail)
steps = append(steps, detail)
}
joined := strings.Join(plan, " | ")
joined := strings.Join(steps, " | ")
if !strings.Contains(joined, "PRIMARY KEY") || strings.Contains(joined, "SCAN kv") {
t.Fatalf("filter probe is not a primary-key range read: %s", joined)
}
@@ -325,3 +326,30 @@ func TestSearchCombinedPlanProbesByPrimaryKey(t *testing.T) {
return textMatch("naruto")(id, f) && matchFilter(f, "fileType", false, "video")
}), "R0000")
}
// When every part is broad (above estimateCap), the smallest is still
// collected and drives — no walk over the roots — and the result is exact.
func TestSearchBroadPartsStillDriveFromTheSmallest(t *testing.T) {
defer func(old int) { estimateCapForTest(old) }(estimateCapForTest(3))
c := newTestClient(t)
recs := map[string]map[string]string{}
for i := 0; i < 20; i++ {
ft := "video"
if i%2 == 1 {
ft = "audio"
}
recs[fmt.Sprintf("R%02d", i)] = map[string]string{"title": "Common words", "fileType": ft}
}
seed(t, c, recs)
filters := []SearchFilter{{Property: "fileType", Values: []string{"audio"}}}
plan, err := c.planCandidates(context.Background(), c.Store(), "common", filters)
if err != nil || plan.walk || len(plan.ordered) != 20 || len(plan.probes) != 1 {
t.Fatalf("want the text (20 rids) driving with one probe, got walk=%v ordered=%d probes=%d err %v", plan.walk, len(plan.ordered), len(plan.probes), err)
}
got := search(t, c, "common", filters, func(id string, f map[string]string) bool {
return textMatch("common")(id, f) && matchFilter(f, "fileType", false, "audio")
})
if len(got) != 10 || got[0] != "R01" {
t.Fatalf("got %v", got)
}
}