hdfsRead()

Supported by libMapRClient for hadoop-2.x

Reads data from the current offset in an open file. After the read, the current offset is incremented by the number of bytes read.

To read from a specific offset, first call hdfsSeek() to move to that offset in the file. Then, call hdfsRead().

Alternatively, call hdfsPread(), specifying an offset in the call. hdfsPread() does not increment the current offset in the file. The offset that you specify in the call is used only for the read.

Signature

tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length)

Parameters

Parameter Description
fs The file system handle. File system handle can be obtained using one of the hdfsConnect() APIs.
file The file handle. Obtain this handle with one of the hdfsOpenFile() APIs.
buffer The buffer to copy bytes into during the read.
length The length of the buffer. The maximum length of the buffer is the maximum size of tSize.

Returned Value

Returns the number of bytes actually read, which can be less than than the length of the buffer if the end of the file is reached during the read. Returns -1 on error.

Check errno for error codes and meanings.