feat(server): Convert DbSlice's AddOr* to return AutoUpdater (#2290)

* fix(server): Use AutoUpdater with AddOr* methods

* Remove explicit calls

* `operator=`

* return *this

* PostUpdate twice

* exp it

* bitops

* remove explicit `Run()`

* Explicitly `delete` copy ops

* Remove `AddOrSkip()`
This commit is contained in:
Shahar Mike 2023-12-17 15:00:10 +02:00 committed by GitHub
parent aaf01d4244
commit dcedd1645e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 208 additions and 245 deletions

View file

@ -52,16 +52,13 @@ inline OpStatus JsonReplaceVerifyNoOp(JsonType&) {
void SetJson(const OpArgs& op_args, string_view key, JsonType&& value) {
auto& db_slice = op_args.shard->db_slice();
DbIndex db_index = op_args.db_cntx.db_index;
auto [it_output, added] = db_slice.AddOrFind(op_args.db_cntx, key);
auto res = db_slice.AddOrFind(op_args.db_cntx, key);
op_args.shard->search_indices()->RemoveDoc(key, op_args.db_cntx, it_output->second);
db_slice.PreUpdate(db_index, it_output);
op_args.shard->search_indices()->RemoveDoc(key, op_args.db_cntx, res.it->second);
it_output->second.SetJson(std::move(value));
res.it->second.SetJson(std::move(value));
db_slice.PostUpdate(db_index, it_output, key);
op_args.shard->search_indices()->AddDoc(key, op_args.db_cntx, it_output->second);
op_args.shard->search_indices()->AddDoc(key, op_args.db_cntx, res.it->second);
}
string JsonTypeToName(const JsonType& val) {