| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.CompressedInputStream.html | [Back] [Original] |
Bases: NativeFile
An input stream wrapper which decompresses data on the fly.
str, path, pyarrow.NativeFile, or file-like objectInput stream object to wrap with the compression.
strThe compression type (bz2, brotli, gzip, lz4 or zstd).
Examples
Create an output stream which compresses the data:
>>> import pyarrow as pa
>>> data = b"Compressed stream"
>>> raw = pa.BufferOutputStream()
>>> with pa.CompressedOutputStream(raw, "gzip") as compressed:
... compressed.write(data)
...
17
Create an input stream with decompression referencing the buffer with compressed data:
>>> cdata = raw.getvalue()
>>> with pa.input_stream(cdata, compression="gzip") as compressed:
... compressed.read()
...
b'Compressed stream'
which actually translates to the use of BufferReader``and
``CompressedInputStream:
>>> raw = pa.BufferReader(cdata)
>>> with pa.CompressedInputStream(raw, "gzip") as compressed:
... compressed.read()
...
b'Compressed stream'
Methods
|
|
|
|
|
Read this file completely to a local path or destination stream. |
|
NOT IMPLEMENTED |
|
Flush the stream, if applicable. |
|
Return an input stream that reads a file segment independent of the state of the file. |
|
|
|
Return file metadata |
|
Read and return up to n bytes. |
|
Read and return up to n bytes. |
|
Read indicated number of bytes at offset from the file |
|
Read from buffer. |
|
|
|
|
|
Read into the supplied buffer |
|
NOT IMPLEMENTED. |
|
NOT IMPLEMENTED. |
|
Change current file stream position |
|
|
|
Return file size |
|
Return current stream position |
|
NOT IMPLEMENTED |
|
Write from a source stream to this file. |
|
|
|
Write data to the file. |
|
Write lines to the file. |
Attributes
Read this file completely to a local path or destination stream.
This method first seeks to the beginning of the file.
NOT IMPLEMENTED
Flush the stream, if applicable.
An error is raised if stream is not writable.
Return an input stream that reads a file segment independent of the state of the file.
Allows reading portions of a random access file as an input stream without interfering with each other.
NativeFileReturn file metadata
The file mode. Currently instances of NativeFile may support:
rb: binary read
wb: binary write
rb+: binary read and write
ab: binary append
Read and return up to n bytes.
If nbytes is None, then the entire remaining file contents are read.
Read and return up to n bytes.
Unlike read(), if nbytes is None then a chunk is read, not the entire file.
Read indicated number of bytes at offset from the file
Read from buffer.
int, optionalmaximum number of bytes read
Read into the supplied buffer
A writable buffer object (such as a bytearray).
intnumber of bytes written
NOT IMPLEMENTED. Read and return a line of bytes from the file.
If size is specified, read at most size bytes.
Line terminator is always bn.
intmaximum number of bytes read
NOT IMPLEMENTED. Read lines of the file
intmaximum number of bytes read until we stop
Change current file stream position
intThe new absolute stream position.
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
Return file size
Return current stream position
NOT IMPLEMENTED
Write from a source stream to this file.
Source stream to pipe to this file.
int, optionalThe buffer size to use for data transfers.
| Web Proxy Viewer | New URL | Original Page |