use FxHashMap for Aggregations Request (#2722)

Co-authored-by: Pascal Seitz <pascal.seitz@datadoghq.com>
This commit is contained in:
PSeitz
2025-10-21 15:59:18 +02:00
committed by GitHub
parent dabcaa5809
commit 938bfec8b7
2 changed files with 5 additions and 3 deletions

View File

@@ -26,8 +26,9 @@
//! let _agg_req: Aggregations = serde_json::from_str(elasticsearch_compatible_json_req).unwrap();
//! ```
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use super::bucket::{
@@ -43,7 +44,7 @@ use super::metric::{
/// defined names. It is also used in buckets aggregations to define sub-aggregations.
///
/// The key is the user defined name of the aggregation.
pub type Aggregations = HashMap<String, Aggregation>;
pub type Aggregations = FxHashMap<String, Aggregation>;
/// Aggregation request.
///

View File

@@ -2362,7 +2362,8 @@ mod tests {
let mut agg_res = search(&index, &agg_req)?;
// --- Aggregations: terms on host and tags ---
let mut agg_req2: Aggregations = Aggregations::with_capacity(20);
let mut agg_req2: Aggregations =
Aggregations::with_capacity_and_hasher(20, Default::default());
agg_req2.insert(
"tags".to_string(),
serde_json::from_value(json!({ "terms": { "field": "tags" } }))?,