Skip to content

Commit 5d46fb1

Browse files
bladepanfacebook-github-bot
authored andcommitted
fix build error of using my_rocksdb namespace
Summary: - remove use of my_rocksdb namespace introduced in rdb_sst_partitioner_factory.h. - other minor changes Squash with: D41586846 Reviewed By: hermanlee Differential Revision: D43054726 fbshipit-source-id: f8845e8
1 parent a97a3ff commit 5d46fb1

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

storage/rocksdb/rdb_sst_partitioner_factory.h

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class Rdb_index_boundary_sst_partitioner : public rocksdb::SstPartitioner {
6868
* if a partition is required for given index
6969
*/
7070
bool should_partition(const std::string &index_key,
71-
const my_rocksdb::Slice *previous_key,
72-
const my_rocksdb::Slice *current_key) {
71+
const rocksdb::Slice *previous_key,
72+
const rocksdb::Slice *current_key) const {
7373
// for reverse cf, indexKey is upper limit of index data,
7474
// for normal cf, indexKey is lower limit of index data.
7575
// we want indexKey itself get partitioned with other keys in the index.
@@ -82,9 +82,9 @@ class Rdb_index_boundary_sst_partitioner : public rocksdb::SstPartitioner {
8282
}
8383

8484
public:
85-
explicit Rdb_index_boundary_sst_partitioner(
86-
const std::set<Index_id> &index_ids,
87-
const rocksdb::Comparator *comparator, const bool is_reverse_cf)
85+
Rdb_index_boundary_sst_partitioner(const std::set<Index_id> &index_ids,
86+
const rocksdb::Comparator *comparator,
87+
const bool is_reverse_cf)
8888
: m_comparator(comparator), m_is_reverse_cf(is_reverse_cf) {
8989
assert(!index_ids.empty());
9090
for (auto index_id : index_ids) {
@@ -112,7 +112,7 @@ class Rdb_index_boundary_sst_partitioner : public rocksdb::SstPartitioner {
112112
m_max_index_key = get_index_key(max_index);
113113
}
114114

115-
virtual ~Rdb_index_boundary_sst_partitioner() override {}
115+
~Rdb_index_boundary_sst_partitioner() override {}
116116

117117
const char *Name() const override {
118118
return "Rdb_index_boundary_sst_partitioner";
@@ -127,7 +127,7 @@ class Rdb_index_boundary_sst_partitioner : public rocksdb::SstPartitioner {
127127
m_comparator->Compare(*request.current_user_key, m_min_index_key) < 0) {
128128
return rocksdb::PartitionerResult::kNotRequired;
129129
}
130-
for (auto &index_key_range : m_index_key_ranges) {
130+
for (const auto &index_key_range : m_index_key_ranges) {
131131
// partition sst file when the request keys cross index boundary
132132
if (should_partition(index_key_range.first, request.prev_user_key,
133133
request.current_user_key) ||
@@ -155,25 +155,18 @@ class Rdb_sst_partitioner_factory : public rocksdb::SstPartitionerFactory {
155155
const rocksdb::Comparator *m_comparator;
156156
const int m_num_levels;
157157
const bool m_is_reverse_cf;
158-
std::mutex m_index_ids_mutex;
158+
mutable std::mutex m_index_ids_mutex;
159159
std::set<Index_id> m_index_ids;
160160

161161
std::set<Index_id> get_index_ids() const {
162-
// this method is marked const so we can call it
163-
// in const CreatePartitioner method.
164-
// and it is a real const method as it does not change
165-
// the object's state. the const_cast here is needed
166-
// to get a non-const reference to mutex, which is needed
167-
// for lock_guard
168-
const std::lock_guard<std::mutex> lock(
169-
const_cast<Rdb_sst_partitioner_factory *>(this)->m_index_ids_mutex);
162+
const std::lock_guard<std::mutex> lock(m_index_ids_mutex);
170163
std::set<Index_id> result(m_index_ids);
171164
return result;
172165
};
173166

174167
public:
175-
explicit Rdb_sst_partitioner_factory(const rocksdb::Comparator *comparator,
176-
int num_levels, int is_reverse_cf)
168+
Rdb_sst_partitioner_factory(const rocksdb::Comparator *comparator,
169+
int num_levels, int is_reverse_cf)
177170
: m_comparator(comparator),
178171
m_num_levels(num_levels),
179172
m_is_reverse_cf(is_reverse_cf){};
@@ -309,7 +302,7 @@ class Rdb_bulk_load_index_registry {
309302
*/
310303
bool clear() {
311304
bool success = true;
312-
for (auto entry : m_partitioner_factories) {
305+
for (auto &entry : m_partitioner_factories) {
313306
bool removed = entry.second->remove_index(entry.first);
314307
if (!removed) {
315308
// unlikely
@@ -325,7 +318,7 @@ class Rdb_bulk_load_index_registry {
325318
* returns true when we have index registered in
326319
* sst partitioner factory
327320
*/
328-
bool index_registered_in_sst_partitioner() {
321+
bool index_registered_in_sst_partitioner() const {
329322
return !m_partitioner_factories.empty();
330323
}
331324

@@ -337,7 +330,7 @@ class Rdb_bulk_load_index_registry {
337330
rocksdb::TransactionDB *rdb,
338331
const rocksdb::CompactRangeOptions compact_range_options) {
339332
rocksdb::Status status;
340-
for (auto entry : m_cf_indexes) {
333+
for (auto &entry : m_cf_indexes) {
341334
auto cf = entry.first;
342335
const auto is_reverse_cf =
343336
Rdb_cf_manager::is_cf_name_reverse(cf->GetName().c_str());

0 commit comments

Comments
 (0)