mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
Refactor
This commit is contained in:
parent
aa03e02fdc
commit
d5978d11e1
@ -75,11 +75,10 @@ impl IndexMapper {
|
|||||||
options.map_size(clamp_to_page_size(self.index_size));
|
options.map_size(clamp_to_page_size(self.index_size));
|
||||||
options.max_readers(1024);
|
options.max_readers(1024);
|
||||||
|
|
||||||
if date == None {
|
if let Some((created, updated)) = date {
|
||||||
Ok(Index::new(options, path)?)
|
|
||||||
} else {
|
|
||||||
let (created, updated) = date.unwrap();
|
|
||||||
Ok(Index::new_with_creation_dates(options, path, created, updated)?)
|
Ok(Index::new_with_creation_dates(options, path, created, updated)?)
|
||||||
|
} else {
|
||||||
|
Ok(Index::new(options, path)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,9 +865,12 @@ impl IndexScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new index without any associated task.
|
/// Create a new index without any associated task.
|
||||||
pub fn create_raw_index(&self, name: &str) -> Result<Index> {
|
pub fn create_raw_index(
|
||||||
|
&self,
|
||||||
|
name: &str,
|
||||||
|
date: Option<(time::OffsetDateTime, time::OffsetDateTime)>,
|
||||||
|
) -> Result<Index> {
|
||||||
let wtxn = self.env.write_txn()?;
|
let wtxn = self.env.write_txn()?;
|
||||||
let date = Some((time::OffsetDateTime::now_utc(), time::OffsetDateTime::now_utc()));
|
|
||||||
let index = self.index_mapper.create_index(wtxn, name, date)?;
|
let index = self.index_mapper.create_index(wtxn, name, date)?;
|
||||||
|
|
||||||
Ok(index)
|
Ok(index)
|
||||||
|
@ -277,7 +277,9 @@ fn import_dump(
|
|||||||
let mut index_reader = index_reader?;
|
let mut index_reader = index_reader?;
|
||||||
let metadata = index_reader.metadata();
|
let metadata = index_reader.metadata();
|
||||||
log::info!("Importing index `{}`.", metadata.uid);
|
log::info!("Importing index `{}`.", metadata.uid);
|
||||||
let index = index_scheduler.create_raw_index(&metadata.uid)?;
|
//let date = Some((time::OffsetDateTime::now_utc(), time::OffsetDateTime::now_utc()));
|
||||||
|
let date = dump_reader.date();
|
||||||
|
let index = index_scheduler.create_raw_index(&metadata.uid, date)?;
|
||||||
|
|
||||||
let mut wtxn = index.write_txn()?;
|
let mut wtxn = index.write_txn()?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user