1 /* 2 * Copyright (c) 2021 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 #ifndef SYNC_GENERIC_INTERFACE_H 16 #define SYNC_GENERIC_INTERFACE_H 17 18 #include "isync_interface.h" 19 #include "single_ver_kv_entry.h" 20 #include "query_object.h" 21 22 namespace DistributedDB { 23 class SyncGenericInterface : public ISyncInterface { 24 public: 25 // Constructor/Destructor. 26 SyncGenericInterface() = default; 27 ~SyncGenericInterface() override = default; 28 GetSyncData(Timestamp begin,Timestamp end,std::vector<DataItem> & dataItems,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)29 virtual int GetSyncData(Timestamp begin, Timestamp end, std::vector<DataItem> &dataItems, 30 ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const 31 { 32 LOGE("GetSyncData not support!"); 33 return -E_NOT_SUPPORT; 34 } 35 36 // Get the data which would be synced to other devices according the timestamp. 37 // if the data size is over than the blockSize, It would alloc one token and assign to continueStmtToken, 38 // it should be released when the read operation terminate. GetSyncData(Timestamp begin,Timestamp end,std::vector<SingleVerKvEntry * > & entries,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)39 virtual int GetSyncData(Timestamp begin, Timestamp end, std::vector<SingleVerKvEntry *> &entries, 40 ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const 41 { 42 LOGE("GetSyncData not support!"); 43 return -E_NOT_SUPPORT; 44 } 45 46 // Get the data which would be synced with query condition GetSyncData(QueryObject & query,const SyncTimeRange & timeRange,const DataSizeSpecInfo & dataSizeInfo,ContinueToken & continueStmtToken,std::vector<SingleVerKvEntry * > & entries)47 virtual int GetSyncData(QueryObject &query, const SyncTimeRange &timeRange, 48 const DataSizeSpecInfo &dataSizeInfo, ContinueToken &continueStmtToken, 49 std::vector<SingleVerKvEntry *> &entries) const 50 { 51 return -E_NOT_SUPPORT; 52 } 53 GetSyncDataNext(std::vector<DataItem> & dataItems,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)54 virtual int GetSyncDataNext(std::vector<DataItem> &dataItems, ContinueToken &continueStmtToken, 55 const DataSizeSpecInfo &dataSizeInfo) const 56 { 57 return -E_NOT_SUPPORT; 58 } 59 GetSyncDataNext(std::vector<SingleVerKvEntry * > & entries,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)60 virtual int GetSyncDataNext(std::vector<SingleVerKvEntry *> &entries, ContinueToken &continueStmtToken, 61 const DataSizeSpecInfo &dataSizeInfo) const 62 { 63 return -E_NOT_SUPPORT; 64 } 65 GetCompressionOption(bool & needCompressOnSync,uint8_t & compressionRate)66 virtual int GetCompressionOption(bool &needCompressOnSync, uint8_t &compressionRate) const 67 { 68 return -E_NOT_SUPPORT; 69 } 70 71 // Release the continue token of getting data. ReleaseContinueToken(ContinueToken & continueStmtToken)72 virtual void ReleaseContinueToken(ContinueToken &continueStmtToken) const 73 { 74 } 75 RemoveDeviceData(const std::string & deviceName,bool isNeedNotify)76 virtual int RemoveDeviceData(const std::string &deviceName, bool isNeedNotify) 77 { 78 return -E_NOT_SUPPORT; 79 } 80 IsReadable()81 virtual bool IsReadable() const 82 { 83 return true; 84 } 85 GetSecurityOption(SecurityOption & option)86 int GetSecurityOption(SecurityOption &option) const override 87 { 88 return -E_NOT_SUPPORT; 89 } 90 NotifyRemotePushFinished(const std::string & targetId)91 virtual void NotifyRemotePushFinished(const std::string &targetId) const 92 { 93 } 94 95 // Get the timestamp when database created or imported GetDatabaseCreateTimestamp(Timestamp & outTime)96 virtual int GetDatabaseCreateTimestamp(Timestamp &outTime) const 97 { 98 return -E_NOT_SUPPORT; 99 } 100 PutSyncDataWithQuery(const QueryObject & query,const std::vector<SingleVerKvEntry * > & entries,const std::string & deviceName)101 virtual int PutSyncDataWithQuery(const QueryObject &query, const std::vector<SingleVerKvEntry *> &entries, 102 const std::string &deviceName) 103 { 104 return -E_NOT_SUPPORT; 105 } 106 CheckAndInitQueryCondition(QueryObject & query)107 virtual int CheckAndInitQueryCondition(QueryObject &query) const 108 { 109 return -E_NOT_SUPPORT; 110 } 111 InterceptData(std::vector<SingleVerKvEntry * > & entries,const std::string & sourceID,const std::string & targetID)112 virtual int InterceptData(std::vector<SingleVerKvEntry *> &entries, const std::string &sourceID, 113 const std::string &targetID) const 114 { 115 return -E_NOT_SUPPORT; 116 } 117 AddSubscribe(const std::string & subscribeId,const QueryObject & query,bool needCacheSubscribe)118 virtual int AddSubscribe(const std::string &subscribeId, const QueryObject &query, bool needCacheSubscribe) 119 { 120 return -E_NOT_SUPPORT; 121 } 122 RemoveSubscribe(const std::string & subscribeId)123 virtual int RemoveSubscribe(const std::string &subscribeId) 124 { 125 return -E_NOT_SUPPORT; 126 } 127 RemoveSubscribe(const std::vector<std::string> & subscribeIds)128 virtual int RemoveSubscribe(const std::vector<std::string> &subscribeIds) 129 { 130 return -E_NOT_SUPPORT; 131 } 132 GetCompressionAlgo(std::set<CompressAlgorithm> & algorithmSet)133 virtual int GetCompressionAlgo(std::set<CompressAlgorithm> &algorithmSet) const 134 { 135 return -E_NOT_SUPPORT; 136 } 137 CheckCompatible(const std::string & schema,uint8_t type)138 virtual bool CheckCompatible(const std::string &schema, uint8_t type) const 139 { 140 return false; 141 } 142 GetDualTupleIdentifier()143 std::vector<uint8_t> GetDualTupleIdentifier() const override 144 { 145 return {}; 146 } 147 }; 148 } 149 #endif // SYNC_GENERIC_INTERFACE_H 150