uproot.source.chunk.Chunk
Defined in uproot.source.chunk on line 249.
- class uproot.source.chunk.Chunk(source: Source, start: int, stop: int, future, is_memmap: bool = False)
- Parameters:
source (uproot.source.chunk.Source) – Source from which the data were derived.
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).
future (uproot.source.futures.TrivialFuture or uproot.source.futures.Future) – Handle to the synchronous or asynchronous data. A chunk is “filled” when the
future
completes.
A range of bytes from a uproot.source.chunk.Source, which may be synchronously or asynchronously filled.
The following methods must wait for the future to complete (to be filled):
wait: Waits and nothing else.
raw_data: The data as a
numpy.ndarray
ofnumpy.uint8
.get: A subinterval of the data as a
numpy.ndarray
ofnumpy.uint8
.remainder: A subinterval from the uproot.Cursor to the end of the uproot.source.chunk.Chunk.
wrap
- classmethod Chunk.wrap(source: Source, data: numpy.ndarray | bytes, start: int = 0)
- Parameters:
source (uproot.source.chunk.Source) – Source to attach to the new chunk.
data (
numpy.ndarray
ofnumpy.uint8
) – Data for the new chunk.start (int) – Virtual starting position for this chunk; if
X
, then a uproot.Cursor is valid fromX
toX + len(data)
.
Manually creates a synchronous uproot.source.chunk.Chunk.
source
- Chunk.source
Source from which this Chunk is derived.
start
- Chunk.start
Seek position of the first byte to include.
stop
- Chunk.stop
Seek position of the first byte to exclude (one greater than the last byte to include).
future
- Chunk.future
Handle to the synchronous or asynchronous data. A chunk is “filled” when the
future
completes.
is_memmap
- Chunk.is_memmap
If True, the raw_data is or will be a view into a memmap file, which must be handled carefully. Accessing that data after the file is closed causes a segfault.
detach_memmap
- Chunk.detach_memmap()
Returns a Chunk (possibly this one) that is not tied to live memmap data. Such a Chunk can be accessed after the file is closed without segfaults.
wait
- Chunk.wait(insist: bool = True)
- Parameters:
insist (bool or int) – If True, raise an OSError if
raw_data
does does not have exactlystop - start
bytes. If False, do not check. If an integer, only raise an OSError if data up to that index can’t be supplied (i.e. requirelen(raw_data) >= insist - start
).
Explicitly wait until the chunk is filled (the future completes).
raw_data
get
- Chunk.get(start: int, stop: int, cursor: Cursor, context: dict) ndarray
- 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).
cursor (uproot.Cursor) – A pointer to the current position in this chunk.
context (dict) – Auxiliary data used in deserialization.
Returns a subinterval of the raw_data as a
numpy.ndarray
ofnumpy.uint8
.Note that this
start
andstop
are in the same coordinate system as the start and stop. That is, to get the whole chunk, usestart=chunk.start
andstop=chunk.stop
.This method will wait until the chunk is filled (the future completes), if it isn’t already.
remainder
- Chunk.remainder(start: int, cursor: Cursor, context: dict) ndarray
- Parameters:
start (int) – Seek position of the first byte to include.
cursor (uproot.Cursor) – A pointer to the current position in this chunk.
context (dict) – Auxiliary data used in deserialization.
Returns a subinterval of the raw_data as a
numpy.ndarray
ofnumpy.uint8
fromstart
to the end of the chunk.Note that this
start
is in the same coordinate system as the start. That is, to get the whole chunk, usestart=chunk.start
.This method will wait until the chunk is filled (the future completes), if it isn’t already.