pyarrow.MemoryMappedFile

class pyarrow.MemoryMappedFile

Bases: pyarrow.lib.NativeFile

Supports ‘r’, ‘r+w’, ‘w’ modes

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

close(self)
create(path, size)
download(self, stream_or_path[, buffer_size]) Read file completely to local path (rather than reading completely into memory).
read(self[, nbytes]) Read indicated number of bytes from file, or read all remaining bytes
read_buffer(self[, nbytes])
seek(self, int64_t position, int whence=0) Change current file stream position
size(self) Return file size
tell(self) Return current stream position
upload(self, stream[, buffer_size]) Pipe file-like object to file
write(self, data) Write byte from any object implementing buffer protocol (bytes,
close(self)
static create(path, size)
download(self, stream_or_path, buffer_size=None)

Read file completely to local path (rather than reading completely into memory). First seeks to the beginning of the file.

mode

The file mode. Currently instances of NativeFile may support

  • rb: binary read
  • wb: binary write
  • rb+: binary read and write
read(self, nbytes=None)

Read indicated number of bytes from file, or read all remaining bytes if no argument passed

Parameters:nbytes (int, default None) –
Returns:data (bytes)
read_buffer(self, nbytes=None)
seek(self, int64_t position, int whence=0)

Change current file stream position

Parameters:
  • position (int) – Byte offset, interpreted relative to value of whence argument
  • whence (int, default 0) – Point of reference for seek offset

Notes

Values of whence: * 0 – start of stream (the default); offset should be zero or positive * 1 – current stream position; offset may be negative * 2 – end of stream; offset is usually negative

Returns:new_position (the new absolute stream position)
size(self)

Return file size

tell(self)

Return current stream position

upload(self, stream, buffer_size=None)

Pipe file-like object to file

write(self, data)

Write byte from any object implementing buffer protocol (bytes, bytearray, ndarray, pyarrow.Buffer)