This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 7eaa78501a [api] Avoid overflow in VectorType default size (#8360)
7eaa78501a is described below
commit 7eaa78501a1a0e4823e94db6674034c10d52a274
Author: QuakeWang <[email protected]>
AuthorDate: Sat Jun 27 08:49:19 2026 +0800
[api] Avoid overflow in VectorType default size (#8360)
---
.../java/org/apache/paimon/types/VectorType.java | 3 +-
.../org/apache/paimon/types/VectorTypeTest.java | 41 ++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/paimon-api/src/main/java/org/apache/paimon/types/VectorType.java
b/paimon-api/src/main/java/org/apache/paimon/types/VectorType.java
index db5337f03a..008b6f8abf 100644
--- a/paimon-api/src/main/java/org/apache/paimon/types/VectorType.java
+++ b/paimon-api/src/main/java/org/apache/paimon/types/VectorType.java
@@ -19,6 +19,7 @@
package org.apache.paimon.types;
import org.apache.paimon.annotation.Public;
+import org.apache.paimon.utils.MathUtils;
import org.apache.paimon.utils.Preconditions;
import
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.core.JsonGenerator;
@@ -95,7 +96,7 @@ public class VectorType extends DataType {
@Override
public int defaultSize() {
- return elementType.defaultSize() * length;
+ return MathUtils.multiplySafely(elementType.defaultSize(), length);
}
@Override
diff --git
a/paimon-api/src/test/java/org/apache/paimon/types/VectorTypeTest.java
b/paimon-api/src/test/java/org/apache/paimon/types/VectorTypeTest.java
new file mode 100644
index 0000000000..9153d254b8
--- /dev/null
+++ b/paimon-api/src/test/java/org/apache/paimon/types/VectorTypeTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.types;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link VectorType}. */
+class VectorTypeTest {
+
+ @Test
+ void testDefaultSize() {
+ assertThat(DataTypes.VECTOR(3,
DataTypes.FLOAT()).defaultSize()).isEqualTo(12);
+ assertThat(DataTypes.VECTOR(2,
DataTypes.DOUBLE()).defaultSize()).isEqualTo(16);
+ }
+
+ @Test
+ void testDefaultSizeOverflowReturnsMaxValue() {
+ assertThat(DataTypes.VECTOR(Integer.MAX_VALUE,
DataTypes.FLOAT()).defaultSize())
+ .isEqualTo(Integer.MAX_VALUE);
+ assertThat(DataTypes.VECTOR(Integer.MAX_VALUE,
DataTypes.DOUBLE()).defaultSize())
+ .isEqualTo(Integer.MAX_VALUE);
+ }
+}