split huge header file#990
Conversation
|
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
Reviewer's GuideRefactor expression parsing by extracting the AST entry point and helper routines into a dedicated argparse module, slimming down the visitor header and updating downstream includes and build configuration. Class diagram for refactored expression parsing (argparse split)classDiagram
class FCExpressionVisitor {
+FCExpressionVisitor(AttrTypeSchema* schema)
+visitFilter_condition(FCParser::Filter_conditionContext* ctx)
+visitParenExpr(FCParser::ParenExprContext* ctx)
+visitNotExpr(FCParser::NotExprContext* ctx)
+visitLogicalExpr(FCParser::LogicalExprContext* ctx)
+visitCompExpr(FCParser::CompExprContext* ctx)
+visitIntPipeListExpr(FCParser::IntPipeListExprContext* ctx)
+visitStrPipeListExpr(FCParser::StrPipeListExprContext* ctx)
+visitIntListExpr(FCParser::IntListExprContext* ctx)
+visitStrListExpr(FCParser::StrListExprContext* ctx)
+visitNumericComparison(FCParser::NumericComparisonContext* ctx)
+visitStringComparison(FCParser::StringComparisonContext* ctx)
+visitParenFieldExpr(FCParser::ParenFieldExprContext* ctx)
+visitFieldRef(FCParser::FieldRefContext* ctx)
+visitArithmeticExpr(FCParser::ArithmeticExprContext* ctx)
+visitNumericConst(FCParser::NumericConstContext* ctx)
+visitStr_value_list(FCParser::Str_value_listContext* ctx)
+visitInt_value_list(FCParser::Int_value_listContext* ctx)
+visitInt_value_list(FCParser::Int_value_listContext* ctx, const bool is_string_type)
+visitInt_pipe_list(FCParser::Int_pipe_listContext* ctx)
+visitInt_pipe_list(FCParser::Int_pipe_listContext* ctx, const bool is_string_type)
+visitStr_pipe_list(FCParser::Str_pipe_listContext* ctx)
+visitField_name(FCParser::Field_nameContext* ctx)
+visitNumeric(FCParser::NumericContext* ctx)
-StrViewSplit(std::string_view str, char delim)
-IsStringType(const ExprPtr& expr)
-AttrTypeSchema* schema_
}
class argparse {
+AstParse(const std::string& filter_condition_str, AttrTypeSchema* schema = nullptr)
}
argparse ..> FCExpressionVisitor : uses
FCExpressionVisitor ..> AttrTypeSchema
FCExpressionVisitor ..> FCParser
FCExpressionVisitor ..> ExprPtr
argparse ..> AttrTypeSchema
argparse ..> ExprPtr
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @LHT129 - I've reviewed your changes - here's some feedback:
- Prefer putting internal helper functions into an anonymous namespace instead of using static at global scope in the .cpp to better encapsulate them.
- Consider renaming argparse.{cpp,h} to something more domain-specific (e.g. filter_parser) to avoid confusion with common ‘argparse’ naming and clarify its responsibility.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Prefer putting internal helper functions into an anonymous namespace instead of using static at global scope in the .cpp to better encapsulate them.
- Consider renaming argparse.{cpp,h} to something more domain-specific (e.g. filter_parser) to avoid confusion with common ‘argparse’ naming and clarify its responsibility.
## Individual Comments
### Comment 1
<location> `src/attr/expression_visitor.cpp:35` </location>
<code_context>
+ parser.addErrorListener(&error_listener);
+ FCExpressionVisitor visitor(schema);
+ auto expr_ptr = std::any_cast<ExprPtr>(visitor.visit(parser.filter_condition()));
+ return std::move(expr_ptr);
+}
+} // namespace vsag
</code_context>
<issue_to_address>
Unnecessary use of std::move on local variable being returned.
Return expr_ptr directly to allow the compiler to apply RVO.
</issue_to_address>
### Comment 2
<location> `src/attr/expression_visitor.cpp:395` </location>
<code_context>
+ end = str.find(delim, start);
+ }
+ result.emplace_back(str.substr(start));
+ return std::move(result);
+}
+
</code_context>
<issue_to_address>
Unnecessary use of std::move on local variable return.
Return 'result' directly to allow copy elision and avoid unnecessary std::move.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
result.emplace_back(str.substr(start));
return std::move(result);
}
=======
result.emplace_back(str.substr(start));
return result;
}
>>>>>>> REPLACE
</suggested_fix>
### Comment 3
<location> `src/attr/expression_visitor.cpp:400` </location>
<code_context>
+
+bool
+FCExpressionVisitor::IsStringType(const ExprPtr& expr) {
+ if (auto field_expr = std::dynamic_pointer_cast<FieldExpression>(expr); field_expr != nullptr) {
+ return schema_->GetTypeOfField(field_expr->fieldName) == STRING;
+ }
</code_context>
<issue_to_address>
No null check for schema_ before dereferencing.
If schema_ can be null, dereferencing it here may cause undefined behavior. Please add a null check or assertion.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #990 +/- ##
==========================================
+ Coverage 91.39% 91.62% +0.23%
==========================================
Files 294 294
Lines 16974 17011 +37
==========================================
+ Hits 15513 15586 +73
+ Misses 1461 1425 -36
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
1 similar comment
|
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
|
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
|
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
Signed-off-by: LHT129 <tianlan.lht@antgroup.com> Signed-off-by: Sia Sheerland <x1075956441x@163.com> Signed-off-by: Sia Sheerland <x1075956441x@163.com>
Summary by Sourcery
Split the bulky expression visitor header by extracting the AST parsing entrypoint and helper logic into a dedicated argparse module, clean up the visitor header, and update build configuration and includes accordingly
New Features:
Enhancements:
Build: