use of org.neo4j.internal.kernel.api.NodeValueIndexCursor 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.NodeValueIndexCursor in project neo4j by neo4j.
the class ManagedTestCursors method allocateNodeValueIndexCursor.
@Override
public NodeValueIndexCursor allocateNodeValueIndexCursor(CursorContext cursorContext, MemoryTracker memoryTracker) {
NodeValueIndexCursor n = cursors.allocateNodeValueIndexCursor(cursorContext, memoryTracker);
allCursors.add(n);
return n;
}
use of org.neo4j.internal.kernel.api.NodeValueIndexCursor 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.NodeValueIndexCursor 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();
}
}
use of org.neo4j.internal.kernel.api.NodeValueIndexCursor in project neo4j by neo4j.
the class FulltextIndexProviderTest method assertQueryResult.
private void assertQueryResult(KernelTransaction ktx, PropertyIndexQuery query, Long... expectedResultArray) throws KernelException {
List<Long> expectedResult = Arrays.asList(expectedResultArray);
IndexReadSession index = ktx.dataRead().indexReadSession(ktx.schemaRead().indexGetForName(NAME));
try (NodeValueIndexCursor cursor = ktx.cursors().allocateNodeValueIndexCursor(ktx.cursorContext(), ktx.memoryTracker())) {
List<Long> actualResult = new ArrayList<>();
ktx.dataRead().nodeIndexSeek(index, cursor, unconstrained(), query);
while (cursor.next()) {
actualResult.add(cursor.nodeReference());
}
actualResult.sort(Long::compareTo);
expectedResult.sort(Long::compareTo);
assertThat(actualResult).isEqualTo(expectedResult);
}
}
Aggregations