Example #1
0
// PutCF writes data associated with a key to the database and column family.
func (db *DB) PutCF(opts *WriteOptions, cf *CF, key, value []byte) error {
	var (
		cErr   *C.char
		cKey   = byteToChar(key)
		cValue = byteToChar(value)
	)
	C.rocksdb_put_cf(db.c, opts.c, cf.c, cKey, C.size_t(len(key)), cValue, C.size_t(len(value)), &cErr)
	return convertErr(cErr)
}
Example #2
0
// PutCF writes data associated with a key to a column family in the database.
func (self *DB) PutCF(opts *WriteOptions, cf *ColumnFamily, key, value []byte) error {
	cKey := byteToChar(key)
	cValue := byteToChar(value)

	var cErr *C.char
	C.rocksdb_put_cf(self.c, opts.c, cf.c, cKey, C.size_t(len(key)), cValue, C.size_t(len(value)), &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return errors.New(C.GoString(cErr))
	}
	return nil
}