int main(int argc, char *argv[]) { WT_CONNECTION *conn; 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", &conn)); /*! [add collator nocase] */ error_check(conn->add_collator(conn, "nocase", &nocasecoll, NULL)); /*! [add collator nocase] */ /*! [add collator prefix10] */ error_check(conn->add_collator(conn, "prefix10", &pcoll10.iface, NULL)); /* Open a session for the current thread's work. */ error_check(conn->open_session(conn, NULL, NULL, &session)); /* Do some work... */ error_check(conn->close(conn, NULL)); /*! [add collator prefix10] */ return (EXIT_SUCCESS); }
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); }
int main(int argc, char *argv[]) { WT_CONNECTION *conn; WT_SESSION *session; home = example_setup(argc, argv); error_check( wiredtiger_open(home, NULL, "create,cache_size=500M", &conn)); add_extractor(conn); error_check(conn->open_session(conn, NULL, NULL, &session)); setup_table(session); read_index(session); remove_items(session); error_check(conn->close(conn, NULL)); return (EXIT_SUCCESS); }
int main(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); }
int main(int argc, char *argv[]) { POP_RECORD *p; WT_CONNECTION *conn; WT_CURSOR *country_cursor, *country_cursor2, *cursor, *join_cursor, *stat_cursor, *subjoin_cursor, *year_cursor; WT_SESSION *session; const char *country; uint64_t recno, population; uint16_t year; int ret; home = example_setup(argc, argv); error_check(wiredtiger_open( home, NULL, "create,statistics=(fast)", &conn)); error_check(conn->open_session(conn, NULL, NULL, &session)); /*! [Create a table with column groups] */ /* * Create the population table. * Keys are record numbers, the format for values is (5-byte string, * uint16_t, uint64_t). * See ::wiredtiger_struct_pack for details of the format strings. */ error_check(session->create(session, "table:poptable", "key_format=r," "value_format=5sHQ," "columns=(id,country,year,population)," "colgroups=(main,population)")); /* * Create two column groups: a primary column group with the country * code, year and population (named "main"), and a population column * group with the population by itself (named "population"). */ error_check(session->create(session, "colgroup:poptable:main", "columns=(country,year,population)")); error_check(session->create(session, "colgroup:poptable:population", "columns=(population)")); /*! [Create a table with column groups] */ /*! [Create an index] */ /* Create an index with a simple key. */ error_check(session->create(session, "index:poptable:country", "columns=(country)")); /*! [Create an index] */ /*! [Create an index with a composite key] */ /* Create an index with a composite key (country,year). */ error_check(session->create(session, "index:poptable:country_plus_year", "columns=(country,year)")); /*! [Create an index with a composite key] */ /*! [Create an immutable index] */ /* Create an immutable index. */ error_check(session->create(session, "index:poptable:immutable_year", "columns=(year),immutable")); /*! [Create an immutable index] */ /* Insert the records into the table. */ error_check(session->open_cursor( session, "table:poptable", NULL, "append", &cursor)); for (p = pop_data; p->year != 0; p++) { cursor->set_value(cursor, p->country, p->year, p->population); error_check(cursor->insert(cursor)); } error_check(cursor->close(cursor)); /* Update records in the table. */ error_check(session->open_cursor(session, "table:poptable", NULL, NULL, &cursor)); while ((ret = cursor->next(cursor)) == 0) { error_check(cursor->get_key(cursor, &recno)); error_check(cursor->get_value( cursor, &country, &year, &population)); cursor->set_value(cursor, country, year, population + 1); error_check(cursor->update(cursor)); } scan_end_check(ret == WT_NOTFOUND); error_check(cursor->close(cursor)); /* List the records in the table. */ error_check(session->open_cursor(session, "table:poptable", NULL, NULL, &cursor)); while ((ret = cursor->next(cursor)) == 0) { error_check(cursor->get_key(cursor, &recno)); error_check(cursor->get_value( cursor, &country, &year, &population)); printf("ID %" PRIu64, recno); printf( ": country %s, year %" PRIu16 ", population %" PRIu64 "\n", country, year, population); } scan_end_check(ret == WT_NOTFOUND); error_check(cursor->close(cursor)); /*! [List the records in the table using raw mode.] */ /* List the records in the table using raw mode. */ error_check(session->open_cursor(session, "table:poptable", NULL, "raw", &cursor)); while ((ret = cursor->next(cursor)) == 0) { WT_ITEM key, value; error_check(cursor->get_key(cursor, &key)); error_check(wiredtiger_struct_unpack( session, key.data, key.size, "r", &recno)); printf("ID %" PRIu64, recno); error_check(cursor->get_value(cursor, &value)); error_check(wiredtiger_struct_unpack(session, value.data, value.size, "5sHQ", &country, &year, &population)); printf( ": country %s, year %" PRIu16 ", population %" PRIu64 "\n", country, year, population); } scan_end_check(ret == WT_NOTFOUND); /*! [List the records in the table using raw mode.] */ error_check(cursor->close(cursor)); /*! [Read population from the primary column group] */ /* * Open a cursor on the main column group, and return the information * for a particular country. */ error_check(session->open_cursor( session, "colgroup:poptable:main", NULL, NULL, &cursor)); cursor->set_key(cursor, 2); error_check(cursor->search(cursor)); error_check(cursor->get_value(cursor, &country, &year, &population)); printf( "ID 2: country %s, year %" PRIu16 ", population %" PRIu64 "\n", country, year, population); /*! [Read population from the primary column group] */ error_check(cursor->close(cursor)); /*! [Read population from the standalone column group] */ /* * Open a cursor on the population column group, and return the * population of a particular country. */ error_check(session->open_cursor(session, "colgroup:poptable:population", NULL, NULL, &cursor)); cursor->set_key(cursor, 2); error_check(cursor->search(cursor)); error_check(cursor->get_value(cursor, &population)); printf("ID 2: population %" PRIu64 "\n", population); /*! [Read population from the standalone column group] */ error_check(cursor->close(cursor)); /*! [Search in a simple index] */ /* Search in a simple index. */ error_check(session->open_cursor(session, "index:poptable:country", NULL, NULL, &cursor)); cursor->set_key(cursor, "AU\0\0\0"); error_check(cursor->search(cursor)); error_check(cursor->get_value(cursor, &country, &year, &population)); printf("AU: country %s, year %" PRIu16 ", population %" PRIu64 "\n", country, year, population); /*! [Search in a simple index] */ error_check(cursor->close(cursor)); /*! [Search in a composite index] */ /* Search in a composite index. */ error_check(session->open_cursor(session, "index:poptable:country_plus_year", NULL, NULL, &cursor)); cursor->set_key(cursor, "USA\0\0", (uint16_t)1900); error_check(cursor->search(cursor)); error_check(cursor->get_value(cursor, &country, &year, &population)); printf( "US 1900: country %s, year %" PRIu16 ", population %" PRIu64 "\n", country, year, population); /*! [Search in a composite index] */ error_check(cursor->close(cursor)); /*! [Return a subset of values from the table] */ /* * Use a projection to return just the table's country and year * columns. */ error_check(session->open_cursor(session, "table:poptable(country,year)", NULL, NULL, &cursor)); while ((ret = cursor->next(cursor)) == 0) { error_check(cursor->get_value(cursor, &country, &year)); printf("country %s, year %" PRIu16 "\n", country, year); } /*! [Return a subset of values from the table] */ scan_end_check(ret == WT_NOTFOUND); error_check(cursor->close(cursor)); /*! [Return a subset of values from the table using raw mode] */ /* * Use a projection to return just the table's country and year * columns, using raw mode. */ error_check(session->open_cursor(session, "table:poptable(country,year)", NULL, "raw", &cursor)); while ((ret = cursor->next(cursor)) == 0) { WT_ITEM value; error_check(cursor->get_value(cursor, &value)); error_check(wiredtiger_struct_unpack( session, value.data, value.size, "5sH", &country, &year)); printf("country %s, year %" PRIu16 "\n", country, year); } scan_end_check(ret == WT_NOTFOUND); /*! [Return a subset of values from the table using raw mode] */ error_check(cursor->close(cursor)); /*! [Return the table's record number key using an index] */ /* * Use a projection to return just the table's record number key * from an index. */ error_check(session->open_cursor(session, "index:poptable:country_plus_year(id)", NULL, NULL, &cursor)); while ((ret = cursor->next(cursor)) == 0) { error_check(cursor->get_key(cursor, &country, &year)); error_check(cursor->get_value(cursor, &recno)); printf("row ID %" PRIu64 ": country %s, year %" PRIu16 "\n", recno, country, year); } scan_end_check(ret == WT_NOTFOUND); /*! [Return the table's record number key using an index] */ error_check(cursor->close(cursor)); /*! [Return a subset of the value columns from an index] */ /* * Use a projection to return just the population column from an * index. */ error_check(session->open_cursor(session, "index:poptable:country_plus_year(population)", NULL, NULL, &cursor)); while ((ret = cursor->next(cursor)) == 0) { error_check(cursor->get_key(cursor, &country, &year)); error_check(cursor->get_value(cursor, &population)); printf("population %" PRIu64 ": country %s, year %" PRIu16 "\n", population, country, year); } scan_end_check(ret == WT_NOTFOUND); /*! [Return a subset of the value columns from an index] */ error_check(cursor->close(cursor)); /*! [Access only the index] */ /* * Use a projection to avoid accessing any other column groups when * using an index: supply an empty list of value columns. */ error_check(session->open_cursor(session, "index:poptable:country_plus_year()", NULL, NULL, &cursor)); while ((ret = cursor->next(cursor)) == 0) { error_check(cursor->get_key(cursor, &country, &year)); printf("country %s, year %" PRIu16 "\n", country, year); } scan_end_check(ret == WT_NOTFOUND); /*! [Access only the index] */ error_check(cursor->close(cursor)); /*! [Join cursors] */ /* Open cursors needed by the join. */ error_check(session->open_cursor(session, "join:table:poptable", NULL, NULL, &join_cursor)); error_check(session->open_cursor(session, "index:poptable:country", NULL, NULL, &country_cursor)); error_check(session->open_cursor(session, "index:poptable:immutable_year", NULL, NULL, &year_cursor)); /* select values WHERE country == "AU" AND year > 1900 */ country_cursor->set_key(country_cursor, "AU\0\0\0"); error_check(country_cursor->search(country_cursor)); error_check(session->join( session, join_cursor, country_cursor, "compare=eq,count=10")); year_cursor->set_key(year_cursor, (uint16_t)1900); error_check(year_cursor->search(year_cursor)); error_check(session->join(session, join_cursor, year_cursor, "compare=gt,count=10,strategy=bloom")); /* List the values that are joined */ while ((ret = join_cursor->next(join_cursor)) == 0) { error_check(join_cursor->get_key(join_cursor, &recno)); error_check(join_cursor->get_value( join_cursor, &country, &year, &population)); printf("ID %" PRIu64, recno); printf( ": country %s, year %" PRIu16 ", population %" PRIu64 "\n", country, year, population); } scan_end_check(ret == WT_NOTFOUND); /*! [Join cursors] */ /*! [Statistics cursor join cursor] */ error_check(session->open_cursor(session, "statistics:join", join_cursor, NULL, &stat_cursor)); /*! [Statistics cursor join cursor] */ error_check(stat_cursor->close(stat_cursor)); error_check(join_cursor->close(join_cursor)); error_check(year_cursor->close(year_cursor)); error_check(country_cursor->close(country_cursor)); /*! [Complex join cursors] */ /* Open cursors needed by the join. */ error_check(session->open_cursor(session, "join:table:poptable", NULL, NULL, &join_cursor)); error_check(session->open_cursor(session, "join:table:poptable", NULL, NULL, &subjoin_cursor)); error_check(session->open_cursor(session, "index:poptable:country", NULL, NULL, &country_cursor)); error_check(session->open_cursor(session, "index:poptable:country", NULL, NULL, &country_cursor2)); error_check(session->open_cursor(session, "index:poptable:immutable_year", NULL, NULL, &year_cursor)); /* * select values WHERE (country == "AU" OR country == "UK") * AND year > 1900 * * First, set up the join representing the country clause. */ country_cursor->set_key(country_cursor, "AU\0\0\0"); error_check(country_cursor->search(country_cursor)); error_check(session->join(session, subjoin_cursor, country_cursor, "operation=or,compare=eq,count=10")); country_cursor2->set_key(country_cursor2, "UK\0\0\0"); error_check(country_cursor2->search(country_cursor2)); error_check(session->join(session, subjoin_cursor, country_cursor2, "operation=or,compare=eq,count=10")); /* Join that to the top join, and add the year clause */ error_check(session->join(session, join_cursor, subjoin_cursor, NULL)); year_cursor->set_key(year_cursor, (uint16_t)1900); error_check(year_cursor->search(year_cursor)); error_check(session->join(session, join_cursor, year_cursor, "compare=gt,count=10,strategy=bloom")); /* List the values that are joined */ while ((ret = join_cursor->next(join_cursor)) == 0) { error_check(join_cursor->get_key(join_cursor, &recno)); error_check(join_cursor->get_value( join_cursor, &country, &year, &population)); printf("ID %" PRIu64, recno); printf( ": country %s, year %" PRIu16 ", population %" PRIu64 "\n", country, year, population); } scan_end_check(ret == WT_NOTFOUND); /*! [Complex join cursors] */ error_check(join_cursor->close(join_cursor)); error_check(subjoin_cursor->close(subjoin_cursor)); error_check(country_cursor->close(country_cursor)); error_check(country_cursor2->close(country_cursor2)); error_check(year_cursor->close(year_cursor)); error_check(conn->close(conn, NULL)); return (EXIT_SUCCESS); }
int main(int argc, char *argv[]) { WT_CONNECTION *conn; WT_CURSOR *c1, *c2, *nc; WT_SESSION *session; int i, ret; char keybuf[32], valbuf[32]; char *key1, *key2, *key3, *val1, *val2, *val3; home = example_setup(argc, argv); error_check(wiredtiger_open(home, NULL, WT_OPEN_CONFIG_GOOD, &conn)); error_check(conn->open_session(conn, NULL, NULL, &session)); /* * Write a log record that is larger than the base 128 bytes and * also should compress well. */ error_check(session->log_printf(session, COMP_A COMP_B COMP_C COMP_A COMP_B COMP_C COMP_A COMP_B COMP_C COMP_A COMP_B COMP_C "The quick brown fox jumps over the lazy dog ")); simple_walk_log(session); /* * Create and open some encrypted and not encrypted tables. * Also use column store and compression for some tables. */ error_check(session->create(session, "table:crypto1", "encryption=(name=rotn,keyid=" USER1_KEYID")," "columns=(key0,value0)," "key_format=S,value_format=S")); error_check(session->create(session, "index:crypto1:byvalue", "encryption=(name=rotn,keyid=" USER1_KEYID")," "columns=(value0,key0)")); error_check(session->create(session, "table:crypto2", "encryption=(name=rotn,keyid=" USER2_KEYID")," "key_format=S,value_format=S")); error_check(session->create(session, "table:nocrypto", "key_format=S,value_format=S")); /* * Send in an unknown keyid. WiredTiger will try to add in the * new keyid, but the customize function above will return an * error since it is unrecognized. */ ret = session->create(session, "table:cryptobad", "encryption=(name=rotn,keyid=" USERBAD_KEYID")," "key_format=S,value_format=S"); if (ret == 0) { fprintf(stderr, "Did not detect bad/unknown keyid error\n"); exit(EXIT_FAILURE); } error_check(session->open_cursor( session, "table:crypto1", NULL, NULL, &c1)); error_check(session->open_cursor( session, "table:crypto2", NULL, NULL, &c2)); error_check(session->open_cursor( session, "table:nocrypto", NULL, NULL, &nc)); /* * Insert a set of keys and values. Insert the same data into * all tables so that we can verify they're all the same after * we decrypt on read. */ for (i = 0; i < MAX_KEYS; i++) { (void)snprintf(keybuf, sizeof(keybuf), "key%d", i); c1->set_key(c1, keybuf); c2->set_key(c2, keybuf); nc->set_key(nc, keybuf); (void)snprintf(valbuf, sizeof(valbuf), "value%d", i); c1->set_value(c1, valbuf); c2->set_value(c2, valbuf); nc->set_value(nc, valbuf); error_check(c1->insert(c1)); error_check(c2->insert(c2)); error_check(nc->insert(nc)); if (i % 5 == 0) error_check(session->log_printf( session, "Wrote %d records", i)); } error_check(session->log_printf( session, "Done. Wrote %d total records", i)); while (c1->next(c1) == 0) { error_check(c1->get_key(c1, &key1)); error_check(c1->get_value(c1, &val1)); printf("Read key %s; value %s\n", key1, val1); } simple_walk_log(session); printf("CLOSE\n"); error_check(conn->close(conn, NULL)); /* * We want to close and reopen so that we recreate the cache * by reading the data from disk, forcing decryption. */ printf("REOPEN and VERIFY encrypted data\n"); error_check(wiredtiger_open(home, NULL, WT_OPEN_CONFIG_GOOD, &conn)); error_check(conn->open_session(conn, NULL, NULL, &session)); /* * Verify we can read the encrypted log after restart. */ simple_walk_log(session); error_check(session->open_cursor( session, "table:crypto1", NULL, NULL, &c1)); error_check(session->open_cursor( session, "table:crypto2", NULL, NULL, &c2)); error_check(session->open_cursor( session, "table:nocrypto", NULL, NULL, &nc)); /* * Read the same data from each cursor. All should be identical. */ while (c1->next(c1) == 0) { error_check(c2->next(c2)); error_check(nc->next(nc)); error_check(c1->get_key(c1, &key1)); error_check(c1->get_value(c1, &val1)); error_check(c2->get_key(c2, &key2)); error_check(c2->get_value(c2, &val2)); error_check(nc->get_key(nc, &key3)); error_check(nc->get_value(nc, &val3)); if (strcmp(key1, key2) != 0) fprintf(stderr, "Key1 %s and Key2 %s do not match\n", key1, key2); if (strcmp(key1, key3) != 0) fprintf(stderr, "Key1 %s and Key3 %s do not match\n", key1, key3); if (strcmp(key2, key3) != 0) fprintf(stderr, "Key2 %s and Key3 %s do not match\n", key2, key3); if (strcmp(val1, val2) != 0) fprintf(stderr, "Val1 %s and Val2 %s do not match\n", val1, val2); if (strcmp(val1, val3) != 0) fprintf(stderr, "Val1 %s and Val3 %s do not match\n", val1, val3); if (strcmp(val2, val3) != 0) fprintf(stderr, "Val2 %s and Val3 %s do not match\n", val2, val3); printf("Verified key %s; value %s\n", key1, val1); } error_check(conn->close(conn, NULL)); return (EXIT_SUCCESS); }
int main(int argc, char *argv[]) { WT_CONNECTION *conn; home = example_setup(argc, argv); /*! [Open a connection] */ error_check(wiredtiger_open(home, NULL, "create,cache_size=5GB,log=(enabled,recover=on),statistics=(all)", &conn)); /*! [Open a connection] */ 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] */ error_check(wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_lz4.so]", &conn)); /*! [Configure lz4 extension] */ error_check(conn->close(conn, NULL)); /*! [Configure snappy extension] */ error_check(wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_snappy.so]", &conn)); /*! [Configure snappy extension] */ error_check(conn->close(conn, NULL)); /*! [Configure zlib extension] */ error_check(wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_zlib.so]", &conn)); /*! [Configure zlib extension] */ error_check(conn->close(conn, NULL)); /*! [Configure zlib extension with compression level] */ error_check(wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/" "libwiredtiger_zlib.so=[config=[compression_level=3]]]", &conn)); /*! [Configure zlib extension with compression level] */ error_check(conn->close(conn, NULL)); /*! [Configure zstd extension] */ error_check(wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/libwiredtiger_zstd.so]", &conn)); /*! [Configure zstd extension] */ error_check(conn->close(conn, NULL)); /*! [Configure zstd extension with compression level] */ error_check(wiredtiger_open(home, NULL, "create," "extensions=[/usr/local/lib/" "libwiredtiger_zstd.so=[config=[compression_level=9]]]", &conn)); /*! [Configure zstd extension with compression level] */ error_check(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] */ error_check(wiredtiger_open( home, NULL, "create,direct_io=[data]", &conn)); /*! [Configure direct_io for data files] */ error_check(conn->close(conn, NULL)); #endif /*! [Configure file_extend] */ error_check(wiredtiger_open( home, NULL, "create,file_extend=(data=16MB)", &conn)); /*! [Configure file_extend] */ error_check(conn->close(conn, NULL)); /*! [Eviction configuration] */ /* * Configure eviction to begin at 90% full, and run until the cache * is only 75% dirty. */ error_check(wiredtiger_open(home, NULL, "create,eviction_trigger=90,eviction_dirty_target=75", &conn)); /*! [Eviction configuration] */ error_check(conn->close(conn, NULL)); /*! [Eviction worker configuration] */ /* Configure up to four eviction threads */ error_check(wiredtiger_open(home, NULL, "create,eviction_trigger=90,eviction=(threads_max=4)", &conn)); /*! [Eviction worker configuration] */ error_check(conn->close(conn, NULL)); /*! [Statistics configuration] */ error_check(wiredtiger_open( home, NULL, "create,statistics=(all)", &conn)); /*! [Statistics configuration] */ error_check(conn->close(conn, NULL)); /*! [Statistics logging] */ error_check(wiredtiger_open( home, NULL, "create,statistics_log=(wait=30)", &conn)); /*! [Statistics logging] */ error_check(conn->close(conn, NULL)); #ifdef MIGHT_NOT_RUN /* * Don't run this code, statistics logging doesn't yet support tables. */ /*! [Statistics logging with a table] */ error_check(wiredtiger_open(home, NULL, "create, statistics_log=(" "sources=(\"table:table1\",\"table:table2\"), wait=5)", &conn)); /*! [Statistics logging with a table] */ error_check(conn->close(conn, NULL)); /* * Don't run this code, statistics logging doesn't yet support indexes. */ /*! [Statistics logging with a source type] */ error_check(wiredtiger_open(home, NULL, "create, statistics_log=(sources=(\"index:\"), wait=5)", &conn)); /*! [Statistics logging with a source type] */ error_check(conn->close(conn, NULL)); /* * Don't run this code, because memory checkers get very upset when we * leak memory. */ error_check(wiredtiger_open(home, NULL, "create", &conn)); /*! [Connection close leaking memory] */ error_check(conn->close(conn, "leak_memory=true")); /*! [Connection close leaking memory] */ #endif /*! [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_v, minor_v, patch; (void)wiredtiger_version(&major_v, &minor_v, &patch); printf("WiredTiger version is %d, %d (patch %d)\n", major_v, minor_v, patch); /*! [Get the WiredTiger library version #2] */ } { /*! [Calculate a modify operation] */ WT_MODIFY mod[3]; int nmod = 3; WT_ITEM prev, newv; prev.data = "the quick brown fox jumped over the lazy dog. " \ "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. " \ "the quick brown fox jumped over the lazy dog. " \ "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. "; prev.size = strlen(prev.data); newv.data = "A quick brown fox jumped over the lazy dog. " \ "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. " \ "then a quick brown fox jumped over the lazy dog. " \ "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG. " \ "then what?"; newv.size = strlen(newv.data); error_check(wiredtiger_calc_modify(NULL, &prev, &newv, 20, mod, &nmod)); /*! [Calculate a modify operation] */ } { const char *buffer = "some string"; size_t len = strlen(buffer); /*! [Checksum a buffer] */ uint32_t crc32c, (*func)(const void *, size_t); func = wiredtiger_crc32c_func(); crc32c = func(buffer, len); /*! [Checksum a buffer] */ (void)crc32c; } return (EXIT_SUCCESS); }