Hadoop 3.2.2
libhdfs/hdfs.c
struct hdfsFile_internal {void* file;enum hdfsStreamType type;int flags;
};
以上数据结构中的 flags 是由以下接口赋值
hdfsFile hdfsOpenFile(hdfsFS fs, const char *path, int flags,int bufferSize, short replication, tSize blockSize)
{struct hdfsStreamBuilder *bld = hdfsStreamBuilderAlloc(fs, path, flags);if (bufferSize != 0) {hdfsStreamBuilderSetBufferSize(bld, bufferSize);}if (replication != 0) {hdfsStreamBuilderSetReplication(bld, replication);}if (blockSize != 0) {hdfsStreamBuilderSetDefaultBlockSize(bld, blockSize);}return hdfsStreamBuilderBuild(bld);
}
int hdfsFileUsesDirectRead(hdfsFile file)
{return !!(file->flags & HDFS_FILE_SUPPORTS_DIRECT_READ);
}void hdfsFileDisableDirectRead(hdfsFile file)
{file->flags &= ~HDFS_FILE_SUPPORTS_DIRECT_READ;
}