这篇教程C++ wiredtiger_open函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wiredtiger_open函数的典型用法代码示例。如果您正苦于以下问题:C++ wiredtiger_open函数的具体用法?C++ wiredtiger_open怎么用?C++ wiredtiger_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wiredtiger_open函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainintmain(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, 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)); { /*! [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 connecting to %s: %s/n", home, wiredtiger_strerror(ret)); return (ret);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:50,
示例2: run_childstatic intrun_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:Tsmith5151,项目名称:mongo,代码行数:50,
示例3: mainint main(void){ /*! [access example connection] */ WT_CONNECTION *conn; WT_CURSOR *cursor; WT_SESSION *session; const char *key, *value; int ret; if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0 || (ret = conn->open_session(conn, NULL, NULL, &session)) != 0) { fprintf(stderr, "Error connecting to %s: %s/n", home, wiredtiger_strerror(ret)); return (ret); } /*! [access example connection] */ /*! [access example table create] */ ret = session->create(session, "table:access", "key_format=S,value_format=S"); /*! [access example table create] */ /*! [access example cursor open] */ ret = session->open_cursor(session, "table:access", NULL, NULL, &cursor); /*! [access example cursor open] */ /*! [access example cursor insert] */ cursor->set_key(cursor, "key1"); /* Insert a record. */ cursor->set_value(cursor, "value1"); ret = cursor->insert(cursor); /*! [access example cursor insert] */ /*! [access example cursor list] */ ret = cursor->reset(cursor); /* Restart the scan. */ 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); } /*! [access example cursor list] */ /*! [access example close] */ ret = conn->close(conn, NULL); /*! [access example close] */ return (ret);}
开发者ID:EaseTech,项目名称:wiredtiger,代码行数:49,
示例4: setup_copystatic intsetup_copy(WT_CONNECTION **wt_connp, WT_SESSION **sessionp){ int ret; if ((ret = wiredtiger_open(home2, NULL, CONN_CONFIG, wt_connp)) != 0) { fprintf(stderr, "Error connecting to %s: %s/n", home1, wiredtiger_strerror(ret)); return (ret); } ret = (*wt_connp)->open_session(*wt_connp, NULL, NULL, sessionp); ret = (*sessionp)->create(*sessionp, uri, "key_format=S,value_format=S"); return (ret);}
开发者ID:XinzeChi,项目名称:wiredtiger,代码行数:16,
示例5: mainintmain(int argc, char *argv[]){ TEST_OPTS *opts, _opts; opts = &_opts; memset(opts, 0, sizeof(*opts)); testutil_check(testutil_parse_opts(argc, argv, opts)); testutil_make_work_dir(opts->home); testutil_check( wiredtiger_open(opts->home, NULL, "create", &opts->conn)); /* Run the test. */ modify_run(opts->verbose); testutil_cleanup(opts); return (EXIT_SUCCESS);}
开发者ID:ajdavis,项目名称:mongo,代码行数:18,
示例6: main/*! [thread main] */intmain(void){ WT_CONNECTION *conn; WT_SESSION *session; WT_CURSOR *cursor; pthread_t threads[NUM_THREADS]; int i, 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; if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0) fprintf(stderr, "Error connecting to %s: %s/n", home == NULL ? "." : 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, conn); for (i = 0; i < NUM_THREADS; i++) ret = pthread_join(threads[i], NULL); ret = conn->close(conn, NULL); return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);}
开发者ID:AshishSanju,项目名称:mongo,代码行数:45,
示例7: mainintmain(void){ WT_CONNECTION *conn; WT_CURSOR *cursor; WT_SESSION *session; int 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; 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); ret = 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:XinzeChi,项目名称:wiredtiger,代码行数:42,
示例8: mainintmain(void){ WT_CONNECTION *conn; WT_SESSION *session; int ret; ret = wiredtiger_open(home, NULL, "create", &conn); ret = conn->open_session(conn, NULL, NULL, &session); ret = session->create( session, "table:access", "key_format=S,value_format=S"); ret = print_database_stats(session); ret = print_file_stats(session); ret = print_overflow_pages(session); return (conn->close(conn, NULL) == 0 ? ret : EXIT_FAILURE);}
开发者ID:qixin,项目名称:wiredtiger,代码行数:20,
示例9: wt_connect/* * wt_connect -- * Configure the WiredTiger connection. */static voidwt_connect(char *config_open){ static WT_EVENT_HANDLER event_handler = { NULL, handle_message, NULL }; int ret; char config[128]; snprintf(config, sizeof(config), "create,error_prefix=/"%s/",cache_size=5MB%s%s", progname, config_open == NULL ? "" : ",", config_open == NULL ? "" : config_open); if ((ret = wiredtiger_open(NULL, &event_handler, config, &conn)) != 0) die("wiredtiger_open", ret);}
开发者ID:zinuyasha,项目名称:wiredtiger,代码行数:24,
示例10: setupint setup(char *name, const char *kf, const char *vf, const char *cconfig, WT_CURSOR **cursor){ WT_SESSION *session; int creating, ret; char tconfig[64]; creating = (kf != NULL); if((ret = wiredtiger_open(NULL, NULL, "create", &conn) != 0) || (ret = conn->open_session(conn, NULL, NULL, &session)) != 0) return ret; /* If we get a configuration, create the table. */ if(creating) { (void)session->drop(session, name, "force"); snprintf(tconfig, sizeof(tconfig), "key_format=%s,value_format=%s", kf, vf); if ((ret = session->create(session, name, tconfig)) != 0) return ret; } return session->open_cursor(session, name, NULL, cconfig, cursor);}
开发者ID:RolfAndreassen,项目名称:wiredtiger,代码行数:21,
示例11: make_dir int WiredTigerEngine::Init(const WiredTigerConfig& cfg) { m_cfg = cfg; make_dir(cfg.path); int ret = 0; if (m_cfg.init_options.empty()) { m_cfg.init_options = "create,cache_size=500M,statistics=(fast)"; } if ((ret = wiredtiger_open(m_cfg.path.c_str(), NULL, m_cfg.init_options.c_str(), &m_db)) != 0) { ERROR_LOG("Error connecting to %s: %s", m_cfg.path.c_str(), wiredtiger_strerror(ret)); return -1; } ret = m_db->add_collator(m_db, "ardb_comparator", &ardb_comparator, NULL); CHECK_WT_RETURN(ret);// m_running = true;// m_background = new Thread(this);// m_background->Start(); return 0; }
开发者ID:Abioy,项目名称:ardb,代码行数:21,
示例12: mainint main(void){ int ret; WT_CONNECTION *conn; WT_SESSION *session; WT_CURSOR *cursor; const char *key, *value; /*! [configure cache size] */ if ((ret = wiredtiger_open(home, NULL, "create,cache_size=500M", &conn)) != 0) fprintf(stderr, "Error connecting to %s: %s/n", home, wiredtiger_strerror(ret)); /*! [configure cache size] */ /*! [create a table] */ ret = conn->open_session(conn, NULL, NULL, &session); ret = session->create(session, "table:access", "key_format=S,value_format=S"); /*! [create a table] */ /*! [transaction] */ ret = session->begin_transaction(session, "priority=100,name=mytxn"); ret = session->open_cursor(session, "config:", NULL, NULL, &cursor); while ((ret = cursor->next(cursor)) == 0) { cursor->get_key(cursor, &key); cursor->get_value(cursor, &value); printf("configuration value: %s = %s/n", key, value); } ret = session->commit_transaction(session, NULL); /*! [transaction] */ ret = conn->close(conn, NULL); return (ret);}
开发者ID:RolfAndreassen,项目名称:wiredtiger,代码行数:40,
示例13: mainintmain(void){ WT_CONNECTION *conn; WT_CURSOR *cursor; WT_SESSION *session; int ret, tret; /* * 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, create a simple table, open a cursor. */ if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0 || (ret = conn->open_session(conn, NULL, NULL, &session)) != 0) { fprintf(stderr, "Error connecting to %s: %s/n", home, wiredtiger_strerror(ret)); return (ret); } ret = session->create(session, "table:scope", "key_format=S,value_format=S,columns=(k,v)"); ret = session->open_cursor(session, "table:scope", NULL, NULL, &cursor); ret = cursor_scope_ops(cursor); /* Close the connection and clean up. */ if ((tret = conn->close(conn, NULL)) != 0 && ret == 0) ret = tret; return (ret);}
开发者ID:XinzeChi,项目名称:wiredtiger,代码行数:40,
示例14: mainintmain(void){ int ret; WT_CONNECTION *conn; WT_SESSION *session; /* * 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)); /*! [add collator nocase] */ ret = conn->add_collator(conn, "nocase", &nocasecoll, NULL); /*! [add collator nocase] */ /*! [add collator prefix10] */ ret = conn->add_collator(conn, "prefix10", &pcoll10.iface, NULL); /* 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)); /* Do some work... */ ret = conn->close(conn, NULL); /*! [add collator prefix10] */ return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);}
开发者ID:AshishSanju,项目名称:mongo,代码行数:40,
示例15: mainintmain(void){ WT_CONNECTION *conn; WT_SESSION *session; int ret; if ((ret = wiredtiger_open(home, NULL, "create", &conn)) != 0 || (ret = conn->open_session(conn, NULL, NULL, &session)) != 0) fprintf(stderr, "Error connecting to %s: %s/n", home, wiredtiger_strerror(ret)); /* Note: further error checking omitted for clarity. */ /*! [file create] */ ret = session->create(session, "file:example", "key_format=u," "internal_page_max=32KB,internal_item_max=1KB," "leaf_page_max=1MB,leaf_item_max=32KB"); /*! [file create] */ return (conn->close(conn, NULL) == 0 ? ret : EXIT_FAILURE);}
开发者ID:zhliu03,项目名称:wiredtiger,代码行数:22,
示例16: mainintmain(int argc, char *argv[]){ WT_CONNECTION *conn; WT_CURSOR *cursor; WT_SESSION *session; home = example_setup(argc, argv); error_check( wiredtiger_open(home, NULL, "create,statistics=(all)", &conn)); error_check(conn->open_session(conn, NULL, NULL, &session)); error_check(session->create(session, "table:access", "key_format=S,value_format=S,columns=(k,v)")); error_check(session->open_cursor( session, "table:access", NULL, NULL, &cursor)); cursor->set_key(cursor, "key"); cursor->set_value(cursor, "value"); error_check(cursor->insert(cursor)); error_check(cursor->close(cursor)); error_check(session->checkpoint(session, NULL)); print_database_stats(session); print_file_stats(session); print_join_cursor_stats(session); print_overflow_pages(session); print_derived_stats(session); error_check(conn->close(conn, NULL)); return (EXIT_SUCCESS);}
开发者ID:DINKIN,项目名称:mongo,代码行数:38,
示例17: wt_startup/* * wt_startup -- * Configure the WiredTiger connection. */static voidwt_startup(char *config_open){ static WT_EVENT_HANDLER event_handler = { handle_error, handle_message, NULL, NULL /* Close handler. */ }; int ret; char config_buf[128]; testutil_make_work_dir(home); snprintf(config_buf, sizeof(config_buf), "create,error_prefix=/"%s/",cache_size=5MB%s%s", progname, config_open == NULL ? "" : ",", config_open == NULL ? "" : config_open); if ((ret = wiredtiger_open( home, &event_handler, config_buf, &conn)) != 0) testutil_die(ret, "wiredtiger_open");}
开发者ID:Arikes,项目名称:mongo,代码行数:27,
示例18: mainint main(void){ WT_CONNECTION *conn; WT_SESSION *session; char buf[50]; size_t size; int i, j, k, 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)); /*! [packing] */ 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 connecting to %s: %s/n", home, wiredtiger_strerror(ret)); return (ret);}
开发者ID:EaseTech,项目名称:wiredtiger,代码行数:36,
示例19: wt_open_corruptstatic voidwt_open_corrupt(const char *sfx){ WT_CONNECTION *conn; WT_DECL_RET; char buf[1024]; if (sfx != NULL) testutil_check(__wt_snprintf(buf, sizeof(buf), "%s.%s", home, sfx)); else testutil_check(__wt_snprintf(buf, sizeof(buf), "%s", home)); ret = wiredtiger_open(buf, &event_handler, NULL, &conn); /* * Not all out of sync combinations lead to corruption. We keep * the previous checkpoint in the file so some combinations of * future or old turtle files and metadata files will succeed. */ if (ret != WT_TRY_SALVAGE && ret != 0) fprintf(stderr, "OPEN_CORRUPT: wiredtiger_open returned %d/n", ret); testutil_assert(ret == WT_TRY_SALVAGE || ret == 0); exit (EXIT_SUCCESS);}
开发者ID:ajdavis,项目名称:mongo,代码行数:24,
示例20: mainintmain(void){ WT_CONNECTION *conn; int ret; /*! [Open a connection] */ ret = wiredtiger_open(home, NULL, "create,cache_size=500M", &conn); /*! [Open a connection] */ if (ret == 0) connection_ops(conn); /* * The connection has been closed. */#ifdef MIGHT_NOT_RUN /* * This example code gets run, and the compression libraries might not * be installed, causing the open to fail. The documentation requires * the code snippets, use #ifdef's to avoid running it. */ /*! [Configure bzip2 extension] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_bzip2.so]", &conn); /*! [Configure bzip2 extension] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Configure snappy extension] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_snappy.so]", &conn); /*! [Configure snappy extension] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Configure zlib extension] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_zlib.so]", &conn); /*! [Configure zlib extension] */ if (ret == 0) (void)conn->close(conn, NULL); /* * This example code gets run, and direct I/O might not be available, * causing the open to fail. The documentation requires code snippets, * use #ifdef's to avoid running it. */ /* Might Not Run: direct I/O may not be available. */ /*! [Configure direct_io for data files] */ ret = wiredtiger_open(home, NULL, "create,direct_io=[data]", &conn); /*! [Configure direct_io for data files] */ if (ret == 0) (void)conn->close(conn, NULL);#endif /*! [Configure file_extend] */ ret = wiredtiger_open( home, NULL, "create,file_extend=(data=16MB)", &conn); /*! [Configure file_extend] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Statistics configuration] */ ret = wiredtiger_open(home, NULL, "create,statistics=(all)", &conn); /*! [Statistics configuration] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Statistics logging] */ ret = wiredtiger_open( home, NULL, "create,statistics_log=(wait=30)", &conn); /*! [Statistics logging] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Statistics logging with a table] */ ret = wiredtiger_open(home, NULL, "create," "statistics_log=(sources=(/"table:table1/",/"table:table2/"))", &conn); /*! [Statistics logging with a table] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Statistics logging with all tables] */ ret = wiredtiger_open(home, NULL, "create,statistics_log=(sources=(/"table:/"))", &conn); /*! [Statistics logging with all tables] */ if (ret == 0) (void)conn->close(conn, NULL);#ifdef MIGHT_NOT_RUN /* * This example code gets run, and a non-existent log file path might * cause the open to fail. The documentation requires code snippets,//.........这里部分代码省略.........
开发者ID:ezhangle,项目名称:node-wiredtiger,代码行数:101,
示例21: wts_openvoidwts_open(void){ WT_CONNECTION *conn; WT_SESSION *session; uint32_t maxintlpage, maxintlitem, maxleafpage, maxleafitem; int ret; const char *ext1, *ext2; char config[512], *end, *p; /* If the bzip2 compression module has been built, use it. */#define EXTPATH "../../ext" ext1 = EXTPATH "compressors/bzip2_compress/.libs/bzip2_compress.so"; if (access(ext1, R_OK) != 0) { ext1 = ""; g.c_bzip = 0; } ext2 = EXTPATH "/collators/reverse/.libs/reverse_collator.so"; /* * 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,sync=false," "extensions=[/"%s/",/"%s/"],%s", g.progname, g.c_cache, ext1, ext2, g.config_open == NULL ? "" : g.config_open); if ((ret = wiredtiger_open("RUNDIR", &event_handler, config, &conn)) != 0) die(ret, "wiredtiger_open"); if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) die(ret, "connection.open_session"); maxintlpage = 1U << g.c_intl_page_max; /* Make sure at least 2 internal page per thread can fit in cache. */ while (2 * g.c_threads * maxintlpage > g.c_cache << 20) maxintlpage >>= 1; maxintlitem = MMRAND(maxintlpage / 50, maxintlpage / 40); if (maxintlitem < 40) maxintlitem = 40; maxleafpage = 1U << g.c_leaf_page_max; /* Make sure at least one leaf page per thread can fit in cache. */ while (g.c_threads * (maxintlpage + maxleafpage) > g.c_cache << 20) maxleafpage >>= 1; maxleafitem = MMRAND(maxleafpage / 50, maxleafpage / 40); if (maxleafitem < 40) maxleafitem = 40; p = config; end = config + sizeof(config); p += snprintf(p, (size_t)(end - p), "key_format=%s," "internal_page_max=%d,internal_item_max=%d," "leaf_page_max=%d,leaf_item_max=%d", (g.type == ROW) ? "u" : "r", maxintlpage, maxintlitem, maxleafpage, maxleafitem); if (g.c_bzip) p += snprintf(p, (size_t)(end - p), ",block_compressor=/"bzip2_compress/""); switch (g.type) { case FIX: p += snprintf(p, (size_t)(end - p), ",value_format=%dt", g.c_bitcnt); break; case ROW: if (g.c_huffman_key) p += snprintf(p, (size_t)(end - p), ",huffman_key=english"); if (g.c_reverse) p += snprintf(p, (size_t)(end - p), ",collator=reverse"); /* FALLTHROUGH */ case VAR: if (g.c_huffman_value) p += snprintf(p, (size_t)(end - p), ",huffman_value=english"); if (g.c_dictionary) p += snprintf(p, (size_t)(end - p), ",dictionary=%d", MMRAND(123, 517)); break; } if ((ret = session->create(session, g.uri, config)) != 0) die(ret, "session.create: %s", g.uri); if ((ret = session->close(session, NULL)) != 0) die(ret, "session.close"); g.wts_conn = conn;}
开发者ID:zhliu03,项目名称:wiredtiger,代码行数:95,
示例22: mainintmain(void){ WT_CONNECTION *conn; int 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] */ ret = wiredtiger_open(home, NULL, "create,cache_size=5GB,log=(enabled,recover=on)", &conn); /*! [Open a connection] */ if (ret == 0) ret = connection_ops(conn); /* * The connection has been closed. */#ifdef MIGHT_NOT_RUN /* * This example code gets run, and the compression libraries might not * be installed, causing the open to fail. The documentation requires * the code snippets, use #ifdef's to avoid running it. */ /*! [Configure lz4 extension] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_lz4.so]", &conn); /*! [Configure lz4 extension] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Configure snappy extension] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_snappy.so]", &conn); /*! [Configure snappy extension] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Configure zlib extension] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_zlib.so]", &conn); /*! [Configure zlib extension] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Configure zlib extension with compression level] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/" "libwiredtiger_zlib.so=[config=[compression_level=3]]]", &conn); /*! [Configure zlib extension with compression level] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Configure zstd extension] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_zstd.so]", &conn); /*! [Configure zstd extension] */ if (ret == 0) (void)conn->close(conn, NULL); /*! [Configure zstd extension with compression level] */ ret = wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/" "libwiredtiger_zstd.so=[config=[compression_level=9]]]", &conn); /*! [Configure zstd extension with compression level] */ if (ret == 0) (void)conn->close(conn, NULL); /* * This example code gets run, and direct I/O might not be available, * causing the open to fail. The documentation requires code snippets, * use #ifdef's to avoid running it. */ /* Might Not Run: direct I/O may not be available. */ /*! [Configure direct_io for data files] */ ret = wiredtiger_open(home, NULL, "create,direct_io=[data]", &conn); /*! [Configure direct_io for data files] */ if (ret == 0) (void)conn->close(conn, NULL);#endif /*! [Configure file_extend] */ ret = wiredtiger_open( home, NULL, "create,file_extend=(data=16MB)", &conn); /*! [Configure file_extend] *///.........这里部分代码省略.........
开发者ID:ksuarz,项目名称:mongo,代码行数:101,
示例23: main//.........这里部分代码省略......... * don't stay in this loop forever. */ testutil_check(__wt_snprintf( statname, sizeof(statname), "%s/%s", home, ckpt_file)); while (stat(statname, &sb) != 0 && kill(pid, 0) == 0) sleep(1); sleep(timeout); /* * !!! It should be plenty long enough to make sure more than * one log file exists. If wanted, that check would be added * here. */ printf("Kill child/n"); testutil_checksys(kill(pid, SIGKILL) != 0); testutil_checksys(waitpid(pid, &status, 0) == -1); } /* * !!! If we wanted to take a copy of the directory before recovery, * this is the place to do it. */ if (chdir(home) != 0) testutil_die(errno, "parent chdir: %s", home); testutil_check(__wt_snprintf(buf, sizeof(buf), "rm -rf ../%s.SAVE && mkdir ../%s.SAVE && " "cp -p WiredTigerLog.* ../%s.SAVE", home, home, home)); (void)system(buf); printf("Open database, run recovery and verify content/n"); /* * Open the connection which forces recovery to be run. */ if ((ret = wiredtiger_open(NULL, NULL, ENV_CONFIG_REC, &conn)) != 0) testutil_die(ret, "wiredtiger_open"); if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) testutil_die(ret, "WT_CONNECTION:open_session"); /* * Open a cursor on all the tables. */ if ((ret = session->open_cursor(session, uri_collection, NULL, NULL, &cur_coll)) != 0) testutil_die(ret, "WT_SESSION.open_cursor: %s", uri_collection); if ((ret = session->open_cursor(session, uri_local, NULL, NULL, &cur_local)) != 0) testutil_die(ret, "WT_SESSION.open_cursor: %s", uri_local); if ((ret = session->open_cursor(session, uri_oplog, NULL, NULL, &cur_oplog)) != 0) testutil_die(ret, "WT_SESSION.open_cursor: %s", uri_oplog); if ((ret = session->open_cursor(session, stable_store, NULL, NULL, &cur_stable)) != 0) testutil_die(ret, "WT_SESSION.open_cursor: %s", stable_store); /* * Find the biggest stable timestamp value that was saved. */ stable_val = 0; memset(val, 0, sizeof(val)); while (cur_stable->next(cur_stable) == 0) { cur_stable->get_key(cur_stable, &key); cur_stable->get_value(cur_stable, &val[key]); if (val[key] > stable_val) stable_val = val[key]; if (use_ts) printf("Stable: key %" PRIu64 " value %" PRIu64 "/n",
开发者ID:DINKIN,项目名称:mongo,代码行数:67,
示例24: run_workloadstatic voidrun_workload(uint32_t nth){ WT_CONNECTION *conn; WT_SESSION *session; WT_THREAD_DATA *td; wt_thread_t *thr; uint32_t i; int ret; char envconf[512]; thr = dcalloc(nth+1, sizeof(*thr)); td = dcalloc(nth+1, sizeof(WT_THREAD_DATA)); if (chdir(home) != 0) testutil_die(errno, "Child chdir: %s", home); if (inmem) strcpy(envconf, ENV_CONFIG_DEF); else strcpy(envconf, ENV_CONFIG_TXNSYNC); if (compat) strcat(envconf, ENV_CONFIG_COMPAT); if ((ret = wiredtiger_open(NULL, NULL, envconf, &conn)) != 0) testutil_die(ret, "wiredtiger_open"); if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) testutil_die(ret, "WT_CONNECTION:open_session"); /* * Create all the tables. */ if ((ret = session->create(session, uri_collection, "key_format=S,value_format=u,log=(enabled=false)")) != 0) testutil_die(ret, "WT_SESSION.create: %s", uri_collection); if ((ret = session->create(session, uri_local, "key_format=S,value_format=u")) != 0) testutil_die(ret, "WT_SESSION.create: %s", uri_local); if ((ret = session->create(session, uri_oplog, "key_format=S,value_format=u")) != 0) testutil_die(ret, "WT_SESSION.create: %s", uri_oplog); /* * Don't log the stable timestamp table so that we know what timestamp * was stored at the checkpoint. */ if ((ret = session->create(session, stable_store, "key_format=Q,value_format=Q,log=(enabled=false)")) != 0) testutil_die(ret, "WT_SESSION.create: %s", stable_store); if ((ret = session->close(session, NULL)) != 0) testutil_die(ret, "WT_SESSION:close"); /* * Thread 0 is the checkpoint thread. */ td[0].conn = conn; td[0].id = 0; printf("Create checkpoint thread/n"); testutil_check(__wt_thread_create( NULL, &thr[0], thread_ckpt_run, &td[0])); for (i = 1; i <= nth; ++i) { td[i].conn = conn; td[i].start = (UINT64_MAX / nth) * (i - 1); td[i].id = i; testutil_check(__wt_thread_create( NULL, &thr[i], thread_run, &td[i])); } /* * The threads never exit, so the child will just wait here until * it is killed. */ printf("Create %" PRIu32 " writer threads/n", nth); fflush(stdout); for (i = 0; i <= nth; ++i) testutil_check(__wt_thread_join(NULL, thr[i])); /* * NOTREACHED */ free(thr); free(td); exit(EXIT_SUCCESS);}
开发者ID:DINKIN,项目名称:mongo,代码行数:78,
示例25: mainint main(void){ /*! [example connection] */ WT_ASYNC_OP *op; WT_CONNECTION *wt_conn; WT_SESSION *session; int i, ret; char k[MAX_KEYS][16], v[MAX_KEYS][16]; if ((ret = wiredtiger_open(home, NULL, "create,cache_size=100MB,async=(enabled=true,ops_max=10,threads=2)", &wt_conn)) != 0) { fprintf(stderr, "Error connecting to %s: %s/n", home, wiredtiger_strerror(ret)); return (ret); } /*! [example connection] */ /*! [example table create] */ ret = wt_conn->open_session(wt_conn, NULL, NULL, &session); ret = session->create(session, uri, "key_format=S,value_format=S"); /*! [example table create] */ for (i = 0; i < MAX_KEYS; i++) { /*! [Allocate a handle] */ op = NULL;retry: ret = wt_conn->async_new_op(wt_conn, uri, NULL, &cb, &op); if (ret != 0) { /* * If we used up all the ops, pause and retry to * give the workers a chance to process them. */ fprintf(stderr, "Iteration %d: async_new_op ret %d/n",i,ret); sleep(1); goto retry; } /*! [Allocate a handle] */ snprintf(k[i], sizeof(k), "key%d", i); snprintf(v[i], sizeof(v), "value%d", i); /*! [Set the operation's string key] */ op->set_key(op, k[i]); /*! [Set the operation's string key] */ /*! [Set the operation's string value] */ op->set_value(op, v[i]); /*! [Set the operation's string value] */ /*! [example insert] */ ret = op->insert(op); /*! [example insert] */ } /*! [flush] */ wt_conn->async_flush(wt_conn); /*! [flush] */ /*! [Compact a table] */ ret = wt_conn->async_new_op(wt_conn, uri, "timeout=10", &cb, &op); op->compact(op); /*! [Compact a table] */ for (i = 0; i < MAX_KEYS; i++) { op = NULL;retry2: ret = wt_conn->async_new_op(wt_conn, uri, NULL, &cb, &op); if (ret != 0) { /* * If we used up all the ops, pause and retry to * give the workers a chance to process them. */ fprintf(stderr, "Iteration %d: async_new_op ret %d/n",i,ret); sleep(1); goto retry2; } snprintf(k[i], sizeof(k), "key%d", i); op->set_key(op, k[i]); /*! [search] */ op->search(op); /*! [search] */ } /*! [example close] */ /* * Connection close automatically does an async_flush so it will * allow all queued search operations to complete. */ ret = wt_conn->close(wt_conn, NULL); /*! [example close] */ return (ret);}
开发者ID:lujudy,项目名称:wiredtiger,代码行数:92,
注:本文中的wiredtiger_open函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wiredtiger_strerror函数代码示例 C++ wiphy_to_rdev函数代码示例 |