use of org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor in project neo4j by neo4j.
the class RelationshipTypeIndexCursorTestBase method shouldFindRelationshipsByType.
@ParameterizedTest
@EnumSource(value = IndexOrder.class)
void shouldFindRelationshipsByType(IndexOrder order) throws KernelException {
// GIVEN
long toDelete;
long relTwo;
long relThree;
long relTwo2;
long relThree2;
long relThree3;
try (KernelTransaction tx = beginTransaction()) {
createRelationship(tx.dataWrite(), typeOne);
relTwo = createRelationship(tx.dataWrite(), typeTwo);
relThree = createRelationship(tx.dataWrite(), typeThree);
toDelete = createRelationship(tx.dataWrite(), typeOne);
relTwo2 = createRelationship(tx.dataWrite(), typeTwo);
relThree2 = createRelationship(tx.dataWrite(), typeThree);
relThree3 = createRelationship(tx.dataWrite(), typeThree);
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
tx.dataWrite().relationshipDelete(toDelete);
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
try (RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
MutableLongSet uniqueIds = new LongHashSet();
// WHEN
relationshipTypeScan(tx, typeOne, cursor, order);
// THEN
assertRelationshipCount(cursor, 1, uniqueIds);
// WHEN
relationshipTypeScan(tx, typeTwo, cursor, order);
// THEN
assertRelationships(cursor, uniqueIds, order, relTwo, relTwo2);
// WHEN
relationshipTypeScan(tx, typeThree, cursor, order);
// THEN
assertRelationships(cursor, uniqueIds, order, relThree, relThree2, relThree3);
}
}
}
use of org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor in project neo4j by neo4j.
the class KernelReadTracerTest method shouldTraceRelationshipTypeScan.
@Test
void shouldTraceRelationshipTypeScan() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
int hasId = token.relationshipTypeGetOrCreateForName("HAS");
List<TraceEvent> expectedEvents = new ArrayList<>();
expectedEvents.add(OnRelationshipTypeScan(hasId));
try (RelationshipTypeIndexCursor cursor = cursors.allocateRelationshipTypeIndexCursor(NULL)) {
// when
cursor.setTracer(tracer);
read.relationshipTypeScan(getTokenReadSession(tx, EntityType.RELATIONSHIP), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(hasId));
while (cursor.next()) {
expectedEvents.add(OnRelationship(cursor.relationshipReference()));
}
}
// then
tracer.assertEvents(expectedEvents);
}
Aggregations