/// <summary> /// Shuffle operation on a sharded streamable /// </summary> /// <typeparam name="TKey">Grouping/sharding key type for input data</typeparam> /// <typeparam name="TNewKey">Grouping/sharding key type for output data</typeparam> /// <typeparam name="TPayload">Payload type for data flowing through the shuffle operation</typeparam> /// <param name="streamable">Input sharded streamable for the shuffle operation</param> /// <param name="shuffleSelector">Selector function to determine new shard keys</param> /// <param name="newLocation">Assign an optional new location descriptor</param> /// <returns>A new sharded streamable post-shuffle</returns> public static IShardedStreamable <TNewKey, TPayload> Shuffle <TKey, TNewKey, TPayload>( this IShardedStreamable <TKey, TPayload> streamable, Expression <Func <TPayload, TNewKey> > shuffleSelector, ILocationDescriptor newLocation = null) { return(streamable.ReKey(shuffleSelector).ReDistribute(newLocation)); }
/// <summary> /// Unshuffle operation on a sharded streamable (essentially, a unifying shuffle operation shuffling to a unity shard /// </summary> /// <typeparam name="TKey">Grouping/sharding key type for input data</typeparam> /// <typeparam name="TPayload">Payload type for data flowing through the shuffle operation</typeparam> /// <param name="streamable">Input sharded streamable for the shuffle operation</param> /// <returns>A new sharded streamable post-shuffle</returns> public static IShardedStreamable <Empty, TPayload> Unshuffle <TKey, TPayload>(this IShardedStreamable <TKey, TPayload> streamable) { return(streamable.ReKey(e => Empty.Default)); }