Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
HAWQ-1721: FileStats does not contain FileId
Browse files Browse the repository at this point in the history
* Add Fileid as part of FileStats and hdfsFileInfo.

Fileid is useful in uniquely identifying files and directories in HDFS. HdfsFileStatusProto has this field but it is not exposed as via library. It is an optional field and in case this field is not present, it default to 0.
  • Loading branch information
Gaurav Khandelwal committed May 26, 2019
1 parent b935042 commit 10ce2f8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion depends/libhdfs3/src/client/FileStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -172,6 +184,7 @@ class FileStatus {
std::string path;
std::string symlink;
FileEncryptionInfo fileEncryption;
int64_t fileid;
};

}
Expand Down
1 change: 1 addition & 0 deletions depends/libhdfs3/src/client/Hdfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions depends/libhdfs3/src/client/hdfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
1 change: 1 addition & 0 deletions depends/libhdfs3/src/server/RpcHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 10ce2f8

Please sign in to comment.