diff --git a/depends/libhdfs3/src/client/FileStatus.h b/depends/libhdfs3/src/client/FileStatus.h index 1033b80036..6d0f24d2b7 100644 --- a/depends/libhdfs3/src/client/FileStatus.h +++ b/depends/libhdfs3/src/client/FileStatus.h @@ -33,7 +33,7 @@ class FileStatus { public: FileStatus() : isdir(false), atime(0), blocksize(0), length(0), mtime( - 0), permission(0644), replications(0) { + 0), permission(0644), replications(0), fileid(0) { } int64_t getAccessTime() const { @@ -159,6 +159,18 @@ class FileStatus { return fileEncryption.getKey().length() > 0 && fileEncryption.getKeyName().length() > 0; } + /** + * Get FileID of hdfs file/directory + * @return fileid of file if present, else 0 + */ + int64_t getFileid() const { + return fileid; + } + + void setFileid(int64_t fileid) { + this->fileid = fileid; + } + private: bool isdir; int64_t atime; @@ -172,6 +184,7 @@ class FileStatus { std::string path; std::string symlink; FileEncryptionInfo fileEncryption; + int64_t fileid; }; } diff --git a/depends/libhdfs3/src/client/Hdfs.cpp b/depends/libhdfs3/src/client/Hdfs.cpp index b8b7830572..495357fe0a 100644 --- a/depends/libhdfs3/src/client/Hdfs.cpp +++ b/depends/libhdfs3/src/client/Hdfs.cpp @@ -1050,6 +1050,7 @@ static void ConstructHdfsFileInfo(hdfsFileInfo * infos, infos[i].mPermissions = status[i].getPermission().toShort(); infos[i].mReplication = status[i].getReplication(); infos[i].mSize = status[i].getLength(); + infos[i].mFileid = status[i].getFileid(); infos[i].mHdfsEncryptionFileInfo = NULL; if (status[i].isFileEncrypted()) { infos[i].mHdfsEncryptionFileInfo = new hdfsEncryptionFileInfo[1]; diff --git a/depends/libhdfs3/src/client/hdfs.h b/depends/libhdfs3/src/client/hdfs.h index b784367524..a920ddbcdb 100644 --- a/depends/libhdfs3/src/client/hdfs.h +++ b/depends/libhdfs3/src/client/hdfs.h @@ -552,6 +552,7 @@ typedef struct { short mPermissions; /* the permissions associated with the file */ tTime mLastAccess; /* the last access time for the file in seconds */ hdfsEncryptionFileInfo * mHdfsEncryptionFileInfo; /* the encryption info of the file/directory */ + tOffset mFileid; /* Fileid associated with a file. Default value is 0*/ } hdfsFileInfo; /** diff --git a/depends/libhdfs3/src/server/RpcHelper.h b/depends/libhdfs3/src/server/RpcHelper.h index 571ffc0b95..b336b8da74 100644 --- a/depends/libhdfs3/src/server/RpcHelper.h +++ b/depends/libhdfs3/src/server/RpcHelper.h @@ -183,6 +183,7 @@ static inline void Convert(const std::string & src, FileStatus & fs, fs.setSymlink(proto.symlink().c_str()); fs.setPermission(Permission(proto.permission().perm())); fs.setIsdir(proto.filetype() == HdfsFileStatusProto::IS_DIR); + fs.setFileid(proto.fileid()); if (proto.has_fileencryptioninfo()){ const FileEncryptionInfoProto &encrypt = proto.fileencryptioninfo();