@@ -134,7 +134,6 @@ boolean matchesExactly(MutablePathResult path, int index) {
134134 if (relationshipIds .length == 0 || path .relationshipIds .length == 0 ) {
135135 return matches (path , index );
136136 }
137- //System.out.println(Arrays.toString(Arrays.stream(relationshipIds).toArray()));
138137 for (int i = 0 ; i < index ; i ++) {
139138 if (nodeIds [i ] != path .nodeIds [i ]) {
140139 return false ;
@@ -157,7 +156,9 @@ boolean matchesExactly(MutablePathResult path, int index) {
157156 * The cost value associated with the last value in this path, is added to
158157 * the costs for each node in the second path.
159158 */
160- void append (MutablePathResult path , boolean shouldstore ) {
159+
160+
161+ private void append (MutablePathResult path , long [] relationships ) {
161162 // spur node is end of first and beginning of second path
162163 assert nodeIds [nodeIds .length - 1 ] == path .nodeIds [0 ];
163164
@@ -166,15 +167,10 @@ void append(MutablePathResult path, boolean shouldstore) {
166167 var newNodeIds = new long [oldLength + path .nodeIds .length - 1 ];
167168 var newCosts = new double [oldLength + path .nodeIds .length - 1 ];
168169
169- var oldRelationshipIdsLength = relationshipIds .length ;
170- var newRelationshipIds = new long [oldRelationshipIdsLength + path .relationshipIds .length ];
171-
172170 // copy node ids
173171 System .arraycopy (this .nodeIds , 0 , newNodeIds , 0 , oldLength );
174172 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+
178174 // copy costs
179175 System .arraycopy (this .costs , 0 , newCosts , 0 , oldLength );
180176 System .arraycopy (path .costs , 1 , newCosts , oldLength , path .costs .length - 1 );
@@ -186,10 +182,41 @@ void append(MutablePathResult path, boolean shouldstore) {
186182 }
187183
188184 this .nodeIds = newNodeIds ;
189- this .relationshipIds = shouldstore ? newRelationshipIds : new long [ 0 ] ;
185+ this .relationshipIds = relationships ;
190186 this .costs = newCosts ;
191187 }
192188
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+
193220 @ Override
194221 public boolean equals (Object o ) {
195222 if (this == o ) return true ;
0 commit comments