示例#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()
}
示例#2
0
文件: wrapper.go 项目: timtadh/sfp
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
}
示例#3
0
文件: sets.go 项目: timtadh/graple
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,
	}
}
示例#4
0
文件: fs.go 项目: 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,
	}
}
示例#5
0
文件: wrapper.go 项目: timtadh/sfp
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
}