select_timerange#

Operators to query built-up state.

These operators usually have two inputs, one is a stream of updated data; the other is a “query stream” which contains how to query that data. Downstream will be the result of each query.

Data#

TC: TypeVar#

Type of secondary bytewax.operators.windowing.ClockLogic’s state snapshots.

Classes#

class TimeRangeQuery#

A query to select values in a time range.

sel_id: str#

Arbitrary ID to identify this query in results.

lower: datetime#

Earlier bound.

The results will be inclusive of this time.

upper: datetime#

Later bound.

The results will be inclusive of this time.

class TimeRangeResult#
Bases:

Results from selecting a time range.

query: TimeRangeQuery#
values: List[V]#
incomplete: bool#

True if some values are missing from the query because the operator was configured with too short of a buffer via select_timerange.

class SelectTimeRangeOut#
Bases:

Streams returned from the select time range operator.

results: KeyedStream[TimeRangeResult[V]]#

Selection results.

late_ups: KeyedStream[V]#

Upstream items that were deemed late.

late_queries: KeyedStream[TimeRangeQuery]#

Upstream queries that were deemed late.

Functions#

time_range_ts_getter(
query: TimeRangeQuery,
) datetime#

Timestamp getter for the select query stream.

select_time_range(
step_id: str,
up: KeyedStream[V],
up_clock: Clock[V, Any],
queries: KeyedStream[TimeRangeQuery],
query_clock: Clock[TimeRangeQuery, Any],
max_query_length: timedelta,
) SelectTimeRangeOut[V]#

Select ranges of buffered timestamped values.

Parameters:
  • step_id – Unique ID.

  • up – Keyed stream of values to buffer.

  • up_clock – Time definition.

  • queries – Keyed stream of time ranges to select.

  • query_clock – This should be an EventClock where ts_getter is time_range_ts_getter.

  • max_query_length – Buffer size. Incoming queries that request more than this will be missing values from their results and tagged as TimeRangeResult.incomplete.

Returns:

A SelectTimeRangeOut dataclass.

Join our community Slack channel

Need some help? Join our community!

If you have any trouble with the process or have ideas about how to improve this document, come talk to us in the #questions-answered Slack channel!

Join now