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_H
17 #define RELATIONAL_ROW_DATA_H
18 
19 #include "parcel.h"
20 #include "db_types.h"
21 
22 namespace DistributedDB {
23 class RelationalRowData {
24 public:
25     RelationalRowData() = default;
26     virtual ~RelationalRowData() = default;
27 
28     virtual std::size_t GetColSize() = 0;
29 
30     virtual int CalcLength() const = 0;
31     virtual int Serialize(Parcel &parcel) const = 0;
32     virtual int DeSerialize(Parcel &parcel) = 0;
33 
34     virtual int GetType(int index, StorageType &type) const = 0;
35     virtual int Get(int index, int64_t &value) const = 0;
36     virtual int Get(int index, double &value) const = 0;
37     virtual int Get(int index, std::string &value) const = 0;
38     virtual int Get(int index, std::vector<uint8_t> &value) const = 0;
39 
Release(std::vector<RelationalRowData * > & entries)40     static void Release(std::vector<RelationalRowData *> &entries)
41     {
42         for (auto &entry : entries) {
43             delete entry;
44             entry = nullptr;
45         }
46         entries.clear();
47     };
48 };
49 }  // namespace DistributedDB
50 #endif  // RELATIONAL_ROW_DATA_H