Exemplo n.º 1
0
            internal Editor(SortedTreeTable <TKey, TValue> sortedTreeFile)
            {
                m_sortedTreeFile     = sortedTreeFile;
                m_currentTransaction = m_sortedTreeFile.m_fileStructure.BeginEdit();
                m_subStream          = m_currentTransaction.OpenFile(sortedTreeFile.m_fileName);
                m_binaryStream1      = new BinaryStream(m_subStream);
                m_tree = SortedTree <TKey, TValue> .Open(m_binaryStream1);

                m_tree.AutoFlush = false;
            }
        private static SortedTreeTable <TKey, TValue> CreateMemoryFile(EncodingDefinition treeNodeType, SortedPointBuffer <TKey, TValue> buffer)
        {
            buffer.IsReadingMode = true;

            SortedTreeFile file = SortedTreeFile.CreateInMemory(4096);
            SortedTreeTable <TKey, TValue> table = file.OpenOrCreateTable <TKey, TValue>(treeNodeType);

            using (SortedTreeTableEditor <TKey, TValue> edit = table.BeginEdit())
            {
                edit.AddPoints(buffer);
                edit.Commit();
            }

            buffer.IsReadingMode = false;
            return(table);
        }
Exemplo n.º 3
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();
                            }
                        }
        }
Exemplo n.º 4
0
        public void TestOld()
        {
            Test(1000, false);

            int pointCount = 10000000;
            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");

            Stopwatch sw = new Stopwatch();

            sw.Start();

            using (SortedTreeFile file = SortedTreeFile.CreateFile(@"C:\Temp\fileTemp.~d2i"))
                using (SortedTreeTable <HistorianKey, HistorianValue> table = file.OpenOrCreateTable <HistorianKey, HistorianValue>(EncodingDefinition.FixedSizeCombinedEncoding))
                {
                    using (SortedTreeTableEditor <HistorianKey, HistorianValue> edit = table.BeginEdit())
                    {
                        edit.AddPoints(points);
                        edit.Commit();
                    }
                }

            //SortedTreeFileSimpleWriter<HistorianKey, HistorianValue>.Create(@"C:\Temp\fileTemp.~d2i", @"C:\Temp\fileTemp.d2i", 4096, SortedTree.FixedSizeNode, points);

            sw.Stop();

            System.Console.WriteLine(SimplifiedSubFileStreamIoSession.ReadBlockCount);
            System.Console.WriteLine(SimplifiedSubFileStreamIoSession.WriteBlockCount);
            System.Console.WriteLine(sw.Elapsed.TotalSeconds.ToString());
        }
Exemplo n.º 5
0
 private void InternalDispose()
 {
     m_disposed = true;
     m_sortedTreeFile.m_activeEditor = null;
     m_sortedTreeFile = null;
 }