本文整理匯總了Golang中github.com/influxdata/influxdb/tsdb.Shard類的典型用法代碼示例。如果您正苦於以下問題:Golang Shard類的具體用法?Golang Shard怎麽用?Golang Shard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Shard類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: chunkedWrite
func chunkedWrite(shard *tsdb.Shard, points []models.Point) {
nPts := len(points)
chunkSz := 10000
start := 0
end := chunkSz
for {
if end > nPts {
end = nPts
}
if end-start == 0 {
break
}
shard.WritePoints(points[start:end])
start = end
end += chunkSz
}
}
示例2: LoadMetadataIndex
// LoadMetadataIndex loads the shard metadata into memory.
func (e *Engine) LoadMetadataIndex(sh *tsdb.Shard, index *tsdb.DatabaseIndex) error {
// Save reference to index for iterator creation.
e.index = index
start := time.Now()
if err := e.FileStore.WalkKeys(func(key string, typ byte) error {
fieldType, err := tsmFieldTypeToInfluxQLDataType(typ)
if err != nil {
return err
}
if err := e.addToIndexFromKey(key, fieldType, index); err != nil {
return err
}
return nil
}); err != nil {
return err
}
// load metadata from the Cache
e.Cache.RLock() // shouldn't need the lock, but just to be safe
defer e.Cache.RUnlock()
for key, entry := range e.Cache.Store() {
fieldType, err := entry.values.InfluxQLType()
if err != nil {
e.logger.Printf("error getting the data type of values for key %s: %s", key, err.Error())
continue
}
if err := e.addToIndexFromKey(key, fieldType, index); err != nil {
return err
}
}
// sh may be nil in tests
if sh != nil {
e.logger.Printf("%s database index loaded in %s", sh.Path(), time.Now().Sub(start))
}
return nil
}