• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "cloud_force_pull_strategy.h"
16 
17 namespace DistributedDB {
18 
TagSyncDataStatus(bool existInLocal,LogInfo & localInfo,LogInfo & cloudInfo,std::set<Key> & deletePrimaryKeySet)19 OpType CloudForcePullStrategy::TagSyncDataStatus(bool existInLocal, LogInfo &localInfo, LogInfo &cloudInfo,
20     std::set<Key> &deletePrimaryKeySet)
21 {
22     if (existInLocal) {
23         if (!IsDelete(localInfo) && IsDelete(cloudInfo)) {
24             (void)deletePrimaryKeySet.insert(localInfo.hashKey);
25             return OpType::DELETE;
26         } else if (IsDelete(cloudInfo)) {
27             return OpType::UPDATE_TIMESTAMP;
28         }
29         if (IsDelete(localInfo) || deletePrimaryKeySet.find(localInfo.hashKey) != deletePrimaryKeySet.end()) {
30             return OpType::INSERT;
31         }
32         return OpType::UPDATE;
33     }
34     bool gidEmpty = localInfo.cloudGid.empty();
35     if (IsDelete(cloudInfo)) {
36         return gidEmpty ? OpType::NOT_HANDLE : OpType::DELETE;
37     }
38     return gidEmpty ? OpType::INSERT : OpType::UPDATE;
39 }
40 
JudgeUpdateCursor()41 bool CloudForcePullStrategy::JudgeUpdateCursor()
42 {
43     return true;
44 }
45 
JudgeUpload()46 bool CloudForcePullStrategy::JudgeUpload()
47 {
48     return false;
49 }
50 }