示例#1
0
int
connection_ops(WT_CONNECTION *conn)
{
	int ret;

	/*! [Load an extension] */
	ret = conn->load_extension(conn, "my_extension.dll", NULL);
	/*! [Load an extension] */

	add_collator(conn);
	add_data_source(conn);
	add_extractor(conn);

	/*! [Reconfigure a connection] */
	ret = conn->reconfigure(conn, "eviction_target=75");
	/*! [Reconfigure a connection] */

	/*! [Get the database home directory] */
	printf("The database home is %s\n", conn->get_home(conn));
	/*! [Get the database home directory] */

	/*! [Check if the database is newly created] */
	if (conn->is_new(conn)) {
		/* First time initialization. */
	}
	/*! [Check if the database is newly created] */

	{
	/*! [Open a session] */
	WT_SESSION *session;
	ret = conn->open_session(conn, NULL, NULL, &session);
	/*! [Open a session] */

	session_ops(session);
	}

	/*! [Close a connection] */
	ret = conn->close(conn, NULL);
	/*! [Close a connection] */

	return (ret);
}
示例#2
0
int
connection_ops(WT_CONNECTION *conn)
{
	int ret;

#ifdef MIGHT_NOT_RUN
	/*! [Load an extension] */
	ret = conn->load_extension(conn, "my_extension.dll", NULL);

	ret = conn->load_extension(conn,
	    "datasource/libdatasource.so",
	    "config=[device=/dev/sd1,alignment=64]");
	/*! [Load an extension] */
#endif

	add_collator(conn);
	add_extractor(conn);

	/*! [Reconfigure a connection] */
	ret = conn->reconfigure(conn, "eviction_target=75");
	/*! [Reconfigure a connection] */

	/*! [Get the database home directory] */
	printf("The database home is %s\n", conn->get_home(conn));
	/*! [Get the database home directory] */

	/*! [Check if the database is newly created] */
	if (conn->is_new(conn)) {
		/* First time initialization. */
	}
	/*! [Check if the database is newly created] */

	{
	/*! [Open a session] */
	WT_SESSION *session;
	ret = conn->open_session(conn, NULL, NULL, &session);
	/*! [Open a session] */

	session_ops(session);
	}

	/*! [Configure method configuration] */
	/*
	 * Applications opening a cursor for the data-source object "my_data"
	 * have an additional configuration option "entries", which is an
	 * integer type, defaults to 5, and must be an integer between 1 and 10.
	 */
	ret = conn->configure_method(conn,
	    "session.open_cursor",
	    "my_data:", "entries=5", "int", "min=1,max=10");

	/*
	 * Applications opening a cursor for the data-source object "my_data"
	 * have an additional configuration option "devices", which is a list
	 * of strings.
	 */
	ret = conn->configure_method(conn,
	    "session.open_cursor", "my_data:", "devices", "list", NULL);
	/*! [Configure method configuration] */

	/*! [Close a connection] */
	ret = conn->close(conn, NULL);
	/*! [Close a connection] */

	return (ret);
}
示例#3
0
文件: ex_all.c 项目: ksuarz/mongo
int
connection_ops(WT_CONNECTION *conn)
{
	int ret;

#ifdef MIGHT_NOT_RUN
	/*! [Load an extension] */
	ret = conn->load_extension(conn, "my_extension.dll", NULL);

	ret = conn->load_extension(conn,
	    "datasource/libdatasource.so",
	    "config=[device=/dev/sd1,alignment=64]");
	/*! [Load an extension] */
#endif

	ret = add_collator(conn);
	ret = add_extractor(conn);

	/*! [Reconfigure a connection] */
	ret = conn->reconfigure(conn, "eviction_target=75");
	/*! [Reconfigure a connection] */

	/*! [Get the database home directory] */
	printf("The database home is %s\n", conn->get_home(conn));
	/*! [Get the database home directory] */

	/*! [Check if the database is newly created] */
	if (conn->is_new(conn)) {
		/* First time initialization. */
	}
	/*! [Check if the database is newly created] */

	/*! [Validate a configuration string] */
	/*
	 * Validate a configuration string for a WiredTiger function or method.
	 *
	 * Functions are specified by name (for example, "wiredtiger_open").
	 *
	 * Methods are specified using a concatenation of the handle name, a
	 * period and the method name (for example, session create would be
	 * "WT_SESSION.create" and cursor close would be WT_CURSOR.close").
	 */
	ret = wiredtiger_config_validate(
	    NULL, NULL, "WT_SESSION.create", "allocation_size=32KB");
	/*! [Validate a configuration string] */

	{
	/*! [Open a session] */
	WT_SESSION *session;
	ret = conn->open_session(conn, NULL, NULL, &session);
	/*! [Open a session] */

	ret = session_ops(session);
	}

	/*! [Configure method configuration] */
	/*
	 * Applications opening a cursor for the data-source object "my_data"
	 * have an additional configuration option "entries", which is an
	 * integer type, defaults to 5, and must be an integer between 1 and 10.
	 *
	 * The method being configured is specified using a concatenation of the
	 * handle name, a period and the method name.
	 */
	ret = conn->configure_method(conn,
	    "WT_SESSION.open_cursor",
	    "my_data:", "entries=5", "int", "min=1,max=10");

	/*
	 * Applications opening a cursor for the data-source object "my_data"
	 * have an additional configuration option "devices", which is a list
	 * of strings.
	 */
	ret = conn->configure_method(conn,
	    "WT_SESSION.open_cursor", "my_data:", "devices", "list", NULL);
	/*! [Configure method configuration] */

	/*! [Close a connection] */
	ret = conn->close(conn, NULL);
	/*! [Close a connection] */

	return (ret);
}