diff options
| author | Dan Engelbrecht <[email protected]> | 2024-08-12 10:52:54 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-08-12 10:52:54 +0200 |
| commit | cb9d622042f7f649ae626d5e8237932536fe1725 (patch) | |
| tree | 5cff4a2299c33b5912bb71266f5328703cf84e3b /src/zenserver/projectstore/httpprojectstore.cpp | |
| parent | project/oplog delete improvements (#105) (diff) | |
| download | zen-cb9d622042f7f649ae626d5e8237932536fe1725.tar.xz zen-cb9d622042f7f649ae626d5e8237932536fe1725.zip | |
make oplog lsn unsigned (#107)
* change oplog lsn to uint32
Diffstat (limited to 'src/zenserver/projectstore/httpprojectstore.cpp')
| -rw-r--r-- | src/zenserver/projectstore/httpprojectstore.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/zenserver/projectstore/httpprojectstore.cpp b/src/zenserver/projectstore/httpprojectstore.cpp index 585cee26f..6de91cf94 100644 --- a/src/zenserver/projectstore/httpprojectstore.cpp +++ b/src/zenserver/projectstore/httpprojectstore.cpp @@ -56,7 +56,7 @@ CSVWriteOp(CidStore& CidStore, std::string_view OplogId, bool Details, bool AttachmentDetails, - int LSN, + uint32_t LSN, const Oid& Key, CbObjectView Op, StringBuilderBase& CSVWriter) @@ -103,7 +103,7 @@ namespace { bool Details, bool OpDetails, bool AttachmentDetails, - int LSN, + uint32_t LSN, const Oid& Key, CbObjectView Op, CbObjectWriter& CbWriter) @@ -175,9 +175,10 @@ namespace { { Cbo.BeginArray("ops"); { - Oplog.IterateOplogWithKey([&Cbo, &CidStore, Details, OpDetails, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { - CbWriteOp(CidStore, Details, OpDetails, AttachmentDetails, LSN, Key, Op, Cbo); - }); + Oplog.IterateOplogWithKey( + [&Cbo, &CidStore, Details, OpDetails, AttachmentDetails](uint32_t LSN, const Oid& Key, CbObjectView Op) { + CbWriteOp(CidStore, Details, OpDetails, AttachmentDetails, LSN, Key, Op, Cbo); + }); } Cbo.EndArray(); } @@ -1782,7 +1783,7 @@ HttpProjectService::HandleDetailsRequest(HttpRouterRequest& Req) m_ProjectStore->IterateProjects([&](ProjectStore::Project& Project) { Project.IterateOplogs([&](const RwLock::SharedLockScope&, ProjectStore::Oplog& Oplog) { Oplog.IterateOplogWithKey( - [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { + [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](uint32_t LSN, const Oid& Key, CbObjectView Op) { CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, Key, Op, CSVWriter); }); }); @@ -1837,7 +1838,7 @@ HttpProjectService::HandleProjectDetailsRequest(HttpRouterRequest& Req) FoundProject->IterateOplogs([&](const RwLock::SharedLockScope&, ProjectStore::Oplog& Oplog) { Oplog.IterateOplogWithKey( - [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { + [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](uint32_t LSN, const Oid& Key, CbObjectView Op) { CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, Key, Op, CSVWriter); }); }); @@ -1893,7 +1894,7 @@ HttpProjectService::HandleOplogDetailsRequest(HttpRouterRequest& Req) CSVHeader(Details, AttachmentDetails, CSVWriter); Oplog.IterateOplogWithKey( - [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { + [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](uint32_t LSN, const Oid& Key, CbObjectView Op) { CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, Key, Op, CSVWriter); }); HttpReq.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, CSVWriter.ToView()); @@ -1952,13 +1953,13 @@ HttpProjectService::HandleOplogOpDetailsRequest(HttpRouterRequest& Req) ProjectStore::Project& Project = *FoundProject.Get(); ProjectStore::Oplog& Oplog = *FoundLog; - int LSN = Oplog.GetOpIndexByKey(ObjId); - if (LSN == -1) + std::optional<CbObject> Op = Oplog.GetOpByKey(ObjId); + if (!Op.has_value()) { return HttpReq.WriteResponse(HttpResponseCode::NotFound); } - std::optional<CbObject> Op = Oplog.GetOpByIndex(LSN); - if (!Op.has_value()) + std::optional<uint32_t> LSN = Oplog.GetOpIndexByKey(ObjId); + if (!LSN.has_value()) { return HttpReq.WriteResponse(HttpResponseCode::NotFound); } @@ -1968,7 +1969,7 @@ HttpProjectService::HandleOplogOpDetailsRequest(HttpRouterRequest& Req) ExtendableStringBuilder<4096> CSVWriter; CSVHeader(Details, AttachmentDetails, CSVWriter); - CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, ObjId, Op.value(), CSVWriter); + CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN.value(), ObjId, Op.value(), CSVWriter); HttpReq.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, CSVWriter.ToView()); } else @@ -1976,7 +1977,7 @@ HttpProjectService::HandleOplogOpDetailsRequest(HttpRouterRequest& Req) CbObjectWriter Cbo; Cbo.BeginArray("ops"); { - CbWriteOp(m_CidStore, Details, OpDetails, AttachmentDetails, LSN, ObjId, Op.value(), Cbo); + CbWriteOp(m_CidStore, Details, OpDetails, AttachmentDetails, LSN.value(), ObjId, Op.value(), Cbo); } Cbo.EndArray(); HttpReq.WriteResponse(HttpResponseCode::OK, Cbo.Save()); |