當前位置: 首頁>>代碼示例>>Golang>>正文


Golang datamodel.Info類代碼示例

本文整理匯總了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;未經允許,請勿轉載。