|
43 | 43 | import org.apache.arrow.vector.complex.ListViewVector; |
44 | 44 | import org.apache.arrow.vector.complex.NonNullableStructVector; |
45 | 45 | import org.apache.arrow.vector.complex.RunEndEncodedVector; |
| 46 | +import org.apache.arrow.vector.complex.RunEndEncodedVector.RangeIterator; |
46 | 47 | import org.apache.arrow.vector.complex.StructVector; |
47 | 48 | import org.apache.arrow.vector.complex.UnionVector; |
48 | 49 |
|
@@ -270,35 +271,24 @@ protected boolean compareRunEndEncodedVectors(Range range) { |
270 | 271 | RunEndEncodedVector leftVector = (RunEndEncodedVector) left; |
271 | 272 | RunEndEncodedVector rightVector = (RunEndEncodedVector) right; |
272 | 273 |
|
273 | | - final int leftRangeEnd = range.getLeftStart() + range.getLength(); |
274 | | - final int rightRangeEnd = range.getRightStart() + range.getLength(); |
| 274 | + final RunEndEncodedVector.RangeIterator leftIterator = |
| 275 | + new RangeIterator(leftVector, range.getLeftStart(), range.getLength()); |
| 276 | + final RunEndEncodedVector.RangeIterator rightIterator = |
| 277 | + new RangeIterator(rightVector, range.getRightStart(), range.getLength()); |
275 | 278 |
|
276 | 279 | FieldVector leftValuesVector = leftVector.getValuesVector(); |
277 | 280 | FieldVector rightValuesVector = rightVector.getValuesVector(); |
278 | 281 |
|
279 | 282 | RangeEqualsVisitor innerVisitor = createInnerVisitor(leftValuesVector, rightValuesVector, null); |
280 | 283 |
|
281 | | - int leftLogicalIndex = range.getLeftStart(); |
282 | | - int rightLogicalIndex = range.getRightStart(); |
| 284 | + while (leftIterator.nextRun() | rightIterator.nextRun()) { |
| 285 | + int leftPhysicalIndex = leftIterator.getRunIndex(); |
| 286 | + int rightPhysicalIndex = rightIterator.getRunIndex(); |
283 | 287 |
|
284 | | - while (leftLogicalIndex < leftRangeEnd) { |
285 | | - // TODO: implement it more efficient |
286 | | - // https://github.com/apache/arrow/issues/44157 |
287 | | - int leftPhysicalIndex = leftVector.getPhysicalIndex(leftLogicalIndex); |
288 | | - int rightPhysicalIndex = rightVector.getPhysicalIndex(rightLogicalIndex); |
289 | 288 | if (leftValuesVector.accept( |
290 | 289 | innerVisitor, new Range(leftPhysicalIndex, rightPhysicalIndex, 1))) { |
291 | | - int leftRunEnd = leftVector.getRunEnd(leftLogicalIndex); |
292 | | - int rightRunEnd = rightVector.getRunEnd(rightLogicalIndex); |
293 | | - |
294 | | - int leftRunLength = Math.min(leftRunEnd, leftRangeEnd) - leftLogicalIndex; |
295 | | - int rightRunLength = Math.min(rightRunEnd, rightRangeEnd) - rightLogicalIndex; |
296 | | - |
297 | | - if (leftRunLength != rightRunLength) { |
| 290 | + if (leftIterator.getRunLength() != rightIterator.getRunLength()) { |
298 | 291 | return false; |
299 | | - } else { |
300 | | - leftLogicalIndex = leftRunEnd; |
301 | | - rightLogicalIndex = rightRunEnd; |
302 | 292 | } |
303 | 293 | } else { |
304 | 294 | return false; |
|
0 commit comments