proxystore.p2p.chunks¶
Message chunking utilities.
ChunkDType
¶
Chunk
¶
Chunk(
stream_id: int,
seq_id: int,
seq_len: int,
data: bytes | str,
dtype: ChunkDType | None = None,
)
Representation of a chunk of a message.
Parameters:
-
stream_id(int) –Unique ID for the stream of chunks.
-
seq_id(int) –Sequence number for this chunk in the stream.
-
seq_len(int) –Length of the stream.
-
data(bytes | str) –Data for this chunk.
-
dtype(ChunkDType | None, default:None) –Optionally specify data type otherwise inferred from data.
Raises:
-
ValueError–if the sequence ID is not less than the sequence length.
Source code in proxystore/p2p/chunks.py
__bytes__
¶
__bytes__() -> bytes
Pack the chunk into bytes.
Source code in proxystore/p2p/chunks.py
from_bytes
classmethod
¶
Decode bytes into a Chunk.
Source code in proxystore/p2p/chunks.py
chunkify
¶
Generate chunks from data.
Parameters:
-
data(bytes | str) –Data to chunk.
-
size(int) –Size of each chunk.
-
stream_id(int) –Unique ID for the stream of chunks.
Yields:
-
Chunk–Chunks of data.
Source code in proxystore/p2p/chunks.py
reconstruct
¶
Reconstructs data from list of chunks.
Parameters:
Returns: