From 8b7fe333ec6aaa992cd67b903e5d089b4b9efb4b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 6 Jun 2020 19:53:18 -0700 Subject: [PATCH] ircd::db: Add valid(rocksdb::Status) to suite. --- ircd/db.cc | 20 ++++++++++++++++++++ ircd/db.h | 1 + 2 files changed, 21 insertions(+) diff --git a/ircd/db.cc b/ircd/db.cc index 591e7574e..6f2564955 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -8078,6 +8078,26 @@ ircd::db::valid(const rocksdb::Iterator &it) } } +bool +ircd::db::valid(const rocksdb::Status &s) +{ + switch(s.code()) + { + using rocksdb::Status; + + case Status::kOk: + return true; + + case Status::kNotFound: + case Status::kIncomplete: + return false; + + default: + throw_on_error{s}; + __builtin_unreachable(); + } +} + // // column_names // diff --git a/ircd/db.h b/ircd/db.h index 80739689e..65278ff74 100644 --- a/ircd/db.h +++ b/ircd/db.h @@ -102,6 +102,7 @@ namespace ircd::db std::vector column_names(const std::string &path, const std::string &options); // Validation functors + bool valid(const rocksdb::Status &); bool valid(const rocksdb::Iterator &); bool operator!(const rocksdb::Iterator &); using valid_proffer = std::function;