本文整理汇总了C++中WT_CURSOR::modify方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_CURSOR::modify方法的具体用法?C++ WT_CURSOR::modify怎么用?C++ WT_CURSOR::modify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_CURSOR
的用法示例。
在下文中一共展示了WT_CURSOR::modify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
//.........这里部分代码省略.........
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";
entries[0].data.size = strlen(entries[0].data.data);
entries[0].offset = 5;
entries[0].size = 20;
/* Insert data at byte offset 40. */
entries[1].data.data = "and more data";
entries[1].data.size = strlen(entries[1].data.data);
entries[1].offset = 40;
entries[1].size = 0;
/* Replace 2 bytes starting at byte offset 10. */
entries[2].data.data = "and more data";
entries[2].data.size = strlen(entries[2].data.data);
entries[2].offset = 10;
entries[2].size = 2;
error_check(cursor->modify(cursor, entries, 3));
/*! [Modify an existing record] */
}
error_check(session->commit_transaction(session, NULL));
{
/*! [Update an existing record or insert a new record] */
const char *key = "some key", *value = "some value";
error_check(session->open_cursor(
session, "table:mytable", NULL, NULL, &cursor));
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
error_check(cursor->update(cursor));
/*! [Update an existing record or insert a new record] */
}
{
/*! [Update an existing record and fail if DNE] */
const char *key = "some 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->update(cursor));
/*! [Update an existing record and fail if DNE] */
}
{
/*! [Remove a record and fail if DNE] */
const char *key = "some key";
error_check(session->open_cursor(
session, "table:mytable", NULL, "overwrite=false", &cursor));
cursor->set_key(cursor, key);