cyq пре 4 месеци
родитељ
комит
c2b62825d1
4 измењених фајлова са 48 додато и 0 уклоњено
  1. +11
    -0
      fielddb/field_db.cpp
  2. +4
    -0
      fielddb/field_db.h
  3. +13
    -0
      fielddb/request.cpp
  4. +20
    -0
      fielddb/request.h

+ 11
- 0
fielddb/field_db.cpp Прегледај датотеку

@ -382,6 +382,17 @@ void FieldDB::ReleaseSnapshot(const Snapshot *snapshot) {
kvDB_->ReleaseSnapshot(snapshot);
}
const XSnapshot * FieldDB::GetXSnapshot() {
SnapshotReq req(&mutex_);
HandleRequest(req, WriteOptions());
return req.xSnapshot;
}
void FieldDB::ReleaseXSnapshot(const XSnapshot *xsnapshot) {
kvDB_->ReleaseSnapshot(xsnapshot->kv_snapshot);
indexDB_->ReleaseSnapshot(xsnapshot->index_snapshot);
}
bool FieldDB::GetProperty(const Slice &property, std::string *value) {
return kvDB_->GetProperty(property, value) | indexDB_->GetProperty(property, value);
}

+ 4
- 0
fielddb/field_db.h Прегледај датотеку

@ -35,6 +35,7 @@ public:
friend class iDeleteReq;
friend class DeleteReq;
friend class BatchReq;
friend class SnapshotReq;
//FieldDB *db = new FieldDB()openDB *db
FieldDB() : indexDB_(nullptr), kvDB_(nullptr), metaDB_(nullptr) {};
@ -60,6 +61,9 @@ public:
//
IndexStatus GetIndexStatus(const std::string &fieldName);
const XSnapshot* GetXSnapshot();
void ReleaseXSnapshot(const XSnapshot* xsnapshot);
static Status OpenFieldDB(Options& options,const std::string& name,FieldDB** dbptr);
private:

+ 13
- 0
fielddb/request.cpp Прегледај датотеку

@ -432,5 +432,18 @@ void BatchReq::ConstructBatch(WriteBatch &KVBatch,WriteBatch &IndexBatch,
//DB->construct_BatchReq_elapsed += DB->env_->NowMicros() - start_;
}
void SnapshotReq::Prepare(FieldDB *DB) {
DB->index_mu.AssertHeld();
for(auto [_,pair] : DB->index_) {
auto [status,req] = pair;
if(status == Creating || status == Deleting) {
req->PendReq(this);
return;
}
}
xSnapshot = new XSnapshot(DB->kvDB_->GetSnapshot(),DB->indexDB_->GetSnapshot());
done = true;
}
} // namespace fielddb

+ 20
- 0
fielddb/request.h Прегледај датотеку

@ -1,5 +1,6 @@
#include <deque>
#include <string>
#include "leveldb/db.h"
#include "leveldb/slice.h"
#include "leveldb/status.h"
#include "leveldb/write_batch.h"
@ -164,6 +165,25 @@ public:
// std::deque<FieldArray> fa_buf;
};
class SnapshotReq;
class XSnapshot {
friend class SnapshotReq;
public:
XSnapshot(const Snapshot *kv,const Snapshot *index)
: kv_snapshot(kv), index_snapshot(index) {}
const leveldb::Snapshot *kv_snapshot;
const leveldb::Snapshot *index_snapshot;
};
class SnapshotReq : public Request {
public:
SnapshotReq(port::Mutex *mu):Request(iCreateReq_t, mu) { };
void Prepare(FieldDB *DB);
XSnapshot *xSnapshot;
};
}
#endif

||||||
x
 
000:0
Loading…
Откажи
Сачувај