From 28d92c521a03ba1be58cf7cc532229a035e0aebf Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 14 Oct 2024 15:40:42 +0200 Subject: [PATCH] External docids to &'bump str --- milli/src/update/new/document_change.rs | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/milli/src/update/new/document_change.rs b/milli/src/update/new/document_change.rs index a789b32b7..63b878854 100644 --- a/milli/src/update/new/document_change.rs +++ b/milli/src/update/new/document_change.rs @@ -6,26 +6,26 @@ use crate::documents::FieldIdMapper; use crate::{DocumentId, Index, Result}; pub enum DocumentChange<'doc> { - Deletion(Deletion), + Deletion(Deletion<'doc>), Update(Update<'doc>), Insertion(Insertion<'doc>), } -pub struct Deletion { +pub struct Deletion<'doc> { docid: DocumentId, - external_document_id: String, + external_document_id: &'doc str, } pub struct Update<'doc> { docid: DocumentId, - external_document_id: String, + external_document_id: &'doc str, new: DocumentFromVersions<'doc>, has_deletion: bool, } pub struct Insertion<'doc> { docid: DocumentId, - external_document_id: String, + external_document_id: &'doc str, new: DocumentFromVersions<'doc>, } @@ -38,7 +38,7 @@ impl<'doc> DocumentChange<'doc> { } } - pub fn external_docid(&self) -> &str { + pub fn external_docid(&self) -> &'doc str { match self { DocumentChange::Deletion(deletion) => deletion.external_document_id(), DocumentChange::Update(update) => update.external_document_id(), @@ -47,8 +47,8 @@ impl<'doc> DocumentChange<'doc> { } } -impl Deletion { - pub fn create(docid: DocumentId, external_document_id: String) -> Self { +impl<'doc> Deletion<'doc> { + pub fn create(docid: DocumentId, external_document_id: &'doc str) -> Self { Self { docid, external_document_id } } @@ -56,8 +56,8 @@ impl Deletion { self.docid } - pub fn external_document_id(&self) -> &str { - &self.external_document_id + pub fn external_document_id(&self) -> &'doc str { + self.external_document_id } pub fn current<'a, Mapper: FieldIdMapper>( @@ -75,7 +75,7 @@ impl Deletion { impl<'doc> Insertion<'doc> { pub fn create( docid: DocumentId, - external_document_id: String, + external_document_id: &'doc str, new: DocumentFromVersions<'doc>, ) -> Self { Insertion { docid, external_document_id, new } @@ -85,8 +85,8 @@ impl<'doc> Insertion<'doc> { self.docid } - pub fn external_document_id(&self) -> &str { - &self.external_document_id + pub fn external_document_id(&self) -> &'doc str { + self.external_document_id } pub fn new(&self) -> DocumentFromVersions<'doc> { self.new @@ -96,7 +96,7 @@ impl<'doc> Insertion<'doc> { impl<'doc> Update<'doc> { pub fn create( docid: DocumentId, - external_document_id: String, + external_document_id: &'doc str, new: DocumentFromVersions<'doc>, has_deletion: bool, ) -> Self { @@ -107,8 +107,8 @@ impl<'doc> Update<'doc> { self.docid } - pub fn external_document_id(&self) -> &str { - &self.external_document_id + pub fn external_document_id(&self) -> &'doc str { + self.external_document_id } pub fn current<'a, Mapper: FieldIdMapper>( &self,