Skip to content

Commit fe7f16e

Browse files
committed
[hotfix] Minor refactor FormatReadBuilder
1 parent 7d2833d commit fe7f16e

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

paimon-core/src/main/java/org/apache/paimon/table/format/FormatReadBuilder.java

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.apache.paimon.CoreOptions;
2222
import org.apache.paimon.data.InternalRow;
23+
import org.apache.paimon.format.FileFormat;
2324
import org.apache.paimon.format.FileFormatDiscover;
2425
import org.apache.paimon.format.FormatReaderContext;
2526
import org.apache.paimon.format.FormatReaderFactory;
@@ -30,7 +31,6 @@
3031
import org.apache.paimon.predicate.Predicate;
3132
import org.apache.paimon.predicate.PredicateBuilder;
3233
import org.apache.paimon.predicate.TopN;
33-
import org.apache.paimon.reader.FileRecordReader;
3434
import org.apache.paimon.reader.RecordReader;
3535
import org.apache.paimon.table.FormatTable;
3636
import org.apache.paimon.table.source.ReadBuilder;
@@ -55,21 +55,19 @@ public class FormatReadBuilder implements ReadBuilder {
5555

5656
private static final long serialVersionUID = 1L;
5757

58-
private CoreOptions options;
59-
private FormatTable table;
60-
private RowType readType;
61-
62-
private final FileFormatDiscover formatDiscover;
58+
private final FormatTable table;
59+
private final FileFormat fileFormat;
6360

61+
private RowType readType;
6462
@Nullable private Predicate filter;
6563
@Nullable private PartitionPredicate partitionFilter;
6664
@Nullable private Integer limit;
6765

6866
public FormatReadBuilder(FormatTable table) {
6967
this.table = table;
7068
this.readType = this.table.rowType();
71-
this.options = new CoreOptions(table.options());
72-
this.formatDiscover = FileFormatDiscover.of(this.options);
69+
CoreOptions options = new CoreOptions(table.options());
70+
this.fileFormat = FileFormatDiscover.of(options).discover(options.formatType());
7371
}
7472

7573
@Override
@@ -148,39 +146,36 @@ protected RecordReader<InternalRow> createReader(FormatDataSplit dataSplit) thro
148146
new FormatReaderContext(table.fileIO(), filePath, dataSplit.length(), null);
149147

150148
FormatReaderFactory readerFactory =
151-
formatDiscover
152-
.discover(options.formatType())
153-
.createReaderFactory(
154-
table.rowType(), readType(), PredicateBuilder.splitAnd(filter));
149+
fileFormat.createReaderFactory(
150+
table.rowType(), readType(), PredicateBuilder.splitAnd(filter));
155151

156152
Pair<int[], RowType> partitionMapping =
157153
PartitionUtils.getPartitionMapping(
158154
table.partitionKeys(), readType().getFields(), table.partitionType());
159155

160-
FileRecordReader<InternalRow> fileRecordReader =
161-
new DataFileRecordReader(
162-
readType(),
163-
readerFactory,
164-
formatReaderContext,
165-
null,
166-
null,
167-
PartitionUtils.create(partitionMapping, dataSplit.partition()),
168-
false,
169-
null,
170-
0,
171-
Collections.emptyMap());
172-
return fileRecordReader;
156+
return new DataFileRecordReader(
157+
readType(),
158+
readerFactory,
159+
formatReaderContext,
160+
null,
161+
null,
162+
PartitionUtils.create(partitionMapping, dataSplit.partition()),
163+
false,
164+
null,
165+
0,
166+
Collections.emptyMap());
173167
}
174168

175169
// ===================== Unsupported ===============================
170+
176171
@Override
177172
public ReadBuilder withTopN(TopN topN) {
178-
throw new UnsupportedOperationException("TopN is not supported for FormatTable.");
173+
return this;
179174
}
180175

181176
@Override
182177
public ReadBuilder dropStats() {
183-
throw new UnsupportedOperationException("Format Table does not support dropStats.");
178+
return this;
184179
}
185180

186181
@Override

paimon-core/src/main/java/org/apache/paimon/table/format/FormatTableRead.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@
3636
/** A {@link TableRead} implementation for {@link FormatTable}. */
3737
public class FormatTableRead implements TableRead {
3838

39-
private RowType readType;
39+
private final RowType readType;
40+
private final Predicate predicate;
41+
private final FormatReadBuilder read;
42+
private final Integer limit;
43+
4044
private boolean executeFilter = false;
41-
private Predicate predicate;
42-
private FormatReadBuilder read;
43-
private Integer limit;
4445

4546
public FormatTableRead(
4647
RowType readType, FormatReadBuilder read, Predicate predicate, Integer limit) {

0 commit comments

Comments
 (0)