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_push_strategy.h"
16
17 namespace DistributedDB {
18 const std::string cloud_device_name = "cloud";
TagSyncDataStatus(bool existInLocal,LogInfo & localInfo,LogInfo & cloudInfo,std::set<Key> & deletePrimaryKeySet)19 OpType CloudForcePushStrategy::TagSyncDataStatus(bool existInLocal, LogInfo &localInfo, LogInfo &cloudInfo,
20 std::set<Key> &deletePrimaryKeySet)
21 {
22 (void)deletePrimaryKeySet;
23 bool isCloudDelete = IsDelete(cloudInfo);
24 if (!existInLocal) {
25 return OpType::NOT_HANDLE;
26 }
27
28 if (localInfo.cloudGid.empty()) {
29 // when cloud data is deleted, we think it is different data
30 return isCloudDelete ? OpType::NOT_HANDLE : OpType::ONLY_UPDATE_GID;
31 }
32
33 if (isCloudDelete) {
34 return OpType::CLEAR_GID;
35 }
36 if (localInfo.device == cloud_device_name && localInfo.timestamp == cloudInfo.timestamp) {
37 return OpType::SET_CLOUD_FORCE_PUSH_FLAG_ONE;
38 }
39 if (localInfo.device == cloud_device_name && localInfo.timestamp != cloudInfo.timestamp) {
40 return OpType::SET_CLOUD_FORCE_PUSH_FLAG_ZERO;
41 }
42 return OpType::NOT_HANDLE;
43 }
44
JudgeUpdateCursor()45 bool CloudForcePushStrategy::JudgeUpdateCursor()
46 {
47 return false;
48 }
49
JudgeUpload()50 bool CloudForcePushStrategy::JudgeUpload()
51 {
52 return true;
53 }
54 }