Esempio n. 1
0
        private void RebuildCounts(long lastCommittedTransactionId, ProgressReporter progressReporter)
        {
            CleanupCountsForRebuilding();

            IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(_fs);
            StoreFactory       storeFactory = new StoreFactory(_testDir.databaseLayout(), _config, idGenFactory, _pageCache, _fs, _logProvider, EmptyVersionContextSupplier.EMPTY);

            using (Lifespan life = new Lifespan(), NeoStores neoStores = storeFactory.OpenAllNeoStores())
            {
                NodeStore         nodeStore           = neoStores.NodeStore;
                RelationshipStore relationshipStore   = neoStores.RelationshipStore;
                int            highLabelId            = ( int )neoStores.LabelTokenStore.HighId;
                int            highRelationshipTypeId = ( int )neoStores.RelationshipTypeTokenStore.HighId;
                CountsComputer countsComputer         = new CountsComputer(lastCommittedTransactionId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId, [email protected]_Fields.AutoWithoutPagecache, progressReporter);
                CountsTracker  countsTracker          = CreateCountsTracker();
                life.Add(countsTracker.setInitializer(countsComputer));
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions()
        public virtual void ShouldGrowAFileWhileContinuingToMemoryMapNewRegions()
        {
            // don't run on windows because memory mapping doesn't work properly there
            assumeTrue(!SystemUtils.IS_OS_WINDOWS);

            // given
            const int numberOfRecords = 1000000;

            Config config = Config.defaults(pagecache_memory, MmapSize(numberOfRecords, NodeRecordFormat.RECORD_SIZE));
            FileSystemAbstraction     fileSystemAbstraction = _fileSystemRule.get();
            DefaultIdGeneratorFactory idGeneratorFactory    = new DefaultIdGeneratorFactory(fileSystemAbstraction);
            PageCache    pageCache    = _pageCacheRule.getPageCache(fileSystemAbstraction, config);
            StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), config, idGeneratorFactory, pageCache, fileSystemAbstraction, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            NeoStores neoStores = storeFactory.OpenAllNeoStores(true);
            NodeStore nodeStore = neoStores.NodeStore;

            // when
            int  iterations = 2 * numberOfRecords;
            long startingId = nodeStore.NextId();
            long nodeId     = startingId;

            for (int i = 0; i < iterations; i++)
            {
                NodeRecord record = new NodeRecord(nodeId, false, i, 0);
                record.InUse = true;
                nodeStore.UpdateRecord(record);
                nodeId = nodeStore.NextId();
            }

            // then
            NodeRecord record = new NodeRecord(0, false, 0, 0);

            for (int i = 0; i < iterations; i++)
            {
                record.Id = startingId + i;
                nodeStore.GetRecord(i, record, NORMAL);
                assertTrue("record[" + i + "] should be in use", record.InUse());
                assertThat("record[" + i + "] should have nextRelId of " + i, record.NextRel, @is(( long )i));
            }

            neoStores.Close();
        }