mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-02-09 03:53:27 +01:00
cleanup the autobatcher a little bit
This commit is contained in:
parent
2db6347686
commit
67dda0678f
@ -278,36 +278,36 @@ impl BatchKind {
|
|||||||
K::DocumentImport { .. } | K::Settings { .. },
|
K::DocumentImport { .. } | K::Settings { .. },
|
||||||
) => Break(this),
|
) => Break(this),
|
||||||
(
|
(
|
||||||
BatchKind::DocumentOperation { method: _, allow_index_creation: _, primary_key: _, operation_ids: mut ids },
|
BatchKind::DocumentOperation { method: _, allow_index_creation: _, primary_key: _, mut operation_ids },
|
||||||
K::DocumentClear,
|
K::DocumentClear,
|
||||||
) => {
|
) => {
|
||||||
ids.push(id);
|
operation_ids.push(id);
|
||||||
Continue(BatchKind::DocumentClear { ids })
|
Continue(BatchKind::DocumentClear { ids: operation_ids })
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can autobatch the same kind of document additions / updates
|
// we can autobatch the same kind of document additions / updates
|
||||||
(
|
(
|
||||||
BatchKind::DocumentOperation { method: ReplaceDocuments, allow_index_creation, primary_key: _, operation_ids: mut import_ids },
|
BatchKind::DocumentOperation { method: ReplaceDocuments, allow_index_creation, primary_key: _, mut operation_ids },
|
||||||
K::DocumentImport { method: ReplaceDocuments, primary_key: pk, .. },
|
K::DocumentImport { method: ReplaceDocuments, primary_key: pk, .. },
|
||||||
) => {
|
) => {
|
||||||
import_ids.push(id);
|
operation_ids.push(id);
|
||||||
Continue(BatchKind::DocumentOperation {
|
Continue(BatchKind::DocumentOperation {
|
||||||
method: ReplaceDocuments,
|
method: ReplaceDocuments,
|
||||||
allow_index_creation,
|
allow_index_creation,
|
||||||
operation_ids: import_ids,
|
operation_ids,
|
||||||
primary_key: pk,
|
primary_key: pk,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
BatchKind::DocumentOperation { method: UpdateDocuments, allow_index_creation, primary_key: _, operation_ids: mut import_ids },
|
BatchKind::DocumentOperation { method: UpdateDocuments, allow_index_creation, primary_key: _, mut operation_ids },
|
||||||
K::DocumentImport { method: UpdateDocuments, primary_key: pk, .. },
|
K::DocumentImport { method: UpdateDocuments, primary_key: pk, .. },
|
||||||
) => {
|
) => {
|
||||||
import_ids.push(id);
|
operation_ids.push(id);
|
||||||
Continue(BatchKind::DocumentOperation {
|
Continue(BatchKind::DocumentOperation {
|
||||||
method: UpdateDocuments,
|
method: UpdateDocuments,
|
||||||
allow_index_creation,
|
allow_index_creation,
|
||||||
primary_key: pk,
|
primary_key: pk,
|
||||||
operation_ids: import_ids,
|
operation_ids,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
@ -331,14 +331,14 @@ impl BatchKind {
|
|||||||
) => Break(this),
|
) => Break(this),
|
||||||
|
|
||||||
(
|
(
|
||||||
BatchKind::DocumentOperation { method, allow_index_creation, primary_key, operation_ids: import_ids },
|
BatchKind::DocumentOperation { method, allow_index_creation, primary_key, operation_ids },
|
||||||
K::Settings { .. },
|
K::Settings { .. },
|
||||||
) => Continue(BatchKind::SettingsAndDocumentOperation {
|
) => Continue(BatchKind::SettingsAndDocumentOperation {
|
||||||
settings_ids: vec![id],
|
settings_ids: vec![id],
|
||||||
method,
|
method,
|
||||||
allow_index_creation,
|
allow_index_creation,
|
||||||
primary_key,
|
primary_key,
|
||||||
operation_ids: import_ids,
|
operation_ids,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
(BatchKind::DocumentDeletion { mut deletion_ids }, K::DocumentClear) => {
|
(BatchKind::DocumentDeletion { mut deletion_ids }, K::DocumentClear) => {
|
||||||
@ -426,41 +426,41 @@ impl BatchKind {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
BatchKind::SettingsAndDocumentOperation { settings_ids, method: _, operation_ids: mut other, allow_index_creation, primary_key: _ },
|
BatchKind::SettingsAndDocumentOperation { settings_ids, method: _, mut operation_ids, allow_index_creation, primary_key: _ },
|
||||||
K::DocumentClear,
|
K::DocumentClear,
|
||||||
) => {
|
) => {
|
||||||
other.push(id);
|
operation_ids.push(id);
|
||||||
Continue(BatchKind::ClearAndSettings {
|
Continue(BatchKind::ClearAndSettings {
|
||||||
settings_ids,
|
settings_ids,
|
||||||
other,
|
other: operation_ids,
|
||||||
allow_index_creation,
|
allow_index_creation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
BatchKind::SettingsAndDocumentOperation { settings_ids, method: ReplaceDocuments, operation_ids: mut import_ids, allow_index_creation, primary_key: _},
|
BatchKind::SettingsAndDocumentOperation { settings_ids, method: ReplaceDocuments, mut operation_ids, allow_index_creation, primary_key: _},
|
||||||
K::DocumentImport { method: ReplaceDocuments, primary_key: pk2, .. },
|
K::DocumentImport { method: ReplaceDocuments, primary_key: pk2, .. },
|
||||||
) => {
|
) => {
|
||||||
import_ids.push(id);
|
operation_ids.push(id);
|
||||||
Continue(BatchKind::SettingsAndDocumentOperation {
|
Continue(BatchKind::SettingsAndDocumentOperation {
|
||||||
settings_ids,
|
settings_ids,
|
||||||
method: ReplaceDocuments,
|
method: ReplaceDocuments,
|
||||||
allow_index_creation,
|
allow_index_creation,
|
||||||
primary_key: pk2,
|
primary_key: pk2,
|
||||||
operation_ids: import_ids,
|
operation_ids,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
BatchKind::SettingsAndDocumentOperation { settings_ids, method: UpdateDocuments, allow_index_creation, primary_key: _, operation_ids: mut import_ids },
|
BatchKind::SettingsAndDocumentOperation { settings_ids, method: UpdateDocuments, allow_index_creation, primary_key: _, mut operation_ids },
|
||||||
K::DocumentImport { method: UpdateDocuments, primary_key: pk2, .. },
|
K::DocumentImport { method: UpdateDocuments, primary_key: pk2, .. },
|
||||||
) => {
|
) => {
|
||||||
import_ids.push(id);
|
operation_ids.push(id);
|
||||||
Continue(BatchKind::SettingsAndDocumentOperation {
|
Continue(BatchKind::SettingsAndDocumentOperation {
|
||||||
settings_ids,
|
settings_ids,
|
||||||
method: UpdateDocuments,
|
method: UpdateDocuments,
|
||||||
allow_index_creation,
|
allow_index_creation,
|
||||||
primary_key: pk2,
|
primary_key: pk2,
|
||||||
operation_ids: import_ids,
|
operation_ids,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// But we can't batch a settings and a doc op with another doc op
|
// But we can't batch a settings and a doc op with another doc op
|
||||||
@ -470,7 +470,7 @@ impl BatchKind {
|
|||||||
K::DocumentDeletion | K::DocumentImport { .. },
|
K::DocumentDeletion | K::DocumentImport { .. },
|
||||||
) => Break(this),
|
) => Break(this),
|
||||||
(
|
(
|
||||||
BatchKind::SettingsAndDocumentOperation { mut settings_ids, method, allow_index_creation,primary_key, operation_ids: import_ids },
|
BatchKind::SettingsAndDocumentOperation { mut settings_ids, method, allow_index_creation,primary_key, operation_ids },
|
||||||
K::Settings { .. },
|
K::Settings { .. },
|
||||||
) => {
|
) => {
|
||||||
settings_ids.push(id);
|
settings_ids.push(id);
|
||||||
@ -479,7 +479,7 @@ impl BatchKind {
|
|||||||
method,
|
method,
|
||||||
allow_index_creation,
|
allow_index_creation,
|
||||||
primary_key,
|
primary_key,
|
||||||
operation_ids: import_ids,
|
operation_ids,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user