Skip to content

feat(arrow/array): add Resize method to RecordBuilder - #805

Merged
zeroshade merged 1 commit into
apache:mainfrom
oakad:gh-796-helper-method-for-recordbuilder
May 19, 2026
Merged

zeroshade merged 1 commit into
apache:mainfrom
oakad:gh-796-helper-method-for-recordbuilder

Conversation

@oakad

@oakad oakad commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Presently added Resize method addresses two, relatively common needs:

  1. All fields within the Builder may need to be resized to the same length.
  2. As part of error recovery process, fields may need to be truncated to the length of the shortest one, effectively discarding incomplete "rows".

Fixes #796

Rationale for this change

Easier error handling when only partial data is available due to error.

What changes are included in this PR?

Additional method for RecordBuilder.

Are these changes tested?

Unit test is provided.

Are there any user-facing changes?

Additional method in RecordBuilder.

@oakad
oakad requested a review from zeroshade as a code owner May 8, 2026 08:58

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally looks fine, but needs unit tests and to reference the relevant issue in the description.

@zeroshade zeroshade changed the title RecordBuilder: add Resize method feat(arrow/array): add Resize method to RecordBuilder May 8, 2026
@oakad

oakad commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

It says "Fixes #796" right there in the commit message. What sort of additional reference can I add?

Will see regarding the unit test tomorrow.

@zeroshade

Copy link
Copy Markdown
Member

It says "Fixes #796" right there in the commit message.

Ah, I missed that. My fault there.

So yea, just needs tests and to fix the linting issue

@oakad
oakad force-pushed the gh-796-helper-method-for-recordbuilder branch from 02388ed to 985cfe9 Compare May 18, 2026 08:32
@oakad

oakad commented May 18, 2026 •

Copy link
Copy Markdown
Contributor Author

I have added a unit test. I also had to alter the NewRecordBatchs semantics slightly, as I could not get rid of memory leak otherwise - after the panic inside NewRecordBatch was raised, the remaining memory state was somehow non-obviously inconsistent.

Also, it feels that current approach (check row counts ahead of any array move action) is generally safer.

Presently added Resize method addresses two, relatively common needs:

1. All fields within the Builder may need to be resized to the same
length.
2. As part of error recovery process, fields may need to be truncated
to the length of the shortest one, effectively discarding incomplete
"rows".

RecordBuilder.NewRecordBatch now performs row length validation prior
to any action, to ensure reusability of RecordBuilder across errors.

This also prevents hard to reason about memory leaks.

Fixes apache#796

Unit test for RecordBuilder.Resize
@oakad
oakad force-pushed the gh-796-helper-method-for-recordbuilder branch from 985cfe9 to ff7fc4c Compare May 18, 2026 09:00
@oakad
oakad requested a review from zeroshade May 19, 2026 07:35
@zeroshade
zeroshade merged commit 53993f5 into apache:main May 19, 2026
23 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.

Helper method for RecordBuilder to drop last, incomplete "rows"

2 participants