-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove templates.h #8746
Merged
maximyurchuk
merged 7 commits into
ydb-platform:main
from
maximyurchuk:remove_templates
Sep 10, 2024
Merged
Remove templates.h #8746
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f234dac
Remove templates.h
maximyurchuk 5e064f6
-
maximyurchuk 5dc455c
fix
maximyurchuk a8fe8f8
fix
maximyurchuk 7a93a51
Try modern constexpr
maximyurchuk d2c10b5
Merge branch 'main' of https://github.com/ydb-platform/ydb into remov…
maximyurchuk a31c179
Use ultra modern С++ standard
maximyurchuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
|
||
#include <ydb/core/tablet_flat/flat_database.h> | ||
#include <ydb/core/util/tuples.h> | ||
#include <ydb/core/util/templates.h> | ||
#include <ydb/core/base/blobstorage_common.h> | ||
|
||
#include <util/system/type_name.h> | ||
#include <util/system/unaligned_mem.h> | ||
#include <library/cpp/containers/stack_vector/stack_vec.h> | ||
#include <type_traits> | ||
#include <utility> | ||
|
||
// https://wiki.yandex-team.ru/kikimr/techdoc/db/cxxapi/nicedb/ | ||
|
@@ -647,6 +647,18 @@ enum class EMaterializationMode { | |
NonExisting, | ||
}; | ||
|
||
namespace NDetail { | ||
template <typename T> | ||
class HasDefault | ||
{ | ||
private: | ||
template <typename C> static std::true_type test(decltype(C::Default)) ; | ||
template <typename C> static std::false_type test(...); | ||
public: | ||
static constexpr bool value = decltype(test<T>(0))::value; | ||
}; | ||
} | ||
|
||
struct Schema { | ||
template <typename T> | ||
struct Precharger { | ||
|
@@ -1437,7 +1449,7 @@ struct Schema { | |
} | ||
|
||
template <typename ColumnType> | ||
auto GetValueOrDefault(typename ColumnType::Type defaultValue = GetDefaultValue<ColumnType>(SFINAE::special())) const { | ||
auto GetValueOrDefault(typename ColumnType::Type defaultValue = GetDefaultValue<ColumnType>()) const { | ||
Y_DEBUG_ABORT_UNLESS(IsReady(), "Rowset is not ready"); | ||
Y_DEBUG_ABORT_UNLESS(IsValid(), "Rowset is not valid"); | ||
typename ColumnType::Type value(HaveValue<ColumnType>() ? GetColumnValue<ColumnType>() : defaultValue); | ||
|
@@ -1462,24 +1474,19 @@ struct Schema { | |
return DbgPrintTuple(Iterator.GetKey(), typeRegistry) + " -> " + DbgPrintTuple(Iterator.GetValues(), typeRegistry); | ||
} | ||
|
||
template <typename ColumnType, typename SFINAE::type_check<decltype(ColumnType::Default)>::type = 0> | ||
static decltype(ColumnType::Default) GetNullValue(SFINAE::special) { | ||
return ColumnType::Default; | ||
} | ||
|
||
template <typename ColumnType> | ||
static typename ColumnType::Type GetNullValue(SFINAE::general) { | ||
return typename ColumnType::Type(); | ||
} | ||
|
||
template <typename ColumnType, typename SFINAE::type_check<decltype(ColumnType::Default)>::type = 0> | ||
static decltype(ColumnType::Default) GetDefaultValue(SFINAE::special) { | ||
return ColumnType::Default; | ||
static typename ColumnType::Type GetNullValue() { | ||
return GetDefaultValue<ColumnType>(); | ||
} | ||
|
||
template <typename ColumnType> | ||
static typename ColumnType::Type GetDefaultValue(SFINAE::general) { | ||
return typename ColumnType::Type(); | ||
static typename ColumnType::Type GetDefaultValue() { | ||
if constexpr (NDetail::HasDefault<ColumnType>::value) { | ||
return ColumnType::Default; | ||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't write "else" on a new line |
||
return typename ColumnType::Type(); | ||
} | ||
} | ||
|
||
NTable::TIteratorStats* Stats() const { | ||
|
@@ -1499,7 +1506,7 @@ struct Schema { | |
auto& cell = tuple.Columns[index]; | ||
auto type = tuple.Types[index]; | ||
if (cell.IsNull()) | ||
return GetNullValue<ColumnType>(SFINAE::special()); | ||
return GetNullValue<ColumnType>(); | ||
return TConvert<ColumnType, typename ColumnType::Type>::Convert(TRawTypeValue(cell.Data(), cell.Size(), type)); | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, it would be much easier to use "requires" statement for that