index

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultMaxCacheSize = 5000000 // 默认 最多500w个,太大了内存会耗尽
)
View Source
const INDEX_SHARD = 256
View Source
const (
	IndexUpdateIncrTaskSleepInterval = time.Duration(10) * time.Second // 增量更新间隔时间, 默认30s
)

Variables

View Source
var IndexedItemCacheBigMap = make([]*IndexCacheBase, INDEX_SHARD)
View Source
var UnIndexedItemCacheBigMap = make([]*IndexCacheBase, INDEX_SHARD)
View Source
var UpdateIndexLock = semaphore.NewSemaphore(1)

重建索引全局锁

Functions

func DeleteItemFronIndex

func DeleteItemFronIndex(hash interface{}) *dataobj.TsdbItem

func GetIndex

func GetIndex()

func GetIndexLoop

func GetIndexLoop()

func GetItemFronIndex

func GetItemFronIndex(hash interface{}) *dataobj.TsdbItem

func Init

func Init(cfg IndexSection)

初始化索引功能模块

func RebuildAllIndex

func RebuildAllIndex(params ...[]string) error

func ReceiveItem

func ReceiveItem(item *dataobj.TsdbItem, hash interface{})

index收到一条新上报的监控数据,尝试用于增量更新索引

func StartIndexUpdateIncrTask

func StartIndexUpdateIncrTask()

启动索引的 异步、增量更新 任务, 每隔一定时间,刷新cache中的数据到数据库中

func StartUpdateIndexTask

func StartUpdateIndexTask()

Types

type DsTypeAndStep

type DsTypeAndStep struct {
	DsType string `json:"dstype"`
	Step   int    `json:"step"`
}

type IndexAddrs

type IndexAddrs struct {
	sync.RWMutex
	Data []string
}
var IndexList IndexAddrs

func (*IndexAddrs) Get

func (i *IndexAddrs) Get() []string

func (*IndexAddrs) Set

func (i *IndexAddrs) Set(addrs []string)

type IndexCacheBase

type IndexCacheBase struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

索引缓存-基本缓存容器

func NewIndexCacheBase

func NewIndexCacheBase(max int) *IndexCacheBase

func (*IndexCacheBase) ContainsKey

func (this *IndexCacheBase) ContainsKey(key interface{}) bool

func (*IndexCacheBase) Get

func (this *IndexCacheBase) Get(key interface{}) *dataobj.TsdbItem

func (*IndexCacheBase) Keys

func (this *IndexCacheBase) Keys() []interface{}

func (*IndexCacheBase) Put

func (this *IndexCacheBase) Put(key interface{}, item *dataobj.TsdbItem)

func (*IndexCacheBase) Remove

func (this *IndexCacheBase) Remove(key interface{})

func (*IndexCacheBase) Size

func (this *IndexCacheBase) Size() int

type IndexCacheItem

type IndexCacheItem struct {
	UUID interface{}
	Item *dataobj.TsdbItem
}

索引缓存的元素数据结构

func NewIndexCacheItem

func NewIndexCacheItem(uuid interface{}, item *dataobj.TsdbItem) *IndexCacheItem

type IndexSection

type IndexSection struct {
	ActiveDuration  int64  `yaml:"activeDuration"`  //内存索引保留时间
	RebuildInterval int64  `yaml:"rebuildInterval"` //索引重建周期
	HbsMod          string `yaml:"hbsMod"`
}
var Config IndexSection

Jump to

Keyboard shortcuts

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