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

Method LoadCacheEntry

be/src/runtime/lib-cache.cc:441–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439}
440
441Status LibCache::LoadCacheEntry(const std::string& hdfs_lib_file, time_t exp_mtime,
442 LibType type, LibCacheEntry* entry) {
443 DCHECK(entry != nullptr);
444 entry->type = type;
445
446 // Copy the file
447 entry->local_path = MakeLocalPath(hdfs_lib_file, FLAGS_local_library_dir);
448 VLOG(1) << "Adding lib cache entry: " << hdfs_lib_file
449 << ", local path: " << entry->local_path;
450
451 hdfsFS hdfs_conn, local_conn;
452 RETURN_IF_ERROR(HdfsFsCache::instance()->GetConnection(hdfs_lib_file, &hdfs_conn));
453 RETURN_IF_ERROR(HdfsFsCache::instance()->GetLocalConnection(&local_conn));
454
455 // Note: the file can be updated between getting last_mod_time and copying the file to
456 // local_path. This can only result in the file unnecessarily being refreshed, and does
457 // not affect correctness.
458 entry->copy_file_status =
459 GetLastModificationTime(hdfs_conn, hdfs_lib_file.c_str(), &entry->last_mod_time);
460 RETURN_IF_ERROR(entry->copy_file_status);
461
462 // Check that the exp_mtime is the same as what's on the filesystem.
463 if (exp_mtime >= 0 && exp_mtime != entry->last_mod_time) {
464 return Status(
465 TErrorCode::LIB_VERSION_MISMATCH, hdfs_lib_file, entry->last_mod_time, exp_mtime);
466 }
467
468 entry->copy_file_status =
469 CopyHdfsFile(hdfs_conn, hdfs_lib_file, local_conn, entry->local_path);
470 RETURN_IF_ERROR(entry->copy_file_status);
471
472 if (type == TYPE_SO) {
473 // dlopen the local library
474 RETURN_IF_ERROR(DynamicOpen(entry->local_path.c_str(), &entry->shared_object_handle));
475 } else if (type == TYPE_IR) {
476 // Load the module temporarily and populate all symbols.
477 const string file = entry->local_path;
478 const string module_id = filesystem::path(file).stem().string();
479 RETURN_IF_ERROR(LlvmCodeGen::GetSymbols(file, module_id, &entry->symbols));
480 } else {
481 DCHECK_EQ(type, TYPE_JAR);
482 // Nothing to do.
483 }
484 return Status::OK();
485}
486
487string LibCache::MakeLocalPath(const string& hdfs_path, const string& local_dir) {
488 // Append the pid and library number to the local directory.

Callers

nothing calls this directly

Calls 7

GetLastModificationTimeFunction · 0.85
CopyHdfsFileFunction · 0.85
DynamicOpenFunction · 0.85
OKFunction · 0.85
GetLocalConnectionMethod · 0.80
StatusClass · 0.70
GetConnectionMethod · 0.45

Tested by

no test coverage detected