MCPcopy Create free account
hub / github.com/ElementsProject/elements / MakeInputIterator

Method MakeInputIterator

src/leveldb/db/version_set.cc:1214–1245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1212}
1213
1214Iterator* VersionSet::MakeInputIterator(Compaction* c) {
1215 ReadOptions options;
1216 options.verify_checksums = options_->paranoid_checks;
1217 options.fill_cache = false;
1218
1219 // Level-0 files have to be merged together. For other levels,
1220 // we will make a concatenating iterator per level.
1221 // TODO(opt): use concatenating iterator for level-0 if there is no overlap
1222 const int space = (c->level() == 0 ? c->inputs_[0].size() + 1 : 2);
1223 Iterator** list = new Iterator*[space];
1224 int num = 0;
1225 for (int which = 0; which < 2; which++) {
1226 if (!c->inputs_[which].empty()) {
1227 if (c->level() + which == 0) {
1228 const std::vector<FileMetaData*>& files = c->inputs_[which];
1229 for (size_t i = 0; i < files.size(); i++) {
1230 list[num++] = table_cache_->NewIterator(options, files[i]->number,
1231 files[i]->file_size);
1232 }
1233 } else {
1234 // Create concatenating iterator for the files from this level
1235 list[num++] = NewTwoLevelIterator(
1236 new Version::LevelFileNumIterator(icmp_, &c->inputs_[which]),
1237 &GetFileIterator, table_cache_, options);
1238 }
1239 }
1240 }
1241 assert(num <= space);
1242 Iterator* result = NewMergingIterator(&icmp_, list, num);
1243 delete[] list;
1244 return result;
1245}
1246
1247Compaction* VersionSet::PickCompaction() {
1248 Compaction* c;

Callers 1

DoCompactionWorkMethod · 0.80

Calls 6

NewTwoLevelIteratorFunction · 0.85
NewMergingIteratorFunction · 0.85
levelMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
NewIteratorMethod · 0.45

Tested by

no test coverage detected