Skip to content

Commit e9dc7c7

Browse files
FlorentinDs1ck
authored andcommitted
Replace DataClass in PropertyMappings
This removes the last usage of the DataClass
1 parent 0753a40 commit e9dc7c7

File tree

15 files changed

+37
-87
lines changed

15 files changed

+37
-87
lines changed

algo-common/src/main/java/org/neo4j/gds/scaling/ScalePropertiesBaseConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.List;
2828
import java.util.stream.Collectors;
2929

30-
import static org.neo4j.gds.AbstractPropertyMappings.fromObject;
30+
import static org.neo4j.gds.PropertyMappings.fromObject;
3131

3232
@ValueClass
3333
@SuppressWarnings("immutables:subtype")

annotations/src/main/java/org/neo4j/gds/annotation/DataClass.java

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
org.neo4j.gds.annotation.DataClass
21
org.neo4j.gds.annotation.ValueClass

core/src/main/java/org/neo4j/gds/config/GraphProjectFromStoreConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ public interface GraphProjectFromStoreConfig extends GraphProjectConfig {
6363

6464
@Value.Default
6565
@Value.Parameter(false)
66-
@Configuration.ConvertWith(method = "org.neo4j.gds.AbstractPropertyMappings#fromObject")
67-
@Configuration.ToMapValue("org.neo4j.gds.AbstractPropertyMappings#toObject")
66+
@Configuration.ConvertWith(method = "org.neo4j.gds.PropertyMappings#fromObject")
67+
@Configuration.ToMapValue("org.neo4j.gds.PropertyMappings#toObject")
6868
default PropertyMappings nodeProperties() {
6969
return PropertyMappings.of();
7070
}
7171

7272
@Value.Default
7373
@Value.Parameter(false)
74-
@Configuration.ConvertWith(method = "org.neo4j.gds.AbstractPropertyMappings#fromObject")
75-
@Configuration.ToMapValue("org.neo4j.gds.AbstractPropertyMappings#toObject")
74+
@Configuration.ConvertWith(method = "org.neo4j.gds.PropertyMappings#fromObject")
75+
@Configuration.ToMapValue("org.neo4j.gds.PropertyMappings#toObject")
7676
default PropertyMappings relationshipProperties() {
7777
return PropertyMappings.of();
7878
}

core/src/main/java/org/neo4j/gds/core/loading/CypherRelationshipLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.eclipse.collections.impl.map.mutable.primitive.ObjectDoubleHashMap;
2424
import org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap;
2525
import org.immutables.value.Value;
26+
import org.neo4j.gds.ImmutablePropertyMappings;
2627
import org.neo4j.gds.Orientation;
2728
import org.neo4j.gds.PropertyMapping;
2829
import org.neo4j.gds.PropertyMappings;
@@ -123,7 +124,7 @@ BatchLoadResult loadSingleBatch(InternalTransaction tx, int bufferSize) {
123124
))
124125
.collect(Collectors.toList());
125126

126-
initFromPropertyMappings(PropertyMappings.of(propertyMappings));
127+
initFromPropertyMappings(ImmutablePropertyMappings.of(propertyMappings));
127128

128129
initializedFromResult = true;
129130
}

graph-projection-api/src/main/java/org/neo4j/gds/ElementProjection.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ default Self addProperty(
102102
) {
103103
inlineBuilder()
104104
.propertiesBuilder()
105-
.addMapping(propertyKey, neoPropertyKey, defaultValue, aggregation);
105+
.addMapping(PropertyMapping.of(propertyKey, neoPropertyKey, defaultValue, aggregation));
106106
return (Self) this;
107107
}
108108

