Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public override IReducingState <TValue> GetReducingState <TValue>(ReducingStateDescriptor <TValue> stateProperties)
        {
            var keyedStateStore = CheckPreconditionsAndGetKeyedStateStore(stateProperties);

            stateProperties.InitializeSerializerUnlessSet(ExecutionConfig);

            return(keyedStateStore.GetReducingState(stateProperties));
        }
 public virtual IReducingState <TValue> GetReducingState <TValue>(ReducingStateDescriptor <TValue> stateProperties)
 {
     throw new NotImplementedException();
 }
 public virtual IReducingState <TValue> GetReducingState <TValue>(ReducingStateDescriptor <TValue> stateProperties)
 {
     throw new UnSupportedOperationException("This state is only accessible by functions executed on a KeyedStream");
 }
Exemplo n.º 5
0
 public override IReducingState <TValue> GetReducingState <TValue>(ReducingStateDescriptor <TValue> stateProperties)
 {
     throw new InvalidOperationException("Per-window state is not allowed when using merging windows.");
 }