本文整理汇总了C++中WT_CURSOR::close方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_CURSOR::close方法的具体用法?C++ WT_CURSOR::close怎么用?C++ WT_CURSOR::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_CURSOR
的用法示例。
在下文中一共展示了WT_CURSOR::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const std::string WiredTigerEngine::Stats()
{
std::string info;
int major_v, minor_v, patch;
(void) wiredtiger_version(&major_v, &minor_v, &patch);
info.append("WiredTiger version:").append(stringfromll(major_v)).append(".").append(stringfromll(minor_v)).append(
".").append(stringfromll(patch)).append("\r\n");
info.append("WiredTiger Init Options:").append(m_cfg.init_options).append("\r\n");
info.append("WiredTiger Table Init Options:").append(m_cfg.init_table_options).append("\r\n");
ContextHolder& holder = m_context.GetValue();
WT_SESSION* session = holder.session;
if (NULL == session)
{
return info;
}
WT_CURSOR *cursor;
int ret;
/*! [statistics database function] */
if ((ret = session->open_cursor(session, "statistics:", NULL, NULL, &cursor)) == 0)
{
print_cursor(cursor, info);
cursor->close(cursor);
}
if ((ret = session->open_cursor(session, "statistics:table:ardb", NULL, NULL, &cursor)) == 0)
{
print_cursor(cursor, info);
cursor->close(cursor);
}
return info;
}
示例2:
/*
* wts_stats --
* Dump the run's statistics.
*/
void
wts_stats(void)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
FILE *fp;
const char *pval, *desc;
uint64_t v;
int ret;
track("stat", 0ULL, NULL);
conn = g.wts_conn;
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
die(ret, "connection.open_session");
if ((fp = fopen("__stats", "w")) == NULL)
die(errno, "fopen: __stats");
/* Connection statistics. */
if ((ret = session->open_cursor(session,
"statistics:", NULL, NULL, &cursor)) != 0)
die(ret, "session.open_cursor");
while ((ret = cursor->next(cursor)) == 0 &&
(ret = cursor->get_value(cursor, &desc, &pval, &v)) == 0)
if (fprintf(fp, "%s=%s\n", desc, pval) < 0)
die(errno, "fprintf");
if (ret != WT_NOTFOUND)
die(ret, "cursor.next");
if ((ret = cursor->close(cursor)) != 0)
die(ret, "cursor.close");
/* File statistics. */
if ((ret = session->open_cursor(session,
"statistics:" WT_TABLENAME, NULL, NULL, &cursor)) != 0)
die(ret, "session.open_cursor");
while ((ret = cursor->next(cursor)) == 0 &&
(ret = cursor->get_value(cursor, &desc, &pval, &v)) == 0)
if (fprintf(fp, "%s=%s\n", desc, pval) < 0)
die(errno, "fprintf");
if (ret != WT_NOTFOUND)
die(ret, "cursor.next");
if ((ret = cursor->close(cursor)) != 0)
die(ret, "cursor.close");
if ((ret = fclose(fp)) != 0)
die(ret, "fclose");
if ((ret = session->close(session, NULL)) != 0)
die(ret, "session.close");
}
示例3:
/*
* __curds_close --
* WT_CURSOR.close method for the data-source cursor type.
*/
static int
__curds_close(WT_CURSOR *cursor)
{
WT_CURSOR *source;
WT_DECL_RET;
WT_SESSION_IMPL *session;
source = ((WT_CURSOR_DATA_SOURCE *)cursor)->source;
CURSOR_API_CALL(cursor, session, close, NULL);
if (source != NULL)
ret = source->close(source);
/*
* The key/value formats are in allocated memory, which isn't standard
* behavior.
*/
__wt_free(session, cursor->key_format);
__wt_free(session, cursor->value_format);
WT_TRET(__wt_cursor_close(cursor));
err: API_END_RET(session, ret);
}
示例4:
/*
* simple_walk_log --
* A simple walk of the write-ahead log.
* We wrote text messages into the log. Print them.
* This verifies we're decrypting properly.
*/
static void
simple_walk_log(WT_SESSION *session)
{
WT_CURSOR *cursor;
WT_ITEM logrec_key, logrec_value;
uint64_t txnid;
uint32_t fileid, log_file, log_offset, opcount, optype, rectype;
int found, ret;
error_check(session->open_cursor(session, "log:", NULL, NULL, &cursor));
found = 0;
while ((ret = cursor->next(cursor)) == 0) {
error_check(cursor->get_key(
cursor, &log_file, &log_offset, &opcount));
error_check(cursor->get_value(cursor, &txnid,
&rectype, &optype, &fileid, &logrec_key, &logrec_value));
if (rectype == WT_LOGREC_MESSAGE) {
found = 1;
printf("Application Log Record: %s\n",
(char *)logrec_value.data);
}
}
scan_end_check(ret == WT_NOTFOUND);
error_check(cursor->close(cursor));
if (found == 0) {
fprintf(stderr, "Did not find log messages.\n");
exit(EXIT_FAILURE);
}
}
示例5:
/*
* Open and close cursor on a table.
*/
void
op_cursor(void *arg)
{
TEST_OPTS *opts;
TEST_PER_THREAD_OPTS *args;
WT_CURSOR *cursor;
WT_SESSION *session;
int i, ret;
args = (TEST_PER_THREAD_OPTS *)arg;
opts = args->testopts;
testutil_check(
opts->conn->open_session(opts->conn, NULL, NULL, &session));
if ((ret = session->open_cursor(
session, opts->uri, NULL, NULL, &cursor)) != 0) {
if (ret != ENOENT && ret != EBUSY)
testutil_die(ret, "session.open_cursor");
} else {
/* Put some data in if asked to. */
if (args->testopts->do_data_ops) {
for (i = 0; i < 1000; i++) {
cursor->set_key(cursor, i);
cursor->set_value(cursor, "abcdef");
cursor->insert(cursor);
}
}
testutil_check(cursor->close(cursor));
}
testutil_check(session->close(session, NULL));
args->thread_counter++;
}
示例6:
/*
* simple_walk_log --
* A simple walk of the log.
*/
static int
simple_walk_log(WT_SESSION *session)
{
WT_CURSOR *cursor;
WT_LSN lsn;
WT_ITEM logrec_key, logrec_value;
uint64_t txnid;
uint32_t fileid, opcount, optype, rectype;
int ret;
/*! [log cursor open] */
ret = session->open_cursor(session, "log:", NULL, NULL, &cursor);
/*! [log cursor open] */
while ((ret = cursor->next(cursor)) == 0) {
/*! [log cursor get_key] */
ret = cursor->get_key(cursor, &lsn.file, &lsn.offset, &opcount);
/*! [log cursor get_key] */
/*! [log cursor get_value] */
ret = cursor->get_value(cursor, &txnid,
&rectype, &optype, &fileid, &logrec_key, &logrec_value);
/*! [log cursor get_value] */
print_record(&lsn, opcount,
rectype, optype, txnid, fileid, &logrec_key, &logrec_value);
}
if (ret == WT_NOTFOUND)
ret = 0;
ret = cursor->close(cursor);
return (ret);
}
示例7:
/*
* __wt_metadata_search --
* Return a copied row from the metadata.
* The caller is responsible for freeing the allocated memory.
*/
int
__wt_metadata_search(
WT_SESSION_IMPL *session, const char *key, char **valuep)
{
WT_CURSOR *cursor;
WT_DECL_RET;
const char *value;
*valuep = NULL;
WT_RET(__wt_verbose(session, WT_VERB_METADATA,
"Search: key: %s, tracking: %s, %s" "turtle",
key, WT_META_TRACKING(session) ? "true" : "false",
__metadata_turtle(key) ? "" : "not "));
if (__metadata_turtle(key))
return (__wt_turtle_read(session, key, valuep));
WT_RET(__wt_metadata_cursor(session, NULL, &cursor));
cursor->set_key(cursor, key);
WT_ERR(cursor->search(cursor));
WT_ERR(cursor->get_value(cursor, &value));
WT_ERR(__wt_strdup(session, value, valuep));
err: WT_TRET(cursor->close(cursor));
return (ret);
}
示例8: Get
int WiredTigerEngine::Get(const Slice& key, std::string* value, const Options& options)
{
WT_SESSION* session = GetContextHolder().session;
if (NULL == session)
{
return -1;
}
WT_CURSOR *cursor = create_wiredtiger_cursor(session);
if (NULL == cursor)
{
return -1;
}
WT_ITEM key_item, value_item;
key_item.data = key.data();
key_item.size = key.size();
cursor->set_key(cursor, &key_item);
int ret = 0;
if ((ret = cursor->search(cursor)) == 0)
{
ret = cursor->get_value(cursor, &value_item);
if (0 == ret)
{
if (NULL != value)
{
value->assign((const char*) value_item.data, value_item.size);
}
}
else
{
CHECK_WT_RETURN(ret);
}
}
cursor->close(cursor);
return ret;
}
示例9: fetchStats
void WiredTigerOperationStats::fetchStats(WT_SESSION* session,
const std::string& uri,
const std::string& config) {
invariant(session);
WT_CURSOR* c = nullptr;
const char* cursorConfig = config.empty() ? nullptr : config.c_str();
int ret = session->open_cursor(session, uri.c_str(), nullptr, cursorConfig, &c);
uassert(ErrorCodes::CursorNotFound, "Unable to open statistics cursor", ret == 0);
invariant(c);
ON_BLOCK_EXIT([&] { c->close(c); });
const char* desc;
uint64_t value;
uint64_t key;
while (c->next(c) == 0 && c->get_key(c, &key) == 0) {
fassert(51035, c->get_value(c, &desc, nullptr, &value) == 0);
#if defined(__s390x__)
_stats[key >> 32] = WiredTigerUtil::castStatisticsValue<long long>(value);
#else
_stats[key] = WiredTigerUtil::castStatisticsValue<long long>(value);
#endif // __s390x__
}
// Reset the statistics so that the next fetch gives the recent values.
invariantWTOK(c->reset(c));
}
示例10:
int
main(void)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
int ret;
ret = wiredtiger_open(home, NULL, "create,statistics=(all)", &conn);
ret = conn->open_session(conn, NULL, NULL, &session);
ret = session->create(
session, "table:access", "key_format=S,value_format=S");
ret = session->open_cursor(
session, "table:access", NULL, NULL, &cursor);
cursor->set_key(cursor, "key");
cursor->set_value(cursor, "value");
ret = cursor->insert(cursor);
cursor->close(cursor);
ret = session->checkpoint(session, NULL);
ret = print_database_stats(session);
ret = print_file_stats(session);
ret = print_overflow_pages(session);
ret = print_derived_stats(session);
return (conn->close(conn, NULL) == 0 ? ret : EXIT_FAILURE);
}
示例11: wt_id2entry_delete
int wt_id2entry_delete(
Operation *op,
WT_SESSION *session,
Entry *e )
{
int rc;
WT_CURSOR *cursor = NULL;
rc = session->open_cursor(session, WT_TABLE_ID2ENTRY, NULL,
NULL, &cursor);
if ( rc ) {
Debug( LDAP_DEBUG_ANY,
LDAP_XSTRING(wt_id2entry_delete)
": open_cursor failed: %s (%d)\n",
wiredtiger_strerror(rc), rc, 0 );
goto done;
}
cursor->set_key(cursor, e->e_id);
rc = cursor->remove(cursor);
if ( rc ) {
Debug( LDAP_DEBUG_ANY,
LDAP_XSTRING(wt_id2entry_delete)
": remove failed: %s (%d)\n",
wiredtiger_strerror(rc), rc, 0 );
goto done;
}
done:
if(cursor){
cursor->close(cursor);
}
return rc;
}
示例12:
/*
* __clsm_close_cursors --
* Close any btree cursors that are not needed.
*/
static int
__clsm_close_cursors(WT_CURSOR_LSM *clsm, u_int start, u_int end)
{
WT_BLOOM *bloom;
WT_CURSOR *c;
u_int i;
if (clsm->cursors == NULL || clsm->nchunks == 0)
return (0);
/*
* Walk the cursors, closing any we don't need. Note that the exit
* condition here is special, don't use WT_FORALL_CURSORS, and be
* careful with unsigned integer wrapping.
*/
for (i = start; i < end; i++) {
if ((c = (clsm)->cursors[i]) != NULL) {
clsm->cursors[i] = NULL;
WT_RET(c->close(c));
}
if ((bloom = clsm->blooms[i]) != NULL) {
clsm->blooms[i] = NULL;
WT_RET(__wt_bloom_close(bloom));
}
}
return (0);
}
示例13: if
/*
* Create a table and open a bulk cursor on it.
*/
void
op_bulk(void *arg)
{
TEST_OPTS *opts;
TEST_PER_THREAD_OPTS *args;
WT_CURSOR *c;
WT_SESSION *session;
int ret;
args = (TEST_PER_THREAD_OPTS *)arg;
opts = args->testopts;
testutil_check(
opts->conn->open_session(opts->conn, NULL, NULL, &session));
if ((ret = session->create(session,
opts->uri, DEFAULT_TABLE_SCHEMA)) != 0)
if (ret != EEXIST && ret != EBUSY)
testutil_die(ret, "session.create");
if (ret == 0) {
__wt_yield();
if ((ret = session->open_cursor(session,
opts->uri, NULL, "bulk,checkpoint_wait=false", &c)) == 0) {
testutil_check(c->close(c));
} else if (ret != ENOENT && ret != EBUSY && ret != EINVAL)
testutil_die(ret, "session.open_cursor bulk");
}
testutil_check(session->close(session, NULL));
args->thread_counter++;
}
示例14: if
void
obj_bulk(void)
{
WT_CURSOR *c;
WT_SESSION *session;
int ret;
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
testutil_die(ret, "conn.session");
if ((ret = session->create(session, uri, config)) != 0)
if (ret != EEXIST && ret != EBUSY)
testutil_die(ret, "session.create");
if (ret == 0) {
__wt_yield();
if ((ret = session->open_cursor(
session, uri, NULL, "bulk", &c)) == 0) {
if ((ret = c->close(c)) != 0)
testutil_die(ret, "cursor.close");
} else if (ret != ENOENT && ret != EBUSY && ret != EINVAL)
testutil_die(ret, "session.open_cursor bulk");
}
if ((ret = session->close(session, NULL)) != 0)
testutil_die(ret, "session.close");
}
示例15:
static void
write_and_read_new(WT_SESSION *session)
{
WT_CURSOR *logc;
WT_ITEM logrec_key, logrec_value;
uint64_t txnid;
uint32_t fileid, log_file, log_offset, opcount, optype, rectype;
bool saw_msg;
/*
* Write a log record and force it to disk so we can read it.
*/
printf("Write log_printf record and verify.\n");
testutil_check(session->log_printf(session, "Test Log Record"));
testutil_check(session->log_flush(session, "sync=on"));
testutil_check(
session->open_cursor(session, "log:", NULL, NULL, &logc));
testutil_check(
session->open_cursor(session, "log:", NULL, NULL, &logc));
saw_msg = false;
while (logc->next(logc) == 0) {
/*
* We don't really need to get the key, but in case we want
* the LSN for some message, get it.
*/
testutil_check(logc->get_key(
logc, &log_file, &log_offset, &opcount));
testutil_check(logc->get_value(logc, &txnid,
&rectype, &optype, &fileid, &logrec_key, &logrec_value));
/*
* We should never see a record from us in log file 2. We wrote
* a record there, but then the record in log file 1 was
* truncated to be a partial record, ending the log there.
* So everything after that, including everything in log
* file 2, is invalid until we get to log file 3 which is where
* the post-recovery records will be written.
* The one exception in log file two is the system record for
* the previous log file's LSN. Although it is written by the
* system, we do walk it when using a cursor.
*/
if (log_file == 2 && rectype != WT_LOGREC_SYSTEM)
testutil_die(EINVAL, "Found LSN in Log 2");
#if 0
printf("LSN [%" PRIu32 "][%" PRIu32 "].%" PRIu32
": record type %" PRIu32 " optype %" PRIu32
" txnid %" PRIu64 " fileid %" PRIu32 "\n",
log_file, log_offset, opcount,
rectype, optype, txnid, fileid);
#endif
if (rectype == WT_LOGREC_MESSAGE) {
saw_msg = true;
printf("Application Record: %s\n",
(char *)logrec_value.data);
break;
}
}
testutil_check(logc->close(logc));
if (!saw_msg)
testutil_die(EINVAL, "Did not traverse log printf record");
}