rename min_word_len_2_typo

This commit is contained in:
ad hoc 2022-03-31 13:51:27 +02:00
parent 55af85db3c
commit 286dd7b2e4
No known key found for this signature in database
GPG Key ID: 4F00A782990CC643
3 changed files with 10 additions and 10 deletions

View File

@ -910,7 +910,7 @@ impl Index {
Ok(()) Ok(())
} }
pub fn min_word_len_2_typo(&self, txn: &RoTxn) -> heed::Result<u8> { pub fn min_word_len_2_typos(&self, txn: &RoTxn) -> heed::Result<u8> {
// It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We
// identify 0 as being false, and anything else as true. The absence of a value is true, // identify 0 as being false, and anything else as true. The absence of a value is true,
// because by default, we authorize typos. // because by default, we authorize typos.
@ -920,7 +920,7 @@ impl Index {
.unwrap_or(DEFAULT_MIN_WORD_LEN_2_TYPOS)) .unwrap_or(DEFAULT_MIN_WORD_LEN_2_TYPOS))
} }
pub(crate) fn put_min_word_len_2_typo(&self, txn: &mut RwTxn, val: u8) -> heed::Result<()> { pub(crate) fn put_min_word_len_2_typos(&self, txn: &mut RwTxn, val: u8) -> heed::Result<()> {
// It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We
// identify 0 as being false, and anything else as true. The absence of a value is true, // identify 0 as being false, and anything else as true. The absence of a value is true,
// because by default, we authorize typos. // because by default, we authorize typos.
@ -1072,15 +1072,15 @@ pub(crate) mod tests {
let mut txn = index.write_txn().unwrap(); let mut txn = index.write_txn().unwrap();
assert_eq!(index.min_word_len_1_typo(&txn).unwrap(), DEFAULT_MIN_WORD_LEN_1_TYPO); assert_eq!(index.min_word_len_1_typo(&txn).unwrap(), DEFAULT_MIN_WORD_LEN_1_TYPO);
assert_eq!(index.min_word_len_2_typo(&txn).unwrap(), DEFAULT_MIN_WORD_LEN_2_TYPOS); assert_eq!(index.min_word_len_2_typos(&txn).unwrap(), DEFAULT_MIN_WORD_LEN_2_TYPOS);
index.put_min_word_len_1_typo(&mut txn, 3).unwrap(); index.put_min_word_len_1_typo(&mut txn, 3).unwrap();
index.put_min_word_len_2_typo(&mut txn, 15).unwrap(); index.put_min_word_len_2_typos(&mut txn, 15).unwrap();
txn.commit().unwrap(); txn.commit().unwrap();
let txn = index.read_txn().unwrap(); let txn = index.read_txn().unwrap();
assert_eq!(index.min_word_len_1_typo(&txn).unwrap(), 3); assert_eq!(index.min_word_len_1_typo(&txn).unwrap(), 3);
assert_eq!(index.min_word_len_2_typo(&txn).unwrap(), 15); assert_eq!(index.min_word_len_2_typos(&txn).unwrap(), 15);
} }
} }

View File

@ -183,7 +183,7 @@ impl<'a> Context for QueryTreeBuilder<'a> {
fn min_word_len_for_typo(&self) -> heed::Result<(u8, u8)> { fn min_word_len_for_typo(&self) -> heed::Result<(u8, u8)> {
let one = self.index.min_word_len_1_typo(&self.rtxn)?; let one = self.index.min_word_len_1_typo(&self.rtxn)?;
let two = self.index.min_word_len_2_typo(&self.rtxn)?; let two = self.index.min_word_len_2_typos(&self.rtxn)?;
Ok((one, two)) Ok((one, two))
} }
} }

View File

@ -501,11 +501,11 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
return Err(UserError::InvalidMinTypoWordSetting(*one, *two).into()); return Err(UserError::InvalidMinTypoWordSetting(*one, *two).into());
} else { } else {
self.index.put_min_word_len_1_typo(&mut self.wtxn, *one)?; self.index.put_min_word_len_1_typo(&mut self.wtxn, *one)?;
self.index.put_min_word_len_2_typo(&mut self.wtxn, *two)?; self.index.put_min_word_len_2_typos(&mut self.wtxn, *two)?;
} }
} }
(Setting::Set(one), _) => { (Setting::Set(one), _) => {
let two = self.index.min_word_len_2_typo(&self.wtxn)?; let two = self.index.min_word_len_2_typos(&self.wtxn)?;
if *one > two { if *one > two {
return Err(UserError::InvalidMinTypoWordSetting(*one, two).into()); return Err(UserError::InvalidMinTypoWordSetting(*one, two).into());
} else { } else {
@ -517,7 +517,7 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
if one > *two { if one > *two {
return Err(UserError::InvalidMinTypoWordSetting(one, *two).into()); return Err(UserError::InvalidMinTypoWordSetting(one, *two).into());
} else { } else {
self.index.put_min_word_len_2_typo(&mut self.wtxn, *two)?; self.index.put_min_word_len_2_typos(&mut self.wtxn, *two)?;
} }
} }
_ => (), _ => (),
@ -1304,7 +1304,7 @@ mod tests {
let txn = index.read_txn().unwrap(); let txn = index.read_txn().unwrap();
assert_eq!(index.min_word_len_1_typo(&txn).unwrap(), 8); assert_eq!(index.min_word_len_1_typo(&txn).unwrap(), 8);
assert_eq!(index.min_word_len_2_typo(&txn).unwrap(), 8); assert_eq!(index.min_word_len_2_typos(&txn).unwrap(), 8);
} }
#[test] #[test]