use of org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor in project neo4j by neo4j.
the class ManagedTestCursors method allocateRelationshipTypeIndexCursor.
@Override
public RelationshipTypeIndexCursor allocateRelationshipTypeIndexCursor(CursorContext cursorContext) {
RelationshipTypeIndexCursor n = cursors.allocateRelationshipTypeIndexCursor(cursorContext);
allCursors.add(n);
return n;
}
use of org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor in project neo4j by neo4j.
the class ManagedTestCursors method allocateFullAccessRelationshipTypeIndexCursor.
@Override
public RelationshipTypeIndexCursor allocateFullAccessRelationshipTypeIndexCursor() {
RelationshipTypeIndexCursor n = cursors.allocateFullAccessRelationshipTypeIndexCursor();
allCursors.add(n);
return n;
}
use of org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor in project neo4j by neo4j.
the class KernelReadTracerTxStateTest method shouldTraceRelationshipTypeScan.
@Test
void shouldTraceRelationshipTypeScan() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (KernelTransaction tx = beginTransaction();
RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
int rType = tx.token().relationshipTypeGetOrCreateForName("R");
long n1 = tx.dataWrite().nodeCreate();
long n2 = tx.dataWrite().nodeCreate();
tx.dataWrite().relationshipCreate(n1, rType, n2);
// when
cursor.setTracer(tracer);
tx.dataRead().relationshipTypeScan(getTokenReadSession(tx, EntityType.RELATIONSHIP), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(rType));
tracer.assertEvents(OnRelationshipTypeScan(rType));
assertTrue(cursor.next());
tracer.assertEvents(OnRelationship(cursor.relationshipReference()));
assertFalse(cursor.next());
tracer.assertEvents();
}
}
use of org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor in project neo4j by neo4j.
the class RelationshipTypeIndexCursorTestBase method shouldTraceRelationshipTypeScanEvents.
@Test
void shouldTraceRelationshipTypeScanEvents() throws KernelException {
long first;
long second;
long third;
try (KernelTransaction tx = beginTransaction()) {
first = createRelationship(tx.dataWrite(), typeOne);
second = createRelationship(tx.dataWrite(), typeTwo);
third = createRelationship(tx.dataWrite(), typeTwo);
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
org.neo4j.internal.kernel.api.Read read = tx.dataRead();
try (RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
TestKernelReadTracer tracer = new TestKernelReadTracer();
cursor.setTracer(tracer);
// when
relationshipTypeScan(tx, typeOne, cursor, IndexOrder.NONE);
exhaustCursor(cursor);
// then
tracer.assertEvents(new TraceEvent(RelationshipTypeScan, typeOne), new TraceEvent(Relationship, first));
// when
relationshipTypeScan(tx, typeTwo, cursor, IndexOrder.NONE);
exhaustCursor(cursor);
// then
tracer.assertEvents(new TraceEvent(RelationshipTypeScan, typeTwo), new TraceEvent(Relationship, second), new TraceEvent(Relationship, third));
}
}
}
use of org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor in project neo4j by neo4j.
the class RelationshipTypeIndexCursorTestBase method shouldFindRelationshipsByTypeInTx.
@ParameterizedTest
@EnumSource(value = IndexOrder.class)
void shouldFindRelationshipsByTypeInTx(IndexOrder order) throws KernelException {
long inStore;
long inStore2;
long deletedInTx;
long createdInTx;
long createdInTx2;
try (KernelTransaction tx = beginTransaction()) {
inStore = createRelationship(tx.dataWrite(), typeOne);
createRelationship(tx.dataWrite(), typeTwo);
deletedInTx = createRelationship(tx.dataWrite(), typeOne);
inStore2 = createRelationship(tx.dataWrite(), typeOne);
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
tx.dataWrite().relationshipDelete(deletedInTx);
createdInTx = createRelationship(tx.dataWrite(), typeOne);
createRelationship(tx.dataWrite(), typeTwo);
createdInTx2 = createRelationship(tx.dataWrite(), typeOne);
try (RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
MutableLongSet uniqueIds = new LongHashSet();
// when
relationshipTypeScan(tx, typeOne, cursor, order);
// then
assertRelationships(cursor, uniqueIds, order, inStore, inStore2, createdInTx, createdInTx2);
}
}
}
Aggregations