You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "xiaokang (via GitHub)" <gi...@apache.org> on 2023/03/23 03:37:02 UTC
[GitHub] [doris] xiaokang commented on a diff in pull request #18000: [Improve](point query) optimize sendFields since `writeField` is heav…
xiaokang commented on code in PR #18000:
URL: https://github.com/apache/doris/pull/18000#discussion_r1145634491
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/PrepareStmt.java:
##########
@@ -26,12 +26,14 @@
import org.apache.doris.thrift.TExprList;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
import com.google.protobuf.ByteString;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TException;
import org.apache.thrift.TSerializer;
+// import java.nio.ByteBuffer;
Review Comment:
useless code
##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -1829,13 +1833,27 @@ private void sendFields(List<String> colNames, List<PrimitiveType> types) throws
// sends how many columns
serializer.reset();
serializer.writeVInt(colNames.size());
- LOG.debug("sendFields {}", colNames.size());
+ LOG.debug("sendFields {}", colNames);
context.getMysqlChannel().sendOnePacket(serializer.toByteBuffer());
// send field one by one
for (int i = 0; i < colNames.size(); ++i) {
serializer.reset();
- serializer.writeField(colNames.get(i), types.get(i));
- context.getMysqlChannel().sendOnePacket(serializer.toByteBuffer());
+ if (prepareStmt != null && isExecuteStmt) {
+ // Using PreparedStatment pre serializedField to avoid serialize each time
+ // we send a field
+ byte[] serializedField = prepareStmt.getSerializedField(colNames.get(i));
+ if (serializedField != null) {
Review Comment:
duplicate sendOnePacket code can be replace as follows:
```
byte[] serializedField = prepareStmt.getSerializedField(colNames.get(i));
if (serializedField == null) {
serializer.writeField(colNames.get(i), types.get(i));
serializedField = serializer.toArray();
prepareStmt.setSerializedField(colNames.get(i), serializedField);
}
context.getMysqlChannel().sendOnePacket(ByteBuffer.wrap(serializedField));
```
##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -200,8 +200,10 @@ public class StmtExecutor implements ProfileWriter {
private boolean isCached;
private QueryPlannerProfile plannerProfile = new QueryPlannerProfile();
private String stmtName;
- private PrepareStmt prepareStmt;
+ private PrepareStmt prepareStmt = null;
Review Comment:
java object default value is null
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org