pool

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2022 Huawei Cloud Computing Technologies Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. nolint

Index

Constants

View Source
const (
	DefaultLocalCacheLen      = 8
	MaxLocalCacheLen          = 64
	DefaultMaxLocalEleMemSize = 2 * 1024 * 1024
	DefaultMaxEleMemSize      = 128 * 1024 * 1024
)

Variables

View Source
var RowsPool sync.Pool

Functions

func GetIntSlice added in v1.3.0

func GetIntSlice(size int) []int

func GetRows added in v1.3.0

func GetRows(num int) *[]influx.Row

func PutIntSlice added in v1.3.0

func PutIntSlice(v []int)

func PutRows added in v1.3.0

func PutRows(rows *[]influx.Row)

Types

type Allocator added in v1.4.1

type Allocator[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewAllocator added in v1.4.1

func NewAllocator[K comparable, V any]() *Allocator[K, V]

func (*Allocator[K, V]) Alloc added in v1.4.1

func (a *Allocator[K, V]) Alloc() *V

func (*Allocator[K, V]) MapAlloc added in v1.4.1

func (a *Allocator[K, V]) MapAlloc(key K) (*V, bool)

func (*Allocator[K, V]) Reset added in v1.4.1

func (a *Allocator[K, V]) Reset()

func (*Allocator[K, V]) Rollback added in v1.4.1

func (a *Allocator[K, V]) Rollback()

func (*Allocator[K, V]) SetMaxCacheSize added in v1.5.0

func (a *Allocator[K, V]) SetMaxCacheSize(v int)

func (*Allocator[K, V]) ValMap added in v1.4.1

func (a *Allocator[K, V]) ValMap() map[K]*V

func (*Allocator[K, V]) Values added in v1.4.1

func (a *Allocator[K, V]) Values() []*V

type Buffer added in v1.2.0

type Buffer struct {
	B    []byte
	Swap []byte
}

func GetChunkMetaBuffer added in v1.2.0

func GetChunkMetaBuffer() (*Buffer, func())

func (*Buffer) Instance added in v1.2.0

func (b *Buffer) Instance() *Buffer

func (*Buffer) MemSize added in v1.2.0

func (b *Buffer) MemSize() int

type FixedPool added in v1.1.0

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

func (*FixedPool) Get added in v1.1.0

func (p *FixedPool) Get() interface{}

func (*FixedPool) Put added in v1.1.0

func (p *FixedPool) Put(v interface{})

func (*FixedPool) Reset added in v1.1.0

func (p *FixedPool) Reset(size int, new func() interface{}, hook *HitRatioHook)

type HitRatioHook added in v1.1.0

type HitRatioHook struct {
	IncrTotal func(int64)
	IncrHit   func(int64)
}

func NewHitRatioHook added in v1.1.0

func NewHitRatioHook(total, hit func(int64)) *HitRatioHook

type ListPool added in v1.0.0

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

func NewListPool added in v1.0.0

func NewListPool() *ListPool

func (*ListPool) Get added in v1.0.0

func (u *ListPool) Get() *list.List

func (*ListPool) HitRatio added in v1.0.0

func (u *ListPool) HitRatio() float64

func (*ListPool) Put added in v1.0.0

func (u *ListPool) Put(v *list.List)

type MemSizeSupported added in v1.4.0

type MemSizeSupported[T any] interface {
	MemSize() int
	Instance() *T
}

type Uint32Array

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

func NewUint32Array

func NewUint32Array() *Uint32Array

func (*Uint32Array) Get

func (u *Uint32Array) Get(size int) []uint32

func (*Uint32Array) HitRatio

func (u *Uint32Array) HitRatio() float64

func (*Uint32Array) Put

func (u *Uint32Array) Put(v *[]uint32)

type UnionPool added in v1.4.0

type UnionPool[T any] struct {
	// contains filtered or unexported fields
}

func NewDefaultUnionPool added in v1.4.0

func NewDefaultUnionPool[T any](creator func() *T) *UnionPool[T]

func NewUnionPool added in v1.4.0

func NewUnionPool[T any](localCacheLen int, maxEleMemSize int, maxLocalEleMemSize int, creator func() *T) *UnionPool[T]

func (*UnionPool[T]) EnableHitRatioStat added in v1.4.0

func (p *UnionPool[T]) EnableHitRatioStat(name string)

EnableHitRatioStat Enable statistics on the hit ratio of the object pool two metrics "{name}GetTotal" and "{name}HitTotal" are added to the hitRatio table

func (*UnionPool[T]) EnableStatLocalMemSize added in v1.4.0

func (p *UnionPool[T]) EnableStatLocalMemSize()

func (*UnionPool[T]) Get added in v1.4.0

func (p *UnionPool[T]) Get() *T

func (*UnionPool[T]) LocalMemorySize added in v1.4.0

func (p *UnionPool[T]) LocalMemorySize() int

func (*UnionPool[T]) Put added in v1.4.0

func (p *UnionPool[T]) Put(v MemSizeSupported[T])

Put object v back into the object pool Object v must implement the MemSizeSupported interface Otherwise, use the PutWithMemSize method instead

func (*UnionPool[T]) PutWithMemSize added in v1.4.0

func (p *UnionPool[T]) PutWithMemSize(v *T, memSize int)

Jump to

Keyboard shortcuts

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