Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Refactory ColumnarRowIterator using LongIterator. #4992

Merged
merged 4 commits into from
Jan 24, 2025

Conversation

leaves12138
Copy link
Contributor

Purpose

Using LongIterator instead of long[].

Tests

API and Format

Documentation

@@ -89,9 +95,11 @@ public Path filePath() {
}

protected ColumnarRowIterator copy(ColumnVector[] vectors) {
// We should call copy only when the iterator is at the beginning of the file.
assert nextPos == 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use checkPrecondition

@@ -77,10 +78,15 @@ public InternalRow next() {

@Override
public long returnedPosition() {
if (nextPos == 0) {
return positions[0] - 1;
for (int i = 0; i < nextPos - callReturnedPositionTimes; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for this.

@@ -52,16 +54,15 @@ public ColumnarRowIterator(Path filePath, ColumnarRow row, @Nullable Runnable re
}

public void reset(long nextFilePos) {
reset(LongIterator.fromRange(nextFilePos, nextFilePos + positions.length));
reset(LongIterator.fromRange(nextFilePos, nextFilePos + row.batch().getNumRows()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can rebase the master

@@ -38,9 +37,10 @@ public VectorizedColumnBatch batch() {

@Override
protected VectorizedRowIterator copy(ColumnVector[] vectors) {
assert nextPos == 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use checkPrecondition

this.nextPos = 0;
this.callReturnedPositionTimes = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returnedPositionIndex?

@@ -42,7 +42,9 @@ public class ColumnarRowIterator extends RecyclableIterator<InternalRow>

protected int num;
protected int nextPos;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is OK to rename this to index.

@JingsongLi
Copy link
Contributor

Looks good to me!

@JingsongLi JingsongLi merged commit aab1097 into apache:master Jan 24, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants