| 134 | } |
| 135 | |
| 136 | Block NativeReader::read() |
| 137 | { |
| 138 | Block res; |
| 139 | |
| 140 | const DataTypeFactory & data_type_factory = DataTypeFactory::instance(); |
| 141 | |
| 142 | if (use_index && index_block_it == index_block_end) |
| 143 | return res; |
| 144 | |
| 145 | if (istr.eof()) |
| 146 | { |
| 147 | if (use_index) |
| 148 | throw Exception(ErrorCodes::CANNOT_READ_ALL_DATA, "Input doesn't contain all data for index."); |
| 149 | |
| 150 | return res; |
| 151 | } |
| 152 | |
| 153 | /// Additional information about the block. |
| 154 | if (server_revision > 0) |
| 155 | res.info.read(istr, server_revision); |
| 156 | |
| 157 | /// Dimensions |
| 158 | size_t columns = 0; |
| 159 | size_t rows = 0; |
| 160 | |
| 161 | if (!use_index) |
| 162 | { |
| 163 | readVarUInt(columns, istr); |
| 164 | readVarUInt(rows, istr); |
| 165 | |
| 166 | if (columns > DEFAULT_NATIVE_BINARY_MAX_NUM_COLUMNS) |
| 167 | throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Suspiciously many columns in Native format: {}", columns); |
| 168 | if (rows > DEFAULT_NATIVE_BINARY_MAX_NUM_ROWS) |
| 169 | throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Suspiciously many rows in Native format: {}", rows); |
| 170 | } |
| 171 | else |
| 172 | { |
| 173 | columns = index_block_it->num_columns; |
| 174 | rows = index_block_it->num_rows; |
| 175 | } |
| 176 | |
| 177 | if (columns == 0 && header.empty() && rows != 0) |
| 178 | throw Exception(ErrorCodes::INCORRECT_DATA, "Zero columns but {} rows in Native format.", rows); |
| 179 | |
| 180 | for (size_t i = 0; i < columns; ++i) |
| 181 | { |
| 182 | if (use_index) |
| 183 | { |
| 184 | /// If the current position is what is required, the real seek does not occur. |
| 185 | istr_concrete->seek(index_column_it->location.offset_in_compressed_file, index_column_it->location.offset_in_decompressed_block); |
| 186 | } |
| 187 | |
| 188 | ColumnWithTypeAndName column; |
| 189 | |
| 190 | /// Name |
| 191 | readBinary(column.name, istr); |
| 192 | |
| 193 | /// Type |
nothing calls this directly
no test coverage detected