Skip to content

Commit 80a1418

Browse files
committed
Use FnvHashMap for keyed bucket entries
1 parent 5ab5f07 commit 80a1418

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/aggregation/agg_result.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
use std::collections::HashMap;
88

9+
use fnv::FnvHashMap;
910
use serde::{Deserialize, Serialize};
1011

1112
use super::agg_req::BucketAggregationInternal;
@@ -145,7 +146,7 @@ pub enum BucketEntries<T> {
145146
/// Vector format bucket entries
146147
Vec(Vec<T>),
147148
/// HashMap format bucket entries
148-
HashMap(HashMap<String, T>),
149+
HashMap(FnvHashMap<String, T>),
149150
}
150151

151152
/// This is the default entry for a bucket, which contains a key, count, and optionally

src/aggregation/intermediate_agg_result.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ impl IntermediateBucketResult {
287287
.expect("unexpected aggregation, expected range aggregation")
288288
.keyed;
289289
let buckets = if is_keyed {
290-
let mut bucket_map = HashMap::new();
290+
let mut bucket_map =
291+
FnvHashMap::with_capacity_and_hasher(buckets.len(), Default::default());
291292
for bucket in buckets {
292293
bucket_map.insert(bucket.key.to_string(), bucket);
293294
}
@@ -306,7 +307,8 @@ impl IntermediateBucketResult {
306307
)?;
307308

308309
let buckets = if req.as_histogram().unwrap().keyed {
309-
let mut bucket_map = HashMap::new();
310+
let mut bucket_map =
311+
FnvHashMap::with_capacity_and_hasher(buckets.len(), Default::default());
310312
for bucket in buckets {
311313
bucket_map.insert(bucket.key.to_string(), bucket);
312314
}

0 commit comments

Comments
 (0)