diff --git a/db/c_test.c b/db/c_test.c index b8f0ea186..2a9dc2036 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -388,7 +388,7 @@ int main(int argc, char** argv) { Free(&err); StartPhase("open_error"); - db = rocksdb_open(options, dbname, &err); + rocksdb_open(options, dbname, &err); CheckCondition(err != NULL); Free(&err); diff --git a/db/db_iter.cc b/db/db_iter.cc index 1b5bf860e..2ab0c3871 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -225,7 +225,6 @@ void DBIter::FindNextUserEntryInternal(bool skipping) { num_skipped++; // skip this entry PERF_COUNTER_ADD(internal_key_skipped_count, 1); } else { - skipping = false; switch (ikey.type) { case kTypeDeletion: // Arrange to skip all upcoming entries for this key since diff --git a/db/log_reader.cc b/db/log_reader.cc index 9ab97ca3e..f6514cfd3 100644 --- a/db/log_reader.cc +++ b/db/log_reader.cc @@ -39,12 +39,11 @@ Reader::~Reader() { } bool Reader::SkipToInitialBlock() { - size_t offset_in_block = initial_offset_ % kBlockSize; - uint64_t block_start_location = initial_offset_ - offset_in_block; + size_t initial_offset_in_block = initial_offset_ % kBlockSize; + uint64_t block_start_location = initial_offset_ - initial_offset_in_block; // Don't search a block if we'd be in the trailer - if (offset_in_block > kBlockSize - 6) { - offset_in_block = 0; + if (initial_offset_in_block > kBlockSize - 6) { block_start_location += kBlockSize; } @@ -82,16 +81,12 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch) { const unsigned int record_type = ReadPhysicalRecord(&fragment); switch (record_type) { case kFullType: - if (in_fragmented_record) { + if (in_fragmented_record && !scratch->empty()) { // Handle bug in earlier versions of log::Writer where // it could emit an empty kFirstType record at the tail end // of a block followed by a kFullType or kFirstType record // at the beginning of the next block. - if (scratch->empty()) { - in_fragmented_record = false; - } else { - ReportCorruption(scratch->size(), "partial record without end(1)"); - } + ReportCorruption(scratch->size(), "partial record without end(1)"); } prospective_record_offset = physical_record_offset; scratch->clear(); @@ -100,16 +95,12 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch) { return true; case kFirstType: - if (in_fragmented_record) { + if (in_fragmented_record && !scratch->empty()) { // Handle bug in earlier versions of log::Writer where // it could emit an empty kFirstType record at the tail end // of a block followed by a kFullType or kFirstType record // at the beginning of the next block. - if (scratch->empty()) { - in_fragmented_record = false; - } else { - ReportCorruption(scratch->size(), "partial record without end(2)"); - } + ReportCorruption(scratch->size(), "partial record without end(2)"); } prospective_record_offset = physical_record_offset; scratch->assign(fragment.data(), fragment.size()); diff --git a/table/plain_table_key_coding.cc b/table/plain_table_key_coding.cc index 4b2da6d55..a8967e8c8 100644 --- a/table/plain_table_key_coding.cc +++ b/table/plain_table_key_coding.cc @@ -73,10 +73,9 @@ Status PlainTableKeyEncoder::AppendKey(const Slice& key, WritableFile* file, Slice key_to_write = key; // Portion of internal key to write out. - uint32_t user_key_size = fixed_user_key_len_; + uint32_t user_key_size = static_cast(key.size() - 8); if (encoding_type_ == kPlain) { if (fixed_user_key_len_ == kPlainTableVariableLength) { - user_key_size = static_cast(key.size() - 8); // Write key length char key_size_buf[5]; // tmp buffer for key size as varint32 char* ptr = EncodeVarint32(key_size_buf, user_key_size); @@ -93,8 +92,6 @@ Status PlainTableKeyEncoder::AppendKey(const Slice& key, WritableFile* file, char size_bytes[12]; size_t size_bytes_pos = 0; - user_key_size = static_cast(key.size() - 8); - Slice prefix = prefix_extractor_->Transform(Slice(key.data(), user_key_size)); if (key_count_for_prefix_ == 0 || prefix != pre_prefix_.GetKey() || diff --git a/tools/db_stress.cc b/tools/db_stress.cc index e33eeed73..986344596 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -1726,6 +1726,7 @@ class StressTest { break; case rocksdb::kLZ4Compression: compression = "lz4"; + break; case rocksdb::kLZ4HCCompression: compression = "lz4hc"; break;