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());
}
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());
}
Aggregations