mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
bump milli to 0.4.0
This commit is contained in:
parent
5795254b2a
commit
5a47cef9a8
7 changed files with 32 additions and 15 deletions
|
@ -6,6 +6,7 @@ use async_stream::stream;
|
|||
use futures::stream::StreamExt;
|
||||
use heed::CompactionOption;
|
||||
use log::debug;
|
||||
use milli::update::UpdateBuilder;
|
||||
use tokio::task::spawn_blocking;
|
||||
use tokio::{fs, sync::mpsc};
|
||||
use uuid::Uuid;
|
||||
|
@ -258,12 +259,15 @@ impl<S: IndexStore + Sync + Send> IndexActor<S> {
|
|||
.ok_or(IndexError::UnexistingIndex)?;
|
||||
|
||||
let result = spawn_blocking(move || match index_settings.primary_key {
|
||||
Some(ref primary_key) => {
|
||||
Some(primary_key) => {
|
||||
let mut txn = index.write_txn()?;
|
||||
if index.primary_key(&txn)?.is_some() {
|
||||
return Err(IndexError::ExistingPrimaryKey);
|
||||
}
|
||||
index.put_primary_key(&mut txn, primary_key)?;
|
||||
let mut builder = UpdateBuilder::new(0).settings(&mut txn, &index);
|
||||
builder.set_primary_key(primary_key);
|
||||
builder.execute(|_, _| ())
|
||||
.map_err(|e| IndexError::Internal(e.to_string()))?;
|
||||
let meta = IndexMeta::new_txn(&index, &txn)?;
|
||||
txn.commit()?;
|
||||
Ok(meta)
|
||||
|
@ -333,7 +337,8 @@ impl<S: IndexStore + Sync + Send> IndexActor<S> {
|
|||
|
||||
Ok(IndexStats {
|
||||
size: index.size(),
|
||||
number_of_documents: index.number_of_documents(&rtxn)?,
|
||||
number_of_documents: index.number_of_documents(&rtxn)
|
||||
.map_err(|e| IndexError::Internal(e.to_string()))?,
|
||||
is_indexing: None,
|
||||
fields_distribution: index.fields_distribution(&rtxn)?,
|
||||
})
|
||||
|
|
|
@ -41,8 +41,12 @@ impl IndexMeta {
|
|||
}
|
||||
|
||||
fn new_txn(index: &Index, txn: &heed::RoTxn) -> IndexResult<Self> {
|
||||
let created_at = index.created_at(&txn)?;
|
||||
let updated_at = index.updated_at(&txn)?;
|
||||
let created_at = index
|
||||
.created_at(&txn)
|
||||
.map_err(|e| IndexError::Internal(e.to_string()))?;
|
||||
let updated_at = index
|
||||
.updated_at(&txn)
|
||||
.map_err(|e| IndexError::Internal(e.to_string()))?;
|
||||
let primary_key = index.primary_key(&txn)?.map(String::from);
|
||||
Ok(Self {
|
||||
created_at,
|
||||
|
|
|
@ -2,6 +2,7 @@ use std::collections::HashMap;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use milli::update::UpdateBuilder;
|
||||
use tokio::fs;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
@ -57,7 +58,12 @@ impl IndexStore for MapIndexStore {
|
|||
let index = Index::open(path, index_size)?;
|
||||
if let Some(primary_key) = primary_key {
|
||||
let mut txn = index.write_txn()?;
|
||||
index.put_primary_key(&mut txn, &primary_key)?;
|
||||
|
||||
let mut builder = UpdateBuilder::new(0).settings(&mut txn, &index);
|
||||
builder.set_primary_key(primary_key);
|
||||
builder.execute(|_, _| ())
|
||||
.map_err(|e| IndexError::Internal(e.to_string()))?;
|
||||
|
||||
txn.commit()?;
|
||||
}
|
||||
Ok(index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue