Commit 1faeb23d authored by Yoni Fogel's avatar Yoni Fogel

Addresses #293


git-svn-id: file:///svn/tokudb@1857 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6b65971b
...@@ -6,7 +6,7 @@ LIBNAME=liblocktree ...@@ -6,7 +6,7 @@ LIBNAME=liblocktree
OPTFLAGS = #-O2 OPTFLAGS = #-O2
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage # GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CFLAGS = -W -Wall -Werror -g3 -ggdb3 -fPIC $(OPTFLAGS) $(GCOV_FLAGS) CFLAGS = -W -Wall -Werror -g3 -ggdb3 -fPIC $(OPTFLAGS) $(GCOV_FLAGS)
CPPFLAGS = -I. -I.. -I../range_tree -I../../include -I../../newbrt CPPFLAGS = -I. -I.. -I../range_tree -I../../include -I../../newbrt -L../range_tree
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
ifeq ($(OSX),OSX) ifeq ($(OSX),OSX)
...@@ -33,7 +33,7 @@ locktree.o: locktree.c locktree.h ...@@ -33,7 +33,7 @@ locktree.o: locktree.c locktree.h
gcc $(CFLAGS) $(CPPFLAGS) -c -DTOKU_LINEAR_RANGE_TREE $< -o $@ gcc $(CFLAGS) $(CPPFLAGS) -c -DTOKU_LINEAR_RANGE_TREE $< -o $@
$(LIBNAME).$(LIBEXT): locktree.o $(LIBNAME).$(LIBEXT): locktree.o
cc $(CPPFLAGS) $< $(SHARED) -o $@ $(CFLAGS) -lz cc $(CPPFLAGS) $< $(SHARED) -o $@ $(CFLAGS) -lrangetreelinear
$(LIBNAME).a: log.o $(LIBNAME).a: locktree.o
$(AR) rv $@ $< $(AR) rv $@ $<
This diff is collapsed.
...@@ -20,13 +20,20 @@ typedef struct { ...@@ -20,13 +20,20 @@ typedef struct {
toku_range* buf; toku_range* buf;
unsigned buflen; unsigned buflen;
BOOL panicked; BOOL panicked;
int (*compare_fun)(DB*,const DBT*,const DBT*);
int (*dup_compare)(DB*,const DBT*,const DBT*);
/** The user malloc function */
void* (*malloc) (size_t);
/** The user free function */
void (*free) (void*);
/** The user realloc function */
void* (*realloc)(void*, size_t);
} toku_lock_tree; } toku_lock_tree;
#warning TODO: Handle 'panicked' variable in every api call.
extern const DBT* const toku_lt_infinity; extern const DBT* const toku_lt_infinity;
extern const DBT* const toku_lt_neg_infinity; extern const DBT* const toku_lt_neg_infinity;
const unsigned __toku_default_buflen = 2;
/* /*
* key_data = (void*)toku_lt_infinity is how we refer to the infinities. * key_data = (void*)toku_lt_infinity is how we refer to the infinities.
*/ */
...@@ -52,11 +59,12 @@ int __toku_lt_point_cmp(void* a, void* b); ...@@ -52,11 +59,12 @@ int __toku_lt_point_cmp(void* a, void* b);
* Params: * Params:
* ptree: We set *ptree to the newly allocated tree. * ptree: We set *ptree to the newly allocated tree.
* db: This is the db that the lock tree will be performing locking for. * db: This is the db that the lock tree will be performing locking for.
* We will get flags to determine if it is a nodup or dupsort db. * duplicates whether the db supports duplicates.
* db should NOT be opened yet, but should have the DB_DUPSORT flag * compare_fun the key compare function.
* set appropriately. * dup_compare the data compare function.
* We will use the key compare (and if appropriate the data compare) \param user_malloc A user provided malloc(3) function.
* functions in order to understand ranges. \param user_free A user provided free(3) function.
\param user_realloc A user provided realloc(3) function.
* Returns: * Returns:
* 0: Success * 0: Success
* EINVAL: If (ptree == NULL || db == NULL). * EINVAL: If (ptree == NULL || db == NULL).
...@@ -67,7 +75,13 @@ int __toku_lt_point_cmp(void* a, void* b); ...@@ -67,7 +75,13 @@ int __toku_lt_point_cmp(void* a, void* b);
* The EINVAL cases described will use assert to abort instead of returning errors. * The EINVAL cases described will use assert to abort instead of returning errors.
* If this library is ever exported to users, we will use error datas instead. * If this library is ever exported to users, we will use error datas instead.
*/ */
int toku_lt_create(toku_lock_tree** ptree, DB* db); int toku_lt_create(toku_lock_tree** ptree, DB* db, BOOL duplicates,
int (*compare_fun)(DB*,const DBT*,const DBT*),
int (*dup_compare)(DB*,const DBT*,const DBT*),
void* (*user_malloc) (size_t),
void (*user_free) (void*),
void* (*user_realloc)(void*, size_t));
/* /*
* Closes/Frees a lock tree. * Closes/Frees a lock tree.
...@@ -76,7 +90,6 @@ int toku_lt_create(toku_lock_tree** ptree, DB* db); ...@@ -76,7 +90,6 @@ int toku_lt_create(toku_lock_tree** ptree, DB* db);
* Returns: * Returns:
* 0: Success. * 0: Success.
* EINVAL: If (tree == NULL) * EINVAL: If (tree == NULL)
* May return other errors due to system calls.
* Asserts: * Asserts:
* The EINVAL cases described will use assert to abort instead of returning errors. * The EINVAL cases described will use assert to abort instead of returning errors.
* If this library is ever exported to users, we will use error datas instead. * If this library is ever exported to users, we will use error datas instead.
...@@ -118,7 +131,8 @@ int toku_lt_close(toku_lock_tree* tree); ...@@ -118,7 +131,8 @@ int toku_lt_close(toku_lock_tree* tree);
* to its local memory. * to its local memory.
* *** Note that txn == NULL is not supported at this time. * *** Note that txn == NULL is not supported at this time.
*/ */
int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB_TXN* txn, DBT* key, DBT* data); int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB_TXN* txn,
const DBT* key, const DBT* data);
//In BDB, txn can actually be NULL (mixed operations with transactions and no transactions). //In BDB, txn can actually be NULL (mixed operations with transactions and no transactions).
//This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use //This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use
...@@ -163,8 +177,8 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB_TXN* txn, DBT* key, DBT* ...@@ -163,8 +177,8 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB_TXN* txn, DBT* key, DBT*
* *** Note that txn == NULL is not supported at this time. * *** Note that txn == NULL is not supported at this time.
*/ */
int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB_TXN* txn, int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB_TXN* txn,
DBT* key_left, DBT* data_left, const DBT* key_left, const DBT* data_left,
DBT* key_right, DBT* data_right); const DBT* key_right, const DBT* data_right);
//In BDB, txn can actually be NULL (mixed operations with transactions and no transactions). //In BDB, txn can actually be NULL (mixed operations with transactions and no transactions).
//This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use //This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use
...@@ -196,7 +210,8 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB_TXN* txn, ...@@ -196,7 +210,8 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB_TXN* txn,
* to its local memory. * to its local memory.
* *** Note that txn == NULL is not supported at this time. * *** Note that txn == NULL is not supported at this time.
*/ */
int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB_TXN* txn, DBT* key, DBT* data); int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB_TXN* txn,
const DBT* key, const DBT* data);
//In BDB, txn can actually be NULL (mixed operations with transactions and no transactions). //In BDB, txn can actually be NULL (mixed operations with transactions and no transactions).
//This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use //This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use
...@@ -246,8 +261,8 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB_TXN* txn, DBT* key, DBT* ...@@ -246,8 +261,8 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB_TXN* txn, DBT* key, DBT*
* *** Note that txn == NULL is not supported at this time. * *** Note that txn == NULL is not supported at this time.
*/ */
int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB_TXN* txn, int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB_TXN* txn,
DBT* key_left, DBT* data_left, const DBT* key_left, const DBT* data_left,
DBT* key_right, DBT* data_right); const DBT* key_right, const DBT* data_right);
//In BDB, txn can actually be NULL (mixed operations with transactions and no transactions). //In BDB, txn can actually be NULL (mixed operations with transactions and no transactions).
//This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use //This can cause conflicts, I was unable (so far) to verify that MySQL does or does not use
......
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