From 2fd8f750ab05bd100b627f1e043603d1069246ed Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Thu, 29 Jan 2015 16:33:11 -0800 Subject: [PATCH] Compile MemEnv with standard RocksDB library Summary: This was a feature request by osquery. See task t5617758 Test Plan: compiles and memenv_test runs Reviewers: yhchiang, rven, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D32115 --- HISTORY.md | 1 + Makefile | 12 +++--------- build_tools/build_detect_platform | 3 +-- build_tools/unity | 2 +- {helpers/memenv => util}/memenv.cc | 8 ++++++++ {helpers/memenv => util}/memenv_test.cc | 0 6 files changed, 14 insertions(+), 12 deletions(-) rename {helpers/memenv => util}/memenv.cc (98%) rename {helpers/memenv => util}/memenv_test.cc (100%) diff --git a/HISTORY.md b/HISTORY.md index bce856f4f..22b0c05ab 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -11,6 +11,7 @@ * Added BlockBasedTableOptions.format_version option, which allows user to specify which version of block based table he wants. As a general guidline, newer versions have more features, but might not be readable by older versions of RocksDB. * Added new block based table format (version 2), which you can enable by setting BlockBasedTableOptions.format_version = 2. This format changes how we encode size information in compressed blocks and should help with memory allocations if you're using Zlib or BZip2 compressions. * GetThreadStatus() is now able to report compaction activity. +* MemEnv (env that stores data in memory) is now available in default library build. You can create it by calling NewMemEnv(). ### Public API changes * Deprecated skip_log_error_on_recovery option diff --git a/Makefile b/Makefile index bcd8c77d7..36814780b 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,6 @@ CXXFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverl LDFLAGS += $(PLATFORM_LDFLAGS) LIBOBJECTS = $(SOURCES:.cc=.o) -MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o) MOCKOBJECTS = $(MOCK_SOURCES:.cc=.o) TESTUTIL = ./util/testutil.o @@ -196,7 +195,6 @@ ifeq ($(LIBNAME),) LIBNAME=librocksdb endif LIBRARY = ${LIBNAME}.a -MEMENVLIBRARY = libmemenv.a ROCKSDB_MAJOR = $(shell egrep "ROCKSDB_MAJOR.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3) ROCKSDB_MINOR = $(shell egrep "ROCKSDB_MINOR.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3) @@ -311,7 +309,7 @@ unity: unity.cc unity.o $(CXX) unity.o $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS) clean: - -rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) make_config.mk unity.cc + -rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) make_config.mk unity.cc -rm -rf ios-x86/* ios-arm/* -find . -name "*.[oda]" -exec rm {} \; -find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \; @@ -552,12 +550,8 @@ options_test: util/options_test.o util/options_helper.o $(LIBOBJECTS) $(TESTHARN sst_dump_test: util/sst_dump_test.o $(LIBOBJECTS) $(TESTHARNESS) $(CXX) util/sst_dump_test.o $(LIBOBJECTS) $(TESTHARNESS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS) -$(MEMENVLIBRARY) : $(MEMENVOBJECTS) - rm -f $@ - $(AR) -rs $@ $(MEMENVOBJECTS) - -memenv_test : helpers/memenv/memenv_test.o $(MEMENVOBJECTS) $(LIBOBJECTS) $(TESTHARNESS) - $(CXX) helpers/memenv/memenv_test.o $(MEMENVOBJECTS) $(LIBOBJECTS) $(TESTHARNESS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS) +memenv_test : util/memenv_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) util/memenv_test.o $(LIBOBJECTS) $(TESTHARNESS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS) mock_env_test : util/mock_env_test.o $(LIBOBJECTS) $(TESTHARNESS) $(CXX) util/mock_env_test.o $(LIBOBJECTS) $(TESTHARNESS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 58451ace2..b314b3acb 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -161,7 +161,7 @@ if test -z "$DO_NOT_RUN_BUILD_DETECT_VERSION"; then "$PWD/build_tools/build_detect_version" fi -# We want to make a list of all cc files within util, db, table, and helpers +# We want to make a list of all cc files within util, db and table # except for the test and benchmark files. By default, find will output a list # of all files matching either rule, so we need to append -print to make the # prune take effect. @@ -179,7 +179,6 @@ set +f # re-enable globbing # file. echo "SOURCES=$PORTABLE_FILES $GENERIC_PORT_FILES $PORT_FILES" >> "$OUTPUT" echo "MOCK_SOURCES=$MOCK_SOURCES" >> "$OUTPUT" -echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> "$OUTPUT" if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then # Cross-compiling; do not try any compilation tests. diff --git a/build_tools/unity b/build_tools/unity index 477b8f7fb..8138de542 100755 --- a/build_tools/unity +++ b/build_tools/unity @@ -54,7 +54,7 @@ case "$TARGET_OS" in exit 1 esac -# We want to make a list of all cc files within util, db, table, and helpers +# We want to make a list of all cc files within util, db and table # except for the test and benchmark files. By default, find will output a list # of all files matching either rule, so we need to append -print to make the # prune take effect. diff --git a/helpers/memenv/memenv.cc b/util/memenv.cc similarity index 98% rename from helpers/memenv/memenv.cc rename to util/memenv.cc index d13fa55eb..e2db2e140 100644 --- a/helpers/memenv/memenv.cc +++ b/util/memenv.cc @@ -13,6 +13,8 @@ namespace rocksdb { +#ifndef ROCKSDB_LITE + namespace { std::string NormalizeFileName(const std::string fname) { @@ -420,4 +422,10 @@ Env* NewMemEnv(Env* base_env) { return new InMemoryEnv(base_env); } +#else // ROCKSDB_LITE + +Env* NewMemEnv(Env* base_env) { return nullptr; } + +#endif // !ROCKSDB_LITE + } // namespace rocksdb diff --git a/helpers/memenv/memenv_test.cc b/util/memenv_test.cc similarity index 100% rename from helpers/memenv/memenv_test.cc rename to util/memenv_test.cc