This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 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 fe7f16eedb [hotfix] Minor refactor FormatReadBuilder
fe7f16eedb is described below
commit fe7f16eedb26deccf058ed22edd613e9cc356da2
Author: JingsongLi <[email protected]>
AuthorDate: Wed Sep 3 11:55:49 2025 +0800
[hotfix] Minor refactor FormatReadBuilder
---
.../paimon/table/format/FormatReadBuilder.java | 49 ++++++++++------------
.../paimon/table/format/FormatTableRead.java | 9 ++--
2 files changed, 27 insertions(+), 31 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/format/FormatReadBuilder.java
b/paimon-core/src/main/java/org/apache/paimon/table/format/FormatReadBuilder.java
index f664acaf85..60eb8e1312 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/format/FormatReadBuilder.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/format/FormatReadBuilder.java
@@ -20,6 +20,7 @@ package org.apache.paimon.table.format;
import org.apache.paimon.CoreOptions;
import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.format.FileFormat;
import org.apache.paimon.format.FileFormatDiscover;
import org.apache.paimon.format.FormatReaderContext;
import org.apache.paimon.format.FormatReaderFactory;
@@ -30,7 +31,6 @@ import org.apache.paimon.partition.PartitionUtils;
import org.apache.paimon.predicate.Predicate;
import org.apache.paimon.predicate.PredicateBuilder;
import org.apache.paimon.predicate.TopN;
-import org.apache.paimon.reader.FileRecordReader;
import org.apache.paimon.reader.RecordReader;
import org.apache.paimon.table.FormatTable;
import org.apache.paimon.table.source.ReadBuilder;
@@ -55,12 +55,10 @@ public class FormatReadBuilder implements ReadBuilder {
private static final long serialVersionUID = 1L;
- private CoreOptions options;
- private FormatTable table;
- private RowType readType;
-
- private final FileFormatDiscover formatDiscover;
+ private final FormatTable table;
+ private final FileFormat fileFormat;
+ private RowType readType;
@Nullable private Predicate filter;
@Nullable private PartitionPredicate partitionFilter;
@Nullable private Integer limit;
@@ -68,8 +66,8 @@ public class FormatReadBuilder implements ReadBuilder {
public FormatReadBuilder(FormatTable table) {
this.table = table;
this.readType = this.table.rowType();
- this.options = new CoreOptions(table.options());
- this.formatDiscover = FileFormatDiscover.of(this.options);
+ CoreOptions options = new CoreOptions(table.options());
+ this.fileFormat =
FileFormatDiscover.of(options).discover(options.formatType());
}
@Override
@@ -148,39 +146,36 @@ public class FormatReadBuilder implements ReadBuilder {
new FormatReaderContext(table.fileIO(), filePath,
dataSplit.length(), null);
FormatReaderFactory readerFactory =
- formatDiscover
- .discover(options.formatType())
- .createReaderFactory(
- table.rowType(), readType(),
PredicateBuilder.splitAnd(filter));
+ fileFormat.createReaderFactory(
+ table.rowType(), readType(),
PredicateBuilder.splitAnd(filter));
Pair<int[], RowType> partitionMapping =
PartitionUtils.getPartitionMapping(
table.partitionKeys(), readType().getFields(),
table.partitionType());
- FileRecordReader<InternalRow> fileRecordReader =
- new DataFileRecordReader(
- readType(),
- readerFactory,
- formatReaderContext,
- null,
- null,
- PartitionUtils.create(partitionMapping,
dataSplit.partition()),
- false,
- null,
- 0,
- Collections.emptyMap());
- return fileRecordReader;
+ return new DataFileRecordReader(
+ readType(),
+ readerFactory,
+ formatReaderContext,
+ null,
+ null,
+ PartitionUtils.create(partitionMapping, dataSplit.partition()),
+ false,
+ null,
+ 0,
+ Collections.emptyMap());
}
// ===================== Unsupported ===============================
+
@Override
public ReadBuilder withTopN(TopN topN) {
- throw new UnsupportedOperationException("TopN is not supported for
FormatTable.");
+ return this;
}
@Override
public ReadBuilder dropStats() {
- throw new UnsupportedOperationException("Format Table does not support
dropStats.");
+ return this;
}
@Override
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/format/FormatTableRead.java
b/paimon-core/src/main/java/org/apache/paimon/table/format/FormatTableRead.java
index 2fbe3f5629..c0610231aa 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/format/FormatTableRead.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/format/FormatTableRead.java
@@ -36,11 +36,12 @@ import java.util.concurrent.atomic.AtomicLong;
/** A {@link TableRead} implementation for {@link FormatTable}. */
public class FormatTableRead implements TableRead {
- private RowType readType;
+ private final RowType readType;
+ private final Predicate predicate;
+ private final FormatReadBuilder read;
+ private final Integer limit;
+
private boolean executeFilter = false;
- private Predicate predicate;
- private FormatReadBuilder read;
- private Integer limit;
public FormatTableRead(
RowType readType, FormatReadBuilder read, Predicate predicate,
Integer limit) {