/Users/deen/code/yugabyte-db/src/yb/common/ql_resultset.cc
Line | Count | Source (jump to first uncovered line) |
1 | | //-------------------------------------------------------------------------------------------------- |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | //-------------------------------------------------------------------------------------------------- |
4 | | #include "yb/common/ql_resultset.h" |
5 | | |
6 | | #include "yb/common/ql_protocol.pb.h" |
7 | | #include "yb/common/ql_protocol_util.h" |
8 | | #include "yb/common/ql_value.h" |
9 | | |
10 | | namespace yb { |
11 | | // TODO(neil) All QL classes in "yb/common" needs to be group under a namespace. Doing that would |
12 | | // result in a number of code changes, so I'll leave this till next diff. |
13 | | // namespace yqlapi |
14 | | |
15 | | //-------------------------------------------------------------------------------------------------- |
16 | | |
17 | | QLRSRowDesc::RSColDesc::RSColDesc(const QLRSColDescPB& desc_pb) |
18 | 13.1M | : name_(desc_pb.name()), ql_type_(QLType::FromQLTypePB(desc_pb.ql_type())) {} |
19 | | |
20 | 3.93M | QLRSRowDesc::QLRSRowDesc(const QLRSRowDescPB& desc_pb) { |
21 | 3.93M | rscol_descs_.reserve(desc_pb.rscol_descs().size()); |
22 | 13.1M | for (const auto& rscol_desc_pb : desc_pb.rscol_descs()) { |
23 | 13.1M | rscol_descs_.emplace_back(rscol_desc_pb); |
24 | 13.1M | } |
25 | 3.93M | } |
26 | | |
27 | 3.92M | QLRSRowDesc::~QLRSRowDesc() { |
28 | 3.92M | } |
29 | | |
30 | | //-------------------------------------------------------------------------------------------------- |
31 | | |
32 | | QLResultSet::QLResultSet(const QLRSRowDesc* rsrow_desc, faststring* rows_data) |
33 | 3.94M | : rsrow_desc_(rsrow_desc), rows_data_(rows_data) { |
34 | 3.94M | CQLEncodeLength(0, rows_data_); |
35 | 3.94M | } |
36 | | |
37 | 3.92M | QLResultSet::~QLResultSet() { |
38 | 3.92M | } |
39 | | |
40 | 7.39M | void QLResultSet::AllocateRow() { |
41 | 7.39M | CQLEncodeLength(CQLDecodeLength(rows_data_->data()) + 1, rows_data_->data()); |
42 | 7.39M | } |
43 | | |
44 | 0 | void QLResultSet::AppendColumn(const size_t index, const QLValue& value) { |
45 | 0 | value.Serialize(rsrow_desc_->rscol_descs()[index].ql_type(), YQL_CLIENT_CQL, rows_data_); |
46 | 0 | } |
47 | | |
48 | 34.8M | void QLResultSet::AppendColumn(const size_t index, const QLValuePB& value) { |
49 | 34.8M | QLValue::Serialize( |
50 | 34.8M | rsrow_desc_->rscol_descs()[index].ql_type(), YQL_CLIENT_CQL, value, rows_data_); |
51 | 34.8M | } |
52 | | |
53 | 26.9M | size_t QLResultSet::rsrow_count() const { |
54 | 26.9M | return CQLDecodeLength(rows_data_->data()); |
55 | 26.9M | } |
56 | | |
57 | | } // namespace yb |