use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.
the class IndexOrderTestBase method shouldDoOrderedCompositeIndexScanWithPointsInBothValues.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldDoOrderedCompositeIndexScanWithPointsInBothValues(IndexOrder indexOrder) throws Exception {
List<Pair<Long, Value[]>> expected = new ArrayList<>();
try (KernelTransaction tx = beginTransaction()) {
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, pointValue(Cartesian, -500000, -500000), "b"));
expected.add(entityWithTwoProps(tx, pointValue(Cartesian, 500000, -500000), "b"));
expected.add(entityWithTwoProps(tx, pointValue(Cartesian, -500000, 500000), "b"));
expected.add(entityWithTwoProps(tx, pointValue(Cartesian, 500000, 500000), "b"));
expected.add(entityWithTwoProps(tx, "a", pointValue(Cartesian, -500000, -500000)));
expected.add(entityWithTwoProps(tx, "a", pointValue(Cartesian, 500000, -500000)));
expected.add(entityWithTwoProps(tx, "a", pointValue(Cartesian, -500000, 500000)));
expected.add(entityWithTwoProps(tx, "a", pointValue(Cartesian, 500000, 500000)));
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.helpers.collection.Pair in project neo4j by neo4j.
the class IndexOrderTestBase method shouldNodeIndexScanInOrderWithPointsAndNodesBefore.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldNodeIndexScanInOrderWithPointsAndNodesBefore(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" }));
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" }));
entityIndexScan(tx, index, cursor, constrained(indexOrder, true));
assertResultsInOrder(expected, cursor, indexOrder);
}
}
}
use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.
the class IndexOrderTestBase method shouldPrefixScanInOrder.
@ParameterizedTest
@EnumSource(value = IndexOrder.class, names = { "ASCENDING", "DESCENDING" })
void shouldPrefixScanInOrder(IndexOrder indexOrder) throws Exception {
List<Pair<Long, Value>> expected = new ArrayList<>();
try (KernelTransaction tx = beginTransaction()) {
expected.add(entityWithProp(tx, "bee hive"));
entityWithProp(tx, "a");
expected.add(entityWithProp(tx, "become"));
expected.add(entityWithProp(tx, "be"));
expected.add(entityWithProp(tx, "bachelor"));
entityWithProp(tx, "street smart");
expected.add(entityWithProp(tx, "builder"));
entityWithProp(tx, "ceasar");
tx.commit();
}
createIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
IndexReadSession index = tx.dataRead().indexReadSession(tx.schemaRead().indexGetForName(INDEX_NAME));
try (var cursor = getEntityValueIndexCursor(tx)) {
entityWithProp(tx, "allow");
expected.add(entityWithProp(tx, "bastard"));
expected.add(entityWithProp(tx, "bully"));
entityWithProp(tx, "willow");
PropertyIndexQuery query = PropertyIndexQuery.stringPrefix(prop, stringValue("b"));
entityIndexSeek(tx, index, cursor, constrained(indexOrder, true), query);
assertResultsInOrder(expected, cursor, indexOrder);
}
}
}
use of org.neo4j.internal.helpers.collection.Pair 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.helpers.collection.Pair in project neo4j by neo4j.
the class IndexTransactionStateTestBase method shouldPerformStringPrefixSearch.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringPrefixSearch(boolean needsValues) throws Exception {
// given
Set<Pair<Long, Value>> expected = new HashSet<>();
try (KernelTransaction tx = beginTransaction()) {
expected.add(entityWithProp(tx, "suff1"));
entityWithPropId(tx, "supp");
tx.commit();
}
createIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
expected.add(entityWithProp(tx, "suff2"));
entityWithPropId(tx, "skruff");
IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
assertEntityAndValueForSeek(expected, tx, index, needsValues, "suffpa", PropertyIndexQuery.stringPrefix(prop, stringValue("suff")));
}
}
Aggregations