Skip to content

Commit

Permalink
[bugfix](hive)fix testcase for viewfs (apache#34790)
Browse files Browse the repository at this point in the history
The specified `fsname` is used first, and if there is no `fsname`, the default `fsname` is used.
Because we create an HDFS cache based on the actual `fsname`.
  • Loading branch information
wuwenchi authored May 17, 2024
1 parent e4df4b4 commit 813a697
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions be/src/io/hdfs_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ Status create_hdfs_fs(const THdfsParams& hdfs_params, const std::string& fs_name
return Status::OK();
}

uint64 hdfs_hash_code(const THdfsParams& hdfs_params) {
uint64 hdfs_hash_code(const THdfsParams& hdfs_params, const std::string& fs_name) {
uint64 hash_code = 0;
hash_code ^= Fingerprint(hdfs_params.fs_name);
if (hdfs_params.__isset.user) {
// The specified fsname is used first.
// If there is no specified fsname, the default fsname is used
if (!fs_name.empty()) {
hash_code ^= Fingerprint(fs_name);
} else if (hdfs_params.__isset.user) {
hash_code ^= Fingerprint(hdfs_params.user);
}
if (hdfs_params.__isset.hdfs_kerberos_principal) {
Expand Down Expand Up @@ -105,7 +108,7 @@ void HdfsHandlerCache::_clean_oldest() {

Status HdfsHandlerCache::get_connection(const THdfsParams& hdfs_params, const std::string& fs_name,
std::shared_ptr<HdfsHandler>* fs_handle) {
uint64 hash_code = hdfs_hash_code(hdfs_params);
uint64 hash_code = hdfs_hash_code(hdfs_params, fs_name);
{
std::lock_guard<std::mutex> l(_lock);
auto it = _cache.find(hash_code);
Expand Down

0 comments on commit 813a697

Please sign in to comment.