コード例 #1
0
        private void Process(long timestamp)
        {
            while (true)
            {
                if (!this.toDelete.TryGetFirst(out long currentTime, out List <TPayload> queue))
                {
                    break;
                }

                if (currentTime < timestamp)
                {
                    foreach (var item in queue)
                    {
                        this.currentVersion.Add(ChangeListEvent.CreateDeletion(item));
                    }

                    this.toDelete.Remove(currentTime);
                }
                else
                {
                    break;
                }
            }

            if (timestamp > this.currentTimestamp)
            {
                this.currentTimestamp = timestamp;
                if (this.currentVersion.Count > 0)
                {
                    this.observer.OnNext(this.currentVersion);
                    this.currentVersion = new List <ChangeListEvent <TPayload> >();
                }
            }
        }
コード例 #2
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++)
            {
                var currentSync = col_vsync[i];
                Process(currentSync);

                if ((col_bv[i >> 6] & (1L << (i & 0x3f))) != 0)
                {
                    continue;
                }
                if (col_vother[i] == StreamEvent.InfinitySyncTime)
                {
                    // Start edge: create an insertion event
                    this.currentVersion.Add(ChangeListEvent.CreateInsertion(batch[i]));
                }
                else if (currentSync < col_vother[i])
                {
                    // Interval: create an insertion event now, and a deletion later when time progresses
                    this.currentVersion.Add(ChangeListEvent.CreateInsertion(batch[i]));
                    EnqueueDelete(col_vother[i], batch[i]);
                }
                else
                {
                    // End edge: create a deletion event
                    this.currentVersion.Add(ChangeListEvent.CreateDeletion(batch[i]));
                }
            }

            batch.Free();
        }