示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverIndexCountsBySamplingThemOnStartup()
        public virtual void ShouldRecoverIndexCountsBySamplingThemOnStartup()
        {
            // given some aliens in a database
            CreateAliens();

            // that have been indexed
            AwaitIndexOnline(IndexAliensBySpecimen());

            // where ALIEN and SPECIMEN are both the first ids of their kind
            IndexDescriptor index   = TestIndexDescriptorFactory.forLabel(LabelId(_alien), PkId(SPECIMEN));
            SchemaStorage   storage = new SchemaStorage(NeoStores().SchemaStore);
            long            indexId = storage.IndexGetForSchema(index).Id;

            // for which we don't have index counts
            ResetIndexCounts(indexId);

            // when we shutdown the database and restart it
            Restart();

            // then we should have re-sampled the index
            CountsTracker tracker = NeoStores().Counts;

            AssertEqualRegisters("Unexpected updates and size for the index", newDoubleLongRegister(0, 32), tracker.IndexUpdatesAndSize(indexId, newDoubleLongRegister()));
            AssertEqualRegisters("Unexpected sampling result", newDoubleLongRegister(16, 32), tracker.IndexSample(indexId, newDoubleLongRegister()));

            // and also
            AssertLogExistsForRecoveryOn(":Alien(specimen)");
        }
示例#2
0
        public static void RecomputeCounts(NeoStores stores, PageCache pageCache, DatabaseLayout databaseLayout)
        {
            MetaDataStore metaDataStore = stores.MetaDataStore;
            CountsTracker counts        = stores.Counts;

            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = Counts.reset(metaDataStore.LastCommittedTransactionId))
            {
                (new CountsComputer(stores, pageCache, databaseLayout)).Initialize(updater);
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.store.counts.CountsTracker tracker = mock(org.neo4j.kernel.impl.store.counts.CountsTracker.class);
            CountsTracker tracker = mock(typeof(CountsTracker));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CountsAccessor_Updater updater = mock(CountsAccessor_Updater.class);
            CountsAccessor_Updater updater = mock(typeof(CountsAccessor_Updater));

            when(tracker.Apply(anyLong())).thenReturn(updater);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CountsStoreBatchTransactionApplier applier = new CountsStoreBatchTransactionApplier(tracker, org.neo4j.storageengine.api.TransactionApplicationMode.INTERNAL);
            CountsStoreBatchTransactionApplier applier = new CountsStoreBatchTransactionApplier(tracker, TransactionApplicationMode.INTERNAL);

            // WHEN
            using (TransactionApplier txApplier = applier.StartTx(new TransactionToApply(null, 2L)))
            {
                txApplier.VisitNodeCountsCommand(new Command.NodeCountsCommand(StatementConstants.ANY_LABEL, 1));
            }

            // THEN
            verify(updater, times(1)).incrementNodeCount(StatementConstants.ANY_LABEL, 1);
        }