use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method shouldScanAllNodesInBatches.
@Test
void shouldScanAllNodesInBatches() {
// given
try (NodeLabelIndexCursor nodes = cursors.allocateNodeLabelIndexCursor(NULL)) {
// when
Scan<NodeLabelIndexCursor> scan = read.nodeLabelScan(FOO_LABEL);
MutableLongList ids = LongLists.mutable.empty();
while (scan.reserveBatch(nodes, 3)) {
while (nodes.next()) {
ids.add(nodes.nodeReference());
}
}
// then
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 ParallelNodeLabelScanTransactionStateTestBase method createNodesWithLabel.
private LongList createNodesWithLabel(Write write, int label, int size) throws KernelException {
MutableLongList ids = LongLists.mutable.empty();
for (int i = 0; i < size; i++) {
long node = write.nodeCreate();
write.nodeAddLabel(node, label);
ids.add(node);
}
return ids;
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class TestUtils method concat.
static LongList concat(List<LongList> lists) {
MutableLongList concat = LongLists.mutable.empty();
lists.forEach(concat::addAll);
return concat;
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class IndexedIdGeneratorTest method shouldConcurrentlyAllocateAllIdsAroundReservedIds.
@Test
void shouldConcurrentlyAllocateAllIdsAroundReservedIds() throws IOException {
// given
idGenerator.start(NO_FREE_IDS, NULL);
long startingId = IdValidator.INTEGER_MINUS_ONE - 100;
idGenerator.setHighId(startingId);
idGenerator.markHighestWrittenAtHighId();
// when
Race race = new Race();
int threads = 8;
int allocationsPerThread = 32;
LongList[] allocatedIds = new LongList[threads];
for (int i = 0; i < 8; i++) {
LongArrayList list = new LongArrayList(32);
allocatedIds[i] = list;
race.addContestant(() -> {
for (int j = 0; j < allocationsPerThread; j++) {
list.add(idGenerator.nextId(NULL));
}
}, 1);
}
race.goUnchecked();
// then
MutableLongList allIds = new LongArrayList(allocationsPerThread * threads);
Stream.of(allocatedIds).forEach(allIds::addAll);
allIds = allIds.sortThis();
assertEquals(allocationsPerThread * threads, allIds.size());
MutableLongIterator allIdsIterator = allIds.longIterator();
long nextExpected = startingId;
while (allIdsIterator.hasNext()) {
assertEquals(nextExpected, allIdsIterator.next());
do {
nextExpected++;
} while (IdValidator.isReservedId(nextExpected));
}
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class DynamicIndexStoreViewTest method shouldVisitRelationshipsUsingTokenIndex.
@Test
void shouldVisitRelationshipsUsingTokenIndex() throws Throwable {
// Given
StubTokenIndexReader tokenReader = new StubTokenIndexReader();
StubStorageCursors cursors = new StubStorageCursors().withTokenIndexes();
IndexProxy indexProxy = mock(IndexProxy.class);
IndexProxyProvider indexProxies = mock(IndexProxyProvider.class);
IndexDescriptor descriptor = forSchema(forAnyEntityTokens(RELATIONSHIP), DESCRIPTOR).withName("index").materialise(0);
when(indexProxy.getState()).thenReturn(InternalIndexState.ONLINE);
when(indexProxy.getDescriptor()).thenReturn(descriptor);
when(indexProxy.newTokenReader()).thenReturn(tokenReader);
when(indexProxies.getIndexProxy(any())).thenReturn(indexProxy);
int targetType = 1;
int notTargetType = 2;
int[] indexedTypes = { targetType };
String targetPropertyKey = "key";
String notTargetPropertyKey = "not-key";
Value propertyValue = Values.stringValue("value");
MutableLongList relationshipsWithTargetType = LongLists.mutable.empty();
long id = 0;
int wantedPropertyUpdates = 5;
for (int i = 0; i < wantedPropertyUpdates; i++) {
// Relationships that are indexed
cursors.withRelationship(id, 1, targetType, 3).properties(targetPropertyKey, propertyValue);
tokenReader.index(indexedTypes, id);
relationshipsWithTargetType.add(id++);
// Relationship with wrong property
cursors.withRelationship(id++, 1, targetType, 3).properties(notTargetPropertyKey, propertyValue);
// Relationship with wrong type
cursors.withRelationship(id++, 1, notTargetType, 3).properties(targetPropertyKey, propertyValue);
}
// When
DynamicIndexStoreView storeView = dynamicIndexStoreView(cursors, indexProxies);
TestTokenScanConsumer tokenConsumer = new TestTokenScanConsumer();
TestPropertyScanConsumer propertyScanConsumer = new TestPropertyScanConsumer();
StoreScan storeScan = storeView.visitRelationships(indexedTypes, relationType -> true, propertyScanConsumer, tokenConsumer, false, true, NULL, INSTANCE);
storeScan.run(StoreScan.NO_EXTERNAL_UPDATES);
// Then make sure all the fitting relationships where included
assertThat(propertyScanConsumer.batches.size()).isEqualTo(1);
assertThat(propertyScanConsumer.batches.get(0).size()).isEqualTo(wantedPropertyUpdates);
// and that we didn't visit any more relationships than what we would get from scan store
assertThat(tokenConsumer.batches.size()).isEqualTo(1);
assertThat(tokenConsumer.batches.get(0).size()).isEqualTo(relationshipsWithTargetType.size());
}
Aggregations