/src/rocksdb/utilities/secondary_index/secondary_index_helper.h
Line | Count | Source |
1 | | // Copyright (c) Meta Platforms, Inc. and affiliates. |
2 | | // |
3 | | // This source code is licensed under both the GPLv2 (found in the |
4 | | // COPYING file in the root directory) and Apache 2.0 License |
5 | | // (found in the LICENSE.Apache file in the root directory). |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <string> |
10 | | #include <variant> |
11 | | |
12 | | #include "rocksdb/rocksdb_namespace.h" |
13 | | #include "rocksdb/slice.h" |
14 | | #include "util/overload.h" |
15 | | |
16 | | namespace ROCKSDB_NAMESPACE { |
17 | | |
18 | | class SecondaryIndexHelper { |
19 | | public: |
20 | 0 | static Slice AsSlice(const std::variant<Slice, std::string>& var) { |
21 | 0 | return std::visit([](const auto& value) -> Slice { return value; }, var);Unexecuted instantiation: rocksdb::Slice rocksdb::SecondaryIndexHelper::AsSlice(std::__1::variant<rocksdb::Slice, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const&)::{lambda(auto:1 const&)#1}::operator()<rocksdb::Slice>(rocksdb::Slice const&) constUnexecuted instantiation: rocksdb::Slice rocksdb::SecondaryIndexHelper::AsSlice(std::__1::variant<rocksdb::Slice, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const&)::{lambda(auto:1 const&)#1}::operator()<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const |
22 | 0 | } |
23 | | |
24 | 0 | static std::string AsString(const std::variant<Slice, std::string>& var) { |
25 | 0 | return std::visit( |
26 | 0 | overload{ |
27 | 0 | [](const Slice& value) -> std::string { return value.ToString(); }, |
28 | 0 | [](const std::string& value) -> std::string { return value; }}, |
29 | 0 | var); |
30 | 0 | } |
31 | | }; |
32 | | |
33 | | } // namespace ROCKSDB_NAMESPACE |