Exemplo n.º 1
0
        public BinaryStorage(StorageConfiguration configuration)
        {
            var storageFilePath = Path.Combine(configuration.WorkingFolder, configuration.StorageFileName);
            var indexFilePath   = Path.Combine(configuration.WorkingFolder, configuration.IndexFileName);

            _nodeStorage = new PersistentNodeStorage(indexFilePath);
            _index       = new ThreadSafeIndex(
                new BTreeIndex <PersistentNode, KeyInfo>(_nodeStorage),
                configuration.IndexTimeout);
            _storage = new FileStorage(storageFilePath);
        }
        public void Capacity_Test()
        {
            var sizes    = new BinStorage.Index.BTree.Persistent.Sizes(TestDegree);
            var capacity = 2 * sizes.NodeSize + BinStorage.Index.BTree.Persistent.Sizes.CursorHolderSize + BinStorage.Index.BTree.Persistent.Sizes.RootHolderSize;

            using (var target = new PersistentNodeStorage(_indexFilePath, capacity, TestDegree)) {
                var root = target.GetRoot();

                for (var i = 0; i < TestDegree * 2; i++)
                {
                    var children = target.NewNode();
                    target.AddChildren(root, children);
                    target.Commit(children);
                }

                target.Commit(root);
            }
        }
 public void TestInitialize()
 {
     _indexFilePath = Path.GetTempFileName();
     _nodeStorage   = new PersistentNodeStorage(_indexFilePath, TestCapacity, TestDegree);
 }
 private T Process <T>(Func <PersistentNodeStorage, T> action)
 {
     using (var target = new PersistentNodeStorage(_indexFilePath, 0x400000, TestDegree)) {
         return(action(target));
     }
 }
 private void Process(Action <PersistentNodeStorage> action)
 {
     using (var target = new PersistentNodeStorage(_indexFilePath, 0x400000, TestDegree)) {
         action(target);
     }
 }