chore: drop the locking and JSON support from internal/index

the index was ported from a prototype with per-node `RWMutex` lock upgrading and JSON marshalling. Its only consumer (`archive.Resolver`) builds it sequentially during extraction and then only reads it, so neither was used. `lock.go` also compared method-value pointers to tell the read lock from the write lock, which can't distinguish lock instances.

removed the locks, the upgrade and retry paths that existed only for concurrent writers, and the JSON methods and their test. The radix logic is unchanged, and the README now points at `archive.Resolver` rather than a nonexistent `archive.Index`.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2026-09-24 13:42:59 -04:00
parent 9dbef8e831
commit 8e2cdf2429
4 changed files with 42 additions and 230 deletions
-28
View File
@@ -1,7 +1,6 @@
package index
import (
"encoding/json"
"fmt"
"testing"
@@ -131,33 +130,6 @@ func Test_KeySplitIndex_Get(t *testing.T) {
require.Equal(t, 0, fi.Get("invalid")) // returns the zero value
}
func Test_KeySplitIndex_serialization(t *testing.T) {
index1 := KeySplitIndex[int]{}
const (
one = 1
two = 2
once = 11
onesie = 111
)
index1.Set("one", one)
index1.Set("two", two)
index1.Set("once", once)
index1.Set("onesie", onesie)
serialized, err := json.Marshal(&index1)
require.NoError(t, err)
require.JSONEq(t, `{"one":1,"two":2,"once":11,"onesie":111}`, string(serialized))
var index2 KeySplitIndex[int]
err = json.Unmarshal(serialized, &index2)
require.NoError(t, err)
require.Equal(t, &index1, &index2)
}
// requireHasAll asserts the values are exactly the required ones, in any order. Carried over with the
// index's own tests so they run here unchanged.
func requireHasAll[T comparable](t *testing.T, values []T, required ...T) {