Skip to content

Commit

Permalink
enum util
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishj committed Jan 15, 2025
1 parent fe26f1e commit 08e14fe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/common/enum_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
#include "duckdb/planner/table_filter.hpp"
#include "duckdb/storage/buffer/block_handle.hpp"
#include "duckdb/storage/compression/bitpacking.hpp"
#include "duckdb/storage/compression/dict_fsst/common.hpp"
#include "duckdb/storage/magic_bytes.hpp"
#include "duckdb/storage/statistics/base_statistics.hpp"
#include "duckdb/storage/table/chunk_info.hpp"
Expand Down Expand Up @@ -1168,6 +1169,26 @@ DestroyBufferUpon EnumUtil::FromString<DestroyBufferUpon>(const char *value) {
return static_cast<DestroyBufferUpon>(StringUtil::StringToEnum(GetDestroyBufferUponValues(), 3, "DestroyBufferUpon", value));
}

const StringUtil::EnumStringLiteral *GetDictFSSTModeValues() {
static constexpr StringUtil::EnumStringLiteral values[] {
{ static_cast<uint32_t>(DictFSSTMode::DICTIONARY), "DICTIONARY" },
{ static_cast<uint32_t>(DictFSSTMode::DICT_FSST), "DICT_FSST" },
{ static_cast<uint32_t>(DictFSSTMode::FSST_ONLY), "FSST_ONLY" },
{ static_cast<uint32_t>(DictFSSTMode::COUNT), "COUNT" }
};
return values;
}

template<>
const char* EnumUtil::ToChars<DictFSSTMode>(DictFSSTMode value) {
return StringUtil::EnumToString(GetDictFSSTModeValues(), 4, "DictFSSTMode", static_cast<uint32_t>(value));
}

template<>
DictFSSTMode EnumUtil::FromString<DictFSSTMode>(const char *value) {
return static_cast<DictFSSTMode>(StringUtil::StringToEnum(GetDictFSSTModeValues(), 4, "DictFSSTMode", value));
}

const StringUtil::EnumStringLiteral *GetDistinctTypeValues() {
static constexpr StringUtil::EnumStringLiteral values[] {
{ static_cast<uint32_t>(DistinctType::DISTINCT), "DISTINCT" },
Expand Down
8 changes: 8 additions & 0 deletions src/include/duckdb/common/enum_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ enum class DeprecatedIndexType : uint8_t;

enum class DestroyBufferUpon : uint8_t;

enum class DictFSSTMode : uint8_t;

enum class DistinctType : uint8_t;

enum class ErrorType : uint16_t;
Expand Down Expand Up @@ -536,6 +538,9 @@ const char* EnumUtil::ToChars<DeprecatedIndexType>(DeprecatedIndexType value);
template<>
const char* EnumUtil::ToChars<DestroyBufferUpon>(DestroyBufferUpon value);

template<>
const char* EnumUtil::ToChars<DictFSSTMode>(DictFSSTMode value);

template<>
const char* EnumUtil::ToChars<DistinctType>(DistinctType value);

Expand Down Expand Up @@ -1071,6 +1076,9 @@ DeprecatedIndexType EnumUtil::FromString<DeprecatedIndexType>(const char *value)
template<>
DestroyBufferUpon EnumUtil::FromString<DestroyBufferUpon>(const char *value);

template<>
DictFSSTMode EnumUtil::FromString<DictFSSTMode>(const char *value);

template<>
DistinctType EnumUtil::FromString<DistinctType>(const char *value);

Expand Down

0 comments on commit 08e14fe

Please sign in to comment.