Skip to content

Remove redundant sort in btree_to_label_selector (DSK-127)#168

Merged
daisuke8000 merged 1 commit into
mainfrom
fix/dsk-127-btree-label-selector
Jul 5, 2026
Merged

Remove redundant sort in btree_to_label_selector (DSK-127)#168
daisuke8000 merged 1 commit into
mainfrom
fix/dsk-127-btree-label-selector

Conversation

@daisuke8000

@daisuke8000 daisuke8000 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Drop redundant sort_by in btree_to_label_selector; iterate the BTreeMap in key order directly.

Test plan

  • cargo test -p rustern-core --lib discovery::workload_selector
  • Local CodeRabbit review (0 findings)

Made with Cursor

Summary by CodeRabbit

  • Refactor
    • ラベルセレクタ文字列の生成処理を整理し、キーの並びを標準の順序に委ねるようになりました。
  • Bug Fixes
    • 一貫した順序でラベルセレクタが出力されるようになり、結果の安定性が向上しました。

BTreeMap iteration is already key-ordered; join pairs directly without collecting and re-sorting.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fcd8da67-3ced-4cc1-97d1-b122097ac8aa

📥 Commits

Reviewing files that changed from the base of the PR and between 14552b2 and df79f26.

📒 Files selected for processing (1)
  • crates/rustern-core/src/discovery/workload_selector.rs

📝 Walkthrough

Walkthrough

btree_to_label_selector 関数において、BTreeMap の要素を一旦ベクタに収集してキーでソートしていた処理を削除し、m.iter() を直接使用してラベルセレクタ文字列を生成するように変更されました。BTreeMap 自体がキーのレキシコグラフィック順でイテレートされる仕様のため、明示的なソート処理は不要と判断された変更です。関連テストの期待値に変更はありません。

Changes

ファイル 変更内容
crates/rustern-core/src/discovery/workload_selector.rs btree_to_label_selector 内の collect→sort_by 処理を除去し、m.iter() を直接利用する形に変更(+1/-4)

重大度: 低。BTreeMap はキー順でイテレートすることが標準ライブラリの仕様として保証されているため、動作は変わらない。正しさ・セキュリティ・K8s関連への影響なし。

Sequence Diagram(s)

該当なし(単純な内部実装の簡素化のため、シーケンス図は省略)。

Possibly related issues

  • DSK-127: 同じ btree_to_label_selector の冗長ソート除去を目的としており、本PRの変更と直接一致する。
🚥 Pre-merge checks | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning Conventional Commitsの接頭辞がなく、要件を満たしていません。 refactor: などのConventional Commits形式にし、必要ならDSK-127を残して具体化してください。
Description check ⚠️ Warning テンプレートの「## 概要」「## 変更理由」がなく、代わりに英語のSummary/Test planになっています。 「## 概要」「## 変更理由」を埋め、変更内容と理由をテンプレートどおりに整理してください。

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

@daisuke8000
daisuke8000 merged commit 66c307e into main Jul 5, 2026
3 checks passed
@daisuke8000
daisuke8000 deleted the fix/dsk-127-btree-label-selector branch July 5, 2026 08:38
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.

1 participant