@@ -134,7 +134,6 @@ boolean matchesExactly(MutablePathResult path, int index) {
134
134
if (relationshipIds .length == 0 || path .relationshipIds .length == 0 ) {
135
135
return matches (path , index );
136
136
}
137
- //System.out.println(Arrays.toString(Arrays.stream(relationshipIds).toArray()));
138
137
for (int i = 0 ; i < index ; i ++) {
139
138
if (nodeIds [i ] != path .nodeIds [i ]) {
140
139
return false ;
@@ -157,7 +156,9 @@ boolean matchesExactly(MutablePathResult path, int index) {
157
156
* The cost value associated with the last value in this path, is added to
158
157
* the costs for each node in the second path.
159
158
*/
160
- void append (MutablePathResult path , boolean shouldstore ) {
159
+
160
+
161
+ private void append (MutablePathResult path , long [] relationships ) {
161
162
// spur node is end of first and beginning of second path
162
163
assert nodeIds [nodeIds .length - 1 ] == path .nodeIds [0 ];
163
164
@@ -166,15 +167,10 @@ void append(MutablePathResult path, boolean shouldstore) {
166
167
var newNodeIds = new long [oldLength + path .nodeIds .length - 1 ];
167
168
var newCosts = new double [oldLength + path .nodeIds .length - 1 ];
168
169
169
- var oldRelationshipIdsLength = relationshipIds .length ;
170
- var newRelationshipIds = new long [oldRelationshipIdsLength + path .relationshipIds .length ];
171
-
172
170
// copy node ids
173
171
System .arraycopy (this .nodeIds , 0 , newNodeIds , 0 , oldLength );
174
172
System .arraycopy (path .nodeIds , 1 , newNodeIds , oldLength , path .nodeIds .length - 1 );
175
- // copy relationship ids
176
- System .arraycopy (this .relationshipIds , 0 , newRelationshipIds , 0 , oldRelationshipIdsLength );
177
- System .arraycopy (path .relationshipIds , 0 , newRelationshipIds , oldRelationshipIdsLength , path .relationshipIds .length );
173
+
178
174
// copy costs
179
175
System .arraycopy (this .costs , 0 , newCosts , 0 , oldLength );
180
176
System .arraycopy (path .costs , 1 , newCosts , oldLength , path .costs .length - 1 );
@@ -186,10 +182,41 @@ void append(MutablePathResult path, boolean shouldstore) {
186
182
}
187
183
188
184
this .nodeIds = newNodeIds ;
189
- this .relationshipIds = shouldstore ? newRelationshipIds : new long [ 0 ] ;
185
+ this .relationshipIds = relationships ;
190
186
this .costs = newCosts ;
191
187
}
192
188
189
+ void append (MutablePathResult path ) {
190
+
191
+ var oldRelationshipIdsLength = relationshipIds .length ;
192
+ var newRelationshipIds = new long [oldRelationshipIdsLength + path .relationshipIds .length ];
193
+ // copy relationship ids
194
+ System .arraycopy (this .relationshipIds , 0 , newRelationshipIds , 0 , oldRelationshipIdsLength );
195
+ System .arraycopy (
196
+ path .relationshipIds ,
197
+ 0 ,
198
+ newRelationshipIds ,
199
+ oldRelationshipIdsLength ,
200
+ path .relationshipIds .length
201
+ );
202
+
203
+ append (path , newRelationshipIds );
204
+ }
205
+
206
+ /**
207
+ * Appends the given path to this path without creating an explicit relationship array.
208
+ *
209
+ * The last node in this path, must match the first node in the given path.
210
+ * This node will only appear once in the resulting path.
211
+ * The cost value associated with the last value in this path, is added to
212
+ * the costs for each node in the second path.
213
+ */
214
+ void appendWithoutRelationshipIds (MutablePathResult path ) {
215
+ // spur node is end of first and beginning of second path
216
+ append (path , new long [0 ]);
217
+ }
218
+
219
+
193
220
@ Override
194
221
public boolean equals (Object o ) {
195
222
if (this == o ) return true ;
0 commit comments