use of org.neo4j.common.EntityType.RELATIONSHIP 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());
}
Aggregations