Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class PaimonJniScanner extends JniScanner {
private long dbId;
private long tblId;
private long lastUpdateTime;
private RecordReader.RecordIterator<InternalRow> recordIterator = null;

public PaimonJniScanner(int batchSize, Map<String, String> params) {
LOG.debug("params:{}", params);
Expand Down Expand Up @@ -133,18 +134,25 @@ public void close() throws IOException {
protected int getNext() throws IOException {
int rows = 0;
try {
RecordReader.RecordIterator<InternalRow> batch;
while ((batch = reader.readBatch()) != null) {
if (recordIterator == null) {
recordIterator = reader.readBatch();
}

while (recordIterator != null) {
InternalRow record;
while ((record = batch.next()) != null) {
while ((record = recordIterator.next()) != null) {
columnValue.setOffsetRow(record);
for (int i = 0; i < fields.length; i++) {
columnValue.setIdx(i, types[i]);
appendData(i, columnValue);
}
rows++;
if (rows >= batchSize) {
return rows;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some logical problem here? After returning here, the following recordIterator.releaseBatch(); will not be executed.
Can it be handled in finally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This iterator hasn't been read yet, so it can't be released. Wait for the next time it is called until the read is complete.

}
}
batch.releaseBatch();
recordIterator.releaseBatch();
recordIterator = reader.readBatch();
}
} catch (IOException e) {
LOG.warn("failed to getNext columnValue ", e);
Expand Down