This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 0e458a3127f branch-4.0: [opt](fe) opt the performance for
setColumnPositionMapping #60003 (#60037)
0e458a3127f is described below
commit 0e458a3127f38ecfd3629364650543c526e66e02
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jan 20 15:34:15 2026 +0800
branch-4.0: [opt](fe) opt the performance for setColumnPositionMapping
#60003 (#60037)
Cherry-picked from #60003
Co-authored-by: camby <[email protected]>
---
.../apache/doris/datasource/FileQueryScanNode.java | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/FileQueryScanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/FileQueryScanNode.java
index 38e59bf9150..15b3121d067 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/FileQueryScanNode.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/FileQueryScanNode.java
@@ -69,6 +69,7 @@ import org.apache.logging.log4j.Logger;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -215,6 +216,14 @@ public abstract class FileQueryScanNode extends
FileScanNode {
params.setColumnIdxs(columnIdxs);
return;
}
+
+ // Pre-index columns into a Map for O(1) lookup
+ List<Column> columns = getColumns();
+ Map<String, Integer> columnNameMap = new HashMap<>(columns.size());
+ for (int i = 0; i < columns.size(); i++) {
+ columnNameMap.putIfAbsent(columns.get(i).getName(), i);
+ }
+
for (TFileScanSlotInfo slot : params.getRequiredSlots()) {
if (!slot.isIsFileSlot()) {
continue;
@@ -225,15 +234,8 @@ public abstract class FileQueryScanNode extends
FileScanNode {
continue;
}
- int idx = -1;
- List<Column> columns = getColumns();
- for (int i = 0; i < columns.size(); i++) {
- if (columns.get(i).getName().equals(colName)) {
- idx = i;
- break;
- }
- }
- if (idx == -1) {
+ Integer idx = columnNameMap.get(colName);
+ if (idx == null) {
throw new UserException("Column " + colName + " not found in
table " + tbl.getName());
}
columnIdxs.add(idx);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]