Version 2.6.1
WT_DATA_SOURCE Struct Reference

Applications can extend WiredTiger by providing new implementations of the WT_DATA_SOURCE class. More...

Public Attributes

int(* create )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)
 Callback to create a new object. More...
 
int(* compact )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)
 Callback to compact an object. More...
 
int(* drop )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)
 Callback to drop an object. More...
 
int(* open_cursor )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config, WT_CURSOR **new_cursor)
 Callback to initialize a cursor. More...
 
int(* rename )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, const char *newuri, WT_CONFIG_ARG *config)
 Callback to rename an object. More...
 
int(* salvage )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)
 Callback to salvage an object. More...
 
int(* truncate )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)
 Callback to truncate an object. More...
 
int(* range_truncate )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, WT_CURSOR *start, WT_CURSOR *stop)
 Callback to truncate a range of an object. More...
 
int(* verify )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)
 Callback to verify an object. More...
 
int(* checkpoint )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, WT_CONFIG_ARG *config)
 Callback to checkpoint the database. More...
 
int(* terminate )(WT_DATA_SOURCE *dsrc, WT_SESSION *session)
 If non-NULL, a callback performed when the database is closed. More...
 

Detailed Description

Applications can extend WiredTiger by providing new implementations of the WT_DATA_SOURCE class.

Each data source supports a different URI scheme for data sources to WT_SESSION::create, WT_SESSION::open_cursor and related methods. See Custom Data Sources for more information.

Thread safety: WiredTiger may invoke methods on the WT_DATA_SOURCE interface from multiple threads concurrently. It is the responsibility of the implementation to protect any shared data.

Applications register their implementation with WiredTiger by calling WT_CONNECTION::add_data_source.

static WT_DATA_SOURCE my_dsrc = {
my_create,
my_compact,
my_drop,
my_open_cursor,
my_rename,
my_salvage,
my_truncate,
my_range_truncate,
my_verify,
my_checkpoint,
my_terminate
};
ret = conn->add_data_source(conn, "dsrc:", &my_dsrc, NULL);

Member Data Documentation

int(* WT_DATA_SOURCE::checkpoint) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, WT_CONFIG_ARG *config)

Callback to checkpoint the database.

static int
my_checkpoint(WT_DATA_SOURCE *dsrc, WT_SESSION *session, WT_CONFIG_ARG *config)
int(* WT_DATA_SOURCE::compact) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)

Callback to compact an object.

static int
my_compact(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, WT_CONFIG_ARG *config)
int(* WT_DATA_SOURCE::create) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)

Callback to create a new object.

static int
my_create(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, WT_CONFIG_ARG *config)
int(* WT_DATA_SOURCE::drop) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)

Callback to drop an object.

static int
my_drop(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, WT_CONFIG_ARG *config)
int(* WT_DATA_SOURCE::open_cursor) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config, WT_CURSOR **new_cursor)

Callback to initialize a cursor.

typedef struct __my_cursor {
WT_CURSOR wtcursor; /* WiredTiger cursor, must come first */
/*
* Local cursor information: for example, we might want to have a
* reference to the extension functions.
*/
WT_EXTENSION_API *wtext; /* Extension functions */
} MY_CURSOR;
static int
my_open_cursor(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, WT_CONFIG_ARG *config, WT_CURSOR **new_cursor)
{
MY_CURSOR *cursor;
/* Allocate and initialize a WiredTiger cursor. */
if ((cursor = calloc(1, sizeof(*cursor))) == NULL)
return (errno);
cursor->wtcursor.next = my_cursor_next;
cursor->wtcursor.prev = my_cursor_prev;
cursor->wtcursor.reset = my_cursor_reset;
cursor->wtcursor.search = my_cursor_search;
cursor->wtcursor.search_near = my_cursor_search_near;
cursor->wtcursor.insert = my_cursor_insert;
cursor->wtcursor.update = my_cursor_update;
cursor->wtcursor.remove = my_cursor_remove;
cursor->wtcursor.close = my_cursor_close;
/*
* Configure local cursor information.
*/
/* Return combined cursor to WiredTiger. */
*new_cursor = (WT_CURSOR *)cursor;
int(* WT_DATA_SOURCE::range_truncate) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, WT_CURSOR *start, WT_CURSOR *stop)

Callback to truncate a range of an object.

static int
my_range_truncate(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
WT_CURSOR *start, WT_CURSOR *stop)
int(* WT_DATA_SOURCE::rename) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, const char *newuri, WT_CONFIG_ARG *config)

Callback to rename an object.

static int
my_rename(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, const char *newname, WT_CONFIG_ARG *config)
int(* WT_DATA_SOURCE::salvage) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)

Callback to salvage an object.

static int
my_salvage(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, WT_CONFIG_ARG *config)
int(* WT_DATA_SOURCE::terminate) (WT_DATA_SOURCE *dsrc, WT_SESSION *session)

If non-NULL, a callback performed when the database is closed.

The WT_DATA_SOURCE::terminate callback is intended to allow cleanup, the handle will not be subsequently accessed by WiredTiger.

static int
my_terminate(WT_DATA_SOURCE *dsrc, WT_SESSION *session)
int(* WT_DATA_SOURCE::truncate) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)

Callback to truncate an object.

static int
my_truncate(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, WT_CONFIG_ARG *config)
int(* WT_DATA_SOURCE::verify) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)

Callback to verify an object.

static int
my_verify(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, WT_CONFIG_ARG *config)