use of org.neo4j.internal.kernel.api.TokenPredicate in project neo4j by neo4j.
the class NodeLabelIndexOrderTest method tokenScan.
@Override
protected void tokenScan(IndexOrder indexOrder, KernelTransaction tx, int label, NodeLabelIndexCursor cursor) throws KernelException {
IndexDescriptor index = tx.schemaRead().index(SchemaDescriptor.forAnyEntityTokens(EntityType.NODE)).next();
TokenReadSession tokenReadSession = tx.dataRead().tokenReadSession(index);
tx.dataRead().nodeLabelScan(tokenReadSession, cursor, IndexQueryConstraints.ordered(indexOrder), new TokenPredicate(label));
}
use of org.neo4j.internal.kernel.api.TokenPredicate 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.TokenPredicate 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.TokenPredicate in project neo4j by neo4j.
the class BatchInsertTokenIndexesTest method assertTokenIndexContains.
private void assertTokenIndexContains(TokenIndexReader reader, int tokenId, Long... intityIds) {
SimpleEntityTokenClient tokenClient = new SimpleEntityTokenClient();
reader.query(tokenClient, unconstrained(), new TokenPredicate(tokenId), CursorContext.NULL);
var found = new ArrayList<Long>();
while (tokenClient.next()) {
found.add(tokenClient.reference);
}
assertThat(found).containsExactlyInAnyOrder(intityIds);
}
use of org.neo4j.internal.kernel.api.TokenPredicate 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