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

Method LoadZoneAliasesFromHdfs

be/src/exprs/timezone_db.cc:372–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372Status TimezoneDatabase::LoadZoneAliasesFromHdfs(const string& hdfs_zone_alias_conf) {
373 DCHECK(!hdfs_zone_alias_conf.empty());
374
375 hdfsFS hdfs_conn;
376 RETURN_IF_ERROR(
377 HdfsFsCache::instance()->GetConnection(hdfs_zone_alias_conf, &hdfs_conn));
378
379 hdfsFile hdfs_file = hdfsOpenFile(
380 hdfs_conn, hdfs_zone_alias_conf.c_str(), O_RDONLY, 0, 0, 0);
381 if (hdfs_file == nullptr) {
382 return Status(GetHdfsErrorMsg("Failed to open HDFS file for reading: ",
383 hdfs_zone_alias_conf));
384 }
385
386 Status status = Status::OK();
387 vector<char> buffer(HDFS_READ_SIZE);
388 int current_bytes_read = -1;
389 stringstream ss;
390 while (true) {
391 current_bytes_read = hdfsRead(hdfs_conn, hdfs_file, buffer.data(), buffer.size());
392 if (current_bytes_read == 0) break;
393 if (current_bytes_read < 0) {
394 status = Status(TErrorCode::DISK_IO_ERROR, GetBackendString(),
395 GetHdfsErrorMsg("Error reading from HDFS file: ", hdfs_zone_alias_conf));
396 break;
397 }
398 ss << string(buffer.data(), current_bytes_read);
399 }
400
401 int hdfs_ret = hdfsCloseFile(hdfs_conn, hdfs_file);
402 if (hdfs_ret != 0) {
403 status.MergeStatus(
404 Status(ErrorMsg(TErrorCode::GENERAL,
405 GetHdfsErrorMsg("Failed to close HDFS file: ", hdfs_zone_alias_conf))));
406 }
407
408 if (status.ok()) {
409 status = LoadZoneAliases(ss, hdfs_zone_alias_conf.c_str());
410 }
411 return status;
412}
413
414Status TimezoneDatabase::LoadZoneAliases(istream &is, const char* path) {
415 string line, alias, value;

Callers

nothing calls this directly

Calls 11

GetHdfsErrorMsgFunction · 0.85
OKFunction · 0.85
GetBackendStringFunction · 0.85
ErrorMsgClass · 0.85
MergeStatusMethod · 0.80
StatusClass · 0.70
emptyMethod · 0.45
GetConnectionMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected