hadoop怎么访问hdfs路径

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hadoop怎么访问hdfs路径相关的知识,希望对你有一定的参考价值。

先用hdfsGetPathInfo 得到一个hdfsFileInfo类型的结构体,
get_real_path(dsh, s, real_path);
hdfsFileInfo * pt_hdfs_file_info = hdfsGetPathInfo(hdfs,real_path);//
这个结构体中有个kind属性,就是来区分是文件还是目录
typedef struct
tObjectKind mKind; /* file or directory */
char *mName; /* the name of the file */
tTime mLastMod; /* the last modification time for the file in seconds */
tOffset mSize; /* the size of the file in bytes */
short mReplication; /* the count of replicas */
tOffset mBlockSize; /* the block size for the file */
char *mOwner; /* the owner of the file */
char *mGroup; /* the group associated with the file */
short mPermissions; /* the permissions associated with the file */
tTime mLastAccess; /* the last access time for the file in seconds */
hdfsFileInfo;
参考技术A

    先用hdfsGetPathInfo 得到一个hdfsFileInfo类型的结构体, get_real_path(dsh, s, real_path); 

    hdfsFileInfo * pt_hdfs_file_info = hdfsGetPathInfo(hdfs,real_path);// 这个结构体中有个kind属性,就是来区分是文件还是目录 typedef struct

参考技术B 先用hdfsGetPathInfo 得到一个hdfsFileInfo类型的结构体,
get_real_path(dsh, s, real_path);
hdfsFileInfo * pt_hdfs_file_info = hdfsGetPathInfo(hdfs,real_path);//
这个结构体中有个kind属性,就是来区分是文件还是目录
typedef struct
tObjectKind mKind; /* file or directory */
char *mName; /* the name of the file */
tTime mLastMod; /* the last modification time for the file in seconds */
tOffset mSize; /* the size of the file in bytes */
short mReplication; /* the count of replicas */
tOffset mBlockSize; /* the block size for the file */
char *mOwner; /* the owner of the file */
char *mGroup; /* the group associated with the file */
short mPermissions; /* the permissions associated with the file */
tTime mLastAccess; /* the last access time for the file in seconds */
hdfsFileInfo;
参考技术C 此题不适合高质量作答

hdfs怎么查看目录路径

参考技术A 用ls命令, 如果返回一行说明是文件,如果多行则表示目录
hadoop fs -ls $path | grep $path | wc -l

以上是关于hadoop怎么访问hdfs路径的主要内容,如果未能解决你的问题,请参考以下文章

Hadoop文档(2.9.2) - HDFS架构

hadoop内部表直接添加文件

HDFS,Hadoop中的低延迟数据访问

ftp提取文件到hdfs

无法通过map reduce java程序访问Hadoop hdfs文件系统

hadoop 3.1.1 无法访问hdfs(50070)的web界面