示例#1
0
        public void TestFile()
        {
            //		FilePath	"C:\\Temp\\Historian\\635287587300536177-Stage1-d559e63e-d938-46a9-8d57-268f7c8ba194.d2"	string
            //635329017197429979-Stage1-38887e11-4097-4937-b269-ce4037157691.d2
            //using (var file = SortedTreeFile.OpenFile(@"C:\Temp\Historian\635287587300536177-Stage1-d559e63e-d938-46a9-8d57-268f7c8ba194.d2", true))
            using (SortedTreeFile file = SortedTreeFile.OpenFile(@"C:\Archive\635329017197429979-Stage1-38887e11-4097-4937-b269-ce4037157691.d2", true))
                //using (var file = SortedTreeFile.OpenFile(@"C:\Temp\Historian\635255664136496199-Stage2-6e758046-b2af-40ff-ae4e-85cd0c0e4501.d2", true))
                using (SortedTreeTable <HistorianKey, HistorianValue> table = file.OpenTable <HistorianKey, HistorianValue>())
                    using (SortedTreeTableReadSnapshot <HistorianKey, HistorianValue> reader = table.BeginRead())
                    {
                        SortedTreeScannerBase <HistorianKey, HistorianValue> scanner = reader.GetTreeScanner();
                        scanner.SeekToStart();
                        scanner.TestSequential().Count();

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

                        int x = 0;
                        scanner.Peek(key, value);

                        while (scanner.Read(key, value) && x < 10000)
                        {
                            System.Console.WriteLine(key.PointID);
                            x++;

                            scanner.Peek(key, value);
                        }

                        scanner.Count();
                    }
        }
        public void TestTwoFiles()
        {
            MemoryPoolTest.TestMemoryLeak();
            ArchiveList <HistorianKey, HistorianValue> list = new ArchiveList <HistorianKey, HistorianValue>(null);

            HistorianKey   key1   = new HistorianKey();
            HistorianKey   key2   = new HistorianKey();
            HistorianValue value1 = new HistorianValue();
            HistorianValue value2 = new HistorianValue();

            SortedTreeTable <HistorianKey, HistorianValue> master = CreateTable();
            SortedTreeTable <HistorianKey, HistorianValue> table1 = CreateTable();
            SortedTreeTable <HistorianKey, HistorianValue> table2 = CreateTable();

            AddData(master, 100, 100, 100);
            AddData(table1, 100, 100, 100);
            AddData(master, 101, 100, 100);
            AddData(table2, 101, 100, 100);
            using (ArchiveListEditor <HistorianKey, HistorianValue> editor = list.AcquireEditLock())
            {
                editor.Add(table1);
                editor.Add(table2);
            }

            using (SortedTreeTableReadSnapshot <HistorianKey, HistorianValue> masterRead = master.BeginRead())
            {
                SortedTreeScannerBase <HistorianKey, HistorianValue> masterScan = masterRead.GetTreeScanner();
                masterScan.SeekToStart();
                TreeStreamSequential <HistorianKey, HistorianValue> masterScanSequential = masterScan.TestSequential();

                using (SequentialReaderStream <HistorianKey, HistorianValue> sequencer = new SequentialReaderStream <HistorianKey, HistorianValue>(list))
                {
                    TreeStreamSequential <HistorianKey, HistorianValue> scanner = sequencer.TestSequential();

                    while (scanner.Read(key1, value1))
                    {
                        if (!masterScanSequential.Read(key2, value2))
                        {
                            throw new Exception();
                        }

                        if (!key1.IsEqualTo(key2))
                        {
                            throw new Exception();
                        }

                        if (!value1.IsEqualTo(value2))
                        {
                            throw new Exception();
                        }
                    }
                    if (masterScan.Read(key2, value2))
                    {
                        throw new Exception();
                    }
                }
            }
            master.Dispose();
            list.Dispose();
            MemoryPoolTest.TestMemoryLeak();
        }