Skip to content

Commit

Permalink
feat(collections): add PrefixUntilTripleRange method for triple k…
Browse files Browse the repository at this point in the history
…ey (#17144)
  • Loading branch information
atheeshp authored Jul 27, 2023
1 parent 9a42a3e commit f0f777f
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions collections/triple.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit f0f777f

Please sign in to comment.