Commit ac575d01 authored by John Esmet's avatar John Esmet

FT-260 Move ftnode related structures and declarations to ft/node.h and ft/node.cc

parent 79a9a40d
...@@ -53,6 +53,7 @@ set(FT_SOURCES ...@@ -53,6 +53,7 @@ set(FT_SOURCES
logger logger
log_upgrade log_upgrade
msg_buffer msg_buffer
node
quicklz quicklz
recover recover
rollback rollback
......
...@@ -89,12 +89,13 @@ PATENT RIGHTS GRANT: ...@@ -89,12 +89,13 @@ PATENT RIGHTS GRANT:
#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."
#include <ft-cachetable-wrappers.h> #include "ft/fttypes.h"
#include "ft/ft-cachetable-wrappers.h"
#include "ft/ft-flusher.h"
#include "ft/ft-internal.h"
#include "ft/ft.h"
#include "ft/node.h"
#include <fttypes.h>
#include <ft-flusher.h>
#include <ft-internal.h>
#include <ft.h>
#include <util/context.h> #include <util/context.h>
static void static void
......
...@@ -92,8 +92,9 @@ PATENT RIGHTS GRANT: ...@@ -92,8 +92,9 @@ PATENT RIGHTS GRANT:
#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."
#include "ft/ft-internal.h"
#include "ft/cachetable.h" #include "ft/cachetable.h"
#include "ft/ft-internal.h"
#include "ft/node.h"
/** /**
* Put an empty node (that is, no fields filled) into the cachetable. * Put an empty node (that is, no fields filled) into the cachetable.
......
This diff is collapsed.
...@@ -151,11 +151,14 @@ toku_flusher_thread_set_callback( ...@@ -151,11 +151,14 @@ toku_flusher_thread_set_callback(
* Puts a workitem on the flusher thread queue, scheduling the node to be * Puts a workitem on the flusher thread queue, scheduling the node to be
* flushed by toku_ft_flush_some_child. * flushed by toku_ft_flush_some_child.
*/ */
void void toku_ft_flush_node_on_background_thread(FT ft, FTNODE parent);
toku_ft_flush_node_on_background_thread(
FT ft, enum split_mode {
FTNODE parent SPLIT_EVENLY,
); SPLIT_LEFT_HEAVY,
SPLIT_RIGHT_HEAVY
};
// Given pinned node and pinned child, split child into two // Given pinned node and pinned child, split child into two
// and update node with information about its new child. // and update node with information about its new child.
...@@ -166,6 +169,7 @@ void toku_ft_split_child( ...@@ -166,6 +169,7 @@ void toku_ft_split_child(
FTNODE child, FTNODE child,
enum split_mode split_mode enum split_mode split_mode
); );
// Given pinned node, merge childnum with a neighbor and update node with // Given pinned node, merge childnum with a neighbor and update node with
// information about the change // information about the change
void toku_ft_merge_child( void toku_ft_merge_child(
...@@ -217,8 +221,6 @@ ft_nonleaf_split( ...@@ -217,8 +221,6 @@ ft_nonleaf_split(
FTNODE* dependent_nodes FTNODE* dependent_nodes
); );
/************************************************************************ /************************************************************************
* HOT optimize, should perhaps be factored out to its own header file * * HOT optimize, should perhaps be factored out to its own header file *
************************************************************************ ************************************************************************
...@@ -249,5 +251,5 @@ void toku_ft_hot_get_status(FT_HOT_STATUS); ...@@ -249,5 +251,5 @@ void toku_ft_hot_get_status(FT_HOT_STATUS);
*/ */
int int
toku_ft_hot_optimize(FT_HANDLE ft_h, DBT* left, DBT* right, toku_ft_hot_optimize(FT_HANDLE ft_h, DBT* left, DBT* right,
int (*progress_callback)(void *extra, float progress), int (*progress_callback)(void *extra, float progress),
void *progress_extra, uint64_t* loops_run); void *progress_extra, uint64_t* loops_run);
...@@ -89,14 +89,15 @@ PATENT RIGHTS GRANT: ...@@ -89,14 +89,15 @@ PATENT RIGHTS GRANT:
#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."
#include <ft-flusher.h> #include "ft/ft.h"
#include <ft-flusher-internal.h> #include "ft/ft-cachetable-wrappers.h"
#include <ft-cachetable-wrappers.h> #include "ft/ft-flusher.h"
#include <ft-internal.h> #include "ft/ft-flusher-internal.h"
#include <ft.h> #include "ft/ft-internal.h"
#include <portability/toku_atomic.h> #include "ft/node.h"
#include <util/status.h> #include "portability/toku_atomic.h"
#include <util/context.h> #include "util/context.h"
#include "util/status.h"
// Member Descirption: // Member Descirption:
// 1. highest_pivot_key - this is the key that corresponds to the // 1. highest_pivot_key - this is the key that corresponds to the
...@@ -339,7 +340,7 @@ toku_ft_hot_optimize(FT_HANDLE ft_handle, DBT* left, DBT* right, ...@@ -339,7 +340,7 @@ toku_ft_hot_optimize(FT_HANDLE ft_handle, DBT* left, DBT* right,
PL_WRITE_EXPENSIVE, PL_WRITE_EXPENSIVE,
&root, &root,
true); true);
toku_assert_entire_node_in_memory(root); toku_ftnode_assert_fully_in_memory(root);
} }
// Prepare HOT diagnostics. // Prepare HOT diagnostics.
......
This diff is collapsed.
...@@ -89,8 +89,8 @@ PATENT RIGHTS GRANT: ...@@ -89,8 +89,8 @@ PATENT RIGHTS GRANT:
#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."
#include <ft-internal.h> #include "ft/node.h"
#include <db.h> #include "ft-internal.h"
/* /*
* ft-node-deserialize.c - * ft-node-deserialize.c -
......
This diff is collapsed.
...@@ -93,6 +93,7 @@ PATENT RIGHTS GRANT: ...@@ -93,6 +93,7 @@ PATENT RIGHTS GRANT:
#include "ft-flusher.h" #include "ft-flusher.h"
#include "ft-internal.h" #include "ft-internal.h"
#include "ft.h" #include "ft.h"
#include "node.h"
#include "fttypes.h" #include "fttypes.h"
#include "ule.h" #include "ule.h"
...@@ -222,7 +223,7 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, const ...@@ -222,7 +223,7 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, const
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);
toku_ft_node_put_msg ( toku_ftnode_put_msg(
ft_handle->ft->compare_fun, ft_handle->ft->compare_fun,
ft_handle->ft->update_fun, ft_handle->ft->update_fun,
&ft_handle->ft->cmp_descriptor, &ft_handle->ft->cmp_descriptor,
......
...@@ -100,6 +100,7 @@ PATENT RIGHTS GRANT: ...@@ -100,6 +100,7 @@ PATENT RIGHTS GRANT:
#include "ft-cachetable-wrappers.h" #include "ft-cachetable-wrappers.h"
#include "ft-internal.h" #include "ft-internal.h"
#include "ft.h" #include "ft.h"
#include "node.h"
static int static int
compare_pairs (FT_HANDLE ft_handle, const DBT *a, const DBT *b) { compare_pairs (FT_HANDLE ft_handle, const DBT *a, const DBT *b) {
...@@ -399,7 +400,7 @@ toku_verify_ftnode_internal(FT_HANDLE ft_handle, ...@@ -399,7 +400,7 @@ toku_verify_ftnode_internal(FT_HANDLE ft_handle,
BLOCKNUM blocknum = node->thisnodename; BLOCKNUM blocknum = node->thisnodename;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v); //printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
toku_assert_entire_node_in_memory(node); toku_ftnode_assert_fully_in_memory(node);
this_msn = node->max_msn_applied_to_node_on_disk; this_msn = node->max_msn_applied_to_node_on_disk;
if (height >= 0) { if (height >= 0) {
...@@ -501,7 +502,7 @@ toku_verify_ftnode (FT_HANDLE ft_handle, ...@@ -501,7 +502,7 @@ toku_verify_ftnode (FT_HANDLE ft_handle,
MSN this_msn; MSN this_msn;
//printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v); //printf("%s:%d pin %p\n", __FILE__, __LINE__, node_v);
toku_assert_entire_node_in_memory(node); toku_ftnode_assert_fully_in_memory(node);
this_msn = node->max_msn_applied_to_node_on_disk; this_msn = node->max_msn_applied_to_node_on_disk;
int result = 0; int result = 0;
......
...@@ -89,12 +89,12 @@ PATENT RIGHTS GRANT: ...@@ -89,12 +89,12 @@ PATENT RIGHTS GRANT:
#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."
#include "ft.h" #include "ft/ft.h"
#include "ft-internal.h" #include "ft/ft-cachetable-wrappers.h"
#include "ft-cachetable-wrappers.h" #include "ft/ft-internal.h"
#include "log-internal.h" #include "ft/log-internal.h"
#include "ft/log_header.h"
#include <ft/log_header.h> #include "ft/node.h"
#include <memory.h> #include <memory.h>
#include <toku_assert.h> #include <toku_assert.h>
......
This diff is collapsed.
...@@ -96,6 +96,7 @@ PATENT RIGHTS GRANT: ...@@ -96,6 +96,7 @@ PATENT RIGHTS GRANT:
#include "fttypes.h" #include "fttypes.h"
#include "ft-internal.h" #include "ft-internal.h"
#include "node.h"
#include "ft_layout_version.h" #include "ft_layout_version.h"
#include "block_table.h" #include "block_table.h"
#include "rbuf.h" #include "rbuf.h"
......
...@@ -111,6 +111,7 @@ PATENT RIGHTS GRANT: ...@@ -111,6 +111,7 @@ PATENT RIGHTS GRANT:
#include "leafentry.h" #include "leafentry.h"
#include "log-internal.h" #include "log-internal.h"
#include "ft.h" #include "ft.h"
#include "node.h"
static size_t (*os_fwrite_fun)(const void *,size_t,size_t,FILE*)=NULL; static size_t (*os_fwrite_fun)(const void *,size_t,size_t,FILE*)=NULL;
void ft_loader_set_os_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) { void ft_loader_set_os_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) {
......
...@@ -129,23 +129,19 @@ struct message_buffer::buffer_entry *message_buffer::get_buffer_entry(int32_t of ...@@ -129,23 +129,19 @@ struct message_buffer::buffer_entry *message_buffer::get_buffer_entry(int32_t of
} }
void message_buffer::enqueue(FT_MSG msg, bool is_fresh, int32_t *offset) { void message_buffer::enqueue(FT_MSG msg, bool is_fresh, int32_t *offset) {
ITEMLEN keylen = ft_msg_get_keylen(msg); int need_space_here = msg_memsize_in_buffer(msg);
ITEMLEN datalen = ft_msg_get_vallen(msg);
XIDS xids = ft_msg_get_xids(msg);
int need_space_here = sizeof(struct buffer_entry)
+ keylen + datalen
+ xids_get_size(xids)
- sizeof(XIDS_S); //Prevent double counting
int need_space_total = _memory_used + need_space_here; int need_space_total = _memory_used + need_space_here;
if (_memory == nullptr || need_space_total > _memory_size) { if (_memory == nullptr || need_space_total > _memory_size) {
// resize the buffer to the next power of 2 greater than the needed space // resize the buffer to the next power of 2 greater than the needed space
int next_2 = next_power_of_two(need_space_total); int next_2 = next_power_of_two(need_space_total);
resize(next_2); resize(next_2);
} }
ITEMLEN keylen = ft_msg_get_keylen(msg);
ITEMLEN datalen = ft_msg_get_vallen(msg);
struct buffer_entry *entry = get_buffer_entry(_memory_used); struct buffer_entry *entry = get_buffer_entry(_memory_used);
entry->type = (unsigned char) ft_msg_get_type(msg); entry->type = (unsigned char) ft_msg_get_type(msg);
entry->msn = msg->msn; entry->msn = msg->msn;
xids_cpy(&entry->xids_s, xids); xids_cpy(&entry->xids_s, ft_msg_get_xids(msg));
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 = xids_get_end_of_array(&entry->xids_s);
entry->keylen = keylen; entry->keylen = keylen;
...@@ -217,8 +213,8 @@ bool message_buffer::equals(message_buffer *other) const { ...@@ -217,8 +213,8 @@ bool message_buffer::equals(message_buffer *other) const {
} }
size_t message_buffer::msg_memsize_in_buffer(FT_MSG msg) { size_t message_buffer::msg_memsize_in_buffer(FT_MSG msg) {
return sizeof(struct buffer_entry) const uint32_t keylen = ft_msg_get_keylen(msg);
+ msg->u.id.key->size + msg->u.id.val->size const uint32_t datalen = ft_msg_get_vallen(msg);
+ xids_get_size(msg->xids) const size_t xidslen = xids_get_size(msg->xids);
- sizeof(XIDS_S); return sizeof(struct buffer_entry) + keylen + datalen + xidslen - sizeof(XIDS_S);
} }
This diff is collapsed.
This diff is collapsed.
...@@ -245,7 +245,7 @@ doit (void) { ...@@ -245,7 +245,7 @@ doit (void) {
// what we say and flushes the child we pick // what we say and flushes the child we pick
FTNODE node = NULL; FTNODE node = NULL;
toku_pin_node_with_min_bfe(&node, node_internal, t); toku_pin_node_with_min_bfe(&node, node_internal, t);
toku_assert_entire_node_in_memory(node); toku_ftnode_assert_fully_in_memory(node);
assert(node->n_children == 2); assert(node->n_children == 2);
assert(!node->dirty); assert(!node->dirty);
assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) > 0); assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) > 0);
...@@ -268,7 +268,7 @@ doit (void) { ...@@ -268,7 +268,7 @@ doit (void) {
assert(num_flushes_called == 1); assert(num_flushes_called == 1);
toku_pin_node_with_min_bfe(&node, node_internal, t); toku_pin_node_with_min_bfe(&node, node_internal, t);
toku_assert_entire_node_in_memory(node); toku_ftnode_assert_fully_in_memory(node);
assert(node->dirty); assert(node->dirty);
assert(node->n_children == 2); assert(node->n_children == 2);
// child 0 should have empty buffer because it flushed // child 0 should have empty buffer because it flushed
...@@ -287,7 +287,7 @@ doit (void) { ...@@ -287,7 +287,7 @@ doit (void) {
toku_pin_node_with_min_bfe(&node, node_internal, t); toku_pin_node_with_min_bfe(&node, node_internal, t);
assert(node->dirty); assert(node->dirty);
toku_assert_entire_node_in_memory(node); toku_ftnode_assert_fully_in_memory(node);
assert(node->n_children == 2); assert(node->n_children == 2);
// both buffers should be empty now // both buffers should be empty now
assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0); assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0);
...@@ -305,7 +305,7 @@ doit (void) { ...@@ -305,7 +305,7 @@ doit (void) {
toku_pin_node_with_min_bfe(&node, node_internal, t); toku_pin_node_with_min_bfe(&node, node_internal, t);
assert(node->dirty); // nothing was flushed, but since we were trying to flush to a leaf, both become dirty assert(node->dirty); // nothing was flushed, but since we were trying to flush to a leaf, both become dirty
toku_assert_entire_node_in_memory(node); toku_ftnode_assert_fully_in_memory(node);
assert(node->n_children == 2); assert(node->n_children == 2);
// both buffers should be empty now // both buffers should be empty now
assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0); assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0);
...@@ -326,7 +326,7 @@ doit (void) { ...@@ -326,7 +326,7 @@ doit (void) {
// use a for loop so to get us down both paths // use a for loop so to get us down both paths
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
toku_pin_node_with_min_bfe(&node, node_root, t); toku_pin_node_with_min_bfe(&node, node_root, t);
toku_assert_entire_node_in_memory(node); // entire root is in memory toku_ftnode_assert_fully_in_memory(node); // entire root is in memory
curr_child_to_flush = i; curr_child_to_flush = i;
num_flushes_called = 0; num_flushes_called = 0;
toku_ft_flush_some_child(t->ft, node, &fa); toku_ft_flush_some_child(t->ft, node, &fa);
...@@ -376,7 +376,7 @@ doit (void) { ...@@ -376,7 +376,7 @@ doit (void) {
//now let's do the same test as above //now let's do the same test as above
toku_pin_node_with_min_bfe(&node, node_root, t); toku_pin_node_with_min_bfe(&node, node_root, t);
toku_assert_entire_node_in_memory(node); // entire root is in memory toku_ftnode_assert_fully_in_memory(node); // entire root is in memory
curr_child_to_flush = 0; curr_child_to_flush = 0;
num_flushes_called = 0; num_flushes_called = 0;
toku_ft_flush_some_child(t->ft, node, &fa); toku_ft_flush_some_child(t->ft, node, &fa);
......
...@@ -102,6 +102,7 @@ PATENT RIGHTS GRANT: ...@@ -102,6 +102,7 @@ PATENT RIGHTS GRANT:
#include <portability/toku_path.h> #include <portability/toku_path.h>
#include "ft.h" #include "ft.h"
#include "node.h"
#include "block_table.h" #include "block_table.h"
#include "log-internal.h" #include "log-internal.h"
#include "logger.h" #include "logger.h"
......
...@@ -180,7 +180,7 @@ static void test_split_merge(void) { ...@@ -180,7 +180,7 @@ static void test_split_merge(void) {
toku_pin_ftnode(ft, rightmost_blocknum_before_merge, toku_pin_ftnode(ft, rightmost_blocknum_before_merge,
toku_cachetable_hash(ft->cf, rightmost_blocknum_before_merge), toku_cachetable_hash(ft->cf, rightmost_blocknum_before_merge),
&bfe, PL_WRITE_EXPENSIVE, &rightmost_leaf, true); &bfe, PL_WRITE_EXPENSIVE, &rightmost_leaf, true);
invariant(get_node_reactivity(ft, rightmost_leaf) == RE_FUSIBLE); invariant(toku_ftnode_get_reactivity(ft, rightmost_leaf) == RE_FUSIBLE);
toku_unpin_ftnode(ft, rightmost_leaf); toku_unpin_ftnode(ft, rightmost_leaf);
// - merge the rightmost child now that it's fusible // - merge the rightmost child now that it's fusible
......
...@@ -95,6 +95,7 @@ PATENT RIGHTS GRANT: ...@@ -95,6 +95,7 @@ PATENT RIGHTS GRANT:
#include "ft.h" #include "ft.h"
#include "fttypes.h" #include "fttypes.h"
#include "ft-internal.h" #include "ft-internal.h"
#include "ft/node.h"
#include <ctype.h> #include <ctype.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
......
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