Search in sources :

Example 1 with IndexProgressor

use of org.neo4j.kernel.api.index.IndexProgressor in project neo4j by neo4j.

the class NativeIndexReader method startSeekForInitializedRange.

void startSeekForInitializedRange(IndexProgressor.EntityValueClient client, KEY treeKeyFrom, KEY treeKeyTo, PropertyIndexQuery[] query, IndexQueryConstraints constraints, boolean needFilter, CursorContext cursorContext) {
    if (isEmptyRange(treeKeyFrom, treeKeyTo)) {
        client.initialize(descriptor, IndexProgressor.EMPTY, query, constraints, false);
        return;
    }
    try {
        Seeker<KEY, VALUE> seeker = makeIndexSeeker(treeKeyFrom, treeKeyTo, constraints.order(), cursorContext);
        IndexProgressor hitProgressor = getIndexProgressor(seeker, client, needFilter, query);
        client.initialize(descriptor, hitProgressor, query, constraints, false);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : IndexProgressor(org.neo4j.kernel.api.index.IndexProgressor) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 2 with IndexProgressor

use of org.neo4j.kernel.api.index.IndexProgressor in project neo4j by neo4j.

the class DocValuesCollectorTest method shouldNotSaveScoresForIndexProgressorWhenNotRequired.

@Test
void shouldNotSaveScoresForIndexProgressorWhenNotRequired() throws Exception {
    // given
    DocValuesCollector collector = new DocValuesCollector(false);
    IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
    // when
    collector.doSetNextReader(readerStub.getContext());
    collector.collect(1);
    // then
    AtomicReference<AcceptedEntity> ref = new AtomicReference<>();
    IndexProgressor.EntityValueClient client = new EntityValueClientWritingToReference(ref);
    IndexProgressor progressor = collector.getIndexProgressor("field", client);
    assertTrue(progressor.next());
    assertFalse(progressor.next());
    progressor.close();
    AcceptedEntity entity = ref.get();
    assertThat(entity.reference).isEqualTo(1L);
    assertTrue(Float.isNaN(entity.score));
}
Also used : IndexReaderStub(org.neo4j.kernel.api.impl.index.IndexReaderStub) IndexProgressor(org.neo4j.kernel.api.index.IndexProgressor) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 3 with IndexProgressor

use of org.neo4j.kernel.api.index.IndexProgressor in project neo4j by neo4j.

the class DefaultTokenIndexReader method query.

@Override
public void query(IndexProgressor.EntityTokenClient client, IndexQueryConstraints constraints, TokenPredicate query, EntityRange range, CursorContext cursorContext) {
    try {
        final int tokenId = query.tokenId();
        final IndexOrder order = constraints.order();
        Seeker<TokenScanKey, TokenScanValue> seeker = seekerForToken(range, tokenId, order, cursorContext);
        IndexProgressor progressor = new TokenScanValueIndexProgressor(seeker, client, order, range);
        client.initialize(progressor, tokenId, order);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : IndexProgressor(org.neo4j.kernel.api.index.IndexProgressor) UncheckedIOException(java.io.UncheckedIOException) IndexOrder(org.neo4j.internal.schema.IndexOrder) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 4 with IndexProgressor

use of org.neo4j.kernel.api.index.IndexProgressor in project neo4j by neo4j.

the class NodeLabelIndexCursorScan method scanStore.

@Override
protected boolean scanStore(NodeLabelIndexCursor cursor, int sizeHint, LongIterator addedItems) {
    DefaultNodeLabelIndexCursor indexCursor = (DefaultNodeLabelIndexCursor) cursor;
    indexCursor.setRead(read);
    IndexProgressor indexProgressor = storageScan.initializeBatch(indexCursor, sizeHint, cursorContext);
    if (indexProgressor == IndexProgressor.EMPTY && !addedItems.hasNext()) {
        return false;
    } else {
        indexCursor.initialize(indexProgressor, label, addedItems, removed);
        return true;
    }
}
Also used : IndexProgressor(org.neo4j.kernel.api.index.IndexProgressor)

Example 5 with IndexProgressor

use of org.neo4j.kernel.api.index.IndexProgressor in project neo4j by neo4j.

the class DocValuesCollectorTest method shouldSaveScoresForIndexProgressorWhenRequired.

@Test
void shouldSaveScoresForIndexProgressorWhenRequired() throws Exception {
    // given
    DocValuesCollector collector = new DocValuesCollector(true);
    IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
    float score = 13.42f;
    // when
    collector.doSetNextReader(readerStub.getContext());
    collector.setScorer(constantScorer(score));
    collector.collect(1);
    // then
    AtomicReference<AcceptedEntity> ref = new AtomicReference<>();
    IndexProgressor.EntityValueClient client = new EntityValueClientWritingToReference(ref);
    IndexProgressor progressor = collector.getIndexProgressor("field", client);
    assertTrue(progressor.next());
    assertFalse(progressor.next());
    progressor.close();
    AcceptedEntity entity = ref.get();
    assertThat(entity.reference).isEqualTo(1L);
    assertThat(entity.score).isEqualTo(score);
}
Also used : IndexReaderStub(org.neo4j.kernel.api.impl.index.IndexReaderStub) IndexProgressor(org.neo4j.kernel.api.index.IndexProgressor) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Aggregations

IndexProgressor (org.neo4j.kernel.api.index.IndexProgressor)9 Test (org.junit.jupiter.api.Test)4 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 IndexReaderStub (org.neo4j.kernel.api.impl.index.IndexReaderStub)2 ArrayList (java.util.ArrayList)1 PrimitiveIterator (java.util.PrimitiveIterator)1 Term (org.apache.lucene.index.Term)1 ParseException (org.apache.lucene.queryparser.classic.ParseException)1 BooleanQuery (org.apache.lucene.search.BooleanQuery)1 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)1 Query (org.apache.lucene.search.Query)1 TermQuery (org.apache.lucene.search.TermQuery)1 TermRangeQuery (org.apache.lucene.search.TermRangeQuery)1 WildcardQuery (org.apache.lucene.search.WildcardQuery)1 IndexQueryConstraints (org.neo4j.internal.kernel.api.IndexQueryConstraints)1 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)1 NodeValueIndexCursor (org.neo4j.internal.kernel.api.NodeValueIndexCursor)1 PropertyIndexQuery (org.neo4j.internal.kernel.api.PropertyIndexQuery)1