Merge pull request #1404 from quickwit-oss/total_cmp

use total_cmp
This commit is contained in:
PSeitz
2022-07-03 22:51:00 -07:00
committed by GitHub
2 changed files with 8 additions and 12 deletions

View File

@@ -16,8 +16,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose --workspace
- name: Install latest nightly to test also against unstable feature flag
uses: actions-rs/toolchain@v1
with:
@@ -25,13 +23,16 @@ jobs:
override: true
components: rustfmt
- name: Install latest nightly to test also against unstable feature flag
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Build
run: cargo build --verbose --workspace
- name: Run tests
run: cargo +stable test --features mmap,brotli-compression,lz4-compression,snappy-compression,zstd-compression,failpoints --verbose --workspace

View File

@@ -277,11 +277,9 @@ impl IntermediateBucketResult {
.collect::<crate::Result<Vec<_>>>()?;
buckets.sort_by(|left, right| {
// TODO use total_cmp next stable rust release
left.from
.unwrap_or(f64::MIN)
.partial_cmp(&right.from.unwrap_or(f64::MIN))
.unwrap_or(Ordering::Equal)
.total_cmp(&right.from.unwrap_or(f64::MIN))
});
Ok(BucketResult::Range { buckets })
}
@@ -438,12 +436,9 @@ impl IntermediateTermBucketResult {
})
.collect::<crate::Result<Vec<_>>>()?;
buckets_with_val.sort_by(|(_, val1), (_, val2)| {
// TODO use total_cmp in next rust stable release
match &order {
Order::Desc => val2.partial_cmp(val1).unwrap_or(std::cmp::Ordering::Equal),
Order::Asc => val1.partial_cmp(val2).unwrap_or(std::cmp::Ordering::Equal),
}
buckets_with_val.sort_by(|(_, val1), (_, val2)| match &order {
Order::Desc => val2.total_cmp(val1),
Order::Asc => val1.total_cmp(val2),
});
buckets = buckets_with_val
.into_iter()