From 374c37da5b2db2c34f95f8c1539c83f69e4f2987 Mon Sep 17 00:00:00 2001 From: Chang Su Date: Mon, 23 Jul 2018 15:42:15 -0700 Subject: [PATCH] move static msgs out of Status class (#4144) Summary: The member msgs of class Status contains all types of status messages. When users dump a Status object, msgs will confuse users. So move it out of class Status by making it as file-local static variable. Closes #3831 . Pull Request resolved: https://github.com/facebook/rocksdb/pull/4144 Differential Revision: D8941419 Pulled By: sagar0 fbshipit-source-id: 56b0510258465ff26db15aa6b04e01532e053e3d --- CMakeLists.txt | 1 - TARGETS | 1 - include/rocksdb/status.h | 2 -- src.mk | 1 - util/status.cc | 12 ++++++++++++ util/status_message.cc | 22 ---------------------- 6 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 util/status_message.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index a3540088d..d46f6bd97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -596,7 +596,6 @@ set(SOURCES util/slice.cc util/sst_file_manager_impl.cc util/status.cc - util/status_message.cc util/string_util.cc util/sync_point.cc util/sync_point_impl.cc diff --git a/TARGETS b/TARGETS index 308690c0b..8f2c27226 100644 --- a/TARGETS +++ b/TARGETS @@ -218,7 +218,6 @@ cpp_library( "util/slice.cc", "util/sst_file_manager_impl.cc", "util/status.cc", - "util/status_message.cc", "util/string_util.cc", "util/sync_point.cc", "util/sync_point_impl.cc", diff --git a/include/rocksdb/status.h b/include/rocksdb/status.h index ea0fb467a..db41c3efd 100644 --- a/include/rocksdb/status.h +++ b/include/rocksdb/status.h @@ -282,8 +282,6 @@ class Status { Severity sev_; const char* state_; - static const char* msgs[static_cast(kMaxSubCode)]; - explicit Status(Code _code, SubCode _subcode = kNone) : code_(_code), subcode_(_subcode), sev_(kNoError), state_(nullptr) {} diff --git a/src.mk b/src.mk index e555c7df8..a3283ff1c 100644 --- a/src.mk +++ b/src.mk @@ -147,7 +147,6 @@ LIB_SOURCES = \ util/slice.cc \ util/sst_file_manager_impl.cc \ util/status.cc \ - util/status_message.cc \ util/string_util.cc \ util/sync_point.cc \ util/sync_point_impl.cc \ diff --git a/util/status.cc b/util/status.cc index c58e21f26..5b3dcf8e9 100644 --- a/util/status.cc +++ b/util/status.cc @@ -32,6 +32,18 @@ const char* Status::CopyState(const char* state) { #endif } +static const char* msgs[static_cast(Status::kMaxSubCode)] = { + "", // kNone + "Timeout Acquiring Mutex", // kMutexTimeout + "Timeout waiting to lock key", // kLockTimeout + "Failed to acquire lock due to max_num_locks limit", // kLockLimit + "No space left on device", // kNoSpace + "Deadlock", // kDeadlock + "Stale file handle", // kStaleFile + "Memory limit reached", // kMemoryLimit + "Space limit reached" // kSpaceLimit +}; + Status::Status(Code _code, SubCode _subcode, const Slice& msg, const Slice& msg2) : code_(_code), subcode_(_subcode), sev_(kNoError) { diff --git a/util/status_message.cc b/util/status_message.cc deleted file mode 100644 index 7150e817e..000000000 --- a/util/status_message.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. -// This source code is licensed under both the GPLv2 (found in the -// COPYING file in the root directory) and Apache 2.0 License -// (found in the LICENSE.Apache file in the root directory). - -#include "rocksdb/status.h" - -namespace rocksdb { - -const char* Status::msgs[] = { - "", // kNone - "Timeout Acquiring Mutex", // kMutexTimeout - "Timeout waiting to lock key", // kLockTimeout - "Failed to acquire lock due to max_num_locks limit", // kLockLimit - "No space left on device", // kNoSpace - "Deadlock", // kDeadlock - "Stale file handle", // kStaleFile - "Memory limit reached", // kMemoryLimit - "Space limit reached" // kSpaceLimit -}; - -} // namespace rocksdb