diff options
| author | ivanmorozov333 <[email protected]> | 2024-01-22 20:11:00 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-22 20:11:00 +0300 |
| commit | 5d10402412ca1a8a811139b07470c14e9feed5ba (patch) | |
| tree | 84f12be9ace22f1ce0967e75e7db53ffc3335a56 | |
| parent | 477e168bafdf6f586678c6b69f7ffa53d8a2f26e (diff) | |
DebugString methods for debug prints (#1198)
| -rw-r--r-- | ydb/core/formats/arrow/program.h | 40 | ||||
| -rw-r--r-- | ydb/core/tx/columnshard/splitter/stats.h | 27 | ||||
| -rw-r--r-- | ydb/core/tx/program/program.cpp | 1 | ||||
| -rw-r--r-- | ydb/core/tx/program/program.h | 11 |
4 files changed, 77 insertions, 2 deletions
diff --git a/ydb/core/formats/arrow/program.h b/ydb/core/formats/arrow/program.h index dbfa46f0f81..31254144fa9 100644 --- a/ydb/core/formats/arrow/program.h +++ b/ydb/core/formats/arrow/program.h @@ -62,6 +62,10 @@ private: } public: + TString DebugString() const { + return TStringBuilder() << (GeneratedFlag ? "G:" : "") << ColumnName; + } + static TColumnInfo Generated(const ui32 columnId, const std::string& columnName) { return TColumnInfo(columnId, columnName, true); } @@ -233,6 +237,12 @@ public: const arrow::compute::FunctionOptions* GetOptions() const { return FuncOpts.get(); } IStepFunction<TAssign>::TPtr GetFunction(arrow::compute::ExecContext* ctx) const; + TString DebugString() const { + return TStringBuilder() << + "{op=" << Operation << ";column=" << Column.DebugString() << ";" << (Constant ? "const=" + Constant->ToString() + ";" : "NO;") + << (KernelFunction ? ("kernel=" + KernelFunction->name() + ";") : "NO;") + << "}"; + } private: const TColumnInfo Column; EOperation Operation{EOperation::Unspecified}; @@ -312,6 +322,27 @@ private: public: using TDatumBatch = TDatumBatch; + TString DebugString() const { + TStringBuilder sb; + sb << "{"; + sb << "assignes=["; + for (auto&& i : Assignes) { + sb << i.DebugString() << ";"; + } + sb << "];"; + sb << "group_by_count = " << GroupBy.size() << "; "; + sb << "group_by_keys_count=" << GroupByKeys.size() << ";"; + + sb << "projections=["; + for (auto&& i : Projection) { + sb << i.DebugString() << ";"; + } + sb << "];"; + + sb << "}"; + return sb; + } + std::set<std::string> GetColumnsInUsage() const; const std::set<ui32>& GetFilterOriginalColumnIds() const; @@ -391,6 +422,15 @@ struct TProgram { std::set<std::string> GetEarlyFilterColumns() const; std::set<std::string> GetProcessingColumns() const; std::shared_ptr<NArrow::TColumnFilter> ApplyEarlyFilter(std::shared_ptr<arrow::Table>& batch, const bool useFilter) const; + TString DebugString() const { + TStringBuilder sb; + sb << "["; + for (auto&& i : Steps) { + sb << i->DebugString() << ";"; + } + sb << "]"; + return sb; + } }; inline arrow::Status ApplyProgram( diff --git a/ydb/core/tx/columnshard/splitter/stats.h b/ydb/core/tx/columnshard/splitter/stats.h index 6c7c5e154d6..695a7ab32dd 100644 --- a/ydb/core/tx/columnshard/splitter/stats.h +++ b/ydb/core/tx/columnshard/splitter/stats.h @@ -30,6 +30,14 @@ public: Y_ABORT_UNLESS(RawBytes); } + TString DebugString() const { + return TStringBuilder() << "{" + << "serialized_bytes=" << SerializedBytes << ";" + << "records=" << RecordsCount << ";" + << "raw_bytes=" << RawBytes << ";" + << "}"; + } + double GetSerializedBytesPerRecord() const { AFL_VERIFY(RecordsCount); return 1.0 * SerializedBytes / RecordsCount; @@ -77,6 +85,10 @@ public: RawBytesPerRecord = 1.0 * rawBytes / recordsCount; } + TString DebugString() const { + return TStringBuilder() << "{sbpr=" << SerializedBytesPerRecord << ";rbpr=" << RawBytesPerRecord << "}"; + } + TBatchSerializationStat(const TSimpleSerializationStat& simple) { SerializedBytesPerRecord = simple.GetSerializedBytesPerRecord(); RawBytesPerRecord = simple.GetRawBytesPerRecord(); @@ -114,6 +126,7 @@ public: class TColumnSerializationStat: public TSimpleSerializationStat { private: + using TBase = TSimpleSerializationStat; YDB_READONLY(ui32, ColumnId, 0); YDB_READONLY_DEF(std::string, ColumnName); public: @@ -133,6 +146,10 @@ public: return result; } + TString DebugString() const { + return TStringBuilder() << "{id=" << ColumnId << ";name=" << ColumnName << ";details=" << TBase::DebugString() << "}"; + } + void Merge(const TSimpleSerializationStat& item) { SerializedBytes += item.GetSerializedBytes(); RawBytes += item.GetRawBytes(); @@ -146,6 +163,16 @@ private: std::map<ui32, TColumnSerializationStat*> StatsByColumnId; std::map<std::string, TColumnSerializationStat*> StatsByColumnName; public: + TString DebugString() const { + TStringBuilder sb; + sb << "{columns="; + for (auto&& i : ColumnStat) { + sb << i.DebugString(); + } + sb << ";}"; + return sb; + } + void Merge(const TSerializationStats& item) { for (auto&& i : item.ColumnStat) { AddStat(i); diff --git a/ydb/core/tx/program/program.cpp b/ydb/core/tx/program/program.cpp index 49967d75d4a..6ee25067bdd 100644 --- a/ydb/core/tx/program/program.cpp +++ b/ydb/core/tx/program/program.cpp @@ -475,6 +475,7 @@ bool TProgramContainer::Init(const IColumnResolver& columnResolver, NKikimrSchem return false; } + ProgramProto = programProto; if (IS_DEBUG_LOG_ENABLED(NKikimrServices::TX_COLUMNSHARD)) { TString out; ::google::protobuf::TextFormat::PrintToString(programProto, &out); diff --git a/ydb/core/tx/program/program.h b/ydb/core/tx/program/program.h index 67cac1845ae..b595fc1f610 100644 --- a/ydb/core/tx/program/program.h +++ b/ydb/core/tx/program/program.h @@ -21,12 +21,21 @@ public: class TProgramContainer { private: + NKikimrSSA::TProgram ProgramProto; std::shared_ptr<NSsa::TProgram> Program; std::shared_ptr<arrow::RecordBatch> ProgramParameters; // TODO TKernelsRegistry KernelsRegistry; std::optional<std::set<std::string>> OverrideProcessingColumnsSet; std::optional<std::vector<TString>> OverrideProcessingColumnsVector; public: + TString ProtoDebugString() const { + return ProgramProto.DebugString(); + } + + TString DebugString() const { + return Program ? Program->DebugString() : "NO_PROGRAM"; + } + bool HasOverridenProcessingColumnIds() const { return !!OverrideProcessingColumnsVector; } @@ -75,8 +84,6 @@ public: std::set<std::string> GetEarlyFilterColumns() const; std::set<std::string> GetProcessingColumns() const; - - bool HasEarlyFilterOnly() const; private: bool ParseProgram(const IColumnResolver& columnResolver, const NKikimrSSA::TProgram& program, TString& error); }; |
