aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-12-09 10:11:16 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-12-09 10:33:35 +0300
commitfa9347ea5cf4447897b525032be9a711cc3dc583 (patch)
tree4f3d4f493e4cfb43a3c8b5f7e279621c41e0e978 /contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h
parentf82bfd2a08a51c4815a4cde64974f819ed4f7128 (diff)
downloadydb-fa9347ea5cf4447897b525032be9a711cc3dc583.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h')
-rw-r--r--contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h36
1 files changed, 20 insertions, 16 deletions
diff --git a/contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h b/contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h
index 8d8fb9ef0c..4c5c3ef72e 100644
--- a/contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h
+++ b/contrib/clickhouse/src/Processors/Formats/OutputFormatWithUTF8ValidationAdaptor.h
@@ -6,15 +6,17 @@
#include <IO/WriteBuffer.h>
#include <IO/WriteBufferValidUTF8.h>
+#include <Common/logger_useful.h>
+
namespace DB
{
-template <typename Base, typename... Args>
+template <typename Base>
class OutputFormatWithUTF8ValidationAdaptorBase : public Base
{
public:
- OutputFormatWithUTF8ValidationAdaptorBase(bool validate_utf8, const Block & header, WriteBuffer & out_, Args... args)
- : Base(header, out_, std::forward<Args>(args)...)
+ OutputFormatWithUTF8ValidationAdaptorBase(const Block & header, WriteBuffer & out_, bool validate_utf8)
+ : Base(header, out_)
{
bool values_can_contain_invalid_utf8 = false;
for (const auto & type : this->getPort(IOutputFormat::PortKind::Main).getHeader().getDataTypes())
@@ -24,37 +26,39 @@ public:
}
if (validate_utf8 && values_can_contain_invalid_utf8)
- {
- validating_ostr = std::make_unique<WriteBufferValidUTF8>(this->out);
- ostr = validating_ostr.get();
- }
- else
- ostr = &this->out;
+ validating_ostr = std::make_unique<WriteBufferValidUTF8>(*Base::getWriteBufferPtr());
}
void flush() override
{
- ostr->next();
-
if (validating_ostr)
- this->out.next();
+ validating_ostr->next();
+ Base::flush();
}
void finalizeBuffers() override
{
if (validating_ostr)
validating_ostr->finalize();
+ Base::finalizeBuffers();
}
void resetFormatterImpl() override
{
- validating_ostr = std::make_unique<WriteBufferValidUTF8>(this->out);
- ostr = validating_ostr.get();
+ LOG_DEBUG(&Poco::Logger::get("RowOutputFormatWithExceptionHandlerAdaptor"), "resetFormatterImpl");
+ Base::resetFormatterImpl();
+ if (validating_ostr)
+ validating_ostr = std::make_unique<WriteBufferValidUTF8>(*Base::getWriteBufferPtr());
}
protected:
- /// Point to validating_ostr or out from IOutputFormat, should be used in derived classes instead of out.
- WriteBuffer * ostr;
+ /// Returns buffer that should be used in derived classes instead of out.
+ WriteBuffer * getWriteBufferPtr() override
+ {
+ if (validating_ostr)
+ return validating_ostr.get();
+ return Base::getWriteBufferPtr();
+ }
private:
/// Validates UTF-8 sequences, replaces bad sequences with replacement character.