2019-10-21 00:28:29 +00:00
|
|
|
#include <Storages/MergeTree/IMergeTreeDataPartWriter.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-02-03 12:08:40 +00:00
|
|
|
/// Writes data part in wide format.
|
2019-10-21 17:23:06 +00:00
|
|
|
class MergeTreeDataPartWriterWide : public IMergeTreeDataPartWriter
|
2019-10-21 00:28:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-01-17 12:24:27 +00:00
|
|
|
|
2019-10-21 15:33:59 +00:00
|
|
|
using ColumnToSize = std::map<std::string, UInt64>;
|
|
|
|
|
|
|
|
MergeTreeDataPartWriterWide(
|
2020-02-27 16:47:40 +00:00
|
|
|
DiskPtr disk,
|
2019-10-21 15:33:59 +00:00
|
|
|
const String & part_path,
|
|
|
|
const MergeTreeData & storage,
|
|
|
|
const NamesAndTypesList & columns_list,
|
2019-12-18 16:41:11 +00:00
|
|
|
const std::vector<MergeTreeIndexPtr> & indices_to_recalc,
|
2019-10-21 15:33:59 +00:00
|
|
|
const String & marks_file_extension,
|
|
|
|
const CompressionCodecPtr & default_codec,
|
2019-12-18 15:54:45 +00:00
|
|
|
const MergeTreeWriterSettings & settings,
|
2019-11-07 11:11:38 +00:00
|
|
|
const MergeTreeIndexGranularity & index_granularity);
|
2019-10-21 15:33:59 +00:00
|
|
|
|
2020-03-18 03:27:32 +00:00
|
|
|
void write(const Block & block, const IColumn::Permutation * permutation,
|
|
|
|
const Block & primary_key_block, const Block & skip_indexes_block) override;
|
2019-10-21 00:28:29 +00:00
|
|
|
|
2020-03-18 03:27:32 +00:00
|
|
|
void finishDataSerialization(IMergeTreeDataPart::Checksums & checksums, bool sync) override;
|
2019-10-21 17:23:06 +00:00
|
|
|
|
2019-12-09 21:21:17 +00:00
|
|
|
IDataType::OutputStreamGetter createStreamGetter(const String & name, WrittenOffsetColumns & offset_columns);
|
2019-10-21 00:28:29 +00:00
|
|
|
|
2020-01-16 16:15:01 +00:00
|
|
|
private:
|
2019-10-21 00:28:29 +00:00
|
|
|
/// Write data of one column.
|
|
|
|
/// Return how many marks were written and
|
|
|
|
/// how many rows were written for last mark
|
2019-12-18 15:54:45 +00:00
|
|
|
void writeColumn(
|
2019-10-21 00:28:29 +00:00
|
|
|
const String & name,
|
|
|
|
const IDataType & type,
|
|
|
|
const IColumn & column,
|
2019-12-09 21:21:17 +00:00
|
|
|
WrittenOffsetColumns & offset_columns);
|
2019-10-21 00:28:29 +00:00
|
|
|
|
|
|
|
/// Write single granule of one column (rows between 2 marks)
|
|
|
|
size_t writeSingleGranule(
|
|
|
|
const String & name,
|
|
|
|
const IDataType & type,
|
|
|
|
const IColumn & column,
|
|
|
|
WrittenOffsetColumns & offset_columns,
|
|
|
|
IDataType::SerializeBinaryBulkStatePtr & serialization_state,
|
|
|
|
IDataType::SerializeBinaryBulkSettings & serialize_settings,
|
|
|
|
size_t from_row,
|
|
|
|
size_t number_of_rows,
|
|
|
|
bool write_marks);
|
|
|
|
|
|
|
|
/// Write mark for column
|
|
|
|
void writeSingleMark(
|
|
|
|
const String & name,
|
|
|
|
const IDataType & type,
|
|
|
|
WrittenOffsetColumns & offset_columns,
|
|
|
|
size_t number_of_rows,
|
|
|
|
DB::IDataType::SubstreamPath & path);
|
2019-12-18 16:41:11 +00:00
|
|
|
|
2019-10-21 17:23:06 +00:00
|
|
|
void writeFinalMark(
|
|
|
|
const std::string & column_name,
|
|
|
|
const DataTypePtr column_type,
|
|
|
|
WrittenOffsetColumns & offset_columns,
|
|
|
|
DB::IDataType::SubstreamPath & path);
|
2019-10-21 00:28:29 +00:00
|
|
|
|
2019-10-21 15:33:59 +00:00
|
|
|
void addStreams(
|
|
|
|
const String & name,
|
|
|
|
const IDataType & type,
|
|
|
|
const CompressionCodecPtr & effective_codec,
|
2019-12-09 21:21:17 +00:00
|
|
|
size_t estimated_size);
|
2019-10-21 15:33:59 +00:00
|
|
|
|
2019-10-21 00:28:29 +00:00
|
|
|
SerializationStates serialization_states;
|
2020-02-19 14:07:36 +00:00
|
|
|
|
|
|
|
using ColumnStreams = std::map<String, StreamPtr>;
|
2019-10-21 00:28:29 +00:00
|
|
|
ColumnStreams column_streams;
|
|
|
|
};
|
|
|
|
|
2019-10-21 15:33:59 +00:00
|
|
|
}
|