-
Notifications
You must be signed in to change notification settings - Fork 182
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
feat: Improve ScanExec native metrics #1133
Changes from all commits
84305d6
16b976a
a28fc50
16ecb19
7591af5
58bf50c
1814121
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,12 +33,31 @@ | |
public class CometBatchIterator { | ||
final Iterator<ColumnarBatch> input; | ||
final NativeUtil nativeUtil; | ||
private ColumnarBatch currentBatch = null; | ||
|
||
CometBatchIterator(Iterator<ColumnarBatch> input, NativeUtil nativeUtil) { | ||
this.input = input; | ||
this.nativeUtil = nativeUtil; | ||
} | ||
|
||
/** | ||
* Fetch the next input batch. | ||
* | ||
* @return Number of rows in next batch or -1 if no batches left. | ||
*/ | ||
public int hasNext() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the earlier comment about returning a bool from this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh. Ignore my previous comment. Why would changing the return type of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I run into this error when trying to return bool:
|
||
if (currentBatch == null) { | ||
if (input.hasNext()) { | ||
currentBatch = input.next(); | ||
} | ||
} | ||
if (currentBatch == null) { | ||
return -1; | ||
} else { | ||
return currentBatch.numRows(); | ||
} | ||
} | ||
|
||
/** | ||
* Get the next batches of Arrow arrays. | ||
* | ||
|
@@ -47,12 +66,11 @@ public class CometBatchIterator { | |
* @return the number of rows of the current batch. -1 if there is no more batch. | ||
*/ | ||
public int next(long[] arrayAddrs, long[] schemaAddrs) { | ||
boolean hasBatch = input.hasNext(); | ||
|
||
if (!hasBatch) { | ||
if (currentBatch == null) { | ||
return -1; | ||
} | ||
|
||
return nativeUtil.exportBatch(arrayAddrs, schemaAddrs, input.next()); | ||
int numRows = nativeUtil.exportBatch(arrayAddrs, schemaAddrs, currentBatch); | ||
kazuyukitanimura marked this conversation as resolved.
Show resolved
Hide resolved
|
||
currentBatch = null; | ||
return numRows; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, I would have had
has_next
return abool
rather thani32
but I could not figure out how to make that happen with our jni macros. I am open to suggestions on how to improve this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a
has_next
in CometBatchIterator.java. Should this becomet_batch_iterator(iter).next()
?And if you want to change the return value you can make the change in the Java class and also in the macro invocation.