use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldRespectOrderCapabilitiesForNumbers.
@Test
void shouldRespectOrderCapabilitiesForNumbers() throws Exception {
// given
boolean needsValues = indexParams.indexProvidesNumericValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexOrderCapability orderCapabilities = index.reference().getCapability().orderCapability(ValueCategory.NUMBER);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
if (orderCapabilities.supportsAsc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, needsValues), PropertyIndexQuery.range(prop, 1, true, 42, true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.ASCENDING);
}
if (orderCapabilities.supportsDesc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.DESCENDING, needsValues), PropertyIndexQuery.range(prop, 1, true, 42, true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldRespectOrderCapabilitiesForStrings.
@Test
void shouldRespectOrderCapabilitiesForStrings() throws Exception {
// given
boolean needsValues = indexParams.indexProvidesStringValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexOrderCapability orderCapabilities = index.reference().getCapability().orderCapability(ValueCategory.TEXT);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
if (orderCapabilities.supportsAsc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, needsValues), PropertyIndexQuery.range(prop, "one", true, "two", true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.ASCENDING);
}
if (orderCapabilities.supportsDesc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.DESCENDING, needsValues), PropertyIndexQuery.range(prop, "one", true, "two", true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldRespectOrderCapabilitiesForWildcard.
@Test
void shouldRespectOrderCapabilitiesForWildcard() throws Exception {
// given
boolean needsValues = false;
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexOrderCapability orderCapabilities = index.reference().getCapability().orderCapability(ValueCategory.UNKNOWN);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
if (orderCapabilities.supportsAsc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, needsValues), PropertyIndexQuery.exists(prop));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.ASCENDING);
}
if (orderCapabilities.supportsDesc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.DESCENDING, needsValues), PropertyIndexQuery.exists(prop));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldRespectOrderCapabilitiesForStringArray.
@Test
void shouldRespectOrderCapabilitiesForStringArray() throws KernelException {
// given
boolean needsValues = indexParams.indexProvidesSpatialValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexOrderCapability orderCapabilities = index.reference().getCapability().orderCapability(ValueCategory.TEXT_ARRAY);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
if (orderCapabilities.supportsAsc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, needsValues), PropertyIndexQuery.range(prop, Values.of(new String[] { "first", "second", "third" }), true, Values.of(new String[] { "fourth", "fifth", "sixth", "seventh" }), true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.ASCENDING);
}
if (orderCapabilities.supportsDesc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.DESCENDING, needsValues), PropertyIndexQuery.range(prop, Values.of(new String[] { "first", "second", "third" }), true, Values.of(new String[] { "fourth", "fifth", "sixth", "seventh" }), true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class SimpleIndexAccessorCompatibility method shouldRangeSeekInOrderWithExpectedSize.
private void shouldRangeSeekInOrderWithExpectedSize(IndexOrder order, RangeSeekMode rangeSeekMode, int expectedSize, Object... objects) throws Exception {
PropertyIndexQuery range;
switch(rangeSeekMode) {
case CLOSED:
range = range(100, Values.of(objects[0]), true, Values.of(objects[objects.length - 1]), true);
break;
case OPEN_END:
range = range(100, Values.of(objects[0]), true, null, false);
break;
case OPEN_START:
range = range(100, null, false, Values.of(objects[objects.length - 1]), true);
break;
default:
throw new IllegalStateException();
}
IndexOrderCapability indexOrders = orderCapability(range);
if (order == IndexOrder.ASCENDING) {
Assume.assumeTrue("Assume support for order " + order, indexOrders.supportsAsc());
} else if (order == IndexOrder.DESCENDING) {
Assume.assumeTrue("Assume support for order " + order, indexOrders.supportsDesc());
}
List<ValueIndexEntryUpdate<?>> additions = Arrays.stream(objects).map(o -> add(1, descriptor.schema(), o)).collect(Collectors.toList());
Collections.shuffle(additions, random.random());
updateAndCommit(additions);
SimpleEntityValueClient client = new SimpleEntityValueClient();
try (AutoCloseable ignored = query(client, order, range)) {
List<Long> seenIds = assertClientReturnValuesInOrder(client, order);
assertThat(seenIds.size()).isEqualTo(expectedSize);
}
}
Aggregations