/Users/deen/code/yugabyte-db/src/yb/common/row_mark.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 | | #ifndef YB_COMMON_ROW_MARK_H |
15 | | #define YB_COMMON_ROW_MARK_H |
16 | | |
17 | | #include <glog/logging.h> |
18 | | |
19 | | #include "yb/common/transaction.pb.h" |
20 | | |
21 | | namespace yb { |
22 | | |
23 | | template <typename PB> |
24 | 15.6M | RowMarkType GetRowMarkTypeFromPB(const PB& pb) { |
25 | 15.6M | if (pb.has_row_mark_type()) { |
26 | 76.5k | if (IsValidRowMarkType(pb.row_mark_type())76.4k ) { |
27 | 76.5k | return pb.row_mark_type(); |
28 | 18.4E | } else { |
29 | | // We shouldn't get here because other row lock types are disabled at the postgres level. |
30 | 18.4E | LOG(DFATAL) << "Unsupported row lock of type " << RowMarkType_Name(pb.row_mark_type()); |
31 | 18.4E | } |
32 | 76.4k | } |
33 | 15.6M | return RowMarkType::ROW_MARK_ABSENT; |
34 | 15.6M | } yb::RowMarkType yb::GetRowMarkTypeFromPB<yb::PgsqlReadRequestPB>(yb::PgsqlReadRequestPB const&) Line | Count | Source | 24 | 9.14M | RowMarkType GetRowMarkTypeFromPB(const PB& pb) { | 25 | 9.14M | if (pb.has_row_mark_type()) { | 26 | 31.0k | if (IsValidRowMarkType(pb.row_mark_type())31.0k ) { | 27 | 31.0k | return pb.row_mark_type(); | 28 | 18.4E | } else { | 29 | | // We shouldn't get here because other row lock types are disabled at the postgres level. | 30 | 18.4E | LOG(DFATAL) << "Unsupported row lock of type " << RowMarkType_Name(pb.row_mark_type()); | 31 | 18.4E | } | 32 | 31.0k | } | 33 | 9.11M | return RowMarkType::ROW_MARK_ABSENT; | 34 | 9.14M | } |
yb::RowMarkType yb::GetRowMarkTypeFromPB<yb::docdb::KeyValueWriteBatchPB>(yb::docdb::KeyValueWriteBatchPB const&) Line | Count | Source | 24 | 6.53M | RowMarkType GetRowMarkTypeFromPB(const PB& pb) { | 25 | 6.53M | if (pb.has_row_mark_type()) { | 26 | 45.4k | if (IsValidRowMarkType(pb.row_mark_type())45.4k ) { | 27 | 45.4k | return pb.row_mark_type(); | 28 | 18.4E | } else { | 29 | | // We shouldn't get here because other row lock types are disabled at the postgres level. | 30 | 18.4E | LOG(DFATAL) << "Unsupported row lock of type " << RowMarkType_Name(pb.row_mark_type()); | 31 | 18.4E | } | 32 | 45.4k | } | 33 | 6.49M | return RowMarkType::ROW_MARK_ABSENT; | 34 | 6.53M | } |
|
35 | | |
36 | | // Get the most restrictive row mark type from a list of row mark types. |
37 | | RowMarkType GetStrongestRowMarkType(std::initializer_list<RowMarkType> row_mark_types); |
38 | | |
39 | | // Determine whether a row mark type is valid. |
40 | | bool IsValidRowMarkType(RowMarkType row_mark_type); |
41 | | |
42 | | /* |
43 | | * Returns whether an operation with this row mark should try to use a higher priority txn. |
44 | | * Currently txn layer will use a best-effort approach, by setting the txn priority to highest if |
45 | | * this is a new txn (first operation within a transaction). |
46 | | */ |
47 | | bool RowMarkNeedsHigherPriority(RowMarkType row_mark_type); |
48 | | |
49 | | } // namespace yb |
50 | | |
51 | | #endif // YB_COMMON_ROW_MARK_H |