Speed up the facets stats infos subcommand

This commit is contained in:
Clément Renault 2020-11-17 21:18:34 +01:00
parent 7a6e6eb5e2
commit 45e0feab4e
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -407,6 +407,7 @@ fn facet_values_docids(index: &Index, rtxn: &heed::RoTxn, debug: bool, field_nam
}
fn facet_stats(index: &Index, rtxn: &heed::RoTxn, field_name: String) -> anyhow::Result<()> {
use heed::types::ByteSlice;
use crate::facet::FacetType;
use crate::heed_codec::facet::{
FacetValueStringCodec, FacetLevelValueF64Codec, FacetLevelValueI64Codec,
@ -423,17 +424,17 @@ fn facet_stats(index: &Index, rtxn: &heed::RoTxn, field_name: String) -> anyhow:
let iter = index.facet_field_id_value_docids.prefix_iter(&rtxn, &[field_id])?;
let iter = match field_type {
FacetType::String => {
let iter = iter.remap_key_type::<FacetValueStringCodec>()
let iter = iter.remap_types::<FacetValueStringCodec, ByteSlice>()
.map(|r| r.map(|_| 0u8));
Box::new(iter) as Box<dyn Iterator<Item=_>>
},
FacetType::Float => {
let iter = iter.remap_key_type::<FacetLevelValueF64Codec>()
let iter = iter.remap_types::<FacetLevelValueF64Codec, ByteSlice>()
.map(|r| r.map(|((_, level, _, _), _)| level));
Box::new(iter)
},
FacetType::Integer => {
let iter = iter.remap_key_type::<FacetLevelValueI64Codec>()
let iter = iter.remap_types::<FacetLevelValueI64Codec, ByteSlice>()
.map(|r| r.map(|((_, level, _, _), _)| level));
Box::new(iter)
},