use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldReturnDocValuesInRelevanceOrder.
@Test
void shouldReturnDocValuesInRelevanceOrder() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(true);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.setScorer(constantScorer(1.0f));
collector.collect(1);
collector.setScorer(constantScorer(2.0f));
collector.collect(2);
// then
LongIterator valuesIterator = collector.getValuesSortedByRelevance("id");
assertEquals(2, valuesIterator.next());
assertEquals(1, valuesIterator.next());
assertFalse(valuesIterator.hasNext());
}
use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldNotSaveScoresWhenNotRequired.
@Test
void shouldNotSaveScoresWhenNotRequired() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(false);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.collect(1);
// then
DocValuesCollector.MatchingDocs matchingDocs = collector.getMatchingDocs().get(0);
assertNull(matchingDocs.scores);
}
use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldSaveScoresWhenRequired.
@Test
void shouldSaveScoresWhenRequired() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(true);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.setScorer(constantScorer(13.42f));
collector.collect(1);
// then
DocValuesCollector.MatchingDocs matchingDocs = collector.getMatchingDocs().get(0);
assertArrayEquals(new float[] { 13.42f }, matchingDocs.scores, 0.001f);
}
use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldSaveScoresInADenseArray.
@Test
void shouldSaveScoresInADenseArray() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(true);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.setScorer(constantScorer(1.0f));
collector.collect(1);
collector.setScorer(constantScorer(41.0f));
collector.collect(41);
// then
DocValuesCollector.MatchingDocs matchingDocs = collector.getMatchingDocs().get(0);
assertArrayEquals(new float[] { 1.0f, 41.0f }, matchingDocs.scores, 0.001f);
}
use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldReturnEmptyIteratorWhenNoDocValuesInOrder.
@Test
void shouldReturnEmptyIteratorWhenNoDocValuesInOrder() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(false);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
// then
LongIterator valuesIterator = collector.getValuesSortedByRelevance("id");
assertFalse(valuesIterator.hasNext());
}
Aggregations