Ejemplo n.º 1
0
 public override void Skip()
 {
     if (readState == ReadState.Interactive)
     {
         MoveToElement();
         objectIterator.MoveNext();
         ReadCurrentPosition();
     }
 }
Ejemplo n.º 2
0
        public List <InternalObject> ReadAllObjectsIncremental(InternalObject[] oldObjects, List <UnchangedSegment> reuseMap, CancellationToken cancellationToken)
        {
            ObjectIterator oldObjectIterator = new ObjectIterator(oldObjects);
            int            reuseMapIndex     = 0;

            while (reuseMapIndex < reuseMap.Count)
            {
                var reuseEntry = reuseMap[reuseMapIndex];
                while (this.CurrentLocation < reuseEntry.NewOffset)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    ReadObject();
                }
                if (this.CurrentLocation >= reuseEntry.NewOffset + reuseEntry.Length)
                {
                    reuseMapIndex++;
                    continue;
                }
                Debug.Assert(reuseEntry.NewOffset <= this.CurrentLocation && this.CurrentLocation < reuseEntry.NewOffset + reuseEntry.Length);
                // reuse the nodes within this reuseEntry starting at oldOffset:
                int oldOffset = this.CurrentLocation - reuseEntry.NewOffset + reuseEntry.OldOffset;
                // seek to oldOffset in the oldObjects array:
                oldObjectIterator.SkipTo(oldOffset);
                if (oldObjectIterator.CurrentPosition == oldOffset)
                {
                    // reuse old objects within this reuse entry:
                    int reuseEnd = reuseEntry.OldOffset + reuseEntry.Length;
                    while (oldObjectIterator.CurrentObject != null && oldObjectIterator.CurrentPosition + oldObjectIterator.CurrentObject.LengthTouched < reuseEnd)
                    {
                        StoreObject(oldObjectIterator.CurrentObject);
                        Skip(oldObjectIterator.CurrentObject.Length);
                        oldObjectIterator.MoveNext();
                    }
                    reuseMapIndex++;                     // go to next re-use map
                }
                else
                {
                    // We are in a region where old objects are available, but aren't aligned correctly.
                    // Don't skip this reuse entry, and read a single object so that we can re-align
                    ReadObject();
                }
            }
            while (HasMoreData())
            {
                cancellationToken.ThrowIfCancellationRequested();
                ReadObject();
            }
            return(objects);
        }
Ejemplo n.º 3
0
		public List<InternalObject> ReadAllObjectsIncremental(InternalObject[] oldObjects, List<UnchangedSegment> reuseMap, CancellationToken cancellationToken)
		{
			ObjectIterator oldObjectIterator = new ObjectIterator(oldObjects);
			int reuseMapIndex = 0;
			while (reuseMapIndex < reuseMap.Count) {
				var reuseEntry = reuseMap[reuseMapIndex];
				while (this.CurrentLocation < reuseEntry.NewOffset) {
					cancellationToken.ThrowIfCancellationRequested();
					ReadObject();
				}
				if (this.CurrentLocation >= reuseEntry.NewOffset + reuseEntry.Length) {
					reuseMapIndex++;
					continue;
				}
				Debug.Assert(reuseEntry.NewOffset <= this.CurrentLocation && this.CurrentLocation < reuseEntry.NewOffset + reuseEntry.Length);
				// reuse the nodes within this reuseEntry starting at oldOffset:
				int oldOffset = this.CurrentLocation - reuseEntry.NewOffset + reuseEntry.OldOffset;
				// seek to oldOffset in the oldObjects array:
				oldObjectIterator.SkipTo(oldOffset);
				if (oldObjectIterator.CurrentPosition == oldOffset) {
					// reuse old objects within this reuse entry:
					int reuseEnd = reuseEntry.OldOffset + reuseEntry.Length;
					while (oldObjectIterator.CurrentObject != null && oldObjectIterator.CurrentPosition + oldObjectIterator.CurrentObject.LengthTouched < reuseEnd) {
						StoreObject(oldObjectIterator.CurrentObject);
						Skip(oldObjectIterator.CurrentObject.Length);
						oldObjectIterator.MoveNext();
					}
					reuseMapIndex++; // go to next re-use map
				} else {
					// We are in a region where old objects are available, but aren't aligned correctly.
					// Don't skip this reuse entry, and read a single object so that we can re-align
					ReadObject();
				}
			}
			while (HasMoreData()) {
				cancellationToken.ThrowIfCancellationRequested();
				ReadObject();
			}
			return objects;
		}