Skip to content

Fix None issue in reorganizer queue#125

Merged
CaralHsi merged 2 commits intoMemTensor:devfrom
J1awei-Yang:fix/reorganizer_queue
Jul 19, 2025
Merged

Fix None issue in reorganizer queue#125
CaralHsi merged 2 commits intoMemTensor:devfrom
J1awei-Yang:fix/reorganizer_queue

Conversation

@J1awei-Yang
Copy link
Collaborator

Description

Summary: (summary)
fix the None type in minheap of reorganizer.

Reviewer: @CaralHsi

Checklist:

  • I have performed a self-review of my own code | 我已自行检查了自己的代码
  • I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释
  • I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常
  • I have added necessary documentation (if applicable) | 我已添加必要的文档(如果适用)
  • I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用)
  • I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人

Copilot AI review requested due to automatic review settings July 18, 2025 08:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a None-handling issue in the reorganizer queue by replacing the use of None as a sentinel value with a proper "end" operation type. The change improves type safety and makes the queue termination mechanism more explicit.

  • Introduces a new "end" operation type to the QueueMessage class
  • Replaces None sentinel value with QueueMessage(op="end") for queue termination
  • Improves null safety in message preprocessing by adding additional None checks

import time
import traceback

from collections import Counter, defaultdict
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

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

The import statement for 'collections' has been moved to the top but the old import on line 9 wasn't removed, creating a duplicate import. Remove the duplicate import statement.

Copilot uses AI. Check for mistakes.

def __lt__(self, other: "QueueMessage") -> bool:
op_priority = {"add": 2, "remove": 2, "merge": 1}
op_priority = {"add": 2, "remove": 2, "merge": 1, "end": 0}
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

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

The op_priority dictionary is missing the 'update' operation which is defined in the Literal type. This will cause a KeyError when comparing QueueMessage objects with op='update'.

Suggested change
op_priority = {"add": 2, "remove": 2, "merge": 1, "end": 0}
op_priority = {"add": 2, "remove": 2, "merge": 1, "update": 1, "end": 0}

Copilot uses AI. Check for mistakes.
@CaralHsi CaralHsi merged commit f00483a into MemTensor:dev Jul 19, 2025
20 checks passed
tianxing02 pushed a commit to tianxing02/MemOS that referenced this pull request Feb 24, 2026
fix: revise None type in QueueMessage to op=end

Co-authored-by: CaralHsi <caralhsi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants