| 102 | |
| 103 | |
| 104 | void NativeBlockOutputStream::write(const Block & block) |
| 105 | { |
| 106 | /// Additional information about the block. |
| 107 | if (client_revision > 0) |
| 108 | block.info.write(ostr); |
| 109 | |
| 110 | block.checkNumberOfRows(); |
| 111 | |
| 112 | /// Dimensions |
| 113 | size_t columns = block.columns(); |
| 114 | size_t rows = block.rows(); |
| 115 | |
| 116 | writeVarUInt(columns, ostr); |
| 117 | writeVarUInt(rows, ostr); |
| 118 | |
| 119 | /** The index has the same structure as the data stream. |
| 120 | * But instead of column values, it contains a mark that points to the location in the data file where this part of the column is located. |
| 121 | */ |
| 122 | if (index_ostr) |
| 123 | { |
| 124 | writeVarUInt(columns, *index_ostr); |
| 125 | writeVarUInt(rows, *index_ostr); |
| 126 | } |
| 127 | |
| 128 | for (size_t i = 0; i < columns; ++i) |
| 129 | { |
| 130 | /// For the index. |
| 131 | MarkInCompressedFile mark; |
| 132 | |
| 133 | if (index_ostr) |
| 134 | { |
| 135 | ostr_concrete->next(); /// Finish compressed block. |
| 136 | mark.offset_in_compressed_file = initial_size_of_file + ostr_concrete->getCompressedBytes(); |
| 137 | mark.offset_in_decompressed_block = ostr_concrete->getRemainingBytes(); |
| 138 | } |
| 139 | |
| 140 | ColumnWithTypeAndName column = block.safeGetByPosition(i); |
| 141 | |
| 142 | /// Send data to old clients without low cardinality type. |
| 143 | if (remove_low_cardinality || (client_revision && client_revision < DBMS_MIN_REVISION_WITH_LOW_CARDINALITY_TYPE)) |
| 144 | { |
| 145 | column.column = recursiveRemoveLowCardinality(column.column); |
| 146 | column.type = recursiveRemoveLowCardinality(column.type); |
| 147 | } |
| 148 | |
| 149 | /// Name |
| 150 | writeStringBinary(column.name, ostr); |
| 151 | |
| 152 | /// Type |
| 153 | String type_name = column.type->getName(); |
| 154 | |
| 155 | /// For compatibility, we will not send explicit timezone parameter in DateTime data type |
| 156 | /// to older clients, that cannot understand it. |
| 157 | if (client_revision < DBMS_MIN_REVISION_WITH_TIME_ZONE_PARAMETER_IN_DATETIME_DATA_TYPE |
| 158 | && startsWith(type_name, "DateTime(")) |
| 159 | type_name = "DateTime"; |
| 160 | |
| 161 | writeStringBinary(type_name, ostr); |
nothing calls this directly
no test coverage detected