diff options
author | azevaykin <azevaykin@yandex-team.com> | 2023-10-27 09:14:08 +0300 |
---|---|---|
committer | azevaykin <azevaykin@yandex-team.com> | 2023-10-27 09:35:25 +0300 |
commit | ae3548c27b9cf95acd210ab3564f3a78e57bd135 (patch) | |
tree | 12e35605c3ca7f36971f65acdc0483b092952bf8 | |
parent | 47a958391355747cfe812b4fd54f47dfa677a18a (diff) | |
download | ydb-ae3548c27b9cf95acd210ab3564f3a78e57bd135.tar.gz |
TStringBuilder -> TString in export s3
-rw-r--r-- | ydb/core/scheme/scheme_tablecell.h | 20 | ||||
-rw-r--r-- | ydb/core/tx/datashard/export_common.cpp | 6 | ||||
-rw-r--r-- | ydb/core/tx/datashard/export_common.h | 4 | ||||
-rw-r--r-- | ydb/core/tx/datashard/export_s3_buffer_raw.h | 2 | ||||
-rw-r--r-- | ydb/core/tx/datashard/export_scan.cpp | 1 |
5 files changed, 22 insertions, 11 deletions
diff --git a/ydb/core/scheme/scheme_tablecell.h b/ydb/core/scheme/scheme_tablecell.h index efe2fc355b..06b530fe0b 100644 --- a/ydb/core/scheme/scheme_tablecell.h +++ b/ydb/core/scheme/scheme_tablecell.h @@ -96,19 +96,29 @@ public: template<typename T, typename = TStdLayout<T>> T AsValue() const noexcept { - Y_ABORT_UNLESS(sizeof(T) == Size(), "AsValue<T>() type doesn't match TCell"); + Y_ABORT_UNLESS(sizeof(T) == Size(), "AsValue<T>() type size %" PRIu64 " doesn't match TCell size %" PRIu32, sizeof(T), Size()); return ReadUnaligned<T>(Data()); } template <typename T, typename = TStdLayout<T>> - bool ToStream(IOutputStream& out, TStringBuilder& err) const noexcept { - if(sizeof(T) != Size()) { - err << "AsValue<T>() type doesn't match TCell"; + bool ToValue(T& value, TString& err) const noexcept { + if (sizeof(T) != Size()) { + err = Sprintf("ToValue<T>() type size %" PRIu64 " doesn't match TCell size %" PRIu32, sizeof(T), Size()); return false; } - out << ReadUnaligned<T>(Data()); + value = ReadUnaligned<T>(Data()); + return true; + } + + template <typename T, typename = TStdLayout<T>> + bool ToStream(IOutputStream& out, TString& err) const noexcept { + T value; + if (!ToValue(value, err)) + return false; + + out << value; return true; } diff --git a/ydb/core/tx/datashard/export_common.cpp b/ydb/core/tx/datashard/export_common.cpp index 10f64c7527..51d36e8320 100644 --- a/ydb/core/tx/datashard/export_common.cpp +++ b/ydb/core/tx/datashard/export_common.cpp @@ -87,7 +87,7 @@ TString DyNumberToString(TStringBuf data) { return result; } -bool DecimalToStream(const std::pair<ui64, i64>& loHi, IOutputStream& out, TStringBuilder& err) { +bool DecimalToStream(const std::pair<ui64, i64>& loHi, IOutputStream& out, TString& err) { Y_UNUSED(err); using namespace NYql::NDecimal; @@ -96,10 +96,10 @@ bool DecimalToStream(const std::pair<ui64, i64>& loHi, IOutputStream& out, TStri return true; } -bool DyNumberToStream(TStringBuf data, IOutputStream& out, TStringBuilder& err) { +bool DyNumberToStream(TStringBuf data, IOutputStream& out, TString& err) { auto result = NDyNumber::DyNumberToString(data); if (!result.Defined()) { - err << "Invalid DyNumber binary representation"; + err = "Invalid DyNumber binary representation"; return false; } out << *result; diff --git a/ydb/core/tx/datashard/export_common.h b/ydb/core/tx/datashard/export_common.h index 4abd007b68..7a7dc19525 100644 --- a/ydb/core/tx/datashard/export_common.h +++ b/ydb/core/tx/datashard/export_common.h @@ -36,8 +36,8 @@ TMaybe<Ydb::Table::CreateTableRequest> GenYdbScheme( TString DecimalToString(const std::pair<ui64, i64>& loHi); TString DyNumberToString(TStringBuf data); -bool DecimalToStream(const std::pair<ui64, i64>& loHi, IOutputStream& out, TStringBuilder& err); -bool DyNumberToStream(TStringBuf data, IOutputStream& out, TStringBuilder& err); +bool DecimalToStream(const std::pair<ui64, i64>& loHi, IOutputStream& out, TString& err); +bool DyNumberToStream(TStringBuf data, IOutputStream& out, TString& err); } // NDataShard } // NKikimr diff --git a/ydb/core/tx/datashard/export_s3_buffer_raw.h b/ydb/core/tx/datashard/export_s3_buffer_raw.h index 4ea6c1094b..3573f4b6d5 100644 --- a/ydb/core/tx/datashard/export_s3_buffer_raw.h +++ b/ydb/core/tx/datashard/export_s3_buffer_raw.h @@ -42,7 +42,7 @@ protected: ui64 BytesRead; TBuffer Buffer; - TStringBuilder ErrorString; + TString ErrorString; }; // TS3BufferRaw } // NDataShard diff --git a/ydb/core/tx/datashard/export_scan.cpp b/ydb/core/tx/datashard/export_scan.cpp index 3645b9de6c..8f17ceae68 100644 --- a/ydb/core/tx/datashard/export_scan.cpp +++ b/ydb/core/tx/datashard/export_scan.cpp @@ -205,6 +205,7 @@ public: if (!Buffer->Collect(row)) { Success = false; Error = Buffer->GetError(); + EXPORT_LOG_E("Error read data from table: " << Error); return EScan::Final; } |