Commit 3719bf2c authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

[t:4901] merging brt->ft rename to main

git-svn-id: file:///svn/toku/tokudb@43686 c7de825b-a66e-492c-adef-691d508d4ae1
parent fe705b38
......@@ -84,7 +84,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/toku_include
${CMAKE_CURRENT_SOURCE_DIR}/portability
${CMAKE_CURRENT_SOURCE_DIR} ## so you can include <newbrt/brt.h> from inside src/
${CMAKE_CURRENT_SOURCE_DIR} ## so you can include <ft/ft-ops.h> from inside src/
${CMAKE_CURRENT_BINARY_DIR} ## for logging code
)
## include where config.h will be generated
......@@ -96,7 +96,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/buildheader)
## add subdirectories
add_subdirectory(portability)
add_subdirectory(newbrt)
add_subdirectory(ft)
add_subdirectory(src)
add_subdirectory(utils)
add_subdirectory(db-benchmark-test)
......
......@@ -2,9 +2,9 @@ cmake_policy(SET CMP0012 NEW)
## these tests shouldn't run with valgrind
list(APPEND CTEST_CUSTOM_MEMCHECK_IGNORE
brtloader-test-extractor-1
brtloader-test-extractor-2
brtloader-test-extractor-3
ft_loader-test-extractor-1
ft_loader-test-extractor-2
ft_loader-test-extractor-3
brt-serialize-benchmark
bnc-insert-benchmark
test_groupcommit_perf.tdb
......
......@@ -12,16 +12,16 @@ else
SRCDIRS_CXX = cxx db-benchmark-test-cxx
endif
SRCDIRS = $(OS_CHOICE) newbrt src/range_tree src/lock_tree src utils db-benchmark-test $(SRCDIRS_CXX)
SRCDIRS = $(OS_CHOICE) ft src/range_tree src/lock_tree src utils db-benchmark-test $(SRCDIRS_CXX)
BUILDDIRS = $(SRCDIRS) man/texi
ifeq ($(OS_CHOICE),windows)
.NOTPARALLEL:; #Windows/cygwin jobserver does not properly handle submakes. Serialize
endif
newbrt.dir: $(OS_CHOICE).dir
ft.dir: $(OS_CHOICE).dir
src/range_tree.dir: $(OS_CHOICE).dir
src/lock_tree.dir: src/range_tree.dir
src.dir: newbrt.dir src/lock_tree.dir
src.dir: ft.dir src/lock_tree.dir
utils.dir: src.dir
db-benchmark-test.dir: src.dir
cxx.dir: src.dir
......@@ -41,7 +41,7 @@ build: $(patsubst %,%.dir, $(BUILDDIRS))
%.check:
cd $(patsubst %.check, %,$@) && $(MAKE) check
release: linux.local newbrt.local src.local release.local
release: linux.local ft.local src.local release.local
CHECKS = $(patsubst %,%.checkdir,$(SRCDIRS))
......@@ -60,26 +60,26 @@ summarize: check
check: $(CHECKS)
.PHONY: fastbuild fastbuildtests fastcheck fastchecknewbrt fastcheckydb fastcheckonlyfail fastcheckonlyfailnewbrt fastcheckonlyfailydb
.PHONY: fastbuild fastbuildtests fastcheck fastcheckft fastcheckydb fastcheckonlyfail fastcheckonlyfailft fastcheckonlyfailydb
fastbuild:
$(MAKE) -s -k -C linux
$(MAKE) -s -k -C newbrt local
$(MAKE) -s -k -C ft local
$(MAKE) -s -k -C src local
$(MAKE) -s -k -C utils
fastbuildtests: fastbuild
$(MAKE) -s -k -C newbrt/tests
$(MAKE) -s -k -C ft/tests
$(MAKE) -s -k -C src/tests tests.tdb
fastcheck: fastchecknewbrt fastcheckydb
fastchecknewbrt: fastbuildtests
$(MAKE) -s -k -C newbrt/tests fastcheck
fastcheck: fastcheckft fastcheckydb
fastcheckft: fastbuildtests
$(MAKE) -s -k -C ft/tests fastcheck
fastcheckydb: fastbuildtests
$(MAKE) -s -k -C src/tests fastcheck.tdb
fastcheckonlyfail: fastcheckonlyfailnewbrt fastcheckonlyfailydb
fastcheckonlyfailnewbrt: fastbuildtests
$(MAKE) -s -k -C newbrt/tests fastcheckonlyfail
fastcheckonlyfail: fastcheckonlyfailft fastcheckonlyfailydb
fastcheckonlyfailft: fastbuildtests
$(MAKE) -s -k -C ft/tests fastcheckonlyfail
fastcheckonlyfailydb: fastbuildtests
$(MAKE) -s -k -C src/tests fastcheckonlyfail.tdb
......@@ -114,12 +114,12 @@ build-coverage:
$(MAKE) build OPTFLAGS= GCOV_FLAGS="-fprofile-arcs -ftest-coverage"
# this is messy now since we dont have consistent make targets
check-coverage: check-coverage-newbrt check-coverage-src-tests check-coverage-utils check-coverage-cxx-tests \
check-coverage: check-coverage-ft check-coverage-src-tests check-coverage-utils check-coverage-cxx-tests \
check-coverage-db-benchmark-test check-coverage-db-benchmark-test-cxx \
check-coverage-range-tree-tests check-coverage-lock-tree-tests
check-coverage-newbrt:
(cd newbrt && $(MAKE) -k check VGRIND="")
check-coverage-ft:
(cd ft && $(MAKE) -k check VGRIND="")
check-coverage-src-tests:
(cd src/tests && $(MAKE) -k check.tdb VGRIND="")
check-coverage-utils:
......
......@@ -4,25 +4,25 @@ file(GLOB_RECURSE all_srcs
toku_include/*.c
buildheader/*.c
portability/*.c
newbrt/*.c
ft/*.c
src/*.c
utils/*.c
db-benchmark-test/*.c
${CMAKE_CURRENT_BINARY_DIR}/newbrt/log_code.c
${CMAKE_CURRENT_BINARY_DIR}/newbrt/log_print.c
${CMAKE_CURRENT_BINARY_DIR}/ft/log_code.c
${CMAKE_CURRENT_BINARY_DIR}/ft/log_print.c
)
file(GLOB_RECURSE all_hdrs
include/*.h
toku_include/*.h
buildheader/*.h
portability/*.h
newbrt/*.h
ft/*.h
src/*.h
utils/*.h
db-benchmark-test/*.h
${CMAKE_CURRENT_BINARY_DIR}/toku_include/config.h
${CMAKE_CURRENT_BINARY_DIR}/buildheader/db.h
${CMAKE_CURRENT_BINARY_DIR}/newbrt/log_header.h
${CMAKE_CURRENT_BINARY_DIR}/ft/log_header.h
)
option(USE_CTAGS "Build the ctags database." ON)
......
......@@ -117,7 +117,7 @@ include(CTest)
if (BUILD_TESTING)
## set up full valgrind suppressions file (concatenate the suppressions files)
file(READ newbrt/valgrind.suppressions valgrind_suppressions)
file(READ ft/valgrind.suppressions valgrind_suppressions)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${valgrind_suppressions}")
file(READ src/tests/bdb.suppressions bdb_suppressions)
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${bdb_suppressions}")
......
#include <stdarg.h>
#include <errno.h>
#include <toku_assert.h>
#include "../newbrt/brttypes.h"
#include "../ft/fttypes.h"
#include <db_cxx.h>
DbEnv::DbEnv (u_int32_t flags)
......
......@@ -47,7 +47,7 @@ endif
ifneq ($(OSX),)
VGRIND=
else
VGRIND=valgrind --quiet --error-exitcode=1 --leak-check=yes --suppressions=../../newbrt/valgrind.suppressions
VGRIND=valgrind --quiet --error-exitcode=1 --leak-check=yes --suppressions=../../ft/valgrind.suppressions
endif
default: build
......
......@@ -9,7 +9,7 @@
.DEFAULT_GOAL= build
TOKUROOT=../
INCLUDEDIRS=-I. -I../ -I$(TOKUROOT)include -I$(TOKUROOT)toku_include -I$(TOKUROOT)newbrt -I../range_tree -I../lock_tree
INCLUDEDIRS=-I. -I../ -I$(TOKUROOT)include -I$(TOKUROOT)toku_include -I$(TOKUROOT)ft -I../range_tree -I../lock_tree
DEPEND_COMPILE += \
./*.h \
#end
......
......@@ -7,7 +7,7 @@
.DEFAULT_GOAL= build
TOKUROOT=../
INCLUDEDIRS=-I. -I$(TOKUROOT)newbrt -I$(TOKUROOT)include -I$(TOKUROOT)/toku_include -I$(TOKUROOT)src
INCLUDEDIRS=-I. -I$(TOKUROOT)ft -I$(TOKUROOT)include -I$(TOKUROOT)/toku_include -I$(TOKUROOT)src
DEPEND_COMPILE += \
../*.h \
../range_tree/*.h \
......@@ -144,7 +144,7 @@ OFILES = \
$(TOKUROOT)src/ydb.lib \
$(TOKUROOT)src/lock_tree/locktree.lib \
$(TOKUROOT)src/range_tree/rangetree.lib \
$(TOKUROOT)newbrt/newbrt.lib \
$(TOKUROOT)ft/ft.lib \
$(LIBPORTABILITY_SO) \
#end
......
......@@ -11,8 +11,8 @@
#include <fcntl.h>
#include <unistd.h>
#ifdef TOKUDB
#include <newbrt/key.h>
#include <newbrt/cachetable.h>
#include <ft/key.h>
#include <ft/cachetable.h>
#endif
static const char *pname;
......
......@@ -17,36 +17,33 @@ add_custom_command(
DEPENDS logformat
)
set(BRT_SOURCES
set(FT_SOURCES
block_allocator.c
block_table.c
brtloader.c
brtloader-callback.c
brt-serialize.c
brt-verify.c
brt.c
brt-cachetable-wrappers.c
brt-flusher.c
brt_header.c
brt-hot-flusher.c
brt_msg.c
brt-test-helpers.c
cachetable.c
checkpoint.c
compress.c
dbufio.c
fifo.c
ft.c
ft-cachetable-wrappers.c
ft-flusher.c
ft-hot-flusher.c
ftloader.c
ftloader-callback.c
ft_msg.c
ft-ops.c
ft-serialize.c
ft-test-helpers.c
ft-verify.c
key.c
kibbutz.c
leafentry.c
le-cursor.c
logcursor.c
logfilemgr.c
logger.c
"${CMAKE_CURRENT_BINARY_DIR}/log_code.c"
"${CMAKE_CURRENT_BINARY_DIR}/log_header.h"
log_upgrade.c
"${CMAKE_CURRENT_BINARY_DIR}/log_print.c"
logcursor.c
memarena.c
mempool.c
minicron.c
......@@ -55,66 +52,69 @@ set(BRT_SOURCES
queue.c
quicklz.c
recover.c
roll.c
rollback.c
roll.c
sort.c
sub_block.c
ule.c
threadpool.c
txn.c
ule.c
workqueue.c
x1764.c
xids.c
ybt.c
"${CMAKE_CURRENT_BINARY_DIR}/log_code.c"
"${CMAKE_CURRENT_BINARY_DIR}/log_header.h"
"${CMAKE_CURRENT_BINARY_DIR}/log_print.c"
)
add_library(newbrt SHARED ${BRT_SOURCES})
add_library(newbrt_static STATIC ${BRT_SOURCES})
add_library(ft SHARED ${FT_SOURCES})
add_library(ft_static STATIC ${FT_SOURCES})
## we're going to link this into libtokudb.so so it needs to have PIC
set_property(TARGET newbrt_static APPEND PROPERTY COMPILE_FLAGS "-fPIC")
maybe_add_gcov_to_libraries(newbrt newbrt_static)
set_property(TARGET ft_static APPEND PROPERTY COMPILE_FLAGS "-fPIC")
maybe_add_gcov_to_libraries(ft ft_static)
## depend on other generated targets
add_dependencies(newbrt install_tdb_h build_lzma)
add_dependencies(newbrt_static install_tdb_h build_lzma)
add_dependencies(ft install_tdb_h build_lzma)
add_dependencies(ft_static install_tdb_h build_lzma)
## link with tokuportability, and lzma (which should be static)
target_link_libraries(newbrt ${LIBTOKUPORTABILITY} lzma)
target_link_libraries(newbrt_static ${LIBTOKUPORTABILITY} lzma)
target_link_libraries(ft ${LIBTOKUPORTABILITY} lzma)
target_link_libraries(ft_static ${LIBTOKUPORTABILITY} lzma)
if (CMAKE_C_COMPILER_ID STREQUAL Intel)
## don't link with default libs, those come with tokuportability, but we
## do need libc and we need the intel libirc (and it should be static to
## be redistributable)
target_link_libraries(newbrt -nodefaultlibs c -Bstatic irc -Bdynamic)
target_link_libraries(ft -nodefaultlibs c -Bstatic irc -Bdynamic)
endif ()
## conditionally use cilk
if (USE_CILK)
set_property(TARGET newbrt APPEND PROPERTY COMPILE_DEFINITIONS HAVE_CILK=1)
set_property(TARGET newbrt_static APPEND PROPERTY COMPILE_DEFINITIONS HAVE_CILK=1)
target_link_libraries(newbrt cilkrts)
target_link_libraries(newbrt_static cilkrts)
set_property(TARGET ft APPEND PROPERTY COMPILE_DEFINITIONS HAVE_CILK=1)
set_property(TARGET ft_static APPEND PROPERTY COMPILE_DEFINITIONS HAVE_CILK=1)
target_link_libraries(ft cilkrts)
target_link_libraries(ft_static cilkrts)
endif (USE_CILK)
## build the bins in this directory
set(bins
brtdump
ftdump
tdb_logprint
tdb-recover
)
foreach(bin ${bins})
add_executable(${bin} ${bin}.c)
add_dependencies(${bin} install_tdb_h)
target_link_libraries(${bin} newbrt ${LIBTOKUPORTABILITY})
target_link_libraries(${bin} ft ${LIBTOKUPORTABILITY})
add_executable(${bin}_static ${bin}.c)
add_dependencies(${bin} install_tdb_h)
target_link_libraries(${bin}_static newbrt_static ${LIBTOKUPORTABILITY_STATIC})
target_link_libraries(${bin}_static ft_static ${LIBTOKUPORTABILITY_STATIC})
endforeach(bin)
install(
TARGETS brtdump_static
TARGETS ftdump_static
DESTINATION bin
)
......
ROOT = ../
build: newbrt.builddir
check: newbrt.checkdir
build: ft.builddir
check: ft.checkdir
include $(ROOT)Makefile.include
......
......@@ -13,19 +13,19 @@ DEPEND_COMPILE += \
log_header.h \
# keep this line so I can have a \ on the previous line
NEWBRT_SO = $(TOKUROOT)lib/libnewbrt.$(SOEXT)
NEWBRT_A = $(TOKUROOT)lib/libnewbrt.$(AEXT)
FT_SO = $(TOKUROOT)lib/libft.$(SOEXT)
FT_A = $(TOKUROOT)lib/libft.$(AEXT)
SKIP_NEWBRTRULE=1
SKIP_FTRULE=1
include $(TOKUROOT)toku_include/Makefile.include
LDFLAGS+=-L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib
LDLIBS+=-lnewbrt -l$(LIBTOKUPORTABILITY)
LDLIBS+=-lft -l$(LIBTOKUPORTABILITY)
# When debugging, try: valgrind --show-reachable=yes --leak-check=full ./brt-test
BINS_RAW= \
brtdump \
brtdump_static \
ftdump \
ftdump_static \
tdb_logprint \
tdb-recover \
# Intentionally left blank
......@@ -36,20 +36,20 @@ BINS_RAW= \
build default: local
cd tests;$(MAKE) build
local: bins libs $(TEST_NEWBRT);
local: bins libs $(TEST_FT);
BRT_SOURCES = \
FT_SOURCES = \
block_allocator \
block_table \
brtloader-callback \
ft_loader-callback \
brt-serialize \
brt-verify \
brt \
brt-cachetable-wrappers \
brt-flusher \
brt-hot-flusher \
brt_msg \
ft_msg \
brt-test-helpers \
cachetable \
checkpoint \
......@@ -85,40 +85,40 @@ BRT_SOURCES = \
ybt \
# keep this line so I can have a \ on the previous line
ifneq ($(OS_CHOICE),windows)
BRT_SOURCES += trace_mem #Windows does not handle 'empty' file
FT_SOURCES += trace_mem #Windows does not handle 'empty' file
endif
TEST_NEWBRT = brt-test-helpers.$(OEXT)
TEST_FT = brt-test-helpers.$(OEXT)
BRT_C_FILES = $(patsubst %,%.c,$(BRT_SOURCES))
BRT_O_FILES = $(patsubst %,%.$(OEXT),$(BRT_SOURCES))
FT_C_FILES = $(patsubst %,%.c,$(FT_SOURCES))
FT_O_FILES = $(patsubst %,%.$(OEXT),$(FT_SOURCES))
newbrt.$(OEXT): $(BRT_C_FILES) $(DEPEND_COMPILE)
$(CC) -c $(BRT_C_FILES) $(COMBINE_C) $(CPPFLAGS) $(CFLAGS) $(OOUTPUT)$@
ft.$(OEXT): $(FT_C_FILES) $(DEPEND_COMPILE)
$(CC) -c $(FT_C_FILES) $(COMBINE_C) $(CPPFLAGS) $(CFLAGS) $(OOUTPUT)$@
brt-serialize.$(OEXT): $(wildcard backwards_*.c)
ifneq ($(CYGWIN),)
NEWBRT_O_FILES = $(BRT_O_FILES)
FT_O_FILES = $(FT_O_FILES)
else ifeq ($(CC),icc)
NEWBRT_O_FILES = $(BRT_O_FILES)
FT_O_FILES = $(FT_O_FILES)
else ifeq ($(COMBINE),0)
NEWBRT_O_FILES = $(BRT_O_FILES)
FT_O_FILES = $(FT_O_FILES)
else
NEWBRT_O_FILES = newbrt.o
FT_O_FILES = ft.o
endif
NEWBRT_O_FILES += brtloader.$(OEXT) quicklz.$(OEXT) compress.$(OEXT)
FT_O_FILES += ft_loader.$(OEXT) quicklz.$(OEXT) compress.$(OEXT)
brtloader.$(OEXT): $(DEPEND_COMPILE)
ft_loader.$(OEXT): $(DEPEND_COMPILE)
$(NEWBRT_O_FILES): VISIBILITY=
$(NEWBRT_O_FILES): $(LZMA_H)
$(NEWBRT_SO): DISABLE_WARNING += 10237 # Do not complain about -lcilkrts being linked in dynamically, static library not available
$(NEWBRT_SO): $(NEWBRT_O_FILES) $(LZMA_A)
$(TOKULINKER) $(SHARED) $(SYMBOLS) $(GCOV_FLAGS) $(SKIP_WARNING) $(NEWBRT_O_FILES) $(LZMA_A) -o$(NEWBRT_SO) $(LINUX_NOSTDLIB) $(LCILKRTS)
$(NEWBRT_A): $(NEWBRT_O_FILES)
$(FT_O_FILES): VISIBILITY=
$(FT_O_FILES): $(LZMA_H)
$(FT_SO): DISABLE_WARNING += 10237 # Do not complain about -lcilkrts being linked in dynamically, static library not available
$(FT_SO): $(FT_O_FILES) $(LZMA_A)
$(TOKULINKER) $(SHARED) $(SYMBOLS) $(GCOV_FLAGS) $(SKIP_WARNING) $(FT_O_FILES) $(LZMA_A) -o$(FT_SO) $(LINUX_NOSTDLIB) $(LCILKRTS)
$(FT_A): $(FT_O_FILES)
log_code.$(OEXT): log_header.h wbuf.h log-internal.h rbuf.h
......@@ -132,15 +132,15 @@ log_code.c: logformat$(BINSUF)
log_print.c log_header.h: log_code.c
test 1 = 1
#Needs to be done manually since it does not include newbrt.
#Needs to be done manually since it does not include ft.
logformat$(BINSUF): logformat.c $(LIBPORTABILITY_SO)
$(CC) $< $(BIN_FROM_O_FLAGS_NOLIB) $(LDFLAGS) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST) $(LIBPORTABILITY_SO)
ifeq ($(PROF),1)
libs: $(NEWBRT_A)
libs: $(FT_A)
else
libs: $(NEWBRT_SO) $(NEWBRT_A)
libs: $(FT_SO) $(FT_A)
endif
bins: $(BINS)
......@@ -151,9 +151,9 @@ check: bins
cd tests;$(MAKE) check
ifeq ($(PROF),1)
$(BINS): $(NEWBRT_A) $(LIBPORTABILITY_A)
$(BINS): $(FT_A) $(LIBPORTABILITY_A)
else
$(BINS): $(NEWBRT_SO) $(LIBPORTABILITY_SO)
$(BINS): $(FT_SO) $(LIBPORTABILITY_SO)
endif
foo2:
......@@ -171,19 +171,19 @@ clean: clean-local clean-tests
clean-tests:
cd tests;$(MAKE) clean
clean-local:
$(RM) $(TOKUROOT)lib/libnewbrt.$(AEXT) $(TOKUROOT)lib/libnewbrt.$(SOEXT)
rm -rf $(NEWBRT)
rm -rf test_oexcl.c.tmp *.brt
$(RM) $(TOKUROOT)lib/libft.$(AEXT) $(TOKUROOT)lib/libft.$(SOEXT)
rm -rf $(FT)
rm -rf test_oexcl.c.tmp *.ft_handle
rm -rf log_code.c log_header.h log_print.c logformat
brtdump_static$(BINSUF): DEPEND_LINK = -lpthread -ldl -lz
brtdump_static$(BINSUF): brtdump.$(OEXT) $(NEWBRT_A) $(LZMA_A) $(LIBPORTABILITY_A) $(DEPEND_COMPILE) $(DEPEND_LINK)
$(CC) $< $(NEWBRT_A) $(LZMA_A) $(LIBPORTABILITY_A) $(BIN_FROM_O_FLAGS_NOLIB) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST)
ftdump_static$(BINSUF): DEPEND_LINK = -lpthread -ldl -lz
ftdump_static$(BINSUF): ftdump.$(OEXT) $(FT_A) $(LZMA_A) $(LIBPORTABILITY_A) $(DEPEND_COMPILE) $(DEPEND_LINK)
$(CC) $< $(FT_A) $(LZMA_A) $(LIBPORTABILITY_A) $(BIN_FROM_O_FLAGS_NOLIB) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST)
# After doing (cd ../src/tests;make test_log5.recover), run these. The files should have no differences.
testdump: brtdump$(BINSUF)
./brtdump ../src/tests/dir.test_log5.c.tdb.recover/foo.db > dump.r && ./brtdump ../src/tests/dir.test_log5.c.tdb/foo.db > dump.$(OEXT) && diff dump.$(OEXT) dump.r
testdump: ftdump$(BINSUF)
./ftdump ../src/tests/dir.test_log5.c.tdb.recover/foo.db > dump.r && ./ftdump ../src/tests/dir.test_log5.c.tdb/foo.db > dump.$(OEXT) && diff dump.$(OEXT) dump.r
foo:
@echo BRTLOADER $(BRTLOADER)
@echo FTLOADER $(FTLOADER)
@echo BDBDIR $(BDBDIR)
......@@ -6,7 +6,7 @@
#ident "Copyright (c) 2007-2010 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."
#include "brttypes.h"
#include "fttypes.h"
#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
......
......@@ -4,8 +4,8 @@
#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 <toku_portability.h>
#include "brt-internal.h" // ugly but pragmatic, need access to dirty bits while holding translation lock
#include "brttypes.h"
#include "ft-internal.h" // ugly but pragmatic, need access to dirty bits while holding translation lock
#include "fttypes.h"
#include "block_table.h"
#include "memory.h"
#include "toku_assert.h"
......@@ -83,11 +83,11 @@ static inline void unlock_for_blocktable (BLOCK_TABLE bt);
static void
brtheader_set_dirty(struct brt_header *h, BOOL for_checkpoint){
ft_set_dirty(FT h, BOOL for_checkpoint){
assert(toku_mutex_is_locked(&h->blocktable->mutex));
assert(h->type == BRTHEADER_CURRENT);
assert(h->type == FT_CURRENT);
if (for_checkpoint) {
assert(h->checkpoint_header->type == BRTHEADER_CHECKPOINT_INPROGRESS);
assert(h->checkpoint_header->type == FT_CHECKPOINT_INPROGRESS);
h->checkpoint_header->dirty = 1;
}
else {
......@@ -97,7 +97,7 @@ brtheader_set_dirty(struct brt_header *h, BOOL for_checkpoint){
//fd is protected (must be holding fdlock)
static void
maybe_truncate_cachefile(BLOCK_TABLE bt, int fd, struct brt_header *h, u_int64_t size_needed_before) {
maybe_truncate_cachefile(BLOCK_TABLE bt, int fd, FT h, u_int64_t size_needed_before) {
assert(toku_mutex_is_locked(&bt->mutex));
u_int64_t new_size_needed = block_allocator_allocated_limit(bt->block_allocator);
//Save a call to toku_os_get_file_size (kernel call) if unlikely to be useful.
......@@ -107,7 +107,7 @@ maybe_truncate_cachefile(BLOCK_TABLE bt, int fd, struct brt_header *h, u_int64_t
//fd is protected (must be holding fdlock)
void
toku_maybe_truncate_cachefile_on_open(BLOCK_TABLE bt, int fd, struct brt_header *h) {
toku_maybe_truncate_cachefile_on_open(BLOCK_TABLE bt, int fd, FT h) {
lock_for_blocktable(bt);
u_int64_t size_needed = block_allocator_allocated_limit(bt->block_allocator);
toku_maybe_truncate_cachefile(h->cf, fd, size_needed);
......@@ -255,7 +255,7 @@ PRNTF("free", i, pair->size, pair->u.diskoff, bt);
// inprogress = NULL
//fd is protected (must be holding fdlock)
void
toku_block_translation_note_end_checkpoint (BLOCK_TABLE bt, int fd, struct brt_header *h) {
toku_block_translation_note_end_checkpoint (BLOCK_TABLE bt, int fd, FT h) {
// Free unused blocks
lock_for_blocktable(bt);
u_int64_t allocated_limit_at_start = block_allocator_allocated_limit(bt->block_allocator);
......@@ -333,13 +333,13 @@ unlock_for_blocktable (BLOCK_TABLE bt) {
}
void
toku_brtheader_lock (struct brt_header *h) {
toku_ft_lock (FT h) {
BLOCK_TABLE bt = h->blocktable;
lock_for_blocktable(bt);
}
void
toku_brtheader_unlock (struct brt_header *h) {
toku_ft_unlock (FT h) {
BLOCK_TABLE bt = h->blocktable;
assert(toku_mutex_is_locked(&bt->mutex));
unlock_for_blocktable(bt);
......@@ -384,9 +384,9 @@ translation_prevents_freeing(struct translation *t, BLOCKNUM b, struct block_tra
}
static void
blocknum_realloc_on_disk_internal (BLOCK_TABLE bt, BLOCKNUM b, DISKOFF size, DISKOFF *offset, struct brt_header * h, BOOL for_checkpoint) {
blocknum_realloc_on_disk_internal (BLOCK_TABLE bt, BLOCKNUM b, DISKOFF size, DISKOFF *offset, FT h, BOOL for_checkpoint) {
assert(toku_mutex_is_locked(&bt->mutex));
brtheader_set_dirty(h, for_checkpoint);
ft_set_dirty(h, for_checkpoint);
struct translation *t = &bt->current;
struct block_translation_pair old_pair = t->block_translation[b.b];
......@@ -416,7 +416,7 @@ PRNTF("New", b.b, t->block_translation[b.b].size, t->block_translation[b.b].u.di
}
void
toku_blocknum_realloc_on_disk (BLOCK_TABLE bt, BLOCKNUM b, DISKOFF size, DISKOFF *offset, struct brt_header * h, BOOL for_checkpoint) {
toku_blocknum_realloc_on_disk (BLOCK_TABLE bt, BLOCKNUM b, DISKOFF size, DISKOFF *offset, FT h, BOOL for_checkpoint) {
lock_for_blocktable(bt);
struct translation *t = &bt->current;
verify_valid_freeable_blocknum(t, b);
......@@ -516,7 +516,7 @@ maybe_expand_translation (struct translation *t) {
}
void
toku_allocate_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *res, struct brt_header * h) {
toku_allocate_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *res, FT h) {
assert(toku_mutex_is_locked(&bt->mutex));
BLOCKNUM result;
struct translation * t = &bt->current;
......@@ -538,11 +538,11 @@ toku_allocate_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *res, struct brt_header
t->block_translation[result.b].size = 0;
verify_valid_freeable_blocknum(t, result);
*res = result;
brtheader_set_dirty(h, FALSE);
ft_set_dirty(h, FALSE);
}
void
toku_allocate_blocknum(BLOCK_TABLE bt, BLOCKNUM *res, struct brt_header * h) {
toku_allocate_blocknum(BLOCK_TABLE bt, BLOCKNUM *res, FT h) {
lock_for_blocktable(bt);
toku_allocate_blocknum_unlocked(bt, res, h);
unlock_for_blocktable(bt);
......@@ -562,7 +562,7 @@ free_blocknum_in_translation(struct translation *t, BLOCKNUM b)
}
static void
free_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *bp, struct brt_header * h, BOOL for_checkpoint) {
free_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *bp, FT h, BOOL for_checkpoint) {
// Effect: Free a blocknum.
// If the blocknum holds the only reference to a block on disk, free that block
assert(toku_mutex_is_locked(&bt->mutex));
......@@ -573,7 +573,7 @@ free_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *bp, struct brt_header * h, BOOL
free_blocknum_in_translation(&bt->current, b);
if (for_checkpoint) {
assert(h->checkpoint_header->type == BRTHEADER_CHECKPOINT_INPROGRESS);
assert(h->checkpoint_header->type == FT_CHECKPOINT_INPROGRESS);
free_blocknum_in_translation(&bt->inprogress, b);
}
......@@ -589,11 +589,11 @@ PRNTF("free_blocknum_free", b.b, old_pair.size, old_pair.u.diskoff, bt);
}
}
else assert(old_pair.size==0 && old_pair.u.diskoff == diskoff_unused);
brtheader_set_dirty(h, for_checkpoint);
ft_set_dirty(h, for_checkpoint);
}
void
toku_free_blocknum(BLOCK_TABLE bt, BLOCKNUM *bp, struct brt_header * h, BOOL for_checkpoint) {
toku_free_blocknum(BLOCK_TABLE bt, BLOCKNUM *bp, FT h, BOOL for_checkpoint) {
lock_for_blocktable(bt);
free_blocknum_unlocked(bt, bp, h, for_checkpoint);
unlock_for_blocktable(bt);
......@@ -649,7 +649,7 @@ dump_translation(FILE *f, struct translation *t) {
else fprintf(f, " does not exist\n");
}
//Only used by toku_brt_dump which is only for debugging purposes
//Only used by toku_ft_dump which is only for debugging purposes
void
toku_dump_translation_table(FILE *f, BLOCK_TABLE bt) {
lock_for_blocktable(bt);
......@@ -662,7 +662,7 @@ toku_dump_translation_table(FILE *f, BLOCK_TABLE bt) {
unlock_for_blocktable(bt);
}
//Only used by brtdump
//Only used by ftdump
void
toku_blocknum_dump_translation(BLOCK_TABLE bt, BLOCKNUM b) {
lock_for_blocktable(bt);
......@@ -892,14 +892,14 @@ toku_blocktable_internal_fragmentation (BLOCK_TABLE bt, int64_t *total_sizep, in
}
void
toku_realloc_descriptor_on_disk_unlocked(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, struct brt_header * h) {
toku_realloc_descriptor_on_disk_unlocked(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, FT h) {
assert(toku_mutex_is_locked(&bt->mutex));
BLOCKNUM b = make_blocknum(RESERVED_BLOCKNUM_DESCRIPTOR);
blocknum_realloc_on_disk_internal(bt, b, size, offset, h, FALSE);
}
void
toku_realloc_descriptor_on_disk(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, struct brt_header * h) {
toku_realloc_descriptor_on_disk(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, FT h) {
lock_for_blocktable(bt);
toku_realloc_descriptor_on_disk_unlocked(bt, size, offset, h);
unlock_for_blocktable(bt);
......
......@@ -5,7 +5,7 @@
#ident "Copyright (c) 2007-2010 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."
#include "brttypes.h"
#include "fttypes.h"
#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
......@@ -13,7 +13,7 @@ extern "C" {
typedef struct block_table *BLOCK_TABLE;
//Needed by tests, brtdump
//Needed by tests, ftdump
struct block_translation_pair {
union { // If in the freelist, use next_free_blocknum, otherwise diskoff.
DISKOFF diskoff;
......@@ -26,28 +26,28 @@ void toku_blocktable_create_new(BLOCK_TABLE *btp);
enum deserialize_error_code toku_blocktable_create_from_buffer(BLOCK_TABLE *btp, DISKOFF location_on_disk, DISKOFF size_on_disk, unsigned char *translation_buffer);
void toku_blocktable_destroy(BLOCK_TABLE *btp);
void toku_brtheader_lock(struct brt_header *h);
void toku_brtheader_unlock(struct brt_header *h);
void toku_ft_lock(FT h);
void toku_ft_unlock(FT h);
void toku_block_translation_note_start_checkpoint_unlocked(BLOCK_TABLE bt);
void toku_block_translation_note_end_checkpoint(BLOCK_TABLE bt, int fd, struct brt_header *h);
void toku_block_translation_note_end_checkpoint(BLOCK_TABLE bt, int fd, FT h);
void toku_block_translation_note_failed_checkpoint(BLOCK_TABLE bt);
void toku_block_translation_note_skipped_checkpoint(BLOCK_TABLE bt);
void toku_maybe_truncate_cachefile_on_open(BLOCK_TABLE bt, int fd, struct brt_header *h);
void toku_maybe_truncate_cachefile_on_open(BLOCK_TABLE bt, int fd, FT h);
//Blocknums
void toku_allocate_blocknum(BLOCK_TABLE bt, BLOCKNUM *res, struct brt_header * h);
void toku_allocate_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *res, struct brt_header * h);
void toku_free_blocknum(BLOCK_TABLE bt, BLOCKNUM *b, struct brt_header * h, BOOL for_checkpoint);
void toku_allocate_blocknum(BLOCK_TABLE bt, BLOCKNUM *res, FT h);
void toku_allocate_blocknum_unlocked(BLOCK_TABLE bt, BLOCKNUM *res, FT h);
void toku_free_blocknum(BLOCK_TABLE bt, BLOCKNUM *b, FT h, BOOL for_checkpoint);
void toku_verify_blocknum_allocated(BLOCK_TABLE bt, BLOCKNUM b);
void toku_block_verify_no_data_blocks_except_root_unlocked(BLOCK_TABLE bt, BLOCKNUM root);
void toku_block_verify_no_free_blocknums(BLOCK_TABLE bt);
void toku_realloc_descriptor_on_disk(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, struct brt_header * h);
void toku_realloc_descriptor_on_disk_unlocked(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, struct brt_header * h);
void toku_realloc_descriptor_on_disk(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, FT h);
void toku_realloc_descriptor_on_disk_unlocked(BLOCK_TABLE bt, DISKOFF size, DISKOFF *offset, FT h);
void toku_get_descriptor_offset_size(BLOCK_TABLE bt, DISKOFF *offset, DISKOFF *size);
//Blocks and Blocknums
void toku_blocknum_realloc_on_disk(BLOCK_TABLE bt, BLOCKNUM b, DISKOFF size, DISKOFF *offset, struct brt_header * h, BOOL for_checkpoint);
void toku_blocknum_realloc_on_disk(BLOCK_TABLE bt, BLOCKNUM b, DISKOFF size, DISKOFF *offset, FT h, BOOL for_checkpoint);
void toku_translate_blocknum_to_offset_size(BLOCK_TABLE bt, BLOCKNUM b, DISKOFF *offset, DISKOFF *size);
//Serialization
......@@ -56,7 +56,7 @@ void toku_serialize_translation_to_wbuf_unlocked(BLOCK_TABLE bt, struct wbuf *w,
void toku_block_table_swap_for_redirect(BLOCK_TABLE old_bt, BLOCK_TABLE new_bt);
//DEBUG ONLY (brtdump included), tests included
//DEBUG ONLY (ftdump included), tests included
void toku_blocknum_dump_translation(BLOCK_TABLE bt, BLOCKNUM b);
void toku_dump_translation_table(FILE *f, BLOCK_TABLE bt);
void toku_block_alloc(BLOCK_TABLE bt, u_int64_t size, u_int64_t *offset);
......
......@@ -17,13 +17,13 @@
#include "cachetable.h"
#include "rwlock.h"
#include "nonblocking_mutex.h"
#include <newbrt/log_header.h>
#include <ft/log_header.h>
#include "checkpoint.h"
#include "minicron.h"
#include "log-internal.h"
#include "kibbutz.h"
#include "brt-internal.h"
#include "ft-internal.h"
#define TRACE_CACHETABLE 0
#if TRACE_CACHETABLE
......@@ -115,7 +115,7 @@ typedef struct ctpair *PAIR;
struct ctpair {
CACHEFILE cachefile;
CACHEKEY key;
void* value_data; // data used by client threads, BRTNODEs and ROLLBACK_LOG_NODEs
void* value_data; // data used by client threads, FTNODEs and ROLLBACK_LOG_NODEs
void* cloned_value_data; // cloned copy of value_data used for checkpointing
long cloned_value_size; // size of cloned_value_data, used for accounting of ct->size_current
void* disk_data; // data used to fetch/flush value_data to and from disk.
......@@ -495,6 +495,9 @@ u_int32_t toku_get_cleaner_iterations_unlocked (CACHETABLE ct) {
#define unreservable_memory(size) ((size)/4)
int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_lsn), TOKULOGGER logger) {
if (size_limit == 0) {
size_limit = 128*1024*1024;
}
CACHETABLE MALLOC(ct);
if (ct == 0) return ENOMEM;
memset(ct, 0, sizeof(*ct));
......@@ -864,7 +867,7 @@ int toku_cachefile_set_fd (CACHEFILE cf, int fd, const char *fname_in_env) {
toku_free(cf->fname_in_env);
cf->fname_in_env = NULL;
}
//It is safe to have the name repeated since this is a newbrt-only test function.
//It is safe to have the name repeated since this is a ft-only test function.
//There isn't an environment directory so its both env/cwd.
cachefile_init_filenum(cf, fd, fname_in_env, fileid);
r = 0;
......@@ -2234,7 +2237,7 @@ static void cachetable_fetch_pair(
cachetable_lock(ct);
rwlock_read_unlock(&cf->fdlock);
// brt.c asserts that get_and_pin succeeds,
// ft-ops.c asserts that get_and_pin succeeds,
// so we might as well just assert it here as opposed
// to trying to support an INVALID state
assert(r == 0);
......@@ -2896,13 +2899,13 @@ void toku_cachefile_verify (CACHEFILE cf) {
int64_t UU() toku_cachetable_size_slowslow (CACHETABLE ct) {
// DANGER DANGER DANGER
// This only works if every entry in the cachetable is actually a
// BRTNODE. Don't say you weren't warned.
// FTNODE. Don't say you weren't warned.
PAIR p;
BOOL is_first = TRUE;
int64_t ret = 0;
for (p=ct->clock_head; ct->clock_head!=NULL && (p!=ct->clock_head || is_first); p=p->clock_next) {
is_first=FALSE;
ret += brtnode_memory_size((BRTNODE) p->value_data);
ret += ftnode_memory_size((FTNODE) p->value_data);
}
return ret;
}
......@@ -2910,13 +2913,13 @@ int64_t UU() toku_cachetable_size_slowslow (CACHETABLE ct) {
int64_t UU() toku_cachetable_size_discrepancy (CACHETABLE ct) {
// DANGER DANGER DANGER
// This only works if every entry in the cachetable is actually a
// BRTNODE. Don't say you weren't warned.
// FTNODE. Don't say you weren't warned.
PAIR p;
BOOL is_first = TRUE;
int64_t ret = 0;
for (p=ct->clock_head; ct->clock_head!=NULL && (p!=ct->clock_head || is_first); p=p->clock_next) {
is_first=FALSE;
ret += brtnode_memory_size((BRTNODE) p->value_data) - p->attr.size;
ret += ftnode_memory_size((FTNODE) p->value_data) - p->attr.size;
}
return ret;
}
......@@ -2924,14 +2927,14 @@ int64_t UU() toku_cachetable_size_discrepancy (CACHETABLE ct) {
int64_t UU() toku_cachetable_size_discrepancy_pinned (CACHETABLE ct) {
// DANGER DANGER DANGER
// This only works if every entry in the cachetable is actually a
// BRTNODE. Don't say you weren't warned.
// FTNODE. Don't say you weren't warned.
PAIR p;
BOOL is_first = TRUE;
int64_t ret = 0;
for (p=ct->clock_head; ct->clock_head!=NULL && (p!=ct->clock_head || is_first); p=p->clock_next) {
is_first=FALSE;
if (nb_mutex_writers(&p->value_nb_mutex)) {
ret += brtnode_memory_size((BRTNODE) p->value_data) - p->attr.size;
ret += ftnode_memory_size((FTNODE) p->value_data) - p->attr.size;
}
}
return ret;
......@@ -3270,7 +3273,7 @@ int toku_cachetable_unpin_and_remove (
p->attr.cache_pressure_size = 0;
//
// callback for removing the key
// for BRTNODEs, this leads to calling
// for FTNODEs, this leads to calling
// toku_free_blocknum
//
if (remove_key) {
......@@ -3389,7 +3392,7 @@ int toku_cachetable_unpin_and_remove (
static int
set_filenum_in_array(OMTVALUE hv, u_int32_t index, void*arrayv) {
FILENUM *array = arrayv;
struct brt_header* h = hv;
FT h = hv;
array[index] = toku_cachefile_filenum(h->cf);
return 0;
}
......@@ -3399,13 +3402,13 @@ log_open_txn (OMTVALUE txnv, u_int32_t UU(index), void *UU(extra)) {
TOKUTXN txn = txnv;
TOKULOGGER logger = txn->logger;
FILENUMS open_filenums;
uint32_t num_filenums = toku_omt_size(txn->open_brt_headers);
uint32_t num_filenums = toku_omt_size(txn->open_fts);
FILENUM array[num_filenums];
{
open_filenums.num = num_filenums;
open_filenums.filenums = array;
//Fill in open_filenums
int r = toku_omt_iterate(txn->open_brt_headers, set_filenum_in_array, array);
int r = toku_omt_iterate(txn->open_fts, set_filenum_in_array, array);
assert(r==0);
}
// Zardosht claims that COMMITTING, ABORTING and RETIRED can never happen because of the multi-operation lock.
......@@ -3927,7 +3930,7 @@ toku_cachefile_get_cachetable(CACHEFILE cf) {
return cf->cachetable;
}
//Only called by brtheader_end_checkpoint
//Only called by ft_end_checkpoint
//Must have access to cf->fd (must be protected)
int
toku_cachefile_fsync(CACHEFILE cf) {
......
......@@ -7,7 +7,7 @@
#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 <fcntl.h>
#include "brttypes.h"
#include "fttypes.h"
#include "workqueue.h"
#if defined(__cplusplus) || defined(__cilkplusplus)
......@@ -39,7 +39,11 @@ u_int32_t toku_get_cleaner_iterations_unlocked (CACHETABLE ct);
// cachetable operations
int toku_create_cachetable(CACHETABLE */*result*/, long size_limit, LSN initial_lsn, TOKULOGGER);
// create and initialize a cache table
// size_limit is the upper limit on the size of the size of the values in the table
// pass 0 if you want the default
int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn, TOKULOGGER);
// Create a new cachetable.
// Effects: a new cachetable is created and initialized.
// The cachetable pointer is stored into result.
......@@ -143,7 +147,7 @@ typedef int (*CACHETABLE_FETCH_CALLBACK)(CACHEFILE, int fd, CACHEKEY key, u_int3
// to return an estimate of the number of bytes it will free
// so that the cachetable can estimate how much data is being evicted on background threads.
// If cost is PE_CHEAP, then the callback does not set bytes_freed_estimate.
typedef void (*CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK)(void *brtnode_pv, void* disk_data, long* bytes_freed_estimate, enum partial_eviction_cost *cost, void *write_extraargs);
typedef void (*CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK)(void *ftnode_pv, void* disk_data, long* bytes_freed_estimate, enum partial_eviction_cost *cost, void *write_extraargs);
// The cachetable calls the partial eviction callback is to possibly try and partially evict pieces
// of the PAIR. The callback determines the strategy for what to evict. The callback may choose to free
......@@ -151,7 +155,7 @@ typedef void (*CACHETABLE_PARTIAL_EVICTION_EST_CALLBACK)(void *brtnode_pv, void*
// old_attr is the PAIR_ATTR of the PAIR when the callback is called.
// new_attr is set to the new PAIR_ATTR after the callback executes partial eviction
// Requires a write lock to be held on the PAIR in the cachetable while this function is called
typedef int (*CACHETABLE_PARTIAL_EVICTION_CALLBACK)(void *brtnode_pv, PAIR_ATTR old_attr, PAIR_ATTR* new_attr, void *write_extraargs);
typedef int (*CACHETABLE_PARTIAL_EVICTION_CALLBACK)(void *ftnode_pv, PAIR_ATTR old_attr, PAIR_ATTR* new_attr, void *write_extraargs);
// The cachetable calls this function to determine if get_and_pin call requires a partial fetch. If this function returns TRUE,
// then the cachetable will subsequently call CACHETABLE_PARTIAL_FETCH_CALLBACK to perform
......@@ -161,7 +165,7 @@ typedef int (*CACHETABLE_PARTIAL_EVICTION_CALLBACK)(void *brtnode_pv, PAIR_ATTR
// CACHETABLE_PARTIAL_FETCH_CALLBACK decide whether to possibly release the ydb lock and perform I/O.
// There is no particular reason why this alternative was not chosen.
// Requires: a read lock to be held on the PAIR
typedef BOOL (*CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK)(void *brtnode_pv, void *read_extraargs);
typedef BOOL (*CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK)(void *ftnode_pv, void *read_extraargs);
// The cachetable calls the partial fetch callback when a thread needs to read or decompress a subset of a PAIR into memory.
// An example is needing to read a basement node into memory. Another example is decompressing an internal node's
......@@ -172,7 +176,7 @@ typedef BOOL (*CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK)(void *brtnode_pv, voi
typedef int (*CACHETABLE_PARTIAL_FETCH_CALLBACK)(void *value_data, void* disk_data, void *read_extraargs, int fd, PAIR_ATTR *sizep);
// TODO(leif) XXX TODO XXX
typedef int (*CACHETABLE_CLEANER_CALLBACK)(void *brtnode_pv, BLOCKNUM blocknum, u_int32_t fullhash, void *write_extraargs);
typedef int (*CACHETABLE_CLEANER_CALLBACK)(void *ftnode_pv, BLOCKNUM blocknum, u_int32_t fullhash, void *write_extraargs);
typedef void (*CACHETABLE_CLONE_CALLBACK)(void* value_data, void** cloned_value_data, PAIR_ATTR* new_attr, BOOL for_checkpoint, void* write_extraargs);
......
......@@ -51,7 +51,7 @@
#include <toku_portability.h>
#include <time.h>
#include "brttypes.h"
#include "fttypes.h"
#include "cachetable.h"
#include "log-internal.h"
#include "logger.h"
......
......@@ -4,7 +4,7 @@
#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 "dbufio.h"
#include "brttypes.h"
#include "fttypes.h"
#include <toku_assert.h>
#include <errno.h>
#include <unistd.h>
......
......@@ -56,7 +56,7 @@ static int next_power_of_two (int n) {
return r;
}
int toku_fifo_enq(FIFO fifo, const void *key, unsigned int keylen, const void *data, unsigned int datalen, enum brt_msg_type type, MSN msn, XIDS xids, bool is_fresh, long *dest) {
int toku_fifo_enq(FIFO fifo, const void *key, unsigned int keylen, const void *data, unsigned int datalen, enum ft_msg_type type, MSN msn, XIDS xids, bool is_fresh, long *dest) {
int need_space_here = sizeof(struct fifo_entry)
+ keylen + datalen
+ xids_get_size(xids)
......@@ -109,7 +109,7 @@ struct fifo_entry * toku_fifo_iterate_internal_get_entry(FIFO fifo, int off) {
return (struct fifo_entry *)(fifo->memory + off);
}
void toku_fifo_iterate (FIFO fifo, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,ITEMLEN datalen, enum brt_msg_type type, MSN msn, XIDS xids, bool is_fresh, void*), void *arg) {
void toku_fifo_iterate (FIFO fifo, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,ITEMLEN datalen, enum ft_msg_type type, MSN msn, XIDS xids, bool is_fresh, void*), void *arg) {
FIFO_ITERATE(fifo,
key, keylen, data, datalen, type, msn, xids, is_fresh,
f(key,keylen,data,datalen,type,msn,xids,is_fresh, arg));
......
......@@ -4,7 +4,7 @@
#ident "Copyright (c) 2007-2010 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."
#include "brttypes.h"
#include "fttypes.h"
#include "xids-internal.h"
#include "xids.h"
......@@ -28,17 +28,17 @@ struct __attribute__((__packed__)) fifo_entry {
// get and set the brt message type for a fifo entry.
// it is internally stored as a single unsigned char.
static inline enum brt_msg_type
static inline enum ft_msg_type
fifo_entry_get_msg_type(const struct fifo_entry * entry)
{
enum brt_msg_type msg_type;
msg_type = (enum brt_msg_type) entry->type;
enum ft_msg_type msg_type;
msg_type = (enum ft_msg_type) entry->type;
return msg_type;
}
static inline void
fifo_entry_set_msg_type(struct fifo_entry * entry,
enum brt_msg_type msg_type)
enum ft_msg_type msg_type)
{
unsigned char type = (unsigned char) msg_type;
entry->type = type;
......@@ -56,7 +56,7 @@ void toku_fifo_free(FIFO *);
int toku_fifo_n_entries(FIFO);
int toku_fifo_enq (FIFO, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, enum brt_msg_type type, MSN msn, XIDS xids, bool is_fresh, long *dest);
int toku_fifo_enq (FIFO, const void *key, ITEMLEN keylen, const void *data, ITEMLEN datalen, enum ft_msg_type type, MSN msn, XIDS xids, bool is_fresh, long *dest);
unsigned int toku_fifo_buffer_size_in_use (FIFO fifo);
unsigned long toku_fifo_memory_size_in_use(FIFO fifo); // return how much memory in the fifo holds useful data
......@@ -65,8 +65,8 @@ unsigned long toku_fifo_memory_footprint(FIFO fifo); // return how much memory
//These two are problematic, since I don't want to malloc() the bytevecs, but dequeueing the fifo frees the memory.
//int toku_fifo_peek_deq (FIFO, bytevec *key, ITEMLEN *keylen, bytevec *data, ITEMLEN *datalen, u_int32_t *type, TXNID *xid);
//int toku_fifo_peek_deq_cmdstruct (FIFO, BRT_MSG, DBT*, DBT*); // fill in the BRT_MSG, using the two DBTs for the DBT part.
void toku_fifo_iterate(FIFO, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,ITEMLEN datalen, enum brt_msg_type type, MSN msn, XIDS xids, bool is_fresh, void*), void*);
//int toku_fifo_peek_deq_cmdstruct (FIFO, FT_MSG, DBT*, DBT*); // fill in the FT_MSG, using the two DBTs for the DBT part.
void toku_fifo_iterate(FIFO, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,ITEMLEN datalen, enum ft_msg_type type, MSN msn, XIDS xids, bool is_fresh, void*), void*);
#define FIFO_ITERATE(fifo,keyvar,keylenvar,datavar,datalenvar,typevar,msnvar,xidsvar,is_freshvar,body) ({ \
for (int fifo_iterate_off = toku_fifo_iterate_internal_start(fifo); \
......@@ -75,7 +75,7 @@ void toku_fifo_iterate(FIFO, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,IT
struct fifo_entry *e = toku_fifo_iterate_internal_get_entry(fifo, fifo_iterate_off); \
ITEMLEN keylenvar = e->keylen; \
ITEMLEN datalenvar = e->vallen; \
enum brt_msg_type typevar = fifo_entry_get_msg_type(e); \
enum ft_msg_type typevar = fifo_entry_get_msg_type(e); \
MSN msnvar = e->msn; \
XIDS xidsvar = &e->xids_s; \
bytevec keyvar = xids_get_end_of_array(xidsvar); \
......
......@@ -3,19 +3,19 @@
#ident "Copyright (c) 2007-2011 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."
#include <brt-cachetable-wrappers.h>
#include <ft-cachetable-wrappers.h>
#include <brttypes.h>
#include <brt-flusher.h>
#include <brt-internal.h>
#include <fttypes.h>
#include <ft-flusher.h>
#include <ft-internal.h>
static void
brtnode_get_key_and_fullhash(
ftnode_get_key_and_fullhash(
BLOCKNUM* cachekey,
u_int32_t* fullhash,
void* extra)
{
struct brt_header* h = extra;
FT h = extra;
BLOCKNUM name;
toku_allocate_blocknum(h->blocktable, &name, h);
*cachekey = name;
......@@ -24,14 +24,14 @@ brtnode_get_key_and_fullhash(
void
cachetable_put_empty_node_with_dep_nodes(
struct brt_header* h,
FT h,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes,
FTNODE* dependent_nodes,
BLOCKNUM* name, //output
u_int32_t* fullhash, //output
BRTNODE* result)
FTNODE* result)
{
BRTNODE XMALLOC(new_node);
FTNODE XMALLOC(new_node);
CACHEFILE dependent_cf[num_dependent_nodes];
BLOCKNUM dependent_keys[num_dependent_nodes];
u_int32_t dependent_fullhash[num_dependent_nodes];
......@@ -45,9 +45,9 @@ cachetable_put_empty_node_with_dep_nodes(
int r = toku_cachetable_put_with_dep_pairs(
h->cf,
brtnode_get_key_and_fullhash,
ftnode_get_key_and_fullhash,
new_node,
make_pair_attr(sizeof(BRTNODE)),
make_pair_attr(sizeof(FTNODE)),
get_write_callbacks_for_node(h),
h,
num_dependent_nodes,
......@@ -63,13 +63,13 @@ cachetable_put_empty_node_with_dep_nodes(
}
void
create_new_brtnode_with_dep_nodes(
struct brt_header* h,
BRTNODE *result,
create_new_ftnode_with_dep_nodes(
FT h,
FTNODE *result,
int height,
int n_children,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes)
FTNODE* dependent_nodes)
{
u_int32_t fullhash = 0;
BLOCKNUM name;
......@@ -88,7 +88,7 @@ create_new_brtnode_with_dep_nodes(
assert(n_children > 0);
}
toku_initialize_empty_brtnode(
toku_initialize_empty_ftnode(
*result,
name,
height,
......@@ -102,13 +102,13 @@ create_new_brtnode_with_dep_nodes(
}
void
toku_create_new_brtnode (
BRT t,
BRTNODE *result,
toku_create_new_ftnode (
FT_HANDLE t,
FTNODE *result,
int height,
int n_children)
{
return create_new_brtnode_with_dep_nodes(
return create_new_ftnode_with_dep_nodes(
t->h,
result,
height,
......@@ -118,17 +118,17 @@ toku_create_new_brtnode (
}
int
toku_pin_brtnode(
BRT brt,
toku_pin_ftnode(
FT_HANDLE brt,
BLOCKNUM blocknum,
u_int32_t fullhash,
UNLOCKERS unlockers,
ANCESTORS ancestors,
const PIVOT_BOUNDS bounds,
BRTNODE_FETCH_EXTRA bfe,
FTNODE_FETCH_EXTRA bfe,
BOOL may_modify_node,
BOOL apply_ancestor_messages, // this BOOL is probably temporary, for #3972, once we know how range query estimates work, will revisit this
BRTNODE *node_p,
FTNODE *node_p,
BOOL* msgs_applied)
{
void *node_v;
......@@ -140,14 +140,14 @@ toku_pin_brtnode(
&node_v,
NULL,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_ftnode_fetch_callback,
toku_ftnode_pf_req_callback,
toku_ftnode_pf_callback,
may_modify_node,
bfe, //read_extraargs
unlockers);
if (r==0) {
BRTNODE node = node_v;
FTNODE node = node_v;
if (apply_ancestor_messages) {
maybe_apply_ancestors_messages_to_node(brt, node, ancestors, bounds, msgs_applied);
}
......@@ -161,15 +161,15 @@ toku_pin_brtnode(
}
void
toku_pin_brtnode_off_client_thread(
struct brt_header* h,
toku_pin_ftnode_off_client_thread(
FT h,
BLOCKNUM blocknum,
u_int32_t fullhash,
BRTNODE_FETCH_EXTRA bfe,
FTNODE_FETCH_EXTRA bfe,
BOOL may_modify_node,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes,
BRTNODE *node_p)
FTNODE* dependent_nodes,
FTNODE *node_p)
{
void *node_v;
CACHEFILE dependent_cf[num_dependent_nodes];
......@@ -190,9 +190,9 @@ toku_pin_brtnode_off_client_thread(
&node_v,
NULL,
get_write_callbacks_for_node(h),
toku_brtnode_fetch_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_ftnode_fetch_callback,
toku_ftnode_pf_req_callback,
toku_ftnode_pf_callback,
may_modify_node,
bfe,
num_dependent_nodes,
......@@ -202,33 +202,33 @@ toku_pin_brtnode_off_client_thread(
dependent_dirty_bits
);
assert(r==0);
BRTNODE node = node_v;
FTNODE node = node_v;
*node_p = node;
}
void
toku_unpin_brtnode_off_client_thread(struct brt_header* h, BRTNODE node)
toku_unpin_ftnode_off_client_thread(FT h, FTNODE node)
{
int r = toku_cachetable_unpin(
h->cf,
node->thisnodename,
node->fullhash,
(enum cachetable_dirty) node->dirty,
make_brtnode_pair_attr(node)
make_ftnode_pair_attr(node)
);
assert(r==0);
}
void
toku_unpin_brtnode(struct brt_header *h, BRTNODE node)
toku_unpin_ftnode(FT h, FTNODE node)
{
// printf("%*sUnpin %ld\n", 8-node->height, "", node->thisnodename.b);
//VERIFY_NODE(brt,node);
toku_unpin_brtnode_off_client_thread(h, node);
toku_unpin_ftnode_off_client_thread(h, node);
}
void
toku_unpin_brtnode_read_only(BRT brt, BRTNODE node)
toku_unpin_ftnode_read_only(FT_HANDLE brt, FTNODE node)
{
int r = toku_cachetable_unpin(
brt->h->cf,
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ifndef BRT_CACHETABLE_WRAPPERS_H
#define BRT_CACHETABLE_WRAPPERS_H
#ifndef FT_CACHETABLE_WRAPPERS_H
#define FT_CACHETABLE_WRAPPERS_H
#ident "$Id$"
#ident "Copyright (c) 2007-2011 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."
#include <brttypes.h>
#include <fttypes.h>
#include "cachetable.h"
/**
......@@ -16,61 +16,61 @@
*/
void
cachetable_put_empty_node_with_dep_nodes(
struct brt_header* h,
FT h,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes,
FTNODE* dependent_nodes,
BLOCKNUM* name, //output
u_int32_t* fullhash, //output
BRTNODE* result
FTNODE* result
);
/**
* Create a new brtnode with specified height and number of children.
* Create a new ftnode with specified height and number of children.
* In the process, write dependent nodes out for checkpoint if
* necessary.
*/
void
create_new_brtnode_with_dep_nodes(
struct brt_header* h,
BRTNODE *result,
create_new_ftnode_with_dep_nodes(
FT h,
FTNODE *result,
int height,
int n_children,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes
FTNODE* dependent_nodes
);
/**
* Create a new brtnode with specified height
* Create a new ftnode with specified height
* and children.
* Used for test functions only.
*/
void
toku_create_new_brtnode (
BRT t,
BRTNODE *result,
toku_create_new_ftnode (
FT_HANDLE t,
FTNODE *result,
int height,
int n_children
);
/**
* toku_pin_brtnode either pins a brtnode, if the operation is fast (because
* toku_pin_ftnode either pins a ftnode, if the operation is fast (because
* a partial fetch is not required and there is no contention for the node)
* or it returns TOKUDB_TRY_AGAIN after unlocking its ancestors (using
* unlockers and ancestors) and bringing the necessary pieces of the node
* into memory.
*/
int
toku_pin_brtnode(
BRT brt,
toku_pin_ftnode(
FT_HANDLE brt,
BLOCKNUM blocknum,
u_int32_t fullhash,
UNLOCKERS unlockers,
ANCESTORS ancestors,
const PIVOT_BOUNDS pbounds,
BRTNODE_FETCH_EXTRA bfe,
FTNODE_FETCH_EXTRA bfe,
BOOL may_modify_node,
BOOL apply_ancestor_messages, // this BOOL is probably temporary, for #3972, once we know how range query estimates work, will revisit this
BRTNODE *node_p,
FTNODE *node_p,
BOOL* msgs_applied
);
......@@ -78,19 +78,19 @@ toku_pin_brtnode(
* Unfortunately, this function is poorly named
* as over time, client threads have also started
* calling this function.
* This function returns a pinned brtnode to the caller.
* Unlike toku_pin_brtnode, this function blocks until the node is pinned.
* This function returns a pinned ftnode to the caller.
* Unlike toku_pin_ftnode, this function blocks until the node is pinned.
*/
void
toku_pin_brtnode_off_client_thread(
struct brt_header* h,
toku_pin_ftnode_off_client_thread(
FT h,
BLOCKNUM blocknum,
u_int32_t fullhash,
BRTNODE_FETCH_EXTRA bfe,
FTNODE_FETCH_EXTRA bfe,
BOOL may_modify_node,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes,
BRTNODE *node_p
FTNODE* dependent_nodes,
FTNODE *node_p
);
/**
......@@ -98,16 +98,16 @@ toku_pin_brtnode_off_client_thread(
* nodes that were pinned off client thread.
*/
void
toku_unpin_brtnode_off_client_thread(struct brt_header* h, BRTNODE node);
toku_unpin_ftnode_off_client_thread(FT h, FTNODE node);
/**
* Effect: Unpin a brt node.
* Used for nodes pinned on a client thread
*/
void
toku_unpin_brtnode(struct brt_header *h, BRTNODE node);
toku_unpin_ftnode(FT h, FTNODE node);
void
toku_unpin_brtnode_read_only(BRT brt, BRTNODE node);
toku_unpin_ftnode_read_only(FT_HANDLE brt, FTNODE node);
#endif
/* -*- mode: C; c-basic-offset: 4 -*- */
#ifndef BRT_FLUSHER_INTERNAL
#define BRT_FLUSHER_INTERNAL
#ifndef FT_FLUSHER_INTERNAL_H
#define FT_FLUSHER_INTERNAL_H
#ident "$Id$"
#ident "Copyright (c) 2007-2010 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."
#include <brttypes.h>
#include <fttypes.h>
#define ft_flush_before_applying_inbox 1
#define ft_flush_before_child_pin 2
#define ft_flush_after_child_pin 3
#define ft_flush_before_split 4
#define ft_flush_during_split 5
#define ft_flush_before_merge 6
#define ft_flush_after_merge 7
#define ft_flush_after_rebalance 8
#define ft_flush_before_unpin_remove 9
#define ft_flush_before_pin_second_node_for_merge 10
#define flt_flush_before_applying_inbox 1
#define flt_flush_before_child_pin 2
#define ft_flush_aflter_child_pin 3
#define flt_flush_before_split 4
#define flt_flush_during_split 5
#define flt_flush_before_merge 6
#define ft_flush_aflter_merge 7
#define ft_flush_aflter_rebalance 8
#define flt_flush_before_unpin_remove 9
#define flt_flush_before_pin_second_node_for_merge 10
typedef struct flusher_advice FLUSHER_ADVICE;
......@@ -29,7 +29,7 @@ typedef struct flusher_advice FLUSHER_ADVICE;
* Cleaner thread merging leaf nodes: follow down to a key
* Hot optimize table: follow down to the right of a key
*/
typedef int (*FA_PICK_CHILD)(struct brt_header *h, BRTNODE parent, void* extra);
typedef int (*FA_PICK_CHILD)(FT h, FTNODE parent, void* extra);
/**
* Decide whether to call `flush_some_child` on the child if it is
......@@ -40,7 +40,7 @@ typedef int (*FA_PICK_CHILD)(struct brt_header *h, BRTNODE parent, void* extra);
* Cleaner thread merging leaf nodes: always yes
* Hot optimize table: always yes
*/
typedef bool (*FA_SHOULD_RECURSIVELY_FLUSH)(BRTNODE child, void* extra);
typedef bool (*FA_SHOULD_RECURSIVELY_FLUSH)(FTNODE child, void* extra);
/**
* Called if the child needs merging. Should do something to get the
......@@ -53,10 +53,10 @@ typedef bool (*FA_SHOULD_RECURSIVELY_FLUSH)(BRTNODE child, void* extra);
* Hot optimize table: just do the merge
*/
typedef void (*FA_MAYBE_MERGE_CHILD)(struct flusher_advice *fa,
struct brt_header *h,
BRTNODE parent,
FT h,
FTNODE parent,
int childnum,
BRTNODE child,
FTNODE child,
void* extra);
/**
......@@ -74,20 +74,20 @@ typedef void (*FA_MAYBE_MERGE_CHILD)(struct flusher_advice *fa,
typedef bool (*FA_SHOULD_DESTROY_BN)(void* extra);
/**
* Update `brt_flusher_status` in whatever way necessary. Called once
* Update `ft_flusher_status` in whatever way necessary. Called once
* by `flush_some_child` right before choosing what to do next (split,
* merge, recurse), with the number of nodes that were dirtied by this
* execution of `flush_some_child`.
*/
typedef void (*FA_UPDATE_STATUS)(BRTNODE child, int dirtied, void* extra);
typedef void (*FA_UPDATE_STATUS)(FTNODE child, int dirtied, void* extra);
/**
* Choose whether to go to the left or right child after a split. Called
* by `brt_split_child`. If -1 is returned, `brt_split_child` defaults to
* by `ft_split_child`. If -1 is returned, `ft_split_child` defaults to
* the old behavior.
*/
typedef int (*FA_PICK_CHILD_AFTER_SPLIT)(struct brt_header* h,
BRTNODE node,
typedef int (*FA_PICK_CHILD_AFTER_SPLIT)(FT h,
FTNODE node,
int childnuma,
int childnumb,
void* extra);
......@@ -95,7 +95,7 @@ typedef int (*FA_PICK_CHILD_AFTER_SPLIT)(struct brt_header* h,
/**
* A collection of callbacks used by the flushing machinery to make
* various decisions. There are implementations of each of these
* functions for flusher threads (ft_*), cleaner threads (ct_*), , and hot
* functions for flusher threads (flt_*), cleaner threads (ct_*), , and hot
* optimize table (hot_*).
*/
struct flusher_advice {
......@@ -112,7 +112,7 @@ struct flusher_advice {
//
// how about:
//
// toku_brtnode_flush_some_child()
// toku_ftnode_flush_some_child()
// toku_fa_flusher_advice_init()
// toku_fa_always_recursively_flush()
// toku_fa_dont_destroy_basement_nodes()
......@@ -133,27 +133,27 @@ flusher_advice_init(
void
flush_some_child(
struct brt_header* h,
BRTNODE parent,
FT h,
FTNODE parent,
struct flusher_advice *fa);
bool
always_recursively_flush(BRTNODE child, void* extra);
always_recursively_flush(FTNODE child, void* extra);
bool
dont_destroy_basement_nodes(void* extra);
void
default_merge_child(struct flusher_advice *fa,
struct brt_header *h,
BRTNODE parent,
FT h,
FTNODE parent,
int childnum,
BRTNODE child,
FTNODE child,
void* extra);
int
default_pick_child_after_split(struct brt_header *h,
BRTNODE parent,
default_pick_child_after_split(FT h,
FTNODE parent,
int childnuma,
int childnumb,
void *extra);
......
This diff is collapsed.
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef BRT_FLUSHER
#define BRT_FLUSHER
#ifndef FT_FLUSHER_H
#define FT_FLUSHER_H
#ident "$Id$"
#ident "Copyright (c) 2007-2010 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."
// This must be first to make the 64-bit file mode work right in Linux
#include "brttypes.h"
#include "fttypes.h"
typedef enum {
BRT_FLUSHER_CLEANER_TOTAL_NODES = 0, // total number of nodes whose buffers are potentially flushed by cleaner thread
BRT_FLUSHER_CLEANER_H1_NODES, // number of nodes of height one whose message buffers are flushed by cleaner thread
BRT_FLUSHER_CLEANER_HGT1_NODES, // number of nodes of height > 1 whose message buffers are flushed by cleaner thread
BRT_FLUSHER_CLEANER_EMPTY_NODES, // number of nodes that are selected by cleaner, but whose buffers are empty
BRT_FLUSHER_CLEANER_NODES_DIRTIED, // number of nodes that are made dirty by the cleaner thread
BRT_FLUSHER_CLEANER_MAX_BUFFER_SIZE, // max number of bytes in message buffer flushed by cleaner thread
BRT_FLUSHER_CLEANER_MIN_BUFFER_SIZE,
BRT_FLUSHER_CLEANER_TOTAL_BUFFER_SIZE,
BRT_FLUSHER_CLEANER_MAX_BUFFER_WORKDONE, // max workdone value of any message buffer flushed by cleaner thread
BRT_FLUSHER_CLEANER_MIN_BUFFER_WORKDONE,
BRT_FLUSHER_CLEANER_TOTAL_BUFFER_WORKDONE,
BRT_FLUSHER_CLEANER_NUM_LEAF_MERGES_STARTED, // number of times cleaner thread tries to merge a leaf
BRT_FLUSHER_CLEANER_NUM_LEAF_MERGES_RUNNING, // number of cleaner thread leaf merges in progress
BRT_FLUSHER_CLEANER_NUM_LEAF_MERGES_COMPLETED, // number of times cleaner thread successfully merges a leaf
BRT_FLUSHER_CLEANER_NUM_DIRTIED_FOR_LEAF_MERGE, // nodes dirtied by the "flush from root" process to merge a leaf node
BRT_FLUSHER_FLUSH_TOTAL, // total number of flushes done by flusher threads or cleaner threads
BRT_FLUSHER_FLUSH_IN_MEMORY, // number of in memory flushes
BRT_FLUSHER_FLUSH_NEEDED_IO, // number of flushes that had to read a child (or part) off disk
BRT_FLUSHER_FLUSH_CASCADES, // number of flushes that triggered another flush in the child
BRT_FLUSHER_FLUSH_CASCADES_1, // number of flushes that triggered 1 cascading flush
BRT_FLUSHER_FLUSH_CASCADES_2, // number of flushes that triggered 2 cascading flushes
BRT_FLUSHER_FLUSH_CASCADES_3, // number of flushes that triggered 3 cascading flushes
BRT_FLUSHER_FLUSH_CASCADES_4, // number of flushes that triggered 4 cascading flushes
BRT_FLUSHER_FLUSH_CASCADES_5, // number of flushes that triggered 5 cascading flushes
BRT_FLUSHER_FLUSH_CASCADES_GT_5, // number of flushes that triggered more than 5 cascading flushes
BRT_FLUSHER_SPLIT_LEAF, // number of leaf nodes split
BRT_FLUSHER_SPLIT_NONLEAF, // number of nonleaf nodes split
BRT_FLUSHER_MERGE_LEAF, // number of times leaf nodes are merged
BRT_FLUSHER_MERGE_NONLEAF, // number of times nonleaf nodes are merged
BRT_FLUSHER_BALANCE_LEAF, // number of times a leaf node is balanced inside brt
BRT_FLUSHER_STATUS_NUM_ROWS
} brt_flusher_status_entry;
FT_FLUSHER_CLEANER_TOTAL_NODES = 0, // total number of nodes whose buffers are potentially flushed by cleaner thread
FT_FLUSHER_CLEANER_H1_NODES, // number of nodes of height one whose message buffers are flushed by cleaner thread
FT_FLUSHER_CLEANER_HGT1_NODES, // number of nodes of height > 1 whose message buffers are flushed by cleaner thread
FT_FLUSHER_CLEANER_EMPTY_NODES, // number of nodes that are selected by cleaner, but whose buffers are empty
FT_FLUSHER_CLEANER_NODES_DIRTIED, // number of nodes that are made dirty by the cleaner thread
FT_FLUSHER_CLEANER_MAX_BUFFER_SIZE, // max number of bytes in message buffer flushed by cleaner thread
FT_FLUSHER_CLEANER_MIN_BUFFER_SIZE,
FT_FLUSHER_CLEANER_TOTAL_BUFFER_SIZE,
FT_FLUSHER_CLEANER_MAX_BUFFER_WORKDONE, // max workdone value of any message buffer flushed by cleaner thread
FT_FLUSHER_CLEANER_MIN_BUFFER_WORKDONE,
FT_FLUSHER_CLEANER_TOTAL_BUFFER_WORKDONE,
FT_FLUSHER_CLEANER_NUM_LEAF_MERGES_STARTED, // number of times cleaner thread tries to merge a leaf
FT_FLUSHER_CLEANER_NUM_LEAF_MERGES_RUNNING, // number of cleaner thread leaf merges in progress
FT_FLUSHER_CLEANER_NUM_LEAF_MERGES_COMPLETED, // number of times cleaner thread successfully merges a leaf
FT_FLUSHER_CLEANER_NUM_DIRTIED_FOR_LEAF_MERGE, // nodes dirtied by the "flush from root" process to merge a leaf node
FT_FLUSHER_FLUSH_TOTAL, // total number of flushes done by flusher threads or cleaner threads
FT_FLUSHER_FLUSH_IN_MEMORY, // number of in memory flushes
FT_FLUSHER_FLUSH_NEEDED_IO, // number of flushes that had to read a child (or part) off disk
FT_FLUSHER_FLUSH_CASCADES, // number of flushes that triggered another flush in the child
FT_FLUSHER_FLUSH_CASCADES_1, // number of flushes that triggered 1 cascading flush
FT_FLUSHER_FLUSH_CASCADES_2, // number of flushes that triggered 2 cascading flushes
FT_FLUSHER_FLUSH_CASCADES_3, // number of flushes that triggered 3 cascading flushes
FT_FLUSHER_FLUSH_CASCADES_4, // number of flushes that triggered 4 cascading flushes
FT_FLUSHER_FLUSH_CASCADES_5, // number of flushes that triggered 5 cascading flushes
FT_FLUSHER_FLUSH_CASCADES_GT_5, // number of flushes that triggered more than 5 cascading flushes
FT_FLUSHER_SPLIT_LEAF, // number of leaf nodes split
FT_FLUSHER_SPLIT_NONLEAF, // number of nonleaf nodes split
FT_FLUSHER_MERGE_LEAF, // number of times leaf nodes are merged
FT_FLUSHER_MERGE_NONLEAF, // number of times nonleaf nodes are merged
FT_FLUSHER_BALANCE_LEAF, // number of times a leaf node is balanced inside brt
FT_FLUSHER_STATUS_NUM_ROWS
} ft_flusher_status_entry;
typedef struct {
bool initialized;
TOKU_ENGINE_STATUS_ROW_S status[BRT_FLUSHER_STATUS_NUM_ROWS];
} BRT_FLUSHER_STATUS_S, *BRT_FLUSHER_STATUS;
TOKU_ENGINE_STATUS_ROW_S status[FT_FLUSHER_STATUS_NUM_ROWS];
} FT_FLUSHER_STATUS_S, *FT_FLUSHER_STATUS;
void toku_brt_flusher_status_init(void) __attribute__((__constructor__));
void toku_brt_flusher_get_status(BRT_FLUSHER_STATUS);
void toku_ft_flusher_status_init(void) __attribute__((__constructor__));
void toku_ft_flusher_get_status(FT_FLUSHER_STATUS);
/**
* Only for testing, not for production.
......@@ -68,8 +68,8 @@ toku_flusher_thread_set_callback(
*/
void
flush_node_on_background_thread(
struct brt_header *h,
BRTNODE parent
FT h,
FTNODE parent
);
/**
......@@ -81,15 +81,15 @@ flush_node_on_background_thread(
* splitk is the right-most key of nodea
*/
void
brtleaf_split(
struct brt_header* h,
BRTNODE node,
BRTNODE *nodea,
BRTNODE *nodeb,
ftleaf_split(
FT h,
FTNODE node,
FTNODE *nodea,
FTNODE *nodeb,
DBT *splitk,
BOOL create_new_node,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes
FTNODE* dependent_nodes
);
/**
......@@ -102,14 +102,14 @@ brtleaf_split(
* but it does not guarantee that the resulting nodes are smaller than nodesize.
*/
void
brt_nonleaf_split(
struct brt_header* h,
BRTNODE node,
BRTNODE *nodea,
BRTNODE *nodeb,
ft_nonleaf_split(
FT h,
FTNODE node,
FTNODE *nodea,
FTNODE *nodeb,
DBT *splitk,
u_int32_t num_dependent_nodes,
BRTNODE* dependent_nodes
FTNODE* dependent_nodes
);
......@@ -120,26 +120,26 @@ brt_nonleaf_split(
*/
typedef enum {
BRT_HOT_NUM_STARTED = 0, // number of HOT operations that have begun
BRT_HOT_NUM_COMPLETED, // number of HOT operations that have successfully completed
BRT_HOT_NUM_ABORTED, // number of HOT operations that have been aborted
BRT_HOT_MAX_ROOT_FLUSH_COUNT, // max number of flushes from root ever required to optimize a tree
BRT_HOT_STATUS_NUM_ROWS
} brt_hot_status_entry;
FT_HOT_NUM_STARTED = 0, // number of HOT operations that have begun
FT_HOT_NUM_COMPLETED, // number of HOT operations that have successfully completed
FT_HOT_NUM_ABORTED, // number of HOT operations that have been aborted
FT_HOT_MAX_ROOT_FLUSH_COUNT, // max number of flushes from root ever required to optimize a tree
FT_HOT_STATUS_NUM_ROWS
} ft_hot_status_entry;
typedef struct {
bool initialized;
TOKU_ENGINE_STATUS_ROW_S status[BRT_HOT_STATUS_NUM_ROWS];
} BRT_HOT_STATUS_S, *BRT_HOT_STATUS;
TOKU_ENGINE_STATUS_ROW_S status[FT_HOT_STATUS_NUM_ROWS];
} FT_HOT_STATUS_S, *FT_HOT_STATUS;
void toku_brt_hot_status_init(void) __attribute__((__constructor__));
void toku_brt_hot_get_status(BRT_HOT_STATUS);
void toku_ft_hot_status_init(void) __attribute__((__constructor__));
void toku_ft_hot_get_status(FT_HOT_STATUS);
/**
* Takes given BRT and pushes all pending messages to the leaf nodes.
* Takes given FT and pushes all pending messages to the leaf nodes.
*/
int
toku_brt_hot_optimize(BRT brt,
toku_ft_hot_optimize(FT_HANDLE brt,
int (*progress_callback)(void *extra, float progress),
void *progress_extra);
......
......@@ -3,11 +3,11 @@
#ident "Copyright (c) 2007-2011 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."
#include <brt-flusher.h>
#include <brt-flusher-internal.h>
#include <brt-cachetable-wrappers.h>
#include <brt-internal.h>
#include <brt_header.h>
#include <ft-flusher.h>
#include <ft-flusher-internal.h>
#include <ft-cachetable-wrappers.h>
#include <ft-internal.h>
#include <ft.h>
// Member Descirption:
// 1. highest_pivot_key - this is the key that corresponds to the
......@@ -28,7 +28,7 @@ struct hot_flusher_extra {
bool rightmost_leaf_seen;
};
static volatile BRT_HOT_STATUS_S hot_status;
static volatile FT_HOT_STATUS_S hot_status;
#define STATUS_INIT(k,t,l) { \
hot_status.status[k].keyname = #k; \
......@@ -39,21 +39,21 @@ static volatile BRT_HOT_STATUS_S hot_status;
#define STATUS_VALUE(x) hot_status.status[x].value.num
void
toku_brt_hot_status_init(void)
toku_ft_hot_status_init(void)
{
STATUS_INIT(BRT_HOT_NUM_STARTED, UINT64, "operations ever started");
STATUS_INIT(BRT_HOT_NUM_COMPLETED, UINT64, "operations successfully completed");
STATUS_INIT(BRT_HOT_NUM_ABORTED, UINT64, "operations aborted");
STATUS_INIT(BRT_HOT_MAX_ROOT_FLUSH_COUNT, UINT64, "max number of flushes from root ever required to optimize a tree");
STATUS_INIT(FT_HOT_NUM_STARTED, UINT64, "operations ever started");
STATUS_INIT(FT_HOT_NUM_COMPLETED, UINT64, "operations successfully completed");
STATUS_INIT(FT_HOT_NUM_ABORTED, UINT64, "operations aborted");
STATUS_INIT(FT_HOT_MAX_ROOT_FLUSH_COUNT, UINT64, "max number of flushes from root ever required to optimize a tree");
hot_status.initialized = true;
}
#undef STATUS_INIT
void
toku_brt_hot_get_status(BRT_HOT_STATUS s) {
toku_ft_hot_get_status(FT_HOT_STATUS s) {
if (!hot_status.initialized) {
toku_brt_hot_status_init();
toku_ft_hot_status_init();
}
*s = hot_status;
}
......@@ -88,7 +88,7 @@ hot_set_highest_key(struct hot_flusher_extra *flusher)
// Copies the pivot key in the parent to the given DBT key, using the
// pivot corresponding to the given child.
static void
hot_set_key(DBT *key, BRTNODE parent, int childnum)
hot_set_key(DBT *key, FTNODE parent, int childnum)
{
// assert that childnum is less than number of children - 1.
DBT *pivot = &parent->childkeys[childnum];
......@@ -103,8 +103,8 @@ hot_set_key(DBT *key, BRTNODE parent, int childnum)
}
static int
hot_just_pick_child(struct brt_header *h,
BRTNODE parent,
hot_just_pick_child(FT h,
FTNODE parent,
struct hot_flusher_extra *flusher)
{
int childnum = 0;
......@@ -118,7 +118,7 @@ hot_just_pick_child(struct brt_header *h,
childnum = 0;
} else {
// Find the pivot boundary.
childnum = toku_brtnode_hot_next_child(parent,
childnum = toku_ftnode_hot_next_child(parent,
&flusher->highest_pivot_key,
&h->cmp_descriptor,
h->compare_fun);
......@@ -128,7 +128,7 @@ hot_just_pick_child(struct brt_header *h,
}
static void
hot_update_flusher_keys(BRTNODE parent,
hot_update_flusher_keys(FTNODE parent,
int childnum,
struct hot_flusher_extra *flusher)
{
......@@ -142,8 +142,8 @@ hot_update_flusher_keys(BRTNODE parent,
// Picks which child flush_some_child will use for flushing and
// recursion.
static int
hot_pick_child(struct brt_header *h,
BRTNODE parent,
hot_pick_child(FT h,
FTNODE parent,
void *extra)
{
struct hot_flusher_extra *flusher = extra;
......@@ -166,7 +166,7 @@ hot_pick_child(struct brt_header *h,
// Does nothing for now.
static void
hot_update_status(BRTNODE UU(child),
hot_update_status(FTNODE UU(child),
int UU(dirtied),
void *UU(extra))
{
......@@ -177,8 +177,8 @@ hot_update_status(BRTNODE UU(child),
// one to flush into. This gives it a chance to do that, and update the
// keys it maintains.
static int
hot_pick_child_after_split(struct brt_header *h,
BRTNODE parent,
hot_pick_child_after_split(FT h,
FTNODE parent,
int childnuma,
int childnumb,
void *extra)
......@@ -189,8 +189,8 @@ hot_pick_child_after_split(struct brt_header *h,
hot_update_flusher_keys(parent, childnum, flusher);
if (parent->height == 1) {
// We don't want to recurse into a leaf node, but if we return
// anything valid, brt_split_child will try to go there, so we
// return -1 to allow brt_split_child to have its default
// anything valid, ft_split_child will try to go there, so we
// return -1 to allow ft_split_child to have its default
// behavior, which will be to stop recursing.
childnum = -1;
}
......@@ -237,7 +237,7 @@ hot_flusher_destroy(struct hot_flusher_extra *flusher)
// Entry point for Hot Optimize Table (HOT). Note, this function is
// not recursive. It iterates over root-to-leaf paths.
int
toku_brt_hot_optimize(BRT brt,
toku_ft_hot_optimize(FT_HANDLE brt,
int (*progress_callback)(void *extra, float progress),
void *progress_extra)
{
......@@ -250,29 +250,29 @@ toku_brt_hot_optimize(BRT brt,
uint64_t loop_count = 0;
MSN msn_at_start_of_hot = ZERO_MSN; // capture msn from root at
// start of HOT operation
(void) __sync_fetch_and_add(&STATUS_VALUE(BRT_HOT_NUM_STARTED), 1);
(void) __sync_fetch_and_add(&STATUS_VALUE(FT_HOT_NUM_STARTED), 1);
{
toku_brt_header_note_hot_begin(brt);
toku_ft_note_hot_begin(brt);
}
// Higher level logic prevents a dictionary from being deleted or
// truncated during a hot optimize operation. Doing so would violate
// the hot optimize contract.
do {
BRTNODE root;
FTNODE root;
CACHEKEY root_key;
u_int32_t fullhash;
{
toku_brtheader_grab_treelock(brt->h);
toku_ft_grab_treelock(brt->h);
// Get root node (the first parent of each successive HOT
// call.)
toku_calculate_root_offset_pointer(brt->h, &root_key, &fullhash);
struct brtnode_fetch_extra bfe;
struct ftnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
toku_pin_brtnode_off_client_thread(brt->h,
toku_pin_ftnode_off_client_thread(brt->h,
(BLOCKNUM) root_key,
fullhash,
&bfe,
......@@ -282,7 +282,7 @@ toku_brt_hot_optimize(BRT brt,
&root);
toku_assert_entire_node_in_memory(root);
toku_brtheader_release_treelock(brt->h);
toku_ft_release_treelock(brt->h);
}
// Prepare HOT diagnostics.
......@@ -293,8 +293,8 @@ toku_brt_hot_optimize(BRT brt,
loop_count++;
if (loop_count > STATUS_VALUE(BRT_HOT_MAX_ROOT_FLUSH_COUNT)) {
STATUS_VALUE(BRT_HOT_MAX_ROOT_FLUSH_COUNT) = loop_count;
if (loop_count > STATUS_VALUE(FT_HOT_MAX_ROOT_FLUSH_COUNT)) {
STATUS_VALUE(FT_HOT_MAX_ROOT_FLUSH_COUNT) = loop_count;
}
// Initialize the maximum current key. We need to do this for
......@@ -315,7 +315,7 @@ toku_brt_hot_optimize(BRT brt,
// Since there are no children to flush, we should abort
// the HOT call.
flusher.rightmost_leaf_seen = 1;
toku_unpin_brtnode_off_client_thread(brt->h, root);
toku_unpin_ftnode_off_client_thread(brt->h, root);
}
// Set the highest pivot key seen here, since the parent may
......@@ -352,13 +352,13 @@ toku_brt_hot_optimize(BRT brt,
if (r == 0) { success = true; }
{
toku_brt_header_note_hot_complete(brt, success, msn_at_start_of_hot);
toku_ft_note_hot_complete(brt, success, msn_at_start_of_hot);
}
if (success) {
(void) __sync_fetch_and_add(&STATUS_VALUE(BRT_HOT_NUM_COMPLETED), 1);
(void) __sync_fetch_and_add(&STATUS_VALUE(FT_HOT_NUM_COMPLETED), 1);
} else {
(void) __sync_fetch_and_add(&STATUS_VALUE(BRT_HOT_NUM_ABORTED), 1);
(void) __sync_fetch_and_add(&STATUS_VALUE(FT_HOT_NUM_ABORTED), 1);
}
}
return r;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,32 +2,32 @@
#ident "Copyright (c) 2007-2010 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."
#ifndef BRT_SEARCH_H
#define BRT_SEARCH_H
#ifndef FT_SEARCH_H
#define FT_SEARCH_H
#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
#endif
enum brt_search_direction_e {
BRT_SEARCH_LEFT = 1, /* search left -> right, finds min xy as defined by the compare function */
BRT_SEARCH_RIGHT = 2, /* search right -> left, finds max xy as defined by the compare function */
enum ft_search_direction_e {
FT_SEARCH_LEFT = 1, /* search left -> right, finds min xy as defined by the compare function */
FT_SEARCH_RIGHT = 2, /* search right -> left, finds max xy as defined by the compare function */
};
struct brt_search;
struct ft_search;
/* the search compare function should return 0 for all xy < kv and 1 for all xy >= kv
the compare function should be a step function from 0 to 1 for a left to right search
and 1 to 0 for a right to left search */
typedef int (*brt_search_compare_func_t)(struct brt_search */*so*/, DBT *);
typedef int (*ft_search_compare_func_t)(struct ft_search */*so*/, DBT *);
/* the search object contains the compare function, search direction, and the kv pair that
is used in the compare function. the context is the user's private data */
typedef struct brt_search {
brt_search_compare_func_t compare;
enum brt_search_direction_e direction;
typedef struct ft_search {
ft_search_compare_func_t compare;
enum ft_search_direction_e direction;
const DBT *k;
void *context;
......@@ -53,10 +53,10 @@ typedef struct brt_search {
// way out with a DB_NOTFOUND we ought to unpin those nodes. See #3528.
BOOL have_pivot_bound;
DBT pivot_bound;
} brt_search_t;
} ft_search_t;
/* initialize the search compare object */
static inline brt_search_t *brt_search_init(brt_search_t *so, brt_search_compare_func_t compare, enum brt_search_direction_e direction, const DBT *k, void *context) {
static inline ft_search_t *ft_search_init(ft_search_t *so, ft_search_compare_func_t compare, enum ft_search_direction_e direction, const DBT *k, void *context) {
so->compare = compare;
so->direction = direction;
so->k = k;
......@@ -65,7 +65,7 @@ static inline brt_search_t *brt_search_init(brt_search_t *so, brt_search_compare
return so;
}
static inline void brt_search_finish(brt_search_t *so) {
static inline void ft_search_finish(ft_search_t *so) {
if (so->have_pivot_bound) toku_free(so->pivot_bound.data);
}
......
......@@ -5,11 +5,11 @@
#include "includes.h"
#include "ule.h"
#include <brt-cachetable-wrappers.h>
#include <brt-flusher.h>
#include <ft-cachetable-wrappers.h>
#include <ft-flusher.h>
// dummymsn needed to simulate msn because messages are injected at a lower level than toku_brt_root_put_cmd()
// dummymsn needed to simulate msn because messages are injected at a lower level than toku_ft_root_put_cmd()
#define MIN_DUMMYMSN ((MSN) {(uint64_t)1 << 62})
static MSN dummymsn;
static int testsetup_initialized = 0;
......@@ -32,10 +32,10 @@ next_dummymsn(void) {
BOOL ignore_if_was_already_open;
int toku_testsetup_leaf(BRT brt, BLOCKNUM *blocknum, int n_children, char **keys, int *keylens) {
BRTNODE node;
int toku_testsetup_leaf(FT_HANDLE brt, BLOCKNUM *blocknum, int n_children, char **keys, int *keylens) {
FTNODE node;
assert(testsetup_initialized);
toku_create_new_brtnode(brt, &node, 0, n_children);
toku_create_new_ftnode(brt, &node, 0, n_children);
int i;
for (i=0; i<n_children; i++) {
BP_STATE(node,i) = PT_AVAIL;
......@@ -47,16 +47,16 @@ int toku_testsetup_leaf(BRT brt, BLOCKNUM *blocknum, int n_children, char **keys
}
*blocknum = node->thisnodename;
toku_unpin_brtnode(brt->h, node);
toku_unpin_ftnode(brt->h, node);
return 0;
}
// Don't bother to clean up carefully if something goes wrong. (E.g., it's OK to have malloced stuff that hasn't been freed.)
int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_children, BLOCKNUM *children, char **keys, int *keylens) {
BRTNODE node;
int toku_testsetup_nonleaf (FT_HANDLE brt, int height, BLOCKNUM *blocknum, int n_children, BLOCKNUM *children, char **keys, int *keylens) {
FTNODE node;
assert(testsetup_initialized);
assert(n_children<=BRT_FANOUT);
toku_create_new_brtnode(brt, &node, height, n_children);
assert(n_children<=FT_FANOUT);
toku_create_new_ftnode(brt, &node, height, n_children);
int i;
for (i=0; i<n_children; i++) {
BP_BLOCKNUM(node, i) = children[i];
......@@ -67,21 +67,21 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child
node->totalchildkeylens += keylens[i];
}
*blocknum = node->thisnodename;
toku_unpin_brtnode(brt->h, node);
toku_unpin_ftnode(brt->h, node);
return 0;
}
int toku_testsetup_root(BRT brt, BLOCKNUM blocknum) {
int toku_testsetup_root(FT_HANDLE brt, BLOCKNUM blocknum) {
assert(testsetup_initialized);
brt->h->root_blocknum = blocknum;
return 0;
}
int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on disk
int toku_testsetup_get_sersize(FT_HANDLE brt, BLOCKNUM diskoff) // Return the size on disk
{
assert(testsetup_initialized);
void *node_v;
struct brtnode_fetch_extra bfe;
struct ftnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
int r = toku_cachetable_get_and_pin(
brt->h->cf, diskoff,
......@@ -89,25 +89,25 @@ int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on
&node_v,
NULL,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_ftnode_fetch_callback,
toku_ftnode_pf_req_callback,
toku_ftnode_pf_callback,
TRUE,
&bfe
);
assert(r==0);
int size = toku_serialize_brtnode_size(node_v);
toku_unpin_brtnode(brt->h, node_v);
int size = toku_serialize_ftnode_size(node_v);
toku_unpin_ftnode(brt->h, node_v);
return size;
}
int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int keylen, char *val, int vallen) {
int toku_testsetup_insert_to_leaf (FT_HANDLE brt, BLOCKNUM blocknum, char *key, int keylen, char *val, int vallen) {
void *node_v;
int r;
assert(testsetup_initialized);
struct brtnode_fetch_extra bfe;
struct ftnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
r = toku_cachetable_get_and_pin(
brt->h->cf,
......@@ -116,24 +116,24 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
&node_v,
NULL,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_ftnode_fetch_callback,
toku_ftnode_pf_req_callback,
toku_ftnode_pf_callback,
TRUE,
&bfe
);
if (r!=0) return r;
BRTNODE node=node_v;
FTNODE node=node_v;
toku_verify_or_set_counts(node);
assert(node->height==0);
DBT keydbt,valdbt;
MSN msn = next_dummymsn();
BRT_MSG_S cmd = {BRT_INSERT, msn, xids_get_root_xids(),
FT_MSG_S cmd = {FT_INSERT, msn, xids_get_root_xids(),
.u.id={toku_fill_dbt(&keydbt, key, keylen),
toku_fill_dbt(&valdbt, val, vallen)}};
toku_brt_node_put_cmd (
toku_ft_node_put_cmd (
brt->h->compare_fun,
brt->h->update_fun,
&brt->h->cmp_descriptor,
......@@ -145,7 +145,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
toku_verify_or_set_counts(node);
toku_unpin_brtnode(brt->h, node_v);
toku_unpin_ftnode(brt->h, node_v);
return 0;
}
......@@ -158,11 +158,11 @@ testhelper_string_key_cmp(DB *UU(e), const DBT *a, const DBT *b)
void
toku_pin_node_with_min_bfe(BRTNODE* node, BLOCKNUM b, BRT t)
toku_pin_node_with_min_bfe(FTNODE* node, BLOCKNUM b, FT_HANDLE t)
{
struct brtnode_fetch_extra bfe;
struct ftnode_fetch_extra bfe;
fill_bfe_for_min_read(&bfe, t->h);
toku_pin_brtnode_off_client_thread(
toku_pin_ftnode_off_client_thread(
t->h,
b,
toku_cachetable_hash(t->h->cf, b),
......@@ -174,13 +174,13 @@ toku_pin_node_with_min_bfe(BRTNODE* node, BLOCKNUM b, BRT t)
);
}
int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_type cmdtype, char *key, int keylen, char *val, int vallen) {
int toku_testsetup_insert_to_nonleaf (FT_HANDLE brt, BLOCKNUM blocknum, enum ft_msg_type cmdtype, char *key, int keylen, char *val, int vallen) {
void *node_v;
int r;
assert(testsetup_initialized);
struct brtnode_fetch_extra bfe;
struct ftnode_fetch_extra bfe;
fill_bfe_for_full_read(&bfe, brt->h);
r = toku_cachetable_get_and_pin(
brt->h->cf,
......@@ -189,18 +189,18 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
&node_v,
NULL,
get_write_callbacks_for_node(brt->h),
toku_brtnode_fetch_callback,
toku_brtnode_pf_req_callback,
toku_brtnode_pf_callback,
toku_ftnode_fetch_callback,
toku_ftnode_pf_req_callback,
toku_ftnode_pf_callback,
TRUE,
&bfe
);
if (r!=0) return r;
BRTNODE node=node_v;
FTNODE node=node_v;
assert(node->height>0);
DBT k;
int childnum = toku_brtnode_which_child(node,
int childnum = toku_ftnode_which_child(node,
toku_fill_dbt(&k, key, keylen),
&brt->h->cmp_descriptor, brt->compare_fun);
......@@ -214,6 +214,6 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
node->max_msn_applied_to_node_on_disk = msn;
node->dirty = 1;
toku_unpin_brtnode(brt->h, node_v);
toku_unpin_ftnode(brt->h, node_v);
return 0;
}
This diff is collapsed.
This diff is collapsed.
/* -*- mode: C; c-basic-offset: 4 -*- */
#ifndef FT_H
#define FT_H
#ident "$Id: ft.h 43422 2012-05-12 17:51:02Z zardosht $"
#ident "Copyright (c) 2007-2010 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."
#include "fttypes.h"
#include "ybt.h"
#include <db.h>
#include "cachetable.h"
#include "log.h"
#include "ft-search.h"
#include "compress.h"
void toku_ft_suppress_rollbacks(FT h, TOKUTXN txn);
//Effect: suppresses rollback logs
void toku_ft_init_treelock(FT h);
void toku_ft_destroy_treelock(FT h);
void toku_ft_grab_treelock(FT h);
void toku_ft_release_treelock(FT h);
int toku_create_new_ft(FT_HANDLE t, CACHEFILE cf, TOKUTXN txn);
void toku_ft_free (FT h);
int toku_read_ft_and_store_in_cachefile (FT_HANDLE brt, CACHEFILE cf, LSN max_acceptable_lsn, FT *header, BOOL* was_open);
void toku_ft_note_ft_handle_open(FT_HANDLE live);
int toku_ft_needed(FT h);
int toku_remove_ft (FT h, char **error_string, BOOL oplsn_valid, LSN oplsn) __attribute__ ((warn_unused_result));
FT_HANDLE toku_ft_get_some_existing_ft_handle(FT h);
void toku_ft_note_hot_begin(FT_HANDLE brt);
void toku_ft_note_hot_complete(FT_HANDLE brt, BOOL success, MSN msn_at_start_of_hot);
void
toku_ft_init(
FT h,
BLOCKNUM root_blocknum_on_disk,
LSN checkpoint_lsn,
TXNID root_xid_that_created,
uint32_t target_nodesize,
uint32_t target_basementnodesize,
enum toku_compression_method compression_method
);
int toku_dictionary_redirect_abort(FT old_h, FT new_h, TOKUTXN txn) __attribute__ ((warn_unused_result));
int toku_dictionary_redirect (const char *dst_fname_in_env, FT_HANDLE old_ft, TOKUTXN txn);
void toku_reset_root_xid_that_created(FT h, TXNID new_root_xid_that_created);
// Reset the root_xid_that_created field to the given value.
// This redefines which xid created the dictionary.
BOOL
toku_ft_maybe_add_txn_ref(FT h, TOKUTXN txn);
void
toku_ft_remove_txn_ref(FT h, TOKUTXN txn);
void toku_calculate_root_offset_pointer ( FT h, CACHEKEY* root_key, u_int32_t *roothash);
void toku_ft_set_new_root_blocknum(FT h, CACHEKEY new_root_key);
LSN toku_ft_checkpoint_lsn(FT h) __attribute__ ((warn_unused_result));
int toku_ft_set_panic(FT h, int panic, char *panic_string) __attribute__ ((warn_unused_result));
void toku_ft_stat64 (FT h, struct ftstat64_s *s);
int toku_update_descriptor(FT h, DESCRIPTOR d, int fd);
// Note: See the locking discussion in ft-ops.c for toku_ft_change_descriptor and toku_update_descriptor.
void toku_ft_update_cmp_descriptor(FT h);
void toku_ft_update_stats(STAT64INFO headerstats, STAT64INFO_S delta);
void toku_ft_decrease_stats(STAT64INFO headerstats, STAT64INFO_S delta);
#endif
/* -*- mode: C; c-basic-offset: 4 -*- */
#ifndef FT_LAYOUT_VERSION_H
#define FT_LAYOUT_VERSION_H
#ident "$Id$"
#ident "Copyright (c) 2007-2010 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."
//Must be defined before other recursive headers could include logger.h
enum ft_layout_version_e {
FT_LAYOUT_VERSION_5 = 5,
FT_LAYOUT_VERSION_6 = 6, // Diff from 5 to 6: Add leafentry_estimate
FT_LAYOUT_VERSION_7 = 7, // Diff from 6 to 7: Add exact-bit to leafentry_estimate #818, add magic to header #22, add per-subdatase flags #333
FT_LAYOUT_VERSION_8 = 8, // Diff from 7 to 8: Use murmur instead of crc32. We are going to make a simplification and stop supporting version 7 and before. Current As of Beta 1.0.6
FT_LAYOUT_VERSION_9 = 9, // Diff from 8 to 9: Variable-sized blocks and compression.
FT_LAYOUT_VERSION_10 = 10, // Diff from 9 to 10: Variable number of compressed sub-blocks per block, disk byte order == intel byte order, Subtree estimates instead of just leafentry estimates, translation table, dictionary descriptors, checksum in header, subdb support removed from brt layer
FT_LAYOUT_VERSION_11 = 11, // Diff from 10 to 11: Nested transaction leafentries (completely redesigned). FT_CMDs on disk now support XIDS (multiple txnids) instead of exactly one.
FT_LAYOUT_VERSION_12 = 12, // Diff from 11 to 12: Added FT_CMD 'FT_INSERT_NO_OVERWRITE', compressed block format, num old blocks
FT_LAYOUT_VERSION_13 = 13, // Diff from 12 to 13: Fixed loader pivot bug, added build_id to every node, timestamps to ft
FT_LAYOUT_VERSION_14 = 14, // Diff from 13 to 14: Added MVCC; deprecated TOKU_DB_VALCMP_BUILTIN(_13); Remove fingerprints; Support QUICKLZ; add end-to-end checksum on uncompressed data.
FT_LAYOUT_VERSION_15 = 15, // Diff from 14 to 15: basement nodes, last verification time
FT_LAYOUT_VERSION_16 = 16, // Dr. No: No subtree estimates, partition layout information represented more transparently.
// ALERT ALERT ALERT: version 16 never released to customers, internal and beta use only
FT_LAYOUT_VERSION_17 = 17, // Dr. No: Add STAT64INFO_S to brt_header
FT_LAYOUT_VERSION_18 = 18, // Dr. No: Add HOT info to brt_header
FT_LAYOUT_VERSION_19 = 19, // Doofenshmirtz: Add compression method, highest_unused_msn_for_upgrade
FT_LAYOUT_VERSION_20 = 20, // Clayface: Add compression method to log_fcreate
FT_NEXT_VERSION, // the version after the current version
FT_LAYOUT_VERSION = FT_NEXT_VERSION-1, // A hack so I don't have to change this line.
FT_LAYOUT_MIN_SUPPORTED_VERSION = FT_LAYOUT_VERSION_13, // Minimum version supported
// Define these symbolically so the knowledge of exactly which layout version got rid of fingerprints isn't spread all over the code.
FT_LAST_LAYOUT_VERSION_WITH_FINGERPRINT = FT_LAYOUT_VERSION_13,
FT_FIRST_LAYOUT_VERSION_WITH_END_TO_END_CHECKSUM = FT_LAYOUT_VERSION_14,
FT_FIRST_LAYOUT_VERSION_WITH_BASEMENT_NODES = FT_LAYOUT_VERSION_15,
};
#endif
......@@ -4,44 +4,44 @@
#include <toku_portability.h>
#include "brttypes.h"
#include "fttypes.h"
#include "xids.h"
#include "brt_msg.h"
#include "ft_msg.h"
u_int32_t
brt_msg_get_keylen(BRT_MSG brt_msg) {
u_int32_t rval = brt_msg->u.id.key->size;
ft_msg_get_keylen(FT_MSG ft_msg) {
u_int32_t rval = ft_msg->u.id.key->size;
return rval;
}
u_int32_t
brt_msg_get_vallen(BRT_MSG brt_msg) {
u_int32_t rval = brt_msg->u.id.val->size;
ft_msg_get_vallen(FT_MSG ft_msg) {
u_int32_t rval = ft_msg->u.id.val->size;
return rval;
}
XIDS
brt_msg_get_xids(BRT_MSG brt_msg) {
XIDS rval = brt_msg->xids;
ft_msg_get_xids(FT_MSG ft_msg) {
XIDS rval = ft_msg->xids;
return rval;
}
void *
brt_msg_get_key(BRT_MSG brt_msg) {
void * rval = brt_msg->u.id.key->data;
ft_msg_get_key(FT_MSG ft_msg) {
void * rval = ft_msg->u.id.key->data;
return rval;
}
void *
brt_msg_get_val(BRT_MSG brt_msg) {
void * rval = brt_msg->u.id.val->data;
ft_msg_get_val(FT_MSG ft_msg) {
void * rval = ft_msg->u.id.val->data;
return rval;
}
enum brt_msg_type
brt_msg_get_type(BRT_MSG brt_msg) {
enum brt_msg_type rval = brt_msg->type;
enum ft_msg_type
ft_msg_get_type(FT_MSG ft_msg) {
enum ft_msg_type rval = ft_msg->type;
return rval;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -35,9 +35,9 @@
#include <string.h>
#include "block_allocator.h"
#include "brt.h"
#include "brt_header.h"
#include "brt-internal.h"
#include "ft-ops.h"
#include "ft.h"
#include "ft-internal.h"
#include "cachetable.h"
#include "rwlock.h"
#include "fifo.h"
......@@ -45,7 +45,7 @@
#include "key.h"
#include "leafentry.h"
#include "log-internal.h"
#include <newbrt/log_header.h>
#include <ft/log_header.h>
#include "logcursor.h"
#include "logfilemgr.h"
#include "rbuf.h"
......
......@@ -6,7 +6,7 @@
#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 "ybt.h"
#include "brttypes.h"
#include "fttypes.h"
#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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