Skip to content

Commit

Permalink
remove value::view() member function
Browse files Browse the repository at this point in the history
  • Loading branch information
kuron99 committed Jan 28, 2025
1 parent 0c61a5e commit bf09221
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 27 deletions.
21 changes: 0 additions & 21 deletions src/jogasaki/data/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,4 @@ std::size_t value::type_index() const noexcept {
return body_.index();
}

any value::view() const {
switch(type_index()) {
case index<std::monostate>: return any{};
case index<std::int8_t>: return any{std::in_place_type<std::int8_t>, ref<std::int8_t>()};
case index<std::int16_t>: return any{std::in_place_type<std::int16_t>, ref<std::int16_t>()};
case index<std::int32_t>: return any{std::in_place_type<std::int32_t>, ref<std::int32_t>()};
case index<std::int64_t>: return any{std::in_place_type<std::int64_t>, ref<std::int64_t>()};
case index<float>: return any{std::in_place_type<float>, ref<float>()};
case index<double>: return any{std::in_place_type<double>, ref<double>()};
case index<std::string>: return any{std::in_place_type<accessor::text>, accessor::text{ref<std::string>()}};
case index<binary_string_value>: return any{std::in_place_type<accessor::binary>, accessor::binary{ref<binary_string_value>().str()}};
case index<runtime_t<meta::field_type_kind::decimal>>: return any{std::in_place_type<runtime_t<meta::field_type_kind::decimal>>, ref<runtime_t<meta::field_type_kind::decimal>>()};
case index<runtime_t<meta::field_type_kind::date>>: return any{std::in_place_type<runtime_t<meta::field_type_kind::date>>, ref<runtime_t<meta::field_type_kind::date>>()};
case index<runtime_t<meta::field_type_kind::time_of_day>>: return any{std::in_place_type<runtime_t<meta::field_type_kind::time_of_day>>, ref<runtime_t<meta::field_type_kind::time_of_day>>()};
case index<runtime_t<meta::field_type_kind::time_point>>: return any{std::in_place_type<runtime_t<meta::field_type_kind::time_point>>, ref<runtime_t<meta::field_type_kind::time_point>>()};
case index<std::size_t>: return any{std::in_place_type<std::size_t>, ref<std::size_t>()};
default: fail_with_exception();
}
std::abort();
}

} // namespace jogasaki::data
5 changes: 0 additions & 5 deletions src/jogasaki/data/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ class value {
*/
[[nodiscard]] std::size_t type_index() const noexcept;

/**
* @brief return the any class as the view of this object
*/
[[nodiscard]] any view() const;

// variant index in value - treat bool as std::int8_t
template <class T>
static constexpr std::size_t index =
Expand Down
4 changes: 3 additions & 1 deletion test/jogasaki/data/value_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <jogasaki/data/value.h>
#include <jogasaki/test_root.h>
#include <jogasaki/test_utils.h>
#include <jogasaki/utils/value_to_any.h>

namespace jogasaki::executor::expr {

Expand Down Expand Up @@ -136,7 +137,8 @@ TEST_F(value_test, string) {
ASSERT_FALSE(v.empty());
ASSERT_EQ("ABC", v.ref<std::string>());

auto a = v.view();
data::any a{};
ASSERT_TRUE(utils::value_to_any(v, a));
auto t = a.to<accessor::text>();
// static_cast to sv requires accessor::text lvalue as sv can reference SSO'ed data in accessor::text.
auto sv = static_cast<std::string_view>(t);
Expand Down

0 comments on commit bf09221

Please sign in to comment.