mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Make the FieldsIdsMap serialization more stable by using a BTreeMap
This commit is contained in:
parent
9133f38138
commit
566a7c3039
9 changed files with 67 additions and 77 deletions
|
@ -1,9 +1,9 @@
|
|||
use std::collections::{HashMap, BTreeMap};
|
||||
use std::collections::BTreeMap;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct FieldsIdsMap {
|
||||
names_ids: HashMap<String, u8>,
|
||||
names_ids: BTreeMap<String, u8>,
|
||||
ids_names: BTreeMap<u8, String>,
|
||||
next_id: Option<u8>,
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ pub struct FieldsIdsMap {
|
|||
impl FieldsIdsMap {
|
||||
pub fn new() -> FieldsIdsMap {
|
||||
FieldsIdsMap {
|
||||
names_ids: HashMap::new(),
|
||||
names_ids: BTreeMap::new(),
|
||||
ids_names: BTreeMap::new(),
|
||||
next_id: Some(0),
|
||||
}
|
||||
|
@ -66,6 +66,12 @@ impl FieldsIdsMap {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for FieldsIdsMap {
|
||||
fn default() -> FieldsIdsMap {
|
||||
FieldsIdsMap::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue