Explorar el Código

iDeleteReq的prepare

gyf
cyq hace 8 meses
padre
commit
d30aaecf56
Se han modificado 2 ficheros con 9 adiciones y 1 borrados
  1. +1
    -1
      fielddb/field_db.cpp
  2. +8
    -0
      fielddb/request.cpp

+ 1
- 1
fielddb/field_db.cpp Ver fichero

@ -229,7 +229,7 @@ Status FieldDB::CreateIndexOnField(const std::string& field_name) {
std::string Field = field_name; std::string Field = field_name;
iCreateReq req(&Field,&mutex_); iCreateReq req(&Field,&mutex_);
HandleRequest(req); HandleRequest(req);
//如果已经存在索引,那么可以直接返回
//如果已经存在索引,那么直接返回
if(req.Existed) { if(req.Existed) {
return req.s; return req.s;
} }

+ 8
- 0
fielddb/request.cpp Ver fichero

@ -141,6 +141,14 @@ void iDeleteReq::Prepare(FieldDB *DB) {
s = Status::OK(); s = Status::OK();
return ; return ;
} }
auto [istatus,parent] = DB->index_[*Field];
if(istatus == FieldDB::Exist) {
DB->index_[*Field] = {FieldDB::Creating,this};
done = true;
} else {
//如果正在创建或者删除,那么pend到对应的请求上
parent->PendReq(this);
}
} }
void iDeleteReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch, void iDeleteReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,

Cargando…
Cancelar
Guardar