Esempio n. 1
0
 public void Commit(ulong transactionId, BrightstarProfiler profiler)
 {
     using (profiler.Step("Commit ResourceTable"))
     {
         if (_currentPage > 0)
         {
             _pageStore.Commit(transactionId, profiler);
             _nextSegment = _pointerSegment;
             _currentPage = 0;
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Copies all the indexes from this store to the specified target page store
        /// </summary>
        /// <param name="pageStore">The page store to copy to</param>
        /// <param name="txnId">The transaction Id to use in the target page store for the write</param>
        /// <returns>The ID of the root store page in the target page store</returns>
        public ulong CopyTo(IPageStore pageStore, ulong txnId)
        {
            var graphIndexId    = _graphIndex.Write(pageStore, txnId, null);
            var prefixManagerId = _prefixManager.Write(pageStore, txnId, null);
            var resourceIndexId = _resourceIndex.Write(pageStore, txnId, null);
            var subjectRelatedResourceIndexId = _subjectRelatedResourceIndex.Write(pageStore, txnId, null);
            var objectRelatedResourceIndexId  = _objectRelatedResourceIndex.Write(pageStore, txnId, null);
            var buff = CreateStoreHeader(graphIndexId, prefixManagerId, resourceIndexId, subjectRelatedResourceIndexId,
                                         objectRelatedResourceIndexId);
            var storePage = pageStore.Create(txnId);

            storePage.SetData(buff);
            storePage.SetData(buff, 0, 128);
            pageStore.Commit(txnId, null);
            return(storePage.Id);
        }
 private void BuildAndScan(IPageStore pageStore, string pageStoreName, PersistenceType persistenceType, int keyCount)
 {
     var config = new BPlusTreeConfiguration(8, 64, pageStore.PageSize);
     var builder = new BPlusTreeBuilder(pageStore, config);
     var treeRoot = builder.Build(1, _testOrderedValues.Take(keyCount));
     var treeBeforeSave = new BPlusTree(pageStore, treeRoot);
     treeBeforeSave.Save(1, null);
     //ValidateScan(treeBeforeSave.Scan(null), keyCount, pageStoreName + " before save");
     pageStore.Commit(1, null);
     pageStore.Close();
     
    
     using(var ps = TestUtils.OpenPageStore(pageStoreName, true, persistenceType, 1))
     {
         var tree = new BPlusTree(ps, treeRoot);
         tree.DumpStructure();
         ValidateScan(tree.Scan(null), keyCount, pageStoreName + " after save");
         ValidateSearch(tree, keyCount, pageStoreName + "after save");
     }
 }
        private void BuildAndScan(IPageStore pageStore, string pageStoreName, PersistenceType persistenceType, int keyCount)
        {
            var config         = new BPlusTreeConfiguration(8, 64, pageStore.PageSize);
            var builder        = new BPlusTreeBuilder(pageStore, config);
            var treeRoot       = builder.Build(1, _testOrderedValues.Take(keyCount));
            var treeBeforeSave = new BPlusTree(pageStore, treeRoot);

            treeBeforeSave.Save(1, null);
            //ValidateScan(treeBeforeSave.Scan(null), keyCount, pageStoreName + " before save");
            pageStore.Commit(1, null);
            pageStore.Close();


            using (var ps = TestUtils.OpenPageStore(pageStoreName, true, persistenceType, 1))
            {
                var tree = new BPlusTree(ps, treeRoot);
                tree.DumpStructure();
                ValidateScan(tree.Scan(null), keyCount, pageStoreName + " after save");
                ValidateSearch(tree, keyCount, pageStoreName + "after save");
            }
        }
Esempio n. 5
0
        private ulong Save(BrightstarProfiler profiler)
        {
            using (profiler.Step("Store.Save"))
            {
                _resourceTable.Commit(_currentTxnId + 1, profiler);

                var txnId           = _currentTxnId + 1;
                var graphIndexId    = _graphIndex.Save(txnId, profiler);
                var prefixManagerId = _prefixManager.Save(txnId, profiler);
                var resourceIndexId = _resourceIndex.Save(txnId, profiler);
                var subjectRelatedResourceIndexId = _subjectRelatedResourceIndex.Save(txnId, profiler);
                var objectRelatedResourceIndexId  = _objectRelatedResourceIndex.Save(txnId, profiler);
                var buff = CreateStoreHeader(graphIndexId, prefixManagerId, resourceIndexId,
                                             subjectRelatedResourceIndexId, objectRelatedResourceIndexId);

                var page = _pageStore.Create(txnId);
                page.SetData(buff);
                page.SetData(buff, 0, 128);
                _pageStore.Commit(txnId, profiler);
                return(page.Id);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Copies all the indexes from this store to the specified target page store
 /// </summary>
 /// <param name="pageStore">The page store to copy to</param>
 /// <param name="txnId">The transaction Id to use in the target page store for the write</param>
 /// <returns>The ID of the root store page in the target page store</returns>
 public ulong CopyTo(IPageStore pageStore, ulong txnId)
 {
     var graphIndexId = _graphIndex.Write(pageStore, txnId, null);
     var prefixManagerId = _prefixManager.Write(pageStore, txnId, null);
     var resourceIndexId = _resourceIndex.Write(pageStore, txnId, null);
     var subjectRelatedResourceIndexId = _subjectRelatedResourceIndex.Write(pageStore, txnId, null);
     var objectRelatedResourceIndexId = _objectRelatedResourceIndex.Write(pageStore, txnId, null);
     var buff = CreateStoreHeader(graphIndexId, prefixManagerId, resourceIndexId, subjectRelatedResourceIndexId,
                                  objectRelatedResourceIndexId);
     var storePage = pageStore.Create(txnId);
     storePage.SetData(buff);
     storePage.SetData(buff, 0, 128);
     pageStore.Commit(txnId, null);
     return storePage.Id;
 }