use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class DynamicIndexStoreViewTest method shouldVisitAllRelationshipsWithoutTokenIndexes.
@Test
void shouldVisitAllRelationshipsWithoutTokenIndexes() {
StubStorageCursors cursors = new StubStorageCursors().withoutTokenIndexes();
IndexProxyProvider indexProxies = mock(IndexProxyProvider.class);
int targetType = 1;
int notTargetType = 2;
int[] targetTypeArray = { targetType };
String targetPropertyKey = "key";
Value propertyValue = Values.stringValue("value");
MutableLongList relationshipsWithTargetType = LongLists.mutable.empty();
long id = 0;
int wantedPropertyUpdates = 5;
for (int i = 0; i < wantedPropertyUpdates; i++) {
// Relationship fitting our target
cursors.withRelationship(id, 1, targetType, 3).properties(targetPropertyKey, propertyValue);
relationshipsWithTargetType.add(id++);
// Relationship with different type
cursors.withRelationship(id, 1, notTargetType, 3).properties(targetPropertyKey, propertyValue);
relationshipsWithTargetType.add(id++);
}
int targetPropertyKeyId = cursors.propertyKeyTokenHolder().getIdByName(targetPropertyKey);
IntPredicate propertyKeyIdFilter = value -> value == targetPropertyKeyId;
DynamicIndexStoreView storeView = dynamicIndexStoreView(cursors, indexProxies);
TestTokenScanConsumer tokenConsumer = new TestTokenScanConsumer();
TestPropertyScanConsumer propertyScanConsumer = new TestPropertyScanConsumer();
StoreScan storeScan = storeView.visitRelationships(targetTypeArray, propertyKeyIdFilter, propertyScanConsumer, tokenConsumer, false, true, NULL, INSTANCE);
storeScan.run(StoreScan.NO_EXTERNAL_UPDATES);
assertThat(tokenConsumer.batches.size()).isEqualTo(1);
assertThat(tokenConsumer.batches.get(0).size()).isEqualTo(relationshipsWithTargetType.size());
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class GenerateIndexUpdatesStepTest method allNodeIds.
private static long[] allNodeIds(StubStorageCursors data) {
try (StorageNodeCursor cursor = data.allocateNodeCursor(NULL)) {
cursor.scan();
MutableLongList ids = LongLists.mutable.empty();
while (cursor.next()) {
ids.add(cursor.entityReference());
}
return ids.toArray();
}
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class DetectRandomSabotageIT method createNodes.
private MutableLongList createNodes(GraphDatabaseAPI db) {
MutableLongList nodeIds = LongLists.mutable.empty();
try (Transaction tx = db.beginTx()) {
for (int i = 0; i < NUMBER_OF_NODES; i++) {
Node node = tx.createNode(labels(random.selection(TOKEN_NAMES, 0, TOKEN_NAMES.length, false)));
setRandomProperties(node);
nodeIds.add(node.getId());
}
tx.commit();
}
return nodeIds;
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class DetectRandomSabotageIT method setUp.
@BeforeEach
protected void setUp() {
dbms = getDbms(directory.homePath());
db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
// Create some nodes
MutableLongList nodeIds = createNodes(db);
// Force some nodes to be dense nodes and some to have only a single relationship
MutableLongSet singleRelationshipNodes = LongSets.mutable.empty();
MutableLongSet denseNodes = LongSets.mutable.empty();
while (singleRelationshipNodes.size() < 5) {
singleRelationshipNodes.add(nodeIds.get(random.nextInt(nodeIds.size())));
}
while (denseNodes.size() < 5) {
long nodeId = nodeIds.get(random.nextInt(nodeIds.size()));
if (!singleRelationshipNodes.contains(nodeId)) {
denseNodes.add(nodeId);
}
}
// Connect them with some relationships
createRelationships(db, nodeIds, singleRelationshipNodes);
// Make the dense nodes dense by creating many relationships to or from them
createAdditionalRelationshipsForDenseNodes(db, nodeIds, denseNodes);
// Delete some entities
deleteSomeEntities(db, nodeIds, singleRelationshipNodes, denseNodes);
// Create some indexes and constraints
createSchema(db);
neoStores = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
resolver = db.getDependencyResolver();
}
use of org.eclipse.collections.api.list.primitive.MutableLongList in project neo4j by neo4j.
the class TxStateIndexChanges method indexUpdatesForScanAndFilter.
// HELPERS
private static AddedAndRemoved indexUpdatesForScanAndFilter(ReadableTransactionState txState, IndexDescriptor descriptor, PropertyIndexQuery filter, IndexOrder indexOrder) {
Map<ValueTuple, ? extends LongDiffSets> updates = getUpdates(txState, descriptor, indexOrder);
if (updates == null) {
return EMPTY_ADDED_AND_REMOVED;
}
MutableLongList added = LongLists.mutable.empty();
MutableLongSet removed = LongSets.mutable.empty();
for (Map.Entry<ValueTuple, ? extends LongDiffSets> entry : updates.entrySet()) {
ValueTuple key = entry.getKey();
if (filter == null || filter.acceptsValue(key.valueAt(0))) {
LongDiffSets diffSet = entry.getValue();
added.addAll(diffSet.getAdded());
removed.addAll(diffSet.getRemoved());
}
}
return new AddedAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed);
}
Aggregations