本文整理汇总了Golang中datamodel.Info类的典型用法代码示例。如果您正苦于以下问题:Golang Info类的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Info类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: create
// CreateSketch ...
func (m *sketchManager) create(info *datamodel.Info) error {
sketch, err := sketches.CreateSketch(info)
if err != nil {
return err
}
m.sketches[info.ID()] = sketch
return nil
}
开发者ID:njpatel,项目名称:skizze,代码行数:9,代码来源:sketch.go
示例2: CreateDomain
// CreateDomain ...
func (m *Manager) CreateDomain(info *datamodel.Info) error {
infos := make(map[string]*datamodel.Info)
for _, typ := range datamodel.GetTypesPb() {
styp := typ
tmpInfo := info.Copy()
tmpInfo.Type = &styp
infos[tmpInfo.ID()] = tmpInfo
}
return m.domains.create(info.GetName(), infos)
}
开发者ID:njpatel,项目名称:skizze,代码行数:11,代码来源:manager.go
示例3: create
func (m *infoManager) create(info *datamodel.Info) error {
if _, ok := m.info[info.ID()]; ok {
return fmt.Errorf(`Sketch of type "%s" with name "%s" already exists`,
info.GetType(), info.GetName())
}
m.info[info.ID()] = info
return nil
}
开发者ID:njpatel,项目名称:skizze,代码行数:8,代码来源:info.go
示例4: CreateSketch
// CreateSketch ...
func (m *Manager) CreateSketch(info *datamodel.Info) error {
if !isValidType(info) {
return fmt.Errorf("Can not create sketch of type %s, invalid type.", info.Type)
}
if err := m.infos.create(info); err != nil {
return err
}
if err := m.sketches.create(info); err != nil {
// If error occurred during creation of sketch, delete info
if err2 := m.infos.delete(info.ID()); err2 != nil {
return fmt.Errorf("%q\n%q ", err, err2)
}
return err
}
return nil
}
开发者ID:njpatel,项目名称:skizze,代码行数:17,代码来源:manager.go
示例5: CreateSketch
// CreateSketch ...
func CreateSketch(info *datamodel.Info) (*SketchProxy, error) {
var err error
var sketch datamodel.Sketcher
sp := &SketchProxy{info, sketch, sync.RWMutex{}}
switch datamodel.GetTypeString(info.GetType()) {
case datamodel.HLLPP:
sp.sketch, err = NewHLLPPSketch(info)
case datamodel.CML:
sp.sketch, err = NewCMLSketch(info)
case datamodel.TopK:
sp.sketch, err = NewTopKSketch(info)
case datamodel.Bloom:
sp.sketch, err = NewBloomSketch(info)
default:
return nil, fmt.Errorf("Invalid sketch type: %s", sp.GetType())
}
if err != nil {
return nil, err
}
return sp, nil
}
开发者ID:njpatel,项目名称:skizze,代码行数:24,代码来源:proxy.go
示例6: LoadSketch
// LoadSketch ...
func LoadSketch(info *datamodel.Info, file *os.File) (*SketchProxy, error) {
var sketch datamodel.Sketcher
sp := &SketchProxy{info, sketch, sync.RWMutex{}}
size, err := utils.GetFileSize(file)
if err != nil {
return nil, err
}
data := make([]byte, size, size)
_, err = file.Read(data)
if err != nil {
return nil, fmt.Errorf("Error loading data for sketch: %s", info.ID())
}
switch datamodel.GetTypeString(info.GetType()) {
case datamodel.HLLPP:
sp.sketch = &HLLPPSketch{}
err = sp.sketch.Unmarshal(info, data)
case datamodel.CML:
sp.sketch = &CMLSketch{}
err = sp.sketch.Unmarshal(info, data)
case datamodel.TopK:
sp.sketch = &TopKSketch{}
err = sp.sketch.Unmarshal(info, data)
case datamodel.Bloom:
sp.sketch = &BloomSketch{}
err = sp.sketch.Unmarshal(info, data)
default:
return nil, fmt.Errorf("Invalid sketch type: %s", sp.GetType())
}
if err != nil {
return nil, err
}
return sp, nil
}
开发者ID:silky,项目名称:skizze,代码行数:37,代码来源:proxy.go
示例7: isValidType
func isValidType(info *datamodel.Info) bool {
if info.Type == nil {
return false
}
return len(datamodel.GetTypeString(info.GetType())) != 0
}
开发者ID:njpatel,项目名称:skizze,代码行数:6,代码来源:manager.go
示例8: NewDict
// NewDict ...
func NewDict(info *datamodel.Info) *Dict {
sketch := make(map[string]uint)
size := info.GetProperties().GetMaxUniqueItems() / 10
d := Dict{info, sketch, uint(size)}
return &d
}
开发者ID:skizzehq,项目名称:skizze,代码行数:7,代码来源:dict.go
注:本文中的datamodel.Info类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论