@@ -32,7 +32,7 @@ def __init__(self, create_function: Callable[..., ConcurrentCursor]):
32
32
self ._create_function = create_function
33
33
34
34
def create (
35
- self , stream_state : Mapping [str , Any ], runtime_lookback_window : Any
35
+ self , stream_state : Mapping [str , Any ], runtime_lookback_window : Optional [ timedelta ]
36
36
) -> ConcurrentCursor :
37
37
return self ._create_function (
38
38
stream_state = stream_state , runtime_lookback_window = runtime_lookback_window
@@ -187,7 +187,7 @@ def _generate_slices_from_partition(self, partition: StreamSlice) -> Iterable[St
187
187
if not cursor :
188
188
cursor = self ._create_cursor (
189
189
self ._global_cursor ,
190
- self ._lookback_window if self ._global_cursor else self . _NO_CURSOR_STATE ,
190
+ self ._lookback_window if self ._global_cursor else 0 ,
191
191
)
192
192
self ._cursor_per_partition [self ._to_partition_key (partition .partition )] = cursor
193
193
self ._semaphore_per_partition [self ._to_partition_key (partition .partition )] = (
@@ -218,9 +218,6 @@ def _ensure_partition_limit(self) -> None:
218
218
f"The maximum number of partitions has been reached. Dropping the oldest partition: { oldest_partition } . Over limit: { self ._over_limit } ."
219
219
)
220
220
221
- def limit_reached (self ) -> bool :
222
- return self ._over_limit > self .DEFAULT_MAX_PARTITIONS_NUMBER
223
-
224
221
def _set_initial_state (self , stream_state : StreamState ) -> None :
225
222
"""
226
223
Initialize the cursor's state using the provided `stream_state`.
@@ -286,6 +283,10 @@ def _set_initial_state(self, stream_state: StreamState) -> None:
286
283
self ._global_cursor = deepcopy (stream_state [self ._GLOBAL_STATE_KEY ])
287
284
self ._new_global_cursor = deepcopy (stream_state [self ._GLOBAL_STATE_KEY ])
288
285
286
+ # Set initial parent state
287
+ if stream_state .get ("parent_state" ):
288
+ self ._parent_state = stream_state ["parent_state" ]
289
+
289
290
# Set parent state for partition routers based on parent streams
290
291
self ._partition_router .set_initial_state (stream_state )
291
292
@@ -305,12 +306,11 @@ def _to_dict(self, partition_key: str) -> Mapping[str, Any]:
305
306
return self ._partition_serializer .to_partition (partition_key )
306
307
307
308
def _create_cursor (
308
- self , cursor_state : Any , runtime_lookback_window : Any = None
309
+ self , cursor_state : Any , runtime_lookback_window : int = 0
309
310
) -> ConcurrentCursor :
310
- if runtime_lookback_window :
311
- runtime_lookback_window = timedelta (seconds = runtime_lookback_window )
312
311
cursor = self ._cursor_factory .create (
313
- stream_state = deepcopy (cursor_state ), runtime_lookback_window = runtime_lookback_window
312
+ stream_state = deepcopy (cursor_state ),
313
+ runtime_lookback_window = timedelta (seconds = runtime_lookback_window ),
314
314
)
315
315
return cursor
316
316
0 commit comments