mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-30 15:03:12 +08:00
Merge pull request #207 from meilisearch/improve-documents-ids-iter
Improve the DocumentsIdsIter internal
This commit is contained in:
commit
0103c7bfd9
@ -307,7 +307,7 @@ fn search_command(command: SearchCommand, database: Database) -> Result<(), Box<
|
|||||||
doc.highlights.sort_unstable_by_key(|m| (m.char_index, m.char_length));
|
doc.highlights.sort_unstable_by_key(|m| (m.char_index, m.char_length));
|
||||||
|
|
||||||
let start_retrieve = Instant::now();
|
let start_retrieve = Instant::now();
|
||||||
let result = index.document::<Document, _>(&reader, Some(&fields), doc.id);
|
let result = index.document::<_, Document>(&reader, Some(&fields), doc.id);
|
||||||
retrieve_duration += start_retrieve.elapsed();
|
retrieve_duration += start_retrieve.elapsed();
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
|
@ -146,15 +146,14 @@ impl<'r> Iterator for DocumentsIdsIter<'r> {
|
|||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
for result in self.iter.next() {
|
for result in self.iter.next() {
|
||||||
match result {
|
match result {
|
||||||
Ok((key, Some(rkv::Value::Blob(bytes)))) => {
|
Ok((key, _)) => {
|
||||||
let array = TryFrom::try_from(key).unwrap();
|
let array = TryFrom::try_from(key).unwrap();
|
||||||
let (document_id, attr) = document_attribute_from_key(array);
|
let (document_id, _) = document_attribute_from_key(array);
|
||||||
if Some(document_id) != self.last_seen_id {
|
if Some(document_id) != self.last_seen_id {
|
||||||
self.last_seen_id = Some(document_id);
|
self.last_seen_id = Some(document_id);
|
||||||
return Some(Ok(document_id))
|
return Some(Ok(document_id))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Ok((key, data)) => panic!("{:?}, {:?}", key, data),
|
|
||||||
Err(e) => return Some(Err(e)),
|
Err(e) => return Some(Err(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ pub struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Index {
|
impl Index {
|
||||||
pub fn document<T: de::DeserializeOwned, R: rkv::Readable>(
|
pub fn document<R: rkv::Readable, T: de::DeserializeOwned>(
|
||||||
&self,
|
&self,
|
||||||
reader: &R,
|
reader: &R,
|
||||||
attributes: Option<&HashSet<&str>>,
|
attributes: Option<&HashSet<&str>>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user