mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-04 03:36:30 +00:00
Add new milli::update:🆕:indexer::sharding
module
This commit is contained in:
@ -36,6 +36,7 @@ mod guess_primary_key;
|
|||||||
mod partial_dump;
|
mod partial_dump;
|
||||||
mod post_processing;
|
mod post_processing;
|
||||||
pub mod settings_changes;
|
pub mod settings_changes;
|
||||||
|
pub mod sharding;
|
||||||
mod update_by_function;
|
mod update_by_function;
|
||||||
mod write;
|
mod write;
|
||||||
|
|
||||||
|
22
crates/milli/src/update/new/indexer/sharding.rs
Normal file
22
crates/milli/src/update/new/indexer/sharding.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright © 2025 Meilisearch Some Rights Reserved
|
||||||
|
// This file is part of Meilisearch Enterprise Edition (EE).
|
||||||
|
// Use of this source code is governed by the Business Source License 1.1,
|
||||||
|
// as found in the LICENSE-EE file or at <https://mariadb.com/bsl11>
|
||||||
|
|
||||||
|
use std::hash::{BuildHasher as _, BuildHasherDefault};
|
||||||
|
|
||||||
|
pub struct Shards {
|
||||||
|
pub own: Vec<String>,
|
||||||
|
pub others: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Shards {
|
||||||
|
pub fn must_process(&self, docid: &str) -> bool {
|
||||||
|
let hasher = BuildHasherDefault::<twox_hash::XxHash3_64>::new();
|
||||||
|
let to_hash = |shard: &String| hasher.hash_one((shard, docid));
|
||||||
|
|
||||||
|
let max_hash = self.others.iter().map(to_hash).max().unwrap_or_default();
|
||||||
|
|
||||||
|
self.own.iter().map(to_hash).any(|hash| hash > max_hash)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user