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 25, 2019
1 parent b935042 commit 1295271
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
11 changes: 10 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 @@ -96,6 +96,14 @@ class FileStatus {
mtime = modificationTime;
}

int64_t getFileid() const {
return fileid;
}

void setFileid(int64_t fileid) {
this->fileid = fileid;
}

const char * getOwner() const {
return owner.c_str();
}
Expand Down Expand Up @@ -165,6 +173,7 @@ class FileStatus {
int64_t blocksize;
int64_t length;
int64_t mtime;
int64_t fileid;
Permission permission;
short replications;
std::string group;
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 1295271

Please sign in to comment.