use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class NodeWriteTestBase method shouldSetAndReadLargeByteArrayPropertyToNode.
@Test
void shouldSetAndReadLargeByteArrayPropertyToNode() throws Exception {
// Given
int prop;
long node = createNode();
Value largeByteArray = Values.of(new byte[100_000]);
// When
try (KernelTransaction tx = beginTransaction()) {
prop = tx.token().propertyKeyGetOrCreateForName(propertyKey);
assertThat(tx.dataWrite().nodeSetProperty(node, prop, largeByteArray)).isEqualTo(NO_VALUE);
tx.commit();
}
// Then
try (KernelTransaction tx = beginTransaction();
NodeCursor nodeCursor = tx.cursors().allocateNodeCursor(tx.cursorContext());
PropertyCursor propertyCursor = tx.cursors().allocatePropertyCursor(tx.cursorContext(), tx.memoryTracker())) {
tx.dataRead().singleNode(node, nodeCursor);
assertTrue(nodeCursor.next());
nodeCursor.properties(propertyCursor);
assertTrue(propertyCursor.next());
assertEquals(propertyCursor.propertyKey(), prop);
assertThat(propertyCursor.propertyValue()).isEqualTo(largeByteArray);
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class Operations method nodeDetachDelete.
@Override
public int nodeDetachDelete(long nodeId) {
ktx.assertOpen();
commandCreationContext.acquireNodeDeletionLock(ktx.txState(), ktx.lockClient(), ktx.lockTracer(), nodeId);
NodeCursor nodeCursor = ktx.ambientNodeCursor();
ktx.dataRead().singleNode(nodeId, nodeCursor);
int deletedRelationships = 0;
if (nodeCursor.next()) {
try (var rels = RelationshipSelections.allCursor(ktx.cursors(), nodeCursor, null, ktx.cursorContext())) {
while (rels.next()) {
boolean deleted = relationshipDelete(rels.relationshipReference());
if (additionLockVerification && !deleted) {
throw new RuntimeException("Relationship chain modified even when node delete lock was held: " + rels);
}
deletedRelationships++;
}
}
}
// we are already holding the lock
nodeDelete(nodeId, false);
return deletedRelationships;
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class TransactionTestBase method assertNoNode.
private void assertNoNode(long nodeId) throws TransactionFailureException {
try (KernelTransaction tx = beginTransaction();
NodeCursor cursor = tx.cursors().allocateNodeCursor(NULL)) {
tx.dataRead().singleNode(nodeId, cursor);
assertFalse(cursor.next());
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class TransactionTestBase method assertNodeExists.
private void assertNodeExists(long nodeId) throws TransactionFailureException {
try (KernelTransaction tx = beginTransaction();
NodeCursor cursor = tx.cursors().allocateNodeCursor(NULL)) {
tx.dataRead().singleNode(nodeId, cursor);
assertTrue(cursor.next());
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class FulltextIndexTransactionState method updateSearcher.
private void updateSearcher(QueryContext context, CursorContext cursorContext, MemoryTracker memoryTracker) throws Exception {
Read read = context.getRead();
CursorFactory cursors = context.cursors();
ReadableTransactionState state = context.getTransactionStateOrNull();
// Clear this, so we don't filter out entities who have had their changes reversed since last time.
modifiedEntityIdsInThisTransaction.clear();
writer.resetWriterState();
try (NodeCursor nodeCursor = visitingNodes ? cursors.allocateFullAccessNodeCursor(cursorContext) : null;
RelationshipScanCursor relationshipCursor = visitingNodes ? null : cursors.allocateRelationshipScanCursor(cursorContext);
PropertyCursor propertyCursor = cursors.allocateFullAccessPropertyCursor(cursorContext, memoryTracker)) {
state.accept(txStateVisitor.init(read, nodeCursor, relationshipCursor, propertyCursor));
}
currentSearcher = writer.getNearRealTimeSearcher();
toCloseLater.add(currentSearcher);
lastUpdateRevision = state.getDataRevision();
}
Aggregations