use of org.neo4j.kernel.impl.store.StoreAccess in project neo4j by neo4j.
the class RelationshipChainExplorerTest method createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes.
private StoreAccess createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes(int nDegreeTwoNodes) {
File storeDirectory = storeLocation.graphDbDir();
GraphDatabaseService database = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDirectory).setConfig(GraphDatabaseSettings.record_format, getRecordFormatName()).newGraphDatabase();
try (Transaction transaction = database.beginTx()) {
Node denseNode = database.createNode();
for (int i = 0; i < nDegreeTwoNodes; i++) {
Node degreeTwoNode = database.createNode();
Node leafNode = database.createNode();
if (i % 2 == 0) {
denseNode.createRelationshipTo(degreeTwoNode, TestRelationshipType.CONNECTED);
} else {
degreeTwoNode.createRelationshipTo(denseNode, TestRelationshipType.CONNECTED);
}
degreeTwoNode.createRelationshipTo(leafNode, TestRelationshipType.CONNECTED);
}
transaction.success();
}
database.shutdown();
PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
StoreAccess storeAccess = new StoreAccess(fileSystemRule.get(), pageCache, storeDirectory, Config.empty());
return storeAccess.initialize();
}
use of org.neo4j.kernel.impl.store.StoreAccess in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportRelationshipLabelNameInconsistencies.
@Test
public void shouldReportRelationshipLabelNameInconsistencies() throws Exception {
// given
final Reference<Integer> inconsistentName = new Reference<>();
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
inconsistentName.set(next.relationshipType());
tx.relationshipType(inconsistentName.get(), "FOO");
}
});
StoreAccess access = fixture.directStoreAccess().nativeStores();
DynamicRecord record = access.getRelationshipTypeNameStore().getRecord(inconsistentName.get(), access.getRelationshipTypeNameStore().newRecord(), FORCE);
record.setNextBlock(record.getId());
access.getRelationshipTypeNameStore().updateRecord(record);
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.RELATIONSHIP_TYPE_NAME, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.StoreAccess in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportLabelInconsistencies.
@Test
public void shouldReportLabelInconsistencies() throws Exception {
// given
StoreAccess access = fixture.directStoreAccess().nativeStores();
LabelTokenRecord record = access.getLabelTokenStore().getRecord(1, access.getLabelTokenStore().newRecord(), FORCE);
record.setNameId(20);
record.setInUse(true);
access.getLabelTokenStore().updateRecord(record);
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.LABEL, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.StoreAccess in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportPropertyKeyInconsistencies.
@Test
public void shouldReportPropertyKeyInconsistencies() throws Exception {
// given
final Reference<Integer> inconsistentKey = new Reference<>();
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
inconsistentKey.set(next.propertyKey());
tx.propertyKey(inconsistentKey.get(), "FOO");
}
});
StoreAccess access = fixture.directStoreAccess().nativeStores();
DynamicRecord record = access.getPropertyKeyNameStore().getRecord(inconsistentKey.get() + 1, access.getPropertyKeyNameStore().newRecord(), FORCE);
record.setInUse(false);
access.getPropertyKeyNameStore().updateRecord(record);
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.PROPERTY_KEY, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.StoreAccess in project neo4j by neo4j.
the class GraphStoreFixture method directStoreAccess.
public DirectStoreAccess directStoreAccess() {
if (directStoreAccess == null) {
fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = getPageCache(fileSystem);
LogProvider logProvider = NullLogProvider.getInstance();
StoreFactory storeFactory = new StoreFactory(directory, pageCache, fileSystem, logProvider);
neoStore = storeFactory.openAllNeoStores();
StoreAccess nativeStores;
if (keepStatistics) {
AccessStatistics accessStatistics = new AccessStatistics();
statistics = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.getInstance());
nativeStores = new AccessStatsKeepingStoreAccess(neoStore, accessStatistics);
} else {
statistics = Statistics.NONE;
nativeStores = new StoreAccess(neoStore);
}
nativeStores.initialize();
Config config = Config.empty();
OperationalMode operationalMode = OperationalMode.single;
IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.getRawNeoStores());
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependencies(Config.defaults(), fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
KernelContext kernelContext = new SimpleKernelContext(directory, UNKNOWN, dependencies);
LabelScanStore labelScanStore = startLabelScanStore(config, dependencies, kernelContext);
directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, createIndexes(fileSystem, config, operationalMode));
}
return directStoreAccess;
}
Aggregations