Fix uninitialized variable gcc error for MyRocks
Summary: make sure seq_ is properly initialized even if ParseInternalKey() fails. Test Plan: run myrocks release tests Reviewers: lightmark, mung, sdong Reviewed By: sdong Subscribers: andrewkr, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D65199
This commit is contained in:
parent
b88f8e87c5
commit
a0ba0aa877
@ -26,7 +26,7 @@ class CompactionIteratorTest : public testing::Test {
|
|||||||
std::unique_ptr<InternalIterator> range_del_iter(
|
std::unique_ptr<InternalIterator> range_del_iter(
|
||||||
new test::VectorIterator(range_del_ks, range_del_vs));
|
new test::VectorIterator(range_del_ks, range_del_vs));
|
||||||
range_del_agg_.reset(new RangeDelAggregator(icmp_, snapshots_));
|
range_del_agg_.reset(new RangeDelAggregator(icmp_, snapshots_));
|
||||||
range_del_agg_->AddTombstones(std::move(range_del_iter));
|
ASSERT_OK(range_del_agg_->AddTombstones(std::move(range_del_iter)));
|
||||||
|
|
||||||
merge_helper_.reset(new MergeHelper(Env::Default(), cmp_, nullptr, nullptr,
|
merge_helper_.reset(new MergeHelper(Env::Default(), cmp_, nullptr, nullptr,
|
||||||
nullptr, 0U, false, 0));
|
nullptr, 0U, false, 0));
|
||||||
|
@ -516,11 +516,7 @@ struct RangeTombstone {
|
|||||||
explicit RangeTombstone(Slice sk, Slice ek, SequenceNumber sn)
|
explicit RangeTombstone(Slice sk, Slice ek, SequenceNumber sn)
|
||||||
: start_key_(sk), end_key_(ek), seq_(sn) {}
|
: start_key_(sk), end_key_(ek), seq_(sn) {}
|
||||||
|
|
||||||
explicit RangeTombstone(Slice internal_key, Slice value) {
|
explicit RangeTombstone(ParsedInternalKey parsed_key, Slice value) {
|
||||||
ParsedInternalKey parsed_key;
|
|
||||||
if (!ParseInternalKey(internal_key, &parsed_key)) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
start_key_ = parsed_key.user_key;
|
start_key_ = parsed_key.user_key;
|
||||||
seq_ = parsed_key.sequence;
|
seq_ = parsed_key.sequence;
|
||||||
end_key_ = value;
|
end_key_ = value;
|
||||||
|
@ -73,25 +73,30 @@ bool RangeDelAggregator::ShouldAddTombstones(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RangeDelAggregator::AddTombstones(ScopedArenaIterator input) {
|
Status RangeDelAggregator::AddTombstones(ScopedArenaIterator input) {
|
||||||
AddTombstones(input.release(), true /* arena */);
|
return AddTombstones(input.release(), true /* arena */);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RangeDelAggregator::AddTombstones(
|
Status RangeDelAggregator::AddTombstones(
|
||||||
std::unique_ptr<InternalIterator> input) {
|
std::unique_ptr<InternalIterator> input) {
|
||||||
AddTombstones(input.release(), false /* arena */);
|
return AddTombstones(input.release(), false /* arena */);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RangeDelAggregator::AddTombstones(InternalIterator* input, bool arena) {
|
Status RangeDelAggregator::AddTombstones(InternalIterator* input, bool arena) {
|
||||||
pinned_iters_mgr_.PinIterator(input, arena);
|
pinned_iters_mgr_.PinIterator(input, arena);
|
||||||
input->SeekToFirst();
|
input->SeekToFirst();
|
||||||
while (input->Valid()) {
|
while (input->Valid()) {
|
||||||
RangeTombstone tombstone(input->key(), input->value());
|
ParsedInternalKey parsed_key;
|
||||||
|
if (!ParseInternalKey(input->key(), &parsed_key)) {
|
||||||
|
return Status::Corruption("Unable to parse range tombstone InternalKey");
|
||||||
|
}
|
||||||
|
RangeTombstone tombstone(parsed_key, input->value());
|
||||||
auto& tombstone_map = GetStripeMapIter(tombstone.seq_)->second;
|
auto& tombstone_map = GetStripeMapIter(tombstone.seq_)->second;
|
||||||
tombstone_map.emplace(tombstone.start_key_.ToString(),
|
tombstone_map.emplace(tombstone.start_key_.ToString(),
|
||||||
std::move(tombstone));
|
std::move(tombstone));
|
||||||
input->Next();
|
input->Next();
|
||||||
}
|
}
|
||||||
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeDelAggregator::StripeMap::iterator RangeDelAggregator::GetStripeMapIter(
|
RangeDelAggregator::StripeMap::iterator RangeDelAggregator::GetStripeMapIter(
|
||||||
|
@ -27,8 +27,8 @@ class RangeDelAggregator {
|
|||||||
|
|
||||||
bool ShouldDelete(const Slice& internal_key, bool for_compaction = false);
|
bool ShouldDelete(const Slice& internal_key, bool for_compaction = false);
|
||||||
bool ShouldAddTombstones(bool bottommost_level = false);
|
bool ShouldAddTombstones(bool bottommost_level = false);
|
||||||
void AddTombstones(ScopedArenaIterator input);
|
Status AddTombstones(ScopedArenaIterator input);
|
||||||
void AddTombstones(std::unique_ptr<InternalIterator> input);
|
Status AddTombstones(std::unique_ptr<InternalIterator> input);
|
||||||
// write tombstones covering a range to a table builder
|
// write tombstones covering a range to a table builder
|
||||||
// usually don't add to a max-level table builder
|
// usually don't add to a max-level table builder
|
||||||
void AddToBuilder(TableBuilder* builder, bool extend_before_min_key,
|
void AddToBuilder(TableBuilder* builder, bool extend_before_min_key,
|
||||||
@ -43,7 +43,7 @@ class RangeDelAggregator {
|
|||||||
// their seqnums are greater than the next smaller snapshot's seqnum.
|
// their seqnums are greater than the next smaller snapshot's seqnum.
|
||||||
typedef std::map<SequenceNumber, TombstoneMap> StripeMap;
|
typedef std::map<SequenceNumber, TombstoneMap> StripeMap;
|
||||||
|
|
||||||
void AddTombstones(InternalIterator* input, bool arena);
|
Status AddTombstones(InternalIterator* input, bool arena);
|
||||||
StripeMap::iterator GetStripeMapIter(SequenceNumber seq);
|
StripeMap::iterator GetStripeMapIter(SequenceNumber seq);
|
||||||
|
|
||||||
PinnedIteratorsManager pinned_iters_mgr_;
|
PinnedIteratorsManager pinned_iters_mgr_;
|
||||||
|
@ -226,7 +226,10 @@ InternalIterator* TableCache::NewIterator(
|
|||||||
if (range_del_agg != nullptr) {
|
if (range_del_agg != nullptr) {
|
||||||
std::unique_ptr<InternalIterator> iter(
|
std::unique_ptr<InternalIterator> iter(
|
||||||
table_reader->NewRangeTombstoneIterator(options));
|
table_reader->NewRangeTombstoneIterator(options));
|
||||||
range_del_agg->AddTombstones(std::move(iter));
|
Status s = range_del_agg->AddTombstones(std::move(iter));
|
||||||
|
if (!s.ok()) {
|
||||||
|
return NewErrorInternalIterator(s, arena);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalIterator* result = nullptr;
|
InternalIterator* result = nullptr;
|
||||||
|
@ -1184,7 +1184,9 @@ TEST_F(BlockBasedTableTest, RangeDelBlock) {
|
|||||||
ASSERT_EQ(true, iter->Valid());
|
ASSERT_EQ(true, iter->Valid());
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
ASSERT_TRUE(iter->Valid());
|
ASSERT_TRUE(iter->Valid());
|
||||||
RangeTombstone t(iter->key(), iter->value());
|
ParsedInternalKey parsed_key;
|
||||||
|
ASSERT_TRUE(ParseInternalKey(iter->key(), &parsed_key));
|
||||||
|
RangeTombstone t(parsed_key, iter->value());
|
||||||
ASSERT_EQ(t.start_key_, keys[i]);
|
ASSERT_EQ(t.start_key_, keys[i]);
|
||||||
ASSERT_EQ(t.end_key_, vals[i]);
|
ASSERT_EQ(t.end_key_, vals[i]);
|
||||||
ASSERT_EQ(t.seq_, i);
|
ASSERT_EQ(t.seq_, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user