Shows how to extend WiredTiger with application-specific collations, extractors and cursor types.
#include <stdio.h>
#include <string.h>
#include <wiredtiger.h>
const char *home = NULL;
static int
{
const char *s1 = (
const char *)v1->
data;
const char *s2 = (
const char *)v2->
data;
(void)session;
(void)collator;
*cmp = strcasecmp(s1, s2);
return (0);
}
static WT_COLLATOR nocasecoll = { __compare_nocase, NULL };
typedef struct {
uint32_t maxlen;
} PREFIX_COLLATOR;
static int
{
PREFIX_COLLATOR *pcoll = (PREFIX_COLLATOR *)collator;
const char *s1 = (
const char *)v1->
data;
const char *s2 = (
const char *)v2->
data;
(void)session;
*cmp = strncmp(s1, s2, pcoll->maxlen);
return (0);
}
static PREFIX_COLLATOR pcoll10 = { {__compare_prefixes, NULL}, 10 };
int main(void)
{
int ret;
fprintf(stderr, "Error connecting to %s: %s\n",
ret = conn->
add_collator(conn,
"nocase", &nocasecoll, NULL);
ret = conn->
add_collator(conn,
"prefix10", &pcoll10.iface, NULL);
if ((ret = conn->
open_session(conn, NULL, NULL, &session)) != 0)
fprintf(stderr, "Error opening a session on %s: %s\n",
if ((ret = conn->
close(conn, NULL)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
return (ret);
}