use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class DocValuesCollectorTest method shouldSilentlyMergeSegmentsWhenReturnDocValuesInOrder.
@Test
public void shouldSilentlyMergeSegmentsWhenReturnDocValuesInOrder() 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.doSetNextReader(readerStub.getContext());
collector.setScorer(constantScorer(2.0f));
collector.collect(2);
// then
PrimitiveLongIterator valuesIterator = collector.getSortedValuesIterator("id", Sort.RELEVANCE);
assertEquals(2, valuesIterator.next());
assertEquals(1, valuesIterator.next());
assertFalse(valuesIterator.hasNext());
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator 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.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method indexReaderShouldSupportScan.
@Test
public void indexReaderShouldSupportScan() throws Exception {
// GIVEN
updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2)));
IndexReader reader = accessor.newReader();
// WHEN
PrimitiveLongIterator results = reader.query(IndexQuery.exists(PROP_ID));
// THEN
assertEquals(asSet(nodeId, nodeId2), PrimitiveLongCollections.toSet(results));
assertEquals(asSet(nodeId), PrimitiveLongCollections.toSet(reader.query(IndexQuery.exact(PROP_ID, value))));
reader.close();
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method indexStringRangeQuery.
@Test
public void indexStringRangeQuery() throws Exception {
updateAndCommit(asList(add(PROP_ID, "A"), add(2, "B"), add(3, "C"), add(4, "")));
IndexReader reader = accessor.newReader();
PrimitiveLongIterator rangeFromBInclusive = reader.query(range(PROP_ID, "B", true, null, false));
assertThat(PrimitiveLongCollections.asArray(rangeFromBInclusive), LongArrayMatcher.of(2, 3));
PrimitiveLongIterator rangeFromANonInclusive = reader.query(range(PROP_ID, "A", false, null, false));
assertThat(PrimitiveLongCollections.asArray(rangeFromANonInclusive), LongArrayMatcher.of(2, 3));
PrimitiveLongIterator emptyLowInclusive = reader.query(range(PROP_ID, "", true, null, false));
assertThat(PrimitiveLongCollections.asArray(emptyLowInclusive), LongArrayMatcher.of(PROP_ID, 2, 3, 4));
PrimitiveLongIterator emptyUpperNonInclusive = reader.query(range(PROP_ID, "B", true, "", false));
assertThat(PrimitiveLongCollections.asArray(emptyUpperNonInclusive), LongArrayMatcher.emptyArrayMatcher());
PrimitiveLongIterator emptyInterval = reader.query(range(PROP_ID, "", true, "", true));
assertThat(PrimitiveLongCollections.asArray(emptyInterval), LongArrayMatcher.of(4));
PrimitiveLongIterator emptyAllNonInclusive = reader.query(range(PROP_ID, "", false, null, false));
assertThat(PrimitiveLongCollections.asArray(emptyAllNonInclusive), LongArrayMatcher.of(PROP_ID, 2, 3));
PrimitiveLongIterator nullNonInclusive = reader.query(range(PROP_ID, (String) null, false, null, false));
assertThat(PrimitiveLongCollections.asArray(nullNonInclusive), LongArrayMatcher.of(PROP_ID, 2, 3, 4));
PrimitiveLongIterator nullInclusive = reader.query(range(PROP_ID, (String) null, false, null, false));
assertThat(PrimitiveLongCollections.asArray(nullInclusive), LongArrayMatcher.of(PROP_ID, 2, 3, 4));
}
use of org.neo4j.collection.primitive.PrimitiveLongIterator in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatorTest method addUpdates.
@Test
public void addUpdates() throws Exception {
populator = newPopulator();
List<IndexEntryUpdate> updates = Arrays.asList(IndexEntryUpdate.add(1, labelSchemaDescriptor, "foo"), IndexEntryUpdate.add(2, labelSchemaDescriptor, "bar"), IndexEntryUpdate.add(42, labelSchemaDescriptor, "bar"));
populator.add(updates);
index.maybeRefreshBlocking();
try (IndexReader reader = index.getIndexReader()) {
int propertyKeyId = labelSchemaDescriptor.getPropertyId();
PrimitiveLongIterator allEntities = reader.query(IndexQuery.exists(propertyKeyId));
assertArrayEquals(new long[] { 1, 2, 42 }, PrimitiveLongCollections.asArray(allEntities));
}
}
Aggregations