Skip to content

Conversation

@albertbolt1
Copy link
Contributor

@albertbolt1 albertbolt1 commented Jan 4, 2026

Which Issue(s) This PR Fixes(Closes)

Fixes #5410
Fixes #5411

Brief Description

Added Op and Operand by converting from java to rust and placed them in filter

How Did You Test This Change?

wrote unit tests for them

Summary by CodeRabbit

  • New Features

    • Added operator and operand abstractions to the filtering system for clearer, reusable filter operations and improved extensibility.
  • Tests

    • Added unit tests covering operator/operand creation, symbol access, cloning, and edge cases to ensure correctness.
  • Chores

    • Updated public exports to expose the new operator/operand modules and removed the previous filter_type export.

✏️ Tip: You can customize this high-level summary in your review settings.

@rocketmq-rust-robot rocketmq-rust-robot added Difficulty level/Moderate Moderate difficult ISSUE feature🚀 Suggest an idea for this project. labels Jan 4, 2026
@rocketmq-rust-bot
Copy link
Collaborator

🔊@albertbolt1 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Walkthrough

Removed filter_type export and added two new public submodules: op (introduces Op trait and OpBase) and operand (introduces Operand that wraps OpBase and implements Op). Both modules include unit tests and are re-exported from the filter root.

Changes

Cohort / File(s) Summary
Module exports
rocketmq-common/src/common/filter.rs
Removed pub mod filter_type;. Added pub mod op; and pub mod operand; to expose new submodules.
Operator trait & base type
rocketmq-common/src/common/filter/op.rs
Added pub trait Op { fn symbol(&self) -> &str; }, pub struct OpBase { symbol: String }, constructor OpBase::new(...), accessor OpBase::symbol(), and unit test.
Operand wrapper
rocketmq-common/src/common/filter/operand.rs
Added #[derive(Debug, Clone)] pub struct Operand { op: OpBase }, pub fn new(symbol: &str) -> Self, impl Op for Operand delegating symbol(), and unit tests (multiple symbols, empty string, clone).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hop through code with joyful cheer,
New Op and Operand have sprung near,
Symbols tucked in a tiny nest,
Tests hum softly — they pass the quest,
A rabbit twitches whiskers — code at rest.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat-5410: add op and operand in filter' accurately describes the main changes: adding Op and Operand modules to the filter module.
Linked Issues check ✅ Passed The PR successfully implements both linked issues: #5410 (Op conversion) and #5411 (Operand conversion) with proper Rust implementations in rocketmq-common/filter.
Out of Scope Changes check ✅ Passed All changes are in-scope: removing filter_type export and adding op and operand modules, with unit tests for validation. No unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be395d7 and 3558b53.

📒 Files selected for processing (1)
  • rocketmq-common/src/common/filter/operand.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • rocketmq-common/src/common/filter/operand.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: auto-approve

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
rocketmq-common/src/common/filter/operand.rs (1)

10-12: Rename parameter from name to symbol for consistency.

The parameter should be named symbol rather than name to align with the OpBase API and the domain concept.

