Example #1
0
func GetUserStore(dir string) (*UserFileStore, error) {
	var bf *fmap.BlockFile
	var users *bptree.BpTree
	path := filepath.Join(dir, "users.bptree")
	err := createOrOpen(path,
		func(path string) (err error) {
			bf, err = fmap.CreateBlockFile(path)
			if err != nil {
				return err
			}
			users, err = bptree.New(bf, -1, -1)
			return err
		},
		func(path string) (err error) {
			bf, err = fmap.OpenBlockFile(path)
			if err != nil {
				return err
			}
			users, err = bptree.Open(bf)
			return err
		},
	)
	if err != nil {
		return nil, err
	}
	s := &UserFileStore{
		path:  path,
		bf:    bf,
		users: users,
	}
	return s, bf.Sync()
}
Example #2
0
func OpenBpTree(
	path string,
	serializeKey func([]byte) []byte,
	serializeValue func(*goiso.SubGraph) []byte,
	deserializeKey func([]byte) []byte,
	deserializeValue func([]byte) *goiso.SubGraph,
) (*BpTree, error) {
	bf, err := fmap.OpenBlockFile(path)
	if err != nil {
		return nil, err
	}
	bpt, err := bptree.Open(bf)
	if err != nil {
		return nil, err
	}
	b := &BpTree{
		bf:               bf,
		bpt:              bpt,
		serializeKey:     serializeKey,
		serializeValue:   serializeValue,
		deserializeKey:   deserializeKey,
		deserializeValue: deserializeValue,
	}
	return b, nil
}
Example #3
0
func OpenFs2Sets(path string) *Fs2Sets {
	bf, err := fmap.OpenBlockFile(path)
	assert_ok(err)
	bpt, err := bptree.Open(bf)
	assert_ok(err)
	return &Fs2Sets{
		bf:  bf,
		bpt: bpt,
	}
}
Example #4
0
File: fs.go Project: timtadh/graple
func OpenFs2BpTree(g *goiso.Graph, path string) *Fs2BpTree {
	bf, err := fmap.OpenBlockFile(path)
	assert_ok(err)
	bpt, err := bptree.Open(bf)
	assert_ok(err)
	return &Fs2BpTree{
		g:   g,
		bf:  bf,
		bpt: bpt,
	}
}
Example #5
0
func OpenBpTree(path string) (*BpTree, error) {
	bf, err := fmap.OpenBlockFile(path)
	if err != nil {
		return nil, err
	}
	bpt, err := bptree.Open(bf)
	if err != nil {
		return nil, err
	}
	b := &BpTree{
		bf:  bf,
		bpt: bpt,
	}
	return b, nil
}
Example #6
0
func OpenList(
	path string,
	serializeItem func(*goiso.SubGraph) []byte,
	deserializeItem func([]byte) *goiso.SubGraph,
) (*MMList, error) {
	bf, err := fmap.OpenBlockFile(path)
	if err != nil {
		return nil, err
	}
	list, err := mmlist.Open(bf)
	if err != nil {
		return nil, err
	}
	b := &MMList{
		bf:              bf,
		list:            list,
		serializeItem:   serializeItem,
		deserializeItem: deserializeItem,
	}
	return b, nil
}