Commit 11f9682b authored by Shaochen Shi's avatar Shaochen Shi Committed by Guolin Ke
Browse files

Fix build error when HDFS is enabled. (#2540)

* Fix build error when HDFS is enabled.

* Replace string with char array to eliminate cpplint.
parent 26ff099a
...@@ -55,6 +55,7 @@ struct LocalFile : VirtualFileReader, VirtualFileWriter { ...@@ -55,6 +55,7 @@ struct LocalFile : VirtualFileReader, VirtualFileWriter {
}; };
const char* kHdfsProto = "hdfs://"; const char* kHdfsProto = "hdfs://";
const size_t kHdfsProtoLength = strlen(kHdfsProto);
#ifdef USE_HDFS #ifdef USE_HDFS
struct HDFSFile : VirtualFileReader, VirtualFileWriter { struct HDFSFile : VirtualFileReader, VirtualFileWriter {
...@@ -117,12 +118,12 @@ struct HDFSFile : VirtualFileReader, VirtualFileWriter { ...@@ -117,12 +118,12 @@ struct HDFSFile : VirtualFileReader, VirtualFileWriter {
} }
static hdfsFS GetHDFSFileSystem(const std::string& uri) { 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) { if (uri.find(kHdfsProto) != 0 || end == std::string::npos) {
Log::Warning("Bad HDFS uri, no namenode found [%s]", uri.c_str()); Log::Warning("Bad HDFS uri, no namenode found [%s]", uri.c_str());
return NULL; 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) { if (fs_cache_.count(hostport) == 0) {
fs_cache_[hostport] = MakeHDFSFileSystem(hostport); fs_cache_[hostport] = MakeHDFSFileSystem(hostport);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment