use of org.neo4j.kernel.impl.store.cursor.CachedStoreCursors in project graph-data-science by neo4j.
the class InMemoryStorageEngineFactory method loadReadOnlyTokens.
private TokenHolders loadReadOnlyTokens(NeoStores stores, boolean lenient, CursorContextFactory cursorContextFactory) {
try (var cursorContext = cursorContextFactory.create("loadReadOnlyTokens");
var storeCursors = new CachedStoreCursors(stores, cursorContext)) {
stores.start(cursorContext);
TokensLoader loader = lenient ? StoreTokens.allReadableTokens(stores) : StoreTokens.allTokens(stores);
TokenHolder propertyKeys = new DelegatingTokenHolder(ReadOnlyTokenCreator.READ_ONLY, TokenHolder.TYPE_PROPERTY_KEY);
TokenHolder labels = new DelegatingTokenHolder(ReadOnlyTokenCreator.READ_ONLY, TokenHolder.TYPE_LABEL);
TokenHolder relationshipTypes = new DelegatingTokenHolder(ReadOnlyTokenCreator.READ_ONLY, TokenHolder.TYPE_RELATIONSHIP_TYPE);
propertyKeys.setInitialTokens(lenient ? unique(loader.getPropertyKeyTokens(storeCursors)) : loader.getPropertyKeyTokens(storeCursors));
labels.setInitialTokens(lenient ? unique(loader.getLabelTokens(storeCursors)) : loader.getLabelTokens(storeCursors));
relationshipTypes.setInitialTokens(lenient ? unique(loader.getRelationshipTypeTokens(storeCursors)) : loader.getRelationshipTypeTokens(storeCursors));
return new TokenHolders(propertyKeys, labels, relationshipTypes);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.neo4j.kernel.impl.store.cursor.CachedStoreCursors in project neo4j by neo4j.
the class RelationshipGroupDefragmenterTest method init.
private void init(RecordFormats format, int units) throws IOException {
this.units = units;
jobScheduler = new ThreadPoolJobScheduler();
stores = BatchingNeoStores.batchingNeoStores(testDirectory.getFileSystem(), databaseLayout, format, CONFIG, NullLogService.getInstance(), AdditionalInitialIds.EMPTY, Config.defaults(), jobScheduler, PageCacheTracer.NULL, INSTANCE);
stores.createNew();
storeCursors = new CachedStoreCursors(stores.getNeoStores(), NULL);
}
use of org.neo4j.kernel.impl.store.cursor.CachedStoreCursors in project neo4j by neo4j.
the class NodeImporterTest method shouldHandleLargeAmountsOfLabels.
@Test
void shouldHandleLargeAmountsOfLabels() throws IOException {
// given
IdMapper idMapper = mock(IdMapper.class);
JobScheduler scheduler = new ThreadPoolJobScheduler();
try (Lifespan life = new Lifespan(scheduler);
BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache(fs, pageCache, NULL, layout, Standard.LATEST_RECORD_FORMATS, Configuration.DEFAULT, NullLogService.getInstance(), AdditionalInitialIds.EMPTY, Config.defaults(), INSTANCE)) {
stores.createNew();
try (var storeCursors = new CachedStoreCursors(stores.getNeoStores(), CursorContext.NULL)) {
// when
int numberOfLabels = 50;
long nodeId = 0;
try (NodeImporter importer = new NodeImporter(stores, idMapper, new DataImporter.Monitor(), NULL, INSTANCE)) {
importer.id(nodeId);
String[] labels = new String[numberOfLabels];
for (int i = 0; i < labels.length; i++) {
labels[i] = "Label" + i;
}
importer.labels(labels);
importer.endOfEntity();
}
// then
NodeStore nodeStore = stores.getNodeStore();
PageCursor nodeCursor = storeCursors.readCursor(NODE_CURSOR);
NodeRecord record = nodeStore.getRecordByCursor(nodeId, nodeStore.newRecord(), RecordLoad.NORMAL, nodeCursor);
long[] labels = NodeLabelsField.parseLabelsField(record).get(nodeStore, storeCursors);
assertEquals(numberOfLabels, labels.length);
}
}
}
use of org.neo4j.kernel.impl.store.cursor.CachedStoreCursors in project neo4j by neo4j.
the class ApplyRecoveredTransactionsTest method before.
@BeforeEach
void before() {
idGeneratorFactory = new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
StoreFactory storeFactory = new StoreFactory(databaseLayout, Config.defaults(), idGeneratorFactory, pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
neoStores = storeFactory.openAllNeoStores(true);
storeCursors = new CachedStoreCursors(neoStores, NULL);
}
use of org.neo4j.kernel.impl.store.cursor.CachedStoreCursors in project neo4j by neo4j.
the class ConsistencyCheckingApplierTest method setUp.
@BeforeEach
void setUp() {
Config config = Config.defaults(neo4j_home, directory.homePath());
RecordDatabaseLayout layout = RecordDatabaseLayout.of(config);
neoStores = new StoreFactory(layout, config, new DefaultIdGeneratorFactory(directory.getFileSystem(), immediate(), DEFAULT_DATABASE_NAME), pageCache, directory.getFileSystem(), NullLogProvider.getInstance(), PageCacheTracer.NULL, writable()).openAllNeoStores(true);
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
storeCursors = new CachedStoreCursors(neoStores, CursorContext.NULL);
checker = new ConsistencyCheckingApplier(relationshipStore, CursorContext.NULL);
BatchContext batchContext = mock(BatchContext.class);
when(batchContext.getLockGroup()).thenReturn(new LockGroup());
applier = new NeoStoreTransactionApplier(CommandVersion.AFTER, neoStores, mock(CacheAccessBackDoor.class), LockService.NO_LOCK_SERVICE, 0, batchContext, CursorContext.NULL, storeCursors);
appliers = new TransactionApplier[] { checker, applier };
}
Aggregations