• 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 RELATIONAL_DB_SYNC_INTERFACE_H
16 #define RELATIONAL_DB_SYNC_INTERFACE_H
17 #ifdef RELATIONAL_STORE
18 
19 #include "prepared_stmt.h"
20 #include "query_sync_object.h"
21 #include "relationaldb_properties.h"
22 #include "relational_row_data_set.h"
23 #include "relational_schema_object.h"
24 #include "relationaldb_properties.h"
25 #include "single_ver_kv_entry.h"
26 #include "sync_generic_interface.h"
27 #include "schema_negotiate.h"
28 
29 namespace DistributedDB {
30 class RelationalDBSyncInterface : public SyncGenericInterface {
31 public:
~RelationalDBSyncInterface()32     ~RelationalDBSyncInterface() override {};
33 
34     virtual RelationalSchemaObject GetSchemaInfo() const = 0;
35 
36     // Get batch meta data associated with the given key.
37     virtual int GetBatchMetaData(const std::vector<Key> &keys, std::vector<Entry> &entries) const = 0;
38     // Put batch meta data as a key-value entry vector
39     virtual int PutBatchMetaData(std::vector<Entry> &entries) = 0;
40 
41     virtual std::vector<QuerySyncObject> GetTablesQuery() = 0;
42 
43     virtual int LocalDataChanged(int notifyEvent, std::vector<QuerySyncObject> &queryObj) = 0;
44 
45     virtual int CreateDistributedDeviceTable(const std::string &device, const RelationalSyncStrategy &syncStrategy) = 0;
46 
47     virtual int RegisterSchemaChangedCallback(const std::function<void()> &callback) = 0;
48 
49     using ISyncInterface::GetMaxTimestamp;
50     virtual int GetMaxTimestamp(const std::string &tableName, Timestamp &timestamp) const = 0;
51 
52     // return OK, when query finished. token will be set NULL; when query unfinished. token must not be null.
53     // return other errCode, some wrong, token will be set NULL.
54     virtual int ExecuteQuery(const PreparedStmt &prepStmt, size_t packetSize, RelationalRowDataSet &data,
55         ContinueToken &token) const = 0;
56 
57     virtual const RelationalDBProperties &GetRelationalDbProperties() const = 0;
58 
59     virtual void ReleaseRemoteQueryContinueToken(ContinueToken &token) const = 0;
60 };
61 }
62 #endif // RELATIONAL_STORE
63 #endif