aistore.sdk.batch.multipart.sliding_window_buffer
aistore.sdk.batch.multipart.sliding_window_buffer
Module Contents
Classes
API
High-performance sliding window buffer optimized for streaming data processing.
The buffer automatically manages memory by sliding the window when it reaches capacity, keeping only the most recent data plus a configurable overlap for cross-chunk pattern detection.
Parameters:
Maximum logical size before sliding window activation
Size of boundary pattern for overlap calculations
Return current logical length of valid data in buffer.
Returns: int
Number of bytes of valid data
Compact buffer by moving valid data to beginning and updating position tracking.
Get a data slice without copying using memoryview for efficiency.
WARNING: The returned memoryview is only valid until the next call to append(), consume(), or any other method that modifies the buffer. For long-term storage, use get_data_bytes() instead.
Parameters:
Starting position. Defaults to 0.
Ending position, None for end of buffer.
Returns: memoryview
Memory view of requested data range (TEMPORARY)
Append data to buffer with automatic sliding window management and compaction.
Parameters:
Data to append to the buffer
Clear the buffer and update total processed byte counter.
Consume and return data from start of buffer, advancing the window.
Parameters:
Number of bytes to consume
Returns: bytes
Consumed data
Find pattern in buffer and return absolute position in stream.
Parameters:
Pattern to search for
Starting offset for search. Defaults to 0.
Returns: int
Absolute position if found, -1 if not found
Find pattern in buffer and return position relative to current buffer window.
Parameters:
Pattern to search for
Starting offset for search. Defaults to 0.
Returns: int
Relative position if found, -1 if not found
Get data as bytes by creating a copy of the requested range.
Parameters:
Starting position. Defaults to 0.
Ending position, None for end of buffer
Returns: bytes
Copy of requested data range
Skip leading whitespace characters and return count of bytes skipped.
Returns: int
Number of whitespace bytes that were skipped and consumed