• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "store_types.h"
21 #include "query_object.h"
22 
23 namespace DistributedDB {
24 class SyncGenericInterface : public ISyncInterface {
25 public:
26     // Constructor/Destructor.
27     SyncGenericInterface() = default;
28     ~SyncGenericInterface() override = default;
29 
GetSyncData(Timestamp begin,Timestamp end,std::vector<DataItem> & dataItems,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)30     virtual int GetSyncData(Timestamp begin, Timestamp end, std::vector<DataItem> &dataItems,
31         ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const
32     {
33         LOGE("GetSyncData not support!");
34         return -E_NOT_SUPPORT;
35     }
36 
37     // Get the data which would be synced to other devices according the timestamp.
38     // if the data size is over than the blockSize, It would alloc one token and assign to continueStmtToken,
39     // it should be released when the read operation terminate.
GetSyncData(Timestamp begin,Timestamp end,std::vector<SingleVerKvEntry * > & entries,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)40     virtual int GetSyncData(Timestamp begin, Timestamp end, std::vector<SingleVerKvEntry *> &entries,
41         ContinueToken &continueStmtToken, const DataSizeSpecInfo &dataSizeInfo) const
42     {
43         LOGE("GetSyncData not support!");
44         return -E_NOT_SUPPORT;
45     }
46 
47     // 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)48     virtual int GetSyncData(QueryObject &query, const SyncTimeRange &timeRange,
49         const DataSizeSpecInfo &dataSizeInfo, ContinueToken &continueStmtToken,
50         std::vector<SingleVerKvEntry *> &entries) const
51     {
52         return -E_NOT_SUPPORT;
53     }
54 
GetSyncDataNext(std::vector<DataItem> & dataItems,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)55     virtual int GetSyncDataNext(std::vector<DataItem> &dataItems, ContinueToken &continueStmtToken,
56         const DataSizeSpecInfo &dataSizeInfo) const
57     {
58         return -E_NOT_SUPPORT;
59     }
60 
GetSyncDataNext(std::vector<SingleVerKvEntry * > & entries,ContinueToken & continueStmtToken,const DataSizeSpecInfo & dataSizeInfo)61     virtual int GetSyncDataNext(std::vector<SingleVerKvEntry *> &entries, ContinueToken &continueStmtToken,
62         const DataSizeSpecInfo &dataSizeInfo) const
63     {
64         return -E_NOT_SUPPORT;
65     }
66 
GetUnSyncTotal(Timestamp begin,Timestamp end,uint32_t & total)67     virtual int GetUnSyncTotal(Timestamp begin, Timestamp end, uint32_t &total) const
68     {
69         return -E_NOT_SUPPORT;
70     }
71 
GetUnSyncTotal(QueryObject & query,const SyncTimeRange & timeRange,uint32_t & total)72     virtual int GetUnSyncTotal(QueryObject &query, const SyncTimeRange &timeRange, uint32_t &total) const
73     {
74         return -E_NOT_SUPPORT;
75     }
76 
GetCompressionOption(bool & needCompressOnSync,uint8_t & compressionRate)77     virtual int GetCompressionOption(bool &needCompressOnSync, uint8_t &compressionRate) const
78     {
79         return -E_NOT_SUPPORT;
80     }
81 
82     // Release the continue token of getting data.
ReleaseContinueToken(ContinueToken & continueStmtToken)83     virtual void ReleaseContinueToken(ContinueToken &continueStmtToken) const
84     {
85     }
86 
RemoveDeviceData(const std::string & deviceName,bool isNeedNotify)87     virtual int RemoveDeviceData(const std::string &deviceName, bool isNeedNotify)
88     {
89         return -E_NOT_SUPPORT;
90     }
91 
IsReadable()92     virtual bool IsReadable() const
93     {
94         return true;
95     }
96 
GetSecurityOption(SecurityOption & option)97     int GetSecurityOption(SecurityOption &option) const override
98     {
99         return -E_NOT_SUPPORT;
100     }
101 
NotifyRemotePushFinished(const std::string & targetId)102     virtual void NotifyRemotePushFinished(const std::string &targetId) const
103     {
104     }
105 
106     // Get the timestamp when database created or imported
GetDatabaseCreateTimestamp(Timestamp & outTime)107     virtual int GetDatabaseCreateTimestamp(Timestamp &outTime) const
108     {
109         return -E_NOT_SUPPORT;
110     }
111 
PutSyncDataWithQuery(const QueryObject & query,const std::vector<SingleVerKvEntry * > & entries,const std::string & deviceName)112     virtual int PutSyncDataWithQuery(const QueryObject &query, const std::vector<SingleVerKvEntry *> &entries,
113         const std::string &deviceName)
114     {
115         return -E_NOT_SUPPORT;
116     }
117 
CheckAndInitQueryCondition(QueryObject & query)118     virtual int CheckAndInitQueryCondition(QueryObject &query) const
119     {
120         return -E_NOT_SUPPORT;
121     }
122 
InterceptData(std::vector<SingleVerKvEntry * > & entries,const std::string & sourceID,const std::string & targetID,bool isPush)123     virtual int InterceptData(std::vector<SingleVerKvEntry *> &entries, const std::string &sourceID,
124         const std::string &targetID, bool isPush) const
125     {
126         return -E_NOT_SUPPORT;
127     }
128 
AddSubscribe(const std::string & subscribeId,const QueryObject & query,bool needCacheSubscribe)129     virtual int AddSubscribe(const std::string &subscribeId, const QueryObject &query, bool needCacheSubscribe)
130     {
131         return -E_NOT_SUPPORT;
132     }
133 
RemoveSubscribe(const std::string & subscribeId)134     virtual int RemoveSubscribe(const std::string &subscribeId)
135     {
136         return -E_NOT_SUPPORT;
137     }
138 
RemoveSubscribe(const std::vector<std::string> & subscribeIds)139     virtual int RemoveSubscribe(const std::vector<std::string> &subscribeIds)
140     {
141         return -E_NOT_SUPPORT;
142     }
143 
GetCompressionAlgo(std::set<CompressAlgorithm> & algorithmSet)144     virtual int GetCompressionAlgo(std::set<CompressAlgorithm> &algorithmSet) const
145     {
146         return -E_NOT_SUPPORT;
147     }
148 
CheckCompatible(const std::string & schema,uint8_t type)149     virtual bool CheckCompatible(const std::string &schema, uint8_t type) const
150     {
151         return false;
152     }
153 
GetDualTupleIdentifier()154     std::vector<uint8_t> GetDualTupleIdentifier() const override
155     {
156         return {};
157     }
158 
GetDBInfo(DBInfo & dbInfo)159     virtual void GetDBInfo(DBInfo &dbInfo) const
160     {
161         dbInfo.appId = GetDbProperties().GetStringProp(DBProperties::APP_ID, "");
162         dbInfo.userId = GetDbProperties().GetStringProp(DBProperties::USER_ID, "");
163         dbInfo.storeId = GetDbProperties().GetStringProp(DBProperties::STORE_ID, "");
164     }
165 
IsSupportSubscribe()166     int IsSupportSubscribe() const override
167     {
168         return -E_NOT_SUPPORT;
169     }
170 
TryHandle()171     virtual int TryHandle() const
172     {
173         return E_OK;
174     }
175 };
176 }
177 #endif // SYNC_GENERIC_INTERFACE_H
178