Пример #1
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void Mark()
        {
            // We read one KV pair in advance in hasNext.
            // If hasNext has read the next KV pair from a new segment, but the
            // user has not called next() for that KV, then reset the readSegmentIndex
            // to the previous segment
            if (nextKVOffset == 0)
            {
                System.Diagnostics.Debug.Assert((readSegmentIndex != 0));
                System.Diagnostics.Debug.Assert((currentKVOffset != 0));
                readSegmentIndex--;
            }
            // just drop segments before the current active segment
            int i = 0;
            IEnumerator <Merger.Segment <K, V> > itr = segmentList.GetEnumerator();

            while (itr.HasNext())
            {
                Merger.Segment <K, V> s = itr.Next();
                if (i == readSegmentIndex)
                {
                    break;
                }
                s.Close();
                itr.Remove();
                i++;
                Log.Debug("Dropping a segment");
            }
            // FirstSegmentOffset is the offset in the current segment from where we
            // need to start reading on the next reset
            firstSegmentOffset = currentKVOffset;
            readSegmentIndex   = 0;
            Log.Debug("Setting the FirsSegmentOffset to " + currentKVOffset);
        }
Пример #2
0
            /// <exception cref="System.IO.IOException"/>
            private void AdjustPriorityQueue(Merger.Segment <K, V> reader)
            {
                long startPos = reader.GetReader().bytesRead;
                bool hasNext  = reader.NextRawKey();
                long endPos   = reader.GetReader().bytesRead;

                totalBytesProcessed += endPos - startPos;
                mergeProgress.Set(totalBytesProcessed * progPerByte);
                if (hasNext)
                {
                    AdjustTop();
                }
                else
                {
                    Pop();
                    reader.Close();
                }
            }