use of org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer in project neo4j by neo4j.
the class FusionIndexReaderTest method mustCombineResultFromExistsPredicate.
@Test
void mustCombineResultFromExistsPredicate() throws Exception {
// given
PropertyIndexQuery.ExistsPredicate exists = PropertyIndexQuery.exists(PROP_KEY);
long lastId = 0;
for (var aliveReader : aliveReaders) {
doAnswer(new NodeIdsIndexReaderQueryAnswer(DESCRIPTOR, lastId++, lastId++)).when(aliveReader).query(any(), any(), any(), any());
}
// when
LongSet resultSet;
try (NodeValueIterator result = new NodeValueIterator()) {
fusionIndexReader.query(NULL_CONTEXT, result, unconstrained(), exists);
// then
resultSet = PrimitiveLongCollections.asSet(result);
for (long i = 0L; i < lastId; i++) {
assertTrue(resultSet.contains(i), "Expected to contain " + i + ", but was " + resultSet);
}
}
}
use of org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer in project neo4j by neo4j.
the class PartitionedValueIndexReaderTest method rangeSeekByStringOverPartitions.
@Test
void rangeSeekByStringOverPartitions() throws Exception {
PartitionedValueIndexReader indexReader = createPartitionedReaderFromReaders();
PropertyIndexQuery.RangePredicate<?> query = PropertyIndexQuery.range(1, "a", false, "b", true);
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 1)).when(indexReader1).query(any(), any(), any(), any());
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 2)).when(indexReader2).query(any(), any(), any(), any());
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 3)).when(indexReader3).query(any(), any(), any(), any());
LongSet results = queryResultAsSet(indexReader, query);
verifyResult(results);
}
use of org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer in project neo4j by neo4j.
the class PartitionedValueIndexReaderTest method scanOverPartitions.
@Test
void scanOverPartitions() throws Exception {
PartitionedValueIndexReader indexReader = createPartitionedReaderFromReaders();
PropertyIndexQuery.ExistsPredicate query = PropertyIndexQuery.exists(1);
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 1)).when(indexReader1).query(any(), any(), any(), any());
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 2)).when(indexReader2).query(any(), any(), any(), any());
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 3)).when(indexReader3).query(any(), any(), any(), any());
LongSet results = queryResultAsSet(indexReader, query);
verifyResult(results);
}
use of org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer in project neo4j by neo4j.
the class PartitionedValueIndexReaderTest method rangeSeekByNumberOverPartitions.
@Test
void rangeSeekByNumberOverPartitions() throws Exception {
PartitionedValueIndexReader indexReader = createPartitionedReaderFromReaders();
PropertyIndexQuery.RangePredicate<?> query = PropertyIndexQuery.range(1, 1, true, 2, true);
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 1)).when(indexReader1).query(any(), any(), any(), any());
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 2)).when(indexReader2).query(any(), any(), any(), any());
doAnswer(new NodeIdsIndexReaderQueryAnswer(schemaIndexDescriptor, 3)).when(indexReader3).query(any(), any(), any(), any());
LongSet results = queryResultAsSet(indexReader, query);
verifyResult(results);
}
use of org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer in project neo4j by neo4j.
the class IndexingServiceTest method shouldStillReportInternalIndexStateAsPopulatingWhenConstraintIndexIsDonePopulating.
@Test
void shouldStillReportInternalIndexStateAsPopulatingWhenConstraintIndexIsDonePopulating() throws Exception {
// given
when(accessor.newUpdater(any(IndexUpdateMode.class), any(CursorContext.class))).thenReturn(updater);
ValueIndexReader indexReader = mock(ValueIndexReader.class);
when(accessor.newValueReader()).thenReturn(indexReader);
doAnswer(new NodeIdsIndexReaderQueryAnswer(index)).when(indexReader).query(any(), any(), any(), any());
IndexingService indexingService = newIndexingServiceWithMockedDependencies(populator, accessor, withData());
life.start();
// when
IndexDescriptor index = constraintIndexRule(0, labelId, propertyKeyId, PROVIDER_DESCRIPTOR);
indexingService.createIndexes(AUTH_DISABLED, index);
IndexProxy proxy = indexingService.getIndexProxy(index);
// don't wait for index to come ONLINE here since we're testing that it doesn't
verify(populator, timeout(20000)).close(eq(true), any());
try (IndexUpdater updater = proxy.newUpdater(IndexUpdateMode.ONLINE, NULL)) {
updater.process(add(10, "foo"));
}
// then
assertEquals(POPULATING, proxy.getState());
InOrder order = inOrder(populator, accessor, updater);
order.verify(populator).create();
order.verify(populator).close(eq(true), any());
order.verify(accessor).newUpdater(eq(IndexUpdateMode.ONLINE), any());
order.verify(updater).process(add(10, "foo"));
order.verify(updater).close();
}
Aggregations