Example #1
0
        /// <summary>
        /// Start building state for a BatchRangeSet.
        /// call sequence should be:
        ///      StartBuildingBatchRangeSet( prevRs )
        ///      AddSyncId(Sid)
        ///      ...
        ///      AddSyncId(Sid)
        ///      StartNextTable( tname )
        ///      AddSyncId(Sid)
        ///      result = FinishBuildingBatchRangeSet()
        ///
        /// Note that this implicitly starts the range with the end of
        /// prevRS+1
        /// ***** We don't track the prevRS internally because we want to be able
        /// ***** to rebuild a rangeset from scratch if we for
        /// ***** instance change the batching limits
        /// </summary>
        /// <param name="prevRS">
        /// The prev rangeset that was built.
        /// </param>
        public void StartBuildingBatchRangeSet(BatchRangeSet prevRS)
        {
            Debug.Assert(_inProgressRS == null);

            BatchRange prevLast = prevRS.Last;

            _inProgressRS = new BatchRangeSet();

            // check that this rangeset was not built as the last
            // rangeset for a knowledge.
            Debug.Assert(prevLast.End != _tableRanges[prevLast.TableName].End);

            // was the end of the last range usable?
            if (!prevLast.RangeIsUsable)
            {
                Debug.Assert(prevLast.TableName != null);
                Debug.Assert(prevLast.Start != null);
                // if the prev range moved to the current table but did
                // not have any rows then we are starting the table again.
                // just take the unusable range as our own
                _inProgressRS.Add(new BatchRange(prevLast));
            }
            else
            {
                // We have a started the current table already
                // So continue from one greater than the last range
                BatchRange nextRange = new BatchRange();
                nextRange.TableName = prevLast.TableName;
                nextRange.Start     = IdPlusOne(_idFormat, prevLast.End);
                // leave End as null
                _inProgressRS.Add(nextRange);
            }
        }
Example #2
0
        // adds range for given table to current range set
        private void AppendNewTableRange(string tableName)
        {
            // take the predetermined start range for the current
            // table and leave the current range in an unusable state
            // until the first row is added or this table ends
            BatchRange nextRange = new BatchRange();

            nextRange.TableName = tableName;
            nextRange.Start     = _tableRanges[tableName].Start;
            _inProgressRS.Add(nextRange);
        }
Example #3
0
        /// <summary>
        /// Start building state for a BatchRangeSet.
        /// call sequence should be:
        ///      StartBuildingBatchRangeSet( prevRs )
        ///      AddSyncId(Sid)
        ///      ...
        ///      AddSyncId(Sid)
        ///      StartNextTable( tname ) 
        ///      AddSyncId(Sid)
        ///      result = FinishBuildingBatchRangeSet()
        ///
        /// Note that this implicitly starts the range with the end of
        /// prevRS+1
        /// ***** We don't track the prevRS internally because we want to be able
        /// ***** to rebuild a rangeset from scratch if we for
        /// ***** instance change the batching limits
        /// </summary>
        /// <param name="prevRS"> 
        /// The prev rangeset that was built.
        /// </param>
        public void StartBuildingBatchRangeSet( BatchRangeSet prevRS )
        {
            Debug.Assert( _inProgressRS == null );

            BatchRange prevLast = prevRS.Last;
            _inProgressRS = new BatchRangeSet();

            // check that this rangeset was not built as the last
            // rangeset for a knowledge. 
            Debug.Assert( prevLast.End != _tableRanges[prevLast.TableName].End );

            // was the end of the last range usable?
            if( !prevLast.RangeIsUsable ) 
            {
                Debug.Assert( prevLast.TableName != null );
                Debug.Assert( prevLast.Start != null );
                // if the prev range moved to the current table but did
                // not have any rows then we are starting the table again.
                // just take the unusable range as our own
                _inProgressRS.Add(new BatchRange(prevLast));
            }
            else 
            {
                // We have a started the current table already 
                // So continue from one greater than the last range
                BatchRange nextRange = new BatchRange();
                nextRange.TableName = prevLast.TableName;
                nextRange.Start = IdPlusOne( _idFormat, prevLast.End );
                // leave End as null
                _inProgressRS.Add( nextRange );
            }
        }