mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-24 13:40:31 +01:00
early return on empty document addition
This commit is contained in:
parent
25f75d4d03
commit
313c362461
@ -1,7 +1,7 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, Seek, SeekFrom};
|
use std::io::{self, Seek, SeekFrom, BufReader, BufRead};
|
||||||
use std::num::{NonZeroU32, NonZeroUsize};
|
use std::num::{NonZeroU32, NonZeroUsize};
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::mpsc::sync_channel;
|
use std::sync::mpsc::sync_channel;
|
||||||
@ -326,6 +326,16 @@ impl<'t, 'u, 'i, 'a> IndexDocuments<'t, 'u, 'i, 'a> {
|
|||||||
R: io::Read,
|
R: io::Read,
|
||||||
F: Fn(UpdateIndexingStep, u64) + Sync,
|
F: Fn(UpdateIndexingStep, u64) + Sync,
|
||||||
{
|
{
|
||||||
|
let mut reader = BufReader::new(reader);
|
||||||
|
reader.fill_buf()?;
|
||||||
|
|
||||||
|
// Early return when there are no document to add
|
||||||
|
if reader.buffer().is_empty() {
|
||||||
|
return Ok(DocumentAdditionResult {
|
||||||
|
nb_documents: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
self.index.set_updated_at(self.wtxn, &Utc::now())?;
|
self.index.set_updated_at(self.wtxn, &Utc::now())?;
|
||||||
let before_transform = Instant::now();
|
let before_transform = Instant::now();
|
||||||
let update_id = self.update_id;
|
let update_id = self.update_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user