use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class IndexOrderTestBase method shouldDoOrderedCompositeIndexScanWithPointsInBothValuesWithTwoGapsBetween.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldDoOrderedCompositeIndexScanWithPointsInBothValuesWithTwoGapsBetween(IndexOrder indexOrder) throws Exception {
List<Pair<Long, Value[]>> expected = new ArrayList<>();
try (KernelTransaction tx = beginTransaction()) {
expected.add(entityWithTwoProps(tx, new String[] { "a" }, new String[] { "b" }));
expected.add(entityWithTwoProps(tx, pointValue(Cartesian, -500000, -500000), "a"));
expected.add(entityWithTwoProps(tx, pointValue(Cartesian, 500000, -500000), "a"));
expected.add(entityWithTwoProps(tx, pointValue(Cartesian, -500000, 500000), "a"));
expected.add(entityWithTwoProps(tx, pointValue(Cartesian, 500000, 500000), "a"));
expected.add(entityWithTwoProps(tx, "b", new String[] { "b" }));
expected.add(entityWithTwoProps(tx, "b", new String[] { "c" }));
expected.add(entityWithTwoProps(tx, "b", pointValue(Cartesian, -500000, -500000)));
expected.add(entityWithTwoProps(tx, "b", pointValue(Cartesian, 500000, -500000)));
expected.add(entityWithTwoProps(tx, "b", pointValue(Cartesian, -500000, 500000)));
expected.add(entityWithTwoProps(tx, "b", pointValue(Cartesian, 500000, 500000)));
expected.add(entityWithTwoProps(tx, "c", new String[] { "b" }));
tx.commit();
}
createCompositeIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
IndexReadSession index = tx.dataRead().indexReadSession(tx.schemaRead().indexGetForName(INDEX_NAME));
try (var cursor = getEntityValueIndexCursor(tx)) {
entityIndexScan(tx, index, cursor, constrained(indexOrder, true));
assertCompositeResultsInOrder(expected, cursor, indexOrder);
}
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class KernelReadTracerTest method shouldTraceNodeIndexSeek.
@Test
void shouldTraceNodeIndexSeek() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (NodeValueIndexCursor cursor = cursors.allocateNodeValueIndexCursor(NULL, EmptyMemoryTracker.INSTANCE)) {
int p1 = token.propertyKey("p1");
IndexReadSession session = read.indexReadSession(index);
assertIndexSeekTracing(tracer, cursor, session, IndexOrder.NONE, p1);
assertIndexSeekTracing(tracer, cursor, session, IndexOrder.ASCENDING, p1);
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class KernelReadTracerTest method shouldTraceRelationshipIndexSeek.
@Test
void shouldTraceRelationshipIndexSeek() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (RelationshipValueIndexCursor cursor = cursors.allocateRelationshipValueIndexCursor(NULL, INSTANCE)) {
int p1 = token.propertyKey("p1");
IndexReadSession session = read.indexReadSession(relIndex);
assertRelationshipIndexSeekTracing(tracer, cursor, session, IndexOrder.NONE, p1);
assertRelationshipIndexSeekTracing(tracer, cursor, session, IndexOrder.ASCENDING, p1);
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class KernelReadTracerTxStateTest method shouldTraceIndexSeek.
@Test
void shouldTraceIndexSeek() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
String indexName = createIndex("User", "name");
try (KernelTransaction tx = beginTransaction();
NodeValueIndexCursor cursor = tx.cursors().allocateNodeValueIndexCursor(NULL, tx.memoryTracker())) {
int name = tx.token().propertyKey("name");
int user = tx.token().nodeLabel("User");
long n = tx.dataWrite().nodeCreate();
tx.dataWrite().nodeAddLabel(n, user);
tx.dataWrite().nodeSetProperty(n, name, Values.stringValue("Bosse"));
IndexDescriptor index = tx.schemaRead().indexGetForName(indexName);
IndexReadSession session = tx.dataRead().indexReadSession(index);
// when
assertIndexSeekTracing(tracer, tx, cursor, session, IndexOrder.NONE, false, user);
assertIndexSeekTracing(tracer, tx, cursor, session, IndexOrder.NONE, true, user);
assertIndexSeekTracing(tracer, tx, cursor, session, IndexOrder.ASCENDING, false, user);
assertIndexSeekTracing(tracer, tx, cursor, session, IndexOrder.ASCENDING, true, user);
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class FulltextIndexProviderTest method verifyNodeData.
private void verifyNodeData(long thirdNodeId) throws Exception {
try (Transaction tx = db.beginTx()) {
KernelTransaction ktx = LuceneFulltextTestSupport.kernelTransaction(tx);
IndexReadSession index = ktx.dataRead().indexReadSession(ktx.schemaRead().indexGetForName("fulltext"));
try (NodeValueIndexCursor cursor = ktx.cursors().allocateNodeValueIndexCursor(ktx.cursorContext(), ktx.memoryTracker())) {
ktx.dataRead().nodeIndexSeek(index, cursor, unconstrained(), fulltextSearch("value"));
assertTrue(cursor.next());
assertEquals(0L, cursor.nodeReference());
assertFalse(cursor.next());
ktx.dataRead().nodeIndexSeek(index, cursor, unconstrained(), fulltextSearch("villa"));
assertTrue(cursor.next());
assertEquals(thirdNodeId, cursor.nodeReference());
assertFalse(cursor.next());
ktx.dataRead().nodeIndexSeek(index, cursor, unconstrained(), fulltextSearch("value3"));
MutableLongSet ids = LongSets.mutable.empty();
ids.add(0L);
ids.add(thirdNodeId);
assertTrue(cursor.next());
assertTrue(ids.remove(cursor.nodeReference()));
assertTrue(cursor.next());
assertTrue(ids.remove(cursor.nodeReference()));
assertFalse(cursor.next());
}
tx.commit();
}
}
Aggregations