Shows how to extend WiredTiger with application-specific collations, extractors and cursor types.
#include <test_util.h>
static const char *home;
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, 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, NULL}, 10 };
int
main(int argc, char *argv[])
{
home = example_setup(argc, argv);
error_check(conn->
add_collator(conn,
"nocase", &nocasecoll, NULL));
error_check(conn->
add_collator(conn,
"prefix10", &pcoll10.iface, NULL));
error_check(conn->
open_session(conn, NULL, NULL, &session));
error_check(conn->
close(conn, NULL));
return (EXIT_SUCCESS);
}