uproot.source.chunk.Source
Defined in uproot.source.chunk on line 57.
- class uproot.source.chunk.Source
Abstract class for physically reading and writing data from a file, which might be remote.
In addition to the file handle, a uproot.source.chunk.Source might manage a uproot.source.futures.ResourceThreadPoolExecutor to read the file in parallel. Stopping these threads is part of the act of closing the file.
chunk
- Source.chunk(start: int, stop: int) Chunk
- Parameters:
start (int) – Seek position of the first byte to include.
stop (int) – Seek position of the first byte to exclude (one greater than the last byte to include).
Request a byte range of data from the file as a uproot.source.chunk.Chunk.
chunks
- Source.chunks(ranges: list[int, int], notifications: queue.Queue) list[Chunk]
- Parameters:
ranges (list of (int, int) 2-tuples) – Intervals to fetch as (start, stop) pairs in a single request, if possible.
notifications (
queue.Queue
) – Indicator of completed chunks. After each gets filled, it isput
on the queue; a listener shouldget
from this queuelen(ranges)
times.
Request a set of byte ranges from the file.
This method has two outputs:
The method returns a list of unfilled uproot.source.chunk.Chunk objects, which get filled in a background thread. If you try to read data from an unfilled chunk, it will wait until it is filled.
The method also puts the same uproot.source.chunk.Chunk objects onto the
notifications
queue as soon as they are filled.
Reading data from chunks on the queue can be more efficient than reading them from the returned list. The total reading time is the same, but work on the filled chunks can be better parallelized if it is triggered by already-filled chunks, rather than waiting for chunks to be filled.
file_path
- Source.file_path
A path to the file (or URL).
num_bytes
- Source.num_bytes
The number of bytes in the file.
num_requests
- Source.num_requests
The number of requests that have been made (performance counter).
num_requested_chunks
- Source.num_requested_chunks
The number of uproot.source.chunk.Chunk objects that have been requested (performance counter).
num_requested_bytes
- Source.num_requested_bytes
The number of bytes that have been requested (performance counter).
performance_counters
- Source.performance_counters
close
- Source.close()
Manually closes the file(s) and stops any running threads.
closed
- Source.closed
True if the associated file/connection/thread pool is closed; False otherwise.