Skip to content

Commit 15ab95e

Browse files
authored
Merge pull request #6900 from s1ck/remove-dataclass-annotation-2.3
remove dataclass annotation 2.3
2 parents 405d9db + 86b16c1 commit 15ab95e

File tree

35 files changed

+246
-337
lines changed

35 files changed

+246
-337
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public interface GraphProjectFromStoreConfig extends GraphProjectConfig {
5252
String RELATIONSHIP_PROPERTIES_KEY = "relationshipProperties";
5353

5454
@Key(NODE_PROJECTION_KEY)
55-
@ConvertWith(method = "org.neo4j.gds.AbstractNodeProjections#fromObject")
56-
@Configuration.ToMapValue("org.neo4j.gds.AbstractNodeProjections#toObject")
55+
@ConvertWith(method = "org.neo4j.gds.NodeProjections#fromObject")
56+
@Configuration.ToMapValue("org.neo4j.gds.NodeProjections#toObject")
5757
NodeProjections nodeProjections();
5858

5959
@Key(RELATIONSHIP_PROJECTION_KEY)
@@ -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/config/RandomGraphGeneratorConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.immutables.value.Value;
2323
import org.jetbrains.annotations.Nullable;
24+
import org.neo4j.gds.ImmutableNodeProjections;
2425
import org.neo4j.gds.ImmutableRelationshipProjections;
2526
import org.neo4j.gds.NodeLabel;
2627
import org.neo4j.gds.NodeProjection;
@@ -97,9 +98,9 @@ default Map<String, Object> relationshipProperty() {
9798
}
9899

99100
@Value.Default
100-
@Configuration.ToMapValue("org.neo4j.gds.AbstractNodeProjections#toObject")
101+
@Configuration.ToMapValue("org.neo4j.gds.NodeProjections#toObject")
101102
default NodeProjections nodeProjections() {
102-
return NodeProjections.builder()
103+
return ImmutableNodeProjections.builder()
103104
.putProjection(
104105
NodeLabel.of(nodeCount() + "_Nodes"),
105106
NodeProjection.of(nodeCount() + "_Nodes"))

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
}

core/src/test/java/org/neo4j/gds/api/schema/GraphSchemaIntegrationTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.neo4j.gds.NodeLabel;
2828
import org.neo4j.gds.NodeProjection;
2929
import org.neo4j.gds.PropertyMapping;
30-
import org.neo4j.gds.PropertyMappings;
3130
import org.neo4j.gds.RelationshipProjection;
3231
import org.neo4j.gds.RelationshipType;
3332
import org.neo4j.gds.StoreLoaderBuilder;
@@ -37,7 +36,6 @@
3736
import org.neo4j.gds.api.nodeproperties.ValueType;
3837
import org.neo4j.gds.core.Aggregation;
3938

40-
import java.util.List;
4139
import java.util.stream.Stream;
4240

4341
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -62,10 +60,10 @@ void computesCorrectNodeSchema(PropertySchema expectedSchema, PropertyMapping pr
6260
Graph graph = new StoreLoaderBuilder()
6361
.databaseService(db)
6462
.addNodeProjection(
65-
NodeProjection.of(
66-
"Node",
67-
PropertyMappings.of(List.of(propertyMapping))
68-
)
63+
NodeProjection.builder()
64+
.label("Node")
65+
.addProperty(propertyMapping)
66+
.build()
6967
)
7068
.build()
7169
.graph();
@@ -81,7 +79,7 @@ void computesCorrectRelationshipSchema(RelationshipPropertySchema expectedSchema
8179
.addRelationshipProjection(
8280
RelationshipProjection.builder()
8381
.type("REL")
84-
.properties(PropertyMappings.of(List.of(propertyMapping)))
82+
.addProperties(propertyMapping)
8583
.build()
8684
)
8785
.build()

core/src/test/java/org/neo4j/gds/config/GraphProjectFromCypherConfigTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.junit.jupiter.params.provider.Arguments;
2525
import org.junit.jupiter.params.provider.MethodSource;
2626
import org.neo4j.gds.AbstractProjections;
27+
import org.neo4j.gds.ImmutableNodeProjections;
2728
import org.neo4j.gds.ImmutableRelationshipProjections;
28-
import org.neo4j.gds.NodeProjections;
2929
import org.neo4j.gds.core.CypherMapWrapper;
3030

3131
import java.util.Map;
@@ -71,9 +71,9 @@ void omitCypherParametersFromToMap() {
7171

7272
static Stream<Arguments> invalidKeys() {
7373
return Stream.of(
74-
Arguments.of(GraphProjectFromStoreConfig.NODE_PROJECTION_KEY, NodeProjections.of()),
74+
Arguments.of(GraphProjectFromStoreConfig.NODE_PROJECTION_KEY, ImmutableNodeProjections.of()),
7575
Arguments.of(GraphProjectFromStoreConfig.RELATIONSHIP_PROJECTION_KEY, ImmutableRelationshipProjections.of()),
76-
Arguments.of(GraphProjectFromStoreConfig.NODE_PROPERTIES_KEY, NodeProjections.of())
76+
Arguments.of(GraphProjectFromStoreConfig.NODE_PROPERTIES_KEY, ImmutableNodeProjections.of())
7777
);
7878
}
7979

core/src/test/java/org/neo4j/gds/config/GraphProjectFromStoreConfigTest.java

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
import org.neo4j.gds.NodeProjection;
2626
import org.neo4j.gds.NodeProjections;
2727
import org.neo4j.gds.Orientation;
28+
import org.neo4j.gds.PropertyMapping;
2829
import org.neo4j.gds.PropertyMappings;
2930
import org.neo4j.gds.RelationshipProjection;
3031
import org.neo4j.gds.RelationshipProjections;
3132
import org.neo4j.gds.RelationshipType;
3233
import org.neo4j.gds.api.DefaultValue;
3334
import org.neo4j.gds.core.Aggregation;
3435

35-
import java.util.Collections;
3636
import java.util.Set;
3737

3838
import static org.hamcrest.MatcherAssert.assertThat;
@@ -46,14 +46,18 @@ class GraphProjectFromStoreConfigTest {
4646

4747
@Test
4848
void testThrowOnOverlappingNodeProperties() {
49-
PropertyMappings propertyMappings = PropertyMappings.builder()
50-
.addMapping("duplicate", "foo", DefaultValue.of(0.0), Aggregation.NONE)
51-
.build();
52-
53-
NodeProjections nodeProjections = NodeProjections.create(Collections.singletonMap(
54-
NodeLabel.of("A"), NodeProjection.of("A", propertyMappings)
49+
PropertyMappings propertyMappings = PropertyMappings.of(PropertyMapping.of(
50+
"duplicate",
51+
"foo",
52+
DefaultValue.of(0.0),
53+
Aggregation.NONE
5554
));
5655

56+
var nodeProjections = NodeProjections.single(
57+
NodeLabel.of("A"),
58+
NodeProjection.builder().label("A").properties(propertyMappings).build()
59+
);
60+
5761
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () ->
5862
ImmutableGraphProjectFromStoreConfig.builder()
5963
.graphName("graph")
@@ -68,9 +72,12 @@ void testThrowOnOverlappingNodeProperties() {
6872

6973
@Test
7074
void testThrowOnOverlappingRelProperties() {
71-
PropertyMappings propertyMappings = PropertyMappings.builder()
72-
.addMapping("duplicate", "foo", DefaultValue.of(0.0), Aggregation.NONE)
73-
.build();
75+
var propertyMappings = PropertyMappings.of(PropertyMapping.of(
76+
"duplicate",
77+
"foo",
78+
DefaultValue.of(0.0),
79+
Aggregation.NONE
80+
));
7481

7582
RelationshipProjections relProjections = ImmutableRelationshipProjections.single(
7683
RelationshipType.of("A"),
@@ -95,18 +102,26 @@ void testThrowOnOverlappingRelProperties() {
95102

96103
@Test
97104
void testMergingOfNodePropertiesAndProjections() {
98-
PropertyMappings propertyMappings1 = PropertyMappings.builder()
99-
.addMapping("foo", "foo", DefaultValue.of(0.0), Aggregation.NONE)
100-
.build();
101-
102-
PropertyMappings propertyMappings2 = PropertyMappings.builder()
103-
.addMapping("bar", "foo", DefaultValue.of(0.0), Aggregation.NONE)
104-
.build();
105+
var propertyMappings1 = PropertyMappings.of(PropertyMapping.of(
106+
"foo",
107+
"foo",
108+
DefaultValue.of(0.0),
109+
Aggregation.NONE
110+
)
111+
);
105112

106-
NodeProjections nodeProjections = NodeProjections.create(Collections.singletonMap(
107-
NodeLabel.of("A"), NodeProjection.of("A", propertyMappings2)
113+
var propertyMappings2 = PropertyMappings.of(PropertyMapping.of(
114+
"bar",
115+
"foo",
116+
DefaultValue.of(0.0),
117+
Aggregation.NONE
108118
));
109119

120+
var nodeProjections = NodeProjections.single(
121+
NodeLabel.of("A"),
122+
NodeProjection.builder().label("A").properties(propertyMappings2).build()
123+
);
124+
110125
GraphProjectFromStoreConfig graphProjectConfig = ImmutableGraphProjectFromStoreConfig.builder()
111126
.graphName("graph")
112127
.relationshipProjections(RelationshipProjections.ALL)
@@ -122,13 +137,14 @@ void testMergingOfNodePropertiesAndProjections() {
122137

123138
@Test
124139
void testMergingOfRelationshipPropertiesAndProjections() {
125-
PropertyMappings propertyMappings1 = PropertyMappings.builder()
126-
.addMapping("foo", "foo", DefaultValue.of(0.0), Aggregation.NONE)
127-
.build();
140+
var propertyMappings1 = PropertyMappings.of(PropertyMapping.of("foo", "foo", DefaultValue.of(0.0), Aggregation.NONE));
128141

129-
PropertyMappings propertyMappings2 = PropertyMappings.builder()
130-
.addMapping("bar", "foo", DefaultValue.of(0.0), Aggregation.NONE)
131-
.build();
142+
var propertyMappings2 = PropertyMappings.of(PropertyMapping.of(
143+
"bar",
144+
"foo",
145+
DefaultValue.of(0.0),
146+
Aggregation.NONE
147+
));
132148

133149
RelationshipProjections relProjections = ImmutableRelationshipProjections.single(
134150
RelationshipType.of("A"),

core/src/test/java/org/neo4j/gds/core/GraphLoaderMultipleRelTypesAndPropertiesTest.java

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.neo4j.gds.NodeLabel;
3030
import org.neo4j.gds.NodeProjection;
3131
import org.neo4j.gds.PropertyMapping;
32-
import org.neo4j.gds.PropertyMappings;
3332
import org.neo4j.gds.RelationshipProjection;
3433
import org.neo4j.gds.RelationshipType;
3534
import org.neo4j.gds.StoreLoaderBuilder;
@@ -89,25 +88,14 @@ void setup() {
8988
@Test
9089
void nodeProjectionsWithExclusiveProperties() {
9190
GraphStore graphStore = new StoreLoaderBuilder()
92-
.putNodeProjectionsWithIdentifier(
93-
"N1",
94-
NodeProjection.of(
95-
"Node1",
96-
PropertyMappings.builder().addMapping(PropertyMapping.of("prop1", 0.0D)).build()
97-
)
98-
).putNodeProjectionsWithIdentifier(
99-
"N2",
100-
NodeProjection.of(
101-
"Node1",
102-
PropertyMappings.of()
103-
)
104-
).putNodeProjectionsWithIdentifier(
105-
"N3",
106-
NodeProjection.of(
107-
"Node2",
108-
PropertyMappings.builder().addMapping(PropertyMapping.of("prop2", 1.0D)).build()
109-
)
110-
).graphName("myGraph")
91+
.putNodeProjectionsWithIdentifier("N1",
92+
NodeProjection.builder().label("Node1").addProperty(PropertyMapping.of("prop1", 0.0D)).build()
93+
)
94+
.putNodeProjectionsWithIdentifier("N2", NodeProjection.of("Node1"))
95+
.putNodeProjectionsWithIdentifier("N3",
96+
NodeProjection.builder().label("Node2").addProperty(PropertyMapping.of("prop2", 1.0D)).build()
97+
)
98+
.graphName("myGraph")
11199
.databaseService(db)
112100
.build()
113101
.graphStore();
@@ -134,19 +122,14 @@ void nodeProjectionsWithAndWithoutLabel() {
134122
GraphStore graphStore = new StoreLoaderBuilder()
135123
.putNodeProjectionsWithIdentifier(
136124
allIdentifier.name(),
137-
NodeProjection.of(
138-
"*",
139-
PropertyMappings.builder()
140-
.addMapping(PropertyMapping.of("prop1", 42.0D))
141-
.addMapping(PropertyMapping.of("prop2", 8.0D))
142-
.build()
143-
)
125+
NodeProjection
126+
.builder()
127+
.label("*")
128+
.addProperties(PropertyMapping.of("prop1", 42.0D), PropertyMapping.of("prop2", 8.0D))
129+
.build()
144130
).putNodeProjectionsWithIdentifier(
145131
node2Identifier.name(),
146-
NodeProjection.of(
147-
"Node2",
148-
PropertyMappings.builder().addMapping(PropertyMapping.of("prop2", 8.0D)).build()
149-
)
132+
NodeProjection.builder().label("Node2").addProperty(PropertyMapping.of("prop2", 8.0D)).build()
150133
).graphName("myGraph")
151134
.databaseService(db)
152135
.build()

0 commit comments

Comments
 (0)