YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/common/column_id.cc
Line
Count
Source (jump to first uncovered line)
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
#include "yb/common/column_id.h"
14
15
#include "yb/util/status.h"
16
#include "yb/util/status_format.h"
17
#include "yb/util/status_log.h"
18
19
namespace yb {
20
21
223M
ColumnId::ColumnId(ColumnIdRep t) : t_(t) {
22
223M
  DCHECK_GE(t, 0);
23
223M
}
24
25
39.9M
ColumnId& ColumnId::operator=(const ColumnIdRep& rhs) {
26
39.9M
  DCHECK_GE(rhs, 0);
27
39.9M
  t_ = rhs;
28
39.9M
  return *this;
29
39.9M
}
30
31
487M
Status ColumnId::FromInt64(int64_t value, ColumnId *column_id) {
32
487M
  if (
value > std::numeric_limits<ColumnIdRep>::max()487M
|| value < 0) {
33
0
    return STATUS_FORMAT(Corruption, "$0 not valid for column id representation", value);
34
0
  }
35
487M
  column_id->t_ = static_cast<ColumnIdRep>(value);
36
487M
  return Status::OK();
37
487M
}
38
39
0
uint64_t ColumnId::ToUint64() const {
40
0
  DCHECK_GE(t_, 0);
41
0
  return static_cast<uint64_t>(t_);
42
0
}
43
44
2.15k
std::ostream& operator<<(std::ostream& os, ColumnId column_id) {
45
2.15k
  return os << column_id.rep();
46
2.15k
}
47
48
}  // namespace yb