From 71b5d267ce1fcae6f47704bb91d8f95c63b688f2 Mon Sep 17 00:00:00 2001 From: Avogar Date: Thu, 18 Jun 2020 21:02:13 +0300 Subject: [PATCH] Set compression to None --- .../Formats/Impl/ORCBlockOutputFormat.cpp | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp b/src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp index f34ca21a1b3..d57a5b665ca 100644 --- a/src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp +++ b/src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp @@ -42,7 +42,17 @@ void ORCOutputStream::write(const void* buf, size_t length) } ORCBlockOutputFormat::ORCBlockOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings_) - : IOutputFormat(header_, out_), format_settings{format_settings_}, output_stream(out_), data_types(header_.getDataTypes()) {} + : IOutputFormat(header_, out_), format_settings{format_settings_}, output_stream(out_), data_types(header_.getDataTypes()) +{ + schema = orc::createStructType(); + options.setCompression(orc::CompressionKind::CompressionKind_NONE); + size_t columns_count = header_.columns(); + for (size_t i = 0; i != columns_count; ++i) + { + schema->addStructField(header_.safeGetByPosition(i).name, getORCType(data_types[i])); + } + writer = orc::createWriter(*schema, &output_stream, options); +} ORC_UNIQUE_PTR ORCBlockOutputFormat::getORCType(const DataTypePtr & type) { @@ -140,10 +150,7 @@ void ORCBlockOutputFormat::ORCBlockOutputFormat::writeNumbers( number_orc_column->notNull[i] = 0; continue; } - if constexpr (std::is_same_v) - number_orc_column->data[i] = static_cast(number_column.getElement(i)); - else - number_orc_column->data[i] = number_column.getElement(i); + number_orc_column->data[i] = number_column.getElement(i); } number_orc_column->numElements = number_column.size(); } @@ -355,7 +362,7 @@ void ORCBlockOutputFormat::writeColumn( writeColumn(orc_column, nullable_column.getNestedColumn(), nested_type, &new_null_bytemap); break; } - /* Doesn't work + /* Doesn't work for unknown reason case TypeIndex::Array: { orc::ListVectorBatch * list_orc_column = dynamic_cast(orc_column); @@ -384,16 +391,6 @@ void ORCBlockOutputFormat::consume(Chunk chunk) { size_t columns_num = chunk.getNumColumns(); size_t rows_num = chunk.getNumRows(); - if (!writer) - { - const Block & header = getPort(PortKind::Main).getHeader(); - schema = orc::createStructType(); - for (size_t i = 0; i != columns_num; ++i) - { - schema->addStructField(header.safeGetByPosition(i).name, getORCType(data_types[i])); - } - writer = orc::createWriter(*schema, &output_stream, options); - } ORC_UNIQUE_PTR batch = writer->createRowBatch(rows_num); orc::StructVectorBatch *root = dynamic_cast(batch.get()); for (size_t i = 0; i != columns_num; ++i)