Commit 4f767ef4 authored by Yoni Fogel's avatar Yoni Fogel

Closes 284

Linear time range tree implementation complete and passes all tests.

git-svn-id: file:///svn/tokudb@1778 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5dfdc1bc
...@@ -6,7 +6,7 @@ LIBNAME=librangetree ...@@ -6,7 +6,7 @@ LIBNAME=librangetree
OPTFLAGS = #-O2 OPTFLAGS = #-O2
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage # GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CFLAGS = -W -Wall -Werror -g -fPIC $(OPTFLAGS) $(GCOV_FLAGS) CFLAGS = -W -Wall -Werror -g3 -ggdb3 -fPIC $(OPTFLAGS) $(GCOV_FLAGS)
CPPFLAGS = -I../../include -I../../newbrt CPPFLAGS = -I../../include -I../../newbrt
#CPPFLAGS += -D_GNU_SOURCE -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE #CPPFLAGS += -D_GNU_SOURCE -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
...@@ -27,7 +27,7 @@ install: $(LIBNAMELINEAR).$(LIBEXT) $(LIBNAMELINEAR).a #$(LIBNAME).$(LIBEXT) $(L ...@@ -27,7 +27,7 @@ install: $(LIBNAMELINEAR).$(LIBEXT) $(LIBNAMELINEAR).a #$(LIBNAME).$(LIBEXT) $(L
cp $(LIBNAMELINEAR).a ../../lib cp $(LIBNAMELINEAR).a ../../lib
clean: clean:
rm -rf $(LIBNAMELINEAR).$(LIBEXT) $(LIBNAMELINEAR) rm -rf $(LIBNAMELINEAR).$(LIBEXT) $(LIBNAMELINEAR).a
rm -rf $(LIBNAME).$(LIBEXT) $(LIBNAME).a *.o *.gcno *.gcda *.gcov rm -rf $(LIBNAME).$(LIBEXT) $(LIBNAME).a *.o *.gcno *.gcda *.gcov
cd tests;make clean cd tests;make clean
......
...@@ -78,15 +78,11 @@ static BOOL __toku_rt_overlap(toku_range_tree* tree, ...@@ -78,15 +78,11 @@ static BOOL __toku_rt_overlap(toku_range_tree* tree,
tree->end_cmp(b->left, a->right) <= 0); tree->end_cmp(b->left, a->right) <= 0);
} }
BOOL __toku_rt_exact(toku_range_tree* tree, static BOOL __toku_rt_exact(toku_range_tree* tree,
toku_range* a, toku_range* b) { toku_range* a, toku_range* b) {
assert(tree); assert(tree);
assert(a); assert(a);
// assert(a->left);
// assert(a->right);
assert(b); assert(b);
// assert(b->left);
// assert(b->right);
return (tree->end_cmp (a->left, b->left) == 0 && return (tree->end_cmp (a->left, b->left) == 0 &&
tree->end_cmp (a->right, b->right) == 0 && tree->end_cmp (a->right, b->right) == 0 &&
tree->data_cmp(a->data, b->data) == 0); tree->data_cmp(a->data, b->data) == 0);
...@@ -174,7 +170,7 @@ int toku_rt_insert(toku_range_tree* tree, toku_range* range) { ...@@ -174,7 +170,7 @@ int toku_rt_insert(toku_range_tree* tree, toku_range* range) {
} }
r = __toku_rt_increase_capacity(tree, tree->numelements + 1); r = __toku_rt_increase_capacity(tree, tree->numelements + 1);
if (r != 0) return r; if (r != 0) return r;
tree->ranges[++tree->numelements] = *range; tree->ranges[tree->numelements++] = *range;
return 0; return 0;
} }
...@@ -189,7 +185,7 @@ int toku_rt_delete(toku_range_tree* tree, toku_range* range) { ...@@ -189,7 +185,7 @@ int toku_rt_delete(toku_range_tree* tree, toku_range* range) {
//EDOM case: Not Found //EDOM case: Not Found
if (i == tree->numelements) return EDOM; if (i == tree->numelements) return EDOM;
if (i < tree->numelements - 1) { if (i < tree->numelements - 1) {
//juggle tree->ranges[i] = tree->ranges[tree->numelements - 1];
} }
__toku_rt_decrease_capacity(tree, --tree->numelements); __toku_rt_decrease_capacity(tree, --tree->numelements);
return 0; return 0;
...@@ -209,7 +205,7 @@ int toku_rt_predecessor (toku_range_tree* tree, void* point, toku_range* pred, ...@@ -209,7 +205,7 @@ int toku_rt_predecessor (toku_range_tree* tree, void* point, toku_range* pred,
} }
} }
*wasfound = best != NULL; *wasfound = best != NULL;
pred = best; if (best) *pred = *best;
return 0; return 0;
} }
...@@ -227,7 +223,7 @@ int toku_rt_successor (toku_range_tree* tree, void* point, toku_range* succ, ...@@ -227,7 +223,7 @@ int toku_rt_successor (toku_range_tree* tree, void* point, toku_range* succ,
} }
} }
*wasfound = best != NULL; *wasfound = best != NULL;
succ = best; if (best) *succ = *best;
return 0; return 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