use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method shouldScanASubsetOfNodes.
@Test
void shouldScanASubsetOfNodes() {
try (NodeLabelIndexCursor nodes = cursors.allocateNodeLabelIndexCursor(NULL)) {
for (int label : ALL_LABELS) {
Scan<NodeLabelIndexCursor> scan = read.nodeLabelScan(label);
assertTrue(scan.reserveBatch(nodes, 11));
MutableLongList found = LongLists.mutable.empty();
while (nodes.next()) {
found.add(nodes.nodeReference());
}
assertThat(found.size()).isGreaterThan(0);
if (label == FOO_LABEL) {
assertTrue(FOO_NODES.containsAll(found));
assertTrue(found.noneSatisfy(f -> BAR_NODES.contains(f)));
} else if (label == BAR_LABEL) {
assertTrue(BAR_NODES.containsAll(found));
assertTrue(found.noneSatisfy(f -> FOO_NODES.contains(f)));
} else {
fail();
}
}
}
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method shouldHandleSizeHintOverflow.
@Test
void shouldHandleSizeHintOverflow() {
try (NodeLabelIndexCursor nodes = cursors.allocateNodeLabelIndexCursor(NULL)) {
// when
Scan<NodeLabelIndexCursor> scan = read.nodeLabelScan(FOO_LABEL);
assertTrue(scan.reserveBatch(nodes, NUMBER_OF_NODES * 2));
MutableLongList ids = LongLists.mutable.empty();
while (nodes.next()) {
ids.add(nodes.nodeReference());
}
assertEquals(FOO_NODES.size(), ids.size());
assertTrue(FOO_NODES.containsAll(ids));
assertTrue(ids.noneSatisfy(f -> BAR_NODES.contains(f)));
}
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class ParallelRelationshipCursorTestBase method createTestGraph.
@Override
public void createTestGraph(GraphDatabaseService graphDb) {
try (Transaction tx = graphDb.beginTx()) {
MutableLongList list = new LongArrayList(NUMBER_OF_RELATIONSHIPS);
for (int i = 0; i < NUMBER_OF_RELATIONSHIPS; i++) {
list.add(tx.createNode().createRelationshipTo(tx.createNode(), RelationshipType.withName("R")).getId());
}
RELATIONSHIPS = list;
tx.commit();
}
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class ParallelNodeCursorTestBase method createTestGraph.
@Override
public void createTestGraph(GraphDatabaseService graphDb) {
try (Transaction tx = graphDb.beginTx()) {
MutableLongList list = new LongArrayList(NUMBER_OF_NODES);
for (int i = 0; i < NUMBER_OF_NODES; i++) {
list.add(tx.createNode().getId());
}
NODE_IDS = list;
tx.commit();
}
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class RelationshipLockHelperTest method canIterateWhileAddingAndRemoving.
@Test
void canIterateWhileAddingAndRemoving() {
MutableLongList shuffle = LongLists.mutable.empty();
SortedLockList sortedListIterator = new SortedLockList(0);
int maxValue = 1000;
for (int i = 0; i < 1000; i++) {
int value = random.nextInt(maxValue);
sortedListIterator.add(value);
shuffle.add(value);
assertThat(sortedListIterator.underlyingList().toArray()).isSorted();
}
while (sortedListIterator.next()) {
long value = sortedListIterator.currentHighestLockedId();
long toAdd = random.nextInt(maxValue);
sortedListIterator.add(toAdd);
assertThat(value).isEqualTo(sortedListIterator.currentHighestLockedId());
if (shuffle.notEmpty()) {
long toRemove = shuffle.removeAtIndex(shuffle.size() - 1);
if (toRemove != value) {
sortedListIterator.remove(toRemove);
}
assertThat(value).isEqualTo(sortedListIterator.currentHighestLockedId());
}
if (random.nextInt(10) == 0) {
int backoff = random.nextInt(5);
while (sortedListIterator.prev() && backoff-- > 0) {
// do nothing
}
}
}
}
Aggregations