Exemple #1
0
        public static RangeCollection Union(this RangeCollection rangeCollection1, RangeCollection rangeCollection2)
        {
            RangeCollection result = new RangeCollection(rangeCollection1);

            result.AddRangeCollection(rangeCollection2);
            return(result);
        }
Exemple #2
0
 public void Add(RangeCollection rowCollection)
 {
     lock (_lockObj)
     {
         _rangePendingCheckin.AddRangeCollection(rowCollection);
         if (_rangePendingCheckin.Count() >= _bufferSize)
         {
             NonBlockingFlush();
         }
     }
 }
Exemple #3
0
        //!!!could the begin and last be removed and just use long.MinValue, etc????
        public static RangeCollection Except(this RangeCollection rangeCollectionMain, RangeCollection rangeCollectionToSubtract, long fullRangeBegin, long fullRangeLast)
        {
            if (rangeCollectionToSubtract.IsEmpty)
            {
                return(rangeCollectionMain);
            }
            RangeCollection rangeCollection = rangeCollectionMain.Complement(fullRangeBegin, fullRangeLast);

            rangeCollection.AddRangeCollection(rangeCollectionToSubtract);
            RangeCollection result = rangeCollection.Complement(fullRangeBegin, fullRangeLast);

            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Only call this in a lock...
        /// </summary>
        private bool AsynchronousAddRangeToStream(RangeCollection itemsToAdd, int itemCount)
        {
            string          completedRanges          = null;
            RangeCollection completedRangeCollection = null;

            //StreamReader reader = null;
            //StreamWriter writer = null;
            try
            {
                //reader = new StreamReader(rangeFileStream);
                //completedRanges = reader.ReadToEnd();
                completedRanges          = _sharedRangeFile.ReadAll().Trim();
                completedRangeCollection = completedRanges.Length == 0 ? new RangeCollection() : RangeCollection.Parse(completedRanges);
                Console.WriteLine("Range read from file: {0}", completedRangeCollection);

                completedRangeCollection.AddRangeCollection(itemsToAdd);

                //rangeFileStream.SetLength(0);
                //writer = new StreamWriter(rangeFileStream);
                //writer.Write(completedRangeCollection);
                //writer.Flush();

                _sharedRangeFile.Clear();
                _sharedRangeFile.Write(completedRangeCollection);

                Console.WriteLine("Range {0} complete to {1} items? {2}", completedRangeCollection, itemCount, completedRangeCollection.IsComplete(itemCount));
                return(completedRangeCollection.IsComplete(itemCount));
            }
            catch (Exception)
            {
                Console.WriteLine("ERROR: Trouble adding range.");
                Console.WriteLine("read from file: {0}", completedRanges);
                Console.WriteLine("new range: {0}", itemsToAdd);
                Console.WriteLine("combined: {0}", completedRangeCollection);

                throw;
            }
        }