use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class HighIdTransactionApplier method visitNodeCommand.
@Override
public boolean visitNodeCommand(NodeCommand command) {
NodeStore nodeStore = neoStores.getNodeStore();
track(nodeStore, command);
track(nodeStore.getDynamicLabelStore(), command.getAfter().getDynamicLabelRecords());
return false;
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class NodeImporterTest method tracePageCacheAccessOnNodeImport.
@Test
void tracePageCacheAccessOnNodeImport() throws IOException {
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();
int numberOfLabels = 50;
long nodeId = 0;
var cacheTracer = new DefaultPageCacheTracer();
try (NodeImporter importer = new NodeImporter(stores, IdMappers.actual(), new DataImporter.Monitor(), cacheTracer, 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.property("a", randomAscii(10));
importer.property("b", randomAscii(100));
importer.property("c", randomAscii(1000));
importer.endOfEntity();
}
NodeStore nodeStore = stores.getNodeStore();
NodeRecord record = nodeStore.getRecord(nodeId, nodeStore.newRecord(), RecordLoad.NORMAL, CursorContext.NULL);
long[] labels = NodeLabelsField.parseLabelsField(record).get(nodeStore, CursorContext.NULL);
assertEquals(numberOfLabels, labels.length);
assertThat(cacheTracer.faults()).isEqualTo(2);
assertThat(cacheTracer.pins()).isEqualTo(13);
assertThat(cacheTracer.unpins()).isEqualTo(13);
assertThat(cacheTracer.hits()).isEqualTo(11);
}
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class HumanUnderstandableExecutionMonitorIT method shouldStartFromNonFirstStage.
@Test
void shouldStartFromNonFirstStage() {
// given
HumanUnderstandableExecutionMonitor monitor = new HumanUnderstandableExecutionMonitor(HumanUnderstandableExecutionMonitor.NO_MONITOR);
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency(Input.knownEstimates(10, 10, 10, 10, 10, 10, 10));
BatchingNeoStores neoStores = mock(BatchingNeoStores.class);
NodeStore nodeStore = mock(NodeStore.class);
RelationshipStore relationshipStore = mock(RelationshipStore.class);
when(neoStores.getNodeStore()).thenReturn(nodeStore);
when(neoStores.getRelationshipStore()).thenReturn(relationshipStore);
dependencies.satisfyDependency(neoStores);
dependencies.satisfyDependency(IdMappers.actual());
dependencies.satisfyDependency(mock(PageCacheArrayFactoryMonitor.class));
dependencies.satisfyDependency(new DataStatistics(10, 10, new DataStatistics.RelationshipTypeCount[0]));
monitor.initialize(dependencies);
// when/then
StageExecution execution = mock(StageExecution.class);
when(execution.getStageName()).thenReturn(NodeDegreeCountStage.NAME);
assertThatCode(() -> monitor.start(execution)).doesNotThrowAnyException();
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class BatchInsertTest method shouldSortLabelIdsWhenGetOrCreate.
@ParameterizedTest
@MethodSource("params")
void shouldSortLabelIdsWhenGetOrCreate(int denseNodeThreshold) throws Exception {
// GIVEN
var inserter = newBatchInserter(denseNodeThreshold);
// WHEN
long nodeId = inserter.createNode(map("Item", 123456789123L), label("AA"), label("BB"), label("CC"), label("DD"));
inserter.setNodeLabels(nodeId, label("CC"), label("AA"), label("DD"), label("EE"), label("FF"));
// THEN
NodeStore nodeStore = getFlushedNeoStores(inserter).getNodeStore();
NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), NORMAL, NULL);
NodeLabels labels = NodeLabelsField.parseLabelsField(node);
long[] labelIds = labels.get(nodeStore, NULL);
long[] sortedLabelIds = Arrays.copyOf(labelIds, labelIds.length);
Arrays.sort(sortedLabelIds);
assertArrayEquals(sortedLabelIds, labelIds);
inserter.shutdown();
}
use of org.neo4j.kernel.impl.store.NodeStore in project neo4j by neo4j.
the class WriteTransactionCommandOrderingTest method injectAllPossibleCommands.
private static TransactionRecordState injectAllPossibleCommands() {
RecordChangeSet recordChangeSet = mock(RecordChangeSet.class);
RecordChanges<LabelTokenRecord, Void> labelTokenChanges = mock(RecordChanges.class);
RecordChanges<RelationshipTypeTokenRecord, Void> relationshipTypeTokenChanges = mock(RecordChanges.class);
RecordChanges<PropertyKeyTokenRecord, Void> propertyKeyTokenChanges = mock(RecordChanges.class);
RecordChanges<NodeRecord, Void> nodeRecordChanges = mock(RecordChanges.class);
RecordChanges<RelationshipRecord, Void> relationshipRecordChanges = mock(RecordChanges.class);
RecordChanges<PropertyRecord, PrimitiveRecord> propertyRecordChanges = mock(RecordChanges.class);
RecordChanges<RelationshipGroupRecord, Integer> relationshipGroupChanges = mock(RecordChanges.class);
RecordChanges<SchemaRecord, SchemaRule> schemaRuleChanges = mock(RecordChanges.class);
when(recordChangeSet.getLabelTokenChanges()).thenReturn(labelTokenChanges);
when(recordChangeSet.getRelationshipTypeTokenChanges()).thenReturn(relationshipTypeTokenChanges);
when(recordChangeSet.getPropertyKeyTokenChanges()).thenReturn(propertyKeyTokenChanges);
when(recordChangeSet.getNodeRecords()).thenReturn(nodeRecordChanges);
when(recordChangeSet.getRelRecords()).thenReturn(relationshipRecordChanges);
when(recordChangeSet.getPropertyRecords()).thenReturn(propertyRecordChanges);
when(recordChangeSet.getRelGroupRecords()).thenReturn(relationshipGroupChanges);
when(recordChangeSet.getSchemaRuleChanges()).thenReturn(schemaRuleChanges);
List<RecordProxy<NodeRecord, Void>> nodeChanges = new LinkedList<>();
RecordChange<NodeRecord, Void> deletedNode = mock(RecordChange.class);
when(deletedNode.getBefore()).thenReturn(inUseNode());
when(deletedNode.forReadingLinkage()).thenReturn(missingNode());
nodeChanges.add(deletedNode);
RecordChange<NodeRecord, Void> createdNode = mock(RecordChange.class);
when(createdNode.getBefore()).thenReturn(missingNode());
when(createdNode.forReadingLinkage()).thenReturn(createdNode());
nodeChanges.add(createdNode);
RecordChange<NodeRecord, Void> updatedNode = mock(RecordChange.class);
when(updatedNode.getBefore()).thenReturn(inUseNode());
when(updatedNode.forReadingLinkage()).thenReturn(inUseNode());
nodeChanges.add(updatedNode);
when(nodeRecordChanges.changes()).thenReturn(nodeChanges);
when(nodeRecordChanges.changeSize()).thenReturn(3);
when(recordChangeSet.changeSize()).thenReturn(3);
when(labelTokenChanges.changes()).thenReturn(Collections.emptyList());
when(relationshipTypeTokenChanges.changes()).thenReturn(Collections.emptyList());
when(propertyKeyTokenChanges.changes()).thenReturn(Collections.emptyList());
when(relationshipRecordChanges.changes()).thenReturn(Collections.emptyList());
when(propertyRecordChanges.changes()).thenReturn(Collections.emptyList());
when(relationshipGroupChanges.changes()).thenReturn(Collections.emptyList());
when(schemaRuleChanges.changes()).thenReturn(Collections.emptyList());
NeoStores neoStores = mock(NeoStores.class);
NodeStore store = mock(NodeStore.class);
when(neoStores.getNodeStore()).thenReturn(store);
RelationshipGroupStore relationshipGroupStore = mock(RelationshipGroupStore.class);
when(neoStores.getRelationshipGroupStore()).thenReturn(relationshipGroupStore);
RelationshipStore relationshipStore = mock(RelationshipStore.class);
when(neoStores.getRelationshipStore()).thenReturn(relationshipStore);
return new TransactionRecordState(neoStores, mock(IntegrityValidator.class), recordChangeSet, 0, null, LockTracer.NONE, null, null, null, NULL, INSTANCE, LATEST_LOG_SERIALIZATION);
}
Aggregations