Commit e0f7e45f authored by Yoni Fogel's avatar Yoni Fogel

Changed range trees to have static types instead of void*

git-svn-id: file:///svn/tokudb@2254 c7de825b-a66e-492c-adef-691d508d4ae1
parent d9f4581b
......@@ -75,18 +75,16 @@ inline static DBT* __toku_recreate_DBT(DBT* dbt, void* payload, u_int32_t length
return dbt;
}
inline static int __toku_lt_txn_cmp(void* a, void* b) {
inline static int __toku_lt_txn_cmp(DB_TXN* a, DB_TXN* b) {
return a < b ? -1 : (a != b);
}
int __toku_lt_point_cmp(void* a, void* b) {
int __toku_lt_point_cmp(toku_point* x, toku_point* y) {
int partial_result;
DBT point_1;
DBT point_2;
assert(a && b);
toku_point* x = (toku_point*)a;
toku_point* y = (toku_point*)b;
assert(x && y);
assert(x->lt);
assert(x->lt == y->lt);
......@@ -171,9 +169,9 @@ inline static int __toku_payload_copy(toku_lock_tree* tree,
return 0;
}
inline static int __toku_p_makecopy(toku_lock_tree* tree, void** ppoint) {
inline static int __toku_p_makecopy(toku_lock_tree* tree, toku_point** ppoint) {
assert(ppoint);
toku_point* point = *(toku_point**)ppoint;
toku_point* point = *ppoint;
toku_point* temp_point = NULL;
int r;
......@@ -1088,9 +1086,8 @@ int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB_TXN* txn,
toku_point right;
toku_range query;
assert(tree);
if (key_left == key_right &&
(data_left == data_right || !tree->duplicates)) {
(data_left == data_right || (tree && !tree->duplicates))) {
return toku_lt_acquire_write_lock(tree, txn, key_left, data_left);
}
......
......@@ -111,14 +111,18 @@ extern const DBT* const toku_lt_neg_infinity; /**< Special value denoting
key_payload = (void*) toku_lt_infinity or
key_payload = (void*) toku_lt_neg infinity
*/
typedef struct {
struct __toku_point {
toku_lock_tree* lt; /**< The lock tree, where toku_lt_point_cmp
is defined */
void* key_payload; /**< The key ... */
u_int32_t key_len; /**< and its length */
void* data_payload; /**< The data ... */
u_int32_t data_len; /**< and its length */
} toku_point;
};
#if !defined(__TOKU_POINT)
#define __TOKU_POINT
typedef struct __toku_point toku_point;
#endif
/**
Create a lock tree. Should be called only inside DB->open.
......
......@@ -25,10 +25,10 @@ struct __toku_range_tree {
//Shared fields:
/** A comparison function, as in bsearch(3), to compare the end-points of
a range. It is assumed to be commutative. */
int (*end_cmp)(void*,void*);
int (*end_cmp)(toku_point*,toku_point*);
/** A comparison function, as in bsearch(3), to compare the data associated
with a range */
int (*data_cmp)(void*,void*);
int (*data_cmp)(DB_TXN*,DB_TXN*);
/** Whether this tree allows ranges to overlap */
BOOL allow_overlaps;
/** The number of ranges in the range tree */
......@@ -54,7 +54,7 @@ static const u_int32_t minlen = 64;
* > 0: Point strictly greater than the range.
*/
static int __toku_rt_p_cmp(toku_range_tree* tree,
void* point, toku_range* range) {
toku_point* point, toku_range* range) {
if (tree->end_cmp(point, range->left) < 0) return -1;
if (tree->end_cmp(point, range->right) > 0) return 1;
return 0;
......@@ -129,7 +129,8 @@ static BOOL __toku_rt_exact(toku_range_tree* tree,
}
int toku_rt_create(toku_range_tree** ptree,
int (*end_cmp)(void*,void*), int (*data_cmp)(void*,void*),
int (*end_cmp)(toku_point*,toku_point*),
int (*data_cmp)(DB_TXN*,DB_TXN*),
BOOL allow_overlaps,
void* (*user_malloc) (size_t),
void (*user_free) (void*),
......@@ -237,8 +238,8 @@ int toku_rt_delete(toku_range_tree* tree, toku_range* range) {
return 0;
}
int toku_rt_predecessor (toku_range_tree* tree, void* point, toku_range* pred,
BOOL* wasfound) {
int toku_rt_predecessor (toku_range_tree* tree, toku_point* point,
toku_range* pred, BOOL* wasfound) {
if (!tree || !point || !pred || !wasfound) return EINVAL;
if (tree->allow_overlaps) return EINVAL;
toku_range* best = NULL;
......@@ -255,8 +256,8 @@ int toku_rt_predecessor (toku_range_tree* tree, void* point, toku_range* pred,
return 0;
}
int toku_rt_successor (toku_range_tree* tree, void* point, toku_range* succ,
BOOL* wasfound) {
int toku_rt_successor (toku_range_tree* tree, toku_point* point,
toku_range* succ, BOOL* wasfound) {
if (!tree || !point || !succ || !wasfound) return EINVAL;
if (tree->allow_overlaps) return EINVAL;
toku_range* best = NULL;
......
......@@ -20,6 +20,13 @@
//Defines BOOL data type.
#include <brttypes.h>
#include <db.h>
struct __toku_point;
#if !defined(__TOKU_POINT)
#define __TOKU_POINT
typedef struct __toku_point toku_point;
#endif
/** \brief Range with value
Represents a range of data with an associated value.
......@@ -27,9 +34,9 @@
buf and buflen.
*/
typedef struct {
void* left; /**< Left end-point */
void* right; /**< Right end-point */
void* data; /**< Data associated with the range */
toku_point* left; /**< Left end-point */
toku_point* right; /**< Right end-point */
DB_TXN* data; /**< Data associated with the range */
} toku_range;
struct __toku_range_tree;
......@@ -68,8 +75,9 @@ int toku_rt_get_allow_overlaps(toku_range_tree* tree, BOOL* allowed);
- 0: Success.
- EINVAL: If any pointer argument is NULL.
- Other exit codes may be forwarded from underlying system calls. */
int toku_rt_create(toku_range_tree** ptree, int (*end_cmp)(void*,void*),
int (*data_cmp)(void*,void*), BOOL allow_overlaps,
int toku_rt_create(toku_range_tree** ptree,
int (*end_cmp)(toku_point*,toku_point*),
int (*data_cmp)(DB_TXN*,DB_TXN*), BOOL allow_overlaps,
void* (*user_malloc) (size_t),
void (*user_free) (void*),
void* (*user_realloc)(void*, size_t));
......@@ -167,8 +175,8 @@ int toku_rt_delete(toku_range_tree* tree, toku_range* range);
If tree allows overlaps.
- Other exit codes may be forwarded from underlying system calls.
*/
int toku_rt_predecessor(toku_range_tree* tree, void* point, toku_range* pred,
BOOL* wasfound);
int toku_rt_predecessor(toku_range_tree* tree, toku_point* point,
toku_range* pred, BOOL* wasfound);
/**
Finds the strict successor range of a point i.e. the leftmost range
......@@ -189,8 +197,8 @@ int toku_rt_predecessor(toku_range_tree* tree, void* point, toku_range* pred,
If tree allows overlaps.
- Other exit codes may be forwarded from underlying system calls.
*/
int toku_rt_successor(toku_range_tree* tree, void* point, toku_range* succ,
BOOL* wasfound);
int toku_rt_successor(toku_range_tree* tree, toku_point* point,
toku_range* succ, BOOL* wasfound);
u_int32_t toku_rt_get_size(toku_range_tree *);
......
......@@ -40,22 +40,22 @@ static inline uint32_t myrandom (void) {
}
int dummy_cmp(void *a __attribute__((__unused__)),
void *b __attribute__((__unused__))) {
int dummy_cmp(toku_point *a __attribute__((__unused__)),
toku_point *b __attribute__((__unused__))) {
return 0;
}
int ptr_cmp(void *a, void *b) {
int ptr_cmp(DB_TXN* a, DB_TXN* b) {
return a < b ? -1 : (a != b); /* \marginpar{!?} */
}
int int_cmp(void *a, void *b) {
int int_cmp(toku_point* a, toku_point*b) {
int x = *(int*)a;
int y = *(int*)b;
return x -y;
}
int char_cmp(void *a, void *b) {
int char_cmp(DB_TXN *a, DB_TXN *b) {
int x = *(char*)a;
int y = *(char*)b;
return x -y;
......
......@@ -11,7 +11,7 @@ int main(int argc, const char *argv[]) {
parse_args(argc, argv);
for (allow_overlaps = 0; allow_overlaps < 2; allow_overlaps++) {
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, allow_overlaps, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, char_cmp, allow_overlaps, malloc, free, realloc);
CKERR(r);
assert(tree!=NULL);
......@@ -30,7 +30,7 @@ int main(int argc, const char *argv[]) {
for (i = 1; i <= 2; i++) {
mallocced = 0;
failon = i;
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, allow_overlaps,
r = toku_rt_create(&tree, int_cmp, char_cmp, allow_overlaps,
fail_malloc, free, realloc);
CKERR2(r, ENOMEM);
......
......@@ -10,24 +10,24 @@ int main(int argc, const char *argv[]) {
parse_args(argc, argv);
/* Create tests */
r = toku_rt_create(NULL, dummy_cmp, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(NULL, int_cmp, ptr_cmp, FALSE, malloc, free, realloc);
CKERR2(r, EINVAL);
r = toku_rt_create(&tree, NULL, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, NULL, ptr_cmp, FALSE, malloc, free, realloc);
CKERR2(r, EINVAL);
assert(tree == NULL);
r = toku_rt_create(&tree, dummy_cmp, NULL, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, NULL, FALSE, malloc, free, realloc);
CKERR2(r, EINVAL);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, NULL, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, NULL, free, realloc);
CKERR2(r, EINVAL);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, NULL, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, NULL, realloc);
CKERR2(r, EINVAL);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, free, NULL);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, free, NULL);
CKERR2(r, EINVAL);
assert(tree == NULL);
......@@ -40,7 +40,7 @@ int main(int argc, const char *argv[]) {
r = toku_rt_insert(NULL, &range);
CKERR2(r, EINVAL);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
......@@ -53,7 +53,7 @@ int main(int argc, const char *argv[]) {
r = toku_rt_delete(NULL, &range);
CKERR2(r, EINVAL);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
......@@ -66,11 +66,11 @@ int main(int argc, const char *argv[]) {
unsigned found;
int stuff[3] = {0,1,2};
range.left = &stuff[0];
range.right = &stuff[1];
range.data = NULL;
range.left = (toku_point*)&stuff[0];
range.right = (toku_point*)&stuff[1];
range.data = NULL;
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
......@@ -80,7 +80,7 @@ int main(int argc, const char *argv[]) {
r = toku_rt_find(tree, NULL, 2, &buf, &bufsize, &found);
CKERR2(r, EINVAL);
range.data = &stuff[2];
range.data = (DB_TXN*)&stuff[2];
r = toku_rt_find(tree, &range, 2, &buf, &bufsize, &found);
CKERR2(r, EINVAL);
range.data = NULL;
......@@ -103,60 +103,60 @@ int main(int argc, const char *argv[]) {
r = toku_rt_close(tree); CKERR(r);
/* Predecessor tests */
int foo;
toku_point* foo;
BOOL wasfound;
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
r = toku_rt_predecessor(NULL, &foo, &range, &wasfound);
r = toku_rt_predecessor(NULL, foo, &range, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_predecessor(tree, NULL, &range, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_predecessor(tree, &foo, NULL, &wasfound);
r = toku_rt_predecessor(tree, foo, NULL, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_predecessor(tree, &foo, &range, NULL);
r = toku_rt_predecessor(tree, foo, &range, NULL);
CKERR2(r, EINVAL);
r = toku_rt_close(tree); CKERR(r);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, TRUE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, TRUE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
r = toku_rt_predecessor(tree, &foo, &range, &wasfound);
r = toku_rt_predecessor(tree, foo, &range, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_close(tree); CKERR(r);
/* Successor tests */
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
r = toku_rt_successor(NULL, &foo, &range, &wasfound);
r = toku_rt_successor(NULL, foo, &range, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_successor(tree, NULL, &range, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_successor(tree, &foo, NULL, &wasfound);
r = toku_rt_successor(tree, foo, NULL, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_successor(tree, &foo, &range, NULL);
r = toku_rt_successor(tree, foo, &range, NULL);
CKERR2(r, EINVAL);
r = toku_rt_close(tree); CKERR(r);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, TRUE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, TRUE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
r = toku_rt_successor(tree, &foo, &range, &wasfound);
r = toku_rt_successor(tree, foo, &range, &wasfound);
CKERR2(r, EINVAL);
r = toku_rt_close(tree); CKERR(r);
......@@ -169,7 +169,7 @@ int main(int argc, const char *argv[]) {
r = toku_rt_get_allow_overlaps(NULL, &allowed);
CKERR2(r, EINVAL);
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE, malloc, free, realloc);
r = toku_rt_create(&tree, int_cmp, ptr_cmp, FALSE, malloc, free, realloc);
CKERR(r);
assert(tree != NULL);
......
......@@ -24,79 +24,79 @@ int main(int argc, const char *argv[]) {
CKERR(r);
/* Verify we can insert a trivial range and lose it. */
range.left = &nums[1];
range.right = &nums[1];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[1];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
u_int32_t num_in_range = toku_rt_get_size(tree);
assert(num_in_range == 1);
r = toku_rt_delete(tree, &range); CKERR(r);
range.left = &nums[1];
range.right = &nums[5];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[5];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
/* Try and fail to insert exact same thing. */
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
/* Try and succeed to insert (and delete) similar yet different things */
range.right = &nums[6];
range.right = (toku_point*)&nums[6];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_delete(tree, &range); CKERR(r);
range.right = &nums[5];
range.data = &letters[1];
range.right = (toku_point*)&nums[5];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_delete(tree, &range); CKERR(r);
range.data = &letters[0];
range.data = (DB_TXN*)&letters[0];
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
range.left = &nums[3];
range.right = &nums[7];
range.data = &letters[0];
range.left = (toku_point*)&nums[3];
range.right = (toku_point*)&nums[7];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR(r);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Try to delete again, make sure it fails. (Not there anymore) */
r = toku_rt_delete(tree, &range); CKERR2(r,EDOM);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Clean up. */
range.left = &nums[1];
range.right = &nums[5];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[5];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
range.left = &nums[3];
range.right = &nums[7];
range.data = &letters[0];
range.left = (toku_point*)&nums[3];
range.right = (toku_point*)&nums[7];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Done */
......@@ -114,60 +114,60 @@ int main(int argc, const char *argv[]) {
CKERR(r);
/* Verify we can insert a trivial range and lose it. */
range.left = &nums[1];
range.right = &nums[1];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[1];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_delete(tree, &range); CKERR(r);
range.left = &nums[1];
range.right = &nums[3];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[3];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
/* Try and fail to insert exact same thing. */
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
/* Try (and fail) to insert an overlapping range in a nooverlap tree. */
range.left = &nums[0];
range.right = &nums[4];
range.data = &letters[0];
range.left = (toku_point*)&nums[0];
range.right = (toku_point*)&nums[4];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
/* Try (and fail) to insert an overlapping range (different data) in a
nooverlap tree. */
range.left = &nums[0];
range.right = &nums[4];
range.data = &letters[1];
range.left = (toku_point*)&nums[0];
range.right = (toku_point*)&nums[4];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR(r);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Try to delete again, make sure it fails. (Not there anymore) */
r = toku_rt_delete(tree, &range); CKERR2(r,EDOM);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR(r);
range.left = &nums[1];
range.right = &nums[3];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[3];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Clean up. */
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Done */
......
......@@ -36,18 +36,18 @@ int main(int argc, const char *argv[]) {
/* Insert lots of ranges */
for (i = 0; i < 512; i++) {
j = i + i;
range.left = &nums[j];
range.right = &nums[j+1];
range.data = &letters[0];
range.left = (toku_point*)&nums[j];
range.right = (toku_point*)&nums[j+1];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
}
/* Decrease lots of ranges */
for (i = 0; i < 512; i++) {
j = i + i;
range.left = &nums[j];
range.right = &nums[j+1];
range.data = &letters[0];
range.left = (toku_point*)&nums[j];
range.right = (toku_point*)&nums[j+1];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
}
......
......@@ -20,9 +20,9 @@ int main(int argc, const char *argv[]) {
r = toku_rt_create(&tree, int_cmp, char_cmp, TRUE, malloc, free, realloc);
CKERR(r);
range.left = &nums[1];
range.right = &nums[5];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[5];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_close(tree); CKERR(r);
......@@ -37,9 +37,9 @@ int main(int argc, const char *argv[]) {
r = toku_rt_create(&tree, int_cmp, char_cmp, FALSE, malloc, free, realloc);
CKERR(r);
range.left = &nums[1];
range.right = &nums[5];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[5];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_close(tree); CKERR(r);
......
......@@ -26,8 +26,8 @@ int main(int argc, const char *argv[]) {
parse_args(argc, argv);
find_range.left = &nums[4];
find_range.right = &nums[4];
find_range.left = (toku_point*)&nums[4];
find_range.right = (toku_point*)&nums[4];
find_range.data = NULL;
/* Test overlap case */
......@@ -45,9 +45,9 @@ int main(int argc, const char *argv[]) {
assert(found == 0);
assert(bufsize == 2);
range.left = &nums[1];
range.right = &nums[5];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[5];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -55,9 +55,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize == 2);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -65,9 +65,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize == 2);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[3];
range.right = &nums[7];
range.data = &letters[0];
range.left = (toku_point*)&nums[3];
range.right = (toku_point*)&nums[7];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
/* Now that we find 3, we are testing that realloc works. */
......@@ -76,9 +76,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 3);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -87,9 +87,9 @@ int main(int argc, const char *argv[]) {
verify_all_overlap(&find_range, buf, found);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -104,9 +104,9 @@ int main(int argc, const char *argv[]) {
*(char*)buf[i].data == letters[1]);
}
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -114,9 +114,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 4);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -132,9 +132,9 @@ int main(int argc, const char *argv[]) {
}
/* Clean up. */
range.left = &nums[1];
range.right = &nums[5];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[5];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -142,9 +142,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 4);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
range.left = (toku_point*)&nums[2];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -157,9 +157,9 @@ int main(int argc, const char *argv[]) {
*(int*)buf[0].right == 7 &&
*(char*)buf[0].data == letters[0]);
range.left = &nums[3];
range.right = &nums[7];
range.data = &letters[0];
range.left = (toku_point*)&nums[3];
range.right = (toku_point*)&nums[7];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -180,8 +180,8 @@ int main(int argc, const char *argv[]) {
|---A---|
|---B---|
*/
find_range.left = &nums[3];
find_range.right = &nums[4];
find_range.left = (toku_point*)&nums[3];
find_range.right = (toku_point*)&nums[4];
find_range.data = NULL;
r = toku_rt_create(&tree, int_cmp, char_cmp, TRUE, malloc, free, realloc);
......@@ -192,9 +192,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 4);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[1];
range.right = &nums[3];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[3];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -202,9 +202,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 4);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -212,9 +212,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 4);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -227,9 +227,9 @@ int main(int argc, const char *argv[]) {
*(int*)buf[0].right == 3 &&
*(char*)buf[0].data == letters[0]);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_insert(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -237,9 +237,9 @@ int main(int argc, const char *argv[]) {
assert(bufsize >= 4);
verify_all_overlap(&find_range, buf, found);
range.left = &nums[1];
range.right = &nums[3];
range.data = &letters[0];
range.left = (toku_point*)&nums[1];
range.right = (toku_point*)&nums[3];
range.data = (DB_TXN*)&letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......@@ -253,9 +253,9 @@ int main(int argc, const char *argv[]) {
*(char*)buf[0].data == letters[1]);
/* Clean up. */
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
range.left = (toku_point*)&nums[4];
range.right = (toku_point*)&nums[6];
range.data = (DB_TXN*)&letters[1];
r = toku_rt_delete(tree, &range); CKERR(r);
r = toku_rt_find(tree, &find_range, 4, &buf, &bufsize, &found); CKERR(r);
......
......@@ -20,10 +20,10 @@ toku_range* buf;
unsigned buflen;
toku_range* init_range(toku_range* range, int left, int right, int data) {
range->left = &nums[left];
range->right = &nums[right];
range->left = (toku_point*)&nums[left];
range->right = (toku_point*)&nums[right];
if (data < 0) range->data = NULL;
else range->data = &letters[data];
else range->data = (DB_TXN*)&letters[data];
return range;
}
......
......@@ -20,10 +20,10 @@ toku_range* buf;
unsigned buflen;
toku_range* init_range(toku_range* range, int left, int right, int data) {
range->left = &nums[left];
range->right = &nums[right];
range->left = (toku_point*)&nums[left];
range->right = (toku_point*)&nums[right];
if (data < 0) range->data = NULL;
else range->data = &letters[data];
else range->data = (DB_TXN*)&letters[data];
return range;
}
......
......@@ -22,10 +22,10 @@ unsigned buflen;
toku_range* init_range(toku_range* range, unsigned left, unsigned right,
int data) {
range->left = &nums[left];
range->right = &nums[right];
range->left = (toku_point*)&nums[left];
range->right = (toku_point*)&nums[right];
if (data < 0) range->data = NULL;
else range->data = &letters[data];
else range->data = (DB_TXN*)&letters[data];
return range;
}
......
......@@ -18,16 +18,16 @@ toku_range* buf;
unsigned buflen;
toku_range* init_range(toku_range* range, int left, int right, int data) {
range->left = &nums[left];
range->right = &nums[right];
range->left = (toku_point*)&nums[left];
range->right = (toku_point*)&nums[right];
if (data < 0) range->data = NULL;
else range->data = &letters[data];
else range->data = (DB_TXN*)&letters[data];
return range;
}
void* init_point(unsigned left) {
assert(left < sizeof(nums) / sizeof(nums[0]));
return (&nums[left]);
return ((toku_point*)&nums[left]);
}
void setup_tree(BOOL allow_overlaps, BOOL insert, int left, int right, int data) {
......@@ -94,9 +94,9 @@ void runtest(predsucc testtype, void* query, BOOL findexpect,
CKERR(r);
assert(found == findexpect);
if (findexpect) {
assert(int_cmp(out.left, &nums[left]) == 0);
assert(int_cmp(out.right, &nums[right]) == 0);
assert(char_cmp(out.data, &letters[data]) == 0);
assert(int_cmp(out.left, (toku_point*)&nums[left]) == 0);
assert(int_cmp(out.right, (toku_point*)&nums[right]) == 0);
assert(char_cmp(out.data, (DB_TXN*)&letters[data]) == 0);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment