Implement the IndexCreate batch operation

This commit is contained in:
Kerollmops 2022-10-04 11:48:08 +02:00 committed by Clément Renault
parent cf6084151b
commit 0543cba6eb
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -407,7 +407,26 @@ impl IndexScheduler {
index_uid, index_uid,
primary_key, primary_key,
task, task,
} => todo!(), } => {
let mut wtxn = self.env.write_txn()?;
let index = self.index_mapper.create_index(&mut wtxn, &index_uid)?;
if let Some(primary_key) = primary_key {
let mut index_wtxn = index.write_txn()?;
let mut builder = milli::update::Settings::new(
&mut index_wtxn,
&index,
self.index_mapper.indexer_config(),
);
builder.set_primary_key(primary_key);
builder.execute(|_| ())?;
index_wtxn.commit()?;
}
wtxn.commit()?;
Ok(vec![task])
}
Batch::IndexUpdate { Batch::IndexUpdate {
index_uid, index_uid,
primary_key, primary_key,
@ -450,6 +469,7 @@ impl IndexScheduler {
mut tasks, mut tasks,
} => { } => {
let indexer_config = self.index_mapper.indexer_config(); let indexer_config = self.index_mapper.indexer_config();
// TODO use the code from the IndexCreate operation
if let Some(primary_key) = primary_key { if let Some(primary_key) = primary_key {
if index.primary_key(index_wtxn)?.is_none() { if index.primary_key(index_wtxn)?.is_none() {
let mut builder = let mut builder =