@@ -126,7 +126,7 @@ default void buildProperties() {
126126
static final class InlinePropertiesBuilder {
127127
private final Supplier<PropertyMappings> getProperties;
128128
private final Consumer<PropertyMappings> setProperties;
129-
private AbstractPropertyMappings.Builder propertiesBuilder;
129+
private PropertyMappings.Builder propertiesBuilder;
130130

131131
InlinePropertiesBuilder(
132132
Supplier<PropertyMappings> getProperties,
@@ -151,9 +151,9 @@ private void build() {
151151
}
152152
}
153153

154-
private AbstractPropertyMappings.Builder propertiesBuilder() {
154+
private PropertyMappings.Builder propertiesBuilder() {
155155
if (propertiesBuilder == null) {
156-
propertiesBuilder = AbstractPropertyMappings.builder();
156+
propertiesBuilder = PropertyMappings.builder();
157157
PropertyMappings properties = getProperties.get();
158158
if (properties != null) {
159159
propertiesBuilder.from(properties);

graph-projection-api/src/main/java/org/neo4j/gds/AbstractPropertyMappings.java renamed to graph-projection-api/src/main/java/org/neo4j/gds/PropertyMappings.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
*/
2020
package org.neo4j.gds;
2121

22-
import org.eclipse.collections.api.tuple.primitive.IntObjectPair;
2322
import org.immutables.builder.Builder.AccessibleFields;
2423
import org.immutables.value.Value;
25-
import org.neo4j.gds.annotation.DataClass;
24+
import org.neo4j.gds.annotation.ValueClass;
2625
import org.neo4j.gds.core.Aggregation;
27-
import org.neo4j.gds.core.utils.CollectionUtil;
2826

2927
import java.util.Arrays;
3028
import java.util.Iterator;
@@ -40,27 +38,27 @@
4038
import static java.util.Collections.singletonMap;
4139
import static org.neo4j.gds.utils.StringFormatting.formatWithLocale;
4240

43-
@DataClass
41+
@ValueClass
4442
@Value.Immutable(singleton = true)
45-
public abstract class AbstractPropertyMappings implements Iterable<PropertyMapping> {
43+
public abstract class PropertyMappings implements Iterable<PropertyMapping> {
4644

4745
public abstract List<PropertyMapping> mappings();
4846

4947
public static PropertyMappings of(PropertyMapping... mappings) {
5048
if (mappings == null) {
51-
return PropertyMappings.of();
49+
return ImmutablePropertyMappings.of();
5250
}
53-
return PropertyMappings.of(Arrays.asList(mappings));
51+
return ImmutablePropertyMappings.of(Arrays.asList(mappings));
5452
}
5553

5654
public static PropertyMappings fromObject(Object relPropertyMapping) {
5755
return fromObject(relPropertyMapping, Aggregation.DEFAULT);
5856
}
5957

6058
public static PropertyMappings fromObject(Object relPropertyMapping, Aggregation defaultAggregation) {
61-
if (relPropertyMapping instanceof PropertyMappings) {
62-
PropertyMappings properties = (PropertyMappings) relPropertyMapping;
63-
return PropertyMappings.builder().from(properties).withDefaultAggregation(defaultAggregation).build();
59+
if (relPropertyMapping instanceof ImmutablePropertyMappings) {
60+
ImmutablePropertyMappings properties = (ImmutablePropertyMappings) relPropertyMapping;
61+
return ImmutablePropertyMappings.builder().from(properties).withDefaultAggregation(defaultAggregation).build();
6462
}
6563
if (relPropertyMapping instanceof String) {
6664
String propertyMapping = (String) relPropertyMapping;
@@ -95,7 +93,7 @@ public static PropertyMappings fromObject(Object relPropertyMapping, Aggregation
9593
}
9694
}
9795

98-
public static Map<String, Object> toObject(AbstractPropertyMappings propertyMappings) {
96+
public static Map<String, Object> toObject(PropertyMappings propertyMappings) {
9997
return propertyMappings.toObject(true);
10098
}
10199

@@ -112,10 +110,6 @@ public Iterator<PropertyMapping> iterator() {
112110
return mappings().iterator();
113111
}
114112

115-
public Stream<IntObjectPair<PropertyMapping>> enumerate() {
116-
return CollectionUtil.enumerate(mappings());
117-
}
118-
119113
public boolean hasMappings() {
120114
return !mappings().isEmpty();
121115
}
@@ -144,7 +138,7 @@ public PropertyMappings mergeWith(PropertyMappings other) {
144138
return other;
145139
}
146140
if (!other.hasMappings()) {
147-
return PropertyMappings.copyOf(this);
141+
return ImmutablePropertyMappings.copyOf(this);
148142
}
149143
Builder builder = PropertyMappings.builder();
150144
builder.addMappings(Stream.concat(stream(), other.stream()).distinct());
@@ -168,7 +162,7 @@ public static Builder builder() {
168162
}
169163

170164
@AccessibleFields
171-
public static final class Builder extends PropertyMappings.Builder {
165+
public static final class Builder extends ImmutablePropertyMappings.Builder {
172166

173167
private Aggregation aggregation;
174168

io/core/src/main/java/org/neo4j/gds/core/io/GraphStoreExporterBaseConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ default int batchSize() {
5151

5252
@Value.Default
5353
@Value.Parameter(false)
54-
@Configuration.ConvertWith(method = "org.neo4j.gds.AbstractPropertyMappings#fromObject")
55-
@Configuration.ToMapValue("org.neo4j.gds.AbstractPropertyMappings#toObject")
54+
@Configuration.ConvertWith(method = "org.neo4j.gds.PropertyMappings#fromObject")
55+
@Configuration.ToMapValue("org.neo4j.gds.PropertyMappings#toObject")
5656
default org.neo4j.gds.PropertyMappings additionalNodeProperties() {
5757
return org.neo4j.gds.PropertyMappings.of();
5858
}

proc/test/src/main/java/org/neo4j/gds/AlgoBaseProcTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ default void testRunOnEmptyGraph() {
323323
loadedGraphName,
324324
ImmutableNodeProjections.of(
325325
Map.of(
326-
NodeLabel.of("X"), ImmutableNodeProjection.of("X", PropertyMappings.of(propertyMappings))
326+
NodeLabel.of("X"), ImmutableNodeProjection.of("X", ImmutablePropertyMappings.of(propertyMappings))
327327
)
328328
),
329329
relationshipProjections()

proc/test/src/main/java/org/neo4j/gds/ConfigurableSeedConfigTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ default void testSeedPropertyValidation() {
8585
GraphProjectFromStoreConfig graphProjectConfig = ImmutableGraphProjectFromStoreConfig.of(
8686
"",
8787
graphName,
88-
NodeProjections.single(NodeLabel.of("A"), ImmutableNodeProjection.of("A", PropertyMappings.of(nodeProperties))),
88+
NodeProjections.single(
89+
NodeLabel.of("A"),
90+
ImmutableNodeProjection.of("A", ImmutablePropertyMappings.of(nodeProperties))
91+
),
8992
allRelationshipsProjection()
9093
);
9194

0 commit comments

Comments
 (0)