diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java index 54227a3875a4bac..a362fb5f2db3e06 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java @@ -28,12 +28,14 @@ import org.apache.doris.thrift.TQueryOptions; import com.google.common.base.Preconditions; +import com.google.common.collect.Maps; import com.google.protobuf.ByteString; import org.apache.thrift.TException; import org.apache.thrift.TSerializer; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; @@ -56,19 +58,16 @@ public class ShortCircuitQueryContext { public final Queriable analzyedQuery; // Serialized mysql Field, this could avoid serialize mysql field each time sendFields. // Since, serialize fields is too heavy when table is wide - List serializedFields = new ArrayList(); + Map serializedFields = Maps.newHashMap(); List returnTypes = null; public byte[] getSerializedField(int idx) { - if (idx < serializedFields.size()) { - return serializedFields.get(idx); - } - return null; + return serializedFields.getOrDefault(idx, null); } - public void addSerializedField(byte[] serializedField) { - serializedFields.add(serializedField); + public void addSerializedField(int idx, byte[] serializedField) { + serializedFields.put(idx, serializedField); } List getReturnTypes() { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index 4a778a7afa3299c..68e2b62fa69665c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -2871,7 +2871,7 @@ private void sendFields(List colNames, List fieldInfos, List< serializer.writeField(colNames.get(i), types.get(i)); } serializedField = serializer.toArray(); - ctx.addSerializedField(serializedField); + ctx.addSerializedField(i, serializedField); } context.getMysqlChannel().sendOnePacket(ByteBuffer.wrap(serializedField)); } else {