예제 #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
}