Implement iter method on ExternalDocumentsIds

This commit is contained in:
ManyTheFish 2023-11-02 15:37:05 +01:00
parent 5b20e625f3
commit bf0651f23c
2 changed files with 7 additions and 2 deletions

View File

@ -18,7 +18,7 @@ pub struct DocumentOperation {
pub kind: DocumentOperationKind, pub kind: DocumentOperationKind,
} }
pub struct ExternalDocumentsIds(pub Database<Str, OwnedType<BEU32>>); pub struct ExternalDocumentsIds(Database<Str, OwnedType<BEU32>>);
impl ExternalDocumentsIds { impl ExternalDocumentsIds {
pub fn new(db: Database<Str, OwnedType<BEU32>>) -> ExternalDocumentsIds { pub fn new(db: Database<Str, OwnedType<BEU32>>) -> ExternalDocumentsIds {
@ -86,6 +86,11 @@ impl ExternalDocumentsIds {
Ok(()) Ok(())
} }
/// Returns an iterator over all the external ids.
pub fn iter<'t>(&self, rtxn: &'t RoTxn) -> heed::Result<RoIter<'t, Str, OwnedType<BEU32>>> {
self.0.iter(rtxn)
}
} }
/// An iterator over mappings between requested internal ids and external ids. /// An iterator over mappings between requested internal ids and external ids.

View File

@ -799,7 +799,7 @@ impl<'a, 'i> Transform<'a, 'i> {
let mut obkv_buffer = Vec::new(); let mut obkv_buffer = Vec::new();
let mut document_sorter_key_buffer = Vec::new(); let mut document_sorter_key_buffer = Vec::new();
let mut document_sorter_value_buffer = Vec::new(); let mut document_sorter_value_buffer = Vec::new();
for result in self.index.external_documents_ids().0.iter(wtxn)? { for result in self.index.external_documents_ids().iter(wtxn)? {
let (external_id, docid) = result?; let (external_id, docid) = result?;
let obkv = self.index.documents.get(wtxn, &docid)?.ok_or( let obkv = self.index.documents.get(wtxn, &docid)?.ok_or(
InternalError::DatabaseMissingEntry { db_name: db_name::DOCUMENTS, key: None }, InternalError::DatabaseMissingEntry { db_name: db_name::DOCUMENTS, key: None },