mirror of https://github.com/facebook/rocksdb.git
Use std::make_unique when possible (#10578)
Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/10578 Test Plan: make check Reviewed By: ajkr Differential Revision: D39064748 Pulled By: riversand963 fbshipit-source-id: c7c135b7b713608edb14614846050ece6d4cc59d
This commit is contained in:
parent
e484b81eee
commit
7c0838e65e
|
@ -82,12 +82,6 @@ bool TruncatedRangeDelIterator::Valid() const {
|
|||
icmp_->Compare(iter_->parsed_start_key(), *largest_) < 0);
|
||||
}
|
||||
|
||||
void TruncatedRangeDelIterator::Next() { iter_->TopNext(); }
|
||||
|
||||
void TruncatedRangeDelIterator::Prev() { iter_->TopPrev(); }
|
||||
|
||||
void TruncatedRangeDelIterator::InternalNext() { iter_->Next(); }
|
||||
|
||||
// NOTE: target is a user key
|
||||
void TruncatedRangeDelIterator::Seek(const Slice& target) {
|
||||
if (largest_ != nullptr &&
|
||||
|
@ -149,9 +143,8 @@ TruncatedRangeDelIterator::SplitBySnapshot(
|
|||
std::for_each(
|
||||
split_untruncated_iters.begin(), split_untruncated_iters.end(),
|
||||
[&](FragmentedIterPair& iter_pair) {
|
||||
std::unique_ptr<TruncatedRangeDelIterator> truncated_iter(
|
||||
new TruncatedRangeDelIterator(std::move(iter_pair.second), icmp_,
|
||||
smallest_ikey_, largest_ikey_));
|
||||
auto truncated_iter = std::make_unique<TruncatedRangeDelIterator>(
|
||||
std::move(iter_pair.second), icmp_, smallest_ikey_, largest_ikey_);
|
||||
split_truncated_iters.emplace(iter_pair.first,
|
||||
std::move(truncated_iter));
|
||||
});
|
||||
|
@ -322,9 +315,8 @@ void ReadRangeDelAggregator::AddTombstones(
|
|||
if (input_iter == nullptr || input_iter->empty()) {
|
||||
return;
|
||||
}
|
||||
rep_.AddTombstones(
|
||||
std::unique_ptr<TruncatedRangeDelIterator>(new TruncatedRangeDelIterator(
|
||||
std::move(input_iter), icmp_, smallest, largest)));
|
||||
rep_.AddTombstones(std::make_unique<TruncatedRangeDelIterator>(
|
||||
std::move(input_iter), icmp_, smallest, largest));
|
||||
}
|
||||
|
||||
bool ReadRangeDelAggregator::ShouldDeleteImpl(const ParsedInternalKey& parsed,
|
||||
|
@ -471,19 +463,16 @@ CompactionRangeDelAggregator::NewIterator(const Slice* lower_bound,
|
|||
const Slice* upper_bound,
|
||||
bool upper_bound_inclusive) {
|
||||
InvalidateRangeDelMapPositions();
|
||||
std::unique_ptr<TruncatedRangeDelMergingIter> merging_iter(
|
||||
new TruncatedRangeDelMergingIter(icmp_, lower_bound, upper_bound,
|
||||
upper_bound_inclusive, parent_iters_));
|
||||
auto merging_iter = std::make_unique<TruncatedRangeDelMergingIter>(
|
||||
icmp_, lower_bound, upper_bound, upper_bound_inclusive, parent_iters_);
|
||||
|
||||
auto fragmented_tombstone_list =
|
||||
std::make_shared<FragmentedRangeTombstoneList>(
|
||||
std::move(merging_iter), *icmp_, true /* for_compaction */,
|
||||
*snapshots_);
|
||||
|
||||
return std::unique_ptr<FragmentedRangeTombstoneIterator>(
|
||||
new FragmentedRangeTombstoneIterator(
|
||||
fragmented_tombstone_list, *icmp_,
|
||||
kMaxSequenceNumber /* upper_bound */));
|
||||
return std::make_unique<FragmentedRangeTombstoneIterator>(
|
||||
fragmented_tombstone_list, *icmp_, kMaxSequenceNumber /* upper_bound */);
|
||||
}
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
|
|
@ -38,10 +38,10 @@ class TruncatedRangeDelIterator {
|
|||
|
||||
bool Valid() const;
|
||||
|
||||
void Next();
|
||||
void Prev();
|
||||
void Next() { iter_->TopNext(); }
|
||||
void Prev() { iter_->TopPrev(); }
|
||||
|
||||
void InternalNext();
|
||||
void InternalNext() { iter_->Next(); }
|
||||
|
||||
// Seeks to the tombstone with the highest visible sequence number that covers
|
||||
// target (a user key). If no such tombstone exists, the position will be at
|
||||
|
@ -281,11 +281,11 @@ class RangeDelAggregator {
|
|||
const InternalKey* smallest = nullptr,
|
||||
const InternalKey* largest = nullptr) = 0;
|
||||
|
||||
bool ShouldDelete(const Slice& key, RangeDelPositioningMode mode) {
|
||||
bool ShouldDelete(const Slice& ikey, RangeDelPositioningMode mode) {
|
||||
ParsedInternalKey parsed;
|
||||
|
||||
Status pik_status =
|
||||
ParseInternalKey(key, &parsed, false /* log_err_key */); // TODO
|
||||
ParseInternalKey(ikey, &parsed, false /* log_err_key */); // TODO
|
||||
assert(pik_status.ok());
|
||||
if (!pik_status.ok()) {
|
||||
return false;
|
||||
|
|
|
@ -67,8 +67,8 @@ FragmentedRangeTombstoneList::FragmentedRangeTombstoneList(
|
|||
unfragmented_tombstones->value().size());
|
||||
}
|
||||
// VectorIterator implicitly sorts by key during construction.
|
||||
auto iter = std::unique_ptr<VectorIterator>(
|
||||
new VectorIterator(std::move(keys), std::move(values), &icmp));
|
||||
auto iter = std::make_unique<VectorIterator>(std::move(keys),
|
||||
std::move(values), &icmp);
|
||||
FragmentTombstones(std::move(iter), icmp, for_compaction, snapshots);
|
||||
}
|
||||
|
||||
|
@ -433,9 +433,8 @@ FragmentedRangeTombstoneIterator::SplitBySnapshot(
|
|||
upper = snapshots[i];
|
||||
}
|
||||
if (tombstones_->ContainsRange(lower, upper)) {
|
||||
splits.emplace(upper, std::unique_ptr<FragmentedRangeTombstoneIterator>(
|
||||
new FragmentedRangeTombstoneIterator(
|
||||
tombstones_, *icmp_, upper, lower)));
|
||||
splits.emplace(upper, std::make_unique<FragmentedRangeTombstoneIterator>(
|
||||
tombstones_, *icmp_, upper, lower));
|
||||
}
|
||||
lower = upper + 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue