本文整理汇总了C++中WT_SESSION类的典型用法代码示例。如果您正苦于以下问题:C++ WT_SESSION类的具体用法?C++ WT_SESSION怎么用?C++ WT_SESSION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WT_SESSION类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_checkpoints
/*
* Function for repeatedly running checkpoint operations.
*/
static WT_THREAD_RET
do_checkpoints(void *_opts)
{
TEST_OPTS *opts;
WT_SESSION *session;
time_t now, start;
int ret;
opts = (TEST_OPTS *)_opts;
(void)time(&start);
(void)time(&now);
while (difftime(now, start) < RUNTIME) {
testutil_check(
opts->conn->open_session(opts->conn, NULL, NULL, &session));
if ((ret = session->checkpoint(session, "force")) != 0)
if (ret != EBUSY && ret != ENOENT)
testutil_die(ret, "session.checkpoint");
testutil_check(session->close(session, NULL));
/*
* A short sleep to let operations process and avoid back to
* back checkpoints locking up resources.
*/
sleep(1);
(void)time(&now);
}
return (WT_THREAD_RET_VALUE);
}
开发者ID:DINKIN,项目名称:mongo,代码行数:35,代码来源:main.c
示例2: session
Status WiredTigerKVEngine::repairIdent( OperationContext* opCtx,
const StringData& ident ) {
WiredTigerSession session( _conn, -1 );
WT_SESSION* s = session.getSession();
string uri = _uri(ident);
return wtRCToStatus( s->compact(s, uri.c_str(), NULL ) );
}
开发者ID:usharanin26,项目名称:mongo,代码行数:7,代码来源:wiredtiger_kv_engine.cpp
示例3: op_cursor
/*
* 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++;
}
开发者ID:ajdavis,项目名称:mongo,代码行数:37,代码来源:thread.c
示例4: op_bulk
/*
* 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++;
}
开发者ID:ajdavis,项目名称:mongo,代码行数:35,代码来源:thread.c
示例5: newCappedRecordStore
virtual RecordStore* newCappedRecordStore( const std::string& ns,
int64_t cappedMaxSize,
int64_t cappedMaxDocs ) {
WiredTigerRecoveryUnit* ru = new WiredTigerRecoveryUnit( _sessionCache );
OperationContextNoop txn( ru );
string uri = "table:a.b";
CollectionOptions options;
options.capped = true;
StatusWith<std::string> result =
WiredTigerRecordStore::generateCreateString(ns, options, "");
ASSERT_TRUE(result.isOK());
std::string config = result.getValue();
{
WriteUnitOfWork uow(&txn);
WT_SESSION* s = ru->getSession()->getSession();
invariantWTOK( s->create( s, uri.c_str(), config.c_str() ) );
uow.commit();
}
return new WiredTigerRecordStore( &txn, ns, uri, true, cappedMaxSize, cappedMaxDocs );
}
开发者ID:CodeHub2,项目名称:mongo,代码行数:25,代码来源:wiredtiger_record_store_test.cpp
示例6: main
/*! [thread main] */
int
main(void)
{
WT_SESSION *session;
WT_CURSOR *cursor;
pthread_t threads[NUM_THREADS];
int i, ret;
if ((ret = wiredtiger_open(home, NULL,
"create", &conn)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
/* Note: further error checking omitted for clarity. */
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,
"overwrite", &cursor);
cursor->set_key(cursor, "key1");
cursor->set_value(cursor, "value1");
ret = cursor->insert(cursor);
ret = session->close(session, NULL);
for (i = 0; i < NUM_THREADS; i++)
ret = pthread_create(&threads[i], NULL, scan_thread, NULL);
for (i = 0; i < NUM_THREADS; i++)
ret = pthread_join(threads[i], NULL);
ret = conn->close(conn, NULL);
return (ret);
}
开发者ID:zhliu03,项目名称:wiredtiger,代码行数:35,代码来源:ex_thread.c
示例7: obj_bulk
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");
}
开发者ID:DINKIN,项目名称:mongo,代码行数:26,代码来源:file.c
示例8: scan_thread
/*! [thread scan] */
void *
scan_thread(void *conn_arg)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
const char *key, *value;
int ret;
conn = conn_arg;
ret = conn->open_session(conn, NULL, NULL, &session);
ret = session->open_cursor(
session, "table:access", NULL, NULL, &cursor);
/* Show all records. */
while ((ret = cursor->next(cursor)) == 0) {
ret = cursor->get_key(cursor, &key);
ret = cursor->get_value(cursor, &value);
printf("Got record: %s : %s\n", key, value);
}
if (ret != WT_NOTFOUND)
fprintf(stderr,
"WT_CURSOR.next: %s\n", session->strerror(session, ret));
return (NULL);
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:28,代码来源:ex_thread.c
示例9: obj_create_unique
void
obj_create_unique(int force)
{
WT_SESSION *session;
int ret;
char new_uri[64];
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
testutil_die(ret, "conn.session");
/* Generate a unique object name. */
if ((ret = pthread_rwlock_wrlock(&single)) != 0)
testutil_die(ret, "pthread_rwlock_wrlock single");
testutil_check(__wt_snprintf(
new_uri, sizeof(new_uri), "%s.%u", uri, ++uid));
if ((ret = pthread_rwlock_unlock(&single)) != 0)
testutil_die(ret, "pthread_rwlock_unlock single");
if ((ret = session->create(session, new_uri, config)) != 0)
testutil_die(ret, "session.create");
__wt_yield();
while ((ret = session->drop(
session, new_uri, force ? "force" : NULL)) != 0)
if (ret != EBUSY)
testutil_die(ret, "session.drop: %s", new_uri);
if ((ret = session->close(session, NULL)) != 0)
testutil_die(ret, "session.close");
}
开发者ID:DINKIN,项目名称:mongo,代码行数:30,代码来源:file.c
示例10: main
int
main(int argc, char *argv[])
{
WT_SESSION *session;
clock_t ce, cs;
pthread_t idlist[100];
uint64_t i, id;
char buf[100];
opts = &_opts;
memset(opts, 0, sizeof(*opts));
opts->table_type = TABLE_ROW;
opts->n_append_threads = N_APPEND_THREADS;
opts->nrecords = N_RECORDS;
testutil_check(testutil_parse_opts(argc, argv, opts));
testutil_make_work_dir(opts->home);
snprintf(buf, sizeof(buf),
"create,"
"cache_size=%s,"
"eviction=(threads_max=5),"
"statistics=(fast)",
opts->table_type == TABLE_FIX ? "500MB" : "2GB");
testutil_check(wiredtiger_open(opts->home, NULL, buf, &opts->conn));
testutil_check(
opts->conn->open_session(opts->conn, NULL, NULL, &session));
snprintf(buf, sizeof(buf),
"key_format=r,value_format=%s,"
"allocation_size=4K,leaf_page_max=64K",
opts->table_type == TABLE_FIX ? "8t" : "S");
testutil_check(session->create(session, opts->uri, buf));
testutil_check(session->close(session, NULL));
page_init(5000);
/* Force to disk and re-open. */
testutil_check(opts->conn->close(opts->conn, NULL));
testutil_check(wiredtiger_open(opts->home, NULL, NULL, &opts->conn));
(void)signal(SIGINT, onsig);
cs = clock();
id = 0;
for (i = 0; i < opts->n_append_threads; ++i, ++id) {
printf("append: %" PRIu64 "\n", id);
testutil_check(pthread_create(
&idlist[id], NULL, thread_append, (void *)opts));
}
for (i = 0; i < id; ++i)
testutil_check(pthread_join(idlist[i], NULL));
ce = clock();
printf("%" PRIu64 "M records: %.2lf processor seconds\n",
opts->max_inserted_id / MILLION,
(ce - cs) / (double)CLOCKS_PER_SEC);
testutil_cleanup(opts);
return (EXIT_SUCCESS);
}
开发者ID:judahschvimer,项目名称:mongo,代码行数:60,代码来源:main.c
示例11: sweep_stats
static void
sweep_stats(void)
{
static const int list[] = {
WT_STAT_CONN_CURSOR_SWEEP_BUCKETS,
WT_STAT_CONN_CURSOR_SWEEP_CLOSED,
WT_STAT_CONN_CURSOR_SWEEP_EXAMINED,
WT_STAT_CONN_CURSOR_SWEEP,
WT_STAT_CONN_DH_SWEEP_REF,
WT_STAT_CONN_DH_SWEEP_CLOSE,
WT_STAT_CONN_DH_SWEEP_REMOVE,
WT_STAT_CONN_DH_SWEEP_TOD,
WT_STAT_CONN_DH_SWEEPS,
WT_STAT_CONN_DH_SESSION_SWEEPS,
-1
};
WT_SESSION *session;
WT_CURSOR *cursor;
uint64_t value;
int i;
const char *desc, *pvalue;
testutil_check(conn->open_session(conn, NULL, NULL, &session));
testutil_check(session->open_cursor(
session, "statistics:", NULL, NULL, &cursor));
for (i = 0;; ++i) {
if (list[i] == -1)
break;
cursor->set_key(cursor, list[i]);
testutil_check(cursor->search(cursor));
testutil_check(
cursor->get_value(cursor, &desc, &pvalue, &value));
printf("\t" "%s=%s\n", desc, pvalue);
}
}
开发者ID:ajdavis,项目名称:mongo,代码行数:35,代码来源:main.c
示例12: check_copy
/*
* check_copy --
* Confirm the hot backup worked.
*/
static void
check_copy(void)
{
WT_CONNECTION *conn;
WT_SESSION *session;
int ret;
wts_open(RUNDIR_BACKUP, 0, &conn);
/*
* Open a session and verify the store; some data-sources don't support
* verify.
*
* XXX
* LSM can deadlock if WT_SESSION methods are called at the wrong time,
* don't do that for now.
*/
if (!DATASOURCE("lsm") && !DATASOURCE("memrata")) {
if ((ret = conn->open_session(
conn, NULL, NULL, &session)) != 0)
die(ret, "connection.open_session");
if ((ret = session->verify(session, g.uri, NULL)) != 0)
die(ret, "session.verify: %s", g.uri);
}
if ((ret = conn->close(conn, NULL)) != 0)
die(ret, "connection.close: %s", RUNDIR_BACKUP);
}
开发者ID:ckoolkarni,项目名称:wiredtiger,代码行数:33,代码来源:backup.c
示例13: indexInsert
bool indexInsert(size_t indexId, fstring key, llong recId) override {
assert(started == m_status);
assert(indexId < m_indices.size());
WT_ITEM item;
WT_SESSION* ses = m_session.ses;
const Schema& schema = m_sconf.getIndexSchema(indexId);
WT_CURSOR* cur = m_indices[indexId].insert;
WtWritableIndex::setKeyVal(schema, cur, key, recId, &item, &m_wrtBuf);
int err = cur->insert(cur);
m_sizeDiff += sizeof(llong) + key.size();
if (schema.m_isUnique) {
if (WT_DUPLICATE_KEY == err) {
return false;
}
if (err) {
THROW_STD(invalid_argument
, "ERROR: wiredtiger insert unique index: %s", ses->strerror(ses, err));
}
}
else {
if (WT_DUPLICATE_KEY == err) {
assert(0); // assert in debug
return true; // ignore in release
}
if (err) {
THROW_STD(invalid_argument
, "ERROR: wiredtiger insert multi index: %s", ses->strerror(ses, err));
}
}
return true;
}
开发者ID:CovariantStudio,项目名称:terark-db,代码行数:31,代码来源:wt_db_segment.cpp
示例14: find_table_count
/*
* Ensure that icount matches the number of records in the
* existing table.
*/
int find_table_count(CONFIG *cfg)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
char *key;
int ret;
conn = cfg->conn;
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) {
lprintf(cfg, ret, 0,
"open_session failed finding existing table count");
goto err;
}
if ((ret = session->open_cursor(session, cfg->uri,
NULL, NULL, &cursor)) != 0) {
lprintf(cfg, ret, 0,
"open_cursor failed finding existing table count");
goto err;
}
if ((ret = cursor->prev(cursor)) != 0) {
lprintf(cfg, ret, 0,
"cursor prev failed finding existing table count");
goto err;
}
cursor->get_key(cursor, &key);
cfg->icount = (uint32_t)atoi(key);
err: session->close(session, NULL);
return (ret);
}
开发者ID:umerazad,项目名称:wiredtiger,代码行数:36,代码来源:wtperf.c
示例15: page_init
static void
page_init(uint64_t n)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
uint64_t recno, vrecno;
char buf[64];
conn = opts->conn;
testutil_check(conn->open_session(conn, NULL, NULL, &session));
testutil_check(
session->open_cursor(session, opts->uri, NULL, "append", &cursor));
vrecno = 0;
buf[0] = '\2';
for (recno = 1;; ++recno) {
if (opts->table_type == TABLE_FIX)
cursor->set_value(cursor, buf[0]);
else {
if (recno % 3 == 0)
++vrecno;
testutil_check(__wt_snprintf(buf,
sizeof(buf), "%" PRIu64 " VALUE ------", vrecno));
cursor->set_value(cursor, buf);
}
testutil_check(cursor->insert(cursor));
testutil_check(cursor->get_key(cursor, &opts->max_inserted_id));
if (opts->max_inserted_id >= n)
break;
}
}
开发者ID:ajdavis,项目名称:mongo,代码行数:33,代码来源:main.c
示例16: col_remove
/*
* col_remove --
* Remove a row from a column-store file.
*/
static void
col_remove(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno, int *notfoundp)
{
WT_SESSION *session;
int notfound, ret;
session = cursor->session;
/* Log the operation */
if (g.logging == LOG_OPS)
(void)session->msg_printf(
session, "%-10s%" PRIu64, "remove", keyno);
cursor->set_key(cursor, keyno);
ret = cursor->remove(cursor);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "col_remove: remove %" PRIu64 " by key", keyno);
*notfoundp = ret == WT_NOTFOUND;
if (!SINGLETHREADED)
return;
/*
* Deleting a fixed-length item is the same as setting the bits to 0;
* do the same thing for the BDB store.
*/
if (g.c_file_type == FIX) {
key_gen((uint8_t *)key->data, &key->size, keyno, 0);
bdb_update(key->data, key->size, "\0", 1, ¬found);
} else
bdb_remove(keyno, ¬found);
(void)notfound_chk("col_remove", ret, notfound, keyno);
}
开发者ID:qixin,项目名称:wiredtiger,代码行数:38,代码来源:wts_ops.c
示例17: main
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);
}
开发者ID:EaseTech,项目名称:wiredtiger,代码行数:32,代码来源:ex_stat.c
示例18: row_update
/*
* row_update --
* Update a row in a row-store file.
*/
static void
row_update(
WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t keyno, int insert)
{
WT_SESSION *session;
int notfound, ret;
session = cursor->session;
key_gen((uint8_t *)key->data, &key->size, keyno, insert);
value_gen((uint8_t *)value->data, &value->size, keyno);
/* Log the operation */
if (g.logging == LOG_OPS)
(void)session->msg_printf(session, "%-10s{%.*s}\n%-10s{%.*s}",
insert ? "insertK" : "putK",
(int)key->size, (char *)key->data,
insert ? "insertV" : "putV",
(int)value->size, (char *)value->data);
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
ret = cursor->insert(cursor);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret,
"row_update: %s row %" PRIu64 " by key",
insert ? "insert" : "update", keyno);
if (!SINGLETHREADED)
return;
bdb_update(key->data, key->size, value->data, value->size, ¬found);
(void)notfound_chk("row_update", ret, notfound, keyno);
}
开发者ID:qixin,项目名称:wiredtiger,代码行数:38,代码来源:wts_ops.c
示例19: row_remove
/*
* row_remove --
* Remove an row from a row-store file.
*/
static void
row_remove(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno, int *notfoundp)
{
WT_SESSION *session;
int notfound, ret;
session = cursor->session;
key_gen((uint8_t *)key->data, &key->size, keyno, 0);
/* Log the operation */
if (g.logging == LOG_OPS)
(void)session->msg_printf(
session, "%-10s%" PRIu64, "remove", keyno);
cursor->set_key(cursor, key);
ret = cursor->remove(cursor);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "row_remove: remove %" PRIu64 " by key", keyno);
*notfoundp = ret == WT_NOTFOUND;
if (!SINGLETHREADED)
return;
bdb_remove(keyno, ¬found);
(void)notfound_chk("row_remove", ret, notfound, keyno);
}
开发者ID:qixin,项目名称:wiredtiger,代码行数:31,代码来源:wts_ops.c
示例20: wiredtiger_version
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;
}
开发者ID:Abioy,项目名称:ardb,代码行数:33,代码来源:wiredtiger_engine.cpp
注:本文中的WT_SESSION类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论