1 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 
6 #include <mutex>
7 
8 #include "db/column_family.h"
9 #include "monitoring/thread_status_updater.h"
10 
11 namespace ROCKSDB_NAMESPACE {
12 
13 #ifndef NDEBUG
14 #ifdef ROCKSDB_USING_THREAD_STATUS
TEST_VerifyColumnFamilyInfoMap(const std::vector<ColumnFamilyHandle * > & handles,bool check_exist)15 void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
16     const std::vector<ColumnFamilyHandle*>& handles, bool check_exist) {
17   std::unique_lock<std::mutex> lock(thread_list_mutex_);
18   if (check_exist) {
19     assert(cf_info_map_.size() == handles.size());
20   }
21   for (auto* handle : handles) {
22     auto* cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(handle)->cfd();
23     auto iter __attribute__((__unused__)) = cf_info_map_.find(cfd);
24     if (check_exist) {
25       assert(iter != cf_info_map_.end());
26       assert(iter->second.cf_name == cfd->GetName());
27     } else {
28       assert(iter == cf_info_map_.end());
29     }
30   }
31 }
32 
33 #else
34 
35 void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
36     const std::vector<ColumnFamilyHandle*>& /*handles*/, bool /*check_exist*/) {
37 }
38 
39 #endif  // ROCKSDB_USING_THREAD_STATUS
40 #endif  // !NDEBUG
41 
42 }  // namespace ROCKSDB_NAMESPACE
43