Esempio n. 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
}
Esempio n. 2
0
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
}