Skip to content

Commit

Permalink
Fix build error when HDFS is enabled. (#2540)
Browse files Browse the repository at this point in the history
* Fix build error when HDFS is enabled.

* Replace string with char array to eliminate cpplint.
  • Loading branch information
shishaochen authored and guolinke committed Nov 16, 2019
1 parent 26ff099 commit 11f9682
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/io/file_io.cpp
Expand Up @@ -55,6 +55,7 @@ struct LocalFile : VirtualFileReader, VirtualFileWriter {
};

const char* kHdfsProto = "hdfs://";
const size_t kHdfsProtoLength = strlen(kHdfsProto);

#ifdef USE_HDFS
struct HDFSFile : VirtualFileReader, VirtualFileWriter {
Expand Down Expand Up @@ -117,12 +118,12 @@ struct HDFSFile : VirtualFileReader, VirtualFileWriter {
}

static hdfsFS GetHDFSFileSystem(const std::string& uri) {
size_t end = uri.find("/", kHdfsProto.length());
size_t end = uri.find("/", kHdfsProtoLength);
if (uri.find(kHdfsProto) != 0 || end == std::string::npos) {
Log::Warning("Bad HDFS uri, no namenode found [%s]", uri.c_str());
return NULL;
}
std::string hostport = uri.substr(kHdfsProto.length(), end - kHdfsProto.length());
std::string hostport = uri.substr(kHdfsProtoLength, end - kHdfsProtoLength);
if (fs_cache_.count(hostport) == 0) {
fs_cache_[hostport] = MakeHDFSFileSystem(hostport);
}
Expand Down

0 comments on commit 11f9682

Please sign in to comment.