Skip to content

Commit

Permalink
Merge a31c179 into b324f1b
Browse files Browse the repository at this point in the history
  • Loading branch information
maximyurchuk authored Sep 9, 2024
2 parents b324f1b + a31c179 commit 012d343
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 59 deletions.
29 changes: 12 additions & 17 deletions ydb/core/tablet_flat/flat_cxx_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -1437,7 +1437,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);
Expand All @@ -1462,24 +1462,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() {
constexpr bool hasDefault = requires {ColumnType::Default;};
if constexpr (hasDefault) {
return ColumnType::Default;
} else {
return typename ColumnType::Type();
}
}

NTable::TIteratorStats* Stats() const {
Expand All @@ -1499,7 +1494,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));
}

Expand Down
41 changes: 0 additions & 41 deletions ydb/core/util/templates.h

This file was deleted.

1 change: 0 additions & 1 deletion ydb/core/util/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ SRCS(
single_thread_ic_mock.h
stlog.cpp
stlog.h
templates.h
testactorsys.cpp
testactorsys.h
text.cpp
Expand Down

0 comments on commit 012d343

Please sign in to comment.