1 /*
2  * Copyright (c) 2022 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_REMOTE_QUERY_CONTINUE_TOKEN_H
16 #define RELATIONAL_REMOTE_QUERY_CONTINUE_TOKEN_H
17 #ifdef RELATIONAL_STORE
18 #include <string>
19 #include <vector>
20 #include "relational_row_data_set.h"
21 #include "relational_row_data.h"
22 
23 namespace DistributedDB {
24 class RelationalRemoteQueryContinueToken {
25 public:
26     RelationalRemoteQueryContinueToken(std::vector<std::string> &&colNames, std::vector<RelationalRowData *> &&data);
27     ~RelationalRemoteQueryContinueToken();
28 
29     // Check the magic number at the beginning and end of the RelationalRemoteQueryContinueToken.
30     bool CheckValid() const;
31 
32     // if succeed, return E_UNFINISHED, E_OK; if error happened, return other errCode
33     int GetData(int packetSize, RelationalRowDataSet &dataSet);
34 
35 private:
36     static const unsigned int MAGIC_BEGIN = 0x600D0AC7;  // for token guard
37     static const unsigned int MAGIC_END = 0x0AC7600D;    // for token guard
38     unsigned int magicBegin_ = MAGIC_BEGIN;
39     std::vector<std::string> colNames_;
40     std::vector<RelationalRowData *> data_;
41     unsigned int magicEnd_ = MAGIC_END;
42 };
43 }  // namespace DistributedDB
44 #endif  // RELATIONAL_STORE
45 #endif  // RELATIONAL_REMOTE_QUERY_CONTINUE_TOKEN_H