Skip to content

Move binary and byte-view cast helpers into a private submodule - #11077

Open
anandghegde wants to merge 1 commit into
apache:mainfrom
anandghegde:extract-binary-cast-helpers
Open

anandghegde wants to merge 1 commit into
apache:mainfrom
anandghegde:extract-binary-cast-helpers

Conversation

@anandghegde

Copy link
Copy Markdown

Which issue does this PR close?

Part of #11032 — the binary, fixed-size binary and byte-view helpers group
only, so it does not close the issue.

Sibling PRs against the same issue: #11075 (temporal) and #11076 (numeric and
boolean). All three are independent and move disjoint functions, but each adds a
mod line and an import to mod.rs, so whichever lands later will want a
trivial rebase.

Rationale for this change

arrow-cast/src/cast/mod.rs is ~14k lines. #5125 moved list, decimal,
dictionary, string, map, run-array and union support into private submodules,
and #11032 lists the groups still inline. The byte-oriented conversions are one
of them.

What changes are included in this PR?

A new private arrow-cast/src/cast/binary.rs holding:

  • cast_numeric_to_binary
  • cast_binary_to_fixed_size_binary
  • cast_fixed_size_binary_to_binary
  • cast_fixed_size_binary_to_binary_view
  • cast_byte_container
  • cast_view_to_byte

cast_with_options stays the top-level dispatcher in mod.rs.

Worth flagging for review:

  • No public API surface is involved here. Unlike the numeric group in
    Move numeric and boolean cast helpers into a private submodule #11076, none of these six were pub, so mod.rs uses a plain
    use crate::cast::binary::* rather than a pub use. All six are called from
    the dispatcher, so all six became pub(crate) and nothing stayed private.
  • cast_numeric_to_binary is not adjacent to the rest. It sits up with the
    numeric helpers in mod.rs rather than with the other byte conversions, but
    it belongs to this group, so it is moved from there.
  • Three imports left orphaned in mod.rs by the move are dropped:
    arrow_data::ByteView, and Buffer from the arrow_buffer import list.

Are these changes tested?

Covered by the existing arrow-cast tests — this is a code move, so no new
tests are warranted and no existing test was modified.

cargo test -p arrow-cast     379 passed + 12 passed, 0 failed (same as base)
cargo clippy -p arrow-cast --all-targets -- -D warnings   clean
cargo fmt -p arrow-cast -- --check                        clean
cargo build -p arrow                                      builds

As with the sibling PRs, the faithfulness of the move is checked mechanically
rather than by eye: extracting the two original line ranges from HEAD and
normalising away the added pub(crate) gives a byte-identical match against
the new file.

Run on macOS 26.6.2, aarch64-apple-darwin, toolchain 1.98.1 from
rust-toolchain.toml.

Are there any user-facing changes?

No. No public API change and no behavioural change.

AI usage disclosure

Written with AI assistance (Claude). The AI performed the mechanical extraction
and ran the verification above; I reviewed the result and own the change.

The moved bodies are unedited, and the byte-identity check is the evidence for
that rather than a reading. The judgement calls — pulling cast_numeric_to_binary
out of the numeric neighbourhood, the uniform pub(crate), and the three dropped
imports — are listed above because they are the parts a "pure move" diff would
not otherwise draw attention to.

Follow-up to apache#5125, continuing the extractions in apache#5537 and friends.

Move the binary, fixed-size binary and byte-view conversion helpers out of
`arrow-cast/src/cast/mod.rs` into a private `binary` submodule, leaving
`cast_with_options` as the top-level dispatcher.

The bodies are moved verbatim. All six helpers are called from the
dispatcher and become `pub(crate)`; none of them were public, so nothing
is added to or removed from the crate's public API.

No behavioural change and no public API change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-cast

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant