Search in sources :

Example 1 with NodeIdsIndexReaderQueryAnswer

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);
        }
    }
}
Also used : NodeValueIterator(org.neo4j.kernel.impl.index.schema.NodeValueIterator) NodeIdsIndexReaderQueryAnswer(org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) LongSet(org.eclipse.collections.api.set.primitive.LongSet) Test(org.junit.jupiter.api.Test)

Example 2 with NodeIdsIndexReaderQueryAnswer

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);
}
Also used : NodeIdsIndexReaderQueryAnswer(org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) LongSet(org.eclipse.collections.api.set.primitive.LongSet) Test(org.junit.jupiter.api.Test)

Example 3 with NodeIdsIndexReaderQueryAnswer

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);
}
Also used : NodeIdsIndexReaderQueryAnswer(org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) LongSet(org.eclipse.collections.api.set.primitive.LongSet) Test(org.junit.jupiter.api.Test)

Example 4 with NodeIdsIndexReaderQueryAnswer

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);
}
Also used : NodeIdsIndexReaderQueryAnswer(org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) LongSet(org.eclipse.collections.api.set.primitive.LongSet) Test(org.junit.jupiter.api.Test)

Example 5 with NodeIdsIndexReaderQueryAnswer

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();
}
Also used : NodeIdsIndexReaderQueryAnswer(org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer) InOrder(org.mockito.InOrder) CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) ValueIndexReader(org.neo4j.kernel.api.index.ValueIndexReader) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Aggregations

NodeIdsIndexReaderQueryAnswer (org.neo4j.kernel.impl.index.schema.NodeIdsIndexReaderQueryAnswer)8 Test (org.junit.jupiter.api.Test)7 LongSet (org.eclipse.collections.api.set.primitive.LongSet)6 PropertyIndexQuery (org.neo4j.internal.kernel.api.PropertyIndexQuery)6 InOrder (org.mockito.InOrder)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 CursorContext (org.neo4j.io.pagecache.context.CursorContext)1 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)1 ValueIndexReader (org.neo4j.kernel.api.index.ValueIndexReader)1 NodeValueIterator (org.neo4j.kernel.impl.index.schema.NodeValueIterator)1