Fixed a signed and unsigned comparison in Compaction

Summary:
Fixed a signed and unsigned comparison in Compaction

Test Plan:
make db_test
export ROCKSDB_TESTS=Compaction
./db_test
main
Yueh-Hsuan Chiang 11 years ago
parent 0d57e3ad7d
commit aac941b3f0
  1. 15
      db/compaction.h

@ -57,9 +57,8 @@ class Compaction {
// compaction input level. // compaction input level.
// The function will return 0 if when "compaction_input_level" < 0 // The function will return 0 if when "compaction_input_level" < 0
// or "compaction_input_level" >= "num_input_levels()". // or "compaction_input_level" >= "num_input_levels()".
int num_input_files(int compaction_input_level) const { int num_input_files(size_t compaction_input_level) const {
if (compaction_input_level >= 0 && if (compaction_input_level < inputs_.size()) {
compaction_input_level < inputs_.size()) {
return inputs_[compaction_input_level].size(); return inputs_[compaction_input_level].size();
} }
return 0; return 0;
@ -75,9 +74,8 @@ class Compaction {
// specified compaction input level. // specified compaction input level.
// REQUIREMENT: "compaction_input_level" must be >= 0 and // REQUIREMENT: "compaction_input_level" must be >= 0 and
// < "input_levels()" // < "input_levels()"
FileMetaData* input(int compaction_input_level, int i) const { FileMetaData* input(size_t compaction_input_level, int i) const {
assert(compaction_input_level < inputs_.size() && assert(compaction_input_level < inputs_.size());
compaction_input_level >= 0);
return inputs_[compaction_input_level][i]; return inputs_[compaction_input_level][i];
} }
@ -85,9 +83,8 @@ class Compaction {
// input level. // input level.
// REQUIREMENT: "compaction_input_level" must be >= 0 and // REQUIREMENT: "compaction_input_level" must be >= 0 and
// < "input_levels()" // < "input_levels()"
std::vector<FileMetaData*>* const inputs(int compaction_input_level) { std::vector<FileMetaData*>* const inputs(size_t compaction_input_level) {
assert(compaction_input_level < inputs_.size() && assert(compaction_input_level < inputs_.size());
compaction_input_level >= 0);
return &inputs_[compaction_input_level].files; return &inputs_[compaction_input_level].files;
} }

Loading…
Cancel
Save