示例#1
0
文件: db.go 项目: butine/research
func (self *DB) CreateColumnFamily(opts *Options, name string) (*ColumnFamilyHandle, error) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	var cErr *C.char
	cHandle := C.rocksdb_create_column_family(self.c, opts.c, cName, &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return nil, errors.New(C.GoString(cErr))
	}
	return NewNativeColumnFamilyHandle(cHandle), nil
}
示例#2
0
// CreateColumnFamily creates a new column family in db.
func (self *DB) CreateColumnFamily(cfd ColumnFamilyDescriptor) (*ColumnFamily, error) {
	var cErr *C.char

	cname := C.CString(cfd.Name)
	defer C.free(unsafe.Pointer(cname))
	cf := C.rocksdb_create_column_family(self.c, cfd.Opts.c, cname, &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return nil, errors.New(C.GoString(cErr))
	}
	return &ColumnFamily{c: cf}, nil
}
示例#3
0
文件: db.go 项目: daaku/gorocksdb
// CreateCF create a new column family.
func (db *DB) CreateCF(opts *Options, name string) (*CF, error) {
	var (
		cErr  *C.char
		cName = C.CString(name)
	)
	defer C.free(unsafe.Pointer(cName))
	cHandle := C.rocksdb_create_column_family(db.c, opts.c, cName, &cErr)
	if cErr != nil {
		return nil, convertErr(cErr)
	}
	return newNativeCF(cHandle), nil
}