🔎 Proposed fix
-    pub fn new(name: &str) -> Self {
-        Self { op: OpBase::new(name) }
+    pub fn new(symbol: &str) -> Self {
+        Self { op: OpBase::new(symbol) }
     }
rocketmq-common/src/common/filter/op.rs (1)

18-30: Consider implementing Op trait for OpBase.

OpBase has the same interface as the Op trait (a symbol() method) but doesn't implement the trait. This creates inconsistency and limits composability. If OpBase is meant to be used as an operator, it should implement Op directly.

🔎 Proposed implementation
 impl OpBase {
     pub fn new(symbol: impl Into<String>) -> Self {
         Self { symbol: symbol.into() }
     }
     pub fn symbol(&self) -> &str {
         &self.symbol
     }
 }
+
+impl Op for OpBase {
+    fn symbol(&self) -> &str {
+        &self.symbol
+    }
+}

This would allow OpBase to be used directly where an Op is expected, and Operand could still delegate to it through the trait.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b12f7a6 and 599ea90.

📒 Files selected for processing (3)
  • rocketmq-common/src/common/filter.rs
  • rocketmq-common/src/common/filter/op.rs
  • rocketmq-common/src/common/filter/operand.rs
🧰 Additional context used
🧬 Code graph analysis (2)
rocketmq-common/src/common/filter/op.rs (2)
rocketmq-common/src/common/filter/operand.rs (2)
  • symbol (16-18)
  • new (10-12)
rocketmq-common/src/utils/parse_config_file.rs (1)
  • cfg (30-30)
rocketmq-common/src/common/filter/operand.rs (2)
rocketmq-common/src/common/filter/op.rs (3)
  • new (24-26)
  • symbol (15-15)
  • symbol (27-29)
rocketmq-common/src/utils/parse_config_file.rs (1)
  • cfg (30-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Code Coverage
  • GitHub Check: Build & Test (ubuntu-latest)
  • GitHub Check: Build & Test (windows-latest)
  • GitHub Check: auto-approve
🔇 Additional comments (6)
rocketmq-common/src/common/filter.rs (1)

17-18: LGTM! Module declarations follow existing patterns.

The new module declarations are consistent with the existing filter submodules and properly expose the Op and Operand types.

rocketmq-common/src/common/filter/operand.rs (3)

1-2: LGTM! Imports are correct.


4-19: Clarify the semantic relationship between Operand and Op.

In typical expression parsing systems, operands (values/variables) and operators (+, -, *, etc.) are distinct concepts. Having Operand implement the Op trait seems semantically backwards.

If this design is preserved from the Java implementation for compatibility, consider adding documentation to explain why operands are treated as operators in this context.

Is this design intentional from the Java port, or should operands and operators have separate trait hierarchies?


21-31: LGTM! Basic test coverage is adequate.

The unit test correctly verifies the construction and symbol retrieval functionality.

rocketmq-common/src/common/filter/op.rs (2)

14-16: LGTM! Trait design is sound.

The Send + Sync bounds are appropriate for concurrent usage in RocketMQ, and the trait interface is clean and focused.


1-13: LGTM! License header is correct.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed ✅

@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.05%. Comparing base (7efc0cf) to head (3558b53).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5442      +/-   ##
==========================================
+ Coverage   37.83%   38.05%   +0.22%     
==========================================
  Files         811      813       +2     
  Lines      109903   110079     +176     
==========================================
+ Hits        41585    41896     +311     
+ Misses      68318    68183     -135     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed ✅

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albertbolt1 please fix ci error

@rocketmq-rust-bot rocketmq-rust-bot self-requested a review January 4, 2026 15:21
albertbolt and others added 6 commits January 4, 2026 20:53
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
rocketmq-common/src/common/filter/operand.rs (4)

14-15: Consider consolidating imports from the same module.

The two imports from crate::common::filter::op can be combined into a single use statement for better readability.

🔎 Proposed consolidation
-use crate::common::filter::op::Op;
-use crate::common::filter::op::OpBase;
+use crate::common::filter::op::{Op, OpBase};

22-28: Add documentation for the public constructor.

Public API methods should include doc comments explaining their purpose, parameters, and usage examples.

🔎 Suggested documentation
 impl Operand {
+    /// Creates a new `Operand` with the given symbol.
+    ///
+    /// # Arguments
+    ///
+    /// * `symbol` - The operator symbol (e.g., "+", "-", "*")
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use rocketmq_common::common::filter::operand::Operand;
+    /// let operand = Operand::new("+");
+    /// ```
     pub fn new(symbol: &str) -> Self {
         Self {
             op: OpBase::new(symbol),
         }
     }
 }

36-46: Consider expanding test coverage.

The basic test validates core functionality, which is good. However, consider adding test cases for edge cases and different symbol types to improve confidence in the implementation.

🔎 Suggested additional tests
#[test]
fn create_operand_with_different_symbols() {
    let symbols = vec!["+", "-", "*", "/", "==", "!=", ">", "<"];
    for sym in symbols {
        let operand = Operand::new(sym);
        assert_eq!(operand.symbol(), sym);
    }
}

#[test]
fn create_operand_with_empty_string() {
    let operand = Operand::new("");
    assert_eq!(operand.symbol(), "");
}

#[test]
fn operand_clone_works() {
    let operand = Operand::new("+");
    let cloned = operand.clone();
    assert_eq!(cloned.symbol(), "+");
}

17-20: Consider removing the unnecessary OpBase wrapper in Operand.

Operand wraps OpBase, which wraps a String. Since OpBase is only used by Operand and provides no additional behavior beyond storing and accessing a symbol string, Operand can directly contain the String field. This would simplify the struct and eliminate one layer of indirection.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69e2dda and be395d7.

📒 Files selected for processing (3)
  • rocketmq-common/src/common/filter.rs
  • rocketmq-common/src/common/filter/op.rs
  • rocketmq-common/src/common/filter/operand.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • rocketmq-common/src/common/filter/op.rs
🧰 Additional context used
🧬 Code graph analysis (1)
rocketmq-common/src/common/filter/operand.rs (1)
rocketmq-common/src/common/filter/op.rs (3)
  • new (24-26)
  • symbol (15-15)
  • symbol (27-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: auto-approve
🔇 Additional comments (2)
rocketmq-common/src/common/filter/operand.rs (1)

30-34: LGTM!

The Op trait implementation correctly delegates to the inner OpBase, following the expected delegation pattern.

rocketmq-common/src/common/filter.rs (1)

17-18: No action needed – module changes are correct.

The addition of pub mod op; and pub mod operand; is correct, and the filter_type module remains available for internal use. No code in the codebase imports filter_type as a public module, so unexporting it does not cause any breakage.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed ✅

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed ✅

@mxsm mxsm merged commit ad0c1f1 into mxsm:main Jan 5, 2026
10 of 13 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI review first Ai review pr first approved PR has approved auto merge Difficulty level/Moderate Moderate difficult ISSUE feature🚀 Suggest an idea for this project.

Projects

None yet

4 participants