diff --git a/db/db_impl.cc b/db/db_impl.cc index c22276675..d95481079 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1717,7 +1717,14 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { stats.files_in_leveln = compact->compaction->num_input_files(0); stats.files_in_levelnp1 = compact->compaction->num_input_files(1); - stats.files_out_levelnp1 = compact->outputs.size(); + + int num_output_files = compact->outputs.size(); + if (compact->builder != NULL) { + // An error occured so ignore the last output. + assert(num_output_files > 0); + --num_output_files; + } + stats.files_out_levelnp1 = num_output_files; for (int i = 0; i < compact->compaction->num_input_files(0); i++) stats.bytes_readn += compact->compaction->input(0, i)->file_size; @@ -1725,7 +1732,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { for (int i = 0; i < compact->compaction->num_input_files(1); i++) stats.bytes_readnp1 += compact->compaction->input(1, i)->file_size; - for (size_t i = 0; i < compact->outputs.size(); i++) { + for (int i = 0; i < num_output_files; i++) { stats.bytes_written += compact->outputs[i].file_size; } diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 69c578079..02934c85e 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -678,19 +678,19 @@ class StressTest { fprintf(stdout, "Num keys per lock : %d\n", 1 << FLAGS_log2_keys_per_lock); - char* compression = (char *)std::string("").c_str(); + const char* compression = ""; switch (FLAGS_compression_type) { case leveldb::kNoCompression: - compression = (char *)std::string("none").c_str(); + compression = "none"; break; case leveldb::kSnappyCompression: - compression = (char *)std::string("snappy").c_str(); + compression = "snappy"; break; case leveldb::kZlibCompression: - compression = (char *)std::string("zlib").c_str(); + compression = "zlib"; break; case leveldb::kBZip2Compression: - compression = (char *)std::string("bzip2").c_str(); + compression = "bzip2"; break; }