Commit 407226d3 authored by John Esmet's avatar John Esmet

FT-299 Clean up XIDs abstraction

parent 3806aa6a
...@@ -2384,7 +2384,7 @@ static void ft_txn_log_insert(FT ft, DBT *key, DBT *val, TOKUTXN txn, bool do_lo ...@@ -2384,7 +2384,7 @@ static void ft_txn_log_insert(FT ft, DBT *key, DBT *val, TOKUTXN txn, bool do_lo
int toku_ft_insert_unique(FT_HANDLE ft_h, DBT *key, DBT *val, TOKUTXN txn, bool do_logging) { int toku_ft_insert_unique(FT_HANDLE ft_h, DBT *key, DBT *val, TOKUTXN txn, bool do_logging) {
// Effect: Insert a unique key-val pair into the fractal tree. // Effect: Insert a unique key-val pair into the fractal tree.
// Return: 0 on success, DB_KEYEXIST if the overwrite constraint failed // Return: 0 on success, DB_KEYEXIST if the overwrite constraint failed
XIDS message_xids = txn != nullptr ? toku_txn_get_xids(txn) : xids_get_root_xids(); XIDS message_xids = txn != nullptr ? toku_txn_get_xids(txn) : toku_xids_get_root_xids();
TXN_MANAGER txn_manager = toku_ft_get_txn_manager(ft_h); TXN_MANAGER txn_manager = toku_ft_get_txn_manager(ft_h);
txn_manager_state txn_state_for_gc(txn_manager); txn_manager_state txn_state_for_gc(txn_manager);
...@@ -2457,13 +2457,13 @@ void toku_ft_optimize (FT_HANDLE ft_h) { ...@@ -2457,13 +2457,13 @@ void toku_ft_optimize (FT_HANDLE ft_h) {
if (logger) { if (logger) {
TXNID oldest = toku_txn_manager_get_oldest_living_xid(logger->txn_manager); TXNID oldest = toku_txn_manager_get_oldest_living_xid(logger->txn_manager);
XIDS root_xids = xids_get_root_xids(); XIDS root_xids = toku_xids_get_root_xids();
XIDS message_xids; XIDS message_xids;
if (oldest == TXNID_NONE_LIVING) { if (oldest == TXNID_NONE_LIVING) {
message_xids = root_xids; message_xids = root_xids;
} }
else { else {
int r = xids_create_child(root_xids, &message_xids, oldest); int r = toku_xids_create_child(root_xids, &message_xids, oldest);
invariant(r == 0); invariant(r == 0);
} }
...@@ -2483,7 +2483,7 @@ void toku_ft_optimize (FT_HANDLE ft_h) { ...@@ -2483,7 +2483,7 @@ void toku_ft_optimize (FT_HANDLE ft_h) {
oldest_referenced_xid_estimate, oldest_referenced_xid_estimate,
true); true);
toku_ft_root_put_msg(ft_h->ft, msg, &gc_info); toku_ft_root_put_msg(ft_h->ft, msg, &gc_info);
xids_destroy(&message_xids); toku_xids_destroy(&message_xids);
} }
} }
...@@ -2570,7 +2570,7 @@ void toku_ft_maybe_insert (FT_HANDLE ft_h, DBT *key, DBT *val, TOKUTXN txn, bool ...@@ -2570,7 +2570,7 @@ void toku_ft_maybe_insert (FT_HANDLE ft_h, DBT *key, DBT *val, TOKUTXN txn, bool
if (oplsn_valid && oplsn.lsn <= (treelsn = toku_ft_checkpoint_lsn(ft_h->ft)).lsn) { if (oplsn_valid && oplsn.lsn <= (treelsn = toku_ft_checkpoint_lsn(ft_h->ft)).lsn) {
// do nothing // do nothing
} else { } else {
XIDS message_xids = txn ? toku_txn_get_xids(txn) : xids_get_root_xids(); XIDS message_xids = txn ? toku_txn_get_xids(txn) : toku_xids_get_root_xids();
TXN_MANAGER txn_manager = toku_ft_get_txn_manager(ft_h); TXN_MANAGER txn_manager = toku_ft_get_txn_manager(ft_h);
txn_manager_state txn_state_for_gc(txn_manager); txn_manager_state txn_state_for_gc(txn_manager);
...@@ -2641,7 +2641,7 @@ void toku_ft_maybe_update(FT_HANDLE ft_h, const DBT *key, const DBT *update_func ...@@ -2641,7 +2641,7 @@ void toku_ft_maybe_update(FT_HANDLE ft_h, const DBT *key, const DBT *update_func
if (oplsn_valid && oplsn.lsn <= (treelsn = toku_ft_checkpoint_lsn(ft_h->ft)).lsn) { if (oplsn_valid && oplsn.lsn <= (treelsn = toku_ft_checkpoint_lsn(ft_h->ft)).lsn) {
// do nothing // do nothing
} else { } else {
XIDS message_xids = txn ? toku_txn_get_xids(txn) : xids_get_root_xids(); XIDS message_xids = txn ? toku_txn_get_xids(txn) : toku_xids_get_root_xids();
ft_msg msg(key, update_function_extra, FT_UPDATE, ZERO_MSN, message_xids); ft_msg msg(key, update_function_extra, FT_UPDATE, ZERO_MSN, message_xids);
ft_send_update_msg(ft_h, msg, txn); ft_send_update_msg(ft_h, msg, txn);
} }
...@@ -2674,7 +2674,7 @@ void toku_ft_maybe_update_broadcast(FT_HANDLE ft_h, const DBT *update_function_e ...@@ -2674,7 +2674,7 @@ void toku_ft_maybe_update_broadcast(FT_HANDLE ft_h, const DBT *update_function_e
} else { } else {
DBT empty_dbt; DBT empty_dbt;
XIDS message_xids = txn ? toku_txn_get_xids(txn) : xids_get_root_xids(); XIDS message_xids = txn ? toku_txn_get_xids(txn) : toku_xids_get_root_xids();
ft_msg msg(toku_init_dbt(&empty_dbt), update_function_extra, FT_UPDATE_BROADCAST_ALL, ZERO_MSN, message_xids); ft_msg msg(toku_init_dbt(&empty_dbt), update_function_extra, FT_UPDATE_BROADCAST_ALL, ZERO_MSN, message_xids);
ft_send_update_msg(ft_h, msg, txn); ft_send_update_msg(ft_h, msg, txn);
} }
...@@ -2726,7 +2726,7 @@ toku_ft_log_del_multiple (TOKUTXN txn, FT_HANDLE src_ft, FT_HANDLE *fts, uint32_ ...@@ -2726,7 +2726,7 @@ toku_ft_log_del_multiple (TOKUTXN txn, FT_HANDLE src_ft, FT_HANDLE *fts, uint32_
} }
void toku_ft_maybe_delete(FT_HANDLE ft_h, DBT *key, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging) { void toku_ft_maybe_delete(FT_HANDLE ft_h, DBT *key, TOKUTXN txn, bool oplsn_valid, LSN oplsn, bool do_logging) {
XIDS message_xids = xids_get_root_xids(); //By default use committed messages XIDS message_xids = toku_xids_get_root_xids(); //By default use committed messages
TXNID_PAIR xid = toku_txn_get_txnid(txn); TXNID_PAIR xid = toku_txn_get_txnid(txn);
if (txn) { if (txn) {
BYTESTRING keybs = {key->size, (char *) key->data}; BYTESTRING keybs = {key->size, (char *) key->data};
...@@ -4474,7 +4474,7 @@ toku_dump_ftnode (FILE *file, FT_HANDLE ft_handle, BLOCKNUM blocknum, int depth, ...@@ -4474,7 +4474,7 @@ toku_dump_ftnode (FILE *file, FT_HANDLE ft_handle, BLOCKNUM blocknum, int depth,
int operator()(const ft_msg &msg, bool UU(is_fresh)) { int operator()(const ft_msg &msg, bool UU(is_fresh)) {
fprintf(file, "%*s xid=%" PRIu64 " %u (type=%d) msn=0x%" PRIu64 "\n", fprintf(file, "%*s xid=%" PRIu64 " %u (type=%d) msn=0x%" PRIu64 "\n",
depth+2, "", depth+2, "",
xids_get_innermost_xid(msg.xids()), toku_xids_get_innermost_xid(msg.xids()),
static_cast<unsigned>(toku_dtoh32(*(int*)msg.kdbt()->data)), static_cast<unsigned>(toku_dtoh32(*(int*)msg.kdbt()->data)),
msg.type(), msg.msn().msn); msg.type(), msg.msn().msn);
return 0; return 0;
......
...@@ -226,7 +226,7 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, const ...@@ -226,7 +226,7 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, const
DBT kdbt, vdbt; DBT kdbt, vdbt;
ft_msg msg(toku_fill_dbt(&kdbt, key, keylen), toku_fill_dbt(&vdbt, val, vallen), ft_msg msg(toku_fill_dbt(&kdbt, key, keylen), toku_fill_dbt(&vdbt, val, vallen),
FT_INSERT, next_dummymsn(), xids_get_root_xids()); FT_INSERT, next_dummymsn(), toku_xids_get_root_xids());
static size_t zero_flow_deltas[] = { 0, 0 }; static size_t zero_flow_deltas[] = { 0, 0 };
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, true); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, true);
...@@ -299,7 +299,7 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, en ...@@ -299,7 +299,7 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, en
DBT k; DBT k;
int childnum = toku_ftnode_which_child(node, toku_fill_dbt(&k, key, keylen), ft_handle->ft->cmp); int childnum = toku_ftnode_which_child(node, toku_fill_dbt(&k, key, keylen), ft_handle->ft->cmp);
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
toku::comparator cmp; toku::comparator cmp;
cmp.create(testhelper_string_key_cmp, nullptr); cmp.create(testhelper_string_key_cmp, nullptr);
......
...@@ -2349,12 +2349,12 @@ static struct leaf_buf *start_leaf (struct dbout *out, const DESCRIPTOR UU(desc) ...@@ -2349,12 +2349,12 @@ static struct leaf_buf *start_leaf (struct dbout *out, const DESCRIPTOR UU(desc)
lbuf->nkeys = lbuf->ndata = lbuf->dsize = 0; lbuf->nkeys = lbuf->ndata = lbuf->dsize = 0;
lbuf->off = 0; lbuf->off = 0;
lbuf->xids = xids_get_root_xids(); lbuf->xids = toku_xids_get_root_xids();
if (xid != TXNID_NONE) { if (xid != TXNID_NONE) {
XIDS new_xids = NULL; XIDS new_xids = NULL;
int r = xids_create_child(lbuf->xids, &new_xids, xid); int r = toku_xids_create_child(lbuf->xids, &new_xids, xid);
assert(r == 0 && new_xids); assert(r == 0 && new_xids);
xids_destroy(&lbuf->xids); toku_xids_destroy(&lbuf->xids);
lbuf->xids = new_xids; lbuf->xids = new_xids;
} }
...@@ -2988,7 +2988,7 @@ static void finish_leafnode (struct dbout *out, struct leaf_buf *lbuf, int progr ...@@ -2988,7 +2988,7 @@ static void finish_leafnode (struct dbout *out, struct leaf_buf *lbuf, int progr
toku_free(serialized_leaf); toku_free(serialized_leaf);
} }
toku_ftnode_free(&lbuf->node); toku_ftnode_free(&lbuf->node);
xids_destroy(&lbuf->xids); toku_xids_destroy(&lbuf->xids);
toku_free(lbuf); toku_free(lbuf);
//printf("Nodewrite %d (%.1f%%):", progress_allocation, 100.0*progress_allocation/PROGRESS_MAX); //printf("Nodewrite %d (%.1f%%):", progress_allocation, 100.0*progress_allocation/PROGRESS_MAX);
......
...@@ -106,7 +106,7 @@ ft_msg ft_msg::deserialize_from_rbuf(struct rbuf *rb, XIDS *x, bool *is_fresh) { ...@@ -106,7 +106,7 @@ ft_msg ft_msg::deserialize_from_rbuf(struct rbuf *rb, XIDS *x, bool *is_fresh) {
enum ft_msg_type t = (enum ft_msg_type) rbuf_char(rb); enum ft_msg_type t = (enum ft_msg_type) rbuf_char(rb);
*is_fresh = rbuf_char(rb); *is_fresh = rbuf_char(rb);
MSN m = rbuf_MSN(rb); MSN m = rbuf_MSN(rb);
xids_create_from_buffer(rb, x); toku_xids_create_from_buffer(rb, x);
rbuf_bytes(rb, &keyp, &keylen); rbuf_bytes(rb, &keyp, &keylen);
rbuf_bytes(rb, &valp, &vallen); rbuf_bytes(rb, &valp, &vallen);
...@@ -118,7 +118,7 @@ ft_msg ft_msg::deserialize_from_rbuf_v13(struct rbuf *rb, MSN m, XIDS *x) { ...@@ -118,7 +118,7 @@ ft_msg ft_msg::deserialize_from_rbuf_v13(struct rbuf *rb, MSN m, XIDS *x) {
const void *keyp, *valp; const void *keyp, *valp;
uint32_t keylen, vallen; uint32_t keylen, vallen;
enum ft_msg_type t = (enum ft_msg_type) rbuf_char(rb); enum ft_msg_type t = (enum ft_msg_type) rbuf_char(rb);
xids_create_from_buffer(rb, x); toku_xids_create_from_buffer(rb, x);
rbuf_bytes(rb, &keyp, &keylen); rbuf_bytes(rb, &keyp, &keylen);
rbuf_bytes(rb, &valp, &vallen); rbuf_bytes(rb, &valp, &vallen);
...@@ -156,7 +156,7 @@ size_t ft_msg::total_size() const { ...@@ -156,7 +156,7 @@ size_t ft_msg::total_size() const {
static const size_t total_overhead = key_val_overhead + msg_overhead; static const size_t total_overhead = key_val_overhead + msg_overhead;
const size_t keyval_size = _key.size + _val.size; const size_t keyval_size = _key.size + _val.size;
const size_t xids_size = xids_get_serialize_size(xids()); const size_t xids_size = toku_xids_get_serialize_size(xids());
return total_overhead + keyval_size + xids_size; return total_overhead + keyval_size + xids_size;
} }
......
...@@ -99,6 +99,8 @@ PATENT RIGHTS GRANT: ...@@ -99,6 +99,8 @@ PATENT RIGHTS GRANT:
#include "portability/toku_assert.h" #include "portability/toku_assert.h"
#include "portability/toku_stdint.h" #include "portability/toku_stdint.h"
#include "ft/xids.h"
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." #ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." #ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
...@@ -194,8 +196,6 @@ ft_msg_type_does_nothing(enum ft_msg_type type) ...@@ -194,8 +196,6 @@ ft_msg_type_does_nothing(enum ft_msg_type type)
return (type == FT_NONE); return (type == FT_NONE);
} }
typedef struct xids_t *XIDS;
class ft_msg { class ft_msg {
public: public:
ft_msg(const DBT *key, const DBT *val, enum ft_msg_type t, MSN m, XIDS x); ft_msg(const DBT *key, const DBT *val, enum ft_msg_type t, MSN m, XIDS x);
......
...@@ -148,7 +148,7 @@ void message_buffer::deserialize_from_rbuf(struct rbuf *rb, ...@@ -148,7 +148,7 @@ void message_buffer::deserialize_from_rbuf(struct rbuf *rb,
} }
enqueue(msg, is_fresh, dest); enqueue(msg, is_fresh, dest);
xids_destroy(&xids); toku_xids_destroy(&xids);
} }
invariant(_num_entries == n_in_this_buffer); invariant(_num_entries == n_in_this_buffer);
...@@ -193,7 +193,7 @@ MSN message_buffer::deserialize_from_rbuf_v13(struct rbuf *rb, ...@@ -193,7 +193,7 @@ MSN message_buffer::deserialize_from_rbuf_v13(struct rbuf *rb,
} }
enqueue(msg, is_fresh, dest); enqueue(msg, is_fresh, dest);
xids_destroy(&xids); toku_xids_destroy(&xids);
} }
return highest_msn_in_this_buffer; return highest_msn_in_this_buffer;
...@@ -230,9 +230,9 @@ void message_buffer::enqueue(const ft_msg &msg, bool is_fresh, int32_t *offset) ...@@ -230,9 +230,9 @@ void message_buffer::enqueue(const ft_msg &msg, bool is_fresh, int32_t *offset)
struct buffer_entry *entry = get_buffer_entry(_memory_used); struct buffer_entry *entry = get_buffer_entry(_memory_used);
entry->type = (unsigned char) msg.type(); entry->type = (unsigned char) msg.type();
entry->msn = msg.msn(); entry->msn = msg.msn();
xids_cpy(&entry->xids_s, msg.xids()); toku_xids_cpy(&entry->xids_s, msg.xids());
entry->is_fresh = is_fresh; entry->is_fresh = is_fresh;
unsigned char *e_key = xids_get_end_of_array(&entry->xids_s); unsigned char *e_key = toku_xids_get_end_of_array(&entry->xids_s);
entry->keylen = keylen; entry->keylen = keylen;
memcpy(e_key, msg.kdbt()->data, keylen); memcpy(e_key, msg.kdbt()->data, keylen);
entry->vallen = datalen; entry->vallen = datalen;
...@@ -261,7 +261,7 @@ ft_msg message_buffer::get_message(int32_t offset, DBT *keydbt, DBT *valdbt) con ...@@ -261,7 +261,7 @@ ft_msg message_buffer::get_message(int32_t offset, DBT *keydbt, DBT *valdbt) con
enum ft_msg_type type = (enum ft_msg_type) entry->type; enum ft_msg_type type = (enum ft_msg_type) entry->type;
MSN msn = entry->msn; MSN msn = entry->msn;
const XIDS xids = (XIDS) &entry->xids_s; const XIDS xids = (XIDS) &entry->xids_s;
const void *key = xids_get_end_of_array(xids); const void *key = toku_xids_get_end_of_array(xids);
const void *val = (uint8_t *) key + entry->keylen; const void *val = (uint8_t *) key + entry->keylen;
return ft_msg(toku_fill_dbt(keydbt, key, keylen), toku_fill_dbt(valdbt, val, vallen), type, msn, xids); return ft_msg(toku_fill_dbt(keydbt, key, keylen), toku_fill_dbt(valdbt, val, vallen), type, msn, xids);
} }
...@@ -269,7 +269,7 @@ ft_msg message_buffer::get_message(int32_t offset, DBT *keydbt, DBT *valdbt) con ...@@ -269,7 +269,7 @@ ft_msg message_buffer::get_message(int32_t offset, DBT *keydbt, DBT *valdbt) con
void message_buffer::get_message_key_msn(int32_t offset, DBT *key, MSN *msn) const { void message_buffer::get_message_key_msn(int32_t offset, DBT *key, MSN *msn) const {
struct buffer_entry *entry = get_buffer_entry(offset); struct buffer_entry *entry = get_buffer_entry(offset);
if (key != nullptr) { if (key != nullptr) {
toku_fill_dbt(key, xids_get_end_of_array((XIDS) &entry->xids_s), entry->keylen); toku_fill_dbt(key, toku_xids_get_end_of_array((XIDS) &entry->xids_s), entry->keylen);
} }
if (msn != nullptr) { if (msn != nullptr) {
*msn = entry->msn; *msn = entry->msn;
...@@ -313,6 +313,6 @@ void message_buffer::serialize_to_wbuf(struct wbuf *wb) const { ...@@ -313,6 +313,6 @@ void message_buffer::serialize_to_wbuf(struct wbuf *wb) const {
size_t message_buffer::msg_memsize_in_buffer(const ft_msg &msg) { size_t message_buffer::msg_memsize_in_buffer(const ft_msg &msg) {
const uint32_t keylen = msg.kdbt()->size; const uint32_t keylen = msg.kdbt()->size;
const uint32_t datalen = msg.vdbt()->size; const uint32_t datalen = msg.vdbt()->size;
const size_t xidslen = xids_get_size(msg.xids()); const size_t xidslen = toku_xids_get_size(msg.xids());
return sizeof(struct buffer_entry) + keylen + datalen + xidslen - sizeof(XIDS_S); return sizeof(struct buffer_entry) + keylen + datalen + xidslen - sizeof(XIDS_S);
} }
...@@ -90,7 +90,6 @@ PATENT RIGHTS GRANT: ...@@ -90,7 +90,6 @@ PATENT RIGHTS GRANT:
#include "ft/msg.h" #include "ft/msg.h"
#include "ft/xids.h" #include "ft/xids.h"
#include "ft/xids-internal.h"
#include "ft/ybt.h" #include "ft/ybt.h"
class message_buffer { class message_buffer {
......
...@@ -273,7 +273,7 @@ static int do_insertion (enum ft_msg_type type, FILENUM filenum, BYTESTRING key, ...@@ -273,7 +273,7 @@ static int do_insertion (enum ft_msg_type type, FILENUM filenum, BYTESTRING key,
!txn->for_recovery); !txn->for_recovery);
toku_ft_root_put_msg(ft, msg, &gc_info); toku_ft_root_put_msg(ft, msg, &gc_info);
if (reset_root_xid_that_created) { if (reset_root_xid_that_created) {
TXNID new_root_xid_that_created = xids_get_outermost_xid(xids); TXNID new_root_xid_that_created = toku_xids_get_outermost_xid(xids);
toku_reset_root_xid_that_created(ft, new_root_xid_that_created); toku_reset_root_xid_that_created(ft, new_root_xid_that_created);
} }
} }
......
...@@ -127,9 +127,9 @@ run_test(unsigned long eltsize, unsigned long nodesize, unsigned long repeat) ...@@ -127,9 +127,9 @@ run_test(unsigned long eltsize, unsigned long nodesize, unsigned long repeat)
*p = (rand() & 0xff); *p = (rand() & 0xff);
} }
} }
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123; XIDS xids_123;
int r = xids_create_child(xids_0, &xids_123, (TXNID)123); int r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
NONLEAF_CHILDINFO bnc; NONLEAF_CHILDINFO bnc;
......
...@@ -126,9 +126,9 @@ test_enqueue(int n) { ...@@ -126,9 +126,9 @@ test_enqueue(int n) {
char *theval = buildval(thevallen); char *theval = buildval(thevallen);
XIDS xids; XIDS xids;
if (i == 0) { if (i == 0) {
xids = xids_get_root_xids(); xids = toku_xids_get_root_xids();
} else { } else {
int r = xids_create_child(xids_get_root_xids(), &xids, (TXNID)i); int r = toku_xids_create_child(toku_xids_get_root_xids(), &xids, (TXNID)i);
assert_zero(r); assert_zero(r);
} }
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
...@@ -138,7 +138,7 @@ test_enqueue(int n) { ...@@ -138,7 +138,7 @@ test_enqueue(int n) {
DBT k, v; DBT k, v;
ft_msg msg(toku_fill_dbt(&k, thekey, thekeylen), toku_fill_dbt(&v, theval, thevallen), type, msn, xids); ft_msg msg(toku_fill_dbt(&k, thekey, thekeylen), toku_fill_dbt(&v, theval, thevallen), type, msn, xids);
msg_buffer.enqueue(msg, true, nullptr); msg_buffer.enqueue(msg, true, nullptr);
xids_destroy(&xids); toku_xids_destroy(&xids);
toku_free(thekey); toku_free(thekey);
toku_free(theval); toku_free(theval);
} }
...@@ -163,7 +163,7 @@ test_enqueue(int n) { ...@@ -163,7 +163,7 @@ test_enqueue(int n) {
assert((int) msg.kdbt()->size == thekeylen); assert(memcmp(msg.kdbt()->data, thekey, msg.kdbt()->size) == 0); assert((int) msg.kdbt()->size == thekeylen); assert(memcmp(msg.kdbt()->data, thekey, msg.kdbt()->size) == 0);
assert((int) msg.vdbt()->size == thevallen); assert(memcmp(msg.vdbt()->data, theval, msg.vdbt()->size) == 0); assert((int) msg.vdbt()->size == thevallen); assert(memcmp(msg.vdbt()->data, theval, msg.vdbt()->size) == 0);
assert(i % 256 == (int)type); assert(i % 256 == (int)type);
assert((TXNID)i==xids_get_innermost_xid(msg.xids())); assert((TXNID)i == toku_xids_get_innermost_xid(msg.xids()));
i += 1; i += 1;
toku_free(thekey); toku_free(thekey);
toku_free(theval); toku_free(theval);
......
...@@ -396,19 +396,19 @@ test_prefetching(void) { ...@@ -396,19 +396,19 @@ test_prefetching(void) {
set_BNC(&sn, 1, toku_create_empty_nl()); set_BNC(&sn, 1, toku_create_empty_nl());
set_BNC(&sn, 2, toku_create_empty_nl()); set_BNC(&sn, 2, toku_create_empty_nl());
//Create XIDS //Create XIDS
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123; XIDS xids_123;
XIDS xids_234; XIDS xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_123, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_123, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
// data in the buffers does not matter in this test // data in the buffers does not matter in this test
//Cleanup: //Cleanup:
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
FT_HANDLE XMALLOC(ft); FT_HANDLE XMALLOC(ft);
FT XCALLOC(ft_h); FT XCALLOC(ft_h);
......
...@@ -324,12 +324,12 @@ test_serialize_nonleaf(void) { ...@@ -324,12 +324,12 @@ test_serialize_nonleaf(void) {
set_BNC(&sn, 0, toku_create_empty_nl()); set_BNC(&sn, 0, toku_create_empty_nl());
set_BNC(&sn, 1, toku_create_empty_nl()); set_BNC(&sn, 1, toku_create_empty_nl());
//Create XIDS //Create XIDS
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123; XIDS xids_123;
XIDS xids_234; XIDS xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_123, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_123, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
toku::comparator cmp; toku::comparator cmp;
...@@ -340,9 +340,9 @@ test_serialize_nonleaf(void) { ...@@ -340,9 +340,9 @@ test_serialize_nonleaf(void) {
toku_bnc_insert_msg(BNC(&sn, 1), "x", 2, "xval", 5, FT_NONE, next_dummymsn(), xids_234, true, cmp); toku_bnc_insert_msg(BNC(&sn, 1), "x", 2, "xval", 5, FT_NONE, next_dummymsn(), xids_234, true, cmp);
//Cleanup: //Cleanup:
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
cmp.destroy(); cmp.destroy();
FT_HANDLE XMALLOC(ft); FT_HANDLE XMALLOC(ft);
......
...@@ -314,9 +314,9 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy, int ser_runs, int ...@@ -314,9 +314,9 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy, int ser_runs, int
set_BNC(&sn, i, toku_create_empty_nl()); set_BNC(&sn, i, toku_create_empty_nl());
} }
//Create XIDS //Create XIDS
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123; XIDS xids_123;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
toku::comparator cmp; toku::comparator cmp;
cmp.create(long_key_cmp, nullptr); cmp.create(long_key_cmp, nullptr);
...@@ -344,8 +344,8 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy, int ser_runs, int ...@@ -344,8 +344,8 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy, int ser_runs, int
} }
//Cleanup: //Cleanup:
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
cmp.destroy(); cmp.destroy();
FT_HANDLE XMALLOC(ft); FT_HANDLE XMALLOC(ft);
......
...@@ -1041,12 +1041,12 @@ test_serialize_nonleaf(enum ftnode_verify_type bft, bool do_clone) { ...@@ -1041,12 +1041,12 @@ test_serialize_nonleaf(enum ftnode_verify_type bft, bool do_clone) {
set_BNC(&sn, 0, toku_create_empty_nl()); set_BNC(&sn, 0, toku_create_empty_nl());
set_BNC(&sn, 1, toku_create_empty_nl()); set_BNC(&sn, 1, toku_create_empty_nl());
//Create XIDS //Create XIDS
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123; XIDS xids_123;
XIDS xids_234; XIDS xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_123, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_123, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
toku::comparator cmp; toku::comparator cmp;
...@@ -1057,9 +1057,9 @@ test_serialize_nonleaf(enum ftnode_verify_type bft, bool do_clone) { ...@@ -1057,9 +1057,9 @@ test_serialize_nonleaf(enum ftnode_verify_type bft, bool do_clone) {
toku_bnc_insert_msg(BNC(&sn, 1), "x", 2, "xval", 5, FT_NONE, next_dummymsn(), xids_234, true, cmp); toku_bnc_insert_msg(BNC(&sn, 1), "x", 2, "xval", 5, FT_NONE, next_dummymsn(), xids_234, true, cmp);
//Cleanup: //Cleanup:
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
cmp.destroy(); cmp.destroy();
FT_HANDLE XMALLOC(ft); FT_HANDLE XMALLOC(ft);
......
...@@ -125,7 +125,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -125,7 +125,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
// apply an insert to the leaf node // apply an insert to the leaf node
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
toku_ft_bn_apply_msg_once(BLB(leafnode,0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode,0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
leafnode->max_msn_applied_to_node_on_disk = msn; leafnode->max_msn_applied_to_node_on_disk = msn;
...@@ -152,7 +152,7 @@ insert_into_child_buffer(FT_HANDLE ft, FTNODE node, int childnum, int minkey, in ...@@ -152,7 +152,7 @@ insert_into_child_buffer(FT_HANDLE ft, FTNODE node, int childnum, int minkey, in
unsigned int key = htonl(val); unsigned int key = htonl(val);
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key); DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
DBT theval; toku_fill_dbt(&theval, &val, sizeof val); DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
toku_ft_append_to_child_buffer(ft->ft->cmp, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval); toku_ft_append_to_child_buffer(ft->ft->cmp, node, childnum, FT_INSERT, msn, toku_xids_get_root_xids(), true, &thekey, &theval);
node->max_msn_applied_to_node_on_disk = msn; node->max_msn_applied_to_node_on_disk = msn;
} }
} }
......
...@@ -131,7 +131,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val ...@@ -131,7 +131,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val
// apply an insert to the leaf node // apply an insert to the leaf node
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
ft->ft->h->max_msn_in_ft = msn; ft->ft->h->max_msn_in_ft = msn;
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg, &gc_info, nullptr, nullptr); toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg, &gc_info, nullptr, nullptr);
...@@ -141,7 +141,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val ...@@ -141,7 +141,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val
assert(pair.call_count==1); assert(pair.call_count==1);
} }
ft_msg badmsg(&thekey, &badval, FT_INSERT, msn, xids_get_root_xids()); ft_msg badmsg(&thekey, &badval, FT_INSERT, msn, toku_xids_get_root_xids());
toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, badmsg, &gc_info, nullptr, nullptr); toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, badmsg, &gc_info, nullptr, nullptr);
// message should be rejected for duplicate msn, row should still have original val // message should be rejected for duplicate msn, row should still have original val
...@@ -154,7 +154,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val ...@@ -154,7 +154,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val
// now verify that message with proper msn gets through // now verify that message with proper msn gets through
msn = next_dummymsn(); msn = next_dummymsn();
ft->ft->h->max_msn_in_ft = msn; ft->ft->h->max_msn_in_ft = msn;
ft_msg msg2(&thekey, &val2, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg2(&thekey, &val2, FT_INSERT, msn, toku_xids_get_root_xids());
toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg2, &gc_info, nullptr, nullptr); toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg2, &gc_info, nullptr, nullptr);
// message should be accepted, val should have new value // message should be accepted, val should have new value
...@@ -166,7 +166,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val ...@@ -166,7 +166,7 @@ append_leaf(FT_HANDLE ft, FTNODE leafnode, void *key, uint32_t keylen, void *val
// now verify that message with lesser (older) msn is rejected // now verify that message with lesser (older) msn is rejected
msn.msn = msn.msn - 10; msn.msn = msn.msn - 10;
ft_msg msg3(&thekey, &badval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg3(&thekey, &badval, FT_INSERT, msn, toku_xids_get_root_xids());
toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg3, &gc_info, nullptr, nullptr); toku_ft_leaf_apply_msg(ft->ft->cmp, ft->ft->update_fun, leafnode, -1, msg3, &gc_info, nullptr, nullptr);
// message should be rejected, val should still have value in pair2 // message should be rejected, val should still have value in pair2
......
...@@ -306,11 +306,11 @@ flush_to_internal(FT_HANDLE t) { ...@@ -306,11 +306,11 @@ flush_to_internal(FT_HANDLE t) {
memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0])); memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0]));
memset(child_messages_is_fresh, 0, 4096*(sizeof child_messages_is_fresh[0])); memset(child_messages_is_fresh, 0, 4096*(sizeof child_messages_is_fresh[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_0, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_0, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
NONLEAF_CHILDINFO child_bnc = toku_create_empty_nl(); NONLEAF_CHILDINFO child_bnc = toku_create_empty_nl();
...@@ -369,7 +369,7 @@ flush_to_internal(FT_HANDLE t) { ...@@ -369,7 +369,7 @@ flush_to_internal(FT_HANDLE t) {
assert(found == 0); assert(found == 0);
assert(dummy_cmp(&valdbt, parent_messages[k]->vdbt()) == 0); assert(dummy_cmp(&valdbt, parent_messages[k]->vdbt()) == 0);
assert(type == parent_messages[k]->type()); assert(type == parent_messages[k]->type());
assert(xids_get_innermost_xid(xids) == xids_get_innermost_xid(parent_messages[k]->xids())); assert(toku_xids_get_innermost_xid(xids) == toku_xids_get_innermost_xid(parent_messages[k]->xids()));
assert(parent_messages_is_fresh[k] == is_fresh); assert(parent_messages_is_fresh[k] == is_fresh);
parent_messages_present[k]++; parent_messages_present[k]++;
found++; found++;
...@@ -382,7 +382,7 @@ flush_to_internal(FT_HANDLE t) { ...@@ -382,7 +382,7 @@ flush_to_internal(FT_HANDLE t) {
assert(found == 0); assert(found == 0);
assert(dummy_cmp(&valdbt, child_messages[k]->vdbt()) == 0); assert(dummy_cmp(&valdbt, child_messages[k]->vdbt()) == 0);
assert(type == child_messages[k]->type()); assert(type == child_messages[k]->type());
assert(xids_get_innermost_xid(xids) == xids_get_innermost_xid(child_messages[k]->xids())); assert(toku_xids_get_innermost_xid(xids) == toku_xids_get_innermost_xid(child_messages[k]->xids()));
assert(child_messages_is_fresh[k] == is_fresh); assert(child_messages_is_fresh[k] == is_fresh);
child_messages_present[k]++; child_messages_present[k]++;
found++; found++;
...@@ -402,9 +402,9 @@ flush_to_internal(FT_HANDLE t) { ...@@ -402,9 +402,9 @@ flush_to_internal(FT_HANDLE t) {
assert(child_messages_present[i] == 1); assert(child_messages_present[i] == 1);
} }
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
toku_free(parent_messages[i]->kdbt()->data); toku_free(parent_messages[i]->kdbt()->data);
...@@ -436,11 +436,11 @@ flush_to_internal_multiple(FT_HANDLE t) { ...@@ -436,11 +436,11 @@ flush_to_internal_multiple(FT_HANDLE t) {
memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0])); memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0]));
memset(child_messages_is_fresh, 0, 4096*(sizeof child_messages_is_fresh[0])); memset(child_messages_is_fresh, 0, 4096*(sizeof child_messages_is_fresh[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_0, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_0, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
NONLEAF_CHILDINFO child_bncs[8]; NONLEAF_CHILDINFO child_bncs[8];
...@@ -525,7 +525,7 @@ flush_to_internal_multiple(FT_HANDLE t) { ...@@ -525,7 +525,7 @@ flush_to_internal_multiple(FT_HANDLE t) {
assert(found == 0); assert(found == 0);
assert(dummy_cmp(&valdbt, parent_messages[_i]->vdbt()) == 0); assert(dummy_cmp(&valdbt, parent_messages[_i]->vdbt()) == 0);
assert(type == parent_messages[_i]->type()); assert(type == parent_messages[_i]->type());
assert(xids_get_innermost_xid(xids) == xids_get_innermost_xid(parent_messages[_i]->xids())); assert(toku_xids_get_innermost_xid(xids) == toku_xids_get_innermost_xid(parent_messages[_i]->xids()));
assert(parent_messages_is_fresh[_i] == is_fresh); assert(parent_messages_is_fresh[_i] == is_fresh);
parent_messages_present[_i]++; parent_messages_present[_i]++;
found++; found++;
...@@ -538,7 +538,7 @@ flush_to_internal_multiple(FT_HANDLE t) { ...@@ -538,7 +538,7 @@ flush_to_internal_multiple(FT_HANDLE t) {
assert(found == 0); assert(found == 0);
assert(dummy_cmp(&valdbt, child_messages[_i]->vdbt()) == 0); assert(dummy_cmp(&valdbt, child_messages[_i]->vdbt()) == 0);
assert(type == child_messages[_i]->type()); assert(type == child_messages[_i]->type());
assert(xids_get_innermost_xid(xids) == xids_get_innermost_xid(child_messages[_i]->xids())); assert(toku_xids_get_innermost_xid(xids) == toku_xids_get_innermost_xid(child_messages[_i]->xids()));
assert(child_messages_is_fresh[_i] == is_fresh); assert(child_messages_is_fresh[_i] == is_fresh);
child_messages_present[_i]++; child_messages_present[_i]++;
found++; found++;
...@@ -559,9 +559,9 @@ flush_to_internal_multiple(FT_HANDLE t) { ...@@ -559,9 +559,9 @@ flush_to_internal_multiple(FT_HANDLE t) {
assert(child_messages_present[i] == 1); assert(child_messages_present[i] == 1);
} }
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
toku_free(parent_messages[i]->kdbt()->data); toku_free(parent_messages[i]->kdbt()->data);
...@@ -605,11 +605,11 @@ flush_to_leaf(FT_HANDLE t, bool make_leaf_up_to_date, bool use_flush) { ...@@ -605,11 +605,11 @@ flush_to_leaf(FT_HANDLE t, bool make_leaf_up_to_date, bool use_flush) {
int *MALLOC_N(4096,parent_messages_applied); int *MALLOC_N(4096,parent_messages_applied);
memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0])); memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_0, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_0, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
BASEMENTNODE child_blbs[8]; BASEMENTNODE child_blbs[8];
...@@ -788,9 +788,9 @@ flush_to_leaf(FT_HANDLE t, bool make_leaf_up_to_date, bool use_flush) { ...@@ -788,9 +788,9 @@ flush_to_leaf(FT_HANDLE t, bool make_leaf_up_to_date, bool use_flush) {
assert(child_messages_present[i] == 1); assert(child_messages_present[i] == 1);
} }
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
toku_free(parent_messages[i]->kdbt()->data); toku_free(parent_messages[i]->kdbt()->data);
...@@ -834,11 +834,11 @@ flush_to_leaf_with_keyrange(FT_HANDLE t, bool make_leaf_up_to_date) { ...@@ -834,11 +834,11 @@ flush_to_leaf_with_keyrange(FT_HANDLE t, bool make_leaf_up_to_date) {
int *MALLOC_N(4096,parent_messages_applied); int *MALLOC_N(4096,parent_messages_applied);
memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0])); memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_0, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_0, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
BASEMENTNODE child_blbs[8]; BASEMENTNODE child_blbs[8];
...@@ -975,9 +975,9 @@ flush_to_leaf_with_keyrange(FT_HANDLE t, bool make_leaf_up_to_date) { ...@@ -975,9 +975,9 @@ flush_to_leaf_with_keyrange(FT_HANDLE t, bool make_leaf_up_to_date) {
} }
} }
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
toku_free(parent_messages[i]->kdbt()->data); toku_free(parent_messages[i]->kdbt()->data);
...@@ -1023,11 +1023,11 @@ compare_apply_and_flush(FT_HANDLE t, bool make_leaf_up_to_date) { ...@@ -1023,11 +1023,11 @@ compare_apply_and_flush(FT_HANDLE t, bool make_leaf_up_to_date) {
int *MALLOC_N(4096,parent_messages_applied); int *MALLOC_N(4096,parent_messages_applied);
memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0])); memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = toku_xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
r = xids_create_child(xids_0, &xids_123, (TXNID)123); r = toku_xids_create_child(xids_0, &xids_123, (TXNID)123);
CKERR(r); CKERR(r);
r = xids_create_child(xids_0, &xids_234, (TXNID)234); r = toku_xids_create_child(xids_0, &xids_234, (TXNID)234);
CKERR(r); CKERR(r);
BASEMENTNODE child1_blbs[8], child2_blbs[8]; BASEMENTNODE child1_blbs[8], child2_blbs[8];
...@@ -1168,9 +1168,9 @@ compare_apply_and_flush(FT_HANDLE t, bool make_leaf_up_to_date) { ...@@ -1168,9 +1168,9 @@ compare_apply_and_flush(FT_HANDLE t, bool make_leaf_up_to_date) {
} }
} }
xids_destroy(&xids_0); toku_xids_destroy(&xids_0);
xids_destroy(&xids_123); toku_xids_destroy(&xids_123);
xids_destroy(&xids_234); toku_xids_destroy(&xids_234);
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
toku_free(parent_messages[i]->kdbt()->data); toku_free(parent_messages[i]->kdbt()->data);
......
...@@ -132,14 +132,14 @@ run_test(void) { ...@@ -132,14 +132,14 @@ run_test(void) {
// test case where we apply a message and the innermost child_id // test case where we apply a message and the innermost child_id
// is the same as the innermost committed TXNID // is the same as the innermost committed TXNID
XIDS root_xids = xids_get_root_xids(); XIDS root_xids = toku_xids_get_root_xids();
TXNID root_txnid = 1000; TXNID root_txnid = 1000;
TXNID child_id = 10; TXNID child_id = 10;
XIDS msg_xids_1; XIDS msg_xids_1;
XIDS msg_xids_2; XIDS msg_xids_2;
r = xids_create_child(root_xids, &msg_xids_1, root_txnid); r = toku_xids_create_child(root_xids, &msg_xids_1, root_txnid);
assert(r==0); assert(r==0);
r = xids_create_child(msg_xids_1, &msg_xids_2, child_id); r = toku_xids_create_child(msg_xids_1, &msg_xids_2, child_id);
assert(r==0); assert(r==0);
init_empty_ule(&ule_initial); init_empty_ule(&ule_initial);
...@@ -189,9 +189,9 @@ run_test(void) { ...@@ -189,9 +189,9 @@ run_test(void) {
assert(ule->uxrs[3].valp == &val_data_three); assert(ule->uxrs[3].valp == &val_data_three);
} }
xids_destroy(&msg_xids_2); toku_xids_destroy(&msg_xids_2);
xids_destroy(&msg_xids_1); toku_xids_destroy(&msg_xids_1);
xids_destroy(&root_xids); toku_xids_destroy(&root_xids);
} }
......
...@@ -525,7 +525,7 @@ generate_provpair_for(ULE ule, const ft_msg &msg) { ...@@ -525,7 +525,7 @@ generate_provpair_for(ULE ule, const ft_msg &msg) {
ule->uxrs = ule->uxrs_static; ule->uxrs = ule->uxrs_static;
ule->num_cuxrs = 1; ule->num_cuxrs = 1;
ule->num_puxrs = xids_get_num_xids(xids); ule->num_puxrs = toku_xids_get_num_xids(xids);
uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs; uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs;
ule->uxrs[0].type = XR_DELETE; ule->uxrs[0].type = XR_DELETE;
ule->uxrs[0].vallen = 0; ule->uxrs[0].vallen = 0;
...@@ -535,12 +535,12 @@ generate_provpair_for(ULE ule, const ft_msg &msg) { ...@@ -535,12 +535,12 @@ generate_provpair_for(ULE ule, const ft_msg &msg) {
ule->uxrs[level].type = XR_PLACEHOLDER; ule->uxrs[level].type = XR_PLACEHOLDER;
ule->uxrs[level].vallen = 0; ule->uxrs[level].vallen = 0;
ule->uxrs[level].valp = NULL; ule->uxrs[level].valp = NULL;
ule->uxrs[level].xid = xids_get_xid(xids, level-1); ule->uxrs[level].xid = toku_xids_get_xid(xids, level-1);
} }
ule->uxrs[num_uxrs - 1].type = XR_INSERT; ule->uxrs[num_uxrs - 1].type = XR_INSERT;
ule->uxrs[num_uxrs - 1].vallen = msg.vdbt()->size; ule->uxrs[num_uxrs - 1].vallen = msg.vdbt()->size;
ule->uxrs[num_uxrs - 1].valp = msg.vdbt()->data; ule->uxrs[num_uxrs - 1].valp = msg.vdbt()->data;
ule->uxrs[num_uxrs - 1].xid = xids_get_innermost_xid(xids); ule->uxrs[num_uxrs - 1].xid = toku_xids_get_innermost_xid(xids);
} }
//Test all the different things that can happen to a //Test all the different things that can happen to a
...@@ -619,7 +619,7 @@ generate_provdel_for(ULE ule, const ft_msg &msg) { ...@@ -619,7 +619,7 @@ generate_provdel_for(ULE ule, const ft_msg &msg) {
XIDS xids = msg.xids(); XIDS xids = msg.xids();
ule->num_cuxrs = 1; ule->num_cuxrs = 1;
ule->num_puxrs = xids_get_num_xids(xids); ule->num_puxrs = toku_xids_get_num_xids(xids);
uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs; uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs;
ule->uxrs[0].type = XR_INSERT; ule->uxrs[0].type = XR_INSERT;
ule->uxrs[0].vallen = msg.vdbt()->size; ule->uxrs[0].vallen = msg.vdbt()->size;
...@@ -629,12 +629,12 @@ generate_provdel_for(ULE ule, const ft_msg &msg) { ...@@ -629,12 +629,12 @@ generate_provdel_for(ULE ule, const ft_msg &msg) {
ule->uxrs[level].type = XR_PLACEHOLDER; ule->uxrs[level].type = XR_PLACEHOLDER;
ule->uxrs[level].vallen = 0; ule->uxrs[level].vallen = 0;
ule->uxrs[level].valp = NULL; ule->uxrs[level].valp = NULL;
ule->uxrs[level].xid = xids_get_xid(xids, level-1); ule->uxrs[level].xid = toku_xids_get_xid(xids, level-1);
} }
ule->uxrs[num_uxrs - 1].type = XR_DELETE; ule->uxrs[num_uxrs - 1].type = XR_DELETE;
ule->uxrs[num_uxrs - 1].vallen = 0; ule->uxrs[num_uxrs - 1].vallen = 0;
ule->uxrs[num_uxrs - 1].valp = NULL; ule->uxrs[num_uxrs - 1].valp = NULL;
ule->uxrs[num_uxrs - 1].xid = xids_get_innermost_xid(xids); ule->uxrs[num_uxrs - 1].xid = toku_xids_get_innermost_xid(xids);
} }
static void static void
...@@ -643,7 +643,7 @@ generate_both_for(ULE ule, DBT *oldval, const ft_msg &msg) { ...@@ -643,7 +643,7 @@ generate_both_for(ULE ule, DBT *oldval, const ft_msg &msg) {
XIDS xids = msg.xids(); XIDS xids = msg.xids();
ule->num_cuxrs = 1; ule->num_cuxrs = 1;
ule->num_puxrs = xids_get_num_xids(xids); ule->num_puxrs = toku_xids_get_num_xids(xids);
uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs; uint32_t num_uxrs = ule->num_cuxrs + ule->num_puxrs;
ule->uxrs[0].type = XR_INSERT; ule->uxrs[0].type = XR_INSERT;
ule->uxrs[0].vallen = oldval->size; ule->uxrs[0].vallen = oldval->size;
...@@ -653,12 +653,12 @@ generate_both_for(ULE ule, DBT *oldval, const ft_msg &msg) { ...@@ -653,12 +653,12 @@ generate_both_for(ULE ule, DBT *oldval, const ft_msg &msg) {
ule->uxrs[level].type = XR_PLACEHOLDER; ule->uxrs[level].type = XR_PLACEHOLDER;
ule->uxrs[level].vallen = 0; ule->uxrs[level].vallen = 0;
ule->uxrs[level].valp = NULL; ule->uxrs[level].valp = NULL;
ule->uxrs[level].xid = xids_get_xid(xids, level-1); ule->uxrs[level].xid = toku_xids_get_xid(xids, level-1);
} }
ule->uxrs[num_uxrs - 1].type = XR_INSERT; ule->uxrs[num_uxrs - 1].type = XR_INSERT;
ule->uxrs[num_uxrs - 1].vallen = msg.vdbt()->size; ule->uxrs[num_uxrs - 1].vallen = msg.vdbt()->size;
ule->uxrs[num_uxrs - 1].valp = msg.vdbt()->data; ule->uxrs[num_uxrs - 1].valp = msg.vdbt()->data;
ule->uxrs[num_uxrs - 1].xid = xids_get_innermost_xid(xids); ule->uxrs[num_uxrs - 1].xid = toku_xids_get_innermost_xid(xids);
} }
//Test all the different things that can happen to a //Test all the different things that can happen to a
...@@ -868,9 +868,9 @@ static void test_le_optimize(void) { ...@@ -868,9 +868,9 @@ static void test_le_optimize(void) {
TXNID optimize_txnid = 1000; TXNID optimize_txnid = 1000;
memset(&key, 0, sizeof(key)); memset(&key, 0, sizeof(key));
memset(&val, 0, sizeof(val)); memset(&val, 0, sizeof(val));
XIDS root_xids = xids_get_root_xids(); XIDS root_xids = toku_xids_get_root_xids();
XIDS msg_xids; XIDS msg_xids;
int r = xids_create_child(root_xids, &msg_xids, optimize_txnid); int r = toku_xids_create_child(root_xids, &msg_xids, optimize_txnid);
assert(r==0); assert(r==0);
ft_msg msg(&key, &val, FT_OPTIMIZE, ZERO_MSN, msg_xids); ft_msg msg(&key, &val, FT_OPTIMIZE, ZERO_MSN, msg_xids);
...@@ -981,8 +981,8 @@ static void test_le_optimize(void) { ...@@ -981,8 +981,8 @@ static void test_le_optimize(void) {
verify_ule_equal(&ule_initial, &ule_expected); verify_ule_equal(&ule_initial, &ule_expected);
xids_destroy(&msg_xids); toku_xids_destroy(&msg_xids);
xids_destroy(&root_xids); toku_xids_destroy(&root_xids);
} }
//TODO: #1125 tests: //TODO: #1125 tests:
...@@ -1020,9 +1020,9 @@ static void test_le_optimize(void) { ...@@ -1020,9 +1020,9 @@ static void test_le_optimize(void) {
static void static void
init_xids(void) { init_xids(void) {
uint32_t i; uint32_t i;
nested_xids[0] = xids_get_root_xids(); nested_xids[0] = toku_xids_get_root_xids();
for (i = 1; i < MAX_TRANSACTION_RECORDS; i++) { for (i = 1; i < MAX_TRANSACTION_RECORDS; i++) {
int r = xids_create_child(nested_xids[i-1], &nested_xids[i], i * 37 + random() % 36); int r = toku_xids_create_child(nested_xids[i-1], &nested_xids[i], i * 37 + random() % 36);
assert(r==0); assert(r==0);
} }
} }
...@@ -1031,7 +1031,7 @@ static void ...@@ -1031,7 +1031,7 @@ static void
destroy_xids(void) { destroy_xids(void) {
uint32_t i; uint32_t i;
for (i = 0; i < MAX_TRANSACTION_RECORDS; i++) { for (i = 0; i < MAX_TRANSACTION_RECORDS; i++) {
xids_destroy(&nested_xids[i]); toku_xids_destroy(&nested_xids[i]);
} }
} }
......
...@@ -127,7 +127,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -127,7 +127,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
// apply an insert to the leaf node // apply an insert to the leaf node
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
...@@ -156,7 +156,7 @@ insert_into_child_buffer(FT_HANDLE ft, FTNODE node, int childnum, int minkey, in ...@@ -156,7 +156,7 @@ insert_into_child_buffer(FT_HANDLE ft, FTNODE node, int childnum, int minkey, in
unsigned int key = htonl(val); unsigned int key = htonl(val);
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key); DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
DBT theval; toku_fill_dbt(&theval, &val, sizeof val); DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
toku_ft_append_to_child_buffer(ft->ft->cmp, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval); toku_ft_append_to_child_buffer(ft->ft->cmp, node, childnum, FT_INSERT, msn, toku_xids_get_root_xids(), true, &thekey, &theval);
// Create bad tree (don't do following): // Create bad tree (don't do following):
// node->max_msn_applied_to_node = msn; // node->max_msn_applied_to_node = msn;
......
...@@ -115,7 +115,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -115,7 +115,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
// apply an insert to the leaf node // apply an insert to the leaf node
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
......
...@@ -116,7 +116,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -116,7 +116,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
// apply an insert to the leaf node // apply an insert to the leaf node
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
......
...@@ -115,7 +115,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -115,7 +115,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
// apply an insert to the leaf node // apply an insert to the leaf node
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
......
...@@ -116,7 +116,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -116,7 +116,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
// apply an insert to the leaf node // apply an insert to the leaf node
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_bn_apply_msg_once(BLB(leafnode,0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode,0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
...@@ -144,7 +144,7 @@ insert_into_child_buffer(FT_HANDLE ft, FTNODE node, int childnum, int minkey, in ...@@ -144,7 +144,7 @@ insert_into_child_buffer(FT_HANDLE ft, FTNODE node, int childnum, int minkey, in
DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key); DBT thekey; toku_fill_dbt(&thekey, &key, sizeof key);
DBT theval; toku_fill_dbt(&theval, &val, sizeof val); DBT theval; toku_fill_dbt(&theval, &val, sizeof val);
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
toku_ft_append_to_child_buffer(ft->ft->cmp, node, childnum, FT_INSERT, msn, xids_get_root_xids(), true, &thekey, &theval); toku_ft_append_to_child_buffer(ft->ft->cmp, node, childnum, FT_INSERT, msn, toku_xids_get_root_xids(), true, &thekey, &theval);
} }
} }
......
...@@ -118,7 +118,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -118,7 +118,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
// apply an insert to the leaf node // apply an insert to the leaf node
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
......
...@@ -115,7 +115,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen) ...@@ -115,7 +115,7 @@ append_leaf(FTNODE leafnode, void *key, size_t keylen, void *val, size_t vallen)
// apply an insert to the leaf node // apply an insert to the leaf node
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
ft_msg msg(&thekey, &theval, FT_INSERT, msn, xids_get_root_xids()); ft_msg msg(&thekey, &theval, FT_INSERT, msn, toku_xids_get_root_xids());
txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false); txn_gc_info gc_info(nullptr, TXNID_NONE, TXNID_NONE, false);
toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL); toku_ft_bn_apply_msg_once(BLB(leafnode, 0), msg, idx, keylen, NULL, &gc_info, NULL, NULL);
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#pragma once
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
/* The number of transaction ids stored in the xids structure is
* represented by an 8-bit value. The value 255 is reserved.
* The constant MAX_NESTED_TRANSACTIONS is one less because
* one slot in the packed leaf entry is used for the implicit
* root transaction (id 0).
*/
enum {
MAX_NESTED_TRANSACTIONS = 253,
MAX_TRANSACTION_RECORDS = MAX_NESTED_TRANSACTIONS + 1
};
...@@ -308,7 +308,7 @@ static void dump_node(int fd, BLOCKNUM blocknum, FT ft) { ...@@ -308,7 +308,7 @@ static void dump_node(int fd, BLOCKNUM blocknum, FT ft) {
printf("HUH?"); printf("HUH?");
ok: ok:
printf(" xid="); printf(" xid=");
xids_fprintf(stdout, xids); toku_xids_fprintf(stdout, xids);
printf(" "); printf(" ");
print_item(key, keylen); print_item(key, keylen);
if (datalen>0) { if (datalen>0) {
......
...@@ -188,13 +188,13 @@ txn_create_xids(TOKUTXN txn, TOKUTXN parent) { ...@@ -188,13 +188,13 @@ txn_create_xids(TOKUTXN txn, TOKUTXN parent) {
XIDS xids; XIDS xids;
XIDS parent_xids; XIDS parent_xids;
if (parent == NULL) { if (parent == NULL) {
parent_xids = xids_get_root_xids(); parent_xids = toku_xids_get_root_xids();
} else { } else {
parent_xids = parent->xids; parent_xids = parent->xids;
} }
xids_create_unknown_child(parent_xids, &xids); toku_xids_create_unknown_child(parent_xids, &xids);
TXNID finalized_xid = (parent == NULL) ? txn->txnid.parent_id64 : txn->txnid.child_id64; TXNID finalized_xid = (parent == NULL) ? txn->txnid.parent_id64 : txn->txnid.child_id64;
xids_finalize_with_child(xids, finalized_xid); toku_xids_finalize_with_child(xids, finalized_xid);
txn->xids = xids; txn->xids = xids;
} }
...@@ -217,7 +217,7 @@ toku_txn_begin_with_xid ( ...@@ -217,7 +217,7 @@ toku_txn_begin_with_xid (
TOKUTXN txn; TOKUTXN txn;
// check for case where we are trying to // check for case where we are trying to
// create too many nested transactions // create too many nested transactions
if (!read_only && parent && !xids_can_create_child(parent->xids)) { if (!read_only && parent && !toku_xids_can_create_child(parent->xids)) {
r = EINVAL; r = EINVAL;
goto exit; goto exit;
} }
...@@ -648,7 +648,7 @@ void toku_txn_complete_txn(TOKUTXN txn) { ...@@ -648,7 +648,7 @@ void toku_txn_complete_txn(TOKUTXN txn) {
void toku_txn_destroy_txn(TOKUTXN txn) { void toku_txn_destroy_txn(TOKUTXN txn) {
txn->open_fts.destroy(); txn->open_fts.destroy();
if (txn->xids) { if (txn->xids) {
xids_destroy(&txn->xids); toku_xids_destroy(&txn->xids);
} }
toku_mutex_destroy(&txn->txn_lock); toku_mutex_destroy(&txn->txn_lock);
toku_mutex_destroy(&txn->state_lock); toku_mutex_destroy(&txn->state_lock);
...@@ -657,7 +657,7 @@ void toku_txn_destroy_txn(TOKUTXN txn) { ...@@ -657,7 +657,7 @@ void toku_txn_destroy_txn(TOKUTXN txn) {
} }
XIDS toku_txn_get_xids (TOKUTXN txn) { XIDS toku_txn_get_xids (TOKUTXN txn) {
if (txn==0) return xids_get_root_xids(); if (txn==0) return toku_xids_get_root_xids();
else return txn->xids; else return txn->xids;
} }
......
...@@ -218,7 +218,7 @@ struct tokutxn { ...@@ -218,7 +218,7 @@ struct tokutxn {
// strictly const. // strictly const.
DB_TXN *container_db_txn; // reference to DB_TXN that contains this tokutxn DB_TXN *container_db_txn; // reference to DB_TXN that contains this tokutxn
xid_omt_t *live_root_txn_list; // the root txns live when the root ancestor (self if a root) started. xid_omt_t *live_root_txn_list; // the root txns live when the root ancestor (self if a root) started.
struct xids_t *xids; // Represents the xid list struct XIDS_S *xids; // Represents the xid list
struct tokutxn *snapshot_next; struct tokutxn *snapshot_next;
struct tokutxn *snapshot_prev; struct tokutxn *snapshot_prev;
...@@ -319,7 +319,7 @@ void toku_txn_complete_txn(struct tokutxn *txn); ...@@ -319,7 +319,7 @@ void toku_txn_complete_txn(struct tokutxn *txn);
// Free the memory of a txn // Free the memory of a txn
void toku_txn_destroy_txn(struct tokutxn *txn); void toku_txn_destroy_txn(struct tokutxn *txn);
struct xids_t *toku_txn_get_xids(struct tokutxn *txn); struct XIDS_S *toku_txn_get_xids(struct tokutxn *txn);
// Force fsync on commit // Force fsync on commit
void toku_txn_force_fsync_on_commit(struct tokutxn *txn); void toku_txn_force_fsync_on_commit(struct tokutxn *txn);
......
...@@ -695,7 +695,7 @@ msg_init_empty_ule(ULE ule) { ...@@ -695,7 +695,7 @@ msg_init_empty_ule(ULE ule) {
static void static void
msg_modify_ule(ULE ule, const ft_msg &msg) { msg_modify_ule(ULE ule, const ft_msg &msg) {
XIDS xids = msg.xids(); XIDS xids = msg.xids();
invariant(xids_get_num_xids(xids) < MAX_TRANSACTION_RECORDS); invariant(toku_xids_get_num_xids(xids) < MAX_TRANSACTION_RECORDS);
enum ft_msg_type type = msg.type(); enum ft_msg_type type = msg.type();
if (type != FT_OPTIMIZE && type != FT_OPTIMIZE_FOR_UPGRADE) { if (type != FT_OPTIMIZE && type != FT_OPTIMIZE_FOR_UPGRADE) {
ule_do_implicit_promotions(ule, xids); ule_do_implicit_promotions(ule, xids);
...@@ -751,10 +751,10 @@ static void ule_optimize(ULE ule, XIDS xids) { ...@@ -751,10 +751,10 @@ static void ule_optimize(ULE ule, XIDS xids) {
if (ule->num_puxrs) { if (ule->num_puxrs) {
TXNID uncommitted = ule->uxrs[ule->num_cuxrs].xid; // outermost uncommitted TXNID uncommitted = ule->uxrs[ule->num_cuxrs].xid; // outermost uncommitted
TXNID oldest_living_xid = TXNID_NONE; TXNID oldest_living_xid = TXNID_NONE;
uint32_t num_xids = xids_get_num_xids(xids); uint32_t num_xids = toku_xids_get_num_xids(xids);
if (num_xids > 0) { if (num_xids > 0) {
invariant(num_xids==1); invariant(num_xids==1);
oldest_living_xid = xids_get_xid(xids, 0); oldest_living_xid = toku_xids_get_xid(xids, 0);
} }
if (oldest_living_xid == TXNID_NONE || uncommitted < oldest_living_xid) { if (oldest_living_xid == TXNID_NONE || uncommitted < oldest_living_xid) {
ule_promote_provisional_innermost_to_committed(ule); ule_promote_provisional_innermost_to_committed(ule);
...@@ -1350,9 +1350,9 @@ int le_latest_is_del(LEAFENTRY le) { ...@@ -1350,9 +1350,9 @@ int le_latest_is_del(LEAFENTRY le) {
bool bool
le_has_xids(LEAFENTRY le, XIDS xids) { le_has_xids(LEAFENTRY le, XIDS xids) {
//Read num_uxrs //Read num_uxrs
uint32_t num_xids = xids_get_num_xids(xids); uint32_t num_xids = toku_xids_get_num_xids(xids);
invariant(num_xids > 0); //Disallow checking for having TXNID_NONE invariant(num_xids > 0); //Disallow checking for having TXNID_NONE
TXNID xid = xids_get_xid(xids, 0); TXNID xid = toku_xids_get_xid(xids, 0);
invariant(xid!=TXNID_NONE); invariant(xid!=TXNID_NONE);
bool rval = (le_outermost_uncommitted_xid(le) == xid); bool rval = (le_outermost_uncommitted_xid(le) == xid);
...@@ -1602,13 +1602,13 @@ ule_do_implicit_promotions(ULE ule, XIDS xids) { ...@@ -1602,13 +1602,13 @@ ule_do_implicit_promotions(ULE ule, XIDS xids) {
//Optimization for (most) common case. //Optimization for (most) common case.
//No commits necessary if everything is already committed. //No commits necessary if everything is already committed.
if (ule->num_puxrs > 0) { if (ule->num_puxrs > 0) {
int num_xids = xids_get_num_xids(xids); int num_xids = toku_xids_get_num_xids(xids);
invariant(num_xids>0); invariant(num_xids>0);
uint32_t max_index = ule->num_cuxrs + min_i32(ule->num_puxrs, num_xids) - 1; uint32_t max_index = ule->num_cuxrs + min_i32(ule->num_puxrs, num_xids) - 1;
uint32_t ica_index = max_index; uint32_t ica_index = max_index;
uint32_t index; uint32_t index;
for (index = ule->num_cuxrs; index <= max_index; index++) { for (index = ule->num_cuxrs; index <= max_index; index++) {
TXNID current_msg_xid = xids_get_xid(xids, index - ule->num_cuxrs); TXNID current_msg_xid = toku_xids_get_xid(xids, index - ule->num_cuxrs);
TXNID current_ule_xid = ule_get_xid(ule, index); TXNID current_ule_xid = ule_get_xid(ule, index);
if (current_msg_xid != current_ule_xid) { if (current_msg_xid != current_ule_xid) {
//ica is innermost transaction with matching xids. //ica is innermost transaction with matching xids.
...@@ -1698,7 +1698,7 @@ ule_promote_provisional_innermost_to_index(ULE ule, uint32_t index) { ...@@ -1698,7 +1698,7 @@ ule_promote_provisional_innermost_to_index(ULE ule, uint32_t index) {
static void static void
ule_apply_insert(ULE ule, XIDS xids, uint32_t vallen, void * valp) { ule_apply_insert(ULE ule, XIDS xids, uint32_t vallen, void * valp) {
ule_prepare_for_new_uxr(ule, xids); ule_prepare_for_new_uxr(ule, xids);
TXNID this_xid = xids_get_innermost_xid(xids); // xid of transaction doing this insert TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction doing this insert
ule_push_insert_uxr(ule, this_xid == TXNID_NONE, this_xid, vallen, valp); ule_push_insert_uxr(ule, this_xid == TXNID_NONE, this_xid, vallen, valp);
} }
...@@ -1706,7 +1706,7 @@ ule_apply_insert(ULE ule, XIDS xids, uint32_t vallen, void * valp) { ...@@ -1706,7 +1706,7 @@ ule_apply_insert(ULE ule, XIDS xids, uint32_t vallen, void * valp) {
static void static void
ule_apply_delete(ULE ule, XIDS xids) { ule_apply_delete(ULE ule, XIDS xids) {
ule_prepare_for_new_uxr(ule, xids); ule_prepare_for_new_uxr(ule, xids);
TXNID this_xid = xids_get_innermost_xid(xids); // xid of transaction doing this delete TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction doing this delete
ule_push_delete_uxr(ule, this_xid == TXNID_NONE, this_xid); ule_push_delete_uxr(ule, this_xid == TXNID_NONE, this_xid);
} }
...@@ -1717,7 +1717,7 @@ ule_apply_delete(ULE ule, XIDS xids) { ...@@ -1717,7 +1717,7 @@ ule_apply_delete(ULE ule, XIDS xids) {
// with placeholders. // with placeholders.
static void static void
ule_prepare_for_new_uxr(ULE ule, XIDS xids) { ule_prepare_for_new_uxr(ULE ule, XIDS xids) {
TXNID this_xid = xids_get_innermost_xid(xids); TXNID this_xid = toku_xids_get_innermost_xid(xids);
//This is for LOADER_USE_PUTS or transactionless environment //This is for LOADER_USE_PUTS or transactionless environment
//where messages use XIDS of 0 //where messages use XIDS of 0
if (this_xid == TXNID_NONE && ule_get_innermost_xid(ule) == TXNID_NONE) { if (this_xid == TXNID_NONE && ule_get_innermost_xid(ule) == TXNID_NONE) {
...@@ -1742,7 +1742,7 @@ ule_prepare_for_new_uxr(ULE ule, XIDS xids) { ...@@ -1742,7 +1742,7 @@ ule_prepare_for_new_uxr(ULE ule, XIDS xids) {
// Remember, the innermost uxr can only be an insert or a delete, not a placeholder. // Remember, the innermost uxr can only be an insert or a delete, not a placeholder.
static void static void
ule_apply_abort(ULE ule, XIDS xids) { ule_apply_abort(ULE ule, XIDS xids) {
TXNID this_xid = xids_get_innermost_xid(xids); // xid of transaction doing this abort TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction doing this abort
invariant(this_xid!=TXNID_NONE); invariant(this_xid!=TXNID_NONE);
UXR innermost = ule_get_innermost_uxr(ule); UXR innermost = ule_get_innermost_uxr(ule);
// need to check for provisional entries in ule, otherwise // need to check for provisional entries in ule, otherwise
...@@ -1773,7 +1773,7 @@ ule_apply_broadcast_commit_all (ULE ule) { ...@@ -1773,7 +1773,7 @@ ule_apply_broadcast_commit_all (ULE ule) {
// If this transaction did modify the leafentry, then promote whatever it did. // If this transaction did modify the leafentry, then promote whatever it did.
// Remember, the innermost uxr can only be an insert or a delete, not a placeholder. // Remember, the innermost uxr can only be an insert or a delete, not a placeholder.
void ule_apply_commit(ULE ule, XIDS xids) { void ule_apply_commit(ULE ule, XIDS xids) {
TXNID this_xid = xids_get_innermost_xid(xids); // xid of transaction committing TXNID this_xid = toku_xids_get_innermost_xid(xids); // xid of transaction committing
invariant(this_xid!=TXNID_NONE); invariant(this_xid!=TXNID_NONE);
// need to check for provisional entries in ule, otherwise // need to check for provisional entries in ule, otherwise
// there is nothing to abort, not checking this may result // there is nothing to abort, not checking this may result
...@@ -1915,7 +1915,7 @@ ule_add_placeholders(ULE ule, XIDS xids) { ...@@ -1915,7 +1915,7 @@ ule_add_placeholders(ULE ule, XIDS xids) {
//Placeholders can be placed on top of the committed uxr. //Placeholders can be placed on top of the committed uxr.
invariant(ule->num_cuxrs > 0); invariant(ule->num_cuxrs > 0);
uint32_t num_xids = xids_get_num_xids(xids); uint32_t num_xids = toku_xids_get_num_xids(xids);
// we assume that implicit promotion has happened // we assume that implicit promotion has happened
// when we get this call, so the number of xids MUST // when we get this call, so the number of xids MUST
// be greater than the number of provisional entries // be greater than the number of provisional entries
...@@ -1923,12 +1923,12 @@ ule_add_placeholders(ULE ule, XIDS xids) { ...@@ -1923,12 +1923,12 @@ ule_add_placeholders(ULE ule, XIDS xids) {
// make sure that the xids stack matches up to a certain amount // make sure that the xids stack matches up to a certain amount
// this first for loop is just debug code // this first for loop is just debug code
for (uint32_t i = 0; i < ule->num_puxrs; i++) { for (uint32_t i = 0; i < ule->num_puxrs; i++) {
TXNID current_msg_xid = xids_get_xid(xids, i); TXNID current_msg_xid = toku_xids_get_xid(xids, i);
TXNID current_ule_xid = ule_get_xid(ule, i + ule->num_cuxrs); TXNID current_ule_xid = ule_get_xid(ule, i + ule->num_cuxrs);
invariant(current_msg_xid == current_ule_xid); invariant(current_msg_xid == current_ule_xid);
} }
for (uint32_t i = ule->num_puxrs; i < num_xids-1; i++) { for (uint32_t i = ule->num_puxrs; i < num_xids-1; i++) {
TXNID current_msg_xid = xids_get_xid(xids, i); TXNID current_msg_xid = toku_xids_get_xid(xids, i);
ule_push_placeholder_uxr(ule, current_msg_xid); ule_push_placeholder_uxr(ule, current_msg_xid);
} }
} }
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*
COPYING CONDITIONS NOTICE:
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation, and provided that the
following conditions are met:
* Redistributions of source code must retain this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below).
* Redistributions in binary form must reproduce this COPYING
CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
PATENT MARKING NOTICE (below), and the PATENT RIGHTS
GRANT (below) in the documentation and/or other materials
provided with the distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
COPYRIGHT NOTICE:
TokuDB, Tokutek Fractal Tree Indexing Library.
Copyright (C) 2007-2013 Tokutek, Inc.
DISCLAIMER:
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
UNIVERSITY PATENT NOTICE:
The technology is licensed by the Massachusetts Institute of
Technology, Rutgers State University of New Jersey, and the Research
Foundation of State University of New York at Stony Brook under
United States of America Serial No. 11/760379 and to the patents
and/or patent applications resulting from it.
PATENT MARKING NOTICE:
This software is covered by US Patent No. 8,185,551.
This software is covered by US Patent No. 8,489,638.
PATENT RIGHTS GRANT:
"THIS IMPLEMENTATION" means the copyrightable works distributed by
Tokutek as part of the Fractal Tree project.
"PATENT CLAIMS" means the claims of patents that are owned or
licensable by Tokutek, both currently or in the future; and that in
the absence of this license would be infringed by THIS
IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
"PATENT CHALLENGE" shall mean a challenge to the validity,
patentability, enforceability and/or non-infringement of any of the
PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
Tokutek hereby grants to you, for the term and geographical scope of
the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and
otherwise run, modify, and propagate the contents of THIS
IMPLEMENTATION, where such license applies only to the PATENT
CLAIMS. This grant does not include claims that would be infringed
only as a consequence of further modifications of THIS
IMPLEMENTATION. If you or your agent or licensee institute or order
or agree to the institution of patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that
THIS IMPLEMENTATION constitutes direct or contributory patent
infringement, or inducement of patent infringement, then any rights
granted to you under this License shall terminate as of the date
such litigation is filed. If you or your agent or exclusive
licensee institute or order or agree to the institution of a PATENT
CHALLENGE, then Tokutek may terminate any rights granted to you
under this License.
*/
#pragma once
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
// Variable size list of transaction ids (known in design doc as xids<>).
// ids[0] is the outermost transaction.
// ids[num_xids - 1] is the innermost transaction.
// Should only be accessed by accessor functions xids_xxx, not directly.
#include "portability/toku_stdint.h"
#include "ft/txn.h"
// If the xids struct is unpacked, the compiler aligns the ids[] and we waste a lot of space
typedef struct __attribute__((__packed__)) xids_t {
uint8_t num_xids; // maximum value of MAX_TRANSACTION_RECORDS - 1 ...
// ... because transaction 0 is implicit
TXNID ids[];
} XIDS_S;
...@@ -110,7 +110,6 @@ PATENT RIGHTS GRANT: ...@@ -110,7 +110,6 @@ PATENT RIGHTS GRANT:
#include "portability/toku_portability.h" #include "portability/toku_portability.h"
#include "ft/xids.h" #include "ft/xids.h"
#include "ft/xids-internal.h"
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// This layer of abstraction (xids_xxx) understands xids<> and nothing else. // This layer of abstraction (xids_xxx) understands xids<> and nothing else.
...@@ -122,7 +121,7 @@ PATENT RIGHTS GRANT: ...@@ -122,7 +121,7 @@ PATENT RIGHTS GRANT:
// the variable num_xids. // the variable num_xids.
// //
// The xids struct is immutable. The caller gets an initial version of XIDS // The xids struct is immutable. The caller gets an initial version of XIDS
// by calling xids_get_root_xids(), which returns the constant struct // by calling toku_xids_get_root_xids(), which returns the constant struct
// representing the root transaction (id 0). When a transaction begins, // representing the root transaction (id 0). When a transaction begins,
// a new XIDS is created with the id of the current transaction appended to // a new XIDS is created with the id of the current transaction appended to
// the list. // the list.
...@@ -134,8 +133,8 @@ PATENT RIGHTS GRANT: ...@@ -134,8 +133,8 @@ PATENT RIGHTS GRANT:
// nested transactions. // nested transactions.
XIDS XIDS
xids_get_root_xids(void) { toku_xids_get_root_xids(void) {
static const struct xids_t root_xids = { static const struct XIDS_S root_xids = {
.num_xids = 0 .num_xids = 0
}; };
...@@ -144,13 +143,13 @@ xids_get_root_xids(void) { ...@@ -144,13 +143,13 @@ xids_get_root_xids(void) {
} }
bool bool
xids_can_create_child(XIDS xids) { toku_xids_can_create_child(XIDS xids) {
invariant(xids->num_xids < MAX_TRANSACTION_RECORDS); invariant(xids->num_xids < MAX_TRANSACTION_RECORDS);
return (xids->num_xids + 1) != MAX_TRANSACTION_RECORDS; return (xids->num_xids + 1) != MAX_TRANSACTION_RECORDS;
} }
int int
xids_create_unknown_child(XIDS parent_xids, XIDS *xids_p) { toku_xids_create_unknown_child(XIDS parent_xids, XIDS *xids_p) {
// Postcondition: // Postcondition:
// xids_p points to an xids that is an exact copy of parent_xids, but with room for one more xid. // xids_p points to an xids that is an exact copy of parent_xids, but with room for one more xid.
int rval; int rval;
...@@ -169,9 +168,9 @@ xids_create_unknown_child(XIDS parent_xids, XIDS *xids_p) { ...@@ -169,9 +168,9 @@ xids_create_unknown_child(XIDS parent_xids, XIDS *xids_p) {
} }
void void
xids_finalize_with_child(XIDS xids, TXNID this_xid) { toku_xids_finalize_with_child(XIDS xids, TXNID this_xid) {
// Precondition: // Precondition:
// - xids was created by xids_create_unknown_child // - xids was created by toku_xids_create_unknown_child
TXNID this_xid_disk = toku_htod64(this_xid); TXNID this_xid_disk = toku_htod64(this_xid);
uint32_t num_child_xids = ++xids->num_xids; uint32_t num_child_xids = ++xids->num_xids;
xids->ids[num_child_xids - 1] = this_xid_disk; xids->ids[num_child_xids - 1] = this_xid_disk;
...@@ -180,21 +179,21 @@ xids_finalize_with_child(XIDS xids, TXNID this_xid) { ...@@ -180,21 +179,21 @@ xids_finalize_with_child(XIDS xids, TXNID this_xid) {
// xids is immutable. This function creates a new xids by copying the // xids is immutable. This function creates a new xids by copying the
// parent's list and then appending the xid of the new transaction. // parent's list and then appending the xid of the new transaction.
int int
xids_create_child(XIDS parent_xids, // xids list for parent transaction toku_xids_create_child(XIDS parent_xids, // xids list for parent transaction
XIDS * xids_p, // xids list created XIDS *xids_p, // xids list created
TXNID this_xid) { // xid of this transaction (new innermost) TXNID this_xid) { // xid of this transaction (new innermost)
bool can_create_child = xids_can_create_child(parent_xids); bool can_create_child = toku_xids_can_create_child(parent_xids);
if (!can_create_child) { if (!can_create_child) {
return EINVAL; return EINVAL;
} }
xids_create_unknown_child(parent_xids, xids_p); toku_xids_create_unknown_child(parent_xids, xids_p);
xids_finalize_with_child(*xids_p, this_xid); toku_xids_finalize_with_child(*xids_p, this_xid);
return 0; return 0;
} }
void void
xids_create_from_buffer(struct rbuf *rb, // xids list for parent transaction toku_xids_create_from_buffer(struct rbuf *rb, // xids list for parent transaction
XIDS * xids_p) { // xids list created XIDS *xids_p) { // xids list created
uint8_t num_xids = rbuf_char(rb); uint8_t num_xids = rbuf_char(rb);
invariant(num_xids < MAX_TRANSACTION_RECORDS); invariant(num_xids < MAX_TRANSACTION_RECORDS);
XIDS CAST_FROM_VOIDP(xids, toku_xmalloc(sizeof(*xids) + num_xids*sizeof(xids->ids[0]))); XIDS CAST_FROM_VOIDP(xids, toku_xmalloc(sizeof(*xids) + num_xids*sizeof(xids->ids[0])));
...@@ -207,8 +206,8 @@ xids_create_from_buffer(struct rbuf *rb, // xids list for parent transaction ...@@ -207,8 +206,8 @@ xids_create_from_buffer(struct rbuf *rb, // xids list for parent transaction
} }
void void
xids_destroy(XIDS *xids_p) { toku_xids_destroy(XIDS *xids_p) {
if (*xids_p != xids_get_root_xids()) toku_free(*xids_p); if (*xids_p != toku_xids_get_root_xids()) toku_free(*xids_p);
*xids_p = NULL; *xids_p = NULL;
} }
...@@ -216,48 +215,49 @@ xids_destroy(XIDS *xids_p) { ...@@ -216,48 +215,49 @@ xids_destroy(XIDS *xids_p) {
// If requesting an xid out of range (which will be the case if xids array is empty) // If requesting an xid out of range (which will be the case if xids array is empty)
// then return 0, the xid of the root transaction. // then return 0, the xid of the root transaction.
TXNID TXNID
xids_get_xid(XIDS xids, uint8_t index) { toku_xids_get_xid(XIDS xids, uint8_t index) {
invariant(index < xids_get_num_xids(xids)); invariant(index < toku_xids_get_num_xids(xids));
TXNID rval = xids->ids[index]; TXNID rval = xids->ids[index];
rval = toku_dtoh64(rval); rval = toku_dtoh64(rval);
return rval; return rval;
} }
uint8_t uint8_t
xids_get_num_xids(XIDS xids) { toku_xids_get_num_xids(XIDS xids) {
uint8_t rval = xids->num_xids; uint8_t rval = xids->num_xids;
return rval; return rval;
} }
// Return innermost xid // Return innermost xid
TXNID TXNID
xids_get_innermost_xid(XIDS xids) { toku_xids_get_innermost_xid(XIDS xids) {
TXNID rval = TXNID_NONE; TXNID rval = TXNID_NONE;
if (xids_get_num_xids(xids)) { if (toku_xids_get_num_xids(xids)) {
// if clause above makes this cast ok // if clause above makes this cast ok
uint8_t innermost_xid = (uint8_t)(xids_get_num_xids(xids)-1); uint8_t innermost_xid = (uint8_t) (toku_xids_get_num_xids(xids) - 1);
rval = xids_get_xid(xids, innermost_xid); rval = toku_xids_get_xid(xids, innermost_xid);
} }
return rval; return rval;
} }
TXNID TXNID
xids_get_outermost_xid(XIDS xids) { toku_xids_get_outermost_xid(XIDS xids) {
TXNID rval = TXNID_NONE; TXNID rval = TXNID_NONE;
if (xids_get_num_xids(xids)) if (toku_xids_get_num_xids(xids)) {
rval = xids_get_xid(xids, 0); rval = toku_xids_get_xid(xids, 0);
}
return rval; return rval;
} }
void void
xids_cpy(XIDS target, XIDS source) { toku_xids_cpy(XIDS target, XIDS source) {
size_t size = xids_get_size(source); size_t size = toku_xids_get_size(source);
memcpy(target, source, size); memcpy(target, source, size);
} }
// return size in bytes // return size in bytes
uint32_t uint32_t
xids_get_size(XIDS xids){ toku_xids_get_size(XIDS xids) {
uint32_t rval; uint32_t rval;
uint8_t num_xids = xids->num_xids; uint8_t num_xids = xids->num_xids;
rval = sizeof(*xids) + num_xids * sizeof(xids->ids[0]); rval = sizeof(*xids) + num_xids * sizeof(xids->ids[0]);
...@@ -265,7 +265,7 @@ xids_get_size(XIDS xids){ ...@@ -265,7 +265,7 @@ xids_get_size(XIDS xids){
} }
uint32_t uint32_t
xids_get_serialize_size(XIDS xids){ toku_xids_get_serialize_size(XIDS xids) {
uint32_t rval; uint32_t rval;
uint8_t num_xids = xids->num_xids; uint8_t num_xids = xids->num_xids;
rval = 1 + //num xids rval = 1 + //num xids
...@@ -274,7 +274,7 @@ xids_get_serialize_size(XIDS xids){ ...@@ -274,7 +274,7 @@ xids_get_serialize_size(XIDS xids){
} }
unsigned char * unsigned char *
xids_get_end_of_array(XIDS xids) { toku_xids_get_end_of_array(XIDS xids) {
TXNID *r = xids->ids + xids->num_xids; TXNID *r = xids->ids + xids->num_xids;
return (unsigned char*)r; return (unsigned char*)r;
} }
...@@ -288,13 +288,13 @@ void wbuf_nocrc_xids(struct wbuf *wb, XIDS xids) { ...@@ -288,13 +288,13 @@ void wbuf_nocrc_xids(struct wbuf *wb, XIDS xids) {
} }
void void
xids_fprintf(FILE* fp, XIDS xids) { toku_xids_fprintf(FILE *fp, XIDS xids) {
uint8_t index; uint8_t index;
unsigned num_xids = xids_get_num_xids(xids); unsigned num_xids = toku_xids_get_num_xids(xids);
fprintf(fp, "[|%u| ", num_xids); fprintf(fp, "[|%u| ", num_xids);
for (index = 0; index < xids_get_num_xids(xids); index++) { for (index = 0; index < toku_xids_get_num_xids(xids); index++) {
if (index) fprintf(fp, ","); if (index) fprintf(fp, ",");
fprintf(fp, "%" PRIx64, xids_get_xid(xids, index)); fprintf(fp, "%" PRIx64, toku_xids_get_xid(xids, index));
} }
fprintf(fp, "]"); fprintf(fp, "]");
} }
......
...@@ -106,44 +106,65 @@ PATENT RIGHTS GRANT: ...@@ -106,44 +106,65 @@ PATENT RIGHTS GRANT:
#include "ft/txn.h" #include "ft/txn.h"
#include "ft/rbuf.h" #include "ft/rbuf.h"
#include "ft/wbuf.h" #include "ft/wbuf.h"
#include "ft/tokuconst.h"
typedef struct xids_t *XIDS; /* The number of transaction ids stored in the xids structure is
* represented by an 8-bit value. The value 255 is reserved.
* The constant MAX_NESTED_TRANSACTIONS is one less because
* one slot in the packed leaf entry is used for the implicit
* root transaction (id 0).
*/
enum {
MAX_NESTED_TRANSACTIONS = 253,
MAX_TRANSACTION_RECORDS = MAX_NESTED_TRANSACTIONS + 1
};
// Variable size list of transaction ids (known in design doc as xids<>).
// ids[0] is the outermost transaction.
// ids[num_xids - 1] is the innermost transaction.
// Should only be accessed by accessor functions toku_xids_xxx, not directly.
// If the xids struct is unpacked, the compiler aligns the ids[] and we waste a lot of space
struct __attribute__((__packed__)) XIDS_S {
// maximum value of MAX_TRANSACTION_RECORDS - 1 because transaction 0 is implicit
uint8_t num_xids;
TXNID ids[];
};
typedef struct XIDS_S *XIDS;
// Retrieve an XIDS representing the root transaction. // Retrieve an XIDS representing the root transaction.
XIDS xids_get_root_xids(void); XIDS toku_xids_get_root_xids(void);
bool xids_can_create_child(XIDS xids); bool toku_xids_can_create_child(XIDS xids);
void xids_cpy(XIDS target, XIDS source); void toku_xids_cpy(XIDS target, XIDS source);
//Creates an XIDS representing this transaction. //Creates an XIDS representing this transaction.
//You must pass in an XIDS representing the parent of this transaction. //You must pass in an XIDS representing the parent of this transaction.
int xids_create_child(XIDS parent_xids, XIDS *xids_p, TXNID this_xid); int toku_xids_create_child(XIDS parent_xids, XIDS *xids_p, TXNID this_xid);
// The following two functions (in order) are equivalent to xids_create child, // The following two functions (in order) are equivalent to toku_xids_create child,
// but allow you to do most of the work without knowing the new xid. // but allow you to do most of the work without knowing the new xid.
int xids_create_unknown_child(XIDS parent_xids, XIDS *xids_p); int toku_xids_create_unknown_child(XIDS parent_xids, XIDS *xids_p);
void xids_finalize_with_child(XIDS xids, TXNID this_xid); void toku_xids_finalize_with_child(XIDS xids, TXNID this_xid);
void xids_create_from_buffer(struct rbuf *rb, XIDS * xids_p); void toku_xids_create_from_buffer(struct rbuf *rb, XIDS *xids_p);
void xids_destroy(XIDS *xids_p); void toku_xids_destroy(XIDS *xids_p);
TXNID xids_get_xid(XIDS xids, uint8_t index); TXNID toku_xids_get_xid(XIDS xids, uint8_t index);
uint8_t xids_get_num_xids(XIDS xids); uint8_t toku_xids_get_num_xids(XIDS xids);
TXNID xids_get_innermost_xid(XIDS xids); TXNID toku_xids_get_innermost_xid(XIDS xids);
TXNID xids_get_outermost_xid(XIDS xids); TXNID toku_xids_get_outermost_xid(XIDS xids);
// return size in bytes // return size in bytes
uint32_t xids_get_size(XIDS xids); uint32_t toku_xids_get_size(XIDS xids);
uint32_t xids_get_serialize_size(XIDS xids); uint32_t toku_xids_get_serialize_size(XIDS xids);
unsigned char *xids_get_end_of_array(XIDS xids); unsigned char *toku_xids_get_end_of_array(XIDS xids);
void wbuf_nocrc_xids(struct wbuf *wb, XIDS xids); void wbuf_nocrc_xids(struct wbuf *wb, XIDS xids);
void xids_fprintf(FILE* fp, XIDS xids); void toku_xids_fprintf(FILE* fp, XIDS xids);
...@@ -96,7 +96,6 @@ PATENT RIGHTS GRANT: ...@@ -96,7 +96,6 @@ PATENT RIGHTS GRANT:
#include <string.h> #include <string.h>
#include <ft/le-cursor.h> #include <ft/le-cursor.h>
#include <ft/tokuconst.h>
#include <ft/ft-ops.h> #include <ft/ft-ops.h>
#include <ft/leafentry.h> #include <ft/leafentry.h>
#include <ft/ule.h> #include <ft/ule.h>
...@@ -199,7 +198,7 @@ indexer_undo_do_committed(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info * ...@@ -199,7 +198,7 @@ indexer_undo_do_committed(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info *
ULEHANDLE ule = prov_info->ule; ULEHANDLE ule = prov_info->ule;
// init the xids to the root xid // init the xids to the root xid
XIDS xids = xids_get_root_xids(); XIDS xids = toku_xids_get_root_xids();
// scan the committed stack from bottom to top // scan the committed stack from bottom to top
uint32_t num_committed = ule_get_num_committed(ule); uint32_t num_committed = ule_get_num_committed(ule);
...@@ -280,7 +279,7 @@ indexer_undo_do_committed(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info * ...@@ -280,7 +279,7 @@ indexer_undo_do_committed(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info *
break; break;
} }
xids_destroy(&xids); toku_xids_destroy(&xids);
return result; return result;
} }
...@@ -312,7 +311,7 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info ...@@ -312,7 +311,7 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info
ULEHANDLE ule = prov_info->ule; ULEHANDLE ule = prov_info->ule;
// init the xids to the root xid // init the xids to the root xid
XIDS xids = xids_get_root_xids(); XIDS xids = toku_xids_get_root_xids();
uint32_t num_provisional = prov_info->num_provisional; uint32_t num_provisional = prov_info->num_provisional;
uint32_t num_committed = prov_info->num_committed; uint32_t num_committed = prov_info->num_committed;
...@@ -472,7 +471,7 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info ...@@ -472,7 +471,7 @@ indexer_undo_do_provisional(DB_INDEXER *indexer, DB *hotdb, struct ule_prov_info
// then this will need to be handled below exit // then this will need to be handled below exit
release_txns(ule, prov_states, prov_txns, indexer); release_txns(ule, prov_states, prov_txns, indexer);
exit: exit:
xids_destroy(&xids); toku_xids_destroy(&xids);
return result; return result;
} }
...@@ -496,16 +495,16 @@ static int ...@@ -496,16 +495,16 @@ static int
indexer_set_xid(DB_INDEXER *UU(indexer), TXNID this_xid, XIDS *xids_result) { indexer_set_xid(DB_INDEXER *UU(indexer), TXNID this_xid, XIDS *xids_result) {
int result = 0; int result = 0;
XIDS old_xids = *xids_result; XIDS old_xids = *xids_result;
XIDS new_xids = xids_get_root_xids(); XIDS new_xids = toku_xids_get_root_xids();
if (this_xid != TXNID_NONE) { if (this_xid != TXNID_NONE) {
XIDS child_xids; XIDS child_xids;
result = xids_create_child(new_xids, &child_xids, this_xid); result = toku_xids_create_child(new_xids, &child_xids, this_xid);
xids_destroy(&new_xids); toku_xids_destroy(&new_xids);
if (result == 0) if (result == 0)
new_xids = child_xids; new_xids = child_xids;
} }
if (result == 0) { if (result == 0) {
xids_destroy(&old_xids); toku_xids_destroy(&old_xids);
*xids_result = new_xids; *xids_result = new_xids;
} }
...@@ -517,9 +516,9 @@ static int ...@@ -517,9 +516,9 @@ static int
indexer_append_xid(DB_INDEXER *UU(indexer), TXNID xid, XIDS *xids_result) { indexer_append_xid(DB_INDEXER *UU(indexer), TXNID xid, XIDS *xids_result) {
XIDS old_xids = *xids_result; XIDS old_xids = *xids_result;
XIDS new_xids; XIDS new_xids;
int result = xids_create_child(old_xids, &new_xids, xid); int result = toku_xids_create_child(old_xids, &new_xids, xid);
if (result == 0) { if (result == 0) {
xids_destroy(&old_xids); toku_xids_destroy(&old_xids);
*xids_result = new_xids; *xids_result = new_xids;
} }
return result; return result;
...@@ -682,7 +681,7 @@ indexer_ft_insert_committed(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, DBT *ho ...@@ -682,7 +681,7 @@ indexer_ft_insert_committed(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, DBT *ho
static int static int
indexer_ft_commit(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, XIDS xids) { indexer_ft_commit(DB_INDEXER *indexer, DB *hotdb, DBT *hotkey, XIDS xids) {
int result = 0; int result = 0;
if (xids_get_num_xids(xids) > 0) {// send commit only when not the root xid if (toku_xids_get_num_xids(xids) > 0) {// send commit only when not the root xid
// TEST // TEST
if (indexer->i->test_commit_any) { if (indexer->i->test_commit_any) {
result = indexer->i->test_commit_any(indexer, hotdb, hotkey, xids); result = indexer->i->test_commit_any(indexer, hotdb, hotkey, xids);
......
...@@ -99,7 +99,6 @@ PATENT RIGHTS GRANT: ...@@ -99,7 +99,6 @@ PATENT RIGHTS GRANT:
#include "ydb-internal.h" #include "ydb-internal.h"
#include <ft/le-cursor.h> #include <ft/le-cursor.h>
#include "indexer.h" #include "indexer.h"
#include <ft/tokuconst.h>
#include <ft/ft-ops.h> #include <ft/ft-ops.h>
#include <ft/leafentry.h> #include <ft/leafentry.h>
#include <ft/ule.h> #include <ft/ule.h>
......
...@@ -95,11 +95,11 @@ PATENT RIGHTS GRANT: ...@@ -95,11 +95,11 @@ PATENT RIGHTS GRANT:
#include "test.h" #include "test.h"
#include <ft/tokuconst.h> #include <ft/xids.h>
#include <ft/ule.h> #include <ft/ule.h>
#include <ft/ule-internal.h> #include <ft/ule-internal.h>
#include <ft/le-cursor.h> #include <ft/le-cursor.h>
#include <ft/xids-internal.h> #include <ft/xids.h>
#include "indexer-internal.h" #include "indexer-internal.h"
......
...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT: ...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT:
#include <memory.h> #include <memory.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <db.h> #include <db.h>
#include <ft/tokuconst.h> #include <ft/xids.h>
#define MAX_NEST MAX_NESTED_TRANSACTIONS #define MAX_NEST MAX_NESTED_TRANSACTIONS
......
...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT: ...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT:
#include <memory.h> #include <memory.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <db.h> #include <db.h>
#include <ft/tokuconst.h> #include <ft/xids.h>
#define MAX_NEST MAX_TRANSACTION_RECORDS #define MAX_NEST MAX_TRANSACTION_RECORDS
#define MAX_SIZE MAX_TRANSACTION_RECORDS #define MAX_SIZE MAX_TRANSACTION_RECORDS
......
...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT: ...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT:
#include <memory.h> #include <memory.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <db.h> #include <db.h>
#include <ft/tokuconst.h> #include <ft/xids.h>
#define MAX_NEST MAX_TRANSACTION_RECORDS #define MAX_NEST MAX_TRANSACTION_RECORDS
#define MAX_SIZE MAX_TRANSACTION_RECORDS #define MAX_SIZE MAX_TRANSACTION_RECORDS
......
...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT: ...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT:
#include <memory.h> #include <memory.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <db.h> #include <db.h>
#include <ft/tokuconst.h> #include <ft/xids.h>
#define MAX_NEST MAX_TRANSACTION_RECORDS #define MAX_NEST MAX_TRANSACTION_RECORDS
#define MAX_SIZE MAX_TRANSACTION_RECORDS #define MAX_SIZE MAX_TRANSACTION_RECORDS
......
...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT: ...@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT:
#include <memory.h> #include <memory.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <db.h> #include <db.h>
#include <ft/tokuconst.h> #include <ft/xids.h>
#define MAX_NEST MAX_TRANSACTION_RECORDS #define MAX_NEST MAX_TRANSACTION_RECORDS
#define MAX_SIZE (MAX_TRANSACTION_RECORDS + 1) #define MAX_SIZE (MAX_TRANSACTION_RECORDS + 1)
......
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