@@ -252,9 +252,9 @@ public DataFrame Merge<TKey>(DataFrame other, string leftJoinColumn, string righ
252
252
// Hash the column with the smaller RowCount
253
253
long leftRowCount = Rows . Count ;
254
254
long rightRowCount = other . Rows . Count ;
255
- DataFrame longerDataFrame = leftRowCount <= rightRowCount ? other : this ;
256
- DataFrame shorterDataFrame = ReferenceEquals ( longerDataFrame , this ) ? other : this ;
257
- DataFrameColumn hashColumn = ( leftRowCount <= rightRowCount ) ? Columns [ leftJoinColumn ] : other . Columns [ rightJoinColumn ] ;
255
+
256
+ var leftColumnIsSmaller = ( leftRowCount <= rightRowCount ) ;
257
+ DataFrameColumn hashColumn = leftColumnIsSmaller ? Columns [ leftJoinColumn ] : other . Columns [ rightJoinColumn ] ;
258
258
DataFrameColumn otherColumn = ReferenceEquals ( hashColumn , Columns [ leftJoinColumn ] ) ? other . Columns [ rightJoinColumn ] : Columns [ leftJoinColumn ] ;
259
259
Dictionary < TKey , ICollection < long > > multimap = hashColumn . GroupColumnValues < TKey > ( ) ;
260
260
@@ -270,23 +270,21 @@ public DataFrame Merge<TKey>(DataFrame other, string leftJoinColumn, string righ
270
270
{
271
271
if ( hashColumn [ row ] == null )
272
272
{
273
- leftRowIndices . Append ( row ) ;
274
- rightRowIndices . Append ( i ) ;
273
+ leftRowIndices . Append ( leftColumnIsSmaller ? row : i ) ;
274
+ rightRowIndices . Append ( leftColumnIsSmaller ? i : row ) ;
275
275
}
276
276
}
277
277
else
278
278
{
279
279
if ( hashColumn [ row ] != null )
280
280
{
281
- leftRowIndices . Append ( row ) ;
282
- rightRowIndices . Append ( i ) ;
281
+ leftRowIndices . Append ( leftColumnIsSmaller ? row : i ) ;
282
+ rightRowIndices . Append ( leftColumnIsSmaller ? i : row ) ;
283
283
}
284
284
}
285
285
}
286
286
}
287
287
}
288
- leftDataFrame = shorterDataFrame ;
289
- rightDataFrame = longerDataFrame ;
290
288
}
291
289
else if ( joinAlgorithm == JoinAlgorithm . FullOuter )
292
290
{
@@ -366,4 +364,5 @@ public DataFrame Merge<TKey>(DataFrame other, string leftJoinColumn, string righ
366
364
}
367
365
368
366
}
367
+
369
368
}
0 commit comments