示例#1
0
文件: db.go 项目: daaku/gorocksdb
// Delete removes the data associated with the key from the database.
func (db *DB) Delete(opts *WriteOptions, key []byte) error {
	var (
		cErr *C.char
		cKey = byteToChar(key)
	)
	C.rocksdb_delete(db.c, opts.c, cKey, C.size_t(len(key)), &cErr)
	return convertErr(cErr)
}
示例#2
0
文件: db.go 项目: C0rWin/fabric
// Delete removes the data associated with the key from the database.
func (db *DB) Delete(opts *WriteOptions, key []byte) error {
	var (
		cErr *C.char
		cKey = byteToChar(key)
	)
	C.rocksdb_delete(db.c, opts.c, cKey, C.size_t(len(key)), &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return errors.New(C.GoString(cErr))
	}
	return nil
}
示例#3
0
// del removes the item from the db with the given key.
func (r *RocksDB) del(key Key) error {
	var cErr *C.char
	C.rocksdb_delete(
		r.rdb,
		r.wOpts,
		(*C.char)(unsafe.Pointer(&key[0])),
		C.size_t(len(key)),
		&cErr)

	if cErr != nil {
		return charToErr(cErr)
	}
	return nil
}
示例#4
0
文件: db.go 项目: malloc-fi/vantaa
func (db *DB) delete(wo *WriteOptions, key []byte) error {
	var errStr *C.char
	var k *C.char
	if len(key) != 0 {
		k = (*C.char)(unsafe.Pointer(&key[0]))
	}

	C.rocksdb_delete(
		db.db, wo.Opt, k, C.size_t(len(key)), &errStr)

	if errStr != nil {
		return saveError(errStr)
	}
	return nil
}
示例#5
0
文件: db.go 项目: tradia/gotable
func (db *DB) Del(rawKey []byte, wb *WriteBatch) error {
	var ck = (*C.char)(unsafe.Pointer(&rawKey[0]))

	if wb == nil {
		var errStr *C.char
		C.rocksdb_delete(db.db, db.wOpt, ck, C.size_t(len(rawKey)), &errStr)
		if errStr != nil {
			defer C.free(unsafe.Pointer(errStr))
			return errors.New(C.GoString(errStr))
		}
	} else {
		C.rocksdb_writebatch_delete(wb.batch, ck, C.size_t(len(rawKey)))
	}

	return nil
}
示例#6
0
// Clear removes the item from the db with the given key.
func (r *RocksDB) Clear(key Key) error {
	if len(key) == 0 {
		return emptyKeyError()
	}
	var cErr *C.char
	C.rocksdb_delete(
		r.rdb,
		r.wOpts,
		bytesPointer(key),
		C.size_t(len(key)),
		&cErr)

	if cErr != nil {
		return charToErr(cErr)
	}
	return nil
}
示例#7
0
文件: db.go 项目: cayleydb/dgraph
// Delete removes the data associated with the key from the database.
//
// The key byte slice may be reused safely. Delete takes a copy of
// them before returning.
func (db *DB) Delete(wo *WriteOptions, key []byte) error {
	var errStr *C.char
	var k *C.char
	if len(key) != 0 {
		k = (*C.char)(unsafe.Pointer(&key[0]))
	}

	C.rocksdb_delete(
		db.Ldb, wo.Opt, k, C.size_t(len(key)), &errStr)

	if errStr != nil {
		gs := C.GoString(errStr)
		C.free(unsafe.Pointer(errStr))
		return DatabaseError(gs)
	}
	return nil
}