YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/ptree/column_desc.h
Line
Count
Source
1
//--------------------------------------------------------------------------------------------------
2
// Copyright (c) YugaByte, Inc.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
// in compliance with the License.  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 distributed under the License
10
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
// or implied.  See the License for the specific language governing permissions and limitations
12
// under the License.
13
//
14
//
15
// Structure definitions for column descriptor of a table.
16
//--------------------------------------------------------------------------------------------------
17
18
#ifndef YB_YQL_CQL_QL_PTREE_COLUMN_DESC_H_
19
#define YB_YQL_CQL_QL_PTREE_COLUMN_DESC_H_
20
21
#include "yb/client/schema.h"
22
23
namespace yb {
24
namespace ql {
25
26
//--------------------------------------------------------------------------------------------------
27
28
// This class can be used to describe any reference of a column.
29
class ColumnDesc {
30
 public:
31
  ColumnDesc(const size_t index,
32
             const int id,
33
             const std::string& name,
34
             const bool is_hash,
35
             const bool is_primary,
36
             const bool is_static,
37
             const bool is_counter,
38
             const std::shared_ptr<QLType>& ql_type,
39
             const InternalType internal_type,
40
             bool has_mangled_name = false)
41
      : index_(index),
42
        id_(id),
43
        name_(name),
44
        is_hash_(is_hash),
45
        is_primary_(is_primary),
46
        is_static_(is_static),
47
        is_counter_(is_counter),
48
        ql_type_(ql_type),
49
        internal_type_(internal_type),
50
3.37M
        has_mangled_name_(has_mangled_name) {
51
3.37M
  }
52
53
478k
  size_t index() const {
54
478k
    return index_;
55
478k
  }
56
57
52.7M
  int id() const {
58
52.7M
    return id_;
59
52.7M
  }
60
61
  // User name (not mangled).
62
  std::string name() const;
63
64
  // Index column name (mangled).
65
  std::string MangledName() const;
66
67
  // Return the name that is kept in catalog.
68
  // - For Catalog::Table, user-defined-column name is not mangled.
69
  // - For Catalong::IndexTable, expression-column name (ColumnRef, JsonRef, ...) is mangled.
70
315
  std::string MetadataName() const {
71
315
    return name_;
72
315
  }
73
74
13.5M
  bool is_hash() const {
75
13.5M
    return is_hash_;
76
13.5M
  }
77
78
16.2M
  bool is_primary() const {
79
16.2M
    return is_primary_;
80
16.2M
  }
81
82
2.44M
  bool is_static() const {
83
2.44M
    return is_static_;
84
2.44M
  }
85
86
6.72k
  bool is_counter() const {
87
6.72k
    return is_counter_;
88
6.72k
  }
89
90
25.9M
  const std::shared_ptr<QLType>& ql_type() const {
91
25.9M
    return ql_type_;
92
25.9M
  }
93
94
862k
  InternalType internal_type() const {
95
862k
    return internal_type_;
96
862k
  }
97
98
713
  void set_id(int id) {
99
713
    id_ = id;
100
713
  }
101
102
 private:
103
  size_t index_;
104
  int id_ = -1;
105
  std::string name_;
106
  bool is_hash_ = false;
107
  bool is_primary_ = false;
108
  bool is_static_ = false;
109
  bool is_counter_ = false;
110
  std::shared_ptr<QLType> ql_type_;
111
  InternalType internal_type_ = InternalType::VALUE_NOT_SET;
112
  // Depending on whether the table object is user-table, old index-table, or new index-table, the
113
  // column name might or might not be mangled. The member "has_mangled_name_" is added so that we
114
  // don't have to concern about which object this column belongs to.
115
  bool has_mangled_name_;
116
};
117
118
}  // namespace ql
119
}  // namespace yb
120
121
#endif  // YB_YQL_CQL_QL_PTREE_COLUMN_DESC_H_