Skip to content

Commit 6944ad4

Browse files
committed
Fix ordering implem
1 parent 4f54d65 commit 6944ad4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

quickwit/quickwit-control-plane/src/indexing_scheduler/scheduling/scheduling_logic.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,33 +228,39 @@ fn assert_enforce_nodes_cpu_capacity_post_condition(
228228
// If this algorithm fails to place all remaining shards, we inflate
229229
// the node capacities by 20% in the scheduling problem and start from the beginning.
230230

231-
#[derive(Debug, PartialEq, Eq, Ord)]
231+
#[derive(Debug, PartialEq, Eq)]
232232
struct PlacementCandidate {
233233
indexer_ord: IndexerOrd,
234234
current_num_shards: u32,
235235
available_capacity: CpuCapacity,
236236
affinity: u32,
237237
}
238238

239-
impl PartialOrd for PlacementCandidate {
240-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
239+
impl Ord for PlacementCandidate {
240+
fn cmp(&self, other: &Self) -> Ordering {
241241
// Higher affinity is better
242242
match self.affinity.cmp(&other.affinity) {
243243
Ordering::Equal => {}
244-
ordering => return Some(ordering.reverse()),
244+
ordering => return ordering.reverse(),
245245
}
246246
// If tie, pick the node with shards already assigned first
247247
match self.current_num_shards.cmp(&other.current_num_shards) {
248248
Ordering::Equal => {}
249-
ordering => return Some(ordering.reverse()),
249+
ordering => return ordering.reverse(),
250250
}
251251
// If tie, pick the node with the highest available capacity
252252
match self.available_capacity.cmp(&other.available_capacity) {
253253
Ordering::Equal => {}
254-
ordering => return Some(ordering.reverse()),
254+
ordering => return ordering.reverse(),
255255
}
256256
// Final tie-breaker: indexer ID for deterministic ordering
257-
Some(self.indexer_ord.cmp(&other.indexer_ord).reverse())
257+
self.indexer_ord.cmp(&other.indexer_ord).reverse()
258+
}
259+
}
260+
261+
impl PartialOrd for PlacementCandidate {
262+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
263+
Some(self.cmp(other))
258264
}
259265
}
260266

0 commit comments

Comments
 (0)