use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class HaCountsIT method assertOnIndexCounts.
private void assertOnIndexCounts(int expectedIndexUpdates, int expectedIndexSize, int expectedUniqueValues, int expectedSampleSize, long indexId, HighlyAvailableGraphDatabase db) {
CountsTracker counts = counts(db);
assertDoubleLongEquals(expectedIndexUpdates, expectedIndexSize, counts.indexUpdatesAndSize(indexId, newDoubleLongRegister()));
assertDoubleLongEquals(expectedUniqueValues, expectedSampleSize, counts.indexSample(indexId, newDoubleLongRegister()));
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class FullCheck method execute.
ConsistencySummaryStatistics execute(DirectStoreAccess stores, Log log, Monitor reportMonitor) throws ConsistencyCheckIncompleteException {
ConsistencySummaryStatistics summary = new ConsistencySummaryStatistics();
InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(log), summary);
OwnerCheck ownerCheck = new OwnerCheck(checkPropertyOwners);
CountsBuilderDecorator countsBuilder = new CountsBuilderDecorator(stores.nativeStores());
CheckDecorator decorator = new CheckDecorator.ChainCheckDecorator(ownerCheck, countsBuilder);
CacheAccess cacheAccess = new DefaultCacheAccess(statistics.getCounts(), threads);
RecordAccess records = recordAccess(stores.nativeStores(), cacheAccess);
execute(stores, decorator, records, report, cacheAccess, reportMonitor);
ownerCheck.scanForOrphanChains(progressFactory);
if (checkGraph) {
CountsAccessor countsAccessor = stores.nativeStores().getCounts();
if (countsAccessor instanceof CountsTracker) {
CountsTracker tracker = (CountsTracker) countsAccessor;
try {
tracker.start();
} catch (Exception e) {
// let's hope it was already started :)
}
}
countsBuilder.checkCounts(countsAccessor, new ConsistencyReporter(records, report), progressFactory);
}
if (!summary.isConsistent()) {
log.warn("Inconsistencies found: " + summary);
}
return summary;
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class CountsStoreTransactionApplierTest method shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar.
@Test
public void shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar() throws Exception {
// GIVEN
final CountsTracker tracker = mock(CountsTracker.class);
final CountsAccessor.Updater updater = mock(CountsAccessor.Updater.class);
when(tracker.apply(anyLong())).thenReturn(Optional.of(updater));
final CountsStoreBatchTransactionApplier applier = new CountsStoreBatchTransactionApplier(tracker, TransactionApplicationMode.INTERNAL);
// WHEN
try (TransactionApplier txApplier = applier.startTx(new TransactionToApply(null, 2L))) {
txApplier.visitNodeCountsCommand(new Command.NodeCountsCommand(ReadOperations.ANY_LABEL, 1));
}
// THEN
verify(updater, times(1)).incrementNodeCount(ReadOperations.ANY_LABEL, 1);
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class CountsComputer method recomputeCounts.
public static void recomputeCounts(NeoStores stores) {
MetaDataStore metaDataStore = stores.getMetaDataStore();
CountsTracker counts = stores.getCounts();
try (CountsAccessor.Updater updater = counts.reset(metaDataStore.getLastCommittedTransactionId())) {
new CountsComputer(stores).initialize(updater);
}
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class StoreMigrator method rebuildCountsFromScratch.
private void rebuildCountsFromScratch(File storeDir, long lastTxId, PageCache pageCache) {
final File storeFileBase = new File(storeDir, MetaDataStore.DEFAULT_NAME + StoreFactory.COUNTS_STORE);
StoreFactory storeFactory = new StoreFactory(storeDir, pageCache, fileSystem, NullLogProvider.getInstance());
try (NeoStores neoStores = storeFactory.openAllNeoStores()) {
NodeStore nodeStore = neoStores.getNodeStore();
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
try (Lifespan life = new Lifespan()) {
int highLabelId = (int) neoStores.getLabelTokenStore().getHighId();
int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId();
CountsComputer initializer = new CountsComputer(lastTxId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId);
life.add(new CountsTracker(logService.getInternalLogProvider(), fileSystem, pageCache, config, storeFileBase).setInitializer(initializer));
}
}
}
Aggregations