本文整理汇总了C++中WT_CONNECTION类的典型用法代码示例。如果您正苦于以下问题:C++ WT_CONNECTION类的具体用法?C++ WT_CONNECTION怎么用?C++ WT_CONNECTION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WT_CONNECTION类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setup
void
setup(void)
{
WT_CONNECTION *conn;
WT_SESSION *session;
int ret;
char config[512];
if ((ret = system("rm -f WiredTiger* *.bf")) != 0)
testutil_die(ret, "system cleanup call failed");
/*
* This test doesn't test public Wired Tiger functionality, it still
* needs connection and session handles.
*/
/*
* Open configuration -- put command line configuration options at the
* end so they can override "standard" configuration.
*/
snprintf(config, sizeof(config),
"create,error_prefix=\"%s\",cache_size=%" PRIu32 "MB,%s",
g.progname, g.c_cache, g.config_open == NULL ? "" : g.config_open);
testutil_check(wiredtiger_open(NULL, NULL, config, &conn));
testutil_check(conn->open_session(conn, NULL, NULL, &session));
g.wt_conn = conn;
g.wt_session = session;
populate_entries();
}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:32,代码来源:test_bloom.c
示例2: 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
示例3: main
int
main(int argc, char *argv[])
{
WT_CONNECTION *conn;
int ret;
(void)argc; /* Unused variable */
/*
* This code deliberately doesn't use the standard test_util macros,
* we don't want to link against that code to smoke-test a build.
*/
(void)system("rm -rf WT_HOME && mkdir WT_HOME");
/* Open a connection to the database, creating it if necessary. */
if ((ret = wiredtiger_open("WT_HOME", NULL, "create", &conn)) != 0) {
fprintf(stderr,
"%s: wiredtiger_open: %s\n",
argv[0], wiredtiger_strerror(ret));
return (EXIT_FAILURE);
}
/* Close the connection to the database. */
if ((ret = conn->close(conn, NULL)) != 0) {
fprintf(stderr,
"%s: WT_CONNECTION.close: %s\n",
argv[0], wiredtiger_strerror(ret));
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
开发者ID:DINKIN,项目名称:mongo,代码行数:32,代码来源:ex_smoke.c
示例4: main
int main(void)
{
int ret;
WT_CONNECTION *conn;
WT_SESSION *session;
/*! [processes] */
/* Open a connection to the database, creating it if necessary. */
if ((ret =
wiredtiger_open(home, NULL, "create,multiprocess", &conn)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
/* Open a session for the current thread's work. */
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
fprintf(stderr, "Error opening a session on %s: %s\n",
home, wiredtiger_strerror(ret));
/* XXX Do some work... */
/* Note: closing the connection implicitly closes open session(s). */
if ((ret = conn->close(conn, NULL)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
/*! [processes] */
return (ret);
}
开发者ID:qixin,项目名称:wiredtiger,代码行数:28,代码来源:ex_process.c
示例5: config_event_handler
static int
config_event_handler(void)
{
WT_CONNECTION *conn;
WT_SESSION *session;
int ret;
/*! [Configure event_handler] */
CUSTOM_EVENT_HANDLER event_handler;
event_handler.h.handle_error = handle_wiredtiger_error;
event_handler.h.handle_message = handle_wiredtiger_message;
/* Set handlers to NULL to use the default handler. */
event_handler.h.handle_progress = NULL;
event_handler.h.handle_close = NULL;
event_handler.app_id = "example_event_handler";
ret = wiredtiger_open(home,
(WT_EVENT_HANDLER *)&event_handler, "create", &conn);
/*! [Configure event_handler] */
/* Make an invalid API call, to ensure the event handler works. */
printf("ex_event_handler: expect an error message to follow\n");
ret = conn->open_session(conn, NULL, "isolation=invalid", &session);
ret = conn->close(conn, NULL);
return (ret);
}
开发者ID:Machyne,项目名称:mongo,代码行数:29,代码来源:ex_event_handler.c
示例6: main
int
main(void)
{
int ret;
{
/*! [Open a connection] */
WT_CONNECTION *conn;
const char *home = "WT_TEST";
ret = wiredtiger_open(home, NULL, "create,transactional", &conn);
/*! [Open a connection] */
(void)conn->close(conn, NULL);
}
/*! [Get the WiredTiger library version #1] */
printf("WiredTiger version %s\n", wiredtiger_version(NULL, NULL, NULL));
/*! [Get the WiredTiger library version #1] */
{
/*! [Get the WiredTiger library version #2] */
int major, minor, patch;
(void)wiredtiger_version(&major, &minor, &patch);
printf("WiredTiger version is %d, %d (patch %d)\n",
major, minor, patch);
/*! [Get the WiredTiger library version #2] */
}
return (ret);
}
开发者ID:zhliu03,项目名称:wiredtiger,代码行数:30,代码来源:ex_all.c
示例7: 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
示例8: 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
示例9: wts_salvage
void
wts_salvage(void)
{
WT_CONNECTION *conn;
WT_SESSION *session;
int ret;
conn = g.wts_conn;
track("salvage", 0ULL, NULL);
/*
* Save a copy of the interesting files so we can replay the salvage
* step as necessary.
*/
if ((ret = system(
"cd RUNDIR && "
"rm -rf slvg.copy && "
"mkdir slvg.copy && "
"cp WiredTiger* wt* slvg.copy/")) != 0)
die(ret, "salvage copy step failed");
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
die(ret, "connection.open_session");
if ((ret = session->salvage(session, g.uri, NULL)) != 0)
die(ret, "session.salvage: %s", g.uri);
if ((ret = session->close(session, NULL)) != 0)
die(ret, "session.close");
}
开发者ID:zhliu03,项目名称:wiredtiger,代码行数:29,代码来源:wts.c
示例10: 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
示例11: 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
示例12: wts_stats
/*
* 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");
}
开发者ID:qixin,项目名称:wiredtiger,代码行数:60,代码来源:wts.c
示例13: main
int
main(void)
{
WT_CONNECTION *conn;
WT_SESSION *session;
int i, j, k, ret;
/*
* Create a clean test directory for this run of the test program if the
* environment variable isn't already set (as is done by make check).
*/
if (getenv("WIREDTIGER_HOME") == NULL) {
home = "WT_HOME";
ret = system("rm -rf WT_HOME && mkdir WT_HOME");
} else
home = NULL;
/* Open a connection to the database, creating it if necessary. */
if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0) {
fprintf(stderr, "Error connecting to %s: %s\n",
home == NULL ? "." : home, wiredtiger_strerror(ret));
return (EXIT_FAILURE);
}
/* Open a session for the current thread's work. */
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) {
fprintf(stderr, "Error opening a session on %s: %s\n",
home == NULL ? "." : home, wiredtiger_strerror(ret));
return (EXIT_FAILURE);
}
{
/*! [packing] */
size_t size;
char buf[50];
ret = wiredtiger_struct_size(session, &size, "iii", 42, 1000, -9);
if (size > sizeof(buf)) {
/* Allocate a bigger buffer. */
}
ret = wiredtiger_struct_pack(session, buf, size, "iii", 42, 1000, -9);
ret = wiredtiger_struct_unpack(session, buf, size, "iii", &i, &j, &k);
/*! [packing] */
}
/* Note: closing the connection implicitly closes open session(s). */
if ((ret = conn->close(conn, NULL)) != 0) {
fprintf(stderr, "Error closing %s: %s\n",
home == NULL ? "." : home, wiredtiger_strerror(ret));
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:56,代码来源:ex_pack.c
示例14: main
int
main(int argc, char *argv[])
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
home = example_setup(argc, argv);
/* Open a connection to the database, creating it if necessary. */
error_check(wiredtiger_open(
home, NULL, "create,statistics=(fast)", &conn));
/* Open a session for the current thread's work. */
error_check(conn->open_session(conn, NULL, NULL, &session));
error_check(session->create(session, "table:world",
"key_format=r,value_format=5sii,"
"columns=(id,country,population,area)"));
/*! [open cursor #1] */
error_check(session->open_cursor(
session, "table:world", NULL, NULL, &cursor));
/*! [open cursor #1] */
/*! [open cursor #2] */
error_check(session->open_cursor(session,
"table:world(country,population)", NULL, NULL, &cursor));
/*! [open cursor #2] */
/*! [open cursor #3] */
error_check(session->open_cursor(
session, "statistics:", NULL, NULL, &cursor));
/*! [open cursor #3] */
/* Create a simple string table to illustrate basic operations. */
error_check(session->create(
session, "table:map", "key_format=S,value_format=S"));
error_check(session->open_cursor(
session, "table:map", NULL, NULL, &cursor));
error_check(cursor_insert(cursor));
error_check(cursor_reset(cursor));
error_check(cursor_forward_scan(cursor));
error_check(cursor_reset(cursor));
error_check(cursor_reverse_scan(cursor));
error_check(cursor_search_near(cursor));
error_check(cursor_update(cursor));
error_check(cursor_remove(cursor));
error_check(cursor->close(cursor));
/* Note: closing the connection implicitly closes open session(s). */
error_check(conn->close(conn, NULL));
return (EXIT_SUCCESS);
}
开发者ID:DINKIN,项目名称:mongo,代码行数:55,代码来源:ex_cursor.c
示例15: wts_close
void
wts_close()
{
WT_CONNECTION *conn;
int ret;
conn = g.wts_conn;
if ((ret = conn->close(conn, NULL)) != 0)
die(ret, "connection.close");
}
开发者ID:zhliu03,项目名称:wiredtiger,代码行数:11,代码来源:wts.c
示例16: main
int main(void)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
int ret;
/* Open a connection to the database, creating it if necessary. */
if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
/* Open a session for the current thread's work. */
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
fprintf(stderr, "Error opening a session on %s: %s\n",
home, wiredtiger_strerror(ret));
ret = session->create(session, "table:world",
"key_format=r,value_format=5sii,"
"columns=(id,country,population,area)");
/*! [open cursor #1] */
ret = session->open_cursor(session, "table:world", NULL, NULL, &cursor);
/*! [open cursor #1] */
/*! [open cursor #2] */
ret = session->open_cursor(session,
"table:world(country,population)", NULL, NULL, &cursor);
/*! [open cursor #2] */
/*! [open cursor #3] */
ret = session->open_cursor(session, "statistics:", NULL, NULL, &cursor);
/*! [open cursor #3] */
/* Create a simple string table to illustrate basic operations. */
ret = session->create(session, "table:map",
"key_format=S,value_format=S");
ret = session->open_cursor(session, "table:map", NULL, NULL, &cursor);
ret = cursor_insert(cursor);
ret = cursor_reset(cursor);
ret = cursor_forward_scan(cursor);
ret = cursor_reset(cursor);
ret = cursor_reverse_scan(cursor);
ret = cursor_update(cursor);
ret = cursor_remove(cursor);
ret = cursor->close(cursor);
/* Note: closing the connection implicitly closes open session(s). */
if ((ret = conn->close(conn, NULL)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
return (ret);
}
开发者ID:zhliu03,项目名称:wiredtiger,代码行数:54,代码来源:ex_cursor.c
示例17: salvage
/*
* salvage --
* A single salvage.
*/
static void
salvage(void)
{
WT_CONNECTION *conn;
WT_SESSION *session;
conn = g.wts_conn;
track("salvage", 0ULL, NULL);
testutil_check(conn->open_session(conn, NULL, NULL, &session));
testutil_check(session->salvage(session, g.uri, "force=true"));
testutil_check(session->close(session, NULL));
}
开发者ID:wiredtiger,项目名称:wiredtiger,代码行数:17,代码来源:salvage.c
示例18: main
int
main(int argc, char *argv[])
{
int ret;
WT_CONNECTION *conn;
WT_SESSION *session;
(void)argc;
(void)argv;
fprintf(stderr, SEPARATOR "wiredtiger_open\n");
if ((ret = wiredtiger_open(".", NULL, "create", &conn)) != 0)
fail(ret);
usleep(100);
fflush(stderr);
fprintf(stderr, SEPARATOR "open_session\n");
fflush(stderr);
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
fail(ret);
usleep(100);
fflush(stderr);
fprintf(stderr, SEPARATOR "create\n");
fflush(stderr);
if ((ret = session->create(
session, "table:hello", "key_format=S,value_format=S")) != 0)
fail(ret);
usleep(100);
fprintf(stderr, SEPARATOR "rename\n");
if ((ret = session->rename(
session, "table:hello", "table:world", NULL)) != 0)
fail(ret);
fflush(stdout);
fprintf(stderr, SEPARATOR "drop\n");
fflush(stdout);
if ((ret = session->drop(session, "table:world", NULL)) != 0)
fail(ret);
fprintf(stderr, SEPARATOR "WT_CONNECTION::close\n");
if ((ret = conn->close(conn, NULL)) != 0)
fail(ret);
return (0);
}
开发者ID:ksuarz,项目名称:mongo,代码行数:51,代码来源:main.c
示例19: wiredtiger_extension_init
int
wiredtiger_extension_init(
WT_SESSION *session, WT_EXTENSION_API *api, const char *config)
{
WT_CONNECTION *conn;
__UNUSED(config);
wt_api = api;
conn = session->connection;
return (conn->add_compressor(
conn, "snappy_compress", &wt_snappy_compressor, NULL));
}
开发者ID:zinuyasha,项目名称:wiredtiger,代码行数:14,代码来源:snappy_compress.c
示例20: run_child
static int
run_child(const char *homedir, int op, int expect)
{
WT_CONNECTION *conn;
WT_CURSOR *cursor;
WT_SESSION *session;
int i, ret;
const char *cfg;
/*
* We expect the read-only database will allow the second read-only
* handle to succeed because no one can create or set the lock file.
*/
if (op == OP_READ)
cfg = ENV_CONFIG_RD;
else
cfg = ENV_CONFIG_WR;
if ((ret = wiredtiger_open(homedir, NULL, cfg, &conn)) == 0) {
if (expect == EXPECT_ERR)
testutil_die(
ret, "wiredtiger_open expected error, succeeded");
} else {
if (expect == EXPECT_SUCCESS)
testutil_die(
ret, "wiredtiger_open expected success, error");
/*
* If we expect an error and got one, we're done.
*/
return (0);
}
/*
* Make sure we can read the data.
*/
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
testutil_die(ret, "WT_CONNECTION:open_session");
if ((ret =
session->open_cursor(session, uri, NULL, NULL, &cursor)) != 0)
testutil_die(ret, "WT_SESSION.open_cursor: %s", uri);
i = 0;
while ((ret = cursor->next(cursor)) == 0)
++i;
if (i != MAX_KV)
testutil_die(EPERM, "cursor walk");
if ((ret = conn->close(conn, NULL)) != 0)
testutil_die(ret, "conn_close");
return (0);
}
开发者ID:jbreams,项目名称:mongo,代码行数:50,代码来源:readonly.c
注:本文中的WT_CONNECTION类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论