本文整理汇总了C++中WT_CURSOR::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_CURSOR::reserve方法的具体用法?C++ WT_CURSOR::reserve怎么用?C++ WT_CURSOR::reserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_CURSOR
的用法示例。
在下文中一共展示了WT_CURSOR::reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* __curds_reserve --
* WT_CURSOR.reserve method for the data-source cursor type.
*/
static int
__curds_reserve(WT_CURSOR *cursor)
{
WT_CURSOR *source;
WT_DECL_RET;
WT_SESSION_IMPL *session;
source = ((WT_CURSOR_DATA_SOURCE *)cursor)->source;
CURSOR_UPDATE_API_CALL(cursor, session, reserve);
WT_STAT_CONN_INCR(session, cursor_reserve);
WT_STAT_DATA_INCR(session, cursor_reserve);
WT_ERR(__curds_txn_enter(session, true));
WT_ERR(__curds_key_set(cursor));
ret = __curds_cursor_resolve(cursor, source->reserve(source));
err: __curds_txn_leave(session);
CURSOR_UPDATE_API_END(session, ret);
return (ret);
}
示例2: strlen
//.........这里部分代码省略.........
/*! [Insert a new record and fail if the record exists] */
/* Insert a new record and fail if the record exists. */
const char *key = "new key", *value = "some value";
error_check(session->open_cursor(
session, "table:mytable", NULL, "overwrite=false", &cursor));
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
error_check(cursor->insert(cursor));
/*! [Insert a new record and fail if the record exists] */
}
error_check(session->open_cursor(
session, "table:recno", NULL, "append", &cursor));
{
/*! [Insert a new record and assign a record number] */
/* Insert a new record and assign a record number. */
uint64_t recno;
const char *value = "some value";
cursor->set_value(cursor, value);
error_check(cursor->insert(cursor));
error_check(cursor->get_key(cursor, &recno));
/*! [Insert a new record and assign a record number] */
}
error_check(session->open_cursor(
session, "table:mytable", NULL, NULL, &cursor));
{
/*! [Reserve a record] */
const char *key = "some key";
error_check(session->begin_transaction(session, NULL));
cursor->set_key(cursor, key);
error_check(cursor->reserve(cursor));
error_check(session->commit_transaction(session, NULL));
/*! [Reserve a record] */
}
error_check(session->create(
session, "table:blob", "key_format=S,value_format=u"));
error_check(session->open_cursor(
session, "table:blob", NULL, NULL, &cursor));
{
WT_ITEM value;
value.data = "abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz";
value.size = strlen(value.data);
cursor->set_key(cursor, "some key");
cursor->set_value(cursor, &value);
error_check(cursor->insert(cursor));
}
/* Modify requires an explicit transaction. */
error_check(session->begin_transaction(session, NULL));
{
/*! [Modify an existing record] */
WT_MODIFY entries[3];
const char *key = "some key";
/* Position the cursor. */
cursor->set_key(cursor, key);
error_check(cursor->search(cursor));
/* Replace 20 bytes starting at byte offset 5. */
entries[0].data.data = "some data";