/// <summary>
        /// Creates a new input for this stage, with the given <paramref name="partitioning"/> requirement.
        /// </summary>
        /// <typeparam name="TRecord">The record type.</typeparam>
        /// <typeparam name="TTime">The time type.</typeparam>
        /// <param name="stream">The stream from which this input will receive records.</param>
        /// <param name="partitioning">Function that maps records to integers, implying the requirement that all records
        /// mapping to the same integer must be processed by the same <see cref="Vertex"/>.</param>
        /// <returns>An object that represents the stage input.</returns>
        public StageInput <TRecord, TTime> NewInput <TRecord, TTime>(Stream <TRecord, TTime> stream, Expression <Func <TRecord, int> > partitioning)
            where TTime : Time <TTime>
        {
            if (inputsSealed)
            {
                throw new Exception("Inputs for a stage may not be added after outputs");
            }

            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            var result = new StageInput <TRecord, TTime>(this, partitioning);

            if (partitioning != null)
            {
                var compiled = partitioning.Compile();
                Action <TRecord[], int[], int> vectoredPartitioning = (data, dsts, len) => { for (int i = 0; i < len; i++)
                                                                                             {
                                                                                                 dsts[i] = compiled(data[i]);
                                                                                             }
                };

                this.InternalComputation.Connect(stream.StageOutput, result, vectoredPartitioning, Channel.Flags.None);
            }
            else
            {
                this.InternalComputation.Connect(stream.StageOutput, result, null, Channel.Flags.None);
            }

            return(result);
        }
Beispiel #2
0
        internal StageInput <R, T> NewUnconnectedInput <R, T>(Expression <Func <R, int> > partitioning)
            where T : Time <T>
        {
            if (inputsSealed)
            {
                throw new Exception("Inputs for a stage may not be added after outputs");
            }

            var result = new StageInput <R, T>(this, partitioning);

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new input for this stage, with the given <paramref name="partitioning"/> requirement.
        /// </summary>
        /// <typeparam name="TRecord">The record type.</typeparam>
        /// <typeparam name="TTime">The time type.</typeparam>
        /// <param name="stream">The stream from which this input will receive records.</param>
        /// <param name="partitioning">Function that maps records to integers, implying the requirement that all records
        /// mapping to the same integer must be processed by the same <see cref="Vertex"/>.</param>
        /// <returns>An object that represents the stage input.</returns>
        public StageInput <TRecord, TTime> NewInput <TRecord, TTime>(Stream <TRecord, TTime> stream, Expression <Func <TRecord, int> > partitioning)
            where TTime : Time <TTime>
        {
            if (inputsSealed)
            {
                throw new Exception("Inputs for a stage may not be added after outputs");
            }

            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            var result = new StageInput <TRecord, TTime>(this, partitioning);

            this.InternalComputation.Connect(stream.StageOutput, result, partitioning, Channel.Flags.None);

            return(result);
        }
Beispiel #4
0
 public void Connect <S, T>(Dataflow.StageOutput <S, T> stream, Dataflow.StageInput <S, T> recvPort)
     where T : Time <T>
 {
     this.Connect(stream, recvPort, null, Channel.Flags.None);
 }
Beispiel #5
0
 public void Connect <S, T>(Dataflow.StageOutput <S, T> stream, Dataflow.StageInput <S, T> recvPort, Action <S[], int[], int> key)
     where T : Time <T>
 {
     this.Connect(stream, recvPort, key, Channel.Flags.None);
 }
Beispiel #6
0
 public void Connect <S, T>(Dataflow.StageOutput <S, T> stream, Dataflow.StageInput <S, T> recvPort, Action <S[], int[], int> key, Channel.Flags flags)
     where T : Time <T>
 {
     stream.ForStage.Targets.Add(new Dataflow.Edge <S, T>(stream, recvPort, key, flags));
 }
Beispiel #7
0
 public void Connect <S, T>(Dataflow.StageOutput <S, T> stream, Dataflow.StageInput <S, T> recvPort, Expression <Func <S, int> > key)
     where T : Time <T>
 {
     this.Connect(stream, recvPort, key, Channel.Flags.None);
 }