Skip to content

refactor(common): centralize checked class-pointer casts - #202

Open
lxy-9602 wants to merge 1 commit into
apache:mainfrom
lxy-9602:refactor-pointer-cast
Open

refactor(common): centralize checked class-pointer casts#202
lxy-9602 wants to merge 1 commit into
apache:mainfrom
lxy-9602:refactor-pointer-cast

Conversation

@lxy-9602

Copy link
Copy Markdown
Collaborator

Purpose

Introduce Paimon-owned checked_cast and checked_pointer_cast helpers that delegate to Arrow's debug-checked cast implementation.

This change:

  • Replaces direct uses of arrow::internal::checked_cast and arrow::internal::checked_pointer_cast.
  • Replaces class-hierarchy static_cast and std::static_pointer_cast usages with the Paimon helpers where applicable.
  • Validates null pointers and Arrow type IDs before checked casts when a type mismatch is a recoverable runtime error.
  • Keeps dynamic_cast when cast failure represents an expected runtime branch or is handled by an existing null-check macro.
  • Keeps discriminator-guarded std::static_pointer_cast for non-polymorphic hierarchies such as parquet::Page.
  • Documents the checked-cast conventions and exceptions in the code style guide.

Tests

API and Format

Documentation

Updated docs/code-style.md.

Generative AI tooling

Generated-by: OpenAI Codex (GPT-5)

using ArrayType = typename arrow::TypeTraits<arrow::TimestampType>::ArrayType;
auto array = arrow::internal::checked_cast<const ArrayType*>(array_);
auto array = checked_cast<const ArrayType*>(array_);
assert(array);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no assert here?

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.

2 participants