示例#1
0
// Index functions
func (node *Node) Index(name string) (idx index.Index, err error) {
	if index.Has(name) {
		idx = index.NewVirtual(name, node.FilePath(), node.File.Size, 10240)
	} else {
		idx = index.New()
		err = idx.Load(node.IndexPath() + "/" + name + ".idx")
	}
	return
}
示例#2
0
文件: node.go 项目: MG-RAST/Shock
func (node *Node) DynamicIndex(name string) (idx index.Index, err error) {
	if index.Has(name) {
		idx = index.NewVirtual(name, node.FilePath(), node.File.Size, 10240)
	} else {
		if _, has := node.Indexes[name]; has {
			idx = index.New()
		} else {
			err_str := fmt.Sprintf("Node %s does not have index of type %s.", node.Id, name)
			err = errors.New(err_str)
		}
	}
	return
}