Documentation
¶
Index ¶
- Constants
- func BinSearchInRange(from, to int, fn func(i int) bool) int
- func ByteToStringUnsafe(b []byte) string
- func CollapseErrors(errs []error) error
- func CopyFile(src, dst string) error
- func DeduplicateErrors(errs []error) error
- func DurationToUnit(durationVal time.Duration, unit string) float64
- func EnsureSliceSize[T any](src []T, size int) []T
- func Float64ToPrec(val float64, prec uint32) float64
- func IdxFill(n int) []int
- func IdxShuffle(n int) []int
- func IsCancelled(ctx context.Context) bool
- func MsTsToESFormat(ts uint64) string
- func MustCreateDir(dirPath string)
- func MustFsyncFile(fpath string)
- func MustRemoveFileByPath(fpath string)
- func MustSyncPath(dirPath string)
- func MustWriteFileAtomic(fpath string, data []byte, perm os.FileMode, tmpFileExt string)
- func NsTsToESFormat(ts uint64) string
- func ParseDuration(esDuration string) (time.Duration, error)
- func Recover(metric prometheus.Counter, err error)
- func RecoverToError(panicData any, metric prometheus.Counter) error
- func RemoveFile(file string)
- func RunEvery(done <-chan struct{}, runInterval time.Duration, actionFn func())
- func SizeStr(bytes uint64) string
- func SizeToUnit(sizeVal uint64, unit string) float64
- func StringToByteUnsafe(str string) []byte
- func SyncPath(dirPath string) error
- func VisitFilesWithExt(des []os.DirEntry, ext string, cb func(name string) error) error
- func WriteFileAtomic(fpath string, data []byte, perm os.FileMode, tmpFileExt string) error
- func ZapDurationWithPrec(key string, dur time.Duration, unit string, prec uint32) zap.Field
- func ZapFloat64WithPrec(key string, val float64, prec uint32) zap.Field
- func ZapMsTsAsESTimeStr(key string, ts uint64) zap.Field
- func ZapUint64AsSizeStr(key string, val uint64) zap.Field
- type Bitmask
- type BufferPool
- type LetterBitsetBuilder
- type LettersBitset
- type MinHeap
- type Pair
- type ReallocSolver
- type ReallocSolverOpts
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ByteToStringUnsafe ¶
func CollapseErrors ¶
CollapseErrors combines errors and writes repeats of each.
func DeduplicateErrors ¶
DeduplicateErrors deduplicates errors.
func DurationToUnit ¶
DurationToUnit converts duration to unit and returns as float64.
func EnsureSliceSize ¶
func Float64ToPrec ¶
Float64ToPrec formats float64 by removing numberics after prec digit.
func IdxShuffle ¶
func IsCancelled ¶
IsCancelled is a faster way to check if the context has been canceled, compared to ctx.Err() != nil
func MsTsToESFormat ¶
MsTsToESFormat converts timestamp in milliseconds to ES time format string.
func MustCreateDir ¶ added in v0.70.0
func MustCreateDir(dirPath string)
MustCreateDir creates directory at dirPath. Handles the case when directory already exists.
func MustFsyncFile ¶ added in v0.70.0
func MustFsyncFile(fpath string)
func MustRemoveFileByPath ¶ added in v0.60.0
func MustRemoveFileByPath(fpath string)
func MustSyncPath ¶
func MustSyncPath(dirPath string)
func MustWriteFileAtomic ¶ added in v0.70.0
func NsTsToESFormat ¶ added in v0.64.0
NsTsToESFormat converts timestamp in nanoseconds to ES time format string. Nanosecond part will not be printed.
func Recover ¶
func Recover(metric prometheus.Counter, err error)
func RecoverToError ¶
func RecoverToError(panicData any, metric prometheus.Counter) error
func RemoveFile ¶ added in v0.62.3
func RemoveFile(file string)
RemoveFile safely removes a file with logging Handles cases where the file already doesn't exist
func SizeToUnit ¶
SizeToUnit converts size in bytes to unit and returns as float64.
func StringToByteUnsafe ¶
func VisitFilesWithExt ¶ added in v0.70.0
VisitFilesWithExt traverses all the files with `ext` extension in `des` directory and calls a `cb` func for each of files.
func WriteFileAtomic ¶ added in v0.70.0
atomicWrite safely writes data to file using atomic replacement pattern
func ZapDurationWithPrec ¶
ZapDurationWithPrec converts duration to unit and forms float64 zap.Field with removed numerics after prec digit.
func ZapFloat64WithPrec ¶
ZapFloat64WithPrec forms float64 zap.Field with removed numerics after prec digit.
func ZapMsTsAsESTimeStr ¶
ZapMsTsAsESTimeStr converts timestamp in milliseconds to ES time format string and forms string zap.Field.
Types ¶
type Bitmask ¶
type Bitmask struct {
// contains filtered or unexported fields
}
func LoadBitmask ¶
func NewBitmask ¶
func (*Bitmask) GetBitmaskBinary ¶
type BufferPool ¶ added in v0.59.0
type BufferPool struct {
// contains filtered or unexported fields
}
func (*BufferPool) Get ¶ added in v0.59.0
func (q *BufferPool) Get() *bytespool.Buffer
func (*BufferPool) Put ¶ added in v0.59.0
func (q *BufferPool) Put(b *bytespool.Buffer)
type LetterBitsetBuilder ¶ added in v0.75.0
type LetterBitsetBuilder [30]bool
func (*LetterBitsetBuilder) Add ¶ added in v0.75.0
func (b *LetterBitsetBuilder) Add(token []byte)
func (*LetterBitsetBuilder) Build ¶ added in v0.75.0
func (b *LetterBitsetBuilder) Build() LettersBitset
type LettersBitset ¶ added in v0.75.0
type LettersBitset uint32
LettersBitset is a bitset of symbols present in token blocks. Allows to prune token blocks on wildcard search. It uses 26 bits for eng letters (case-insensitive) as well as two bits for first bytes of ru letters, and a single bit for everything else.
The highest bit (bit 31) is reserved as the nil marker.
func NewLettersBitset ¶ added in v0.75.0
func NewLettersBitset(data []byte) LettersBitset
func NewLettersBitsetFromArray ¶ added in v0.75.0
func NewLettersBitsetFromArray(letters [30]bool) LettersBitset
func NewLettersBitsetNil ¶ added in v0.75.0
func NewLettersBitsetNil() LettersBitset
func (LettersBitset) ContainsAll ¶ added in v0.75.0
func (s LettersBitset) ContainsAll(required LettersBitset) bool
func (LettersBitset) IsNil ¶ added in v0.75.0
func (s LettersBitset) IsNil() bool
type MinHeap ¶ added in v0.73.0
MinHeap is a min‑heap for any comparable type. Maintains both a heap structure and a map for fast lookup of items.
func NewMinHeap ¶ added in v0.73.0
NewMinHeap creates and initializes a new MinHeap instance.
func (*MinHeap[T]) Min ¶ added in v0.73.0
Min returns the minimum value in the heap without removing it. Returns (zero value, false) if the heap is empty.
func (*MinHeap[T]) PopMin ¶ added in v0.73.0
PopMin removes and returns the minimum value from the heap. Returns (zero value, false) if the heap is empty.
type ReallocSolver ¶
type ReallocSolver struct {
// contains filtered or unexported fields
}
func NewReallocSolver ¶
func NewReallocSolver(opts ...ReallocSolverOpts) ReallocSolver
func (*ReallocSolver) ReallocParams ¶
func (s *ReallocSolver) ReallocParams(curLen, curCap int) (int, bool)
type ReallocSolverOpts ¶
type ReallocSolverOpts func(*ReallocSolver)
func ReallocSolverLabel ¶
func ReallocSolverLabel(label string) ReallocSolverOpts