예제 #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
파일: cfam.go 프로젝트: rdallman/gorocksdb
// 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
}