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 
16 #ifndef RELATIONAL_ROW_DATA_SET_H
17 #define RELATIONAL_ROW_DATA_SET_H
18 
19 #include "parcel.h"
20 #include "relational_row_data.h"
21 
22 namespace DistributedDB {
23 class RelationalRowDataSet {
24 public:
25     RelationalRowDataSet();
26     virtual ~RelationalRowDataSet();
27 
28     RelationalRowDataSet(const RelationalRowDataSet &) = delete;
29     RelationalRowDataSet &operator=(const RelationalRowDataSet &) = delete;
30 
31     RelationalRowDataSet &operator=(RelationalRowDataSet &&) noexcept;
32 
33     int GetSize() const;
34 
35     int CalcLength() const;
36 
37     int Serialize(Parcel &parcel) const;
38 
39     int DeSerialize(Parcel &parcel);
40 
41     void SetColNames(std::vector<std::string> &&colNames);
42 
43     void SetRowData(std::vector<RelationalRowData *> &&data);
44 
45     int Insert(RelationalRowData *rowData);
46 
47     void Clear();
48 
49     const std::vector<std::string> &GetColNames() const;
50 
51     const RelationalRowData *Get(int index) const;
52 
53     int Merge(RelationalRowDataSet &&rowDataSet);
54 
55 private:
56     std::vector<std::string> colNames_;
57     std::vector<RelationalRowData *> data_;
58     size_t serialLength_;
59 };
60 }  // namespace DistributedDB
61 #endif  // RELATIONAL_ROW_DATA_SET_H