示例#1
0
        public SnapshotWindowSlidingPipe(
            SnapshotWindowStreamable <TKey, TInput, TState, TOutput> stream,
            IStreamObserver <TKey, TOutput> observer)
            : base(stream, observer)
        {
            this.aggregate         = stream.Aggregate;
            this.initialStateExpr  = this.aggregate.InitialState();
            this.initialState      = this.initialStateExpr.Compile();
            this.accumulateExpr    = this.aggregate.Accumulate();
            this.accumulate        = this.accumulateExpr.Compile();
            this.deaccumulateExpr  = this.aggregate.Deaccumulate();
            this.deaccumulate      = this.deaccumulateExpr.Compile();
            this.differenceExpr    = this.aggregate.Difference();
            this.difference        = this.differenceExpr.Compile();
            this.computeResultExpr = this.aggregate.ComputeResult();
            this.computeResult     = this.computeResultExpr.Compile();

            var comparer = stream.Properties.KeyEqualityComparer;

            this.keyComparerEqualsExpr      = comparer.GetEqualsExpr();
            this.keyComparerEquals          = this.keyComparerEqualsExpr.Compile();
            this.keyComparerGetHashCodeExpr = comparer.GetGetHashCodeExpr();
            this.keyComparerGetHashCode     = this.keyComparerGetHashCodeExpr.Compile();

            this.errorMessages = stream.ErrorMessages;
            this.pool          = MemoryManager.GetMemoryPool <TKey, TOutput>(false);
            this.pool.Get(out this.batch);
            this.batch.Allocate();

            this.aggregateByKey = comparer.CreateFastDictionary2Generator <TKey, HeldState <TState> >(1, this.keyComparerEquals, this.keyComparerGetHashCode, stream.Properties.QueryContainer).Invoke();
            this.ecq            = new ElasticCircularBuffer <EcqState>();
            var stateDictGenerator = comparer.CreateFastDictionaryGenerator <TKey, StateAndActive <TState> >(1, this.keyComparerEquals, this.keyComparerGetHashCode, stream.Properties.QueryContainer);

            this.ecqEntryPool = new DataStructurePool <FastDictionary <TKey, StateAndActive <TState> > >(() => stateDictGenerator.Invoke());
        }
示例#2
0
        public SnapshotWindowSlidingPipeSimple(
            SnapshotWindowStreamable <Empty, TInput, TState, TOutput> stream,
            IStreamObserver <Empty, TOutput> observer)
            : base(stream, observer)
        {
            this.aggregate         = stream.Aggregate;
            this.initialStateExpr  = this.aggregate.InitialState();
            this.initialState      = this.initialStateExpr.Compile();
            this.accumulateExpr    = this.aggregate.Accumulate();
            this.accumulate        = this.accumulateExpr.Compile();
            this.deaccumulateExpr  = this.aggregate.Deaccumulate();
            this.deaccumulate      = this.deaccumulateExpr.Compile();
            this.differenceExpr    = this.aggregate.Difference();
            this.difference        = this.differenceExpr.Compile();
            this.computeResultExpr = this.aggregate.ComputeResult();
            this.computeResult     = this.computeResultExpr.Compile();

            this.errorMessages = stream.ErrorMessages;
            this.pool          = MemoryManager.GetMemoryPool <Empty, TOutput>(false);
            this.pool.Get(out this.batch);
            this.batch.Allocate();

            this.ecq = new ElasticCircularBuffer <HeldState <TState> >();
        }