From f0f777fa3cb77fae5a403cd8e0f3da79d1f9d010 Mon Sep 17 00:00:00 2001 From: atheeshp <59333759+atheeshp@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:54:31 +0530 Subject: [PATCH] feat(collections): add `PrefixUntilTripleRange` method for `triple` key (#17144) --- collections/triple.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/collections/triple.go b/collections/triple.go index b465b25b877d..9733d9984099 100644 --- a/collections/triple.go +++ b/collections/triple.go @@ -273,26 +273,19 @@ func (t tripleKeyCodec[K1, K2, K3]) SizeNonTerminal(key Triple[K1, K2, K3]) int return size } -func PrefixTripleRange[K1, K2, K3 any](k1 K1) Ranger[Triple[K1, K2, K3]] { +// NewPrefixUntilTripleRange defines a collection query which ranges until the provided Pair prefix. +// Unstable: this API might change in the future. +func NewPrefixUntilTripleRange[K1, K2, K3 any](k1 K1) Ranger[Triple[K1, K2, K3]] { key := TriplePrefix[K1, K2, K3](k1) return &Range[Triple[K1, K2, K3]]{ - start: RangeKeyExact(key), - end: RangeKeyPrefixEnd(key), - } -} - -func SuperPrefixTripleRange[K1, K2, K3 any](k1 K1, k2 K2) Ranger[Triple[K1, K2, K3]] { - key := TripleSuperPrefix[K1, K2, K3](k1, k2) - return &Range[Triple[K1, K2, K3]]{ - start: RangeKeyExact(key), - end: RangeKeyPrefixEnd(key), + end: RangeKeyPrefixEnd(key), } } // NewPrefixedTripleRange provides a Range for all keys prefixed with the given // first part of the Triple key. -func NewPrefixedTripleRange[K1, K2, K3 any](prefix K1) Ranger[Triple[K1, K2, K3]] { - key := TriplePrefix[K1, K2, K3](prefix) +func NewPrefixedTripleRange[K1, K2, K3 any](k1 K1) Ranger[Triple[K1, K2, K3]] { + key := TriplePrefix[K1, K2, K3](k1) return &Range[Triple[K1, K2, K3]]{ start: RangeKeyExact(key), end: RangeKeyPrefixEnd(key),