public override void OnNext(StreamMessage <Empty, TPayload> batch)
        {
            var col_bv     = batch.bitvector.col;
            var col_vsync  = batch.vsync.col;
            var col_vother = batch.vother.col;

            for (int i = 0; i < batch.Count; i++)
            {
                if ((col_bv[i >> 6] & (1L << (i & 0x3f))) != 0 && col_vother[i] >= 0)
                {
                    continue;
                }
                else if (col_vother[i] == StreamEvent.PunctuationOtherTime)
                {
                    this.array[this.populationCount++] = StreamEvent.CreatePunctuation <TPayload>(col_vsync[i]);
                }
                else
                {
                    this.array[this.populationCount++] = new StreamEvent <TPayload>(col_vsync[i], col_vother[i], batch[i]);
                }

                if (this.populationCount == this.arrayLength)
                {
                    this.observer.OnNext(new ArraySegment <StreamEvent <TPayload> >(this.array, 0, this.arrayLength));
                    this.populationCount = 0;
                    this.array           = this.generator();
                    this.arrayLength     = this.array.Length;
                }
            }
            batch.Free();
        }
示例#2
0
 protected override void OnCompleted(long punctuationTime)
 {
     FlushContents();
     OnPunctuation(StreamEvent.CreatePunctuation <TPayload>(punctuationTime));
     if (this.flushPolicy != FlushPolicy.FlushOnPunctuation)
     {
         OnFlush();
     }
 }
示例#3
0
 private void EmitPunctuation(object state)
 {
     lock (this.sentinel)
     {
         if (this.timer != null)
         {
             var time = DateTimeOffset.UtcNow.Ticks;
             this.currentTime = Math.Max(time, this.currentTime);
             OnPunctuation(StreamEvent.CreatePunctuation <TPayload>(this.currentTime));
         }
     }
 }
示例#4
0
        public override void OnNext(ArraySegment <StreamEvent <TPayload> > value)
        {
            Contract.EnsuresOnThrow <IngressException>(true);

            int n = value.Count + value.Offset;

            // Sanity check
            if (n > value.Array.Length)
            {
                throw new IngressException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              "Invalid array segment. Offset: " + value.Offset +
                              "Count: " + value.Count +
                              "Length: " + value.Array.Length));
            }
            int offset = value.Offset;

            while (offset < n)
            {
                var full = this.currentBatch.Add(
                    value,
                    ref this.currentTime,
                    ref offset,
                    out bool hitAPunctuation);
                if (hitAPunctuation)
                {
                    var current = value.Array[offset];
                    if (current.SyncTime < this.currentTime)
                    {
                        current = StreamEvent.CreatePunctuation <TPayload>(this.currentTime);
                    }
                    System.Array.Clear(this.currentBatch.hash.col, 0, this.currentBatch.hash.col.Length);
                    OnPunctuation(current);
                    offset++;
                }
                else if (full)
                {
                    System.Array.Clear(this.currentBatch.hash.col, 0, this.currentBatch.hash.col.Length);
                    FlushContents();
                }
            }
        }
示例#5
0
        public override void OnNext(TPayload value)
        {
            Contract.EnsuresOnThrow <IngressException>(true);

            this.currentBatch.Add(this.currentTime, StreamEvent.InfinitySyncTime, Empty.Default, value);
            if (this.currentBatch.Count == Config.DataBatchSize)
            {
                FlushContents();
            }
            this.eventCount++;

            if (this.eventCount == this.eventsPerSample)
            {
                this.eventCount = 0;
                this.currentTime++;

                FlushContents();
                OnPunctuation(StreamEvent.CreatePunctuation <TPayload>(this.currentTime));
            }
        }
示例#6
0
        public override void OnNext(ArraySegment <StreamEvent <TPayload> > value)
        {
            Contract.EnsuresOnThrow <IngressException>(true);

            int n = value.Count + value.Offset;

            if (n > value.Array.Length)
            {
                throw new IngressException(
                          $"Invalid array segment. Offset: {value.Offset} Count: {value.Count} Length: {value.Array.Length}");
            }

            int offset = value.Offset;

            while (offset < n)
            {
                var full = this.currentBatch.Add(
                    value,
                    ref this.currentTime,
                    ref offset,
                    out bool hitAPunctuation);
                if (hitAPunctuation)
                {
                    var current = value.Array[offset];
                    if (current.SyncTime < this.currentTime)
                    {
                        current = StreamEvent.CreatePunctuation <TPayload>(this.currentTime);
                    }
                    Array.Clear(this.currentBatch.hash.col, 0, this.currentBatch.hash.col.Length);
                    OnPunctuation(current);
                    offset++;
                }
                else if (full)
                {
                    Array.Clear(this.currentBatch.hash.col, 0, this.currentBatch.hash.col.Length);
                    FlushContents();
                }
            }
        }
示例#7
0
        public override void OnNext(StreamMessage <Empty, TPayload> batch)
        {
            var col_bv     = batch.bitvector.col;
            var col_vsync  = batch.vsync.col;
            var col_vother = batch.vother.col;

            for (int i = 0; i < batch.Count; i++)
            {
                if ((col_bv[i >> 6] & (1L << (i & 0x3f))) != 0 && col_vother[i] >= 0)
                {
                    continue;
                }
                else if (col_vother[i] == StreamEvent.PunctuationOtherTime)
                {
                    this.observer.OnNext(StreamEvent.CreatePunctuation <TPayload>(col_vsync[i]));
                }
                else
                {
                    this.observer.OnNext(new StreamEvent <TPayload>(col_vsync[i], col_vother[i], col_vother[i] >= 0 ? batch[i] : default));
                }
            }
            batch.Free();
        }
示例#8
0
 protected override void OnCompleted(long punctuationTime)
 {
     OnNext(new ArraySegment <StreamEvent <TPayload> >(new[] { StreamEvent.CreatePunctuation <TPayload>(punctuationTime) }));
 }
 protected override void OnCompleted(long punctuationTime)
 {
     FlushContents();
     OnPunctuation(StreamEvent.CreatePunctuation <TPayload>(punctuationTime));
 }