YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/docdb/docdb-internal.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_DOCDB_DOCDB_INTERNAL_H_
15
#define YB_DOCDB_DOCDB_INTERNAL_H_
16
17
#include <assert.h>
18
#include <inttypes.h>
19
#include <stddef.h>
20
#include <stdint.h>
21
#include <stdio.h>
22
#include <string.h>
23
24
#include <iosfwd>
25
#include <limits>
26
#include <string>
27
28
#include "yb/common/doc_hybrid_time.h"
29
30
#include "yb/docdb/docdb_types.h"
31
32
#include "yb/gutil/endian.h"
33
#include "yb/gutil/integral_types.h"
34
#include "yb/gutil/strings/substitute.h" // For Substitute
35
36
#include "yb/util/status_fwd.h"
37
38
// This file should only be included in .cc files of the docdb subsystem. Defines some macros for
39
// debugging DocDB functionality.
40
41
// Enable this during debugging only. This enables very verbose logging. Should always be undefined
42
// when code is checked in.
43
#undef DOCDB_DEBUG
44
45
0
constexpr bool IsDocDbDebug() {
46
0
#ifdef DOCDB_DEBUG
47
0
  return true;
48
0
#else
49
0
  return false;
50
0
#endif
51
0
}
52
53
#define DOCDB_DEBUG_LOG(...) \
54
224M
  do { \
55
224M
    if (IsDocDbDebug()) { \
56
0
      LOG(INFO) << "DocDB DEBUG [" << __func__  << "]: " \
57
0
                << strings::Substitute(__VA_ARGS__); \
58
0
    } \
59
224M
  } while (false)
60
61
#ifdef DOCDB_DEBUG
62
#define DOCDB_DEBUG_SCOPE_LOG(msg, on_scope_bounds) \
63
    ScopeLogger sl(std::string("DocDB DEBUG [") + __func__ + "] " + (msg), on_scope_bounds)
64
#else
65
// Still compile the debug logging code to make sure it does not get broken silently.
66
#define DOCDB_DEBUG_SCOPE_LOG(msg, on_scope_bounds) \
67
1.38G
    if (false) \
68
1.38G
      
ScopeLogger sl(std::string("DocDB DEBUG [") + __func__ + "] " + (msg), (on_scope_bounds))0
69
#endif
70
71
namespace yb {
72
namespace docdb {
73
74
// Infer the key type from the given slice, given whether this is regular or intents RocksDB.
75
KeyType GetKeyType(const Slice& slice, StorageDbType db_type);
76
77
} // namespace docdb
78
} // namespace yb
79
80
#endif  // YB_DOCDB_DOCDB_INTERNAL_H_