Example #1
0
        public PartitionedSnapshotWindowHoppingPipe(
            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();
            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());
            this.hopsPerDuration = (int)(stream.Source.Properties.ConstantDurationLength.Value / stream.Source.Properties.ConstantHopLength) + 1;
        }
Example #2
0
        public PartitionedStitchPipe(IStreamable <TKey, TPayload> stream, IStreamObserver <TKey, TPayload> observer)
            : base(stream, observer)
        {
            this.errorMessages = stream.ErrorMessages;
            this.outputCount   = 0;
            this.pool          = MemoryManager.GetMemoryPool <TKey, TPayload>(stream.Properties.IsColumnar);
            this.pool.Get(out this.batch);
            this.batch.Allocate();

            var khpcomparer = EqualityComparerExtensions.GetCompoundEqualityComparerExpression <KHP, TKey, TPayload>(
                e => e.Key, stream.Properties.KeyEqualityComparer,
                e => e.Payload, stream.Properties.PayloadEqualityComparer);
            var equals      = khpcomparer.GetEqualsExpr().Compile();
            var getHashCode = khpcomparer.GetGetHashCodeExpr().Compile();

            var generator1 = khpcomparer.CreateFastDictionary2Generator <KHP, List <ActiveEvent> >(1, equals, getHashCode, stream.Properties.QueryContainer);

            this.dictPool = new DataStructurePool <FastDictionary2 <KHP, List <ActiveEvent> > >(() => generator1.Invoke());

            var generator2 = khpcomparer.CreateFastDictionary2Generator <KHP, int>(1, equals, getHashCode, stream.Properties.QueryContainer);

            this.CurrentTimeOpenEventBufferGenerator = () => generator2.Invoke();

            var generator3 = khpcomparer.CreateFastDictionary2Generator <KHP, List <ActiveEventExt> >(1, equals, getHashCode, stream.Properties.QueryContainer);

            this.OpenEventsGenerator = () => generator3.Invoke();
        }
        public StitchAggregatePipe(StitchAggregateStreamable <TKey, TPayload, TState, TResult> stream,
                                   IStreamObserver <TKey, TResult> observer)
            : base(stream, observer)
        {
            this.errorMessages = stream.ErrorMessages;
            this.pool          = MemoryManager.GetMemoryPool <TKey, TResult>(stream.Properties.IsColumnar);
            this.pool.Get(out this.batch);
            this.batch.Allocate();

            this.aggregate     = stream.aggregate;
            this.initialState  = this.aggregate.InitialState().Compile();
            this.accumulate    = this.aggregate.Accumulate().Compile();
            this.computeResult = this.aggregate.ComputeResult().Compile();

            var khpcomparer = EqualityComparerExtensions.GetEqualityComparerExpression <KHP, TKey>(
                e => e.Key, stream.Properties.KeyEqualityComparer);
            var equals      = khpcomparer.GetEqualsExpr().Compile();
            var getHashCode = khpcomparer.GetGetHashCodeExpr().Compile();
            var generator   = khpcomparer.CreateFastDictionary2Generator <KHP, List <ActiveEvent> >(1, equals, getHashCode, stream.Properties.QueryContainer);

            this.dictPool    = new DataStructurePool <FastDictionary2 <KHP, List <ActiveEvent> > >(() => generator.Invoke());
            this.outputCount = 0;
            this.CurrentTimeOpenEventBuffer = khpcomparer.CreateFastDictionary2Generator <KHP, int>(1, equals, getHashCode, stream.Properties.QueryContainer).Invoke();
            this.OpenEvents = khpcomparer.CreateFastDictionary2Generator <KHP, List <ActiveEventExt> >(1, equals, getHashCode, stream.Properties.QueryContainer).Invoke();
        }
Example #4
0
 public ImpatienceSorter()
 {
     this.Tails                 = new long[this.MaxFibers];
     this.Fibers                = new List <PooledElasticCircularBuffer <PartitionedStreamEvent <TKey, TPayload> > >();
     this.MergeSource           = new PooledElasticCircularBuffer <PartitionedStreamEvent <TKey, TPayload> > [this.MaxFibers];
     this.NextAffectingSyncTime = StreamEvent.InfinitySyncTime;
     this.ecbPool               = new DataStructurePool <PooledElasticCircularBuffer <PartitionedStreamEvent <TKey, TPayload> > >();
 }
        public PartitionedEndEdgeFreeOutputPipe(IStreamable <TKey, TPayload> stream, IStreamObserver <TKey, TPayload> observer)
            : base(stream, observer)
        {
            this.pool          = MemoryManager.GetMemoryPool <TKey, TPayload>(stream.Properties.IsColumnar);
            this.errorMessages = stream.ErrorMessages;

            var compoundEqualityExpr = EqualityComparerExtensions.GetCompoundEqualityComparerExpression <ActiveEvent, long, TKey, TPayload>(
                e => e.End, EqualityComparerExpression <long> .Default, e => e.Key, stream.Properties.KeyEqualityComparer, e => e.Payload, stream.Properties.PayloadEqualityComparer);
            var equals      = compoundEqualityExpr.GetEqualsExpr().Compile();
            var getHashCode = compoundEqualityExpr.GetGetHashCodeExpr().Compile();
            var generator   = compoundEqualityExpr.CreateFastDictionary2Generator <ActiveEvent, int>(1, equals, getHashCode, stream.Properties.QueryContainer);

            this.dictPool = new DataStructurePool <FastDictionary2 <ActiveEvent, int> >(() => generator.Invoke());
            this.pool.Get(out this.output);
            this.output.Allocate();
        }