use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class AbstractIndexQueryingTest method relationshipIndexSeekMustThrowOnWrongIndexEntityType.
@Test
void relationshipIndexSeekMustThrowOnWrongIndexEntityType() throws IndexNotFoundKernelException {
IndexDescriptor index = schemaRead.indexGetForName("ftsNodes");
IndexReadSession indexReadSession = read.indexReadSession(index);
try (RelationshipValueIndexCursor cursor = cursors.allocateRelationshipValueIndexCursor(NULL, EmptyMemoryTracker.INSTANCE)) {
assertThrows(IndexNotApplicableKernelException.class, () -> read.relationshipIndexSeek(indexReadSession, cursor, unconstrained(), PropertyIndexQuery.fulltextSearch("search")));
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class NodeIndexTransactionStateTest method assertEntityAndValueForSeek.
@Override
void assertEntityAndValueForSeek(Set<Pair<Long, Value>> expected, KernelTransaction tx, IndexDescriptor index, boolean needsValues, Object anotherValueFoundByQuery, PropertyIndexQuery... queries) throws Exception {
try (NodeValueIndexCursor nodes = tx.cursors().allocateNodeValueIndexCursor(tx.cursorContext(), tx.memoryTracker())) {
IndexReadSession indexSession = tx.dataRead().indexReadSession(index);
tx.dataRead().nodeIndexSeek(indexSession, nodes, unordered(needsValues), queries);
assertEntityAndValue(expected, tx, needsValues, anotherValueFoundByQuery, new NodeCursorAdapter(nodes));
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class IndexOrderTestBase method shouldNodeIndexScanInOrderWithPointsAndSingleNodeAfterwards.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldNodeIndexScanInOrderWithPointsAndSingleNodeAfterwards(IndexOrder indexOrder) throws Exception {
List<Pair<Long, Value>> expected = new ArrayList<>();
try (KernelTransaction tx = beginTransaction()) {
// NOTE: strings come after points in natural ascending sort order
expected.add(entityWithProp(tx, "a"));
expected.add(entityWithProp(tx, pointValue(Cartesian, -500000, -500000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 500000, -500000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, -500000, 500000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 500000, 500000)));
tx.commit();
}
createIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
IndexReadSession index = tx.dataRead().indexReadSession(tx.schemaRead().indexGetForName(INDEX_NAME));
try (var cursor = getEntityValueIndexCursor(tx)) {
expected.add(entityWithProp(tx, pointValue(Cartesian, -400000, -400000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 400000, -400000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, -400000, 400000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 400000, 400000)));
expected.add(entityWithProp(tx, "b"));
entityIndexScan(tx, index, cursor, constrained(indexOrder, true));
assertResultsInOrder(expected, cursor, indexOrder);
}
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class IndexOrderTestBase method shouldNodeIndexScanInOrderWithPointsAndNodesOnBothSides.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldNodeIndexScanInOrderWithPointsAndNodesOnBothSides(IndexOrder indexOrder) throws Exception {
List<Pair<Long, Value>> expected = new ArrayList<>();
try (KernelTransaction tx = beginTransaction()) {
// NOTE: arrays come before points in natural ascending sort order
expected.add(entityWithProp(tx, new String[] { "a" }));
expected.add(entityWithProp(tx, new String[] { "b" }));
expected.add(entityWithProp(tx, new String[] { "c" }));
// NOTE: strings come after points in natural ascending sort order
expected.add(entityWithProp(tx, "a"));
expected.add(entityWithProp(tx, "b"));
expected.add(entityWithProp(tx, "c"));
expected.add(entityWithProp(tx, pointValue(Cartesian, -500000, -500000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 500000, -500000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, -500000, 500000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 500000, 500000)));
tx.commit();
}
createIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
IndexReadSession index = tx.dataRead().indexReadSession(tx.schemaRead().indexGetForName(INDEX_NAME));
try (var cursor = getEntityValueIndexCursor(tx)) {
expected.add(entityWithProp(tx, pointValue(Cartesian, -400000, -400000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 400000, -400000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, -400000, 400000)));
expected.add(entityWithProp(tx, pointValue(Cartesian, 400000, 400000)));
expected.add(entityWithProp(tx, new String[] { "d" }));
expected.add(entityWithProp(tx, "d"));
entityIndexScan(tx, index, cursor, constrained(indexOrder, true));
assertResultsInOrder(expected, cursor, indexOrder);
}
}
}
use of org.neo4j.internal.kernel.api.IndexReadSession in project neo4j by neo4j.
the class IndexOrderTestBase method shouldDoOrderedCompositeIndexScanWithPointsInBothValuesWithOneGapBetween.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldDoOrderedCompositeIndexScanWithPointsInBothValuesWithOneGapBetween(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", 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);
}
}
}
Aggregations