xiaokang commented on code in PR #27717: URL: https://github.com/apache/doris/pull/27717#discussion_r1407750798
########## fe/fe-core/src/main/java/org/apache/doris/analysis/ArrayLiteral.java: ########## @@ -134,6 +134,33 @@ protected void toThrift(TExprNode msg) { msg.setChildType(((ArrayType) type).getItemType().getPrimitiveType().toThrift()); } + @Override + public int hashCode() { + int code = 31 * super.hashCode(); + for (Expr c : children) { + code = code + c.hashCode(); + } + return code; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ArrayLiteral)) { + return false; + } + if (this == o) { + return true; + } + + ArrayLiteral that = (ArrayLiteral) o; + for (int i = 0; i < children.size(); i++) { Review Comment: check children.size() equal first to avoid index out of bound ########## fe/fe-core/src/main/java/org/apache/doris/analysis/ArrayLiteral.java: ########## @@ -134,6 +134,33 @@ protected void toThrift(TExprNode msg) { msg.setChildType(((ArrayType) type).getItemType().getPrimitiveType().toThrift()); } + @Override + public int hashCode() { + int code = 31 * super.hashCode(); + for (Expr c : children) { + code = code + c.hashCode(); + } + return code; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof ArrayLiteral)) { Review Comment: return false if o == null ########## fe/fe-core/src/main/java/org/apache/doris/analysis/MapLiteral.java: ########## @@ -218,4 +218,31 @@ public void write(DataOutput out) throws IOException { Expr.writeTo(e, out); } } + + @Override + public int hashCode() { + int code = 31 * super.hashCode(); + for (Expr c : children) { + code = code + c.hashCode(); + } + return code; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof MapLiteral)) { Review Comment: return false if o == null ########## fe/fe-core/src/main/java/org/apache/doris/analysis/MapLiteral.java: ########## @@ -218,4 +218,31 @@ public void write(DataOutput out) throws IOException { Expr.writeTo(e, out); } } + + @Override + public int hashCode() { + int code = 31 * super.hashCode(); + for (Expr c : children) { + code = code + c.hashCode(); + } + return code; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof MapLiteral)) { + return false; + } + if (this == o) { + return true; + } + + MapLiteral that = (MapLiteral) o; + for (int i = 0; i < children.size(); i++) { Review Comment: check children.size() equal first to avoid index out of bound ########## fe/fe-core/src/main/java/org/apache/doris/analysis/StructLiteral.java: ########## @@ -164,4 +164,30 @@ public void checkValueValid() throws AnalysisException { e.checkValueValid(); } } + + public int hashCode() { + int code = 31 * super.hashCode(); + for (Expr c : children) { + code = code + c.hashCode(); + } + return code; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof StructLiteral)) { + return false; + } + if (this == o) { + return true; + } + + StructLiteral that = (StructLiteral) o; + for (int i = 0; i < children.size(); i++) { Review Comment: check children.size() equal first to avoid index out of bound ########## fe/fe-core/src/main/java/org/apache/doris/analysis/StructLiteral.java: ########## @@ -164,4 +164,30 @@ public void checkValueValid() throws AnalysisException { e.checkValueValid(); } } + + public int hashCode() { + int code = 31 * super.hashCode(); + for (Expr c : children) { + code = code + c.hashCode(); + } + return code; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof StructLiteral)) { Review Comment: return false if o == 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org