use of org.neo4j.kernel.impl.api.state.TxState in project neo4j by neo4j.
the class RecordStorageReaderTestBase method createNode.
protected long createNode(Map<String, Object> properties, Label... labels) throws Exception {
TxState txState = new TxState();
long nodeId = commitContext.reserveNode();
txState.nodeDoCreate(nodeId);
for (Label label : labels) {
txState.nodeDoAddLabel(getOrCreateLabelId(label), nodeId);
}
for (Map.Entry<String, Object> property : properties.entrySet()) {
txState.nodeDoAddProperty(nodeId, getOrCreatePropertyKeyId(property.getKey()), Values.of(property.getValue()));
}
apply(txState);
return nodeId;
}
use of org.neo4j.kernel.impl.api.state.TxState in project neo4j by neo4j.
the class RecordStorageReaderTestBase method createNodePropertyExistenceConstraint.
protected void createNodePropertyExistenceConstraint(Label label, String propertyKey) throws Exception {
TxState txState = new TxState();
NodeExistenceConstraintDescriptor constraint = ConstraintDescriptorFactory.existsForLabel(getOrCreateLabelId(label), getOrCreatePropertyKeyId(propertyKey));
long id = commitContext.reserveSchema();
txState.constraintDoAdd(constraint.withId(id).withName("constraint_" + id));
apply(txState);
}
use of org.neo4j.kernel.impl.api.state.TxState in project neo4j by neo4j.
the class RecordStorageReaderTestBase method createRelationship.
protected long createRelationship(long sourceNode, long targetNode, RelationshipType relationshipType) throws Exception {
TxState txState = new TxState();
long relationshipId = commitContext.reserveRelationship();
txState.relationshipDoCreate(relationshipId, getOrCreateRelationshipTypeId(relationshipType), sourceNode, targetNode);
apply(txState);
return relationshipId;
}
use of org.neo4j.kernel.impl.api.state.TxState in project neo4j by neo4j.
the class CommitProcessTracingIT method tracePageCacheAccessOnCommandCreation.
@Test
void tracePageCacheAccessOnCommandCreation() throws KernelException {
long sourceId;
try (Transaction transaction = database.beginTx()) {
sourceId = transaction.createNode(Label.label("a")).getId();
transaction.commit();
}
var pageCacheTracer = new DefaultPageCacheTracer();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnCommandCreation"));
var reader = storageEngine.newReader()) {
assertZeroCursor(cursorContext);
try (CommandCreationContext context = storageEngine.newCommandCreationContext(INSTANCE)) {
context.initialize(cursorContext);
List<StorageCommand> commands = new ArrayList<>();
var txState = new TxState();
txState.nodeDoAddLabel(1, sourceId);
storageEngine.createCommands(commands, txState, reader, context, IGNORE, LockTracer.NONE, 0, NO_DECORATION, cursorContext, INSTANCE);
}
assertCursor(cursorContext, 2);
}
}
use of org.neo4j.kernel.impl.api.state.TxState in project neo4j by neo4j.
the class DefaultRelationshipTraversalCursorTest method txState.
private static Read txState(Rel... rels) {
KernelTransactionImplementation ktx = mock(KernelTransactionImplementation.class);
Read read = new TestRead(ktx);
when(ktx.securityContext()).thenReturn(SecurityContext.AUTH_DISABLED);
if (rels.length > 0) {
TxState txState = new TxState();
for (Rel rel : rels) {
txState.relationshipDoCreate(rel.relId, rel.type, rel.sourceId, rel.targetId);
}
when(read.hasTxStateWithChanges()).thenReturn(true);
when(read.txState()).thenReturn(txState);
}
return read;
}
Aggregations