示例#1
0
        /// <summary>
        ///		After top reader returned last data item in a file
        /// </summary>
        private void OnTopReaderFileFinished()
        {
            if (!this.TopReader.EndReached)
            {
                if (_onlineQueue.First.Next == null ||
                    TimestampComparer.Compare(
                        _onlineQueue.First.Next.Value.CurrentItem.DateTime
                        , TopReader.NextFileFirstTimestampToRead.Value) >= 0)
                {
                    // there's no next reader or it contains older or equal item as the first item in
                    // the top reader's next file
                    // second in the queue must remain second; load next data file in the top reader
                    TopReader.LoadNextFile();

                    // update may be required because if data item timestamps are equal the DataItemComparer may change the order
                    UpdateTopReaderPosition();
                }
                else
                {
                    // second reader is present and it has to move to the top
                    MoveTopReaderToOfflineQueue();
                }
            }
            else
            {
                MoveTopReaderToExhaustedList();
            }
        }
示例#2
0
        /// <summary>
        ///		Read next available data item
        /// </summary>
        /// <returns>
        ///		<see cref="IDataItemRead"/>
        ///		<see langword="null"/> if the end is reached (<see cref="HasData"/> will return <see langword="false"/>)
        /// </returns>
        /// <remarks>
        ///		The order of data items coming from multiple folders is guaranteed only if item timestamps are different.
        ///		If more than one folder being read contains data item with a particular timestamp
        ///		the order in which those data items are read may change next time you read same data from those same folders.
        ///		Use <see cref="IRepositoryFolder.LastTimestamp"/> to position precisely every single data source.
        ///		<seealso cref="IRepositoryReader.GetLastItemTimestamp"/>
        ///		<seealso cref="IDataItemRead.RepositoryFolder"/>
        /// </remarks>
        /// <exception cref="ObjectDisposedException">
        ///		The reader has been disposed.
        /// </exception>
        public IDataItemRead Read()
        {
            CheckNotDisposed();
            IDataItemRead retval = null;

            if (this.HasData)
            {
                retval = new DataItemRead
                {
                    DataItem         = TopReader.CurrentItem,
                    RepositoryFolder = TopReader.TargetFolder
                };

                TopReader.UpdatePosition();
                _position.Update(retval.DataItem);

                MoveTopReaderToNextItem();
            }
            return(retval);
        }