#include <map.h>
#include <btree_map.h>
#include "map_btree.h"
static int
map_btree_check(PMEMobjpool *pop, TOID(struct map) map)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_check(pop, btree_map);
}
static int
map_btree_create(PMEMobjpool *pop, TOID(struct map) *map, void *arg)
{
TOID(struct btree_map) *btree_map =
(TOID(struct btree_map) *)map;
return btree_map_create(pop, btree_map, arg);
}
static int
map_btree_destroy(PMEMobjpool *pop, TOID(struct map) *map)
{
TOID(struct btree_map) *btree_map =
(TOID(struct btree_map) *)map;
return btree_map_destroy(pop, btree_map);
}
static int
map_btree_insert(PMEMobjpool *pop, TOID(struct map) map,
uint64_t key, PMEMoid value)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_insert(pop, btree_map, key, value);
}
static int
map_btree_insert_new(PMEMobjpool *pop, TOID(struct map) map,
uint64_t key, size_t size,
unsigned type_num,
void (*constructor)(PMEMobjpool *pop, void *ptr, void *arg),
void *arg)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_insert_new(pop, btree_map, key, size,
type_num, constructor, arg);
}
static PMEMoid
map_btree_remove(PMEMobjpool *pop, TOID(struct map) map, uint64_t key)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_remove(pop, btree_map, key);
}
static int
map_btree_remove_free(PMEMobjpool *pop, TOID(struct map) map, uint64_t key)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_remove_free(pop, btree_map, key);
}
static int
map_btree_clear(PMEMobjpool *pop, TOID(struct map) map)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_clear(pop, btree_map);
}
static PMEMoid
map_btree_get(PMEMobjpool *pop, TOID(struct map) map, uint64_t key)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_get(pop, btree_map, key);
}
static int
map_btree_lookup(PMEMobjpool *pop, TOID(struct map) map, uint64_t key)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_lookup(pop, btree_map, key);
}
static int
map_btree_foreach(PMEMobjpool *pop, TOID(struct map) map,
int (*cb)(uint64_t key, PMEMoid value, void *arg),
void *arg)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_foreach(pop, btree_map, cb, arg);
}
static int
map_btree_is_empty(PMEMobjpool *pop, TOID(struct map) map)
{
TOID(struct btree_map) btree_map;
TOID_ASSIGN(btree_map, map.oid);
return btree_map_is_empty(pop, btree_map);
}
struct map_ops btree_map_ops = {
map_btree_check,
map_btree_create,
map_btree_destroy,
NULL,
map_btree_insert,
map_btree_insert_new,
map_btree_remove,
map_btree_remove_free,
map_btree_clear,
map_btree_get,
map_btree_lookup,
map_btree_foreach,
map_btree_is_empty,
NULL,
NULL,
};