4646class SplitRelationshipsTest {
4747
4848 @ GdlGraph (orientation = Orientation .UNDIRECTED , idOffset = 42 )
49- static final String GRAPH_WITH_OFFSET =
50- " CREATE" +
51- " (a: Node)," +
52- " (b: Node)," +
53- " (c: Node)," +
54- " (d: Node)," +
55- " (e: Node)," +
56- " (f: Node)," +
57- " (g: Node)," +
58- " (a)-[:REL]->(b)," +
59- " (a)-[:REL]->(c)," +
60- " (a)-[:REL]->(d)," +
61- " (a)-[:REL]->(e)," +
62- " (a)-[:REL]->(f)," +
63- " (a)-[:REL]->(g)," +
64- " (b)-[:REL]->(c)," +
65- " (b)-[:REL]->(d)," +
66- " (b)-[:REL]->(e)," +
67- " (b)-[:REL]->(f)," +
68- " (b)-[:REL2]->(g)," +
69- " (c)-[:REL2]->(d)," +
70- " (c)-[:REL2]->(e)," +
71- " (c)-[:REL2]->(f)," +
72- " (c)-[:REL2]->(g)" ;
49+ static final String GRAPH_WITH_OFFSET = " CREATE" + " (a: Node)," + " (b: Node)," + " (c: Node)," + " (d: Node)," + " (e: Node)," + " (f: Node)," + " (g: Node)," + " (a)-[:REL]->(b)," + " (a)-[:REL]->(c)," + " (a)-[:REL]->(d)," + " (a)-[:REL]->(e)," + " (a)-[:REL]->(f)," + " (a)-[:REL]->(g)," + " (b)-[:REL]->(c)," + " (b)-[:REL]->(d)," + " (b)-[:REL]->(e)," + " (b)-[:REL]->(f)," + " (b)-[:REL2]->(g)," + " (c)-[:REL2]->(d)," + " (c)-[:REL2]->(e)," + " (c)-[:REL2]->(f)," + " (c)-[:REL2]->(g)" ;
7350
7451 @ Inject
7552 private GraphStore graphStore ;
@@ -96,16 +73,11 @@ void computeWithOffset() {
9673 @ Test
9774 void estimate () {
9875 var graphDimensions = GraphDimensions .of (1 , 10_000 );
99- var config = SplitRelationshipsMutateConfigImpl
100- .builder ()
101- .negativeSamplingRatio (1.0 )
102- .holdoutRelationshipType ("HOLDOUT" )
103- .remainingRelationshipType ("REST" )
104- .holdoutFraction (0.3 )
105- .relationshipTypes (List .of (ElementProjection .PROJECT_ALL ))
106- .build ();
76+ var config = SplitRelationshipsMutateConfigImpl .builder ().negativeSamplingRatio (1.0 ).holdoutRelationshipType (
77+ "HOLDOUT" ).remainingRelationshipType ("REST" ).holdoutFraction (0.3 ).relationshipTypes (List .of (
78+ ElementProjection .PROJECT_ALL )).build ();
10779
108- MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
80+ MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
10981 .memoryEstimation ()
11082 .estimate (graphDimensions , config .concurrency ());
11183
@@ -127,27 +99,24 @@ public static Stream<Arguments> withTypesParams() {
12799 void estimateWithTypes (List <String > relTypes , MemoryRange expectedMemory ) {
128100 var nodeCount = 100 ;
129101 var relationshipCounts = Map .of (
130- RelationshipType .of ("TYPE1" ), 10L ,
131- RelationshipType .of ("TYPE2" ), 20L ,
132- RelationshipType .of ("TYPE3" ), 30L
102+ RelationshipType .of ("TYPE1" ),
103+ 10L ,
104+ RelationshipType .of ("TYPE2" ),
105+ 20L ,
106+ RelationshipType .of ("TYPE3" ),
107+ 30L
133108 );
134109
135- var graphDimensions = ImmutableGraphDimensions .builder ()
136- . nodeCount ( nodeCount )
137- .relationshipCounts ( relationshipCounts )
138- .relCountUpperBound ( relationshipCounts . values (). stream (). mapToLong (Long ::longValue ). sum () )
139- .build ();
110+ var graphDimensions = ImmutableGraphDimensions .builder (). nodeCount ( nodeCount ). relationshipCounts (
111+ relationshipCounts ). relCountUpperBound ( relationshipCounts . values ( )
112+ .stream ( )
113+ .mapToLong (Long ::longValue )
114+ .sum ()). build ();
140115
141- var config = SplitRelationshipsMutateConfigImpl
142- .builder ()
143- .negativeSamplingRatio (1.0 )
144- .holdoutRelationshipType ("HOLDOUT" )
145- .remainingRelationshipType ("REST" )
146- .holdoutFraction (0.3 )
147- .relationshipTypes (relTypes )
148- .build ();
116+ var config = SplitRelationshipsMutateConfigImpl .builder ().negativeSamplingRatio (1.0 ).holdoutRelationshipType (
117+ "HOLDOUT" ).remainingRelationshipType ("REST" ).holdoutFraction (0.3 ).relationshipTypes (relTypes ).build ();
149118
150- MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
119+ MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
151120 .memoryEstimation ()
152121 .estimate (graphDimensions , config .concurrency ());
153122
@@ -156,23 +125,18 @@ void estimateWithTypes(List<String> relTypes, MemoryRange expectedMemory) {
156125
157126 @ Test
158127 void estimateIndependentOfNodeCount () {
159- var config = SplitRelationshipsMutateConfigImpl
160- .builder ()
161- .negativeSamplingRatio (1.0 )
162- .holdoutRelationshipType ("HOLDOUT" )
163- .remainingRelationshipType ("REST" )
164- .holdoutFraction (0.3 )
165- .relationshipTypes (List .of (ElementProjection .PROJECT_ALL ))
166- .build ();
128+ var config = SplitRelationshipsMutateConfigImpl .builder ().negativeSamplingRatio (1.0 ).holdoutRelationshipType (
129+ "HOLDOUT" ).remainingRelationshipType ("REST" ).holdoutFraction (0.3 ).relationshipTypes (List .of (
130+ ElementProjection .PROJECT_ALL )).build ();
167131
168132 var graphDimensions = GraphDimensions .of (1 , 10_000 );
169- MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
133+ MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
170134 .memoryEstimation ()
171135 .estimate (graphDimensions , config .concurrency ());
172136 assertMemoryRange (actualEstimate .memoryUsage (), MemoryRange .of (160_000 , 208_000 ));
173137
174138 graphDimensions = GraphDimensions .of (100_000 , 10_000 );
175- actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
139+ actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
176140 .memoryEstimation ()
177141 .estimate (graphDimensions , config .concurrency ());
178142 assertMemoryRange (actualEstimate .memoryUsage (), MemoryRange .of (160_000 , 208_000 ));
@@ -182,22 +146,21 @@ void estimateIndependentOfNodeCount() {
182146 void estimateDifferentSamplingRatios () {
183147 var graphDimensions = GraphDimensions .of (1 , 10_000 );
184148
185- var configBuilder = SplitRelationshipsMutateConfigImpl
186- .builder ()
149+ var configBuilder = SplitRelationshipsMutateConfigImpl .builder ()
187150 .holdoutRelationshipType ("HOLDOUT" )
188151 .remainingRelationshipType ("REST" )
189152 .holdoutFraction (0.3 )
190153 .relationshipTypes (List .of (ElementProjection .PROJECT_ALL ));
191154
192155 var config = configBuilder .negativeSamplingRatio (1.0 ).build ();
193- MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
156+ MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
194157 .memoryEstimation ()
195158 .estimate (graphDimensions , config .concurrency ());
196159
197160 assertMemoryRange (actualEstimate .memoryUsage (), MemoryRange .of (160_000 , 208_000 ));
198161
199162 config = configBuilder .negativeSamplingRatio (2.0 ).build ();
200- actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
163+ actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
201164 .memoryEstimation ()
202165 .estimate (graphDimensions , config .concurrency ());
203166
@@ -208,21 +171,20 @@ void estimateDifferentSamplingRatios() {
208171 void estimateDifferentHoldoutFractions () {
209172 var graphDimensions = GraphDimensions .of (1 , 10_000 );
210173
211- var configBuilder = SplitRelationshipsMutateConfigImpl
212- .builder ()
174+ var configBuilder = SplitRelationshipsMutateConfigImpl .builder ()
213175 .holdoutRelationshipType ("HOLDOUT" )
214176 .remainingRelationshipType ("REST" )
215177 .negativeSamplingRatio (1.0 )
216178 .relationshipTypes (List .of (ElementProjection .PROJECT_ALL ));
217179
218180 var config = configBuilder .holdoutFraction (0.3 ).build ();
219- MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
181+ MemoryTree actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
220182 .memoryEstimation ()
221183 .estimate (graphDimensions , config .concurrency ());
222184 assertMemoryRange (actualEstimate .memoryUsage (), MemoryRange .of (160_000 , 208_000 ));
223185
224186 config = configBuilder .holdoutFraction (0.1 ).build ();
225- actualEstimate = new SplitRelationshipsEstimateDefinition (config .toMemoryEstimateParameters ())
187+ actualEstimate = new SplitRelationshipsEstimateDefinition (SplitRelationshipConfigTransformer .toMemoryEstimateParameters (config ))
226188 .memoryEstimation ()
227189 .estimate (graphDimensions , config .concurrency ());
228190
0 commit comments