MCPcopy Create free account
hub / github.com/apache/impala / CreateFiles

Method CreateFiles

be/src/runtime/tmp-file-mgr.cc:1333–1359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1331}
1332
1333Status TmpFileGroup::CreateFiles() {
1334 lock_.DCheckLocked();
1335 DCHECK(tmp_files_.empty());
1336 vector<DeviceId> tmp_devices = tmp_file_mgr_->ActiveTmpDevices();
1337 DCHECK(tmp_file_mgr_->NumActiveTmpDevicesLocal() <= tmp_devices.size());
1338 int files_allocated = 0;
1339 // Initialize the tmp files and the initial file to use.
1340 for (int i = 0; i < tmp_file_mgr_->NumActiveTmpDevicesLocal(); ++i) {
1341 DeviceId device_id = tmp_devices[i];
1342 unique_ptr<TmpFile> tmp_file;
1343 tmp_file_mgr_->NewFile(this, device_id, &tmp_file);
1344 tmp_files_.emplace_back(std::move(tmp_file));
1345 ++files_allocated;
1346 }
1347 DCHECK_EQ(tmp_file_mgr_->NumActiveTmpDevicesLocal(), files_allocated);
1348 DCHECK_EQ(tmp_file_mgr_->NumActiveTmpDevicesLocal(), tmp_files_.size());
1349 if (tmp_files_.size() == 0) return ScratchAllocationFailedStatus({});
1350 // Initialize the next allocation index for each priority.
1351 for (const auto& entry: tmp_files_index_range_) {
1352 const int priority = entry.first;
1353 const int start = entry.second.start;
1354 const int end = entry.second.end;
1355 // Start allocating on a random device to avoid overloading the first device.
1356 next_allocation_index_.emplace(priority, start + rand() % (end - start + 1));
1357 }
1358 return Status::OK();
1359}
1360
1361template <typename T>
1362void TmpFileGroup::CloseInternal(vector<T>& tmp_files) {

Callers

nothing calls this directly

Calls 8

moveFunction · 0.85
OKFunction · 0.85
DCheckLockedMethod · 0.80
ActiveTmpDevicesMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
NewFileMethod · 0.45

Tested by

no test coverage detected