/Users/deen/code/yugabyte-db/src/yb/bfql/bfunc_convert.h
Line | Count | Source (jump to first uncovered line) |
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 | | // This module defines of C++ functions to support "cast" operators. Note that for "cast" operators, |
16 | | // all arguments must of exact types. Type resolution will raise error if an argument type is |
17 | | // only compatible / convertible but not equal. |
18 | | // Example: cast(int64 to string) will accept only int64 and string but not int32 and string. |
19 | | // |
20 | | // The conversion routines can be use for either or both of two different purposes. |
21 | | // - Converting the value from one type to another. |
22 | | // - Converting the value from one data representation to another. |
23 | | // |
24 | | // Once written, this function should not be changed to avoid compatibility issues. That is, |
25 | | // server might runs one version while client use a different version of this function. |
26 | | // |
27 | | // See the header of file "/util/bfql/bfql.h" for overall info. |
28 | | //-------------------------------------------------------------------------------------------------- |
29 | | |
30 | | #ifndef YB_BFQL_BFUNC_CONVERT_H_ |
31 | | #define YB_BFQL_BFUNC_CONVERT_H_ |
32 | | |
33 | | #include <iostream> |
34 | | #include <string> |
35 | | |
36 | | #include "yb/common/ql_datatype.h" |
37 | | #include "yb/common/ql_type.h" |
38 | | |
39 | | #include "yb/gutil/casts.h" |
40 | | #include "yb/gutil/endian.h" |
41 | | #include "yb/gutil/strings/escaping.h" |
42 | | #include "yb/util/date_time.h" |
43 | | #include "yb/util/decimal.h" |
44 | | #include "yb/util/enums.h" |
45 | | #include "yb/util/logging.h" |
46 | | #include "yb/util/net/inetaddress.h" |
47 | | #include "yb/util/status_fwd.h" |
48 | | #include "yb/util/stol_utils.h" |
49 | | #include "yb/util/uuid.h" |
50 | | |
51 | | namespace yb { |
52 | | namespace bfql { |
53 | | |
54 | | static constexpr size_t kSizeBool = 1; |
55 | | static constexpr size_t kSizeTinyInt = 1; |
56 | | static constexpr size_t kSizeSmallInt = 2; |
57 | | static constexpr size_t kSizeInt = 4; |
58 | | static constexpr size_t kSizeBigInt = 8; |
59 | | static constexpr size_t kSizeUuid = 16; |
60 | | static constexpr size_t kByteSize = 8; |
61 | | static constexpr size_t kHexBase = 16; |
62 | | |
63 | | //-------------------------------------------------------------------------------------------------- |
64 | | template<typename SetResult, typename PTypePtr, typename RTypePtr> |
65 | | CHECKED_STATUS SetNumericResult(SetResult set_result, PTypePtr source, DataType target_datatype, |
66 | 29 | RTypePtr target) { |
67 | 29 | DataType source_datatype = InternalToDataType(source->type()); |
68 | 29 | if (!QLType::IsExplicitlyConvertible(target_datatype, source_datatype)) { |
69 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", |
70 | 0 | QLType::ToCQLString(source_datatype), |
71 | 0 | QLType::ToCQLString(target_datatype)); |
72 | 0 | } |
73 | | |
74 | 29 | switch(source->type()) { |
75 | 0 | case InternalType::kInt8Value: |
76 | 0 | RETURN_NOT_OK(set_result(source->int8_value(), target)); |
77 | 0 | break; |
78 | 5 | case InternalType::kInt16Value: |
79 | 5 | RETURN_NOT_OK(set_result(source->int16_value(), target)); |
80 | 5 | break; |
81 | 9 | case InternalType::kInt32Value: |
82 | 9 | RETURN_NOT_OK(set_result(source->int32_value(), target)); |
83 | 9 | break; |
84 | 9 | case InternalType::kInt64Value: |
85 | 7 | RETURN_NOT_OK(set_result(source->int64_value(), target)); |
86 | 7 | break; |
87 | 7 | case InternalType::kFloatValue: |
88 | 4 | RETURN_NOT_OK(set_result(source->float_value(), target)); |
89 | 4 | break; |
90 | 4 | case InternalType::kDoubleValue: |
91 | 4 | RETURN_NOT_OK(set_result(source->double_value(), target)); |
92 | 4 | break; |
93 | 4 | case InternalType::kDecimalValue: { |
94 | 0 | util::Decimal d; |
95 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); |
96 | | |
97 | 0 | if (target_datatype == DataType::FLOAT || target_datatype == DataType::DOUBLE) { |
98 | | // Convert via DOUBLE: |
99 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(d.ToDouble()), target)); |
100 | 0 | } else { // Expected an Integer type |
101 | 0 | RSTATUS_DCHECK(target_datatype == DataType::INT8 || target_datatype == DataType::INT16 |
102 | 0 | || target_datatype == DataType::INT32 || target_datatype == DataType::INT64, |
103 | 0 | InvalidArgument, strings::Substitute("Unexpected target type: ", |
104 | 0 | QLType::ToCQLString(target_datatype))); |
105 | | // Convert via INT64: |
106 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(VERIFY_RESULT(d.ToVarInt()).ToInt64()), target)); |
107 | 0 | } |
108 | 0 | } |
109 | 0 | break; |
110 | 0 | default: |
111 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", |
112 | 29 | QLType::ToCQLString(source_datatype), |
113 | 29 | QLType::ToCQLString(target_datatype)); |
114 | 29 | } |
115 | 29 | return Status::OK(); |
116 | 29 | } Unexecuted instantiation: yb::Status yb::bfql::SetNumericResult<yb::Status (*)(short, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(yb::Status (*)(short, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, yb::DataType, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::SetNumericResult<yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, yb::DataType, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::SetNumericResult<yb::Status (*)(double, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(yb::Status (*)(double, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, yb::DataType, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::SetNumericResult<yb::Status (*)(float, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(yb::Status (*)(float, std::__1::shared_ptr<yb::QLValue>), std::__1::shared_ptr<yb::QLValue>, yb::DataType, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::SetNumericResult<yb::Status (*)(short, yb::QLValue*), yb::QLValue*, yb::QLValue*>(yb::Status (*)(short, yb::QLValue*), yb::QLValue*, yb::DataType, yb::QLValue*) Line | Count | Source | 66 | 7 | RTypePtr target) { | 67 | 7 | DataType source_datatype = InternalToDataType(source->type()); | 68 | 7 | if (!QLType::IsExplicitlyConvertible(target_datatype, source_datatype)) { | 69 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 70 | 0 | QLType::ToCQLString(source_datatype), | 71 | 0 | QLType::ToCQLString(target_datatype)); | 72 | 0 | } | 73 | | | 74 | 7 | switch(source->type()) { | 75 | 0 | case InternalType::kInt8Value: | 76 | 0 | RETURN_NOT_OK(set_result(source->int8_value(), target)); | 77 | 0 | break; | 78 | 1 | case InternalType::kInt16Value: | 79 | 1 | RETURN_NOT_OK(set_result(source->int16_value(), target)); | 80 | 1 | break; | 81 | 2 | case InternalType::kInt32Value: | 82 | 2 | RETURN_NOT_OK(set_result(source->int32_value(), target)); | 83 | 2 | break; | 84 | 2 | case InternalType::kInt64Value: | 85 | 2 | RETURN_NOT_OK(set_result(source->int64_value(), target)); | 86 | 2 | break; | 87 | 2 | case InternalType::kFloatValue: | 88 | 1 | RETURN_NOT_OK(set_result(source->float_value(), target)); | 89 | 1 | break; | 90 | 1 | case InternalType::kDoubleValue: | 91 | 1 | RETURN_NOT_OK(set_result(source->double_value(), target)); | 92 | 1 | break; | 93 | 1 | case InternalType::kDecimalValue: { | 94 | 0 | util::Decimal d; | 95 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); | 96 | | | 97 | 0 | if (target_datatype == DataType::FLOAT || target_datatype == DataType::DOUBLE) { | 98 | | // Convert via DOUBLE: | 99 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(d.ToDouble()), target)); | 100 | 0 | } else { // Expected an Integer type | 101 | 0 | RSTATUS_DCHECK(target_datatype == DataType::INT8 || target_datatype == DataType::INT16 | 102 | 0 | || target_datatype == DataType::INT32 || target_datatype == DataType::INT64, | 103 | 0 | InvalidArgument, strings::Substitute("Unexpected target type: ", | 104 | 0 | QLType::ToCQLString(target_datatype))); | 105 | | // Convert via INT64: | 106 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(VERIFY_RESULT(d.ToVarInt()).ToInt64()), target)); | 107 | 0 | } | 108 | 0 | } | 109 | 0 | break; | 110 | 0 | default: | 111 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 112 | 7 | QLType::ToCQLString(source_datatype), | 113 | 7 | QLType::ToCQLString(target_datatype)); | 114 | 7 | } | 115 | 7 | return Status::OK(); | 116 | 7 | } |
yb::Status yb::bfql::SetNumericResult<yb::Status (*)(long long, yb::QLValue*), yb::QLValue*, yb::QLValue*>(yb::Status (*)(long long, yb::QLValue*), yb::QLValue*, yb::DataType, yb::QLValue*) Line | Count | Source | 66 | 14 | RTypePtr target) { | 67 | 14 | DataType source_datatype = InternalToDataType(source->type()); | 68 | 14 | if (!QLType::IsExplicitlyConvertible(target_datatype, source_datatype)) { | 69 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 70 | 0 | QLType::ToCQLString(source_datatype), | 71 | 0 | QLType::ToCQLString(target_datatype)); | 72 | 0 | } | 73 | | | 74 | 14 | switch(source->type()) { | 75 | 0 | case InternalType::kInt8Value: | 76 | 0 | RETURN_NOT_OK(set_result(source->int8_value(), target)); | 77 | 0 | break; | 78 | 2 | case InternalType::kInt16Value: | 79 | 2 | RETURN_NOT_OK(set_result(source->int16_value(), target)); | 80 | 2 | break; | 81 | 5 | case InternalType::kInt32Value: | 82 | 5 | RETURN_NOT_OK(set_result(source->int32_value(), target)); | 83 | 5 | break; | 84 | 5 | case InternalType::kInt64Value: | 85 | 3 | RETURN_NOT_OK(set_result(source->int64_value(), target)); | 86 | 3 | break; | 87 | 3 | case InternalType::kFloatValue: | 88 | 2 | RETURN_NOT_OK(set_result(source->float_value(), target)); | 89 | 2 | break; | 90 | 2 | case InternalType::kDoubleValue: | 91 | 2 | RETURN_NOT_OK(set_result(source->double_value(), target)); | 92 | 2 | break; | 93 | 2 | case InternalType::kDecimalValue: { | 94 | 0 | util::Decimal d; | 95 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); | 96 | | | 97 | 0 | if (target_datatype == DataType::FLOAT || target_datatype == DataType::DOUBLE) { | 98 | | // Convert via DOUBLE: | 99 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(d.ToDouble()), target)); | 100 | 0 | } else { // Expected an Integer type | 101 | 0 | RSTATUS_DCHECK(target_datatype == DataType::INT8 || target_datatype == DataType::INT16 | 102 | 0 | || target_datatype == DataType::INT32 || target_datatype == DataType::INT64, | 103 | 0 | InvalidArgument, strings::Substitute("Unexpected target type: ", | 104 | 0 | QLType::ToCQLString(target_datatype))); | 105 | | // Convert via INT64: | 106 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(VERIFY_RESULT(d.ToVarInt()).ToInt64()), target)); | 107 | 0 | } | 108 | 0 | } | 109 | 0 | break; | 110 | 0 | default: | 111 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 112 | 14 | QLType::ToCQLString(source_datatype), | 113 | 14 | QLType::ToCQLString(target_datatype)); | 114 | 14 | } | 115 | 14 | return Status::OK(); | 116 | 14 | } |
yb::Status yb::bfql::SetNumericResult<yb::Status (*)(double, yb::QLValue*), yb::QLValue*, yb::QLValue*>(yb::Status (*)(double, yb::QLValue*), yb::QLValue*, yb::DataType, yb::QLValue*) Line | Count | Source | 66 | 4 | RTypePtr target) { | 67 | 4 | DataType source_datatype = InternalToDataType(source->type()); | 68 | 4 | if (!QLType::IsExplicitlyConvertible(target_datatype, source_datatype)) { | 69 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 70 | 0 | QLType::ToCQLString(source_datatype), | 71 | 0 | QLType::ToCQLString(target_datatype)); | 72 | 0 | } | 73 | | | 74 | 4 | switch(source->type()) { | 75 | 0 | case InternalType::kInt8Value: | 76 | 0 | RETURN_NOT_OK(set_result(source->int8_value(), target)); | 77 | 0 | break; | 78 | 1 | case InternalType::kInt16Value: | 79 | 1 | RETURN_NOT_OK(set_result(source->int16_value(), target)); | 80 | 1 | break; | 81 | 1 | case InternalType::kInt32Value: | 82 | 1 | RETURN_NOT_OK(set_result(source->int32_value(), target)); | 83 | 1 | break; | 84 | 1 | case InternalType::kInt64Value: | 85 | 1 | RETURN_NOT_OK(set_result(source->int64_value(), target)); | 86 | 1 | break; | 87 | 1 | case InternalType::kFloatValue: | 88 | 1 | RETURN_NOT_OK(set_result(source->float_value(), target)); | 89 | 1 | break; | 90 | 1 | case InternalType::kDoubleValue: | 91 | 0 | RETURN_NOT_OK(set_result(source->double_value(), target)); | 92 | 0 | break; | 93 | 0 | case InternalType::kDecimalValue: { | 94 | 0 | util::Decimal d; | 95 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); | 96 | | | 97 | 0 | if (target_datatype == DataType::FLOAT || target_datatype == DataType::DOUBLE) { | 98 | | // Convert via DOUBLE: | 99 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(d.ToDouble()), target)); | 100 | 0 | } else { // Expected an Integer type | 101 | 0 | RSTATUS_DCHECK(target_datatype == DataType::INT8 || target_datatype == DataType::INT16 | 102 | 0 | || target_datatype == DataType::INT32 || target_datatype == DataType::INT64, | 103 | 0 | InvalidArgument, strings::Substitute("Unexpected target type: ", | 104 | 0 | QLType::ToCQLString(target_datatype))); | 105 | | // Convert via INT64: | 106 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(VERIFY_RESULT(d.ToVarInt()).ToInt64()), target)); | 107 | 0 | } | 108 | 0 | } | 109 | 0 | break; | 110 | 0 | default: | 111 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 112 | 4 | QLType::ToCQLString(source_datatype), | 113 | 4 | QLType::ToCQLString(target_datatype)); | 114 | 4 | } | 115 | 4 | return Status::OK(); | 116 | 4 | } |
yb::Status yb::bfql::SetNumericResult<yb::Status (*)(float, yb::QLValue*), yb::QLValue*, yb::QLValue*>(yb::Status (*)(float, yb::QLValue*), yb::QLValue*, yb::DataType, yb::QLValue*) Line | Count | Source | 66 | 4 | RTypePtr target) { | 67 | 4 | DataType source_datatype = InternalToDataType(source->type()); | 68 | 4 | if (!QLType::IsExplicitlyConvertible(target_datatype, source_datatype)) { | 69 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 70 | 0 | QLType::ToCQLString(source_datatype), | 71 | 0 | QLType::ToCQLString(target_datatype)); | 72 | 0 | } | 73 | | | 74 | 4 | switch(source->type()) { | 75 | 0 | case InternalType::kInt8Value: | 76 | 0 | RETURN_NOT_OK(set_result(source->int8_value(), target)); | 77 | 0 | break; | 78 | 1 | case InternalType::kInt16Value: | 79 | 1 | RETURN_NOT_OK(set_result(source->int16_value(), target)); | 80 | 1 | break; | 81 | 1 | case InternalType::kInt32Value: | 82 | 1 | RETURN_NOT_OK(set_result(source->int32_value(), target)); | 83 | 1 | break; | 84 | 1 | case InternalType::kInt64Value: | 85 | 1 | RETURN_NOT_OK(set_result(source->int64_value(), target)); | 86 | 1 | break; | 87 | 1 | case InternalType::kFloatValue: | 88 | 0 | RETURN_NOT_OK(set_result(source->float_value(), target)); | 89 | 0 | break; | 90 | 1 | case InternalType::kDoubleValue: | 91 | 1 | RETURN_NOT_OK(set_result(source->double_value(), target)); | 92 | 1 | break; | 93 | 1 | case InternalType::kDecimalValue: { | 94 | 0 | util::Decimal d; | 95 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); | 96 | | | 97 | 0 | if (target_datatype == DataType::FLOAT || target_datatype == DataType::DOUBLE) { | 98 | | // Convert via DOUBLE: | 99 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(d.ToDouble()), target)); | 100 | 0 | } else { // Expected an Integer type | 101 | 0 | RSTATUS_DCHECK(target_datatype == DataType::INT8 || target_datatype == DataType::INT16 | 102 | 0 | || target_datatype == DataType::INT32 || target_datatype == DataType::INT64, | 103 | 0 | InvalidArgument, strings::Substitute("Unexpected target type: ", | 104 | 0 | QLType::ToCQLString(target_datatype))); | 105 | | // Convert via INT64: | 106 | 0 | RETURN_NOT_OK(set_result(VERIFY_RESULT(VERIFY_RESULT(d.ToVarInt()).ToInt64()), target)); | 107 | 0 | } | 108 | 0 | } | 109 | 0 | break; | 110 | 0 | default: | 111 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 112 | 4 | QLType::ToCQLString(source_datatype), | 113 | 4 | QLType::ToCQLString(target_datatype)); | 114 | 4 | } | 115 | 4 | return Status::OK(); | 116 | 4 | } |
|
117 | | |
118 | | template<typename PTypePtr, typename RTypePtr> |
119 | 43 | CHECKED_STATUS SetStringResult(PTypePtr source, RTypePtr target) { |
120 | 43 | DataType source_datatype = InternalToDataType(source->type()); |
121 | 43 | if (!QLType::IsExplicitlyConvertible(DataType::STRING, source_datatype)) { |
122 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", |
123 | 0 | QLType::ToCQLString(source_datatype), |
124 | 0 | QLType::ToCQLString(DataType::STRING)); |
125 | 0 | } |
126 | | |
127 | 43 | switch(source->type()) { |
128 | 0 | case InternalType::kInt8Value: |
129 | 0 | target->set_string_value(std::to_string(source->int8_value())); |
130 | 0 | break; |
131 | 1 | case InternalType::kInt16Value: |
132 | 1 | target->set_string_value(std::to_string(source->int16_value())); |
133 | 1 | break; |
134 | 1 | case InternalType::kInt32Value: |
135 | 1 | target->set_string_value(std::to_string(source->int32_value())); |
136 | 1 | break; |
137 | 2 | case InternalType::kInt64Value: |
138 | 2 | target->set_string_value(std::to_string(source->int64_value())); |
139 | 2 | break; |
140 | 1 | case InternalType::kFloatValue: |
141 | 1 | target->set_string_value(std::to_string(source->float_value())); |
142 | 1 | break; |
143 | 1 | case InternalType::kDoubleValue: |
144 | 1 | target->set_string_value(std::to_string(source->double_value())); |
145 | 1 | break; |
146 | 4 | case InternalType::kStringValue: |
147 | 4 | target->set_string_value(source->string_value()); |
148 | 4 | break; |
149 | 2 | case InternalType::kBoolValue: |
150 | 2 | target->set_string_value(source->bool_value() ? "true"0 : "false"); |
151 | 2 | break; |
152 | 4 | case InternalType::kTimestampValue: |
153 | 4 | target->set_string_value(DateTime::TimestampToString(source->timestamp_value())); |
154 | 4 | break; |
155 | 11 | case InternalType::kDateValue: |
156 | 11 | target->set_string_value(VERIFY_RESULT(DateTime::DateToString(source->date_value()))); |
157 | 0 | break; |
158 | 4 | case InternalType::kTimeValue: |
159 | 4 | target->set_string_value(VERIFY_RESULT(DateTime::TimeToString(source->time_value()))); |
160 | 0 | break; |
161 | 3 | case InternalType::kUuidValue: |
162 | 3 | target->set_string_value(source->uuid_value().ToString()); |
163 | 3 | break; |
164 | 2 | case InternalType::kTimeuuidValue: |
165 | 2 | target->set_string_value(source->timeuuid_value().ToString()); |
166 | 2 | break; |
167 | 3 | case InternalType::kBinaryValue: |
168 | 3 | target->set_string_value("0x" + b2a_hex(source->binary_value())); |
169 | 3 | break; |
170 | 3 | case InternalType::kInetaddressValue: { |
171 | 3 | string strval; |
172 | 3 | RETURN_NOT_OK(source->inetaddress_value().ToString(&strval)); |
173 | 3 | target->set_string_value(strval); |
174 | 3 | } |
175 | 0 | break; |
176 | 0 | case InternalType::kDecimalValue: { |
177 | 0 | util::Decimal d; |
178 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); |
179 | 0 | target->set_string_value(d.ToString()); |
180 | 0 | } |
181 | 0 | break; |
182 | 1 | default: |
183 | 1 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", |
184 | 43 | QLType::ToCQLString(source_datatype), |
185 | 43 | QLType::ToCQLString(DataType::STRING)); |
186 | 43 | } |
187 | 42 | return Status::OK(); |
188 | 43 | } yb::Status yb::bfql::SetStringResult<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Line | Count | Source | 119 | 20 | CHECKED_STATUS SetStringResult(PTypePtr source, RTypePtr target) { | 120 | 20 | DataType source_datatype = InternalToDataType(source->type()); | 121 | 20 | if (!QLType::IsExplicitlyConvertible(DataType::STRING, source_datatype)) { | 122 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 123 | 0 | QLType::ToCQLString(source_datatype), | 124 | 0 | QLType::ToCQLString(DataType::STRING)); | 125 | 0 | } | 126 | | | 127 | 20 | switch(source->type()) { | 128 | 0 | case InternalType::kInt8Value: | 129 | 0 | target->set_string_value(std::to_string(source->int8_value())); | 130 | 0 | break; | 131 | 0 | case InternalType::kInt16Value: | 132 | 0 | target->set_string_value(std::to_string(source->int16_value())); | 133 | 0 | break; | 134 | 0 | case InternalType::kInt32Value: | 135 | 0 | target->set_string_value(std::to_string(source->int32_value())); | 136 | 0 | break; | 137 | 0 | case InternalType::kInt64Value: | 138 | 0 | target->set_string_value(std::to_string(source->int64_value())); | 139 | 0 | break; | 140 | 0 | case InternalType::kFloatValue: | 141 | 0 | target->set_string_value(std::to_string(source->float_value())); | 142 | 0 | break; | 143 | 0 | case InternalType::kDoubleValue: | 144 | 0 | target->set_string_value(std::to_string(source->double_value())); | 145 | 0 | break; | 146 | 0 | case InternalType::kStringValue: | 147 | 0 | target->set_string_value(source->string_value()); | 148 | 0 | break; | 149 | 0 | case InternalType::kBoolValue: | 150 | 0 | target->set_string_value(source->bool_value() ? "true" : "false"); | 151 | 0 | break; | 152 | 3 | case InternalType::kTimestampValue: | 153 | 3 | target->set_string_value(DateTime::TimestampToString(source->timestamp_value())); | 154 | 3 | break; | 155 | 3 | case InternalType::kDateValue: | 156 | 3 | target->set_string_value(VERIFY_RESULT(DateTime::DateToString(source->date_value()))); | 157 | 0 | break; | 158 | 3 | case InternalType::kTimeValue: | 159 | 3 | target->set_string_value(VERIFY_RESULT(DateTime::TimeToString(source->time_value()))); | 160 | 0 | break; | 161 | 3 | case InternalType::kUuidValue: | 162 | 3 | target->set_string_value(source->uuid_value().ToString()); | 163 | 3 | break; | 164 | 2 | case InternalType::kTimeuuidValue: | 165 | 2 | target->set_string_value(source->timeuuid_value().ToString()); | 166 | 2 | break; | 167 | 3 | case InternalType::kBinaryValue: | 168 | 3 | target->set_string_value("0x" + b2a_hex(source->binary_value())); | 169 | 3 | break; | 170 | 3 | case InternalType::kInetaddressValue: { | 171 | 3 | string strval; | 172 | 3 | RETURN_NOT_OK(source->inetaddress_value().ToString(&strval)); | 173 | 3 | target->set_string_value(strval); | 174 | 3 | } | 175 | 0 | break; | 176 | 0 | case InternalType::kDecimalValue: { | 177 | 0 | util::Decimal d; | 178 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); | 179 | 0 | target->set_string_value(d.ToString()); | 180 | 0 | } | 181 | 0 | break; | 182 | 0 | default: | 183 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 184 | 20 | QLType::ToCQLString(source_datatype), | 185 | 20 | QLType::ToCQLString(DataType::STRING)); | 186 | 20 | } | 187 | 20 | return Status::OK(); | 188 | 20 | } |
yb::Status yb::bfql::SetStringResult<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 119 | 23 | CHECKED_STATUS SetStringResult(PTypePtr source, RTypePtr target) { | 120 | 23 | DataType source_datatype = InternalToDataType(source->type()); | 121 | 23 | if (!QLType::IsExplicitlyConvertible(DataType::STRING, source_datatype)) { | 122 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 123 | 0 | QLType::ToCQLString(source_datatype), | 124 | 0 | QLType::ToCQLString(DataType::STRING)); | 125 | 0 | } | 126 | | | 127 | 23 | switch(source->type()) { | 128 | 0 | case InternalType::kInt8Value: | 129 | 0 | target->set_string_value(std::to_string(source->int8_value())); | 130 | 0 | break; | 131 | 1 | case InternalType::kInt16Value: | 132 | 1 | target->set_string_value(std::to_string(source->int16_value())); | 133 | 1 | break; | 134 | 1 | case InternalType::kInt32Value: | 135 | 1 | target->set_string_value(std::to_string(source->int32_value())); | 136 | 1 | break; | 137 | 2 | case InternalType::kInt64Value: | 138 | 2 | target->set_string_value(std::to_string(source->int64_value())); | 139 | 2 | break; | 140 | 1 | case InternalType::kFloatValue: | 141 | 1 | target->set_string_value(std::to_string(source->float_value())); | 142 | 1 | break; | 143 | 1 | case InternalType::kDoubleValue: | 144 | 1 | target->set_string_value(std::to_string(source->double_value())); | 145 | 1 | break; | 146 | 4 | case InternalType::kStringValue: | 147 | 4 | target->set_string_value(source->string_value()); | 148 | 4 | break; | 149 | 2 | case InternalType::kBoolValue: | 150 | 2 | target->set_string_value(source->bool_value() ? "true"0 : "false"); | 151 | 2 | break; | 152 | 1 | case InternalType::kTimestampValue: | 153 | 1 | target->set_string_value(DateTime::TimestampToString(source->timestamp_value())); | 154 | 1 | break; | 155 | 8 | case InternalType::kDateValue: | 156 | 8 | target->set_string_value(VERIFY_RESULT(DateTime::DateToString(source->date_value()))); | 157 | 0 | break; | 158 | 1 | case InternalType::kTimeValue: | 159 | 1 | target->set_string_value(VERIFY_RESULT(DateTime::TimeToString(source->time_value()))); | 160 | 0 | break; | 161 | 0 | case InternalType::kUuidValue: | 162 | 0 | target->set_string_value(source->uuid_value().ToString()); | 163 | 0 | break; | 164 | 0 | case InternalType::kTimeuuidValue: | 165 | 0 | target->set_string_value(source->timeuuid_value().ToString()); | 166 | 0 | break; | 167 | 0 | case InternalType::kBinaryValue: | 168 | 0 | target->set_string_value("0x" + b2a_hex(source->binary_value())); | 169 | 0 | break; | 170 | 0 | case InternalType::kInetaddressValue: { | 171 | 0 | string strval; | 172 | 0 | RETURN_NOT_OK(source->inetaddress_value().ToString(&strval)); | 173 | 0 | target->set_string_value(strval); | 174 | 0 | } | 175 | 0 | break; | 176 | 0 | case InternalType::kDecimalValue: { | 177 | 0 | util::Decimal d; | 178 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); | 179 | 0 | target->set_string_value(d.ToString()); | 180 | 0 | } | 181 | 0 | break; | 182 | 1 | default: | 183 | 1 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 184 | 23 | QLType::ToCQLString(source_datatype), | 185 | 23 | QLType::ToCQLString(DataType::STRING)); | 186 | 23 | } | 187 | 22 | return Status::OK(); | 188 | 23 | } |
|
189 | | |
190 | | template<typename PTypePtr, typename RTypePtr> |
191 | 36 | CHECKED_STATUS SetTimestampResult(PTypePtr source, RTypePtr target) { |
192 | 36 | DataType source_datatype = InternalToDataType(source->type()); |
193 | 36 | if (!QLType::IsExplicitlyConvertible(DataType::TIMESTAMP, source_datatype)) { |
194 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", |
195 | 0 | QLType::ToCQLString(source_datatype), |
196 | 0 | QLType::ToCQLString(DataType::TIMESTAMP)); |
197 | 0 | } |
198 | | |
199 | 36 | switch(source->type()) { |
200 | 33 | case InternalType::kTimeuuidValue: { |
201 | 33 | Uuid time_uuid = source->timeuuid_value(); |
202 | 33 | int64_t unix_timestamp; |
203 | 33 | RETURN_NOT_OK(time_uuid.ToUnixTimestamp(&unix_timestamp)); |
204 | 33 | target->set_timestamp_value(Timestamp(DateTime::AdjustPrecision |
205 | 33 | (unix_timestamp, |
206 | 33 | DateTime::kMillisecondPrecision, |
207 | 33 | DateTime::kInternalPrecision))); |
208 | 33 | break; |
209 | 33 | } |
210 | 2 | case InternalType::kDateValue: |
211 | 2 | target->set_timestamp_value(DateTime::DateToTimestamp(source->date_value())); |
212 | 2 | break; |
213 | 1 | default: |
214 | 1 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", |
215 | 36 | QLType::ToCQLString(source_datatype), |
216 | 36 | QLType::ToCQLString(DataType::TIMESTAMP)); |
217 | 36 | } |
218 | 35 | return Status::OK(); |
219 | 36 | } Unexecuted instantiation: yb::Status yb::bfql::SetTimestampResult<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::SetTimestampResult<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 191 | 36 | CHECKED_STATUS SetTimestampResult(PTypePtr source, RTypePtr target) { | 192 | 36 | DataType source_datatype = InternalToDataType(source->type()); | 193 | 36 | if (!QLType::IsExplicitlyConvertible(DataType::TIMESTAMP, source_datatype)) { | 194 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 195 | 0 | QLType::ToCQLString(source_datatype), | 196 | 0 | QLType::ToCQLString(DataType::TIMESTAMP)); | 197 | 0 | } | 198 | | | 199 | 36 | switch(source->type()) { | 200 | 33 | case InternalType::kTimeuuidValue: { | 201 | 33 | Uuid time_uuid = source->timeuuid_value(); | 202 | 33 | int64_t unix_timestamp; | 203 | 33 | RETURN_NOT_OK(time_uuid.ToUnixTimestamp(&unix_timestamp)); | 204 | 33 | target->set_timestamp_value(Timestamp(DateTime::AdjustPrecision | 205 | 33 | (unix_timestamp, | 206 | 33 | DateTime::kMillisecondPrecision, | 207 | 33 | DateTime::kInternalPrecision))); | 208 | 33 | break; | 209 | 33 | } | 210 | 2 | case InternalType::kDateValue: | 211 | 2 | target->set_timestamp_value(DateTime::DateToTimestamp(source->date_value())); | 212 | 2 | break; | 213 | 1 | default: | 214 | 1 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 215 | 36 | QLType::ToCQLString(source_datatype), | 216 | 36 | QLType::ToCQLString(DataType::TIMESTAMP)); | 217 | 36 | } | 218 | 35 | return Status::OK(); | 219 | 36 | } |
|
220 | | |
221 | | template<typename PTypePtr, typename RTypePtr> |
222 | 2 | CHECKED_STATUS SetDateResult(PTypePtr source, RTypePtr target) { |
223 | 2 | DataType source_datatype = InternalToDataType(source->type()); |
224 | 2 | if (!QLType::IsExplicitlyConvertible(DataType::DATE, source_datatype)) { |
225 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", |
226 | 0 | QLType::ToCQLString(source_datatype), |
227 | 0 | QLType::ToCQLString(DataType::DATE)); |
228 | 0 | } |
229 | | |
230 | 2 | switch(source->type()) { |
231 | 2 | case InternalType::kTimestampValue: |
232 | 2 | target->set_date_value(VERIFY_RESULT(DateTime::DateFromTimestamp(source->timestamp_value()))); |
233 | 0 | break; |
234 | 0 | case InternalType::kTimeuuidValue: { |
235 | 0 | Uuid time_uuid = source->timeuuid_value(); |
236 | 0 | int64_t unix_timestamp; |
237 | 0 | RETURN_NOT_OK(time_uuid.ToUnixTimestamp(&unix_timestamp)); |
238 | 0 | target->set_date_value(VERIFY_RESULT(DateTime::DateFromUnixTimestamp(unix_timestamp))); |
239 | 0 | break; |
240 | 0 | } |
241 | 0 | default: |
242 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", |
243 | 2 | QLType::ToCQLString(source_datatype), |
244 | 2 | QLType::ToCQLString(DataType::DATE)); |
245 | 2 | } |
246 | 2 | return Status::OK(); |
247 | 2 | } Unexecuted instantiation: yb::Status yb::bfql::SetDateResult<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::SetDateResult<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 222 | 2 | CHECKED_STATUS SetDateResult(PTypePtr source, RTypePtr target) { | 223 | 2 | DataType source_datatype = InternalToDataType(source->type()); | 224 | 2 | if (!QLType::IsExplicitlyConvertible(DataType::DATE, source_datatype)) { | 225 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 226 | 0 | QLType::ToCQLString(source_datatype), | 227 | 0 | QLType::ToCQLString(DataType::DATE)); | 228 | 0 | } | 229 | | | 230 | 2 | switch(source->type()) { | 231 | 2 | case InternalType::kTimestampValue: | 232 | 2 | target->set_date_value(VERIFY_RESULT(DateTime::DateFromTimestamp(source->timestamp_value()))); | 233 | 0 | break; | 234 | 0 | case InternalType::kTimeuuidValue: { | 235 | 0 | Uuid time_uuid = source->timeuuid_value(); | 236 | 0 | int64_t unix_timestamp; | 237 | 0 | RETURN_NOT_OK(time_uuid.ToUnixTimestamp(&unix_timestamp)); | 238 | 0 | target->set_date_value(VERIFY_RESULT(DateTime::DateFromUnixTimestamp(unix_timestamp))); | 239 | 0 | break; | 240 | 0 | } | 241 | 0 | default: | 242 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 243 | 2 | QLType::ToCQLString(source_datatype), | 244 | 2 | QLType::ToCQLString(DataType::DATE)); | 245 | 2 | } | 246 | 2 | return Status::OK(); | 247 | 2 | } |
|
248 | | |
249 | | template<typename RTypePtr, typename StrToNum, typename SetTarget> |
250 | | CHECKED_STATUS StringToNumeric(const string& str_val, RTypePtr target, StrToNum strToNum, |
251 | 38 | SetTarget setTarget) { |
252 | 38 | auto result = strToNum(str_val); |
253 | 38 | RETURN_NOT_OK(result); |
254 | 38 | return setTarget(*result, target); |
255 | 38 | } Unexecuted instantiation: yb::Status yb::bfql::StringToNumeric<std::__1::shared_ptr<yb::QLValue>, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, std::__1::shared_ptr<yb::QLValue>)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<yb::QLValue>, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::StringToNumeric<std::__1::shared_ptr<yb::QLValue>, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<yb::QLValue>, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::StringToNumeric<std::__1::shared_ptr<yb::QLValue>, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<yb::QLValue>, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::StringToNumeric<std::__1::shared_ptr<yb::QLValue>, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, std::__1::shared_ptr<yb::QLValue>)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<yb::QLValue>, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::StringToNumeric<std::__1::shared_ptr<yb::QLValue>, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, std::__1::shared_ptr<yb::QLValue>)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<yb::QLValue>, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, std::__1::shared_ptr<yb::QLValue>)) yb::Status yb::bfql::StringToNumeric<yb::QLValue*, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, yb::QLValue*)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::QLValue*, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, yb::QLValue*)) Line | Count | Source | 251 | 2 | SetTarget setTarget) { | 252 | 2 | auto result = strToNum(str_val); | 253 | 2 | RETURN_NOT_OK(result); | 254 | 2 | return setTarget(*result, target); | 255 | 2 | } |
yb::Status yb::bfql::StringToNumeric<yb::QLValue*, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::QLValue*, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)) Line | Count | Source | 251 | 13 | SetTarget setTarget) { | 252 | 13 | auto result = strToNum(str_val); | 253 | 13 | RETURN_NOT_OK(result); | 254 | 13 | return setTarget(*result, target); | 255 | 13 | } |
yb::Status yb::bfql::StringToNumeric<yb::QLValue*, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::QLValue*, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)) Line | Count | Source | 251 | 11 | SetTarget setTarget) { | 252 | 11 | auto result = strToNum(str_val); | 253 | 11 | RETURN_NOT_OK(result); | 254 | 11 | return setTarget(*result, target); | 255 | 11 | } |
yb::Status yb::bfql::StringToNumeric<yb::QLValue*, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, yb::QLValue*)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::QLValue*, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, yb::QLValue*)) Line | Count | Source | 251 | 10 | SetTarget setTarget) { | 252 | 10 | auto result = strToNum(str_val); | 253 | 10 | RETURN_NOT_OK(result); | 254 | 10 | return setTarget(*result, target); | 255 | 10 | } |
yb::Status yb::bfql::StringToNumeric<yb::QLValue*, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, yb::QLValue*)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::QLValue*, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, yb::QLValue*)) Line | Count | Source | 251 | 2 | SetTarget setTarget) { | 252 | 2 | auto result = strToNum(str_val); | 253 | 2 | RETURN_NOT_OK(result); | 254 | 2 | return setTarget(*result, target); | 255 | 2 | } |
|
256 | | |
257 | | //-------------------------------------------------------------------------------------------------- |
258 | | template<typename PTypePtr, typename RTypePtr> |
259 | | CHECKED_STATUS ConvertI8ToI8(PTypePtr source, RTypePtr target) { |
260 | | if (source->IsNull()) { |
261 | | target->SetNull(); |
262 | | } else { |
263 | | target->set_int8_value(source->int8_value()); |
264 | | } |
265 | | return Status::OK(); |
266 | | } |
267 | | |
268 | | template<typename PTypePtr, typename RTypePtr> |
269 | 0 | CHECKED_STATUS ConvertI8ToI16(PTypePtr source, RTypePtr target) { |
270 | 0 | if (source->IsNull()) { |
271 | 0 | target->SetNull(); |
272 | 0 | } else { |
273 | 0 | target->set_int16_value(source->int8_value()); |
274 | 0 | } |
275 | 0 | return Status::OK(); |
276 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToI16<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToI16<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
277 | | |
278 | | template<typename PTypePtr, typename RTypePtr> |
279 | 0 | CHECKED_STATUS ConvertI8ToI32(PTypePtr source, RTypePtr target) { |
280 | 0 | if (source->IsNull()) { |
281 | 0 | target->SetNull(); |
282 | 0 | } else { |
283 | 0 | target->set_int32_value(source->int8_value()); |
284 | 0 | } |
285 | 0 | return Status::OK(); |
286 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToI32<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToI32<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
287 | | |
288 | | template<typename PTypePtr, typename RTypePtr> |
289 | 0 | CHECKED_STATUS ConvertI8ToI64(PTypePtr source, RTypePtr target) { |
290 | 0 | if (source->IsNull()) { |
291 | 0 | target->SetNull(); |
292 | 0 | } else { |
293 | 0 | target->set_int64_value(source->int8_value()); |
294 | 0 | } |
295 | 0 | return Status::OK(); |
296 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToI64<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToI64<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
297 | | |
298 | | template<typename PTypePtr, typename RTypePtr> |
299 | 0 | CHECKED_STATUS ConvertI8ToFloat(PTypePtr source, RTypePtr target) { |
300 | 0 | if (source->IsNull()) { |
301 | 0 | target->SetNull(); |
302 | 0 | } else { |
303 | 0 | target->set_float_value(source->int8_value()); |
304 | 0 | } |
305 | 0 | return Status::OK(); |
306 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
307 | | |
308 | | template<typename PTypePtr, typename RTypePtr> |
309 | 0 | CHECKED_STATUS ConvertI8ToDouble(PTypePtr source, RTypePtr target) { |
310 | 0 | if (source->IsNull()) { |
311 | 0 | target->SetNull(); |
312 | 0 | } else { |
313 | 0 | target->set_double_value(source->int8_value()); |
314 | 0 | } |
315 | 0 | return Status::OK(); |
316 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
317 | | |
318 | | // Conversion from int16 to others. |
319 | | template<typename PTypePtr, typename RTypePtr> |
320 | 0 | CHECKED_STATUS ConvertI16ToI8(PTypePtr source, RTypePtr target) { |
321 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
322 | 0 | if (source->IsNull()) { |
323 | 0 | target->SetNull(); |
324 | 0 | } else { |
325 | 0 | target->set_int8_value(source->int16_value()); |
326 | 0 | } |
327 | 0 | return Status::OK(); |
328 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToI8<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToI8<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
329 | | |
330 | | template<typename PTypePtr, typename RTypePtr> |
331 | | CHECKED_STATUS ConvertI16ToI16(PTypePtr source, RTypePtr target) { |
332 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
333 | | if (source->IsNull()) { |
334 | | target->SetNull(); |
335 | | } else { |
336 | | target->set_int16_value(source->int16_value()); |
337 | | } |
338 | | return Status::OK(); |
339 | | } |
340 | | |
341 | | template<typename PTypePtr, typename RTypePtr> |
342 | 0 | CHECKED_STATUS ConvertI16ToI32(PTypePtr source, RTypePtr target) { |
343 | 0 | if (source->IsNull()) { |
344 | 0 | target->SetNull(); |
345 | 0 | } else { |
346 | 0 | target->set_int32_value(source->int16_value()); |
347 | 0 | } |
348 | 0 | return Status::OK(); |
349 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToI32<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToI32<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
350 | | |
351 | | template<typename PTypePtr, typename RTypePtr> |
352 | 0 | CHECKED_STATUS ConvertI16ToI64(PTypePtr source, RTypePtr target) { |
353 | 0 | if (source->IsNull()) { |
354 | 0 | target->SetNull(); |
355 | 0 | } else { |
356 | 0 | target->set_int64_value(source->int16_value()); |
357 | 0 | } |
358 | 0 | return Status::OK(); |
359 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToI64<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToI64<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
360 | | |
361 | | template<typename PTypePtr, typename RTypePtr> |
362 | 0 | CHECKED_STATUS ConvertI16ToFloat(PTypePtr source, RTypePtr target) { |
363 | 0 | if (source->IsNull()) { |
364 | 0 | target->SetNull(); |
365 | 0 | } else { |
366 | 0 | target->set_float_value(source->int16_value()); |
367 | 0 | } |
368 | 0 | return Status::OK(); |
369 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
370 | | |
371 | | template<typename PTypePtr, typename RTypePtr> |
372 | 0 | CHECKED_STATUS ConvertI16ToDouble(PTypePtr source, RTypePtr target) { |
373 | 0 | if (source->IsNull()) { |
374 | 0 | target->SetNull(); |
375 | 0 | } else { |
376 | 0 | target->set_double_value(source->int16_value()); |
377 | 0 | } |
378 | 0 | return Status::OK(); |
379 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
380 | | |
381 | | // Conversion from int32 to others. |
382 | | template<typename PTypePtr, typename RTypePtr> |
383 | 0 | CHECKED_STATUS ConvertI32ToI8(PTypePtr source, RTypePtr target) { |
384 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
385 | 0 | if (source->IsNull()) { |
386 | 0 | target->SetNull(); |
387 | 0 | } else { |
388 | 0 | target->set_int8_value(source->int32_value()); |
389 | 0 | } |
390 | 0 | return Status::OK(); |
391 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToI8<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToI8<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
392 | | |
393 | | template<typename PTypePtr, typename RTypePtr> |
394 | 0 | CHECKED_STATUS ConvertI32ToI16(PTypePtr source, RTypePtr target) { |
395 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
396 | 0 | if (source->IsNull()) { |
397 | 0 | target->SetNull(); |
398 | 0 | } else { |
399 | 0 | target->set_int16_value(source->int32_value()); |
400 | 0 | } |
401 | 0 | return Status::OK(); |
402 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToI16<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToI16<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
403 | | |
404 | | template<typename PTypePtr, typename RTypePtr> |
405 | | CHECKED_STATUS ConvertI32ToI32(PTypePtr source, RTypePtr target) { |
406 | | if (source->IsNull()) { |
407 | | target->SetNull(); |
408 | | } else { |
409 | | target->set_int32_value(source->int32_value()); |
410 | | } |
411 | | return Status::OK(); |
412 | | } |
413 | | |
414 | | template<typename PTypePtr, typename RTypePtr> |
415 | 16 | CHECKED_STATUS ConvertI32ToI64(PTypePtr source, RTypePtr target) { |
416 | 16 | if (source->IsNull()) { |
417 | 2 | target->SetNull(); |
418 | 14 | } else { |
419 | 14 | target->set_int64_value(source->int32_value()); |
420 | 14 | } |
421 | 16 | return Status::OK(); |
422 | 16 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToI64<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertI32ToI64<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 415 | 16 | CHECKED_STATUS ConvertI32ToI64(PTypePtr source, RTypePtr target) { | 416 | 16 | if (source->IsNull()) { | 417 | 2 | target->SetNull(); | 418 | 14 | } else { | 419 | 14 | target->set_int64_value(source->int32_value()); | 420 | 14 | } | 421 | 16 | return Status::OK(); | 422 | 16 | } |
|
423 | | |
424 | | template<typename PTypePtr, typename RTypePtr> |
425 | 0 | CHECKED_STATUS ConvertI32ToFloat(PTypePtr source, RTypePtr target) { |
426 | 0 | if (source->IsNull()) { |
427 | 0 | target->SetNull(); |
428 | 0 | } else { |
429 | 0 | target->set_float_value(source->int32_value()); |
430 | 0 | } |
431 | 0 | return Status::OK(); |
432 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
433 | | |
434 | | template<typename PTypePtr, typename RTypePtr> |
435 | 0 | CHECKED_STATUS ConvertI32ToDouble(PTypePtr source, RTypePtr target) { |
436 | 0 | if (source->IsNull()) { |
437 | 0 | target->SetNull(); |
438 | 0 | } else { |
439 | 0 | target->set_double_value(source->int32_value()); |
440 | 0 | } |
441 | 0 | return Status::OK(); |
442 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
443 | | |
444 | | // Conversion from int64 to others. |
445 | | template<typename PTypePtr, typename RTypePtr> |
446 | 2 | CHECKED_STATUS ConvertI64ToI8(PTypePtr source, RTypePtr target) { |
447 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
448 | 2 | if (source->IsNull()) { |
449 | 0 | target->SetNull(); |
450 | 2 | } else { |
451 | 2 | target->set_int8_value(source->int64_value()); |
452 | 2 | } |
453 | 2 | return Status::OK(); |
454 | 2 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToI8<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertI64ToI8<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 446 | 2 | CHECKED_STATUS ConvertI64ToI8(PTypePtr source, RTypePtr target) { | 447 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. | 448 | 2 | if (source->IsNull()) { | 449 | 0 | target->SetNull(); | 450 | 2 | } else { | 451 | 2 | target->set_int8_value(source->int64_value()); | 452 | 2 | } | 453 | 2 | return Status::OK(); | 454 | 2 | } |
|
455 | | |
456 | | template<typename PTypePtr, typename RTypePtr> |
457 | 2 | CHECKED_STATUS ConvertI64ToI16(PTypePtr source, RTypePtr target) { |
458 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
459 | 2 | if (source->IsNull()) { |
460 | 0 | target->SetNull(); |
461 | 2 | } else { |
462 | 2 | target->set_int16_value(source->int64_value()); |
463 | 2 | } |
464 | 2 | return Status::OK(); |
465 | 2 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToI16<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertI64ToI16<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 457 | 2 | CHECKED_STATUS ConvertI64ToI16(PTypePtr source, RTypePtr target) { | 458 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. | 459 | 2 | if (source->IsNull()) { | 460 | 0 | target->SetNull(); | 461 | 2 | } else { | 462 | 2 | target->set_int16_value(source->int64_value()); | 463 | 2 | } | 464 | 2 | return Status::OK(); | 465 | 2 | } |
|
466 | | |
467 | | template<typename PTypePtr, typename RTypePtr> |
468 | 36 | CHECKED_STATUS ConvertI64ToI32(PTypePtr source, RTypePtr target) { |
469 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
470 | 36 | if (source->IsNull()) { |
471 | 2 | target->SetNull(); |
472 | 34 | } else { |
473 | 34 | target->set_int32_value(static_cast<int32_t>(source->int64_value())); |
474 | 34 | } |
475 | 36 | return Status::OK(); |
476 | 36 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToI32<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertI64ToI32<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 468 | 36 | CHECKED_STATUS ConvertI64ToI32(PTypePtr source, RTypePtr target) { | 469 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. | 470 | 36 | if (source->IsNull()) { | 471 | 2 | target->SetNull(); | 472 | 34 | } else { | 473 | 34 | target->set_int32_value(static_cast<int32_t>(source->int64_value())); | 474 | 34 | } | 475 | 36 | return Status::OK(); | 476 | 36 | } |
|
477 | | |
478 | | template<typename PTypePtr, typename RTypePtr> |
479 | | CHECKED_STATUS ConvertI64ToI64(PTypePtr source, RTypePtr target) { |
480 | | // TODO(neil) Overflow? When we truely support expressions, these loose-ends must be fixed. |
481 | | if (source->IsNull()) { |
482 | | target->SetNull(); |
483 | | } else { |
484 | | target->set_int64_value(source->int64_value()); |
485 | | } |
486 | | return Status::OK(); |
487 | | } |
488 | | |
489 | | template<typename PTypePtr, typename RTypePtr> |
490 | 0 | CHECKED_STATUS ConvertI64ToFloat(PTypePtr source, RTypePtr target) { |
491 | 0 | if (source->IsNull()) { |
492 | 0 | target->SetNull(); |
493 | 0 | } else { |
494 | 0 | target->set_float_value(source->int64_value()); |
495 | 0 | } |
496 | 0 | return Status::OK(); |
497 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
498 | | |
499 | | template<typename PTypePtr, typename RTypePtr> |
500 | 0 | CHECKED_STATUS ConvertI64ToDouble(PTypePtr source, RTypePtr target) { |
501 | 0 | if (source->IsNull()) { |
502 | 0 | target->SetNull(); |
503 | 0 | } else { |
504 | 0 | target->set_double_value(source->int64_value()); |
505 | 0 | } |
506 | 0 | return Status::OK(); |
507 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
508 | | |
509 | | // Conversion from float to others. |
510 | | template<typename PTypePtr, typename RTypePtr> |
511 | | CHECKED_STATUS ConvertFloatToFloat(PTypePtr source, RTypePtr target) { |
512 | | if (source->IsNull()) { |
513 | | target->SetNull(); |
514 | | } else { |
515 | | target->set_float_value(source->float_value()); |
516 | | } |
517 | | return Status::OK(); |
518 | | } |
519 | | |
520 | | template<typename PTypePtr, typename RTypePtr> |
521 | 0 | CHECKED_STATUS ConvertFloatToDouble(PTypePtr source, RTypePtr target) { |
522 | 0 | if (source->IsNull()) { |
523 | 0 | target->SetNull(); |
524 | 0 | } else { |
525 | 0 | target->set_double_value(source->float_value()); |
526 | 0 | } |
527 | 0 | return Status::OK(); |
528 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertFloatToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertFloatToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
529 | | |
530 | | // Conversion from double to others. |
531 | | template<typename PTypePtr, typename RTypePtr> |
532 | 0 | CHECKED_STATUS ConvertDoubleToFloat(PTypePtr source, RTypePtr target) { |
533 | 0 | if (source->IsNull()) { |
534 | 0 | target->SetNull(); |
535 | 0 | } else { |
536 | 0 | target->set_float_value(source->double_value()); |
537 | 0 | } |
538 | 0 | return Status::OK(); |
539 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertDoubleToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertDoubleToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
540 | | |
541 | | template<typename PTypePtr, typename RTypePtr> |
542 | | CHECKED_STATUS ConvertDoubleToDouble(PTypePtr source, RTypePtr target) { |
543 | | if (source->IsNull()) { |
544 | | target->SetNull(); |
545 | | } else { |
546 | | target->set_double_value(source->double_value()); |
547 | | } |
548 | | return Status::OK(); |
549 | | } |
550 | | |
551 | | //-------------------------------------------------------------------------------------------------- |
552 | | // The following functions are for timestamp conversion. |
553 | | template<typename PTypePtr, typename RTypePtr> |
554 | | CHECKED_STATUS ConvertTimestampToI64(PTypePtr source, RTypePtr target) { |
555 | | if (source->IsNull()) { |
556 | | target->SetNull(); |
557 | | } else { |
558 | | target->set_int64_value(source->timestamp_value().ToInt64()); |
559 | | } |
560 | | return Status::OK(); |
561 | | } |
562 | | |
563 | | template<typename PTypePtr, typename RTypePtr> |
564 | | CHECKED_STATUS ConvertI64ToTimestamp(PTypePtr source, RTypePtr target) { |
565 | | if (source->IsNull()) { |
566 | | target->SetNull(); |
567 | | } else { |
568 | | target->set_timestamp_value(DateTime::TimestampFromInt(source->int64_value()).ToInt64()); |
569 | | } |
570 | | return Status::OK(); |
571 | | } |
572 | | |
573 | | template<typename PTypePtr, typename RTypePtr> |
574 | | CHECKED_STATUS ConvertTimestampToString(PTypePtr source, RTypePtr target) { |
575 | | if (source->IsNull()) { |
576 | | target->SetNull(); |
577 | | } else { |
578 | | target->set_string_value(source->timestamp_value().ToString()); |
579 | | } |
580 | | return Status::OK(); |
581 | | } |
582 | | |
583 | | template<typename PTypePtr, typename RTypePtr> |
584 | | CHECKED_STATUS ConvertStringToTimestamp(PTypePtr source, RTypePtr target) { |
585 | | if (source->IsNull()) { |
586 | | target->SetNull(); |
587 | | } else { |
588 | | Timestamp ts; |
589 | | RETURN_NOT_OK(DateTime::TimestampFromString(source->string_value(), &ts)); |
590 | | target->set_timestamp_value(ts.ToInt64()); |
591 | | } |
592 | | return Status::OK(); |
593 | | } |
594 | | |
595 | | //-------------------------------------------------------------------------------------------------- |
596 | | // The following functions are for string conversion. |
597 | | template<typename PTypePtr, typename RTypePtr> |
598 | | CHECKED_STATUS ConvertStringToString(PTypePtr source, RTypePtr target) { |
599 | | if (source->IsNull()) { |
600 | | target->SetNull(); |
601 | | } else { |
602 | | target->set_string_value(source->string_value()); |
603 | | } |
604 | | return Status::OK(); |
605 | | } |
606 | | |
607 | | template<typename PTypePtr, typename RTypePtr> |
608 | | CHECKED_STATUS ConvertStringToInet(PTypePtr source, RTypePtr target) { |
609 | | if (source->IsNull()) { |
610 | | target->SetNull(); |
611 | | } else { |
612 | | target->set_inetaddress_value(InetAddress( |
613 | | VERIFY_RESULT(HostToAddress(source->string_value())))); |
614 | | } |
615 | | return Status::OK(); |
616 | | } |
617 | | |
618 | | //-------------------------------------------------------------------------------------------------- |
619 | | // The following functions are for boolean conversion. |
620 | | template<typename PTypePtr, typename RTypePtr> |
621 | | CHECKED_STATUS ConvertBoolToBool(PTypePtr source, RTypePtr target) { |
622 | | if (source->IsNull()) { |
623 | | target->SetNull(); |
624 | | } else { |
625 | | target->set_bool_value(source->bool_value()); |
626 | | } |
627 | | return Status::OK(); |
628 | | } |
629 | | |
630 | | //-------------------------------------------------------------------------------------------------- |
631 | | // The following functions are for conversions to blob / binary from other datatypes. |
632 | | |
633 | | template<typename PTypePtr, typename RTypePtr> |
634 | 21 | CHECKED_STATUS ConvertStringToBlob(PTypePtr source, RTypePtr target) { |
635 | 21 | if (source->IsNull()) { |
636 | 0 | target->SetNull(); |
637 | 21 | } else { |
638 | 21 | string target_val = source->string_value(); |
639 | 21 | target->set_binary_value(target_val); |
640 | 21 | } |
641 | 21 | return Status::OK(); |
642 | 21 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertStringToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertStringToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 634 | 21 | CHECKED_STATUS ConvertStringToBlob(PTypePtr source, RTypePtr target) { | 635 | 21 | if (source->IsNull()) { | 636 | 0 | target->SetNull(); | 637 | 21 | } else { | 638 | 21 | string target_val = source->string_value(); | 639 | 21 | target->set_binary_value(target_val); | 640 | 21 | } | 641 | 21 | return Status::OK(); | 642 | 21 | } |
|
643 | | |
644 | | template<typename PTypePtr, typename RTypePtr> |
645 | 4 | CHECKED_STATUS ConvertBoolToBlob(PTypePtr source, RTypePtr target) { |
646 | 4 | if (source->IsNull()) { |
647 | 0 | target->SetNull(); |
648 | 4 | } else { |
649 | 4 | int8_t byte_stream = (source->bool_value()) ? 12 : 02 ; |
650 | 4 | target->set_binary_value(reinterpret_cast<void *> (&byte_stream), kSizeBool); |
651 | 4 | } |
652 | 4 | return Status::OK(); |
653 | 4 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBoolToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBoolToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 645 | 4 | CHECKED_STATUS ConvertBoolToBlob(PTypePtr source, RTypePtr target) { | 646 | 4 | if (source->IsNull()) { | 647 | 0 | target->SetNull(); | 648 | 4 | } else { | 649 | 4 | int8_t byte_stream = (source->bool_value()) ? 12 : 02 ; | 650 | 4 | target->set_binary_value(reinterpret_cast<void *> (&byte_stream), kSizeBool); | 651 | 4 | } | 652 | 4 | return Status::OK(); | 653 | 4 | } |
|
654 | | |
655 | | template<typename PTypePtr, typename RTypePtr> |
656 | 6 | CHECKED_STATUS ConvertInt8ToBlob(PTypePtr source, RTypePtr target) { |
657 | 6 | if (source->IsNull()) { |
658 | 0 | target->SetNull(); |
659 | 6 | } else { |
660 | 6 | int8_t byte_stream = source->int8_value(); |
661 | 6 | target->set_binary_value(reinterpret_cast<void *> (&byte_stream), kSizeTinyInt); |
662 | 6 | } |
663 | 6 | return Status::OK(); |
664 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertInt8ToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertInt8ToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 656 | 6 | CHECKED_STATUS ConvertInt8ToBlob(PTypePtr source, RTypePtr target) { | 657 | 6 | if (source->IsNull()) { | 658 | 0 | target->SetNull(); | 659 | 6 | } else { | 660 | 6 | int8_t byte_stream = source->int8_value(); | 661 | 6 | target->set_binary_value(reinterpret_cast<void *> (&byte_stream), kSizeTinyInt); | 662 | 6 | } | 663 | 6 | return Status::OK(); | 664 | 6 | } |
|
665 | | |
666 | | template<typename PTypePtr, typename RTypePtr> |
667 | 6 | CHECKED_STATUS ConvertInt16ToBlob(PTypePtr source, RTypePtr target) { |
668 | 6 | if (source->IsNull()) { |
669 | 0 | target->SetNull(); |
670 | 6 | } else { |
671 | 6 | int16_t source_val = source->int16_value(); |
672 | 6 | uint16* source_ptr = reinterpret_cast<uint16*> (&source_val); |
673 | 6 | uint16 source_big_endian = BigEndian::FromHost16(*source_ptr); |
674 | 6 | target->set_binary_value(reinterpret_cast<void*> (&source_big_endian), kSizeSmallInt); |
675 | 6 | } |
676 | 6 | return Status::OK(); |
677 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertInt16ToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertInt16ToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 667 | 6 | CHECKED_STATUS ConvertInt16ToBlob(PTypePtr source, RTypePtr target) { | 668 | 6 | if (source->IsNull()) { | 669 | 0 | target->SetNull(); | 670 | 6 | } else { | 671 | 6 | int16_t source_val = source->int16_value(); | 672 | 6 | uint16* source_ptr = reinterpret_cast<uint16*> (&source_val); | 673 | 6 | uint16 source_big_endian = BigEndian::FromHost16(*source_ptr); | 674 | 6 | target->set_binary_value(reinterpret_cast<void*> (&source_big_endian), kSizeSmallInt); | 675 | 6 | } | 676 | 6 | return Status::OK(); | 677 | 6 | } |
|
678 | | |
679 | | template<typename PTypePtr, typename RTypePtr> |
680 | 11 | CHECKED_STATUS ConvertInt32ToBlob(PTypePtr source, RTypePtr target) { |
681 | 11 | if (source->IsNull()) { |
682 | 0 | target->SetNull(); |
683 | 11 | } else { |
684 | 11 | int32_t source_val = source->int32_value(); |
685 | 11 | uint32* source_ptr = reinterpret_cast<uint32*> (&source_val); |
686 | 11 | uint32 source_big_endian = BigEndian::FromHost32(*source_ptr); |
687 | 11 | target->set_binary_value(reinterpret_cast<void*> (&source_big_endian), kSizeInt); |
688 | 11 | } |
689 | 11 | return Status::OK(); |
690 | 11 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertInt32ToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertInt32ToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 680 | 11 | CHECKED_STATUS ConvertInt32ToBlob(PTypePtr source, RTypePtr target) { | 681 | 11 | if (source->IsNull()) { | 682 | 0 | target->SetNull(); | 683 | 11 | } else { | 684 | 11 | int32_t source_val = source->int32_value(); | 685 | 11 | uint32* source_ptr = reinterpret_cast<uint32*> (&source_val); | 686 | 11 | uint32 source_big_endian = BigEndian::FromHost32(*source_ptr); | 687 | 11 | target->set_binary_value(reinterpret_cast<void*> (&source_big_endian), kSizeInt); | 688 | 11 | } | 689 | 11 | return Status::OK(); | 690 | 11 | } |
|
691 | | |
692 | | template<typename PTypePtr, typename RTypePtr> |
693 | 6 | CHECKED_STATUS ConvertInt64ToBlob(PTypePtr source, RTypePtr target) { |
694 | 6 | if (source->IsNull()) { |
695 | 0 | target->SetNull(); |
696 | 6 | } else { |
697 | 6 | int64_t source_val = source->int64_value(); |
698 | 6 | uint64* source_ptr = reinterpret_cast<uint64*> (&source_val); |
699 | 6 | uint64 source_big_endian = BigEndian::FromHost64(*source_ptr); |
700 | 6 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeBigInt); |
701 | 6 | } |
702 | 6 | return Status::OK(); |
703 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertInt64ToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertInt64ToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 693 | 6 | CHECKED_STATUS ConvertInt64ToBlob(PTypePtr source, RTypePtr target) { | 694 | 6 | if (source->IsNull()) { | 695 | 0 | target->SetNull(); | 696 | 6 | } else { | 697 | 6 | int64_t source_val = source->int64_value(); | 698 | 6 | uint64* source_ptr = reinterpret_cast<uint64*> (&source_val); | 699 | 6 | uint64 source_big_endian = BigEndian::FromHost64(*source_ptr); | 700 | 6 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeBigInt); | 701 | 6 | } | 702 | 6 | return Status::OK(); | 703 | 6 | } |
|
704 | | |
705 | | template<typename PTypePtr, typename RTypePtr> |
706 | 0 | CHECKED_STATUS ConvertVarintToBlob(PTypePtr source, RTypePtr target) { |
707 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
708 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
709 | | |
710 | | template<typename PTypePtr, typename RTypePtr> |
711 | 6 | CHECKED_STATUS ConvertFloatToBlob(PTypePtr source, RTypePtr target) { |
712 | 6 | if (source->IsNull()) { |
713 | 0 | target->SetNull(); |
714 | 6 | } else { |
715 | 6 | float source_val = source->float_value(); |
716 | 6 | uint32* source_ptr = reinterpret_cast<uint32*> (&source_val); |
717 | 6 | uint32 source_big_endian = BigEndian::FromHost32(*source_ptr); |
718 | 6 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeInt); |
719 | 6 | } |
720 | 6 | return Status::OK(); |
721 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertFloatToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertFloatToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 711 | 6 | CHECKED_STATUS ConvertFloatToBlob(PTypePtr source, RTypePtr target) { | 712 | 6 | if (source->IsNull()) { | 713 | 0 | target->SetNull(); | 714 | 6 | } else { | 715 | 6 | float source_val = source->float_value(); | 716 | 6 | uint32* source_ptr = reinterpret_cast<uint32*> (&source_val); | 717 | 6 | uint32 source_big_endian = BigEndian::FromHost32(*source_ptr); | 718 | 6 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeInt); | 719 | 6 | } | 720 | 6 | return Status::OK(); | 721 | 6 | } |
|
722 | | |
723 | | template<typename PTypePtr, typename RTypePtr> |
724 | 6 | CHECKED_STATUS ConvertDoubleToBlob(PTypePtr source, RTypePtr target) { |
725 | 6 | if (source->IsNull()) { |
726 | 0 | target->SetNull(); |
727 | 6 | } else { |
728 | 6 | double source_val = source->double_value(); |
729 | 6 | uint64* source_ptr = reinterpret_cast<uint64*> (&source_val); |
730 | 6 | uint64 source_big_endian = BigEndian::FromHost64(*source_ptr); |
731 | 6 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeBigInt); |
732 | 6 | } |
733 | 6 | return Status::OK(); |
734 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertDoubleToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertDoubleToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 724 | 6 | CHECKED_STATUS ConvertDoubleToBlob(PTypePtr source, RTypePtr target) { | 725 | 6 | if (source->IsNull()) { | 726 | 0 | target->SetNull(); | 727 | 6 | } else { | 728 | 6 | double source_val = source->double_value(); | 729 | 6 | uint64* source_ptr = reinterpret_cast<uint64*> (&source_val); | 730 | 6 | uint64 source_big_endian = BigEndian::FromHost64(*source_ptr); | 731 | 6 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeBigInt); | 732 | 6 | } | 733 | 6 | return Status::OK(); | 734 | 6 | } |
|
735 | | |
736 | | template<typename PTypePtr, typename RTypePtr> |
737 | 0 | CHECKED_STATUS ConvertDecimalToBlob(PTypePtr source, RTypePtr target) { |
738 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
739 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertDecimalToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertDecimalToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
740 | | |
741 | | template<typename PTypePtr, typename RTypePtr> |
742 | 0 | CHECKED_STATUS ConvertDateToBlob(PTypePtr source, RTypePtr target) { |
743 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
744 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertDateToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertDateToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
745 | | |
746 | | template<typename PTypePtr, typename RTypePtr> |
747 | 0 | CHECKED_STATUS ConvertTimeToBlob(PTypePtr source, RTypePtr target) { |
748 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
749 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
750 | | |
751 | | template<typename PTypePtr, typename RTypePtr> |
752 | 8 | CHECKED_STATUS ConvertTimestampToBlob(PTypePtr source, RTypePtr target) { |
753 | 8 | if (source->IsNull()) { |
754 | 0 | target->SetNull(); |
755 | 8 | } else { |
756 | 8 | Timestamp source_val = source->timestamp_value(); |
757 | 8 | int64_t ts_int_value = source_val.ToInt64(); |
758 | 8 | ts_int_value = DateTime::AdjustPrecision(ts_int_value, DateTime::kInternalPrecision, |
759 | 8 | DateTime::kMillisecondPrecision); |
760 | 8 | uint64* source_ptr = reinterpret_cast<uint64*> (&ts_int_value); |
761 | 8 | uint64 source_big_endian = BigEndian::FromHost64(*source_ptr); |
762 | 8 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeBigInt); |
763 | 8 | } |
764 | 8 | return Status::OK(); |
765 | 8 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimestampToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertTimestampToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 752 | 8 | CHECKED_STATUS ConvertTimestampToBlob(PTypePtr source, RTypePtr target) { | 753 | 8 | if (source->IsNull()) { | 754 | 0 | target->SetNull(); | 755 | 8 | } else { | 756 | 8 | Timestamp source_val = source->timestamp_value(); | 757 | 8 | int64_t ts_int_value = source_val.ToInt64(); | 758 | 8 | ts_int_value = DateTime::AdjustPrecision(ts_int_value, DateTime::kInternalPrecision, | 759 | 8 | DateTime::kMillisecondPrecision); | 760 | 8 | uint64* source_ptr = reinterpret_cast<uint64*> (&ts_int_value); | 761 | 8 | uint64 source_big_endian = BigEndian::FromHost64(*source_ptr); | 762 | 8 | target->set_binary_value(reinterpret_cast<void *> (&source_big_endian), kSizeBigInt); | 763 | 8 | } | 764 | 8 | return Status::OK(); | 765 | 8 | } |
|
766 | | |
767 | | template<typename PTypePtr, typename RTypePtr> |
768 | 8 | CHECKED_STATUS ConvertUuidToBlob(PTypePtr source, RTypePtr target) { |
769 | 8 | if (source->IsNull()) { |
770 | 0 | target->SetNull(); |
771 | 8 | } else { |
772 | 8 | string byte_stream; |
773 | 8 | const Uuid& source_val = source->uuid_value(); |
774 | 8 | source_val.ToBytes(&byte_stream); |
775 | 8 | target->set_binary_value(byte_stream); |
776 | 8 | } |
777 | 8 | return Status::OK(); |
778 | 8 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertUuidToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertUuidToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 768 | 8 | CHECKED_STATUS ConvertUuidToBlob(PTypePtr source, RTypePtr target) { | 769 | 8 | if (source->IsNull()) { | 770 | 0 | target->SetNull(); | 771 | 8 | } else { | 772 | 8 | string byte_stream; | 773 | 8 | const Uuid& source_val = source->uuid_value(); | 774 | 8 | source_val.ToBytes(&byte_stream); | 775 | 8 | target->set_binary_value(byte_stream); | 776 | 8 | } | 777 | 8 | return Status::OK(); | 778 | 8 | } |
|
779 | | |
780 | | template<typename PTypePtr, typename RTypePtr> |
781 | 4 | CHECKED_STATUS ConvertTimeuuidToBlob(PTypePtr source, RTypePtr target) { |
782 | 4 | if (source->IsNull()) { |
783 | 0 | target->SetNull(); |
784 | 4 | } else { |
785 | 4 | string byte_stream; |
786 | 4 | const Uuid& source_val = source->timeuuid_value(); |
787 | 4 | source_val.ToBytes(&byte_stream); |
788 | 4 | target->set_binary_value(byte_stream); |
789 | 4 | } |
790 | 4 | return Status::OK(); |
791 | 4 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeuuidToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertTimeuuidToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 781 | 4 | CHECKED_STATUS ConvertTimeuuidToBlob(PTypePtr source, RTypePtr target) { | 782 | 4 | if (source->IsNull()) { | 783 | 0 | target->SetNull(); | 784 | 4 | } else { | 785 | 4 | string byte_stream; | 786 | 4 | const Uuid& source_val = source->timeuuid_value(); | 787 | 4 | source_val.ToBytes(&byte_stream); | 788 | 4 | target->set_binary_value(byte_stream); | 789 | 4 | } | 790 | 4 | return Status::OK(); | 791 | 4 | } |
|
792 | | |
793 | | template<typename PTypePtr, typename RTypePtr> |
794 | 0 | CHECKED_STATUS ConvertInetToBlob(PTypePtr source, RTypePtr target) { |
795 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
796 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertInetToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertInetToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
797 | | |
798 | | template<typename PTypePtr, typename RTypePtr> |
799 | 0 | CHECKED_STATUS ConvertListToBlob(PTypePtr source, RTypePtr target) { |
800 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
801 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertListToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertListToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
802 | | |
803 | | template<typename PTypePtr, typename RTypePtr> |
804 | 0 | CHECKED_STATUS ConvertMapToBlob(PTypePtr source, RTypePtr target) { |
805 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
806 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertMapToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertMapToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
807 | | |
808 | | template<typename PTypePtr, typename RTypePtr> |
809 | 0 | CHECKED_STATUS ConvertSetToBlob(PTypePtr source, RTypePtr target) { |
810 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
811 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertSetToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertSetToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
812 | | |
813 | | template<typename PTypePtr, typename RTypePtr> |
814 | 0 | CHECKED_STATUS ConvertTupleToBlob(PTypePtr source, RTypePtr target) { |
815 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
816 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTupleToBlob<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertTupleToBlob<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
817 | | |
818 | | // The following functions are for conversions from blob / binary to other datatypes. |
819 | | |
820 | | template<typename PTypePtr, typename RTypePtr> |
821 | 12 | CHECKED_STATUS ConvertBlobToString(PTypePtr source, RTypePtr target) { |
822 | 12 | if (source->IsNull()) { |
823 | 0 | target->SetNull(); |
824 | 12 | } else { |
825 | 12 | target->set_string_value(source->binary_value()); |
826 | 12 | } |
827 | 12 | return Status::OK(); |
828 | 12 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToString<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToString<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 821 | 12 | CHECKED_STATUS ConvertBlobToString(PTypePtr source, RTypePtr target) { | 822 | 12 | if (source->IsNull()) { | 823 | 0 | target->SetNull(); | 824 | 12 | } else { | 825 | 12 | target->set_string_value(source->binary_value()); | 826 | 12 | } | 827 | 12 | return Status::OK(); | 828 | 12 | } |
|
829 | | |
830 | | template<typename PTypePtr, typename RTypePtr> |
831 | 4 | CHECKED_STATUS ConvertBlobToBool(PTypePtr source, RTypePtr target) { |
832 | 4 | if (source->IsNull()) { |
833 | 0 | target->SetNull(); |
834 | 4 | } else { |
835 | 4 | string blob = source->binary_value(); |
836 | 4 | if (blob.size() != kSizeBool) { |
837 | 0 | return STATUS(QLError, "The blob string is not a valid string for a boolean type."); |
838 | 0 | } |
839 | 4 | target->set_bool_value(blob[0] != 0); |
840 | 4 | } |
841 | 4 | return Status::OK(); |
842 | 4 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToBool<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToBool<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 831 | 4 | CHECKED_STATUS ConvertBlobToBool(PTypePtr source, RTypePtr target) { | 832 | 4 | if (source->IsNull()) { | 833 | 0 | target->SetNull(); | 834 | 4 | } else { | 835 | 4 | string blob = source->binary_value(); | 836 | 4 | if (blob.size() != kSizeBool) { | 837 | 0 | return STATUS(QLError, "The blob string is not a valid string for a boolean type."); | 838 | 0 | } | 839 | 4 | target->set_bool_value(blob[0] != 0); | 840 | 4 | } | 841 | 4 | return Status::OK(); | 842 | 4 | } |
|
843 | | |
844 | | template<typename PTypePtr, typename RTypePtr> |
845 | 6 | CHECKED_STATUS ConvertBlobToInt8(PTypePtr source, RTypePtr target) { |
846 | 6 | if (source->IsNull()) { |
847 | 0 | target->SetNull(); |
848 | 6 | } else { |
849 | 6 | string blob = source->binary_value(); |
850 | 6 | if (blob.size() != kSizeTinyInt) { |
851 | 0 | return STATUS(QLError, "The blob string is not valid for tinyint type."); |
852 | 0 | } |
853 | 6 | target->set_int8_value(static_cast<int8_t> (blob[0])); |
854 | 6 | } |
855 | 6 | return Status::OK(); |
856 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToInt8<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToInt8<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 845 | 6 | CHECKED_STATUS ConvertBlobToInt8(PTypePtr source, RTypePtr target) { | 846 | 6 | if (source->IsNull()) { | 847 | 0 | target->SetNull(); | 848 | 6 | } else { | 849 | 6 | string blob = source->binary_value(); | 850 | 6 | if (blob.size() != kSizeTinyInt) { | 851 | 0 | return STATUS(QLError, "The blob string is not valid for tinyint type."); | 852 | 0 | } | 853 | 6 | target->set_int8_value(static_cast<int8_t> (blob[0])); | 854 | 6 | } | 855 | 6 | return Status::OK(); | 856 | 6 | } |
|
857 | | |
858 | | template<typename PTypePtr, typename RTypePtr> |
859 | 6 | CHECKED_STATUS ConvertBlobToInt16(PTypePtr source, RTypePtr target) { |
860 | 6 | if (source->IsNull()) { |
861 | 0 | target->SetNull(); |
862 | 6 | } else { |
863 | 6 | string blob = source->binary_value(); |
864 | 6 | if (blob.size() != kSizeSmallInt) { |
865 | 0 | return STATUS(QLError, "The blob string is not valid for smallint type."); |
866 | 0 | } |
867 | 6 | uint16* target_ptr = reinterpret_cast<uint16*> (const_cast <char*> (blob.c_str())); |
868 | 6 | uint16 target_little_endian = BigEndian::ToHost16(*target_ptr); |
869 | 6 | int16_t* target_val_ptr = reinterpret_cast<int16_t*> (&target_little_endian); |
870 | 6 | target->set_int16_value(*target_val_ptr); |
871 | 6 | } |
872 | 6 | return Status::OK(); |
873 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToInt16<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToInt16<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 859 | 6 | CHECKED_STATUS ConvertBlobToInt16(PTypePtr source, RTypePtr target) { | 860 | 6 | if (source->IsNull()) { | 861 | 0 | target->SetNull(); | 862 | 6 | } else { | 863 | 6 | string blob = source->binary_value(); | 864 | 6 | if (blob.size() != kSizeSmallInt) { | 865 | 0 | return STATUS(QLError, "The blob string is not valid for smallint type."); | 866 | 0 | } | 867 | 6 | uint16* target_ptr = reinterpret_cast<uint16*> (const_cast <char*> (blob.c_str())); | 868 | 6 | uint16 target_little_endian = BigEndian::ToHost16(*target_ptr); | 869 | 6 | int16_t* target_val_ptr = reinterpret_cast<int16_t*> (&target_little_endian); | 870 | 6 | target->set_int16_value(*target_val_ptr); | 871 | 6 | } | 872 | 6 | return Status::OK(); | 873 | 6 | } |
|
874 | | |
875 | | template<typename PTypePtr, typename RTypePtr> |
876 | 6 | CHECKED_STATUS ConvertBlobToInt32(PTypePtr source, RTypePtr target) { |
877 | 6 | if (source->IsNull()) { |
878 | 0 | target->SetNull(); |
879 | 6 | } else { |
880 | 6 | string blob = source->binary_value(); |
881 | 6 | if (blob.size() != kSizeInt) { |
882 | 0 | return STATUS(QLError, "The blob string is not valid for int type."); |
883 | 0 | } |
884 | 6 | uint32* target_ptr = reinterpret_cast<uint32*> (const_cast <char*> (blob.c_str())); |
885 | 6 | uint32 target_little_endian = BigEndian::ToHost32(*target_ptr); |
886 | 6 | int32_t* target_val_ptr = reinterpret_cast<int32_t*> (&target_little_endian); |
887 | 6 | target->set_int32_value(*target_val_ptr); |
888 | 6 | } |
889 | 6 | return Status::OK(); |
890 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToInt32<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToInt32<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 876 | 6 | CHECKED_STATUS ConvertBlobToInt32(PTypePtr source, RTypePtr target) { | 877 | 6 | if (source->IsNull()) { | 878 | 0 | target->SetNull(); | 879 | 6 | } else { | 880 | 6 | string blob = source->binary_value(); | 881 | 6 | if (blob.size() != kSizeInt) { | 882 | 0 | return STATUS(QLError, "The blob string is not valid for int type."); | 883 | 0 | } | 884 | 6 | uint32* target_ptr = reinterpret_cast<uint32*> (const_cast <char*> (blob.c_str())); | 885 | 6 | uint32 target_little_endian = BigEndian::ToHost32(*target_ptr); | 886 | 6 | int32_t* target_val_ptr = reinterpret_cast<int32_t*> (&target_little_endian); | 887 | 6 | target->set_int32_value(*target_val_ptr); | 888 | 6 | } | 889 | 6 | return Status::OK(); | 890 | 6 | } |
|
891 | | |
892 | | template<typename PTypePtr, typename RTypePtr> |
893 | 6 | CHECKED_STATUS ConvertBlobToInt64(PTypePtr source, RTypePtr target) { |
894 | 6 | if (source->IsNull()) { |
895 | 0 | target->SetNull(); |
896 | 6 | } else { |
897 | 6 | string blob = source->binary_value(); |
898 | 6 | if (blob.size() != kSizeBigInt) { |
899 | 0 | return STATUS(QLError, "The blob string is not valid for bigint type."); |
900 | 0 | } |
901 | 6 | uint64* target_ptr = reinterpret_cast<uint64*> (const_cast <char*> (blob.c_str())); |
902 | 6 | uint64 target_little_endian = BigEndian::ToHost64(*target_ptr); |
903 | 6 | int64_t* target_val_ptr = reinterpret_cast<int64_t*> (&target_little_endian); |
904 | 6 | target->set_int64_value(*target_val_ptr); |
905 | 6 | } |
906 | 6 | return Status::OK(); |
907 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToInt64<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToInt64<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 893 | 6 | CHECKED_STATUS ConvertBlobToInt64(PTypePtr source, RTypePtr target) { | 894 | 6 | if (source->IsNull()) { | 895 | 0 | target->SetNull(); | 896 | 6 | } else { | 897 | 6 | string blob = source->binary_value(); | 898 | 6 | if (blob.size() != kSizeBigInt) { | 899 | 0 | return STATUS(QLError, "The blob string is not valid for bigint type."); | 900 | 0 | } | 901 | 6 | uint64* target_ptr = reinterpret_cast<uint64*> (const_cast <char*> (blob.c_str())); | 902 | 6 | uint64 target_little_endian = BigEndian::ToHost64(*target_ptr); | 903 | 6 | int64_t* target_val_ptr = reinterpret_cast<int64_t*> (&target_little_endian); | 904 | 6 | target->set_int64_value(*target_val_ptr); | 905 | 6 | } | 906 | 6 | return Status::OK(); | 907 | 6 | } |
|
908 | | |
909 | | template<typename PTypePtr, typename RTypePtr> |
910 | 0 | CHECKED_STATUS ConvertBlobToVarint(PTypePtr source, RTypePtr target) { |
911 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
912 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToVarint<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToVarint<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
913 | | |
914 | | template<typename PTypePtr, typename RTypePtr> |
915 | 3 | CHECKED_STATUS ConvertBlobToFloat(PTypePtr source, RTypePtr target) { |
916 | 3 | if (source->IsNull()) { |
917 | 0 | target->SetNull(); |
918 | 3 | } else { |
919 | 3 | string blob = source->binary_value(); |
920 | 3 | if (blob.size() != kSizeInt) { |
921 | 0 | return STATUS(QLError, "The blob string is not valid for float type."); |
922 | 0 | } |
923 | 3 | uint32* target_ptr = reinterpret_cast<uint32*> (const_cast <char*> (blob.c_str())); |
924 | 3 | uint32 target_little_endian = BigEndian::ToHost32(*target_ptr); |
925 | 3 | float* target_val_ptr = reinterpret_cast<float*> (&target_little_endian); |
926 | 3 | target->set_float_value(*target_val_ptr); |
927 | 3 | } |
928 | 3 | return Status::OK(); |
929 | 3 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 915 | 3 | CHECKED_STATUS ConvertBlobToFloat(PTypePtr source, RTypePtr target) { | 916 | 3 | if (source->IsNull()) { | 917 | 0 | target->SetNull(); | 918 | 3 | } else { | 919 | 3 | string blob = source->binary_value(); | 920 | 3 | if (blob.size() != kSizeInt) { | 921 | 0 | return STATUS(QLError, "The blob string is not valid for float type."); | 922 | 0 | } | 923 | 3 | uint32* target_ptr = reinterpret_cast<uint32*> (const_cast <char*> (blob.c_str())); | 924 | 3 | uint32 target_little_endian = BigEndian::ToHost32(*target_ptr); | 925 | 3 | float* target_val_ptr = reinterpret_cast<float*> (&target_little_endian); | 926 | 3 | target->set_float_value(*target_val_ptr); | 927 | 3 | } | 928 | 3 | return Status::OK(); | 929 | 3 | } |
|
930 | | |
931 | | template<typename PTypePtr, typename RTypePtr> |
932 | 3 | CHECKED_STATUS ConvertBlobToDouble(PTypePtr source, RTypePtr target) { |
933 | 3 | if (source->IsNull()) { |
934 | 0 | target->SetNull(); |
935 | 3 | } else { |
936 | 3 | string blob = source->binary_value(); |
937 | 3 | if (blob.size() != kSizeBigInt) { |
938 | 0 | return STATUS(QLError, "The blob string is not valid for double type."); |
939 | 0 | } |
940 | 3 | uint64* target_ptr = reinterpret_cast<uint64*> (const_cast <char*> (blob.c_str())); |
941 | 3 | uint64 target_little_endian = BigEndian::ToHost64(*target_ptr); |
942 | 3 | double* target_val_ptr = reinterpret_cast<double*> (&target_little_endian); |
943 | 3 | target->set_double_value(*target_val_ptr); |
944 | 3 | } |
945 | 3 | return Status::OK(); |
946 | 3 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 932 | 3 | CHECKED_STATUS ConvertBlobToDouble(PTypePtr source, RTypePtr target) { | 933 | 3 | if (source->IsNull()) { | 934 | 0 | target->SetNull(); | 935 | 3 | } else { | 936 | 3 | string blob = source->binary_value(); | 937 | 3 | if (blob.size() != kSizeBigInt) { | 938 | 0 | return STATUS(QLError, "The blob string is not valid for double type."); | 939 | 0 | } | 940 | 3 | uint64* target_ptr = reinterpret_cast<uint64*> (const_cast <char*> (blob.c_str())); | 941 | 3 | uint64 target_little_endian = BigEndian::ToHost64(*target_ptr); | 942 | 3 | double* target_val_ptr = reinterpret_cast<double*> (&target_little_endian); | 943 | 3 | target->set_double_value(*target_val_ptr); | 944 | 3 | } | 945 | 3 | return Status::OK(); | 946 | 3 | } |
|
947 | | |
948 | | template<typename PTypePtr, typename RTypePtr> |
949 | 0 | CHECKED_STATUS ConvertBlobToDecimal(PTypePtr source, RTypePtr target) { |
950 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
951 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToDecimal<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToDecimal<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
952 | | |
953 | | template<typename PTypePtr, typename RTypePtr> |
954 | 0 | CHECKED_STATUS ConvertBlobToDate(PTypePtr source, RTypePtr target) { |
955 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
956 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToDate<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToDate<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
957 | | |
958 | | template<typename PTypePtr, typename RTypePtr> |
959 | 0 | CHECKED_STATUS ConvertBlobToTime(PTypePtr source, RTypePtr target) { |
960 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
961 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToTime<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToTime<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
962 | | |
963 | | template<typename PTypePtr, typename RTypePtr> |
964 | 4 | CHECKED_STATUS ConvertBlobToTimestamp(PTypePtr source, RTypePtr target) { |
965 | 4 | if (source->IsNull()) { |
966 | 0 | target->SetNull(); |
967 | 4 | } else { |
968 | 4 | string blob = source->binary_value(); |
969 | 4 | if (blob.size() != kSizeBigInt) { |
970 | 0 | return STATUS(QLError, "The blob string is not a valid Timestamp."); |
971 | 0 | } |
972 | 4 | uint64* target_ptr = reinterpret_cast<uint64*> (const_cast <char*> (blob.c_str())); |
973 | 4 | uint64 target_little_endian = BigEndian::ToHost64(*target_ptr); |
974 | 4 | int64_t* target_val_ptr = reinterpret_cast<int64_t*> (&target_little_endian); |
975 | 4 | int64_t target_val = DateTime::AdjustPrecision(*target_val_ptr, |
976 | 4 | DateTime::kMillisecondPrecision, |
977 | 4 | DateTime::kInternalPrecision); |
978 | 4 | Timestamp ts(target_val); |
979 | 4 | target->set_timestamp_value(ts); |
980 | 4 | } |
981 | 4 | return Status::OK(); |
982 | 4 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToTimestamp<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToTimestamp<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 964 | 4 | CHECKED_STATUS ConvertBlobToTimestamp(PTypePtr source, RTypePtr target) { | 965 | 4 | if (source->IsNull()) { | 966 | 0 | target->SetNull(); | 967 | 4 | } else { | 968 | 4 | string blob = source->binary_value(); | 969 | 4 | if (blob.size() != kSizeBigInt) { | 970 | 0 | return STATUS(QLError, "The blob string is not a valid Timestamp."); | 971 | 0 | } | 972 | 4 | uint64* target_ptr = reinterpret_cast<uint64*> (const_cast <char*> (blob.c_str())); | 973 | 4 | uint64 target_little_endian = BigEndian::ToHost64(*target_ptr); | 974 | 4 | int64_t* target_val_ptr = reinterpret_cast<int64_t*> (&target_little_endian); | 975 | 4 | int64_t target_val = DateTime::AdjustPrecision(*target_val_ptr, | 976 | 4 | DateTime::kMillisecondPrecision, | 977 | 4 | DateTime::kInternalPrecision); | 978 | 4 | Timestamp ts(target_val); | 979 | 4 | target->set_timestamp_value(ts); | 980 | 4 | } | 981 | 4 | return Status::OK(); | 982 | 4 | } |
|
983 | | |
984 | | template<typename PTypePtr, typename RTypePtr> |
985 | 8 | CHECKED_STATUS ConvertBlobToUuid(PTypePtr source, RTypePtr target) { |
986 | 8 | if (source->IsNull()) { |
987 | 0 | target->SetNull(); |
988 | 8 | } else { |
989 | 8 | string blob = source->binary_value(); |
990 | 8 | if (blob.size() != kSizeUuid) { |
991 | 0 | return STATUS(QLError, "The blob string is not valid for UUID type."); |
992 | 0 | } |
993 | 8 | Uuid target_val; |
994 | 8 | RETURN_NOT_OK(target_val.FromBytes(blob)); |
995 | 8 | target->set_uuid_value(target_val); |
996 | 8 | } |
997 | 8 | return Status::OK(); |
998 | 8 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToUuid<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToUuid<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 985 | 8 | CHECKED_STATUS ConvertBlobToUuid(PTypePtr source, RTypePtr target) { | 986 | 8 | if (source->IsNull()) { | 987 | 0 | target->SetNull(); | 988 | 8 | } else { | 989 | 8 | string blob = source->binary_value(); | 990 | 8 | if (blob.size() != kSizeUuid) { | 991 | 0 | return STATUS(QLError, "The blob string is not valid for UUID type."); | 992 | 0 | } | 993 | 8 | Uuid target_val; | 994 | 8 | RETURN_NOT_OK(target_val.FromBytes(blob)); | 995 | 8 | target->set_uuid_value(target_val); | 996 | 8 | } | 997 | 8 | return Status::OK(); | 998 | 8 | } |
|
999 | | |
1000 | | template<typename PTypePtr, typename RTypePtr> |
1001 | 4 | CHECKED_STATUS ConvertBlobToTimeuuid(PTypePtr source, RTypePtr target) { |
1002 | 4 | if (source->IsNull()) { |
1003 | 0 | target->SetNull(); |
1004 | 4 | } else { |
1005 | 4 | string blob = source->binary_value(); |
1006 | 4 | if (blob.size() != kSizeUuid) { |
1007 | 0 | return STATUS(QLError, "The blob string is not valid for UUID type."); |
1008 | 0 | } |
1009 | 4 | Uuid target_val; |
1010 | 4 | RETURN_NOT_OK(target_val.FromBytes(blob)); |
1011 | 4 | target->set_timeuuid_value(target_val); |
1012 | 4 | } |
1013 | 4 | return Status::OK(); |
1014 | 4 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToTimeuuid<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertBlobToTimeuuid<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1001 | 4 | CHECKED_STATUS ConvertBlobToTimeuuid(PTypePtr source, RTypePtr target) { | 1002 | 4 | if (source->IsNull()) { | 1003 | 0 | target->SetNull(); | 1004 | 4 | } else { | 1005 | 4 | string blob = source->binary_value(); | 1006 | 4 | if (blob.size() != kSizeUuid) { | 1007 | 0 | return STATUS(QLError, "The blob string is not valid for UUID type."); | 1008 | 0 | } | 1009 | 4 | Uuid target_val; | 1010 | 4 | RETURN_NOT_OK(target_val.FromBytes(blob)); | 1011 | 4 | target->set_timeuuid_value(target_val); | 1012 | 4 | } | 1013 | 4 | return Status::OK(); | 1014 | 4 | } |
|
1015 | | |
1016 | | template<typename PTypePtr, typename RTypePtr> |
1017 | 0 | CHECKED_STATUS ConvertBlobToInet(PTypePtr source, RTypePtr target) { |
1018 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
1019 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToInet<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToInet<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1020 | | |
1021 | | template<typename PTypePtr, typename RTypePtr> |
1022 | 0 | CHECKED_STATUS ConvertBlobToList(PTypePtr source, RTypePtr target) { |
1023 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
1024 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToList<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToList<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1025 | | |
1026 | | template<typename PTypePtr, typename RTypePtr> |
1027 | 0 | CHECKED_STATUS ConvertBlobToMap(PTypePtr source, RTypePtr target) { |
1028 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
1029 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToMap<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToMap<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1030 | | |
1031 | | template<typename PTypePtr, typename RTypePtr> |
1032 | 0 | CHECKED_STATUS ConvertBlobToSet(PTypePtr source, RTypePtr target) { |
1033 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
1034 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToSet<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToSet<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1035 | | |
1036 | | template<typename PTypePtr, typename RTypePtr> |
1037 | 0 | CHECKED_STATUS ConvertBlobToTuple(PTypePtr source, RTypePtr target) { |
1038 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
1039 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToTuple<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertBlobToTuple<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1040 | | |
1041 | | //-------------------------------------------------------------------------------------------------- |
1042 | | // The following functions are for conversions between date-time datatypes. |
1043 | | template<typename PTypePtr, typename RTypePtr> |
1044 | 0 | CHECKED_STATUS ConvertTimeuuidToDate(PTypePtr source, RTypePtr target) { |
1045 | 0 | if (source->IsNull()) { |
1046 | 0 | target->SetNull(); |
1047 | 0 | return Status::OK(); |
1048 | 0 | } |
1049 | 0 | return SetDateResult(source, target); |
1050 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeuuidToDate<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeuuidToDate<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1051 | | |
1052 | | template<typename PTypePtr, typename RTypePtr> |
1053 | 1 | CHECKED_STATUS ConvertTimestampToDate(PTypePtr source, RTypePtr target) { |
1054 | 1 | if (source->IsNull()) { |
1055 | 0 | target->SetNull(); |
1056 | 0 | return Status::OK(); |
1057 | 0 | } |
1058 | 1 | return SetDateResult(source, target); |
1059 | 1 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimestampToDate<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertTimestampToDate<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1053 | 1 | CHECKED_STATUS ConvertTimestampToDate(PTypePtr source, RTypePtr target) { | 1054 | 1 | if (source->IsNull()) { | 1055 | 0 | target->SetNull(); | 1056 | 0 | return Status::OK(); | 1057 | 0 | } | 1058 | 1 | return SetDateResult(source, target); | 1059 | 1 | } |
|
1060 | | |
1061 | | template<typename PTypePtr, typename RTypePtr> |
1062 | 0 | CHECKED_STATUS ConvertTimeuuidToTime(PTypePtr source, RTypePtr target) { |
1063 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
1064 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeuuidToTime<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeuuidToTime<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1065 | | |
1066 | | template<typename PTypePtr, typename RTypePtr> |
1067 | 0 | CHECKED_STATUS ConvertTimestampToTime(PTypePtr source, RTypePtr target) { |
1068 | 0 | return STATUS(RuntimeError, "Not yet implemented"); |
1069 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimestampToTime<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertTimestampToTime<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1070 | | |
1071 | | template<typename PTypePtr, typename RTypePtr> |
1072 | 1 | CHECKED_STATUS ConvertDateToTimestamp(PTypePtr source, RTypePtr target) { |
1073 | 1 | if (source->IsNull()) { |
1074 | 0 | target->SetNull(); |
1075 | 0 | return Status::OK(); |
1076 | 0 | } |
1077 | 1 | return SetTimestampResult(source, target); |
1078 | 1 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertDateToTimestamp<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertDateToTimestamp<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1072 | 1 | CHECKED_STATUS ConvertDateToTimestamp(PTypePtr source, RTypePtr target) { | 1073 | 1 | if (source->IsNull()) { | 1074 | 0 | target->SetNull(); | 1075 | 0 | return Status::OK(); | 1076 | 0 | } | 1077 | 1 | return SetTimestampResult(source, target); | 1078 | 1 | } |
|
1079 | | |
1080 | | template<typename PTypePtr, typename RTypePtr> |
1081 | 33 | CHECKED_STATUS ConvertTimeuuidToTimestamp(PTypePtr source, RTypePtr target) { |
1082 | 33 | if (source->IsNull()) { |
1083 | 0 | target->SetNull(); |
1084 | 0 | return Status::OK(); |
1085 | 0 | } |
1086 | 33 | return SetTimestampResult(source, target); |
1087 | 33 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeuuidToTimestamp<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertTimeuuidToTimestamp<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1081 | 33 | CHECKED_STATUS ConvertTimeuuidToTimestamp(PTypePtr source, RTypePtr target) { | 1082 | 33 | if (source->IsNull()) { | 1083 | 0 | target->SetNull(); | 1084 | 0 | return Status::OK(); | 1085 | 0 | } | 1086 | 33 | return SetTimestampResult(source, target); | 1087 | 33 | } |
|
1088 | | |
1089 | | template<typename PTypePtr, typename RTypePtr> |
1090 | 1 | CHECKED_STATUS ConvertDateToUnixTimestamp(PTypePtr source, RTypePtr target) { |
1091 | 1 | if (source->IsNull()) { |
1092 | 0 | target->SetNull(); |
1093 | 1 | } else { |
1094 | 1 | target->set_int64_value(DateTime::DateToUnixTimestamp(source->date_value())); |
1095 | 1 | } |
1096 | 1 | return Status::OK(); |
1097 | 1 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertDateToUnixTimestamp<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertDateToUnixTimestamp<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1090 | 1 | CHECKED_STATUS ConvertDateToUnixTimestamp(PTypePtr source, RTypePtr target) { | 1091 | 1 | if (source->IsNull()) { | 1092 | 0 | target->SetNull(); | 1093 | 1 | } else { | 1094 | 1 | target->set_int64_value(DateTime::DateToUnixTimestamp(source->date_value())); | 1095 | 1 | } | 1096 | 1 | return Status::OK(); | 1097 | 1 | } |
|
1098 | | |
1099 | | template<typename PTypePtr, typename RTypePtr> |
1100 | 4 | CHECKED_STATUS ConvertTimestampToUnixTimestamp(PTypePtr source, RTypePtr target) { |
1101 | 4 | if (source->IsNull()) { |
1102 | 0 | target->SetNull(); |
1103 | 4 | } else { |
1104 | 4 | int64_t unix_timestamp = DateTime::AdjustPrecision(source->timestamp_value().ToInt64(), |
1105 | 4 | DateTime::kInternalPrecision, |
1106 | 4 | DateTime::kMillisecondPrecision); |
1107 | 4 | target->set_int64_value(unix_timestamp); |
1108 | 4 | } |
1109 | 4 | return Status::OK(); |
1110 | 4 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimestampToUnixTimestamp<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertTimestampToUnixTimestamp<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1100 | 4 | CHECKED_STATUS ConvertTimestampToUnixTimestamp(PTypePtr source, RTypePtr target) { | 1101 | 4 | if (source->IsNull()) { | 1102 | 0 | target->SetNull(); | 1103 | 4 | } else { | 1104 | 4 | int64_t unix_timestamp = DateTime::AdjustPrecision(source->timestamp_value().ToInt64(), | 1105 | 4 | DateTime::kInternalPrecision, | 1106 | 4 | DateTime::kMillisecondPrecision); | 1107 | 4 | target->set_int64_value(unix_timestamp); | 1108 | 4 | } | 1109 | 4 | return Status::OK(); | 1110 | 4 | } |
|
1111 | | |
1112 | | template<typename PTypePtr, typename RTypePtr> |
1113 | 10 | CHECKED_STATUS ConvertTimeuuidToUnixTimestamp(PTypePtr source, RTypePtr target) { |
1114 | 10 | if (source->IsNull()) { |
1115 | 0 | target->SetNull(); |
1116 | 10 | } else { |
1117 | 10 | Uuid time_uuid = source->timeuuid_value(); |
1118 | 10 | int64_t unix_timestamp; |
1119 | 10 | RETURN_NOT_OK(time_uuid.ToUnixTimestamp(&unix_timestamp)); |
1120 | 10 | target->set_int64_value(unix_timestamp); |
1121 | 10 | } |
1122 | 10 | return Status::OK(); |
1123 | 10 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertTimeuuidToUnixTimestamp<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertTimeuuidToUnixTimestamp<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1113 | 10 | CHECKED_STATUS ConvertTimeuuidToUnixTimestamp(PTypePtr source, RTypePtr target) { | 1114 | 10 | if (source->IsNull()) { | 1115 | 0 | target->SetNull(); | 1116 | 10 | } else { | 1117 | 10 | Uuid time_uuid = source->timeuuid_value(); | 1118 | 10 | int64_t unix_timestamp; | 1119 | 10 | RETURN_NOT_OK(time_uuid.ToUnixTimestamp(&unix_timestamp)); | 1120 | 10 | target->set_int64_value(unix_timestamp); | 1121 | 10 | } | 1122 | 10 | return Status::OK(); | 1123 | 10 | } |
|
1124 | | |
1125 | | template<typename PTypePtr, typename RTypePtr> |
1126 | 8 | CHECKED_STATUS ConvertToMaxTimeuuid(PTypePtr source, RTypePtr target) { |
1127 | 8 | if (source->IsNull()) { |
1128 | 0 | return STATUS(RuntimeError, "Cannot get max timeuuid of null"); |
1129 | 8 | } else { |
1130 | 8 | int64_t timestamp_ms = DateTime::AdjustPrecision(source->timestamp_value().ToInt64(), |
1131 | 8 | DateTime::kInternalPrecision, |
1132 | 8 | DateTime::kMillisecondPrecision); |
1133 | | |
1134 | 8 | Uuid uuid; |
1135 | 8 | RETURN_NOT_OK(uuid.MaxFromUnixTimestamp(timestamp_ms)); |
1136 | 8 | target->set_timeuuid_value(uuid); |
1137 | 8 | } |
1138 | 8 | return Status::OK(); |
1139 | 8 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToMaxTimeuuid<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToMaxTimeuuid<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1126 | 8 | CHECKED_STATUS ConvertToMaxTimeuuid(PTypePtr source, RTypePtr target) { | 1127 | 8 | if (source->IsNull()) { | 1128 | 0 | return STATUS(RuntimeError, "Cannot get max timeuuid of null"); | 1129 | 8 | } else { | 1130 | 8 | int64_t timestamp_ms = DateTime::AdjustPrecision(source->timestamp_value().ToInt64(), | 1131 | 8 | DateTime::kInternalPrecision, | 1132 | 8 | DateTime::kMillisecondPrecision); | 1133 | | | 1134 | 8 | Uuid uuid; | 1135 | 8 | RETURN_NOT_OK(uuid.MaxFromUnixTimestamp(timestamp_ms)); | 1136 | 8 | target->set_timeuuid_value(uuid); | 1137 | 8 | } | 1138 | 8 | return Status::OK(); | 1139 | 8 | } |
|
1140 | | |
1141 | | template<typename PTypePtr, typename RTypePtr> |
1142 | 10 | CHECKED_STATUS ConvertToMinTimeuuid(PTypePtr source, RTypePtr target) { |
1143 | 10 | if (source->IsNull()) { |
1144 | 0 | return STATUS(RuntimeError, "Cannot get max timeuuid of null"); |
1145 | 10 | } else { |
1146 | 10 | int64_t timestamp_ms = DateTime::AdjustPrecision(source->timestamp_value().ToInt64(), |
1147 | 10 | DateTime::kInternalPrecision, |
1148 | 10 | DateTime::kMillisecondPrecision); |
1149 | | |
1150 | 10 | Uuid uuid; |
1151 | 10 | RETURN_NOT_OK(uuid.MinFromUnixTimestamp(timestamp_ms)); |
1152 | 10 | target->set_timeuuid_value(uuid); |
1153 | 10 | } |
1154 | 10 | return Status::OK(); |
1155 | 10 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToMinTimeuuid<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToMinTimeuuid<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1142 | 10 | CHECKED_STATUS ConvertToMinTimeuuid(PTypePtr source, RTypePtr target) { | 1143 | 10 | if (source->IsNull()) { | 1144 | 0 | return STATUS(RuntimeError, "Cannot get max timeuuid of null"); | 1145 | 10 | } else { | 1146 | 10 | int64_t timestamp_ms = DateTime::AdjustPrecision(source->timestamp_value().ToInt64(), | 1147 | 10 | DateTime::kInternalPrecision, | 1148 | 10 | DateTime::kMillisecondPrecision); | 1149 | | | 1150 | 10 | Uuid uuid; | 1151 | 10 | RETURN_NOT_OK(uuid.MinFromUnixTimestamp(timestamp_ms)); | 1152 | 10 | target->set_timeuuid_value(uuid); | 1153 | 10 | } | 1154 | 10 | return Status::OK(); | 1155 | 10 | } |
|
1156 | | |
1157 | | //-------------------------------------------------------------------------------------------------- |
1158 | | // The following functions are for conversions from VarInt to the other numeric types. |
1159 | | |
1160 | | template<typename PTypePtr, typename RTypePtr> |
1161 | 1 | CHECKED_STATUS ConvertVarintToI8(PTypePtr source, RTypePtr target) { |
1162 | 1 | if (source->IsNull()) { |
1163 | 0 | target->SetNull(); |
1164 | 1 | } else { |
1165 | 1 | int64_t val = VERIFY_RESULT(source->varint_value().ToInt64()); |
1166 | 1 | if (val < INT8_MIN || val > INT8_MAX) { |
1167 | 0 | return STATUS(QLError, "VarInt cannot be converted to int8 due to overflow"); |
1168 | 0 | } |
1169 | 1 | target->set_int8_value(val); |
1170 | 1 | } |
1171 | 1 | return Status::OK(); |
1172 | 1 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToI8<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertVarintToI8<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1161 | 1 | CHECKED_STATUS ConvertVarintToI8(PTypePtr source, RTypePtr target) { | 1162 | 1 | if (source->IsNull()) { | 1163 | 0 | target->SetNull(); | 1164 | 1 | } else { | 1165 | 1 | int64_t val = VERIFY_RESULT(source->varint_value().ToInt64()); | 1166 | 1 | if (val < INT8_MIN || val > INT8_MAX) { | 1167 | 0 | return STATUS(QLError, "VarInt cannot be converted to int8 due to overflow"); | 1168 | 0 | } | 1169 | 1 | target->set_int8_value(val); | 1170 | 1 | } | 1171 | 1 | return Status::OK(); | 1172 | 1 | } |
|
1173 | | |
1174 | | template<typename PTypePtr, typename RTypePtr> |
1175 | 1 | CHECKED_STATUS ConvertVarintToI16(PTypePtr source, RTypePtr target) { |
1176 | 1 | if (source->IsNull()) { |
1177 | 0 | target->SetNull(); |
1178 | 1 | } else { |
1179 | 1 | int64_t val = VERIFY_RESULT(source->varint_value().ToInt64()); |
1180 | 1 | if (val < INT16_MIN || val > INT16_MAX) { |
1181 | 0 | return STATUS(QLError, "VarInt cannot be converted to int16 due to overflow"); |
1182 | 0 | } |
1183 | 1 | target->set_int16_value(val); |
1184 | 1 | } |
1185 | 1 | return Status::OK(); |
1186 | 1 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToI16<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertVarintToI16<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1175 | 1 | CHECKED_STATUS ConvertVarintToI16(PTypePtr source, RTypePtr target) { | 1176 | 1 | if (source->IsNull()) { | 1177 | 0 | target->SetNull(); | 1178 | 1 | } else { | 1179 | 1 | int64_t val = VERIFY_RESULT(source->varint_value().ToInt64()); | 1180 | 1 | if (val < INT16_MIN || val > INT16_MAX) { | 1181 | 0 | return STATUS(QLError, "VarInt cannot be converted to int16 due to overflow"); | 1182 | 0 | } | 1183 | 1 | target->set_int16_value(val); | 1184 | 1 | } | 1185 | 1 | return Status::OK(); | 1186 | 1 | } |
|
1187 | | |
1188 | | template<typename PTypePtr, typename RTypePtr> |
1189 | 2 | CHECKED_STATUS ConvertVarintToI32(PTypePtr source, RTypePtr target) { |
1190 | 2 | if (source->IsNull()) { |
1191 | 0 | target->SetNull(); |
1192 | 2 | } else { |
1193 | 2 | int64_t val = VERIFY_RESULT(source->varint_value().ToInt64()); |
1194 | 2 | if (val < INT32_MIN || val > INT32_MAX) { |
1195 | 0 | return STATUS(QLError, "VarInt cannot be converted to int32 due to overflow"); |
1196 | 0 | } |
1197 | 2 | target->set_int32_value(static_cast<int32_t>(val)); |
1198 | 2 | } |
1199 | 2 | return Status::OK(); |
1200 | 2 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToI32<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertVarintToI32<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1189 | 2 | CHECKED_STATUS ConvertVarintToI32(PTypePtr source, RTypePtr target) { | 1190 | 2 | if (source->IsNull()) { | 1191 | 0 | target->SetNull(); | 1192 | 2 | } else { | 1193 | 2 | int64_t val = VERIFY_RESULT(source->varint_value().ToInt64()); | 1194 | 2 | if (val < INT32_MIN || val > INT32_MAX) { | 1195 | 0 | return STATUS(QLError, "VarInt cannot be converted to int32 due to overflow"); | 1196 | 0 | } | 1197 | 2 | target->set_int32_value(static_cast<int32_t>(val)); | 1198 | 2 | } | 1199 | 2 | return Status::OK(); | 1200 | 2 | } |
|
1201 | | |
1202 | | template<typename PTypePtr, typename RTypePtr> |
1203 | 10 | CHECKED_STATUS ConvertVarintToI64(PTypePtr source, RTypePtr target) { |
1204 | 10 | if (source->IsNull()) { |
1205 | 0 | target->SetNull(); |
1206 | 10 | } else { |
1207 | 10 | int64_t val = VERIFY_RESULT6 (source->varint_value().ToInt64());6 |
1208 | 0 | target->set_int64_value(val); |
1209 | 6 | } |
1210 | 6 | return Status::OK(); |
1211 | 10 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToI64<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertVarintToI64<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1203 | 10 | CHECKED_STATUS ConvertVarintToI64(PTypePtr source, RTypePtr target) { | 1204 | 10 | if (source->IsNull()) { | 1205 | 0 | target->SetNull(); | 1206 | 10 | } else { | 1207 | 10 | int64_t val = VERIFY_RESULT6 (source->varint_value().ToInt64());6 | 1208 | 0 | target->set_int64_value(val); | 1209 | 6 | } | 1210 | 6 | return Status::OK(); | 1211 | 10 | } |
|
1212 | | |
1213 | | template<typename PTypePtr, typename RTypePtr> |
1214 | 0 | CHECKED_STATUS ConvertVarintToFloat(PTypePtr source, RTypePtr target) { |
1215 | 0 | if (source->IsNull()) { |
1216 | 0 | target->SetNull(); |
1217 | 0 | } else { |
1218 | | // This may lose precision, it should return the closest float value to the input number. |
1219 | 0 | target->set_float_value(static_cast<float>(VERIFY_RESULT(CheckedStold( |
1220 | 0 | source->varint_value().ToString())))); |
1221 | 0 | } |
1222 | 0 | return Status::OK(); |
1223 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1224 | | |
1225 | | template<typename PTypePtr, typename RTypePtr> |
1226 | 0 | CHECKED_STATUS ConvertVarintToDouble(PTypePtr source, RTypePtr target) { |
1227 | 0 | if (source->IsNull()) { |
1228 | 0 | target->SetNull(); |
1229 | 0 | } else { |
1230 | | // This may lose precision, it should return the closest double value to the input number. |
1231 | 0 | target->set_double_value(VERIFY_RESULT(CheckedStold( |
1232 | 0 | source->varint_value().ToString()))); |
1233 | 0 | } |
1234 | 0 | return Status::OK(); |
1235 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertVarintToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1236 | | |
1237 | | template<typename PTypePtr, typename RTypePtr> |
1238 | 0 | CHECKED_STATUS ConvertI8ToVarint(PTypePtr source, RTypePtr target) { |
1239 | 0 | if (source->IsNull()) { |
1240 | 0 | target->SetNull(); |
1241 | 0 | } else { |
1242 | 0 | target->set_varint_value(util::VarInt(static_cast<int64_t>(source->int8_value()))); |
1243 | 0 | } |
1244 | 0 | return Status::OK(); |
1245 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToVarint<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI8ToVarint<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1246 | | |
1247 | | template<typename PTypePtr, typename RTypePtr> |
1248 | 0 | CHECKED_STATUS ConvertI16ToVarint(PTypePtr source, RTypePtr target) { |
1249 | 0 | if (source->IsNull()) { |
1250 | 0 | target->SetNull(); |
1251 | 0 | } else { |
1252 | 0 | target->set_varint_value(util::VarInt(static_cast<int64_t>(source->int16_value()))); |
1253 | 0 | } |
1254 | 0 | return Status::OK(); |
1255 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToVarint<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI16ToVarint<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1256 | | |
1257 | | template<typename PTypePtr, typename RTypePtr> |
1258 | 0 | CHECKED_STATUS ConvertI32ToVarint(PTypePtr source, RTypePtr target) { |
1259 | 0 | if (source->IsNull()) { |
1260 | 0 | target->SetNull(); |
1261 | 0 | } else { |
1262 | 0 | target->set_varint_value(util::VarInt(static_cast<int64_t>(source->int32_value()))); |
1263 | 0 | } |
1264 | 0 | return Status::OK(); |
1265 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToVarint<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI32ToVarint<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1266 | | |
1267 | | template<typename PTypePtr, typename RTypePtr> |
1268 | 0 | CHECKED_STATUS ConvertI64ToVarint(PTypePtr source, RTypePtr target) { |
1269 | 0 | if (source->IsNull()) { |
1270 | 0 | target->SetNull(); |
1271 | 0 | } else { |
1272 | 0 | target->set_varint_value(util::VarInt(source->int64_value())); |
1273 | 0 | } |
1274 | 0 | return Status::OK(); |
1275 | 0 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToVarint<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Unexecuted instantiation: yb::Status yb::bfql::ConvertI64ToVarint<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) |
1276 | | |
1277 | | template<typename RTypePtr> |
1278 | 21 | CHECKED_STATUS ToInt32(int64_t val, RTypePtr target) { |
1279 | 21 | target->set_int32_value(static_cast<int32_t>(val)); |
1280 | 21 | return Status::OK(); |
1281 | 21 | } Unexecuted instantiation: yb::Status yb::bfql::ToInt32<std::__1::shared_ptr<yb::QLValue> >(long long, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ToInt32<yb::QLValue*>(long long, yb::QLValue*) Line | Count | Source | 1278 | 21 | CHECKED_STATUS ToInt32(int64_t val, RTypePtr target) { | 1279 | 21 | target->set_int32_value(static_cast<int32_t>(val)); | 1280 | 21 | return Status::OK(); | 1281 | 21 | } |
|
1282 | | |
1283 | | template<typename RTypePtr> |
1284 | 17 | CHECKED_STATUS ToInt64(int64_t val, RTypePtr target) { |
1285 | 17 | target->set_int64_value(val); |
1286 | 17 | return Status::OK(); |
1287 | 17 | } Unexecuted instantiation: yb::Status yb::bfql::ToInt64<std::__1::shared_ptr<yb::QLValue> >(long long, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ToInt64<yb::QLValue*>(long long, yb::QLValue*) Line | Count | Source | 1284 | 17 | CHECKED_STATUS ToInt64(int64_t val, RTypePtr target) { | 1285 | 17 | target->set_int64_value(val); | 1286 | 17 | return Status::OK(); | 1287 | 17 | } |
|
1288 | | |
1289 | | template<typename RTypePtr> |
1290 | 9 | CHECKED_STATUS ToInt16(int16_t val, RTypePtr target) { |
1291 | 9 | target->set_int16_value(val); |
1292 | 9 | return Status::OK(); |
1293 | 9 | } Unexecuted instantiation: yb::Status yb::bfql::ToInt16<std::__1::shared_ptr<yb::QLValue> >(short, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ToInt16<yb::QLValue*>(short, yb::QLValue*) Line | Count | Source | 1290 | 9 | CHECKED_STATUS ToInt16(int16_t val, RTypePtr target) { | 1291 | 9 | target->set_int16_value(val); | 1292 | 9 | return Status::OK(); | 1293 | 9 | } |
|
1294 | | |
1295 | | template<typename RTypePtr> |
1296 | 6 | CHECKED_STATUS ToFloat(float val, RTypePtr target) { |
1297 | 6 | target->set_float_value(val); |
1298 | 6 | return Status::OK(); |
1299 | 6 | } Unexecuted instantiation: yb::Status yb::bfql::ToFloat<std::__1::shared_ptr<yb::QLValue> >(float, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ToFloat<yb::QLValue*>(float, yb::QLValue*) Line | Count | Source | 1296 | 6 | CHECKED_STATUS ToFloat(float val, RTypePtr target) { | 1297 | 6 | target->set_float_value(val); | 1298 | 6 | return Status::OK(); | 1299 | 6 | } |
|
1300 | | |
1301 | | template<typename RTypePtr> |
1302 | 14 | CHECKED_STATUS ToDouble(double val, RTypePtr target) { |
1303 | 14 | target->set_double_value(val); |
1304 | 14 | return Status::OK(); |
1305 | 14 | } Unexecuted instantiation: yb::Status yb::bfql::ToDouble<std::__1::shared_ptr<yb::QLValue> >(double, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ToDouble<yb::QLValue*>(double, yb::QLValue*) Line | Count | Source | 1302 | 14 | CHECKED_STATUS ToDouble(double val, RTypePtr target) { | 1303 | 14 | target->set_double_value(val); | 1304 | 14 | return Status::OK(); | 1305 | 14 | } |
|
1306 | | |
1307 | | template<typename RTypePtr, typename PTypePtr, typename StrToNum, typename ToNumeric> |
1308 | | CHECKED_STATUS ConvertToNumeric(PTypePtr source, RTypePtr target, const DataType& data_type, |
1309 | 174 | StrToNum strToNum, ToNumeric toNumeric) { |
1310 | 174 | if (source->IsNull()) { |
1311 | 107 | target->SetNull(); |
1312 | 107 | return Status::OK(); |
1313 | 107 | } |
1314 | 67 | if (source->type() == InternalType::kStringValue) { |
1315 | 38 | return StringToNumeric<RTypePtr>(source->string_value(), target, strToNum, toNumeric); |
1316 | 38 | } else { |
1317 | 29 | return SetNumericResult(toNumeric, source, data_type, target); |
1318 | 29 | } |
1319 | 67 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToNumeric<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, std::__1::shared_ptr<yb::QLValue>)>(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::DataType const&, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::ConvertToNumeric<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)>(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::DataType const&, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::ConvertToNumeric<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)>(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::DataType const&, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::ConvertToNumeric<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, std::__1::shared_ptr<yb::QLValue>)>(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::DataType const&, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, std::__1::shared_ptr<yb::QLValue>)) Unexecuted instantiation: yb::Status yb::bfql::ConvertToNumeric<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, std::__1::shared_ptr<yb::QLValue>)>(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>, yb::DataType const&, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, std::__1::shared_ptr<yb::QLValue>)) yb::Status yb::bfql::ConvertToNumeric<yb::QLValue*, yb::QLValue*, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, yb::QLValue*)>(yb::QLValue*, yb::QLValue*, yb::DataType const&, yb::Result<int> (*)(yb::Slice), yb::Status (*)(short, yb::QLValue*)) Line | Count | Source | 1309 | 9 | StrToNum strToNum, ToNumeric toNumeric) { | 1310 | 9 | if (source->IsNull()) { | 1311 | 0 | target->SetNull(); | 1312 | 0 | return Status::OK(); | 1313 | 0 | } | 1314 | 9 | if (source->type() == InternalType::kStringValue) { | 1315 | 2 | return StringToNumeric<RTypePtr>(source->string_value(), target, strToNum, toNumeric); | 1316 | 7 | } else { | 1317 | 7 | return SetNumericResult(toNumeric, source, data_type, target); | 1318 | 7 | } | 1319 | 9 | } |
yb::Status yb::bfql::ConvertToNumeric<yb::QLValue*, yb::QLValue*, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)>(yb::QLValue*, yb::QLValue*, yb::DataType const&, yb::Result<int> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)) Line | Count | Source | 1309 | 50 | StrToNum strToNum, ToNumeric toNumeric) { | 1310 | 50 | if (source->IsNull()) { | 1311 | 29 | target->SetNull(); | 1312 | 29 | return Status::OK(); | 1313 | 29 | } | 1314 | 21 | if (source->type() == InternalType::kStringValue) { | 1315 | 13 | return StringToNumeric<RTypePtr>(source->string_value(), target, strToNum, toNumeric); | 1316 | 13 | } else { | 1317 | 8 | return SetNumericResult(toNumeric, source, data_type, target); | 1318 | 8 | } | 1319 | 21 | } |
yb::Status yb::bfql::ConvertToNumeric<yb::QLValue*, yb::QLValue*, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)>(yb::QLValue*, yb::QLValue*, yb::DataType const&, yb::Result<long long> (*)(yb::Slice), yb::Status (*)(long long, yb::QLValue*)) Line | Count | Source | 1309 | 80 | StrToNum strToNum, ToNumeric toNumeric) { | 1310 | 80 | if (source->IsNull()) { | 1311 | 63 | target->SetNull(); | 1312 | 63 | return Status::OK(); | 1313 | 63 | } | 1314 | 17 | if (source->type() == InternalType::kStringValue) { | 1315 | 11 | return StringToNumeric<RTypePtr>(source->string_value(), target, strToNum, toNumeric); | 1316 | 11 | } else { | 1317 | 6 | return SetNumericResult(toNumeric, source, data_type, target); | 1318 | 6 | } | 1319 | 17 | } |
yb::Status yb::bfql::ConvertToNumeric<yb::QLValue*, yb::QLValue*, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, yb::QLValue*)>(yb::QLValue*, yb::QLValue*, yb::DataType const&, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(double, yb::QLValue*)) Line | Count | Source | 1309 | 22 | StrToNum strToNum, ToNumeric toNumeric) { | 1310 | 22 | if (source->IsNull()) { | 1311 | 8 | target->SetNull(); | 1312 | 8 | return Status::OK(); | 1313 | 8 | } | 1314 | 14 | if (source->type() == InternalType::kStringValue) { | 1315 | 10 | return StringToNumeric<RTypePtr>(source->string_value(), target, strToNum, toNumeric); | 1316 | 10 | } else { | 1317 | 4 | return SetNumericResult(toNumeric, source, data_type, target); | 1318 | 4 | } | 1319 | 14 | } |
yb::Status yb::bfql::ConvertToNumeric<yb::QLValue*, yb::QLValue*, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, yb::QLValue*)>(yb::QLValue*, yb::QLValue*, yb::DataType const&, yb::Result<long double> (*)(yb::Slice), yb::Status (*)(float, yb::QLValue*)) Line | Count | Source | 1309 | 13 | StrToNum strToNum, ToNumeric toNumeric) { | 1310 | 13 | if (source->IsNull()) { | 1311 | 7 | target->SetNull(); | 1312 | 7 | return Status::OK(); | 1313 | 7 | } | 1314 | 6 | if (source->type() == InternalType::kStringValue) { | 1315 | 2 | return StringToNumeric<RTypePtr>(source->string_value(), target, strToNum, toNumeric); | 1316 | 4 | } else { | 1317 | 4 | return SetNumericResult(toNumeric, source, data_type, target); | 1318 | 4 | } | 1319 | 6 | } |
|
1320 | | |
1321 | | template<typename PTypePtr, typename RTypePtr> |
1322 | 50 | CHECKED_STATUS ConvertToI32(PTypePtr source, RTypePtr target) { |
1323 | 50 | return ConvertToNumeric(source, target, DataType::INT32, CheckedStoi, |
1324 | 50 | ToInt32<RTypePtr>); |
1325 | 50 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToI32<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToI32<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1322 | 50 | CHECKED_STATUS ConvertToI32(PTypePtr source, RTypePtr target) { | 1323 | 50 | return ConvertToNumeric(source, target, DataType::INT32, CheckedStoi, | 1324 | 50 | ToInt32<RTypePtr>); | 1325 | 50 | } |
|
1326 | | |
1327 | | template<typename PTypePtr, typename RTypePtr> |
1328 | 9 | CHECKED_STATUS ConvertToI16(PTypePtr source, RTypePtr target) { |
1329 | 9 | return ConvertToNumeric(source, target, DataType::INT16, CheckedStoi, |
1330 | 9 | ToInt16<RTypePtr>); |
1331 | 9 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToI16<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToI16<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1328 | 9 | CHECKED_STATUS ConvertToI16(PTypePtr source, RTypePtr target) { | 1329 | 9 | return ConvertToNumeric(source, target, DataType::INT16, CheckedStoi, | 1330 | 9 | ToInt16<RTypePtr>); | 1331 | 9 | } |
|
1332 | | |
1333 | | template<typename PTypePtr, typename RTypePtr> |
1334 | 80 | CHECKED_STATUS ConvertToI64(PTypePtr source, RTypePtr target) { |
1335 | 80 | return ConvertToNumeric(source, target, DataType::INT64, CheckedStoll, |
1336 | 80 | ToInt64<RTypePtr>); |
1337 | 80 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToI64<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToI64<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1334 | 80 | CHECKED_STATUS ConvertToI64(PTypePtr source, RTypePtr target) { | 1335 | 80 | return ConvertToNumeric(source, target, DataType::INT64, CheckedStoll, | 1336 | 80 | ToInt64<RTypePtr>); | 1337 | 80 | } |
|
1338 | | |
1339 | | template<typename PTypePtr, typename RTypePtr> |
1340 | 22 | CHECKED_STATUS ConvertToDouble(PTypePtr source, RTypePtr target) { |
1341 | 22 | return ConvertToNumeric(source, target, DataType::DOUBLE, CheckedStold, |
1342 | 22 | ToDouble<RTypePtr>); |
1343 | 22 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToDouble<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToDouble<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1340 | 22 | CHECKED_STATUS ConvertToDouble(PTypePtr source, RTypePtr target) { | 1341 | 22 | return ConvertToNumeric(source, target, DataType::DOUBLE, CheckedStold, | 1342 | 22 | ToDouble<RTypePtr>); | 1343 | 22 | } |
|
1344 | | |
1345 | | template<typename PTypePtr, typename RTypePtr> |
1346 | 13 | CHECKED_STATUS ConvertToFloat(PTypePtr source, RTypePtr target) { |
1347 | 13 | return ConvertToNumeric(source, target, DataType::FLOAT, CheckedStold, |
1348 | 13 | ToFloat<RTypePtr>); |
1349 | 13 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToFloat<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToFloat<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1346 | 13 | CHECKED_STATUS ConvertToFloat(PTypePtr source, RTypePtr target) { | 1347 | 13 | return ConvertToNumeric(source, target, DataType::FLOAT, CheckedStold, | 1348 | 13 | ToFloat<RTypePtr>); | 1349 | 13 | } |
|
1350 | | |
1351 | | YB_DEFINE_ENUM(ConvertDecimalVia, (kUnknown)(kString)(kVarint)(kDecimal)(kInt64)(kDouble)); |
1352 | | |
1353 | | template<typename PTypePtr, typename RTypePtr> |
1354 | 16 | CHECKED_STATUS ConvertToDecimal(PTypePtr source, RTypePtr target) { |
1355 | 16 | if (source->IsNull()) { |
1356 | 14 | target->SetNull(); |
1357 | 14 | return Status::OK(); |
1358 | 14 | } |
1359 | | |
1360 | 2 | const DataType source_datatype = InternalToDataType(source->type()); |
1361 | 2 | if (!QLType::IsExplicitlyConvertible(DataType::DECIMAL, source_datatype)) { |
1362 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", |
1363 | 0 | QLType::ToCQLString(source_datatype), |
1364 | 0 | QLType::ToCQLString(DataType::DECIMAL)); |
1365 | 0 | } |
1366 | | |
1367 | 2 | int64_t int_num = 0; |
1368 | 2 | double double_num = 0.; |
1369 | 2 | ConvertDecimalVia convert = ConvertDecimalVia::kUnknown; |
1370 | | |
1371 | 2 | switch(source->type()) { |
1372 | 2 | case InternalType::kStringValue: |
1373 | 2 | convert = ConvertDecimalVia::kString; |
1374 | 2 | break; |
1375 | 0 | case InternalType::kVarintValue: |
1376 | 0 | convert = ConvertDecimalVia::kVarint; |
1377 | 0 | break; |
1378 | 0 | case InternalType::kDecimalValue: |
1379 | 0 | convert = ConvertDecimalVia::kDecimal; |
1380 | 0 | break; |
1381 | | |
1382 | 0 | case InternalType::kInt8Value: |
1383 | 0 | int_num = source->int8_value(); |
1384 | 0 | convert = ConvertDecimalVia::kInt64; |
1385 | 0 | break; |
1386 | 0 | case InternalType::kInt16Value: |
1387 | 0 | int_num = source->int16_value(); |
1388 | 0 | convert = ConvertDecimalVia::kInt64; |
1389 | 0 | break; |
1390 | 0 | case InternalType::kInt32Value: |
1391 | 0 | int_num = source->int32_value(); |
1392 | 0 | convert = ConvertDecimalVia::kInt64; |
1393 | 0 | break; |
1394 | 0 | case InternalType::kInt64Value: |
1395 | 0 | int_num = source->int64_value(); |
1396 | 0 | convert = ConvertDecimalVia::kInt64; |
1397 | 0 | break; |
1398 | | |
1399 | 0 | case InternalType::kFloatValue: |
1400 | 0 | double_num = source->float_value(); |
1401 | 0 | convert = ConvertDecimalVia::kDouble; |
1402 | 0 | break; |
1403 | 0 | case InternalType::kDoubleValue: |
1404 | 0 | double_num = source->double_value(); |
1405 | 0 | convert = ConvertDecimalVia::kDouble; |
1406 | 0 | break; |
1407 | | |
1408 | 0 | default: // Process all unexpected cases in the next switch. |
1409 | 0 | convert = ConvertDecimalVia::kUnknown; |
1410 | 2 | } |
1411 | | |
1412 | 2 | util::Decimal d; |
1413 | 2 | switch(convert) { |
1414 | 2 | case ConvertDecimalVia::kString: |
1415 | 2 | RSTATUS_DCHECK_EQ(source->type(), InternalType::kStringValue, |
1416 | 2 | InvalidArgument, strings::Substitute("Invalid source type: ", |
1417 | 2 | QLType::ToCQLString(source_datatype))); |
1418 | 2 | RETURN_NOT_OK(d.FromString(source->string_value())); |
1419 | 2 | break; |
1420 | 2 | case ConvertDecimalVia::kVarint: |
1421 | 0 | RSTATUS_DCHECK_EQ(source->type(), InternalType::kVarintValue, |
1422 | 0 | InvalidArgument, strings::Substitute("Invalid source type: ", |
1423 | 0 | QLType::ToCQLString(source_datatype))); |
1424 | 0 | RETURN_NOT_OK(d.FromVarInt(source->varint_value())); |
1425 | 0 | break; |
1426 | 0 | case ConvertDecimalVia::kDecimal: |
1427 | 0 | RSTATUS_DCHECK_EQ(source->type(), InternalType::kDecimalValue, |
1428 | 0 | InvalidArgument, strings::Substitute("Invalid source type: ", |
1429 | 0 | QLType::ToCQLString(source_datatype))); |
1430 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); |
1431 | 0 | break; |
1432 | 0 | case ConvertDecimalVia::kInt64: |
1433 | 0 | RETURN_NOT_OK(d.FromVarInt(util::VarInt(int_num))); |
1434 | 0 | break; |
1435 | 0 | case ConvertDecimalVia::kDouble: |
1436 | 0 | RETURN_NOT_OK(d.FromDouble(double_num)); |
1437 | 0 | break; |
1438 | 0 | case ConvertDecimalVia::kUnknown: |
1439 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", |
1440 | 2 | QLType::ToCQLString(source_datatype), |
1441 | 2 | QLType::ToCQLString(DataType::DECIMAL)); |
1442 | 2 | } |
1443 | | |
1444 | 2 | target->set_decimal_value(d.EncodeToComparable()); |
1445 | 2 | return Status::OK(); |
1446 | 2 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToDecimal<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToDecimal<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1354 | 16 | CHECKED_STATUS ConvertToDecimal(PTypePtr source, RTypePtr target) { | 1355 | 16 | if (source->IsNull()) { | 1356 | 14 | target->SetNull(); | 1357 | 14 | return Status::OK(); | 1358 | 14 | } | 1359 | | | 1360 | 2 | const DataType source_datatype = InternalToDataType(source->type()); | 1361 | 2 | if (!QLType::IsExplicitlyConvertible(DataType::DECIMAL, source_datatype)) { | 1362 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot convert $0 to $1", | 1363 | 0 | QLType::ToCQLString(source_datatype), | 1364 | 0 | QLType::ToCQLString(DataType::DECIMAL)); | 1365 | 0 | } | 1366 | | | 1367 | 2 | int64_t int_num = 0; | 1368 | 2 | double double_num = 0.; | 1369 | 2 | ConvertDecimalVia convert = ConvertDecimalVia::kUnknown; | 1370 | | | 1371 | 2 | switch(source->type()) { | 1372 | 2 | case InternalType::kStringValue: | 1373 | 2 | convert = ConvertDecimalVia::kString; | 1374 | 2 | break; | 1375 | 0 | case InternalType::kVarintValue: | 1376 | 0 | convert = ConvertDecimalVia::kVarint; | 1377 | 0 | break; | 1378 | 0 | case InternalType::kDecimalValue: | 1379 | 0 | convert = ConvertDecimalVia::kDecimal; | 1380 | 0 | break; | 1381 | | | 1382 | 0 | case InternalType::kInt8Value: | 1383 | 0 | int_num = source->int8_value(); | 1384 | 0 | convert = ConvertDecimalVia::kInt64; | 1385 | 0 | break; | 1386 | 0 | case InternalType::kInt16Value: | 1387 | 0 | int_num = source->int16_value(); | 1388 | 0 | convert = ConvertDecimalVia::kInt64; | 1389 | 0 | break; | 1390 | 0 | case InternalType::kInt32Value: | 1391 | 0 | int_num = source->int32_value(); | 1392 | 0 | convert = ConvertDecimalVia::kInt64; | 1393 | 0 | break; | 1394 | 0 | case InternalType::kInt64Value: | 1395 | 0 | int_num = source->int64_value(); | 1396 | 0 | convert = ConvertDecimalVia::kInt64; | 1397 | 0 | break; | 1398 | | | 1399 | 0 | case InternalType::kFloatValue: | 1400 | 0 | double_num = source->float_value(); | 1401 | 0 | convert = ConvertDecimalVia::kDouble; | 1402 | 0 | break; | 1403 | 0 | case InternalType::kDoubleValue: | 1404 | 0 | double_num = source->double_value(); | 1405 | 0 | convert = ConvertDecimalVia::kDouble; | 1406 | 0 | break; | 1407 | | | 1408 | 0 | default: // Process all unexpected cases in the next switch. | 1409 | 0 | convert = ConvertDecimalVia::kUnknown; | 1410 | 2 | } | 1411 | | | 1412 | 2 | util::Decimal d; | 1413 | 2 | switch(convert) { | 1414 | 2 | case ConvertDecimalVia::kString: | 1415 | 2 | RSTATUS_DCHECK_EQ(source->type(), InternalType::kStringValue, | 1416 | 2 | InvalidArgument, strings::Substitute("Invalid source type: ", | 1417 | 2 | QLType::ToCQLString(source_datatype))); | 1418 | 2 | RETURN_NOT_OK(d.FromString(source->string_value())); | 1419 | 2 | break; | 1420 | 2 | case ConvertDecimalVia::kVarint: | 1421 | 0 | RSTATUS_DCHECK_EQ(source->type(), InternalType::kVarintValue, | 1422 | 0 | InvalidArgument, strings::Substitute("Invalid source type: ", | 1423 | 0 | QLType::ToCQLString(source_datatype))); | 1424 | 0 | RETURN_NOT_OK(d.FromVarInt(source->varint_value())); | 1425 | 0 | break; | 1426 | 0 | case ConvertDecimalVia::kDecimal: | 1427 | 0 | RSTATUS_DCHECK_EQ(source->type(), InternalType::kDecimalValue, | 1428 | 0 | InvalidArgument, strings::Substitute("Invalid source type: ", | 1429 | 0 | QLType::ToCQLString(source_datatype))); | 1430 | 0 | RETURN_NOT_OK(d.DecodeFromComparable(source->decimal_value())); | 1431 | 0 | break; | 1432 | 0 | case ConvertDecimalVia::kInt64: | 1433 | 0 | RETURN_NOT_OK(d.FromVarInt(util::VarInt(int_num))); | 1434 | 0 | break; | 1435 | 0 | case ConvertDecimalVia::kDouble: | 1436 | 0 | RETURN_NOT_OK(d.FromDouble(double_num)); | 1437 | 0 | break; | 1438 | 0 | case ConvertDecimalVia::kUnknown: | 1439 | 0 | return STATUS_SUBSTITUTE(QLError, "Cannot cast $0 to $1", | 1440 | 2 | QLType::ToCQLString(source_datatype), | 1441 | 2 | QLType::ToCQLString(DataType::DECIMAL)); | 1442 | 2 | } | 1443 | | | 1444 | 2 | target->set_decimal_value(d.EncodeToComparable()); | 1445 | 2 | return Status::OK(); | 1446 | 2 | } |
|
1447 | | |
1448 | | template<typename PTypePtr, typename RTypePtr> |
1449 | 58 | CHECKED_STATUS ConvertToString(PTypePtr source, RTypePtr target) { |
1450 | 58 | if (source->IsNull()) { |
1451 | 15 | target->SetNull(); |
1452 | 15 | return Status::OK(); |
1453 | 15 | } |
1454 | 43 | return SetStringResult(source, target); |
1455 | 58 | } yb::Status yb::bfql::ConvertToString<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) Line | Count | Source | 1449 | 20 | CHECKED_STATUS ConvertToString(PTypePtr source, RTypePtr target) { | 1450 | 20 | if (source->IsNull()) { | 1451 | 0 | target->SetNull(); | 1452 | 0 | return Status::OK(); | 1453 | 0 | } | 1454 | 20 | return SetStringResult(source, target); | 1455 | 20 | } |
yb::Status yb::bfql::ConvertToString<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1449 | 38 | CHECKED_STATUS ConvertToString(PTypePtr source, RTypePtr target) { | 1450 | 38 | if (source->IsNull()) { | 1451 | 15 | target->SetNull(); | 1452 | 15 | return Status::OK(); | 1453 | 15 | } | 1454 | 23 | return SetStringResult(source, target); | 1455 | 38 | } |
|
1456 | | |
1457 | | template<typename PTypePtr, typename RTypePtr> |
1458 | 3 | CHECKED_STATUS ConvertToTimestamp(PTypePtr source, RTypePtr target) { |
1459 | 3 | if (source->IsNull()) { |
1460 | 1 | target->SetNull(); |
1461 | 1 | return Status::OK(); |
1462 | 1 | } |
1463 | 2 | return SetTimestampResult(source, target); |
1464 | 3 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToTimestamp<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToTimestamp<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1458 | 3 | CHECKED_STATUS ConvertToTimestamp(PTypePtr source, RTypePtr target) { | 1459 | 3 | if (source->IsNull()) { | 1460 | 1 | target->SetNull(); | 1461 | 1 | return Status::OK(); | 1462 | 1 | } | 1463 | 2 | return SetTimestampResult(source, target); | 1464 | 3 | } |
|
1465 | | |
1466 | | template<typename PTypePtr, typename RTypePtr> |
1467 | 1 | CHECKED_STATUS ConvertToDate(PTypePtr source, RTypePtr target) { |
1468 | 1 | if (source->IsNull()) { |
1469 | 0 | target->SetNull(); |
1470 | 0 | return Status::OK(); |
1471 | 0 | } |
1472 | 1 | return SetDateResult(source, target); |
1473 | 1 | } Unexecuted instantiation: yb::Status yb::bfql::ConvertToDate<std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue> >(std::__1::shared_ptr<yb::QLValue>, std::__1::shared_ptr<yb::QLValue>) yb::Status yb::bfql::ConvertToDate<yb::QLValue*, yb::QLValue*>(yb::QLValue*, yb::QLValue*) Line | Count | Source | 1467 | 1 | CHECKED_STATUS ConvertToDate(PTypePtr source, RTypePtr target) { | 1468 | 1 | if (source->IsNull()) { | 1469 | 0 | target->SetNull(); | 1470 | 0 | return Status::OK(); | 1471 | 0 | } | 1472 | 1 | return SetDateResult(source, target); | 1473 | 1 | } |
|
1474 | | |
1475 | | } // namespace bfql |
1476 | | } // namespace yb |
1477 | | |
1478 | | #endif // YB_BFQL_BFUNC_CONVERT_H_ |