You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "PragmaTwice (via GitHub)" <gi...@apache.org> on 2024/10/31 05:20:02 UTC
[PR] feat(status): support rocksdb::Status fowarding in GET_OR_RET [kvrocks]
PragmaTwice opened a new pull request, #2630:
URL: https://github.com/apache/kvrocks/pull/2630
So now `Get_OR_RET` supports `StatusOr<T>`, `Status` and `rocksdb::Status`.
For conversions:
- `StatusOr<T>` and `Status` are designed to be converted mutually and implicitly.
- `rocksdb::Status` -> `Status` is currently not supported, it can be supported by ctors or functions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(status): support rocksdb::Status fowarding in GET_OR_RET [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice merged PR #2630:
URL: https://github.com/apache/kvrocks/pull/2630
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(status): support rocksdb::Status fowarding in GET_OR_RET [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #2630:
URL: https://github.com/apache/kvrocks/pull/2630#discussion_r1824080849
##########
src/common/status.h:
##########
@@ -369,10 +370,30 @@ struct [[nodiscard]] StatusOr {
friend struct StatusOr;
};
+template <typename T,
+ std::enable_if_t<IsStatusOr<RemoveCVRef<T>>::value || std::is_same_v<RemoveCVRef<T>, Status>, int> = 0>
+decltype(auto) StatusGetValue(T&& v) {
+ return std::forward<T>(v).GetValue();
+}
+
+template <typename T, std::enable_if_t<std::is_same_v<RemoveCVRef<T>, rocksdb::Status>, int> = 0>
+void StatusGetValue(T&&) {}
+
+template <typename T,
+ std::enable_if_t<IsStatusOr<RemoveCVRef<T>>::value || std::is_same_v<RemoveCVRef<T>, Status>, int> = 0>
+bool StatusIsOK(const T& v) {
+ return v.IsOK();
+}
+
+template <typename T, std::enable_if_t<std::is_same_v<RemoveCVRef<T>, rocksdb::Status>, int> = 0>
+bool StatusIsOK(const T& v) {
+ return v.ok();
+}
+
// NOLINTNEXTLINE
-#define GET_OR_RET(...) \
- ({ \
- auto&& status = (__VA_ARGS__); \
- if (!status) return std::forward<decltype(status)>(status); \
- std::forward<decltype(status)>(status); \
- }).GetValue()
+#define GET_OR_RET(...) \
Review Comment:
Same as for `Status`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(status): support rocksdb::Status fowarding in GET_OR_RET [kvrocks]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #2630:
URL: https://github.com/apache/kvrocks/pull/2630#discussion_r1824069010
##########
src/common/status.h:
##########
@@ -369,10 +370,30 @@ struct [[nodiscard]] StatusOr {
friend struct StatusOr;
};
+template <typename T,
+ std::enable_if_t<IsStatusOr<RemoveCVRef<T>>::value || std::is_same_v<RemoveCVRef<T>, Status>, int> = 0>
+decltype(auto) StatusGetValue(T&& v) {
+ return std::forward<T>(v).GetValue();
+}
+
+template <typename T, std::enable_if_t<std::is_same_v<RemoveCVRef<T>, rocksdb::Status>, int> = 0>
+void StatusGetValue(T&&) {}
+
+template <typename T,
+ std::enable_if_t<IsStatusOr<RemoveCVRef<T>>::value || std::is_same_v<RemoveCVRef<T>, Status>, int> = 0>
+bool StatusIsOK(const T& v) {
+ return v.IsOK();
+}
+
+template <typename T, std::enable_if_t<std::is_same_v<RemoveCVRef<T>, rocksdb::Status>, int> = 0>
+bool StatusIsOK(const T& v) {
+ return v.ok();
+}
+
// NOLINTNEXTLINE
-#define GET_OR_RET(...) \
- ({ \
- auto&& status = (__VA_ARGS__); \
- if (!status) return std::forward<decltype(status)>(status); \
- std::forward<decltype(status)>(status); \
- }).GetValue()
+#define GET_OR_RET(...) \
Review Comment:
So this is `RET_NOT_OK` for `rocksdb::Status`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(status): support rocksdb::Status fowarding in GET_OR_RET [kvrocks]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2630:
URL: https://github.com/apache/kvrocks/pull/2630#issuecomment-2449216713
## [](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2630) **Quality Gate passed**
Issues
 [6 New issues](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2630&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_kvrocks&pullRequest=2630&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_kvrocks&pullRequest=2630&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [61.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2630&metric=new_coverage&view=list)
 [1.1% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_kvrocks&pullRequest=2630&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_kvrocks&pullRequest=2630)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org