forked from longtao.wu/droboticflow
27 lines
743 B
Go
27 lines
743 B
Go
package store
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestQueryBuildSlicePlansAvoidPerTaskFanout(t *testing.T) {
|
|
fragmented := map[string]map[int]bool{}
|
|
for i := 0; i < 601; i++ {
|
|
fragmented[fmt.Sprint(i)] = map[int]bool{i: true}
|
|
}
|
|
if got := len(workforceSliceReadFilters(fragmented, true)); got != 4 {
|
|
t.Fatal("rare histories became one query per task", got)
|
|
}
|
|
dense := map[string]map[int]bool{}
|
|
for i := 0; i < 6000; i++ {
|
|
dense[fmt.Sprint(i)] = map[int]bool{1: true, 2: true}
|
|
}
|
|
if got := len(workforceSliceReadFilters(dense, true)); got != 3 {
|
|
t.Fatal("common version sets remain fragmented", got)
|
|
}
|
|
if got := len(workforceSliceReadFilters(dense, false)); got != 30 {
|
|
t.Fatal("legacy API query strategy changed", got)
|
|
}
|
|
}
|