use of org.neo4j.internal.kernel.api.PropertyIndexQuery in project neo4j by neo4j.
the class DeferredConflictCheckingIndexUpdaterTest method shouldQueryAboutAddedAndChangedValueTuples.
@Test
void shouldQueryAboutAddedAndChangedValueTuples() throws Exception {
// given
IndexUpdater actual = mock(IndexUpdater.class);
ValueIndexReader reader = mock(ValueIndexReader.class);
doAnswer(new NodeIdsIndexReaderQueryAnswer(descriptor, 0)).when(reader).query(any(), any(), any(), any(), any());
long nodeId = 0;
List<ValueIndexEntryUpdate<IndexDescriptor>> updates = new ArrayList<>();
updates.add(add(nodeId++, descriptor, tuple(10, 11)));
updates.add(change(nodeId++, descriptor, tuple("abc", "def"), tuple("ghi", "klm")));
updates.add(remove(nodeId++, descriptor, tuple(1001L, 1002L)));
updates.add(change(nodeId++, descriptor, tuple((byte) 2, (byte) 3), tuple((byte) 4, (byte) 5)));
updates.add(add(nodeId, descriptor, tuple(5, "5")));
try (DeferredConflictCheckingIndexUpdater updater = new DeferredConflictCheckingIndexUpdater(actual, () -> reader, descriptor, NULL)) {
// when
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
updater.process(update);
verify(actual).process(update);
}
}
// then
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
if (update.updateMode() == UpdateMode.ADDED || update.updateMode() == UpdateMode.CHANGED) {
Value[] tuple = update.values();
PropertyIndexQuery[] query = new PropertyIndexQuery[tuple.length];
for (int i = 0; i < tuple.length; i++) {
query[i] = PropertyIndexQuery.exact(propertyKeyIds[i], tuple[i]);
}
verify(reader).query(any(), any(), any(), eq(query[0]), eq(query[1]));
}
}
verify(reader).close();
verifyNoMoreInteractions(reader);
}
use of org.neo4j.internal.kernel.api.PropertyIndexQuery 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);
}
}
use of org.neo4j.internal.kernel.api.PropertyIndexQuery in project neo4j by neo4j.
the class NativeIndexAccessorTests method mustHandleMultipleNestedQueries.
private void mustHandleMultipleNestedQueries(ValueIndexEntryUpdate<IndexDescriptor>[] updates) throws IndexEntryConflictException, IndexNotApplicableKernelException {
processAll(updates);
ValueCreatorUtil.sort(updates);
// when
var reader = accessor.newValueReader();
PropertyIndexQuery query1 = ValueCreatorUtil.rangeQuery(valueOf(updates[4]), true, valueOf(updates[5]), true);
PropertyIndexQuery query2 = ValueCreatorUtil.rangeQuery(valueOf(updates[2]), true, valueOf(updates[3]), true);
PropertyIndexQuery query3 = ValueCreatorUtil.rangeQuery(valueOf(updates[0]), true, valueOf(updates[1]), true);
long[] expected1 = { entityIdOf(updates[4]), entityIdOf(updates[5]) };
long[] expected2 = { entityIdOf(updates[2]), entityIdOf(updates[3]) };
long[] expected3 = { entityIdOf(updates[0]), entityIdOf(updates[1]) };
Collection<Long> result1 = new ArrayList<>();
try (NodeValueIterator iter1 = query(reader, query1)) {
while (iter1.hasNext()) {
result1.add(iter1.next());
Collection<Long> result2 = new ArrayList<>();
try (NodeValueIterator iter2 = query(reader, query2)) {
while (iter2.hasNext()) {
result2.add(iter2.next());
Collection<Long> result3 = new ArrayList<>();
try (NodeValueIterator iter3 = query(reader, query3)) {
while (iter3.hasNext()) {
result3.add(iter3.next());
}
}
assertEntityIdHits(expected3, result3);
}
}
assertEntityIdHits(expected2, result2);
}
}
assertEntityIdHits(expected1, result1);
}
use of org.neo4j.internal.kernel.api.PropertyIndexQuery in project neo4j by neo4j.
the class NativeIndexAccessorTests method shouldNotSeeFilteredEntries.
@Test
void shouldNotSeeFilteredEntries() throws Exception {
// given
ValueIndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleTypeNoDuplicates(supportedTypesExcludingNonOrderable());
processAll(updates);
ValueCreatorUtil.sort(updates);
var reader = accessor.newValueReader();
// when
try (NodeValueIterator iter = new NodeValueIterator()) {
PropertyIndexQuery.ExactPredicate filter = PropertyIndexQuery.exact(0, valueOf(updates[1]));
PropertyIndexQuery rangeQuery = ValueCreatorUtil.rangeQuery(valueOf(updates[0]), true, valueOf(updates[2]), true);
IndexProgressor.EntityValueClient filterClient = filterClient(iter, filter);
reader.query(NULL_CONTEXT, filterClient, unconstrained(), rangeQuery);
// then
assertTrue(iter.hasNext());
assertEquals(entityIdOf(updates[1]), iter.next());
assertFalse(iter.hasNext());
}
}
use of org.neo4j.internal.kernel.api.PropertyIndexQuery in project neo4j by neo4j.
the class FusionIndexReaderTest method mustSelectGenericForExactPredicateWithOtherValue.
@Test
void mustSelectGenericForExactPredicateWithOtherValue() throws Exception {
// given
for (Object value : FusionIndexTestHelp.valuesNotSupportedBySpecificIndex()) {
PropertyIndexQuery indexQuery = PropertyIndexQuery.exact(PROP_KEY, value);
// then
verifyQueryWithCorrectReader(readers.get(GENERIC), indexQuery);
}
}
Aggregations