Пример #1
0
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);
}
Пример #2
0
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);
}
Пример #3
0
void ascii_write(char *f) {
    for (int i = 0; f[i] != '\0'; ++i)
        if (f[i] == '\t')
            cursor_reset();
        else
            putchar(f[i]);
    ascii_zzz();
}
Пример #4
0
void ascii_write_destroy() {
    console_clear();
    cursor_reset();
    cursor_show();
}
Пример #5
0
void ascii_write_init() {
    console_clear();
    cursor_reset();
    cursor_hide();
}
Пример #6
0
int
main(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;

	/* Open a connection to the database, creating it if necessary. */
	if ((ret = wiredtiger_open(
	    home, NULL, "create,statistics=(fast)", &conn)) != 0)
		fprintf(stderr, "Error connecting to %s: %s\n",
		    home == NULL ? "." : 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 == NULL ? "." : 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_search_near(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 closing %s: %s\n",
		    home == NULL ? "." : home, wiredtiger_strerror(ret));
		return (EXIT_FAILURE);
	}

	return (EXIT_SUCCESS);
}