use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class RelationshipChangesForNodeTest method shouldGetRelationshipsByTypeAndDirection.
@Test
void shouldGetRelationshipsByTypeAndDirection() {
RelationshipChangesForNode changes = createRelationshipChangesForNode(ADD, INSTANCE);
final int TYPE = 2;
final int DECOY_TYPE = 666;
changes.addRelationship(1, TYPE, INCOMING);
changes.addRelationship(2, TYPE, OUTGOING);
changes.addRelationship(3, TYPE, OUTGOING);
changes.addRelationship(4, TYPE, LOOP);
changes.addRelationship(5, TYPE, LOOP);
changes.addRelationship(6, TYPE, LOOP);
changes.addRelationship(10, DECOY_TYPE, INCOMING);
changes.addRelationship(11, DECOY_TYPE, OUTGOING);
changes.addRelationship(12, DECOY_TYPE, LOOP);
LongIterator rawIncoming = changes.getRelationships(Direction.INCOMING, TYPE);
assertThat(asArray(rawIncoming)).containsExactly(1, 4, 5, 6);
LongIterator rawOutgoing = changes.getRelationships(Direction.OUTGOING, TYPE);
assertThat(asArray(rawOutgoing)).containsExactly(2, 3, 4, 5, 6);
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class RelationshipChangesForNodeTest method shouldGetRelationships.
@Test
void shouldGetRelationships() {
RelationshipChangesForNode changes = createRelationshipChangesForNode(ADD, INSTANCE);
final int TYPE = 2;
changes.addRelationship(1, TYPE, INCOMING);
changes.addRelationship(2, TYPE, OUTGOING);
changes.addRelationship(3, TYPE, OUTGOING);
changes.addRelationship(4, TYPE, LOOP);
changes.addRelationship(5, TYPE, LOOP);
changes.addRelationship(6, TYPE, LOOP);
LongIterator rawRelationships = changes.getRelationships();
assertThat(asArray(rawRelationships)).containsExactly(1, 2, 3, 4, 5, 6);
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class IndexSamplingController method recoverIndexSamples.
public void recoverIndexSamples() {
samplingLock.lock();
try {
IndexMap indexMap = indexMapSnapshotProvider.indexMapSnapshot();
final LongIterator indexIds = indexMap.indexIds();
List<IndexSamplingJobHandle> asyncSamplingJobs = Lists.mutable.of();
while (indexIds.hasNext()) {
long indexId = indexIds.next();
IndexDescriptor descriptor = indexMap.getIndexProxy(indexId).getDescriptor();
if (indexRecoveryCondition.test(descriptor) && descriptor.getIndexType() != IndexType.LOOKUP) {
if (logRecoverIndexSamples) {
log.info("Index requires sampling, id=%d, name=%s.", indexId, descriptor.getName());
}
if (asyncRecoverIndexSamples) {
asyncSamplingJobs.add(sampleIndexOnTracker(indexMap, indexId));
} else {
sampleIndexOnCurrentThread(indexMap, indexId);
}
} else {
if (logRecoverIndexSamples) {
log.info("Index does not require sampling, id=%d, name=%s.", indexId, descriptor.getName());
}
}
}
if (asyncRecoverIndexSamplesWait) {
waitForAsyncIndexSamples(asyncSamplingJobs);
}
} finally {
samplingLock.unlock();
}
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class PrimitiveLongCollectionsTest method shouldNotContinueToCallNextOnHasNextFalse.
@Test
void shouldNotContinueToCallNextOnHasNextFalse() {
// GIVEN
AtomicLong count = new AtomicLong(2);
LongIterator iterator = new AbstractPrimitiveLongBaseIterator() {
@Override
protected boolean fetchNext() {
return count.decrementAndGet() >= 0 && next(count.get());
}
};
// WHEN/THEN
assertTrue(iterator.hasNext());
assertTrue(iterator.hasNext());
assertEquals(1L, iterator.next());
assertTrue(iterator.hasNext());
assertTrue(iterator.hasNext());
assertEquals(0L, iterator.next());
assertFalse(iterator.hasNext());
assertFalse(iterator.hasNext());
assertEquals(-1L, count.get());
}
use of org.eclipse.collections.api.iterator.LongIterator in project neo4j by neo4j.
the class PrimitiveLongCollectionsTest method reverseArrayOfItemsAsIterator.
@Test
void reverseArrayOfItemsAsIterator() {
// GIVEN
long[] items = new long[] { 2, 5, 234 };
// WHEN
LongIterator iterator = PrimitiveLongCollections.reverseIterator(items);
// THEN
assertItems(iterator, 234, 5, 2);
}
Aggregations