예제 #1
0
        /// <summary>
        /// Applies the given window function to each window. The window function is called for each evaluation of the window for each key individually. The output of the window function is interpreted as a regular non-windowed stream.
        /// Arriving data is incrementally aggregated using the given reducer.
        /// </summary>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="reduceFunction">The reduce function that is used for incremental aggregation.</param>
        /// <param name="function">The window function.</param>
        /// <param name="resultType">Type information for the result type of the window function.</param>
        /// <returns>The data stream that is the result of applying the window function to the window.</returns>
        public SingleOutputStreamOperator <TOutput> Reduce <TOutput>(
            IReduceFunction <TElement> reduceFunction,
            IWindowFunction <TElement, TOutput, TKey, TWindow> function,
            TypeInformation <TOutput> resultType)
        {
            if (reduceFunction is IRichFunction)
            {
                throw new InvalidOperationException("ReduceFunction of reduce can not be a RichFunction.");
            }

            var env    = _input.ExecutionEnvironment;
            var config = env.ExecutionConfig;

            function       = env.Clean(function);
            reduceFunction = env.Clean(reduceFunction);

            var operatorName = GenerateOperatorName(_assigner, _trigger, _evictor, reduceFunction, function);
            var keySelector  = _input.KeySelector;

            IOneInputStreamOperator <TElement, TOutput> @operator = default;

            if (_evictor != null)
            {
            }
            else
            {
                var stateDesc = new ReducingStateDescriptor <TElement>("window-contents", reduceFunction, _input.Type.CreateSerializer(config));
            }

            return(_input.Transform(operatorName, resultType, @operator));
        }
예제 #2
0
 /// <summary>
 /// Creates a new <see cref="OneInputTransformation{TInput,TOutput}"/> from the given input and operator.
 /// </summary>
 /// <param name="input">The input <see cref="Transformation{T}"/></param>
 /// <param name="name">The name of the <see cref="Transformation{T}"/>, this will be shown in Visualizations and the Log</param>
 /// <param name="operator"></param>
 /// <param name="outputType">The type of the elements produced by this <see cref="OneInputTransformation{TInput,TOutput}"/></param>
 /// <param name="parallelism">The parallelism of this <see cref="OneInputTransformation{TInput,TOutput}"/></param>
 public OneInputTransformation(
     Transformation <TInput> input,
     string name,
     IOneInputStreamOperator <TInput, TOutput> @operator,
     TypeInformation <TOutput> outputType,
     int parallelism)
     : this(input, name, SimpleOperatorFactory <TOutput> .Of(@operator), outputType, parallelism)
 {
 }
예제 #3
0
        /// <summary>
        /// Method for passing user defined operators along with the type information that will transform the DataStream.
        /// </summary>
        /// <typeparam name="TOutput">type of the return stream</typeparam>
        /// <param name="operatorName">name of the operator, for logging purposes</param>
        /// <param name="outTypeInfo">the output type of the operator</param>
        /// <param name="operator">the object containing the transformation logic</param>
        /// <returns>type of the return stream</returns>
        public SingleOutputStreamOperator <TOutput> Transform <TOutput>(
            string operatorName,
            TypeInformation <TOutput> outTypeInfo,
            IOneInputStreamOperator <TElement, TOutput> @operator)
        {
            var resultTransform = new OneInputTransformation <TElement, TOutput>(Transformation, operatorName, @operator, outTypeInfo, ExecutionEnvironment.Parallelism);
            var returnStream    = new SingleOutputStreamOperator <TOutput>(ExecutionEnvironment, resultTransform);

            ExecutionEnvironment.AddOperator(resultTransform);

            return(returnStream);
        }