YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/yql/pggate/pg_table.cc
Line
Count
Source
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#include "yb/yql/pggate/pg_table.h"
15
16
#include "yb/util/result.h"
17
18
#include "yb/yql/pggate/pg_tabledesc.h"
19
20
namespace yb {
21
namespace pggate {
22
23
PgTable::PgTable(const PgTableDescPtr& desc)
24
9.72M
    : desc_(desc), columns_(std::make_shared<std::vector<PgColumn>>()) {
25
9.72M
  if (!desc_) {
26
461k
    return;
27
461k
  }
28
9.25M
  size_t num_columns = desc_->num_columns();
29
9.25M
  columns_->reserve(num_columns + 1);
30
64.2M
  for (size_t i = 0; i != num_columns; 
++i55.0M
) {
31
55.0M
    columns_->emplace_back(desc->schema(), i);
32
55.0M
  }
33
9.25M
  columns_->emplace_back(desc_->schema(), num_columns);
34
9.25M
}
35
36
54.6M
Result<PgColumn&> PgTable::ColumnForAttr(int attr_num) {
37
54.6M
  return (*columns_)[
VERIFY_RESULT54.6M
(desc_->FindColumn(attr_num))]54.6M
;
38
54.6M
}
39
40
19.9M
PgColumn& PgTable::ColumnForIndex(size_t index) {
41
19.9M
  CHECK_LT(index + 1, columns_->size());
42
19.9M
  return (*columns_)[index];
43
19.9M
}
44
45
}  // namespace pggate
46
}  // namespace yb