update edition to 2024 (#2620)

* update common to edition 2024

* update bitpacker to edition 2024

* update stacker to edition 2024

* update query-grammar to edition 2024

* update sstable to edition 2024 + fmt

* fmt

* update columnar to edition 2024

* cargo fmt

* use None instead of _
This commit is contained in:
PSeitz
2025-04-18 04:56:31 +02:00
committed by GitHub
parent 3fa90e70e2
commit 5379c99ea2
75 changed files with 239 additions and 231 deletions

View File

@@ -1,7 +1,7 @@
[package]
name = "tantivy-sstable"
version = "0.3.0"
edition = "2021"
edition = "2024"
license = "MIT"
homepage = "https://github.com/quickwit-oss/tantivy"
repository = "https://github.com/quickwit-oss/tantivy"

View File

@@ -1,8 +1,8 @@
use std::sync::Arc;
use common::file_slice::FileSlice;
use common::OwnedBytes;
use criterion::{criterion_group, criterion_main, Criterion};
use common::file_slice::FileSlice;
use criterion::{Criterion, criterion_group, criterion_main};
use tantivy_sstable::{Dictionary, MonotonicU64SSTable};
fn make_test_sstable(suffix: &str) -> FileSlice {

View File

@@ -2,7 +2,7 @@ use std::collections::BTreeSet;
use std::io;
use common::file_slice::FileSlice;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use tantivy_sstable::{Dictionary, MonotonicU64SSTable};

View File

@@ -51,18 +51,21 @@ impl BlockReader {
let block_len = match self.reader.len() {
0 => {
// we are out of data for this block. Check if we have another block after
if let Some(new_reader) = self.next_readers.next() {
self.reader = new_reader;
continue;
} else {
return Ok(false);
match self.next_readers.next() {
Some(new_reader) => {
self.reader = new_reader;
continue;
}
_ => {
return Ok(false);
}
}
}
1..=3 => {
return Err(io::Error::new(
io::ErrorKind::UnexpectedEof,
"failed to read block_len",
))
));
}
_ => self.reader.read_u32() as usize,
};

View File

@@ -5,7 +5,7 @@ use common::{CountingWriter, OwnedBytes};
use zstd::bulk::Compressor;
use super::value::ValueWriter;
use super::{value, vint, BlockReader};
use super::{BlockReader, value, vint};
const FOUR_BIT_LIMITS: usize = 1 << 4;
const VINT_MODE: u8 = 1u8;

View File

@@ -6,13 +6,13 @@ use std::marker::PhantomData;
use std::ops::{Bound, RangeBounds};
use std::sync::Arc;
use common::bounds::{transform_bound_inner_res, TransformBound};
use common::bounds::{TransformBound, transform_bound_inner_res};
use common::file_slice::FileSlice;
use common::{BinarySerializable, OwnedBytes};
use futures_util::{stream, StreamExt, TryStreamExt};
use futures_util::{StreamExt, TryStreamExt, stream};
use itertools::Itertools;
use tantivy_fst::automaton::AlwaysMatch;
use tantivy_fst::Automaton;
use tantivy_fst::automaton::AlwaysMatch;
use crate::sstable_index_v3::SSTableIndexV3Empty;
use crate::streamer::{Streamer, StreamerBuilder};
@@ -311,7 +311,7 @@ impl<TSSTable: SSTable> Dictionary<TSSTable> {
return Err(io::Error::new(
io::ErrorKind::Other,
format!("Unsupported sstable version, expected one of [2, 3], found {version}"),
))
));
}
};
@@ -644,8 +644,8 @@ mod tests {
use common::OwnedBytes;
use super::Dictionary;
use crate::dictionary::TermOrdHit;
use crate::MonotonicU64SSTable;
use crate::dictionary::TermOrdHit;
#[derive(Debug)]
struct PermissionedHandle {
@@ -914,30 +914,33 @@ mod tests {
// Single term
let mut terms = Vec::new();
assert!(dic
.sorted_ords_to_term_cb(100_000..100_001, |term| {
assert!(
dic.sorted_ords_to_term_cb(100_000..100_001, |term| {
terms.push(term.to_vec());
Ok(())
})
.unwrap());
.unwrap()
);
assert_eq!(terms, vec![format!("{:05X}", 100_000).into_bytes(),]);
// Single term
let mut terms = Vec::new();
assert!(dic
.sorted_ords_to_term_cb(100_001..100_002, |term| {
assert!(
dic.sorted_ords_to_term_cb(100_001..100_002, |term| {
terms.push(term.to_vec());
Ok(())
})
.unwrap());
.unwrap()
);
assert_eq!(terms, vec![format!("{:05X}", 100_001).into_bytes(),]);
// both terms
let mut terms = Vec::new();
assert!(dic
.sorted_ords_to_term_cb(100_000..100_002, |term| {
assert!(
dic.sorted_ords_to_term_cb(100_000..100_002, |term| {
terms.push(term.to_vec());
Ok(())
})
.unwrap());
.unwrap()
);
assert_eq!(
terms,
vec![
@@ -947,12 +950,13 @@ mod tests {
);
// Test cross block
let mut terms = Vec::new();
assert!(dic
.sorted_ords_to_term_cb(98653..=98655, |term| {
assert!(
dic.sorted_ords_to_term_cb(98653..=98655, |term| {
terms.push(term.to_vec());
Ok(())
})
.unwrap());
.unwrap()
);
assert_eq!(
terms,
vec![

View File

@@ -322,7 +322,7 @@ mod test {
use common::OwnedBytes;
use super::{common_prefix_len, MonotonicU64SSTable, SSTable, VoidMerge, VoidSSTable};
use super::{MonotonicU64SSTable, SSTable, VoidMerge, VoidSSTable, common_prefix_len};
fn aux_test_common_prefix_len(left: &str, right: &str, expect_len: usize) {
assert_eq!(

View File

@@ -1,6 +1,6 @@
use std::cmp::Ordering;
use std::collections::binary_heap::PeekMut;
use std::collections::BinaryHeap;
use std::collections::binary_heap::PeekMut;
use std::io;
use super::{SingleValueMerger, ValueMerger};
@@ -41,14 +41,17 @@ pub fn merge_sstable<SST: SSTable, W: io::Write, M: ValueMerger<SST::Value>>(
loop {
let len = heap.len();
let mut value_merger;
if let Some(mut head) = heap.peek_mut() {
writer.insert_key(head.0.key()).unwrap();
value_merger = merger.new_value(head.0.value());
if !head.0.advance()? {
PeekMut::pop(head);
match heap.peek_mut() {
Some(mut head) => {
writer.insert_key(head.0.key()).unwrap();
value_merger = merger.new_value(head.0.value());
if !head.0.advance()? {
PeekMut::pop(head);
}
}
_ => {
break;
}
} else {
break;
}
for _ in 0..len - 1 {
if let Some(mut head) = heap.peek_mut() {

View File

@@ -3,12 +3,12 @@ use std::ops::Range;
use std::sync::Arc;
use common::{BinarySerializable, FixedSize, OwnedBytes};
use tantivy_bitpacker::{compute_num_bits, BitPacker};
use tantivy_bitpacker::{BitPacker, compute_num_bits};
use tantivy_fst::raw::Fst;
use tantivy_fst::{Automaton, IntoStreamer, Map, MapBuilder, Streamer};
use crate::block_match_automaton::can_block_match_automaton;
use crate::{common_prefix_len, SSTableDataCorruption, TermOrdinal};
use crate::{SSTableDataCorruption, TermOrdinal, common_prefix_len};
#[derive(Debug, Clone)]
pub enum SSTableIndex {
@@ -824,8 +824,8 @@ mod tests {
use common::OwnedBytes;
use super::*;
use crate::block_match_automaton::tests::EqBuffer;
use crate::SSTableDataCorruption;
use crate::block_match_automaton::tests::EqBuffer;
#[test]
fn test_sstable_index() {

View File

@@ -1,8 +1,8 @@
use std::io;
use std::ops::Bound;
use tantivy_fst::automaton::AlwaysMatch;
use tantivy_fst::Automaton;
use tantivy_fst::automaton::AlwaysMatch;
use crate::dictionary::Dictionary;
use crate::{DeltaReader, SSTable, TermOrdinal};

View File

@@ -1,7 +1,7 @@
use std::io;
use crate::value::{deserialize_vint_u64, ValueReader, ValueWriter};
use crate::{vint, BlockAddr};
use crate::value::{ValueReader, ValueWriter, deserialize_vint_u64};
use crate::{BlockAddr, vint};
#[derive(Default)]
pub(crate) struct IndexValueReader {

View File

@@ -1,7 +1,7 @@
use std::io;
use std::ops::Range;
use crate::value::{deserialize_vint_u64, ValueReader, ValueWriter};
use crate::value::{ValueReader, ValueWriter, deserialize_vint_u64};
/// See module comment.
#[derive(Default)]

View File

@@ -1,6 +1,6 @@
use std::io;
use crate::value::{deserialize_vint_u64, ValueReader, ValueWriter};
use crate::value::{ValueReader, ValueWriter, deserialize_vint_u64};
use crate::vint;
#[derive(Default)]