Search in sources :

Example 6 with ValuesIterator

use of org.neo4j.kernel.api.impl.index.collector.ValuesIterator in project neo4j by neo4j.

the class ScoreEntityIteratorTest method mergeShouldReturnOrderedResults.

@Test
void mergeShouldReturnOrderedResults() {
    StubValuesIterator one = new StubValuesIterator().add(3, 10).add(10, 3).add(12, 1);
    StubValuesIterator two = new StubValuesIterator().add(1, 12).add(5, 8).add(7, 6).add(8, 5).add(11, 2);
    StubValuesIterator three = new StubValuesIterator().add(2, 11).add(4, 9).add(6, 7).add(9, 4);
    ValuesIterator concat = ScoreEntityIterator.mergeIterators(Arrays.asList(one, two, three));
    for (int i = 1; i <= 12; i++) {
        assertTrue(concat.hasNext());
        assertEquals(i, concat.next());
        assertEquals(i, concat.current());
        assertEquals(13 - i, concat.currentScore(), 0.001);
    }
    assertFalse(concat.hasNext());
}
Also used : ValuesIterator(org.neo4j.kernel.api.impl.index.collector.ValuesIterator) Test(org.junit.jupiter.api.Test)

Example 7 with ValuesIterator

use of org.neo4j.kernel.api.impl.index.collector.ValuesIterator in project neo4j by neo4j.

the class ScoreEntityIteratorTest method mergeShouldCorrectlyOrderSpecialValues.

@Test
void mergeShouldCorrectlyOrderSpecialValues() {
    // According to CIP2016-06-14, NaN comes between positive infinity and the largest float/double value.
    StubValuesIterator one = new StubValuesIterator().add(2, Float.POSITIVE_INFINITY).add(4, 1.0f).add(6, Float.MIN_VALUE).add(8, -1.0f);
    StubValuesIterator two = new StubValuesIterator().add(1, Float.NaN).add(3, Float.MAX_VALUE).add(5, Float.MIN_NORMAL).add(7, 0.0f).add(9, Float.NEGATIVE_INFINITY);
    ValuesIterator concat = ScoreEntityIterator.mergeIterators(Arrays.asList(one, two));
    assertTrue(concat.hasNext());
    assertEquals(1, concat.next());
    assertTrue(isNaN(concat.currentScore()));
    assertEquals(2, concat.next());
    assertTrue(isInfinite(concat.currentScore()));
    assertTrue(concat.currentScore() > 0.0f);
    assertEquals(3, concat.next());
    assertEquals(4, concat.next());
    assertEquals(5, concat.next());
    assertEquals(6, concat.next());
    assertEquals(7, concat.next());
    assertEquals(8, concat.next());
    assertEquals(9, concat.next());
    assertFalse(concat.hasNext());
}
Also used : ValuesIterator(org.neo4j.kernel.api.impl.index.collector.ValuesIterator) Test(org.junit.jupiter.api.Test)

Aggregations

ValuesIterator (org.neo4j.kernel.api.impl.index.collector.ValuesIterator)7 Test (org.junit.jupiter.api.Test)4 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LongPredicate (java.util.function.LongPredicate)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 Weight (org.apache.lucene.search.Weight)1 WildcardQuery (org.apache.lucene.search.WildcardQuery)1 PropertyIndexQuery (org.neo4j.internal.kernel.api.PropertyIndexQuery)1 IndexNotApplicableKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException)1 SearcherReference (org.neo4j.kernel.api.impl.index.SearcherReference)1 Neo4jIndexSearcher (org.neo4j.kernel.api.impl.index.partition.Neo4jIndexSearcher)1 BitmapExtractor (org.neo4j.kernel.api.impl.labelscan.bitmaps.BitmapExtractor)1 LongPageIterator (org.neo4j.kernel.api.impl.labelscan.bitmaps.LongPageIterator)1