本文整理汇总了C++中DBC::del方法的典型用法代码示例。如果您正苦于以下问题:C++ DBC::del方法的具体用法?C++ DBC::del怎么用?C++ DBC::del使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBC
的用法示例。
在下文中一共展示了DBC::del方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_impl
/**
@brief
@return true (k1,k2) existed, remove success
false (k1,k2) not existed, nothing done
*/
bool kmapdset_base::remove_impl(const void* k1, const void* k2, DB_TXN* txn, const char* func)
{
PortableDataOutput<AutoGrownMemIO> oKey1, oData;
oData.resize(4*1024);
save_key1(oKey1, k1);
save_key2(oData, k2);
DBT tk1; memset(&tk1, 0, sizeof(DBT)); tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
DBT tdd; memset(&tdd, 0, sizeof(DBT)); tdd.data = oData.begin(); tdd.size = oData.tell();
DBC* curp = NULL;
int ret = m_db->cursor(m_db, txn, &curp, 0);
if (0 == ret)
{
ret = curp->get(curp, &tk1, &tdd, DB_GET_BOTH);
if (0 == ret) {
ret = curp->del(curp, 0);
}
curp->close(curp);
return 0 == ret;
}
else
{
string_appender<> oss;
oss << db_strerror(ret)
<< "... at: " << func
<< "\n"
;
throw std::runtime_error(oss.str());
}
}
示例2: rberkeley_dbcursor_del
/* {{{ rberkeley_dbcursor_del */
SEXP rberkeley_dbcursor_del (SEXP _dbc, SEXP _flags)
{
DBC *dbc;
u_int32_t flags;
int ret;
dbc = R_ExternalPtrAddr(_dbc);
if(R_ExternalPtrTag(_dbc) != install("DBC") || dbc == NULL)
error("invalid 'dbc' handle");
flags = (u_int32_t)INTEGER(_flags)[0];
ret = dbc->del(dbc, flags);
return ScalarInteger(ret);
}
示例3:
static int
kvs_cursor_remove(WT_CURSOR *wtcursor)
{
CURSOR_SOURCE *cursor;
DBC *dbc;
DBT *key, *value;
WT_EXTENSION_API *wt_api;
WT_SESSION *session;
int ret = 0;
session = wtcursor->session;
cursor = (CURSOR_SOURCE *)wtcursor;
wt_api = cursor->wt_api;
dbc = cursor->dbc;
key = &cursor->key;
value = &cursor->value;
/*
* WiredTiger's "remove" of a bitfield is really an update with a value
* of a single byte of zero.
*/
if (cursor->config_bitfield) {
wtcursor->value.size = 1;
wtcursor->value.data = "\0";
return (kvs_cursor_update(wtcursor));
}
if ((ret = copyin_key(wtcursor)) != 0)
return (ret);
if ((ret = dbc->get(dbc, key, value, DB_SET)) != 0) {
if (ret == DB_NOTFOUND || ret == DB_KEYEMPTY)
return (WT_NOTFOUND);
ERET(wt_api,
session, WT_ERROR, "DbCursor.get: %s", db_strerror(ret));
}
if ((ret = dbc->del(dbc, 0)) != 0)
ERET(wt_api,
session, WT_ERROR, "DbCursor.del: %s", db_strerror(ret));
return (0);
}
示例4:
void
bdb_remove(uint64_t keyno, int *notfoundp)
{
DBC *dbc = g.dbc;
int ret;
key.data = keybuf;
key_gen(key.data, &key.size, keyno, 0);
bdb_read(keyno, &value.data, &value.size, notfoundp);
if (*notfoundp)
return;
if ((ret = dbc->del(dbc, 0)) != 0) {
if (ret != DB_NOTFOUND)
die(ret, "dbc.del: {%.*s}",
(int)key.size, (char *)key.data);
*notfoundp = 1;
}
}
示例5: sizeof
void
bdb_zero_database(const char *dbpath, int blacklist)
{
DB *map;
DBC *cursor;
DBT key, data;
int score;
map = _bdb_open_database(dbpath);
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
map->cursor(map, NULL, &cursor, 0);
data.data = &score;
data.ulen = sizeof(int);
data.flags = DB_DBT_USERMEM;
while(cursor->get(cursor, &key, &data, DB_NEXT) == 0) {
if(score != blacklist)
cursor->del(cursor, 0);
}
cursor->close(cursor);
map->close(map, 0);
}
示例6: search
int
jack_remove_properties (jack_client_t* client, jack_uuid_t subject)
{
DBT key;
DBT data;
DBC* cursor;
int ret;
char ustr[JACK_UUID_STRING_SIZE];
int retval = 0;
uint32_t cnt = 0;
jack_uuid_unparse (subject, ustr);
if (jack_property_init (NULL)) {
return -1;
}
if ((ret = db->cursor (db, NULL, &cursor, 0)) != 0) {
jack_error ("Cannot create cursor for metadata search (%s)", db_strerror (ret));
return -1;
}
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
data.flags = DB_DBT_MALLOC;
while ((ret = cursor->get(cursor, &key, &data, DB_NEXT)) == 0) {
/* require 2 extra chars (data+null) for key,
which is composed of UUID str plus a key name
*/
if (key.size < JACK_UUID_STRING_SIZE + 2) {
if (data.size > 0) {
free (data.data);
}
continue;
}
if (memcmp (ustr, key.data, JACK_UUID_STRING_SIZE) != 0) {
/* not relevant */
if (data.size > 0) {
free (data.data);
}
continue;
}
if ((ret = cursor->del (cursor, 0)) != 0) {
jack_error ("cannot delete property (%s)", db_strerror (ret));
/* don't return -1 here since this would leave things
even more inconsistent. wait till the cursor is finished
*/
retval = -1;
}
cnt++;
}
cursor->close (cursor);
if (cnt) {
jack_property_change_notify (client, subject, NULL, PropertyDeleted);
}
if (retval) {
return -1;
}
return cnt;
}
示例7: update_db
/* Internal function to add or remove key/value pairs. When rm is zero,
* the entry will be added; otherwise, it will be removed. Even when
* adding, a matching record will be removed.
*
* The part of the database record to match is found by trimming both the
* provided value and the database value to at most trimlen bytes and
* comparing what remains. Note that this comparison must also match
* in size, so trimming to any size longer than the provided value will
* cause a mismatch if the database value is larger. Negative values
* of trimlen are treated as infinite, and will thus take full records
* into account, including their lengths.
*
* Another comparison trick is the inclusion of the trailing NUL char
* at the end of a PKCS #11 URI or validation expression string.
*
* The array mask4 can be used to indicate flags for the first four bytes,
* which is a big-endian flag value in localid and trust databases.
* When NULL is provided, it will match everything.
*
* The function returns 1 on succes, 0 on failure. Note that it is not
* an error if a record to remove had already gone, or when a matching
* record had to be removed before adding one. This is considered to
* be the result of manual overrides. Failure of this function solely
* refers to issues of a technical nature, such as I/O problems or
* running out of memory.
*
* All operations on the database are excuted within the current
* transaction; the call from api.c has ensured that one exists.
*/
static int update_db (struct pulleyback_tlspool *self,
dercursor *key, dercursor *value,
int trimlen, const uint8_t *mask4,
int rm) {
int ok = 1;
int gotcrs = 0;
int nomore = 1;
DBC *crs;
DBT db_key;
DBT db_val;
DBT db_got;
uint8_t my_mask4 [] = { 0xff, 0xff, 0xff, 0xff };
if (mask4 == NULL) {
// When no mask4 provided, match everything
mask4 = my_mask4;
}
if (trimlen < 0) {
// Standardise on positive values that act as "infinite"
trimlen = value->derlen + 1;
}
gotcrs =
ok = ok && (0 == self->db->cursor (self->db, self->txn, &crs, 0));
memset (&db_key, 0, sizeof (db_key));
db_key.data = key->derptr;
db_key.size = key->derlen;
memset (&db_val, 0, sizeof (db_val));
db_val.data = value->derptr;
db_val.size = value->derlen;
memset (&db_got, 0, sizeof (db_got));
//OLD// dbt_init_fixbuf (&db_key, key ->derptr, key ->derlen);
//OLD// dbt_init_fixbuf (&db_val, value->derptr, value->derlen);
//OLD// dbt_init_empty (&db_got);
nomore = crs->get (crs, &db_key, &db_got, DB_SET);
while (!nomore) {
int match = 1;
int i;
for (i = 0; match && (i < trimlen); i++) {
match = match && (i < db_val.size);
match = match && (i < db_got.size);
if (!match) {
// Final decision; only match for same sizes
match = (db_val.size == db_got.size);
break;
} else {
uint8_t m, a, b;
m = (i < 4)? mask4 [i]: 0xff;
a = m & ((uint8_t *) db_val.data) [i];
b = m & ((uint8_t *) db_got.data) [i];
match = (a == b);
}
}
if (match) {
crs->del (crs, 0);
}
nomore = crs->get (crs, &db_key, &db_got, DB_NEXT_DUP);
}
ok = ok && (nomore == DB_NOTFOUND);
if (gotcrs) {
if (0 != crs->close (crs)) {
fprintf (stderr, "Failed to close cursor\n");
}
}
if (!rm) {
ok = ok && (0 == self->db->put (
self->db, self->txn, &db_key, &db_val, 0));
}
//OLD// // Not ours, so don't free // dbt_free (&db_got);
//OLD// // Static, so don't free // dbt_free (&db_val);
//OLD// // Static, so don't free // dbt_free (&db_key);
return ok;
}