public override ISourceBlock <TOutput> TransformDataFlows(ISourceBlock <DataflowCalculation <TInput, TOutput, TDataflowOperator> > dataflows)
 {
     return(dataflows
            .GroupBy(dataflow => dataflow.Operator.Type)
            .SelectMany(group => PerformOperatorTyped(group.Key, group))
            .TransformDataflows());
 }
 public override ISourceBlock <IList <T> > TransformDataFlows(ISourceBlock <Buffer <T> > dataflows)
 {
     return(dataflows
            .GroupBy(item => new { item.BatchMaxSize, item.BatchTimeout })
            .SelectMany(group => group
                        .Select(item => item.Item)
                        .Buffer(group.Key.BatchTimeout, group.Key.BatchMaxSize)));
 }
예제 #3
0
 public static ISourceBlock <Either <TLeft, TRightOutput> > SelectManySafe <TLeft, TRightInput, TRightOutput>(
     this ISourceBlock <Either <TLeft, TRightInput> > source, Func <TRightInput, ISourceBlock <Either <TLeft, TRightOutput> > > selector)
 {
     return(source
            .GroupBy(item => item.IsRight)
            .SelectMany(group => group.Key
             ? group.SelectMany(item => selector(item.GetRightSafe()))
             : group.Select(item => Left <TLeft, TRightOutput>(item.GetLeftSafe()))));
 }
 public override ISourceBlock <IGroupedDataflow <TKey, TElement> > TransformDataFlows(ISourceBlock <Group <TKey, TElement> > dataflows)
 {
     return(dataflows
            .GroupBy(item => item.KeySelector)
            .SelectMany(group => group
                        .GroupBy(item => new { Key = group.Key(item.Item), Factory = item.Factory })
                        .Select(innerGroup =>
                                ((DataflowFactory)innerGroup.Key.Factory).CreateGroupedDataflow(
                                    innerGroup.Key.Key, innerGroup.Select(item => item.Item)))));
 }
 public override ISourceBlock <IDataflow <TOutput> > PerformOperator <TOutput>(
     ISourceBlock <DataflowCalculation <IList <T>, TOutput, Buffer <T> > > calculationDataflows)
 {
     return(calculationDataflows
            .GroupBy(dataflow => new
     {
         dataflow.Operator.BatchMaxSize,
         dataflow.Operator.BatchTimeout
     })
            .SelectMany(group => group.Buffer(group.Key.BatchTimeout, group.Key.BatchMaxSize))
            .Where(batch => batch.Count > 0)
            .Select(batch =>
                    batch[0].Continuation(batch.Select(item => item.Operator.Item).ToList())));
 }
예제 #6
0
 public static ISourceBlock <Either <TLeft, GroupedSourceBlock <TKey, TRight> > > GroupBySafe <TLeft, TRight, TKey>(
     this ISourceBlock <Either <TLeft, TRight> > source, Func <TRight, TKey> keySelector)
 {
     return(source
            .GroupBy(item => item.IsRight)
            .SelectMany(
                group => group.Key
                 ? group
                .SelectMany(item => item.RightAsEnumerable())
                .GroupBy(keySelector)
                .Select(Right <TLeft, GroupedSourceBlock <TKey, TRight> >)
                 : group
                .SelectMany(item => item.LeftAsEnumerable())
                .Select(Left <TLeft, GroupedSourceBlock <TKey, TRight> >)));
 }
 public override ISourceBlock <IDataflow <TOutput> > PerformOperator <TOutput>(ISourceBlock <DataflowCalculation <IGroupedDataflow <TKey, TElement>, TOutput, Group <TKey, TElement> > > calculationDataflows)
 {
     return(calculationDataflows
            .GroupBy(item => item.Operator.KeySelector)
            .SelectMany(group => group
                        .GroupBy(item => new
     {
         Key = group.Key(item.Operator.Item),
         Continuation = item.Continuation,
         Factory = item.Factory
     })
                        .Select(innerGroup => innerGroup.Key.Continuation(
                                    ((DataflowFactory)innerGroup.Key.Factory).CreateGroupedDataflow(
                                        innerGroup.Key.Key, innerGroup.Select(item => item.Operator.Item))))));
 }
 private static ISourceBlock <TOutput> TransformDataflows <TOutput>(this ISourceBlock <IDataflow <TOutput> > dataflows)
 {
     return(dataflows
            .GroupBy(dataflow => dataflow.Type)
            .SelectMany(group => TransformDataflowsByType(group.Key, group)));
 }