keyutil

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between

func Between(startKey, endKey, key []byte) bool

Between returns true if startKey < key < endKey. If the key is empty and the boundary is right, the keys is infinite.

func BuildKeyRangeKey

func BuildKeyRangeKey(startKey, endKey []byte) string

BuildKeyRangeKey build key for a keyRange

func DecodeHTTPKeyRanges

func DecodeHTTPKeyRanges(input map[string]any) ([]string, error)

DecodeHTTPKeyRanges decodes the key ranges from the HTTP request parameters.

func MaxKey

func MaxKey(a, b []byte) []byte

MaxKey return the bigger key for the given keys.

func MaxStartKey

func MaxStartKey(a, b []byte) []byte

MaxStartKey returns the bigger keys, the empty key is the biggest.

func MinEndKey

func MinEndKey(a, b []byte) []byte

MinEndKey returns the smaller keys, the empty key is the biggest.

func MinKey

func MinKey(a, b []byte) []byte

MinKey returns the smaller key for the given keys.

Types

type KeyRange

type KeyRange struct {
	StartKey []byte `json:"start-key"`
	EndKey   []byte `json:"end-key"`
}

KeyRange is a key range.

func NewKeyRange

func NewKeyRange(startKey, endKey string) KeyRange

NewKeyRange create a KeyRange with the given start key and end key.

func (*KeyRange) IsAdjacent

func (kr *KeyRange) IsAdjacent(other *KeyRange) bool

IsAdjacent returns true if the two KeyRanges are adjacent.

func (*KeyRange) MarshalJSON

func (kr *KeyRange) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json.

func (*KeyRange) OverLapped

func (kr *KeyRange) OverLapped(other *KeyRange) bool

OverLapped return true if the two KeyRanges are overlapped. if the two KeyRanges are continuous, it will also return true.

func (*KeyRange) UnmarshalJSON

func (kr *KeyRange) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from json.

type KeyRanges

type KeyRanges struct {
	// contains filtered or unexported fields
}

KeyRanges is a slice of monotonically increasing KeyRange.

func NewKeyRangesWithSize

func NewKeyRangesWithSize(size int) *KeyRanges

NewKeyRangesWithSize creates a KeyRanges with the hint size.

func (*KeyRanges) Append

func (rs *KeyRanges) Append(startKey, endKey []byte)

Append appends a KeyRange.

func (*KeyRanges) Delete

func (rs *KeyRanges) Delete(base *KeyRange)

Delete deletes the KeyRange from the KeyRanges.

func (*KeyRanges) IsEmpty

func (rs *KeyRanges) IsEmpty() bool

IsEmpty returns true if the KeyRanges is empty.

func (*KeyRanges) Merge

func (rs *KeyRanges) Merge()

Merge merges the continuous KeyRanges.

func (*KeyRanges) Ranges

func (rs *KeyRanges) Ranges() []*KeyRange

Ranges returns the slice of KeyRange.

func (*KeyRanges) SortAndDeduce

func (rs *KeyRanges) SortAndDeduce()

SortAndDeduce sorts the KeyRanges and deduces the overlapped KeyRanges.

func (*KeyRanges) SubtractKeyRanges

func (rs *KeyRanges) SubtractKeyRanges(base *KeyRange) []KeyRange

SubtractKeyRanges returns the KeyRanges that are not overlapped with the given KeyRange.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL