You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by et...@apache.org on 2025/04/28 06:25:24 UTC
(iceberg) branch main updated: Spark: Use newArrayListWithExpectedSize in NDVSketchUtil (#12907)
This is an automated email from the ASF dual-hosted git repository.
etudenhoefner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new 346414c0f5 Spark: Use newArrayListWithExpectedSize in NDVSketchUtil (#12907)
346414c0f5 is described below
commit 346414c0f500ec06f524517d368bdedd4744edf2
Author: jackylee <qc...@gmail.com>
AuthorDate: Mon Apr 28 14:25:18 2025 +0800
Spark: Use newArrayListWithExpectedSize in NDVSketchUtil (#12907)
---
.../src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java | 3 ++-
.../src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java
index c8a20d3cca..8aff398e92 100644
--- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java
+++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java
@@ -50,7 +50,8 @@ public class NDVSketchUtil {
SparkSession spark, Table table, Snapshot snapshot, List<String> columns) {
Row sketches = computeNDVSketches(spark, table, snapshot, columns);
Schema schema = table.schemas().get(snapshot.schemaId());
- List<Blob> blobs = Lists.newArrayList();
+ List<Blob> blobs = Lists.newArrayListWithExpectedSize(columns.size());
+
for (int i = 0; i < columns.size(); i++) {
Types.NestedField field = schema.findField(columns.get(i));
Sketch sketch = CompactSketch.wrap(Memory.wrap((byte[]) sketches.get(i)));
diff --git a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java
index c8a20d3cca..8aff398e92 100644
--- a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java
+++ b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/actions/NDVSketchUtil.java
@@ -50,7 +50,8 @@ public class NDVSketchUtil {
SparkSession spark, Table table, Snapshot snapshot, List<String> columns) {
Row sketches = computeNDVSketches(spark, table, snapshot, columns);
Schema schema = table.schemas().get(snapshot.schemaId());
- List<Blob> blobs = Lists.newArrayList();
+ List<Blob> blobs = Lists.newArrayListWithExpectedSize(columns.size());
+
for (int i = 0; i < columns.size(); i++) {
Types.NestedField field = schema.findField(columns.get(i));
Sketch sketch = CompactSketch.wrap(Memory.wrap((byte[]) sketches.get(i)));