2020
2121import org .apache .paimon .CoreOptions ;
2222import org .apache .paimon .data .InternalRow ;
23+ import org .apache .paimon .format .FileFormat ;
2324import org .apache .paimon .format .FileFormatDiscover ;
2425import org .apache .paimon .format .FormatReaderContext ;
2526import org .apache .paimon .format .FormatReaderFactory ;
3031import org .apache .paimon .predicate .Predicate ;
3132import org .apache .paimon .predicate .PredicateBuilder ;
3233import org .apache .paimon .predicate .TopN ;
33- import org .apache .paimon .reader .FileRecordReader ;
3434import org .apache .paimon .reader .RecordReader ;
3535import org .apache .paimon .table .FormatTable ;
3636import 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
0 commit comments