Commit a86d3a3b authored by Yoni Fogel's avatar Yoni Fogel

Addresses #293 Addresses #307

Addresses #337
Makefile modifications, test modifications,
Lock tree is better integraded with db.

git-svn-id: file:///svn/tokudb@2126 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3ce1f7ce
......@@ -8,6 +8,7 @@ OPTFLAGS = -O2
CFLAGS = -W -Wall -Werror -g3 -ggdb3 -fPIC $(OPTFLAGS) $(GCOV_FLAGS)
CPPFLAGS = -I../include -I../newbrt -I./lock_tree/ -I./range_tree/
CPPFLAGS += -D_GNU_SOURCE -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
CPPFLAGS += -L../lib
ifeq ($(OSX),OSX)
......@@ -20,7 +21,7 @@ SHARED=-shared
endif
.PHONY: install logformat
install: logformat rangetree locktree $(LIBNAME).$(LIBEXT) $(LIBNAME).a
install: logformat locktree $(LIBNAME).$(LIBEXT) $(LIBNAME).a
cp $(LIBNAME).$(LIBEXT) ../lib/
cp $(LIBNAME).a ../lib
......@@ -30,9 +31,6 @@ logformat:
locktree:
cd lock_tree;make OSX=$(OSX) OPT=$(OPT) GCOV=$(GCOV)
rangetree:
cd range_tree;make OSX=$(OSX) OPT=$(OPT) GCOV=$(GCOV)
check: $(LIBNAME).$(LIBEXT)
python tokuglobals.py $(LIBNAME).$(LIBEXT)
......@@ -43,20 +41,17 @@ clean:
rm -rf $(LIBNAME).$(LIBEXT) $(LIBNAME).a *.o *.gcno *.gcda *.gcov
cd tests;make clean
cd lock_tree;make clean
cd range_tree;make clean
ydb.o: ../include/db.h ../newbrt/cachetable.h ../newbrt/brt.h ../newbrt/log.c
RANGETREE_BINS = range_tree/linear.o
LOCKTREE_BINS = lock_tree/rth.o lock_tree/locktree.o
DBBINS = ydb.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/fifo.o ../newbrt/key.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/pma.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o ../newbrt/log_code.o ../newbrt/roll.o $(RANGETREE_BINS) $(LOCKTREE_BINS)
DBBINS = ydb.o ../newbrt/brt.o ../newbrt/brt-serialize.o ../newbrt/brt-verify.o ../newbrt/cachetable.o ../newbrt/fifo.o ../newbrt/key.o ../newbrt/memory.o ../newbrt/mempool.o ../newbrt/pma.o ../newbrt/ybt.o ../newbrt/primes.o ../newbrt/log.o ../newbrt/fingerprint.o ../newbrt/log_code.o ../newbrt/roll.o
$(LIBNAME).$(LIBEXT): $(DBBINS)
cc $(CPPFLAGS) $(DBBINS) $(SHARED) -o $@ $(CFLAGS) -lz
cc $(CPPFLAGS) $^ $(SHARED) -o $@ $(CFLAGS) -lz -llocktree_linear
$(LIBNAME).a: $(DBBINS)
$(AR) rv $@ $(DBBINS)
$(LIBNAME).a: $(DBBINS) lock_tree/locktree.o lock_tree/rth.o range_tree/linear.o
$(AR) rv $@ $^
libdb.a(ydb.o): ydb.o
# On OSX do:
# make OSX=OSX
LIBNAME=liblocktree_linear
LIBNAME_LINEAR = liblocktree_linear
LIBNAME_TLOG = liblocktree_tlog
LIBNAME_LOG = liblocktree_log
ifneq ($(OPT),)
OPTFLAGS = -O0 -g3 -ggdb3
......@@ -31,12 +33,20 @@ LIBEXT=so
SHARED=-shared
endif
.PHONY: install logformat
install: $(LIBNAME).$(LIBEXT) $(LIBNAME).a
cp $(LIBNAME).$(LIBEXT) ../../lib/
cp $(LIBNAME).a ../../lib
.PHONY: install logformat range_tree
install: range_tree $(LIBNAME_LINEAR).$(LIBEXT) $(LIBNAME_LINEAR).a #$(LIBNAME_TLOG).$(LIBEXT) $(LIBNAME_TLOG).a $(LIBNAME_LOG).$(LIBEXT) $(LIBNAME_LOG).a
cp $(LIBNAME_LINEAR).$(LIBEXT) ../../lib/
cp $(LIBNAME_LINEAR).a ../../lib
#cp $(LIBNAME_TLOG).$(LIBEXT) ../../lib/
#cp $(LIBNAME_TLOG).a ../../lib
#cp $(LIBNAME_LOG).$(LIBEXT) ../../lib/
#cp $(LIBNAME_LOG).a ../../lib
range_tree:
cd ../range_tree; make
clean:
cd ../range_tree; make clean
rm -rf *.o
rm -rf $(LIBNAME_LINEAR).$(LIBEXT) $(LIBNAME_LINEAR).a
rm -rf $(LIBNAME_TLOG).$(LIBEXT) $(LIBNAME_TLOG).a
......@@ -51,8 +61,21 @@ locktree.o: locktree.c locktree.h
rth.o: rth.c rth.h
gcc $(CFLAGS) $(CPPFLAGS) -DTOKU_RT_LINEAR -c $< -o $@
$(LIBNAME).$(LIBEXT): locktree.o rth.o
$(LIBNAME_LINEAR).$(LIBEXT): locktree.o rth.o
cc $(CPPFLAGS) $^ $(SHARED) -o $@ $(CFLAGS) -lrangetree_linear
$(LIBNAME).a: locktree.o rth.o
$(LIBNAME_LINEAR).a: locktree.o rth.o ../range_tree/linear.o
$(AR) rv $@ $^
$(LIBNAME_TLOG).$(LIBEXT): locktree.o rth.o
cc $(CPPFLAGS) $^ $(SHARED) -o $@ $(CFLAGS) -lrangetree_tlog
$(LIBNAME_TLOG).a: locktree.o rth.o ../range_tree/tlog.o
$(AR) rv $@ $^
$(LIBNAME_LOG).$(LIBEXT): locktree.o rth.o
cc $(CPPFLAGS) $^ $(SHARED) -o $@ $(CFLAGS) -lrangetree_log
$(LIBNAME_LOG).a: locktree.o rth.o ../range_tree/log.o
$(AR) rv $@ $^
......@@ -46,17 +46,6 @@
#include <assert.h>
#include <db.h>
#include <brttypes.h>
#if defined(TOKU_LT_LINEAR)
#define TOKU_RT_LINEAR
#elif defined(TOKU_LT_TLOG)
#define TOKU_RT_TLOG
#elif defined(TOKU_LT_LOG)
#define TOKU_RT_LOG
#else
#error Using an undefined LOCK TREE TYPE.
#endif
#include <rangetree.h>
#include <rth.h>
......
......@@ -41,8 +41,7 @@ int dbcmp (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
BOOL panicked = FALSE;
int dbpanic(DB* db, int r) {
r++;
if (verbose) printf("AHH!!!! Run away %p!!!\n", db);
if (verbose) printf("AHH!!!! %d is rampaging! Run away %p!!!\n", r, db);
panicked = TRUE;
assert(want_panic);
return EINVAL;
......
......@@ -4,13 +4,12 @@ int main() {
int r;
toku_lock_tree* lt = NULL;
DB* db = (DB*)1;
u_int32_t mem = 4096 * 1000;
u_int32_t max_locks = 1000;
u_int32_t memcnt = 0;
BOOL duplicates;
for (duplicates = 0; duplicates < 2; duplicates++) {
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
r = toku_lt_create(&lt, db, duplicates, dbpanic, max_locks, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR(r);
assert(lt);
......
......@@ -52,13 +52,13 @@ clean:
linear.o: linear.c rangetree.h
gcc $(CFLAGS) $(CPPFLAGS) -DTOKU_RT_LINEAR -c $< -o $@
gcc $(CFLAGS) $(CPPFLAGS) -c $< -o $@
log.o: log.c rangetree.h
gcc $(CFLAGS) $(CPPFLAGS) -DTOKU_RT_LOG -c $< -o $@
gcc $(CFLAGS) $(CPPFLAGS) -c $< -o $@
tlog.o: tlog.c rangetree.h
gcc $(CFLAGS) $(CPPFLAGS) -DTOKU_RT_TLOG -c $< -o $@
gcc $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(LIBNAME_TLOG).$(LIBEXT): tlog.o
cc $(CPPFLAGS) $< $(SHARED) -o $@ $(CFLAGS)
......
......@@ -11,12 +11,40 @@
//Currently this is a stub implementation just so we can write and compile tests
//before actually implementing the range tree.
#include "rangetree.h"
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
/** \brief Internal range representation
Internal representation of a range tree. Some fields depend on the
implementation of range trees, and some others are shared. */
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*);
/** A comparison function, as in bsearch(3), to compare the data associated
with a range */
int (*data_cmp)(void*,void*);
/** Whether this tree allows ranges to overlap */
BOOL allow_overlaps;
/** The number of ranges in the range tree */
u_int32_t numelements;
/** The user malloc function */
void* (*malloc) (size_t);
/** The user free function */
void (*free) (void*);
/** The user realloc function */
void* (*realloc)(void*, size_t);
//Linear version only fields:
toku_range* ranges;
u_int32_t ranges_len;
};
static const u_int32_t minlen = 64;
/*
......
......@@ -32,51 +32,11 @@ typedef struct {
void* data; /**< Data associated with the range */
} toku_range;
/** \brief Internal range representation
Internal representation of a range tree. Some fields depend on the
implementation of range trees, and some others are shared. */
struct __toku_range_tree_internal {
//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*);
/** A comparison function, as in bsearch(3), to compare the data associated
with a range */
int (*data_cmp)(void*,void*);
/** Whether this tree allows ranges to overlap */
BOOL allow_overlaps;
/** The number of ranges in the range tree */
u_int32_t numelements;
/** The user malloc function */
void* (*malloc) (size_t);
/** The user free function */
void (*free) (void*);
/** The user realloc function */
void* (*realloc)(void*, size_t);
#if defined(TOKU_RT_LINEAR)
#if defined(TOKU_RT_TLOG) || defined(TOKU_RT_LOG)
#error Choose just one range tree type.
#endif
//Linear version only fields:
toku_range* ranges;
u_int32_t ranges_len;
#elif defined(TOKU_RT_TLOG)
#if defined(TOKU_RT_LOG)
#error Choose just one range tree type.
#endif
#error Not defined yet.
//TLog version only fields:
#elif defined(TOKU_RT_LOG)
#error Not defined yet.
//Log version only fields:
#else
#error Using an undefined RANGE TREE TYPE.
#endif
};
struct __toku_range_tree;
/** Export the internal representation to a sensible name */
/* These lines will remain. */
typedef struct __toku_range_tree_internal toku_range_tree;
typedef struct __toku_range_tree toku_range_tree;
/**
Gets whether the range tree allows overlapping ranges.
......
......@@ -90,11 +90,11 @@ libs:
cd ..;make
%.lin: %.c ../rangetree.h test.h
$(SETENV) cc -DDIR=\"dir.$<.lin\" -DTOKU_RT_LINEAR $(CPPFLAGS) $(CFLAGS) $< -lrangetree_linear -o $@
$(SETENV) cc -DDIR=\"dir.$<.lin\" $(CPPFLAGS) $(CFLAGS) $< -lrangetree_linear -o $@
%.log: %.c ../rangetree.h test.h
$(SETENV) cc -DDIR=\"dir.$<.log\" -DTOKU_RT_LOG $(CPPFLAGS) $(CFLAGS) $< -lrangetree_log -o $@
$(SETENV) cc -DDIR=\"dir.$<.log\" $(CPPFLAGS) $(CFLAGS) $< -lrangetree_log -o $@
%.tlog: %.c ../rangetree.h test.h
$(SETENV) cc -DDIR=\"dir.$<.log\" -DTOKU_RT_TLOG $(CPPFLAGS) $(CFLAGS) $< -lrangetree_tlog -o $@
$(SETENV) cc -DDIR=\"dir.$<.log\" $(CPPFLAGS) $(CFLAGS) $< -lrangetree_tlog -o $@
.PHONY: make_libs
......
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