datalad_next.itertools.route_in
- datalad_next.itertools.route_in(iterable: Iterable, data_store: list, joiner: Callable[[Any, Any], Any]) Generator [source]
Yield previously rerouted data to the consumer
This function is the counter-part to
route_out()
. It takes the iterableiterable
and a data store given indata_store
and yields items in the same order in whichroute_out()
received them from its underlying iterable (using the same data store). This includes items that were not yielded byroute_out()
, but only stored.route_in()
usesjoiner()
-function to determine how stored and optionally processed data should be joined into a single item, which is then yielded byroute_in()
.route_in()
callsjoiner()
with a 2-tuple. The first element of the tuple is eitherdatalad_next.itertools.StoreOnly
or the next item from the underlying iterator. The second element is the data that was stored in the data store. The result ofjoiner()
which will be yielded byroute_in()
.This module provides a standard joiner-function:
join_with_list()
that works with splitter-functions that return a list as second element of the result tuple.The cardinality of
iterable
must match the number of processed data elements in the data store. The output cardinality ofroute_in()
will be the cardinality of the input iterable of the correspondingroute_out()
-call. Given the following code:store_1 = list() route_in( some_generator( route_out(input_iterable, store_1, splitter_1) ), store_1, joiner_1 )
route_in()
will yield the same number of elements asinput_iterable
. But, the number of elements processed bysome_generator
is determined by thesplitter_1()
inroute_out()
, i.e. by the number ofsplitter_1()
-results that have don't havedatalad_next.itertools.don_process
as first element.- Parameters:
iterable (Iterable) -- The iterable that yields the input data.
data_store (list) -- The list from which the data that is to be "routed in" is read.
joiner (Callable[[Any, Any], Any]) -- A function that determines how the items that are yielded by
iterable
should be combined with the corresponding data fromdata_store
, in order to yield the final result. The first argument tojoiner
is the item that is yielded byiterable
, ordatalad_next.itertools.StoreOnly
if no data was processed in the corresponding step. The second argument is the data that was stored indata_store
in the corresponding step.