use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class EntityValueIndexCursorTestBase method shouldRespectOrderCapabilitiesForTemporal.
@Test
void shouldRespectOrderCapabilitiesForTemporal() throws KernelException {
// given
boolean needsValues = indexParams.indexProvidesTemporalValues();
int prop = token.propertyKey(PROP_NAME);
IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
IndexOrderCapability orderCapabilities = index.reference().getCapability().orderCapability(ValueCategory.TEMPORAL);
try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
if (orderCapabilities.supportsAsc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.ASCENDING, needsValues), PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), true, DateValue.date(1989, 3, 24), true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.ASCENDING);
}
if (orderCapabilities.supportsDesc()) {
// when
entityParams.entityIndexSeek(tx, index, cursor, constrained(IndexOrder.DESCENDING, needsValues), PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), true, DateValue.date(1989, 3, 24), true));
// then
assertFoundEntitiesInOrder(cursor, IndexOrder.DESCENDING);
}
}
}
use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class QueryValidator method validateOrder.
static void validateOrder(IndexCapability capability, IndexOrder indexOrder, PropertyIndexQuery[] predicates) {
if (indexOrder != IndexOrder.NONE) {
ValueCategory valueCategory = predicates[0].valueGroup().category();
IndexOrderCapability orderCapability = capability.orderCapability(valueCategory);
if (indexOrder == IndexOrder.ASCENDING && !orderCapability.supportsAsc() || indexOrder == IndexOrder.DESCENDING && !orderCapability.supportsDesc()) {
throw new UnsupportedOperationException(format("Tried to query index with unsupported order %s. For query %s supports ascending: %b, supports descending: %b.", indexOrder, Arrays.toString(predicates), orderCapability.supportsAsc(), orderCapability.supportsDesc()));
}
}
}
use of org.neo4j.internal.schema.IndexOrderCapability in project neo4j by neo4j.
the class NativeIndexAccessorTests method respectIndexOrder.
@Test
void respectIndexOrder() throws Exception {
// given
int nUpdates = 10000;
ValueType[] types = supportedTypesExcludingNonOrderable();
Iterator<ValueIndexEntryUpdate<IndexDescriptor>> randomUpdateGenerator = valueCreatorUtil.randomUpdateGenerator(random, types);
// noinspection unchecked
ValueIndexEntryUpdate<IndexDescriptor>[] someUpdates = new ValueIndexEntryUpdate[nUpdates];
for (int i = 0; i < nUpdates; i++) {
someUpdates[i] = randomUpdateGenerator.next();
}
processAll(someUpdates);
Value[] allValues = ValueCreatorUtil.extractValuesFromUpdates(someUpdates);
// when
try (var reader = accessor.newValueReader()) {
ValueGroup valueGroup = random.among(allValues).valueGroup();
PropertyIndexQuery.RangePredicate<?> supportedQuery = PropertyIndexQuery.range(0, valueGroup);
IndexOrderCapability supportedOrders = indexCapability().orderCapability(valueGroup.category());
if (supportedOrders.supportsAsc()) {
expectIndexOrder(allValues, valueGroup, reader, IndexOrder.ASCENDING, supportedQuery);
}
if (supportedOrders.supportsDesc()) {
expectIndexOrder(allValues, valueGroup, reader, IndexOrder.DESCENDING, supportedQuery);
}
}
}
Aggregations