Coverage Report

Created: 2024-07-27 06:53

/src/rocksdb/table/block_based/cachable_entry.h
Line
Count
Source (jump to first uncovered line)
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
// Copyright (c) 2012 The LevelDB Authors. All rights reserved.
7
// Use of this source code is governed by a BSD-style license that can be
8
// found in the LICENSE file. See the AUTHORS file for names of contributors.
9
10
#pragma once
11
12
#include <cassert>
13
#include <type_traits>
14
15
#include "port/likely.h"
16
#include "rocksdb/advanced_cache.h"
17
#include "rocksdb/cleanable.h"
18
19
namespace ROCKSDB_NAMESPACE {
20
21
// CachableEntry is a handle to an object that may or may not be in the block
22
// cache. It is used in a variety of ways:
23
//
24
// 1) It may refer to an object in the block cache. In this case, cache_ and
25
// cache_handle_ are not nullptr, and the cache handle has to be released when
26
// the CachableEntry is destroyed (the lifecycle of the cached object, on the
27
// other hand, is managed by the cache itself).
28
// 2) It may uniquely own the (non-cached) object it refers to (examples include
29
// a block read directly from file, or uncompressed blocks when there is a
30
// compressed block cache but no uncompressed block cache). In such cases, the
31
// object has to be destroyed when the CachableEntry is destroyed.
32
// 3) It may point to an object (cached or not) without owning it. In this case,
33
// no action is needed when the CachableEntry is destroyed.
34
// 4) Sometimes, management of a cached or owned object (see #1 and #2 above)
35
// is transferred to some other object. This is used for instance with iterators
36
// (where cleanup is performed using a chain of cleanup functions,
37
// see Cleanable).
38
//
39
// Because of #1 and #2 above, copying a CachableEntry is not safe (and thus not
40
// allowed); hence, this is a move-only type, where a move transfers the
41
// management responsibilities, and leaves the source object in an empty state.
42
43
template <class T>
44
class CachableEntry {
45
 public:
46
99.1k
  CachableEntry() = default;
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kData>::CachableEntry()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::CachableEntry()
rocksdb::CachableEntry<rocksdb::Block>::CachableEntry()
Line
Count
Source
46
99.1k
  CachableEntry() = default;
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::CachableEntry()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::CachableEntry()
47
48
  CachableEntry(T* value, Cache* cache, Cache::Handle* cache_handle,
49
                bool own_value)
50
      : value_(value),
51
        cache_(cache),
52
        cache_handle_(cache_handle),
53
        own_value_(own_value) {
54
    assert(value_ != nullptr ||
55
           (cache_ == nullptr && cache_handle_ == nullptr && !own_value_));
56
    assert(!!cache_ == !!cache_handle_);
57
    assert(!cache_handle_ || !own_value_);
58
  }
59
60
  CachableEntry(const CachableEntry&) = delete;
61
  CachableEntry& operator=(const CachableEntry&) = delete;
62
63
  CachableEntry(CachableEntry&& rhs) noexcept
64
      : value_(rhs.value_),
65
        cache_(rhs.cache_),
66
        cache_handle_(rhs.cache_handle_),
67
30.6k
        own_value_(rhs.own_value_) {
68
30.6k
    assert(value_ != nullptr ||
69
30.6k
           (cache_ == nullptr && cache_handle_ == nullptr && !own_value_));
70
30.6k
    assert(!!cache_ == !!cache_handle_);
71
30.6k
    assert(!cache_handle_ || !own_value_);
72
73
30.6k
    rhs.ResetFields();
74
30.6k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::CachableEntry(rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>&&)
rocksdb::CachableEntry<rocksdb::Block>::CachableEntry(rocksdb::CachableEntry<rocksdb::Block>&&)
Line
Count
Source
67
30.6k
        own_value_(rhs.own_value_) {
68
30.6k
    assert(value_ != nullptr ||
69
30.6k
           (cache_ == nullptr && cache_handle_ == nullptr && !own_value_));
70
30.6k
    assert(!!cache_ == !!cache_handle_);
71
30.6k
    assert(!cache_handle_ || !own_value_);
72
73
30.6k
    rhs.ResetFields();
74
30.6k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::CachableEntry(rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>&&)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::CachableEntry(rocksdb::CachableEntry<rocksdb::UncompressionDict>&&)
75
76
0
  CachableEntry& operator=(CachableEntry&& rhs) noexcept {
77
0
    if (UNLIKELY(this == &rhs)) {
78
0
      return *this;
79
0
    }
80
81
0
    ReleaseResource(/*erase_if_last_ref=*/false);
82
83
0
    value_ = rhs.value_;
84
0
    cache_ = rhs.cache_;
85
0
    cache_handle_ = rhs.cache_handle_;
86
0
    own_value_ = rhs.own_value_;
87
88
0
    assert(value_ != nullptr ||
89
0
           (cache_ == nullptr && cache_handle_ == nullptr && !own_value_));
90
0
    assert(!!cache_ == !!cache_handle_);
91
0
    assert(!cache_handle_ || !own_value_);
92
93
0
    rhs.ResetFields();
94
95
0
    return *this;
96
0
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::operator=(rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>&&)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block>::operator=(rocksdb::CachableEntry<rocksdb::Block>&&)
97
98
130k
  ~CachableEntry() { ReleaseResource(/*erase_if_last_ref=*/false); }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kData>::~CachableEntry()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::~CachableEntry()
rocksdb::CachableEntry<rocksdb::Block>::~CachableEntry()
Line
Count
Source
98
130k
  ~CachableEntry() { ReleaseResource(/*erase_if_last_ref=*/false); }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::~CachableEntry()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::~CachableEntry()
99
100
37.8k
  bool IsEmpty() const {
101
37.8k
    return value_ == nullptr && cache_ == nullptr && cache_handle_ == nullptr &&
102
37.8k
           !own_value_;
103
37.8k
  }
rocksdb::CachableEntry<rocksdb::Block>::IsEmpty() const
Line
Count
Source
100
37.8k
  bool IsEmpty() const {
101
37.8k
    return value_ == nullptr && cache_ == nullptr && cache_handle_ == nullptr &&
102
37.8k
           !own_value_;
103
37.8k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::IsEmpty() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::IsEmpty() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::IsEmpty() const
104
105
61.2k
  bool IsCached() const {
106
61.2k
    assert(!!cache_ == !!cache_handle_);
107
108
61.2k
    return cache_handle_ != nullptr;
109
61.2k
  }
rocksdb::CachableEntry<rocksdb::Block>::IsCached() const
Line
Count
Source
105
61.2k
  bool IsCached() const {
106
61.2k
    assert(!!cache_ == !!cache_handle_);
107
108
61.2k
    return cache_handle_ != nullptr;
109
61.2k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::IsCached() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::IsCached() const
110
111
204k
  T* GetValue() const { return value_; }
rocksdb::CachableEntry<rocksdb::Block>::GetValue() const
Line
Count
Source
111
112k
  T* GetValue() const { return value_; }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::GetValue() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kIndex>::GetValue() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::GetValue() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kRangeDeletion>::GetValue() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kMetaIndex>::GetValue() const
rocksdb::CachableEntry<rocksdb::Block_kData>::GetValue() const
Line
Count
Source
111
91.8k
  T* GetValue() const { return value_; }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::GetValue() const
112
  Cache* GetCache() const { return cache_; }
113
71.1k
  Cache::Handle* GetCacheHandle() const { return cache_handle_; }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::GetCacheHandle() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::GetCacheHandle() const
rocksdb::CachableEntry<rocksdb::Block_kData>::GetCacheHandle() const
Line
Count
Source
113
43.4k
  Cache::Handle* GetCacheHandle() const { return cache_handle_; }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kIndex>::GetCacheHandle() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::GetCacheHandle() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kRangeDeletion>::GetCacheHandle() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kMetaIndex>::GetCacheHandle() const
rocksdb::CachableEntry<rocksdb::Block>::GetCacheHandle() const
Line
Count
Source
113
27.7k
  Cache::Handle* GetCacheHandle() const { return cache_handle_; }
114
0
  bool GetOwnValue() const { return own_value_; }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block>::GetOwnValue() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::GetOwnValue() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::GetOwnValue() const
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::GetOwnValue() const
115
116
99.1k
  void Reset() {
117
99.1k
    ReleaseResource(/*erase_if_last_ref=*/false);
118
99.1k
    ResetFields();
119
99.1k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::Reset()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::Reset()
rocksdb::CachableEntry<rocksdb::Block_kIndex>::Reset()
Line
Count
Source
116
30.6k
  void Reset() {
117
30.6k
    ReleaseResource(/*erase_if_last_ref=*/false);
118
30.6k
    ResetFields();
119
30.6k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::Reset()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kRangeDeletion>::Reset()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kMetaIndex>::Reset()
rocksdb::CachableEntry<rocksdb::Block_kData>::Reset()
Line
Count
Source
116
30.6k
  void Reset() {
117
30.6k
    ReleaseResource(/*erase_if_last_ref=*/false);
118
30.6k
    ResetFields();
119
30.6k
  }
rocksdb::CachableEntry<rocksdb::Block>::Reset()
Line
Count
Source
116
37.8k
  void Reset() {
117
37.8k
    ReleaseResource(/*erase_if_last_ref=*/false);
118
37.8k
    ResetFields();
119
37.8k
  }
120
121
0
  void ResetEraseIfLastRef() {
122
0
    ReleaseResource(/*erase_if_last_ref=*/true);
123
0
    ResetFields();
124
0
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block>::ResetEraseIfLastRef()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::ResetEraseIfLastRef()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::ResetEraseIfLastRef()
125
126
68.4k
  void TransferTo(Cleanable* cleanable) {
127
68.4k
    if (cleanable) {
128
68.4k
      if (cache_handle_ != nullptr) {
129
27.7k
        assert(cache_ != nullptr);
130
27.7k
        cleanable->RegisterCleanup(&ReleaseCacheHandle, cache_, cache_handle_);
131
40.7k
      } else if (own_value_) {
132
2.90k
        cleanable->RegisterCleanup(&DeleteValue, value_, nullptr);
133
2.90k
      }
134
68.4k
    }
135
136
68.4k
    ResetFields();
137
68.4k
  }
138
139
33.5k
  void SetOwnedValue(std::unique_ptr<T>&& value) {
140
33.5k
    assert(value.get() != nullptr);
141
142
33.5k
    if (UNLIKELY(value_ == value.get() && own_value_)) {
143
0
      assert(cache_ == nullptr && cache_handle_ == nullptr);
144
0
      return;
145
0
    }
146
147
33.5k
    Reset();
148
149
33.5k
    value_ = value.release();
150
33.5k
    own_value_ = true;
151
33.5k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::SetOwnedValue(std::__1::unique_ptr<rocksdb::ParsedFullFilterBlock, std::__1::default_delete<rocksdb::ParsedFullFilterBlock> >&&)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::SetOwnedValue(std::__1::unique_ptr<rocksdb::UncompressionDict, std::__1::default_delete<rocksdb::UncompressionDict> >&&)
rocksdb::CachableEntry<rocksdb::Block_kIndex>::SetOwnedValue(std::__1::unique_ptr<rocksdb::Block_kIndex, std::__1::default_delete<rocksdb::Block_kIndex> >&&)
Line
Count
Source
139
30.6k
  void SetOwnedValue(std::unique_ptr<T>&& value) {
140
30.6k
    assert(value.get() != nullptr);
141
142
30.6k
    if (UNLIKELY(value_ == value.get() && own_value_)) {
143
0
      assert(cache_ == nullptr && cache_handle_ == nullptr);
144
0
      return;
145
0
    }
146
147
30.6k
    Reset();
148
149
30.6k
    value_ = value.release();
150
30.6k
    own_value_ = true;
151
30.6k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::SetOwnedValue(std::__1::unique_ptr<rocksdb::Block_kFilterPartitionIndex, std::__1::default_delete<rocksdb::Block_kFilterPartitionIndex> >&&)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kRangeDeletion>::SetOwnedValue(std::__1::unique_ptr<rocksdb::Block_kRangeDeletion, std::__1::default_delete<rocksdb::Block_kRangeDeletion> >&&)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kMetaIndex>::SetOwnedValue(std::__1::unique_ptr<rocksdb::Block_kMetaIndex, std::__1::default_delete<rocksdb::Block_kMetaIndex> >&&)
rocksdb::CachableEntry<rocksdb::Block_kData>::SetOwnedValue(std::__1::unique_ptr<rocksdb::Block_kData, std::__1::default_delete<rocksdb::Block_kData> >&&)
Line
Count
Source
139
2.90k
  void SetOwnedValue(std::unique_ptr<T>&& value) {
140
2.90k
    assert(value.get() != nullptr);
141
142
2.90k
    if (UNLIKELY(value_ == value.get() && own_value_)) {
143
0
      assert(cache_ == nullptr && cache_handle_ == nullptr);
144
0
      return;
145
0
    }
146
147
2.90k
    Reset();
148
149
2.90k
    value_ = value.release();
150
2.90k
    own_value_ = true;
151
2.90k
  }
152
153
37.8k
  void SetUnownedValue(T* value) {
154
37.8k
    assert(value != nullptr);
155
156
37.8k
    if (UNLIKELY(value_ == value && cache_ == nullptr &&
157
37.8k
                 cache_handle_ == nullptr && !own_value_)) {
158
0
      return;
159
0
    }
160
161
37.8k
    Reset();
162
163
37.8k
    value_ = value;
164
37.8k
    assert(!own_value_);
165
37.8k
  }
rocksdb::CachableEntry<rocksdb::Block>::SetUnownedValue(rocksdb::Block*)
Line
Count
Source
153
37.8k
  void SetUnownedValue(T* value) {
154
37.8k
    assert(value != nullptr);
155
156
37.8k
    if (UNLIKELY(value_ == value && cache_ == nullptr &&
157
37.8k
                 cache_handle_ == nullptr && !own_value_)) {
158
0
      return;
159
0
    }
160
161
37.8k
    Reset();
162
163
37.8k
    value_ = value;
164
37.8k
    assert(!own_value_);
165
37.8k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::SetUnownedValue(rocksdb::ParsedFullFilterBlock*)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::SetUnownedValue(rocksdb::UncompressionDict*)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::SetUnownedValue(rocksdb::Block_kFilterPartitionIndex*)
166
167
27.7k
  void SetCachedValue(T* value, Cache* cache, Cache::Handle* cache_handle) {
168
27.7k
    assert(cache != nullptr);
169
27.7k
    assert(cache_handle != nullptr);
170
171
27.7k
    if (UNLIKELY(value_ == value && cache_ == cache &&
172
27.7k
                 cache_handle_ == cache_handle && !own_value_)) {
173
0
      return;
174
0
    }
175
176
27.7k
    Reset();
177
178
27.7k
    value_ = value;
179
27.7k
    cache_ = cache;
180
27.7k
    cache_handle_ = cache_handle;
181
27.7k
    assert(!own_value_);
182
27.7k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::SetCachedValue(rocksdb::ParsedFullFilterBlock*, rocksdb::Cache*, rocksdb::Cache::Handle*)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::SetCachedValue(rocksdb::UncompressionDict*, rocksdb::Cache*, rocksdb::Cache::Handle*)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kIndex>::SetCachedValue(rocksdb::Block_kIndex*, rocksdb::Cache*, rocksdb::Cache::Handle*)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::SetCachedValue(rocksdb::Block_kFilterPartitionIndex*, rocksdb::Cache*, rocksdb::Cache::Handle*)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kRangeDeletion>::SetCachedValue(rocksdb::Block_kRangeDeletion*, rocksdb::Cache*, rocksdb::Cache::Handle*)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kMetaIndex>::SetCachedValue(rocksdb::Block_kMetaIndex*, rocksdb::Cache*, rocksdb::Cache::Handle*)
rocksdb::CachableEntry<rocksdb::Block_kData>::SetCachedValue(rocksdb::Block_kData*, rocksdb::Cache*, rocksdb::Cache::Handle*)
Line
Count
Source
167
27.7k
  void SetCachedValue(T* value, Cache* cache, Cache::Handle* cache_handle) {
168
27.7k
    assert(cache != nullptr);
169
27.7k
    assert(cache_handle != nullptr);
170
171
27.7k
    if (UNLIKELY(value_ == value && cache_ == cache &&
172
27.7k
                 cache_handle_ == cache_handle && !own_value_)) {
173
0
      return;
174
0
    }
175
176
27.7k
    Reset();
177
178
27.7k
    value_ = value;
179
27.7k
    cache_ = cache;
180
27.7k
    cache_handle_ = cache_handle;
181
27.7k
    assert(!own_value_);
182
27.7k
  }
183
184
  // Since this class is essentially an elaborate pointer, it's sometimes
185
  // useful to be able to upcast or downcast the base type of the pointer,
186
  // especially when interacting with typed_cache.h.
187
  template <class TWrapper>
188
  std::enable_if_t<sizeof(TWrapper) == sizeof(T) &&
189
                       (std::is_base_of_v<TWrapper, T> ||
190
                        std::is_base_of_v<T, TWrapper>),
191
                   /* Actual return type */
192
                   CachableEntry<TWrapper>&>
193
61.2k
  As() {
194
61.2k
    CachableEntry<TWrapper>* result_ptr =
195
61.2k
        reinterpret_cast<CachableEntry<TWrapper>*>(this);
196
    // Ensure no weirdness in template instantiations
197
61.2k
    assert(static_cast<void*>(&this->value_) ==
198
61.2k
           static_cast<void*>(&result_ptr->value_));
199
61.2k
    assert(&this->cache_handle_ == &result_ptr->cache_handle_);
200
    // This function depends on no arithmetic involved in the pointer
201
    // conversion, which is not statically checkable.
202
61.2k
    assert(static_cast<void*>(this->value_) ==
203
61.2k
           static_cast<void*>(result_ptr->value_));
204
61.2k
    return *result_ptr;
205
61.2k
  }
Unexecuted instantiation: _ZN7rocksdb13CachableEntryINS_11Block_kDataEE2AsIS1_EENSt3__19enable_ifIXaaeqstT_Lm88Eoosr3stdE12is_base_of_vIS6_S1_Esr3stdE12is_base_of_vIS1_S6_EERNS0_IS6_EEE4typeEv
Unexecuted instantiation: _ZN7rocksdb13CachableEntryINS_11Block_kDataEE2AsINS_5BlockEEENSt3__19enable_ifIXaaeqstT_Lm88Eoosr3stdE12is_base_of_vIS7_S1_Esr3stdE12is_base_of_vIS1_S7_EERNS0_IS7_EEE4typeEv
_ZN7rocksdb13CachableEntryINS_5BlockEE2AsINS_11Block_kDataEEENSt3__19enable_ifIXaaeqstT_Lm88Eoosr3stdE12is_base_of_vIS7_S1_Esr3stdE12is_base_of_vIS1_S7_EERNS0_IS7_EEE4typeEv
Line
Count
Source
193
30.6k
  As() {
194
30.6k
    CachableEntry<TWrapper>* result_ptr =
195
30.6k
        reinterpret_cast<CachableEntry<TWrapper>*>(this);
196
    // Ensure no weirdness in template instantiations
197
30.6k
    assert(static_cast<void*>(&this->value_) ==
198
30.6k
           static_cast<void*>(&result_ptr->value_));
199
30.6k
    assert(&this->cache_handle_ == &result_ptr->cache_handle_);
200
    // This function depends on no arithmetic involved in the pointer
201
    // conversion, which is not statically checkable.
202
30.6k
    assert(static_cast<void*>(this->value_) ==
203
30.6k
           static_cast<void*>(result_ptr->value_));
204
30.6k
    return *result_ptr;
205
30.6k
  }
_ZN7rocksdb13CachableEntryINS_5BlockEE2AsINS_12Block_kIndexEEENSt3__19enable_ifIXaaeqstT_Lm88Eoosr3stdE12is_base_of_vIS7_S1_Esr3stdE12is_base_of_vIS1_S7_EERNS0_IS7_EEE4typeEv
Line
Count
Source
193
30.6k
  As() {
194
30.6k
    CachableEntry<TWrapper>* result_ptr =
195
30.6k
        reinterpret_cast<CachableEntry<TWrapper>*>(this);
196
    // Ensure no weirdness in template instantiations
197
30.6k
    assert(static_cast<void*>(&this->value_) ==
198
30.6k
           static_cast<void*>(&result_ptr->value_));
199
30.6k
    assert(&this->cache_handle_ == &result_ptr->cache_handle_);
200
    // This function depends on no arithmetic involved in the pointer
201
    // conversion, which is not statically checkable.
202
30.6k
    assert(static_cast<void*>(this->value_) ==
203
30.6k
           static_cast<void*>(result_ptr->value_));
204
30.6k
    return *result_ptr;
205
30.6k
  }
Unexecuted instantiation: _ZN7rocksdb13CachableEntryINS_5BlockEE2AsIS1_EENSt3__19enable_ifIXaaeqstT_Lm88Eoosr3stdE12is_base_of_vIS6_S1_Esr3stdE12is_base_of_vIS1_S6_EERNS0_IS6_EEE4typeEv
206
207
 private:
208
229k
  void ReleaseResource(bool erase_if_last_ref) noexcept {
209
229k
    if (LIKELY(cache_handle_ != nullptr)) {
210
0
      assert(cache_ != nullptr);
211
0
      cache_->Release(cache_handle_, erase_if_last_ref);
212
229k
    } else if (own_value_) {
213
30.8k
      delete value_;
214
30.8k
    }
215
229k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::ReleaseResource(bool)
rocksdb::CachableEntry<rocksdb::Block_kData>::ReleaseResource(bool)
Line
Count
Source
208
30.6k
  void ReleaseResource(bool erase_if_last_ref) noexcept {
209
30.6k
    if (LIKELY(cache_handle_ != nullptr)) {
210
0
      assert(cache_ != nullptr);
211
0
      cache_->Release(cache_handle_, erase_if_last_ref);
212
30.6k
    } else if (own_value_) {
213
0
      delete value_;
214
0
    }
215
30.6k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::ReleaseResource(bool)
rocksdb::CachableEntry<rocksdb::Block_kIndex>::ReleaseResource(bool)
Line
Count
Source
208
30.6k
  void ReleaseResource(bool erase_if_last_ref) noexcept {
209
30.6k
    if (LIKELY(cache_handle_ != nullptr)) {
210
0
      assert(cache_ != nullptr);
211
0
      cache_->Release(cache_handle_, erase_if_last_ref);
212
30.6k
    } else if (own_value_) {
213
0
      delete value_;
214
0
    }
215
30.6k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::ReleaseResource(bool)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kRangeDeletion>::ReleaseResource(bool)
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kMetaIndex>::ReleaseResource(bool)
rocksdb::CachableEntry<rocksdb::Block>::ReleaseResource(bool)
Line
Count
Source
208
167k
  void ReleaseResource(bool erase_if_last_ref) noexcept {
209
167k
    if (LIKELY(cache_handle_ != nullptr)) {
210
0
      assert(cache_ != nullptr);
211
0
      cache_->Release(cache_handle_, erase_if_last_ref);
212
167k
    } else if (own_value_) {
213
30.8k
      delete value_;
214
30.8k
    }
215
167k
  }
216
217
198k
  void ResetFields() noexcept {
218
198k
    value_ = nullptr;
219
198k
    cache_ = nullptr;
220
198k
    cache_handle_ = nullptr;
221
198k
    own_value_ = false;
222
198k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::UncompressionDict>::ResetFields()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::ParsedFullFilterBlock>::ResetFields()
rocksdb::CachableEntry<rocksdb::Block_kIndex>::ResetFields()
Line
Count
Source
217
30.6k
  void ResetFields() noexcept {
218
30.6k
    value_ = nullptr;
219
30.6k
    cache_ = nullptr;
220
30.6k
    cache_handle_ = nullptr;
221
30.6k
    own_value_ = false;
222
30.6k
  }
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kFilterPartitionIndex>::ResetFields()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kRangeDeletion>::ResetFields()
Unexecuted instantiation: rocksdb::CachableEntry<rocksdb::Block_kMetaIndex>::ResetFields()
rocksdb::CachableEntry<rocksdb::Block_kData>::ResetFields()
Line
Count
Source
217
30.6k
  void ResetFields() noexcept {
218
30.6k
    value_ = nullptr;
219
30.6k
    cache_ = nullptr;
220
30.6k
    cache_handle_ = nullptr;
221
30.6k
    own_value_ = false;
222
30.6k
  }
rocksdb::CachableEntry<rocksdb::Block>::ResetFields()
Line
Count
Source
217
137k
  void ResetFields() noexcept {
218
137k
    value_ = nullptr;
219
137k
    cache_ = nullptr;
220
137k
    cache_handle_ = nullptr;
221
137k
    own_value_ = false;
222
137k
  }
223
224
27.7k
  static void ReleaseCacheHandle(void* arg1, void* arg2) {
225
27.7k
    Cache* const cache = static_cast<Cache*>(arg1);
226
27.7k
    assert(cache);
227
228
27.7k
    Cache::Handle* const cache_handle = static_cast<Cache::Handle*>(arg2);
229
27.7k
    assert(cache_handle);
230
231
27.7k
    cache->Release(cache_handle);
232
27.7k
  }
233
234
2.90k
  static void DeleteValue(void* arg1, void* /* arg2 */) {
235
2.90k
    delete static_cast<T*>(arg1);
236
2.90k
  }
237
238
 private:
239
  // Have to be your own best friend
240
  template <class TT>
241
  friend class CachableEntry;
242
243
  T* value_ = nullptr;
244
  Cache* cache_ = nullptr;
245
  Cache::Handle* cache_handle_ = nullptr;
246
  bool own_value_ = false;
247
};
248
249
}  // namespace ROCKSDB_NAMESPACE