use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.
the class NodeTransactionStateTestBase method shouldNotFindDeletedNodeInLabelScan.
@Test
void shouldNotFindDeletedNodeInLabelScan() throws Exception {
// Given
Node node = createNode("label");
try (KernelTransaction tx = beginTransaction();
NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(tx.cursorContext())) {
// when
tx.dataWrite().nodeDelete(node.node);
tx.dataRead().nodeLabelScan(getTokenReadSession(tx, EntityType.NODE), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(node.labels[0]));
// then
assertFalse(cursor.next());
}
}
use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.
the class ManagedTestCursors method allocateFullAccessNodeLabelIndexCursor.
@Override
public NodeLabelIndexCursor allocateFullAccessNodeLabelIndexCursor(CursorContext cursorContext) {
NodeLabelIndexCursor n = cursors.allocateFullAccessNodeLabelIndexCursor(cursorContext);
allCursors.add(n);
return n;
}
use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.
the class ManagedTestCursors method allocateNodeLabelIndexCursor.
@Override
public NodeLabelIndexCursor allocateNodeLabelIndexCursor(CursorContext cursorContext) {
NodeLabelIndexCursor n = cursors.allocateNodeLabelIndexCursor(cursorContext);
allCursors.add(n);
return n;
}
use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.
the class KernelReadTracerTxStateTest method shouldTraceLabelScan.
@Test
void shouldTraceLabelScan() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (KernelTransaction tx = beginTransaction();
NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(NULL)) {
int barId = tx.tokenWrite().labelGetOrCreateForName("Bar");
long n = tx.dataWrite().nodeCreate();
tx.dataWrite().nodeAddLabel(n, barId);
// when
cursor.setTracer(tracer);
tx.dataRead().nodeLabelScan(getTokenReadSession(tx, EntityType.NODE), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(barId));
tracer.assertEvents(OnLabelScan(barId));
assertTrue(cursor.next());
tracer.assertEvents(OnNode(cursor.nodeReference()));
assertFalse(cursor.next());
tracer.assertEvents();
}
}
use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.
the class DefaultPooledCursorsTestBase method shouldReuseFullAccessNodeLabelIndexCursor.
@Test
void shouldReuseFullAccessNodeLabelIndexCursor() throws Exception {
try (KernelTransaction tx = beginTransaction()) {
NodeLabelIndexCursor c1 = tx.cursors().allocateFullAccessNodeLabelIndexCursor(NULL);
tx.dataRead().nodeLabelScan(getTokenReadSession(tx, EntityType.NODE), c1, IndexQueryConstraints.unconstrained(), new TokenPredicate(1));
c1.close();
NodeLabelIndexCursor c2 = tx.cursors().allocateFullAccessNodeLabelIndexCursor(NULL);
assertThat(c1).isSameAs(c2);
c2.close();
}
}
Aggregations