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(RelationalRowDataSet &&) noexcept; 32 RelationalRowDataSet &operator=(RelationalRowDataSet &&) noexcept; 33 34 int GetSize() const; 35 36 int CalcLength() const; 37 38 int Serialize(Parcel &parcel) const; 39 40 int DeSerialize(Parcel &parcel); 41 42 void SetColNames(std::vector<std::string> &&colNames); 43 44 void SetRowData(std::vector<RelationalRowData *> &&data); 45 46 int Insert(RelationalRowData *rowData); 47 48 void Clear(); 49 50 const std::vector<std::string> &GetColNames() const; 51 52 const RelationalRowData *Get(int index) const; 53 54 int Merge(RelationalRowDataSet &&rowDataSet); 55 56 private: 57 std::vector<std::string> colNames_; 58 std::vector<RelationalRowData *> data_; 59 size_t serialLength_; 60 }; 61 } // namespace DistributedDB 62 #endif // RELATIONAL_ROW_DATA_SET_H