Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
leaves12138 committed Dec 9, 2024
1 parent 8cee400 commit ee95997
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
public class DataFileRecordReader implements FileRecordReader<InternalRow> {

private final FileRecordReader<InternalRow> reader;
@Nullable private final int[] columnMapping;
@Nullable private final int[] indexMapping;
@Nullable private final PartitionInfo partitionInfo;
@Nullable private final CastFieldGetter[] castMapping;

public DataFileRecordReader(
FormatReaderFactory readerFactory,
FormatReaderFactory.Context context,
@Nullable int[] columnMapping,
@Nullable int[] indexMapping,
@Nullable CastFieldGetter[] castMapping,
@Nullable PartitionInfo partitionInfo)
throws IOException {
Expand All @@ -55,7 +55,7 @@ public DataFileRecordReader(
FileUtils.checkExists(context.fileIO(), context.filePath());
throw e;
}
this.columnMapping = columnMapping;
this.indexMapping = indexMapping;
this.partitionInfo = partitionInfo;
this.castMapping = castMapping;
}
Expand All @@ -69,16 +69,16 @@ public FileRecordIterator<InternalRow> readBatch() throws IOException {
}

if (iterator instanceof ColumnarRowIterator) {
iterator = ((ColumnarRowIterator) iterator).mapping(partitionInfo, columnMapping);
iterator = ((ColumnarRowIterator) iterator).mapping(partitionInfo, indexMapping);
} else {
if (partitionInfo != null) {
final PartitionSettedRow partitionSettedRow =
PartitionSettedRow.from(partitionInfo);
iterator = iterator.transform(partitionSettedRow::replaceRow);
}

if (columnMapping != null) {
final ProjectedRow projectedRow = ProjectedRow.from(columnMapping);
if (indexMapping != null) {
final ProjectedRow projectedRow = ProjectedRow.from(indexMapping);
iterator = iterator.transform(projectedRow::replaceRow);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private FileRecordReader<KeyValue> createRecordReader(
? new FormatReaderContext(fileIO, filePath, fileSize)
: new OrcFormatReaderContext(
fileIO, filePath, fileSize, orcPoolSize),
bulkFormatMapping.getColumnMapping(),
bulkFormatMapping.getIndexMapping(),
bulkFormatMapping.getCastMapping(),
PartitionUtils.create(bulkFormatMapping.getPartitionPair(), partition));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private FileRecordReader<InternalRow> createFileReader(
new DataFileRecordReader(
bulkFormatMapping.getReaderFactory(),
formatReaderContext,
bulkFormatMapping.getColumnMapping(),
bulkFormatMapping.getIndexMapping(),
bulkFormatMapping.getCastMapping(),
PartitionUtils.create(bulkFormatMapping.getPartitionPair(), partition));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ public class BulkFormatMapping {

// index mapping from data schema fields to table schema fields, this is used to realize paimon
// schema evolution
@Nullable private final int[] columnMapping;
@Nullable private final int[] indexMapping;
// help indexMapping to cast defferent data type
@Nullable private final CastFieldGetter[] castMapping;
// partition fields mapping, add partition fields to the read fields
@Nullable private final Pair<int[], RowType> partitionPair;
// key fields mapping, add key fields to the read fields
@Nullable private final int[] trimmedKeyMapping;
private final FormatReaderFactory bulkFormat;
private final TableSchema dataSchema;
private final List<Predicate> dataFilters;
Expand All @@ -70,11 +68,10 @@ public BulkFormatMapping(
FormatReaderFactory bulkFormat,
TableSchema dataSchema,
List<Predicate> dataFilters) {
this.columnMapping = combine(indexMapping, trimmedKeyMapping);
this.indexMapping = combine(indexMapping, trimmedKeyMapping);
this.castMapping = castMapping;
this.bulkFormat = bulkFormat;
this.partitionPair = partitionPair;
this.trimmedKeyMapping = trimmedKeyMapping;
this.dataSchema = dataSchema;
this.dataFilters = dataFilters;
}
Expand All @@ -100,8 +97,8 @@ private int[] combine(@Nullable int[] indexMapping, @Nullable int[] trimmedKeyMa
}

@Nullable
public int[] getColumnMapping() {
return columnMapping;
public int[] getIndexMapping() {
return indexMapping;
}

@Nullable
Expand All @@ -114,11 +111,6 @@ public Pair<int[], RowType> getPartitionPair() {
return partitionPair;
}

// @Nullable
// public int[] getTrimmedKeyMapping() {
// return trimmedKeyMapping;
// }
//
public FormatReaderFactory getReaderFactory() {
return bulkFormat;
}
Expand Down

0 comments on commit ee95997

Please sign in to comment.