util

package
v0.0.0-...-7695f31 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EStamatewithParameters

func EStamatewithParameters(n uint, p float64) (m uint, k uint)

func GenerateRandom

func GenerateRandom(digit int) string

GenerateRandom 生成随机数字

func GenerateRandomTime

func GenerateRandomTime() time.Duration

func InitWorker

func InitWorker(workerId int64)

实例化一个工作节点 workerId 为当前节点的id

func SnowFlake

func SnowFlake(db *gorm.DB)

SnowFlake gorm雪花算法插件

func Version

func Version(db *gorm.DB)

Version gorm乐观锁插件

Types

type BloomFilter

type BloomFilter struct {
	M uint           `json:"m"` //容量
	K uint           `json:"k"` //hash函数个数
	B *bitset.BitSet `json:"b"`
}

func From

func From(data []uint64, k uint) *BloomFilter

根据数据量新建布隆过滤器

func NewBloomFilter

func NewBloomFilter(m uint, k uint) *BloomFilter

新建一个布隆 过滤器

func NewwithEstimates

func NewwithEstimates(n uint, p float64) *BloomFilter

新建一个布隆过滤器,预估数据规模

func (*BloomFilter) Add

func (f *BloomFilter) Add(data []byte) *BloomFilter

func (*BloomFilter) AddString

func (f *BloomFilter) AddString(data string) *BloomFilter

func (*BloomFilter) Cap

func (f *BloomFilter) Cap() uint

func (*BloomFilter) Clear

func (f *BloomFilter) Clear() *BloomFilter

清空布隆过滤器

func (*BloomFilter) Copy

func (f *BloomFilter) Copy() *BloomFilter

拷贝新建一个布隆过滤器

func (*BloomFilter) Equal

func (f *BloomFilter) Equal(g *BloomFilter) bool

判断布隆过滤器是否相等

func (*BloomFilter) EstimateFalsePositiveRate

func (f *BloomFilter) EstimateFalsePositiveRate(n uint, rounds uint32) (fpRate float64)

测试正确率

func (*BloomFilter) GK

func (f *BloomFilter) GK() uint

func (*BloomFilter) GoDecode

func (f *BloomFilter) GoDecode(data []byte) error

func (*BloomFilter) GoEncode

func (f *BloomFilter) GoEncode() ([]byte, error)

func (*BloomFilter) MarshaJson

func (f *BloomFilter) MarshaJson() ([]byte, error)

字节转对象

func (*BloomFilter) Merge

func (f *BloomFilter) Merge(g *BloomFilter) error

func (*BloomFilter) Readfrom

func (f *BloomFilter) Readfrom(stream io.Reader) (int64, error)

func (*BloomFilter) Test

func (f *BloomFilter) Test(data []byte) bool

func (*BloomFilter) TestAndAdd

func (f *BloomFilter) TestAndAdd(data []byte) bool

测试是否存在,存在就更新

func (*BloomFilter) TestAndAddString

func (f *BloomFilter) TestAndAddString(data []byte) bool

测试是否存在,存在就更新

func (*BloomFilter) TestLocations

func (f *BloomFilter) TestLocations(locs []uint64) bool

测试整数 是否存在

func (*BloomFilter) TestString

func (f *BloomFilter) TestString(data []byte) bool

func (*BloomFilter) UnMarshaJson

func (f *BloomFilter) UnMarshaJson(data []byte) error

字节转对象

func (*BloomFilter) Writeto

func (f *BloomFilter) Writeto(stream io.Writer) (int64, error)

type PageHelper

type PageHelper struct {
	Page  int64 `json:"page"`
	Size  int64 `json:"size"`
	Total int64 `json:"total"`
	Pages int64 `json:"pages"`
}

func (*PageHelper) Limit

func (ph *PageHelper) Limit() int64

func (*PageHelper) Offset

func (ph *PageHelper) Offset() int64

func (*PageHelper) SetPages

func (ph *PageHelper) SetPages(total int64)

Jump to

Keyboard shortcuts

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