Blocking Map-Reduce
In the following code example, we calculate the square of each number and once we have all the squares, we sum them.Non-blocking Map-Reduce
In the following code example, we calculate the square of each number and as soon as each square is available, we sum them. This is achieved using futures and tail calls. This reduces the overall duration of the Map-Reduce operation. The reduce function is still called sequentially in the original order of the list.Inputs
List
Both map and reduce operations accept a list as operation inputs. Each item in the list can be a value, a Future, a Tensorlake coroutine, or anasyncio.Task object.
Tensorlake recognizes these Futures/coroutines/asyncio.Task objects, runs them automatically, and uses their
results as the input values for the operation.
Future / Coroutine / Task
Map and reduce operations accept a single Future/coroutine/asyncio.Task
object as their input. The Future/coroutine/asyncio.Task object has to resolve to a list of items.
Tensorlake automatically waits for it to complete and uses the returned list as the operation input.
This is useful when the input list is produced by another Tensorlake function.