public static StageOutput<R, T> Broadcast<R, T>(this StageOutput<R, T> port) where R : Cloneable<R> where T : Time<T> { var controller = port.Context.Manager.Controller; int threadCount = controller.DefaultPlacement.Count / controller.Configuration.Processes; if (threadCount * controller.Configuration.Processes != controller.DefaultPlacement.Count) { throw new Exception("Uneven thread count?"); } var processDests = controller.DefaultPlacement.Where(x => x.ThreadId == 0).Select(x => x.ShardId).ToArray(); var boutput = UnaryStreamingShard<R, Pair<int, R>, T>.MakeStage(port, (i, v) => new BroadcastSendShard<R, T>(i, v, processDests), null, null, "BroadcastProcessSend"); var collectable = boutput; if (controller.DefaultPlacement.Where(x => x.ProcessId == controller.Configuration.ProcessID).Count() > 1) { var threadDests = controller.DefaultPlacement .Where(x => x.ProcessId == controller.Configuration.ProcessID) .Select(x => x.ShardId) .ToArray(); collectable = UnaryStreamingShard<Pair<int, R>, Pair<int, R>, T>.MakeStage(boutput, (i, v) => new BroadcastForwardShard<R, T>(i, v, threadDests), x => x.s, null, "BroadcastShardSend"); } return Naiad.Frameworks.Linq.ExtensionMethods.Select(collectable, x => x.t); }
public static StageOutput<Pair<K, X>, T> LocalTimeReduce<A, X, R, S, K, I, T>( this StageOutput<I, T> port, Func<I, K> key, Func<I, R> val, Func<A> factory, string name, Expression<Func<I, int>> inPlacement, Expression<Func<Pair<K, X>, int>> outPlacement) where A : IReducer<X, R, S> where T : Time<T> { return UnaryStreamingShard<I, Pair<K, X>, T>.MakeStage(port, (i, v) => new LocalTimeKeyedReduceShard<A, X, R, S, K, I, T>(i, v, key, val, factory), inPlacement, outPlacement, name); }
public static StageOutput<Pair<K, S>, T> LocalTimeCombine<A, X, R, S, K, T>( this StageOutput<Pair<K, X>, T> port, Func<A> factory, string name, Expression<Func<Pair<K, S>, int>> outPlacement) where A : IReducer<X, R, S> where T : Time<T> { Expression<Func<Pair<K, X>, int>> inPlacement = null; if (outPlacement != null) { inPlacement = x => x.s.GetHashCode(); } return UnaryStreamingShard<Pair<K, X>, Pair<K, S>, T>.MakeStage(port, (i, v) => new LocalTimeKeyedCombineShard<A, X, R, S, K, T>(i, v, factory), inPlacement, outPlacement, name); }
public static StageOutput<R, T> SelectMany<S, R, T>(this StageOutput<S, T> stream, Func<S, IEnumerable<R>> function) where T : Time<T> { return UnaryStreamingShard<S, R, T>.MakeStage(stream, (i, v) => new SelectManyShard<S, R, T>(i, v, function), null, null, "SelectMany"); }
public static StageOutput<S, T> Where<S, T>(this StageOutput<S, T> stream, Func<S, bool> predicate) where T : Time<T> { return UnaryStreamingShard<S, S, T>.MakeStage(stream, (i, v) => new Where<S, T>(i, v, predicate), stream.PartitionedBy, stream.PartitionedBy, "Where"); }
public static StageOutput<R, T> ShardSelect<S, R, T>(this StageOutput<S, T> stream, Func<int, S, R> function) where T : Time<T> { return UnaryStreamingShard<S, R, T>.MakeStage(stream, (i, v) => new ShardSelect<S, R, T>(i, v, function), null, null, "ShardSelect"); }
public static StageOutput<S, T> LocalCombine<A, X, R, S, T>(this StageOutput<X, T> port, Func<A> factory, string name) where A : IReducer<X, R, S> where T : Time<T> { return UnaryStreamingShard<X, S, T>.MakeStage(port, (i, v) => new LocalCombineShard<A, X, R, S, T>(i, v, factory), null, null, name); }