Skip to content

[api] Avoid overflow in VectorType default size#8360

Merged
JingsongLi merged 1 commit into
apache:masterfrom
QuakeWang:vector-size
Jun 27, 2026
Merged

[api] Avoid overflow in VectorType default size#8360
JingsongLi merged 1 commit into
apache:masterfrom
QuakeWang:vector-size

Conversation

@QuakeWang

Copy link
Copy Markdown
Member

Purpose

VectorType.defaultSize() previously multiplied the element default size by the vector length using int arithmetic. For very large vector lengths, this could overflow and return a negative size estimate.

This PR uses MathUtils.multiplySafely to cap overflow at Integer.MAX_VALUE and keep size estimation valid.

Tests

  • mvn -pl paimon-api -Pfast-build -Dtest=VectorTypeTest test
  • mvn -pl paimon-api -Pfast-build -DskipTests compile
  • mvn -pl paimon-api -Dtest=VectorTypeTest test

VectorType.defaultSize multiplies the element default size by the vector length using int arithmetic. For large vector lengths, this can overflow and return a negative estimate.

Use MathUtils.multiplySafely to cap the estimate at Integer.MAX_VALUE, and add tests for the normal and overflow cases.

Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi JingsongLi merged commit 7eaa785 into apache:master Jun 27, 2026
12 of 13 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.

2 participants