mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-06 20:25:40 +00:00
refactor: update macro
This commit is contained in:
parent
f690fa0686
commit
95821d0bde
@ -91,7 +91,8 @@ impl FacetedDocidsExtractor {
|
|||||||
let mut del_add_facet_value = DelAddFacetValue::new(&context.doc_alloc);
|
let mut del_add_facet_value = DelAddFacetValue::new(&context.doc_alloc);
|
||||||
let docid = document_change.docid();
|
let docid = document_change.docid();
|
||||||
|
|
||||||
macro_rules! facet_fn_factory {
|
// Macro expanding to an insertion/deletion facet fn
|
||||||
|
macro_rules! facet_fn {
|
||||||
(del) => {
|
(del) => {
|
||||||
|fid: FieldId, meta: Metadata, depth: perm_json_p::Depth, value: &Value| {
|
|fid: FieldId, meta: Metadata, depth: perm_json_p::Depth, value: &Value| {
|
||||||
Self::facet_fn_with_options(
|
Self::facet_fn_with_options(
|
||||||
@ -130,7 +131,7 @@ impl FacetedDocidsExtractor {
|
|||||||
|
|
||||||
match document_change {
|
match document_change {
|
||||||
DocumentChange::Deletion(inner) => {
|
DocumentChange::Deletion(inner) => {
|
||||||
let mut del = facet_fn_factory!(del);
|
let mut del = facet_fn!(del);
|
||||||
|
|
||||||
extract_document_facets(
|
extract_document_facets(
|
||||||
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
||||||
@ -148,7 +149,6 @@ impl FacetedDocidsExtractor {
|
|||||||
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
||||||
inner.external_document_id(),
|
inner.external_document_id(),
|
||||||
new_fields_ids_map.deref_mut(),
|
new_fields_ids_map.deref_mut(),
|
||||||
asc_desc_fields,
|
|
||||||
&mut del,
|
&mut del,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ impl FacetedDocidsExtractor {
|
|||||||
|
|
||||||
if has_changed {
|
if has_changed {
|
||||||
// 1. Delete old facet values
|
// 1. Delete old facet values
|
||||||
let mut del = facet_fn_factory!(del);
|
let mut del = facet_fn!(del);
|
||||||
|
|
||||||
extract_document_facets(
|
extract_document_facets(
|
||||||
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
||||||
@ -191,12 +191,12 @@ impl FacetedDocidsExtractor {
|
|||||||
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
inner.current(rtxn, index, context.db_fields_ids_map)?,
|
||||||
inner.external_document_id(),
|
inner.external_document_id(),
|
||||||
new_fields_ids_map.deref_mut(),
|
new_fields_ids_map.deref_mut(),
|
||||||
asc_desc_fields,
|
|
||||||
&mut del,
|
&mut del,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut add = facet_fn_factory!(add);
|
// 2. Insert new facet values
|
||||||
|
let mut add = facet_fn!(add);
|
||||||
|
|
||||||
extract_document_facets(
|
extract_document_facets(
|
||||||
inner.merged(rtxn, index, context.db_fields_ids_map)?,
|
inner.merged(rtxn, index, context.db_fields_ids_map)?,
|
||||||
@ -214,14 +214,13 @@ impl FacetedDocidsExtractor {
|
|||||||
inner.merged(rtxn, index, context.db_fields_ids_map)?,
|
inner.merged(rtxn, index, context.db_fields_ids_map)?,
|
||||||
inner.external_document_id(),
|
inner.external_document_id(),
|
||||||
new_fields_ids_map.deref_mut(),
|
new_fields_ids_map.deref_mut(),
|
||||||
asc_desc_fields,
|
|
||||||
&mut add,
|
&mut add,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DocumentChange::Insertion(inner) => {
|
DocumentChange::Insertion(inner) => {
|
||||||
let mut add = facet_fn_factory!(add);
|
let mut add = facet_fn!(add);
|
||||||
|
|
||||||
extract_document_facets(
|
extract_document_facets(
|
||||||
inner.inserted(),
|
inner.inserted(),
|
||||||
@ -238,7 +237,6 @@ impl FacetedDocidsExtractor {
|
|||||||
inner.inserted(),
|
inner.inserted(),
|
||||||
inner.external_document_id(),
|
inner.external_document_id(),
|
||||||
new_fields_ids_map.deref_mut(),
|
new_fields_ids_map.deref_mut(),
|
||||||
asc_desc_fields,
|
|
||||||
&mut add,
|
&mut add,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,6 @@ pub fn extract_geo_document<'doc>(
|
|||||||
document: impl Document<'doc>,
|
document: impl Document<'doc>,
|
||||||
external_document_id: &str,
|
external_document_id: &str,
|
||||||
field_id_map: &mut GlobalFieldsIdsMap,
|
field_id_map: &mut GlobalFieldsIdsMap,
|
||||||
asc_desc_fields: &HashSet<String>,
|
|
||||||
facet_fn: &mut impl FnMut(FieldId, Metadata, perm_json_p::Depth, &Value) -> Result<()>,
|
facet_fn: &mut impl FnMut(FieldId, Metadata, perm_json_p::Depth, &Value) -> Result<()>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if let Some(geo_value) = document.geo_field()? {
|
if let Some(geo_value) = document.geo_field()? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user