public void TestIntervalRanges()
        {
            _ = new List <ulong>();
            SeekFilterBase <HistorianKey> pointId = TimestampSeekFilter.CreateFromIntervalData <HistorianKey>(0, 100, 10, 3, 1);

            if (!pointId.GetType().FullName.Contains("IntervalRanges"))
            {
                throw new Exception("Wrong type");
            }

            using (BinaryStream bs = new BinaryStream(allocatesOwnMemory: true))
            {
                bs.Write(pointId.FilterType);
                pointId.Save(bs);
                bs.Position = 0;

                SeekFilterBase <HistorianKey> filter = Library.Filters.GetSeekFilter <HistorianKey>(bs.ReadGuid(), bs);

                if (!filter.GetType().FullName.Contains("IntervalRanges"))
                {
                    throw new Exception("Wrong type");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Reads data from the SortedTreeEngine with the provided read options and server side filters.
        /// </summary>
        /// <param name="readerOptions">read options supplied to the reader. Can be null.</param>
        /// <param name="keySeekFilter">a seek based filter to follow. Can be null.</param>
        /// <param name="keyMatchFilter">a match based filer to follow. Can be null.</param>
        /// <returns>A stream that will read the specified data.</returns>
        public override TreeStream <TKey, TValue> Read(SortedTreeEngineReaderOptions readerOptions, SeekFilterBase <TKey> keySeekFilter, MatchFilterBase <TKey, TValue> keyMatchFilter)
        {
            if (m_reader != null)
            {
                throw new Exception("Sockets do not support concurrent readers. Dispose of old reader.");
            }

            m_stream.Write((byte)ServerCommand.Read);
            if (keySeekFilter == null)
            {
                m_stream.Write(false);
            }
            else
            {
                m_stream.Write(true);
                m_stream.Write(keySeekFilter.FilterType);
                keySeekFilter.Save(m_stream);
            }

            if (keyMatchFilter == null)
            {
                m_stream.Write(false);
            }
            else
            {
                m_stream.Write(true);
                m_stream.Write(keyMatchFilter.FilterType);
                keyMatchFilter.Save(m_stream);
            }

            if (readerOptions == null)
            {
                m_stream.Write(false);
            }
            else
            {
                m_stream.Write(true);
                readerOptions.Save(m_stream);
            }
            m_stream.Flush();


            var command = (ServerResponse)m_stream.ReadUInt8();

            switch (command)
            {
            case ServerResponse.UnhandledException:
                string exception = m_stream.ReadString();
                throw new Exception("Server UnhandledExcetion: \n" + exception);

            case ServerResponse.UnknownOrCorruptSeekFilter:
                throw new Exception("Server does not recgonize the seek filter");

            case ServerResponse.UnknownOrCorruptMatchFilter:
                throw new Exception("Server does not recgonize the match filter");

            case ServerResponse.UnknownOrCorruptReaderOptions:
                throw new Exception("Server does not recgonize the reader options");

            case ServerResponse.SerializingPoints:
                break;

            case ServerResponse.ErrorWhileReading:
                exception = m_stream.ReadString();
                throw new Exception("Server Error While Reading: \n" + exception);

            default:
                throw new Exception("Unknown server response: " + command.ToString());
            }

            m_reader = new PointReader(m_encodingMode, m_stream, () => m_reader = null);
            return(m_reader);
        }