use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldSilentlyMergeSegmentsWhenReadingDocValues.
@Test
public void shouldSilentlyMergeSegmentsWhenReadingDocValues() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(false);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.collect(1);
collector.doSetNextReader(readerStub.getContext());
collector.collect(2);
// then
DocValuesCollector.LongValuesIterator valuesIterator = collector.getValuesIterator("id");
assertEquals(2, valuesIterator.remaining());
assertEquals(1, valuesIterator.next());
assertEquals(2, valuesIterator.next());
assertFalse(valuesIterator.hasNext());
}
use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldReturnIndexHitsInIndexOrderWhenNoSortIsGiven.
@Test
public void shouldReturnIndexHitsInIndexOrderWhenNoSortIsGiven() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector();
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.collect(1);
collector.collect(2);
// then
IndexHits<Document> indexHits = collector.getIndexHits(null);
assertEquals(2, indexHits.size());
assertEquals("1", indexHits.next().get("id"));
assertEquals("2", indexHits.next().get("id"));
assertFalse(indexHits.hasNext());
}
use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldSilentlyMergeAllSegments.
@Test
public void shouldSilentlyMergeAllSegments() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(false);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.collect(1);
collector.doSetNextReader(readerStub.getContext());
collector.collect(2);
// then
IndexHits<Document> indexHits = collector.getIndexHits(null);
assertEquals(2, indexHits.size());
assertEquals("1", indexHits.next().get("id"));
assertEquals("2", indexHits.next().get("id"));
assertFalse(indexHits.hasNext());
}
use of org.neo4j.kernel.api.impl.index.IndexReaderStub in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldReturnDocValuesInGivenOrder.
@Test
public void shouldReturnDocValuesInGivenOrder() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(false);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.collect(1);
collector.collect(2);
// then
Sort byIdDescending = new Sort(new SortField("id", SortField.Type.LONG, true));
PrimitiveLongIterator valuesIterator = collector.getSortedValuesIterator("id", byIdDescending);
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 shouldDynamicallyResizeScoresArray.
@Test
void shouldDynamicallyResizeScoresArray() throws Exception {
// given
DocValuesCollector collector = new DocValuesCollector(true);
IndexReaderStub readerStub = indexReaderWithMaxDocs(42);
// when
collector.doSetNextReader(readerStub.getContext());
collector.setScorer(constantScorer(1.0f));
// scores starts with array size of 32, adding 42 docs forces resize
for (int i = 0; i < 42; i++) {
collector.collect(i);
}
// then
DocValuesCollector.MatchingDocs matchingDocs = collector.getMatchingDocs().get(0);
float[] scores = new float[42];
Arrays.fill(scores, 1.0f);
assertArrayEquals(scores, matchingDocs.scores, 0.001f);
}
Aggregations