comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5757:5463c3ae3235 large-queries

refactored extended /changes
author Alain Mazy <am@orthanc.team>
date Thu, 05 Sep 2024 18:21:56 +0200
parents 3765085693e5
children ca06dde85358
comparison
equal deleted inserted replaced
5663:3765085693e5 5757:5463c3ae3235
279 last = log.back().GetSeq(); 279 last = log.back().GetSeq();
280 } 280 }
281 } 281 }
282 282
283 target["Last"] = static_cast<int>(last); 283 target["Last"] = static_cast<int>(last);
284 if (!log.empty())
285 {
286 target["First"] = static_cast<int>(log.front().GetSeq());
287 }
284 } 288 }
285 289
286 290
287 static void CopyListToVector(std::vector<std::string>& target, 291 static void CopyListToVector(std::vector<std::string>& target,
288 const std::list<std::string>& source) 292 const std::list<std::string>& source)
1220 Operations operations; 1224 Operations operations;
1221 operations.Apply(*this, target, since, maxResults); 1225 operations.Apply(*this, target, since, maxResults);
1222 } 1226 }
1223 1227
1224 1228
1225 void StatelessDatabaseOperations::GetChanges2(Json::Value& target, 1229 void StatelessDatabaseOperations::GetChangesExtended(Json::Value& target,
1226 int64_t since, 1230 int64_t since,
1227 int64_t to, 1231 int64_t to,
1228 unsigned int maxResults, 1232 unsigned int maxResults,
1229 ChangeType changeType) 1233 ChangeType changeType)
1230 { 1234 {
1231 class Operations : public ReadOnlyOperationsT5<Json::Value&, int64_t, int64_t, unsigned int, unsigned int> 1235 class Operations : public ReadOnlyOperationsT5<Json::Value&, int64_t, int64_t, unsigned int, unsigned int>
1232 { 1236 {
1233 public: 1237 public:
1234 virtual void ApplyTuple(ReadOnlyTransaction& transaction, 1238 virtual void ApplyTuple(ReadOnlyTransaction& transaction,
1237 std::list<ServerIndexChange> changes; 1241 std::list<ServerIndexChange> changes;
1238 bool done; 1242 bool done;
1239 bool hasLast = false; 1243 bool hasLast = false;
1240 int64_t last = 0; 1244 int64_t last = 0;
1241 1245
1242 transaction.GetChanges2(changes, done, tuple.get<1>(), tuple.get<2>(), tuple.get<3>(), static_cast<ChangeType>(tuple.get<4>())); 1246 transaction.GetChangesExtended(changes, done, tuple.get<1>(), tuple.get<2>(), tuple.get<3>(), static_cast<ChangeType>(tuple.get<4>()));
1243 if (changes.empty()) 1247 if (changes.empty())
1244 { 1248 {
1245 last = transaction.GetLastChangeIndex(); 1249 last = transaction.GetLastChangeIndex();
1246 hasLast = true; 1250 hasLast = true;
1247 } 1251 }
3840 { 3844 {
3841 boost::shared_lock<boost::shared_mutex> lock(mutex_); 3845 boost::shared_lock<boost::shared_mutex> lock(mutex_);
3842 return db_.GetDatabaseCapabilities().HasLabelsSupport(); 3846 return db_.GetDatabaseCapabilities().HasLabelsSupport();
3843 } 3847 }
3844 3848
3845 bool StatelessDatabaseOperations::HasExtendedApiV1() 3849 bool StatelessDatabaseOperations::HasExtendedChanges()
3846 { 3850 {
3847 boost::shared_lock<boost::shared_mutex> lock(mutex_); 3851 boost::shared_lock<boost::shared_mutex> lock(mutex_);
3848 return db_.GetDatabaseCapabilities().HasExtendedApiV1(); 3852 return db_.GetDatabaseCapabilities().HasExtendedChanges();
3849 } 3853 }
3850 } 3854 }