示例#1
0
        public void TestNonSequential(int pointCount, bool verify)
        {
            SortedPointBuffer <HistorianKey, HistorianValue> points = new SortedPointBuffer <HistorianKey, HistorianValue>(pointCount, true);

            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            for (int x = 0; x < pointCount; x++)
            {
                key.PointID = (ulong)x;
                points.TryEnqueue(key, value);
            }

            points.IsReadingMode = true;

            File.Delete(@"C:\Temp\fileTemp.~d2i");
            File.Delete(@"C:\Temp\fileTemp.d2i");

            SortedTreeFileSimpleWriter <HistorianKey, HistorianValue> .CreateNonSequential(@"C:\Temp\fileTemp.~d2i", @"C:\Temp\fileTemp.d2i", 4096, null, EncodingDefinition.FixedSizeCombinedEncoding, points);

            if (!verify)
            {
                return;
            }
            using (SortedTreeFile file = SortedTreeFile.OpenFile(@"C:\Temp\fileTemp.d2i", true))
                using (SortedTreeTable <HistorianKey, HistorianValue> table = file.OpenTable <HistorianKey, HistorianValue>())
                    using (SortedTreeTableReadSnapshot <HistorianKey, HistorianValue> read = table.AcquireReadSnapshot().CreateReadSnapshot())
                        using (SortedTreeScannerBase <HistorianKey, HistorianValue> scanner = read.GetTreeScanner())
                        {
                            scanner.SeekToStart();
                            int cnt = 0;
                            while (scanner.Read(key, value))
                            {
                                if (key.PointID != (ulong)cnt)
                                {
                                    throw new Exception();
                                }
                                cnt++;
                            }
                            if (cnt != pointCount)
                            {
                                throw new Exception();
                            }
                        }
        }