From a98fbacfa01dd323272612f72b0cea0fba0de234 Mon Sep 17 00:00:00 2001 From: Venkatesh Radhakrishnan Date: Fri, 16 Oct 2015 14:10:33 -0700 Subject: [PATCH] Moving memtable related files from util to a new directory memtable Summary: We are cleaning up dependencies. This diff takes a first step at moving memtable files to their own directory called memtable. In future diffs, we will move other memtable files from db to memtable. Test Plan: make check Reviewers: sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D48915 --- CMakeLists.txt | 6 ++--- db/column_family.cc | 2 +- db/compaction_job_stats_test.cc | 2 +- db/comparator_db_test.cc | 3 ++- db/db_impl.cc | 4 ++-- db/db_test.cc | 2 +- db/db_test_util.h | 2 +- db/listener_test.cc | 2 +- {util => memtable}/hash_cuckoo_rep.cc | 6 ++--- {util => memtable}/hash_cuckoo_rep.h | 3 ++- {util => memtable}/hash_linklist_rep.cc | 2 +- {util => memtable}/hash_linklist_rep.h | 2 +- {util => memtable}/hash_skiplist_rep.cc | 2 +- {util => memtable}/hash_skiplist_rep.h | 2 +- {util => memtable}/stl_wrappers.h | 12 ---------- src.mk | 6 ++--- table/meta_blocks.h | 2 +- table/mock_table.h | 2 +- table/table_test.cc | 2 +- util/kv_map.h | 31 +++++++++++++++++++++++++ util/vectorrep.cc | 2 +- 21 files changed, 59 insertions(+), 38 deletions(-) rename {util => memtable}/hash_cuckoo_rep.cc (99%) rename {util => memtable}/hash_cuckoo_rep.h (98%) rename {util => memtable}/hash_linklist_rep.cc (99%) rename {util => memtable}/hash_linklist_rep.h (100%) rename {util => memtable}/hash_skiplist_rep.cc (99%) rename {util => memtable}/hash_skiplist_rep.h (100%) rename {util => memtable}/stl_wrappers.h (73%) create mode 100644 util/kv_map.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a8ad95fc8..3655c79c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,9 @@ set(SOURCES db/write_batch_base.cc db/write_controller.cc db/write_thread.cc + memtable/hash_cuckoo_rep.cc + memtable/hash_linklist_rep.cc + memtable/hash_skiplist_rep.cc port/stack_trace.cc port/win/env_win.cc port/win/port_win.cc @@ -185,9 +188,6 @@ set(SOURCES util/file_reader_writer.cc util/filter_policy.cc util/hash.cc - util/hash_cuckoo_rep.cc - util/hash_linklist_rep.cc - util/hash_skiplist_rep.cc util/histogram.cc util/instrumented_mutex.cc util/iostats_context.cc diff --git a/db/column_family.cc b/db/column_family.cc index 88bf0339b..f6233a729 100644 --- a/db/column_family.cc +++ b/db/column_family.cc @@ -27,9 +27,9 @@ #include "db/version_set.h" #include "db/write_controller.h" #include "db/writebuffer.h" +#include "memtable/hash_skiplist_rep.h" #include "util/autovector.h" #include "util/compression.h" -#include "util/hash_skiplist_rep.h" #include "util/options_helper.h" #include "util/thread_status_util.h" #include "util/xfunc.h" diff --git a/db/compaction_job_stats_test.cc b/db/compaction_job_stats_test.cc index 1d69e61f0..d6a82e18d 100644 --- a/db/compaction_job_stats_test.cc +++ b/db/compaction_job_stats_test.cc @@ -27,6 +27,7 @@ #include "db/job_context.h" #include "db/version_set.h" #include "db/write_batch_internal.h" +#include "memtable/hash_linklist_rep.h" #include "port/stack_trace.h" #include "rocksdb/cache.h" #include "rocksdb/compaction_filter.h" @@ -50,7 +51,6 @@ #include "table/scoped_arena_iterator.h" #include "util/compression.h" #include "util/hash.h" -#include "util/hash_linklist_rep.h" #include "util/logging.h" #include "util/mock_env.h" #include "util/mutexlock.h" diff --git a/db/comparator_db_test.cc b/db/comparator_db_test.cc index cb944a76a..530c91060 100644 --- a/db/comparator_db_test.cc +++ b/db/comparator_db_test.cc @@ -7,10 +7,11 @@ #include #include +#include "memtable/stl_wrappers.h" #include "rocksdb/db.h" #include "rocksdb/env.h" #include "util/hash.h" -#include "util/stl_wrappers.h" +#include "util/kv_map.h" #include "util/string_util.h" #include "util/testharness.h" #include "util/testutil.h" diff --git a/db/db_impl.cc b/db/db_impl.cc index fe10e2086..034b51495 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -50,6 +50,8 @@ #include "db/write_batch_internal.h" #include "db/write_callback.h" #include "db/writebuffer.h" +#include "memtable/hash_linklist_rep.h" +#include "memtable/hash_skiplist_rep.h" #include "port/likely.h" #include "port/port.h" #include "rocksdb/cache.h" @@ -77,8 +79,6 @@ #include "util/db_info_dumper.h" #include "util/file_reader_writer.h" #include "util/file_util.h" -#include "util/hash_linklist_rep.h" -#include "util/hash_skiplist_rep.h" #include "util/iostats_context_imp.h" #include "util/log_buffer.h" #include "util/logging.h" diff --git a/db/db_test.cc b/db/db_test.cc index 8698251d2..690fdf812 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -30,6 +30,7 @@ #include "db/job_context.h" #include "db/version_set.h" #include "db/write_batch_internal.h" +#include "memtable/hash_linklist_rep.h" #include "port/stack_trace.h" #include "rocksdb/cache.h" #include "rocksdb/compaction_filter.h" @@ -57,7 +58,6 @@ #include "table/scoped_arena_iterator.h" #include "util/file_reader_writer.h" #include "util/hash.h" -#include "util/hash_linklist_rep.h" #include "utilities/merge_operators.h" #include "util/logging.h" #include "util/compression.h" diff --git a/db/db_test_util.h b/db/db_test_util.h index 9f1b96a71..befd6cd8c 100644 --- a/db/db_test_util.h +++ b/db/db_test_util.h @@ -30,6 +30,7 @@ #include "db/db_test_util.h" #include "db/dbformat.h" #include "db/filename.h" +#include "memtable/hash_linklist_rep.h" #include "rocksdb/cache.h" #include "rocksdb/compaction_filter.h" #include "rocksdb/convenience.h" @@ -45,7 +46,6 @@ #include "table/plain_table_factory.h" #include "table/scoped_arena_iterator.h" #include "util/compression.h" -#include "util/hash_linklist_rep.h" #include "util/mock_env.h" #include "util/mutexlock.h" diff --git a/db/listener_test.cc b/db/listener_test.cc index 0880a6597..08fe096dc 100644 --- a/db/listener_test.cc +++ b/db/listener_test.cc @@ -8,6 +8,7 @@ #include "db/filename.h" #include "db/version_set.h" #include "db/write_batch_internal.h" +#include "memtable/hash_linklist_rep.h" #include "rocksdb/cache.h" #include "rocksdb/compaction_filter.h" #include "rocksdb/db.h" @@ -22,7 +23,6 @@ #include "table/block_based_table_factory.h" #include "table/plain_table_factory.h" #include "util/hash.h" -#include "util/hash_linklist_rep.h" #include "util/logging.h" #include "util/mutexlock.h" #include "util/rate_limiter.h" diff --git a/util/hash_cuckoo_rep.cc b/memtable/hash_cuckoo_rep.cc similarity index 99% rename from util/hash_cuckoo_rep.cc rename to memtable/hash_cuckoo_rep.cc index 6e5057a73..447113ddf 100644 --- a/util/hash_cuckoo_rep.cc +++ b/memtable/hash_cuckoo_rep.cc @@ -5,8 +5,7 @@ // #ifndef ROCKSDB_LITE - -#include "util/hash_cuckoo_rep.h" +#include "memtable/hash_cuckoo_rep.h" #include #include @@ -18,9 +17,10 @@ #include "db/memtable.h" #include "db/skiplist.h" +#include "memtable/stl_wrappers.h" +#include "port/port.h" #include "rocksdb/memtablerep.h" #include "util/murmurhash.h" -#include "util/stl_wrappers.h" namespace rocksdb { namespace { diff --git a/util/hash_cuckoo_rep.h b/memtable/hash_cuckoo_rep.h similarity index 98% rename from util/hash_cuckoo_rep.h rename to memtable/hash_cuckoo_rep.h index 9f374a978..6de4baa20 100644 --- a/util/hash_cuckoo_rep.h +++ b/memtable/hash_cuckoo_rep.h @@ -6,8 +6,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. -#ifndef ROCKSDB_LITE #pragma once +#ifndef ROCKSDB_LITE +#include "port/port.h" #include "rocksdb/slice_transform.h" #include "rocksdb/memtablerep.h" diff --git a/util/hash_linklist_rep.cc b/memtable/hash_linklist_rep.cc similarity index 99% rename from util/hash_linklist_rep.cc rename to memtable/hash_linklist_rep.cc index 1e6eadfe6..2e761ce15 100644 --- a/util/hash_linklist_rep.cc +++ b/memtable/hash_linklist_rep.cc @@ -5,7 +5,7 @@ // #ifndef ROCKSDB_LITE -#include "util/hash_linklist_rep.h" +#include "memtable/hash_linklist_rep.h" #include #include diff --git a/util/hash_linklist_rep.h b/memtable/hash_linklist_rep.h similarity index 100% rename from util/hash_linklist_rep.h rename to memtable/hash_linklist_rep.h index 629272394..1bab441ed 100644 --- a/util/hash_linklist_rep.h +++ b/memtable/hash_linklist_rep.h @@ -6,8 +6,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. -#ifndef ROCKSDB_LITE #pragma once +#ifndef ROCKSDB_LITE #include "rocksdb/slice_transform.h" #include "rocksdb/memtablerep.h" diff --git a/util/hash_skiplist_rep.cc b/memtable/hash_skiplist_rep.cc similarity index 99% rename from util/hash_skiplist_rep.cc rename to memtable/hash_skiplist_rep.cc index 142903d42..cbdd88993 100644 --- a/util/hash_skiplist_rep.cc +++ b/memtable/hash_skiplist_rep.cc @@ -5,7 +5,7 @@ // #ifndef ROCKSDB_LITE -#include "util/hash_skiplist_rep.h" +#include "memtable/hash_skiplist_rep.h" #include diff --git a/util/hash_skiplist_rep.h b/memtable/hash_skiplist_rep.h similarity index 100% rename from util/hash_skiplist_rep.h rename to memtable/hash_skiplist_rep.h index 15d0fc77f..a6544ff04 100644 --- a/util/hash_skiplist_rep.h +++ b/memtable/hash_skiplist_rep.h @@ -6,8 +6,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. -#ifndef ROCKSDB_LITE #pragma once +#ifndef ROCKSDB_LITE #include "rocksdb/slice_transform.h" #include "rocksdb/memtablerep.h" diff --git a/util/stl_wrappers.h b/memtable/stl_wrappers.h similarity index 73% rename from util/stl_wrappers.h rename to memtable/stl_wrappers.h index 15b9bdf52..cef8301fa 100644 --- a/util/stl_wrappers.h +++ b/memtable/stl_wrappers.h @@ -30,17 +30,5 @@ struct Compare : private Base { } }; -struct LessOfComparator { - explicit LessOfComparator(const Comparator* c = BytewiseComparator()) - : cmp(c) {} - - bool operator()(const std::string& a, const std::string& b) const { - return cmp->Compare(Slice(a), Slice(b)) < 0; - } - - const Comparator* cmp; -}; - -typedef std::map KVMap; } } diff --git a/src.mk b/src.mk index c975b7e6b..7b3f15b19 100644 --- a/src.mk +++ b/src.mk @@ -46,6 +46,9 @@ LIB_SOURCES = \ db/write_batch_base.cc \ db/write_controller.cc \ db/write_thread.cc \ + memtable/hash_cuckoo_rep.cc \ + memtable/hash_linklist_rep.cc \ + memtable/hash_skiplist_rep.cc \ port/stack_trace.cc \ port/port_posix.cc \ table/adaptive_table_factory.cc \ @@ -96,9 +99,6 @@ LIB_SOURCES = \ util/file_reader_writer.cc \ util/filter_policy.cc \ util/hash.cc \ - util/hash_cuckoo_rep.cc \ - util/hash_linklist_rep.cc \ - util/hash_skiplist_rep.cc \ util/histogram.cc \ util/instrumented_mutex.cc \ util/iostats_context.cc \ diff --git a/table/meta_blocks.h b/table/meta_blocks.h index 3dddc4427..085ae308e 100644 --- a/table/meta_blocks.h +++ b/table/meta_blocks.h @@ -11,12 +11,12 @@ #include "db/builder.h" #include "db/table_properties_collector.h" +#include "util/kv_map.h" #include "rocksdb/comparator.h" #include "rocksdb/options.h" #include "rocksdb/slice.h" #include "table/block_builder.h" #include "table/format.h" -#include "util/stl_wrappers.h" namespace rocksdb { diff --git a/table/mock_table.h b/table/mock_table.h index 8f6e53321..c13636af1 100644 --- a/table/mock_table.h +++ b/table/mock_table.h @@ -14,6 +14,7 @@ #include #include +#include "util/kv_map.h" #include "port/port.h" #include "rocksdb/comparator.h" #include "rocksdb/table.h" @@ -21,7 +22,6 @@ #include "table/table_builder.h" #include "table/table_reader.h" #include "util/mutexlock.h" -#include "util/stl_wrappers.h" #include "util/testharness.h" #include "util/testutil.h" diff --git a/table/table_test.cc b/table/table_test.cc index 7d93d067e..58607bbb2 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -21,6 +21,7 @@ #include "db/memtable.h" #include "db/write_batch_internal.h" #include "db/writebuffer.h" +#include "memtable/stl_wrappers.h" #include "rocksdb/cache.h" #include "rocksdb/db.h" #include "rocksdb/env.h" @@ -43,7 +44,6 @@ #include "util/compression.h" #include "util/random.h" #include "util/statistics.h" -#include "util/stl_wrappers.h" #include "util/string_util.h" #include "util/testharness.h" #include "util/testutil.h" diff --git a/util/kv_map.h b/util/kv_map.h new file mode 100644 index 000000000..486db1918 --- /dev/null +++ b/util/kv_map.h @@ -0,0 +1,31 @@ +// Copyright (c) 2013, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +#pragma once + +#include +#include + +#include "rocksdb/comparator.h" +#include "rocksdb/slice.h" +#include "util/coding.h" +#include "util/murmurhash.h" + +namespace rocksdb { +namespace stl_wrappers { + +struct LessOfComparator { + explicit LessOfComparator(const Comparator* c = BytewiseComparator()) + : cmp(c) {} + + bool operator()(const std::string& a, const std::string& b) const { + return cmp->Compare(Slice(a), Slice(b)) < 0; + } + + const Comparator* cmp; +}; + +typedef std::map KVMap; +} +} diff --git a/util/vectorrep.cc b/util/vectorrep.cc index 017f89f7c..324439a1d 100644 --- a/util/vectorrep.cc +++ b/util/vectorrep.cc @@ -14,9 +14,9 @@ #include "util/arena.h" #include "db/memtable.h" +#include "memtable/stl_wrappers.h" #include "port/port.h" #include "util/mutexlock.h" -#include "util/stl_wrappers.h" namespace rocksdb { namespace {