|
11 | 11 | import org.elasticsearch.common.lucene.BytesRefs; |
12 | 12 | import org.elasticsearch.common.settings.Settings; |
13 | 13 | import org.elasticsearch.common.util.BigArrays; |
| 14 | +import org.elasticsearch.common.util.Maps; |
14 | 15 | import org.elasticsearch.compute.Describable; |
15 | 16 | import org.elasticsearch.compute.aggregation.AggregatorMode; |
16 | 17 | import org.elasticsearch.compute.data.Block; |
|
117 | 118 | import org.elasticsearch.xpack.esql.session.Configuration; |
118 | 119 |
|
119 | 120 | import java.util.ArrayList; |
120 | | -import java.util.HashMap; |
121 | | -import java.util.HashSet; |
122 | | -import java.util.LinkedHashMap; |
123 | 121 | import java.util.List; |
124 | 122 | import java.util.Map; |
125 | 123 | import java.util.Objects; |
@@ -501,8 +499,8 @@ private PhysicalOperation planGrok(GrokExec grok, LocalExecutionPlannerContext c |
501 | 499 | Layout.Builder layoutBuilder = source.layout.builder(); |
502 | 500 | List<Attribute> extractedFields = grok.extractedFields(); |
503 | 501 | layoutBuilder.append(extractedFields); |
504 | | - Map<String, Integer> fieldToPos = new HashMap<>(extractedFields.size()); |
505 | | - Map<String, ElementType> fieldToType = new HashMap<>(extractedFields.size()); |
| 502 | + Map<String, Integer> fieldToPos = Maps.newHashMapWithExpectedSize(extractedFields.size()); |
| 503 | + Map<String, ElementType> fieldToType = Maps.newHashMapWithExpectedSize(extractedFields.size()); |
506 | 504 | ElementType[] types = new ElementType[extractedFields.size()]; |
507 | 505 | List<Attribute> extractedFieldsFromPattern = grok.pattern().extractedFields(); |
508 | 506 | for (int i = 0; i < extractedFields.size(); i++) { |
@@ -559,7 +557,8 @@ private PhysicalOperation planEnrich(EnrichExec enrich, LocalExecutionPlannerCon |
559 | 557 | private PhysicalOperation planRerank(RerankExec rerank, LocalExecutionPlannerContext context) { |
560 | 558 | PhysicalOperation source = plan(rerank.child(), context); |
561 | 559 |
|
562 | | - Map<ColumnInfoImpl, EvalOperator.ExpressionEvaluator.Factory> rerankFieldsEvaluatorSuppliers = new LinkedHashMap<>(); |
| 560 | + Map<ColumnInfoImpl, EvalOperator.ExpressionEvaluator.Factory> rerankFieldsEvaluatorSuppliers = Maps |
| 561 | + .newLinkedHashMapWithExpectedSize(rerank.rerankFields().size()); |
563 | 562 |
|
564 | 563 | for (var rerankField : rerank.rerankFields()) { |
565 | 564 | rerankFieldsEvaluatorSuppliers.put( |
@@ -734,31 +733,13 @@ private PhysicalOperation planProject(ProjectExec project, LocalExecutionPlanner |
734 | 733 | List<Integer> projectionList = new ArrayList<>(projections.size()); |
735 | 734 |
|
736 | 735 | Layout.Builder layout = new Layout.Builder(); |
737 | | - Map<Integer, Layout.ChannelSet> inputChannelToOutputIds = new HashMap<>(); |
738 | | - for (int index = 0, size = projections.size(); index < size; index++) { |
739 | | - NamedExpression ne = projections.get(index); |
740 | | - |
741 | | - NameId inputId = null; |
742 | | - if (ne instanceof Alias a) { |
743 | | - inputId = ((NamedExpression) a.child()).id(); |
744 | | - } else { |
745 | | - inputId = ne.id(); |
746 | | - } |
| 736 | + for (NamedExpression ne : projections) { |
| 737 | + NameId inputId = ne instanceof Alias a ? ((NamedExpression) a.child()).id() : ne.id(); |
747 | 738 | Layout.ChannelAndType input = source.layout.get(inputId); |
748 | 739 | if (input == null) { |
749 | 740 | throw new IllegalStateException("can't find input for [" + ne + "]"); |
750 | 741 | } |
751 | | - Layout.ChannelSet channelSet = inputChannelToOutputIds.get(input.channel()); |
752 | | - if (channelSet == null) { |
753 | | - channelSet = new Layout.ChannelSet(new HashSet<>(), input.type()); |
754 | | - channelSet.nameIds().add(ne.id()); |
755 | | - layout.append(channelSet); |
756 | | - } else { |
757 | | - channelSet.nameIds().add(ne.id()); |
758 | | - } |
759 | | - if (channelSet.type() != input.type()) { |
760 | | - throw new IllegalArgumentException("type mismatch for aliases"); |
761 | | - } |
| 742 | + layout.append(ne); |
762 | 743 | projectionList.add(input.channel()); |
763 | 744 | } |
764 | 745 |
|
|
0 commit comments