WiredTiger: WT_DATA_SOURCE Struct Reference

| Version 3.1.0

Fork me on GitHub Join my user group
List of all members | Public Attributes
WT_DATA_SOURCE Struct Reference
WiredTiger Extension API

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

## Public Attributes
int(* | alter )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)
| Callback to alter an object. More...
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(* | size )(WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, wt_off_t *size)
| Callback to get the size of 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...
int(* | lsm_pre_merge )(WT_DATA_SOURCE *dsrc, WT_CURSOR *source, WT_CURSOR *dest)
| If non-NULL, a callback performed before an LSM merge. 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_alter,
my_create,
my_compact,
my_drop,
my_open_cursor,
my_rename,
my_salvage,
my_size,
my_truncate,
my_range_truncate,
my_verify,
my_checkpoint,
my_terminate,
my_lsm_pre_merge
};
error_check(conn->add_data_source(conn, "dsrc:", &my_dsrc, NULL));

## Member Data Documentation

## ◆ alter

int(* WT_DATA_SOURCE::alter) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, WT_CONFIG_ARG *config)

Callback to alter an object.

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

## ◆ checkpoint

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)

## ◆ compact

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)

## ◆ create

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)

## ◆ drop

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)

## ◆ lsm_pre_merge

int(* WT_DATA_SOURCE::lsm_pre_merge) (WT_DATA_SOURCE *dsrc, WT_CURSOR *source, WT_CURSOR *dest)

If non-NULL, a callback performed before an LSM merge.

Parameters

  [in] | source | a cursor configured with the data being merged
  [in] | dest | a cursor on the new object being filled by the merge

static int
my_lsm_pre_merge(WT_DATA_SOURCE *dsrc, WT_CURSOR *source, WT_CURSOR *dest)

## ◆ open_cursor

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;
int ret;
/* 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;

## ◆ range_truncate

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)

## ◆ rename

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)

## ◆ salvage

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)

## ◆ size

int(* WT_DATA_SOURCE::size) (WT_DATA_SOURCE *dsrc, WT_SESSION *session, const char *uri, wt_off_t *size)

Callback to get the size of an object.

static int
my_size(WT_DATA_SOURCE *dsrc, WT_SESSION *session,
const char *uri, wt_off_t *size)

## ◆ terminate

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)

## ◆ truncate

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)

## ◆ verify

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)