Skip to content

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

Open
oakad wants to merge 1 commit into
apache:mainfrom
oakad:gh-796-helper-method-for-recordbuilder
Open

feat(arrow/array): add Resize method to RecordBuilder#805
oakad wants to merge 1 commit into
apache:mainfrom
oakad:gh-796-helper-method-for-recordbuilder

Conversation

@oakad
Copy link
Copy Markdown

@oakad oakad commented May 8, 2026

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
Copy link
Copy Markdown
Member

@zeroshade zeroshade left a comment

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
Copy link
Copy Markdown
Author

oakad commented May 14, 2026

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
Copy link
Copy Markdown
Author

oakad commented May 18, 2026

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
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