Esempio n. 1
0
        private void Initialize(string workingDir, bool createNotFound)
        {
            if (String.IsNullOrEmpty(workingDir))
            {
                throw new InvalidOperationException();
            }

            _quickStorage = new MemoryTargetStorage();

            if (!Directory.Exists(workingDir))
            {
                Directory.CreateDirectory(workingDir);
            }
            if (_isSystem)
            {
                _treeFileName  = Path.Combine(workingDir, "LinkT2.6.10621.1.dat");
                _blockFileName = Path.Combine(workingDir, "LinkB2.6.10621.1.dat");
            }
            else
            {
                string tempFile = Path.GetFileNameWithoutExtension(
                    Path.GetTempFileName());

                _treeFileName  = Path.Combine(workingDir, tempFile + "Tree.dat");
                _blockFileName = Path.Combine(workingDir, tempFile + "Block.dat");
            }

            if (File.Exists(_treeFileName) && File.Exists(_blockFileName))
            {
                _isExisted = true;
                _plusTree  = hBplusTree.ReOpen(_treeFileName, _blockFileName);
                if (_plusTree.ContainsKey("$DataCount$"))
                {
                    _count = Convert.ToInt32(_plusTree["$DataCount$"]);
                }

                this.AddQuickTargets();
                //if (_count > 0)
                //{
                //}
            }
            else
            {
                _count = 0;
                if (createNotFound)
                {
                    _plusTree = hBplusTree.Initialize(_treeFileName,
                                                      _blockFileName, 64);
                }
            }

            if (_plusTree != null)
            {
                _targetCache = new DatabaseTargetCache(100);
            }
        }