feat: initial recursive archive cataloging impl

Signed-off-by: Keith Zantow <keith.zantow@anchore.com>
This commit is contained in:
Keith Zantow
2026-09-10 08:45:36 -04:00
parent 0a93e60b16
commit 8c0d3747ce
85 changed files with 23477 additions and 868 deletions
+37
View File
@@ -0,0 +1,37 @@
package index
// PrefixSuffix index combines two KeySplitIndexes to simplify indexing and searching by prefix and suffix
type PrefixSuffix[T any] struct {
forwardIndex KeySplitIndex[T]
reverseIndex KeySplitIndex[T]
}
func (f *PrefixSuffix[T]) Set(key string, value T) {
f.forwardIndex.Set(key, value)
f.reverseIndex.Set(reverse(key), value)
}
func (f *PrefixSuffix[T]) Update(key string, fn NodeUpdateFunc[T]) {
f.forwardIndex.Update(key, fn)
f.reverseIndex.Update(reverse(key), fn)
}
func (f *PrefixSuffix[T]) Get(key string) T {
return f.forwardIndex.Get(key)
}
func (f *PrefixSuffix[T]) ByPrefix(prefix string) []T {
return f.forwardIndex.ByPrefix(prefix)
}
func (f *PrefixSuffix[T]) BySuffix(suffix string) []T {
return f.reverseIndex.ByPrefix(reverse(suffix))
}
func reverse(s string) string {
runes := []rune(s)
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
runes[i], runes[j] = runes[j], runes[i]
}
return string(runes)
}