Commit 16c937a8 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

Sort in place

parent 101efe6f
use std::cmp::Ordering;
use anyhow::Result; use anyhow::Result;
use futures::join; use futures::join;
use tracing::Instrument; use tracing::Instrument;
...@@ -429,6 +431,7 @@ fn reorder_isolated_merged_entries( ...@@ -429,6 +431,7 @@ fn reorder_isolated_merged_entries(
else { else {
unreachable!("expected ChunkGroup::IsolatedMerged for client reference") unreachable!("expected ChunkGroup::IsolatedMerged for client reference")
}; };
// Reorder the entries, because the order of IsolatedMerged entries obtained by chunk_group_info // Reorder the entries, because the order of IsolatedMerged entries obtained by chunk_group_info
// is unspecified (and thus not strictly execution order, which is a problem for CSS). // is unspecified (and thus not strictly execution order, which is a problem for CSS).
// //
...@@ -437,18 +440,17 @@ fn reorder_isolated_merged_entries( ...@@ -437,18 +440,17 @@ fn reorder_isolated_merged_entries(
// matter in this case (since they will not be chunked in this step anyway). // matter in this case (since they will not be chunked in this step anyway).
if entries.iter().any(|m| client_to_ref_ty.contains_key(m)) { if entries.iter().any(|m| client_to_ref_ty.contains_key(m)) {
let entries = client_to_ref_ty let mut entries = entries.clone();
.keys() entries.sort_by(|a, b| {
.copied() match (
.filter(|m| entries.contains(m)) client_to_ref_ty.get_index_of(a),
.chain( client_to_ref_ty.get_index_of(b),
entries ) {
.iter() (Some(a), Some(b)) => a.cmp(&b),
.copied() // We don't know, so just keep the same order.
.filter(|m| !client_to_ref_ty.contains_key(m)), _ => Ordering::Equal,
) }
.collect(); });
Some(ChunkGroup::IsolatedMerged { Some(ChunkGroup::IsolatedMerged {
parent: *parent, parent: *parent,
entries, entries,
......
use std::{ use std::{
hash::{BuildHasher, Hash}, hash::{BuildHasher, Hash},
ops::Deref, ops::{Deref, DerefMut},
time::Duration, time::Duration,
}; };
...@@ -91,6 +91,11 @@ impl<T: Hash + Eq> Deref for HashableIndexSet<T> { ...@@ -91,6 +91,11 @@ impl<T: Hash + Eq> Deref for HashableIndexSet<T> {
&self.0 &self.0
} }
} }
impl<T: Hash + Eq> DerefMut for HashableIndexSet<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<T: Hash + Eq> Hash for HashableIndexSet<T> { impl<T: Hash + Eq> Hash for HashableIndexSet<T> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
let mut result = 0u64; let mut result = 0u64;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment