/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 | 91.1M | ColumnId::ColumnId(ColumnIdRep t) : t_(t) { |
22 | 91.1M | DCHECK_GE(t, 0); |
23 | 91.1M | } |
24 | | |
25 | 17.4M | ColumnId& ColumnId::operator=(const ColumnIdRep& rhs) { |
26 | 17.4M | DCHECK_GE(rhs, 0); |
27 | 17.4M | t_ = rhs; |
28 | 17.4M | return *this; |
29 | 17.4M | } |
30 | | |
31 | 148M | Status ColumnId::FromInt64(int64_t value, ColumnId *column_id) { |
32 | 148M | if (value > std::numeric_limits<ColumnIdRep>::max() || value < 0) { |
33 | 0 | return STATUS_FORMAT(Corruption, "$0 not valid for column id representation", value); |
34 | 0 | } |
35 | 148M | column_id->t_ = static_cast<ColumnIdRep>(value); |
36 | 148M | return Status::OK(); |
37 | 148M | } |
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 | 963 | std::ostream& operator<<(std::ostream& os, ColumnId column_id) { |
45 | 963 | return os << column_id.rep(); |
46 | 963 | } |
47 | | |
48 | | } // namespace yb |