| 132 | } |
| 133 | |
| 134 | Chunk SourceFromInputStream::generate() |
| 135 | { |
| 136 | if (is_stream_finished) |
| 137 | return {}; |
| 138 | |
| 139 | if (!is_stream_started) |
| 140 | { |
| 141 | stream->readPrefix(); |
| 142 | is_stream_started = true; |
| 143 | } |
| 144 | |
| 145 | auto block = stream->read(); |
| 146 | if (!block && !isCancelled()) |
| 147 | { |
| 148 | if (rows_before_limit) |
| 149 | { |
| 150 | const auto & info = stream->getProfileInfo(); |
| 151 | if (info.hasAppliedLimit()) |
| 152 | rows_before_limit->add(info.getRowsBeforeLimit()); |
| 153 | } |
| 154 | |
| 155 | stream->readSuffix(); |
| 156 | |
| 157 | if (auto totals_block = stream->getTotals()) |
| 158 | { |
| 159 | if (totals_block.rows() > 0) /// Sometimes we can get empty totals. Skip it. |
| 160 | { |
| 161 | totals.setColumns(totals_block.getColumns(), totals_block.rows()); |
| 162 | has_totals = true; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if (auto extremes_block = stream->getExtremes()) |
| 167 | { |
| 168 | if (extremes_block.rows() > 0) /// Sometimes we can get empty extremes. Skip it. |
| 169 | { |
| 170 | extremes.setColumns(extremes_block.getColumns(), extremes_block.rows()); |
| 171 | has_extremes = true; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | is_stream_finished = true; |
| 176 | return {}; |
| 177 | } |
| 178 | |
| 179 | if (isCancelled()) |
| 180 | return {}; |
| 181 | |
| 182 | #ifndef NDEBUG |
| 183 | assertBlocksHaveEqualStructure(getPort().getHeader(), block, "SourceFromInputStream"); |
| 184 | #endif |
| 185 | |
| 186 | UInt64 num_rows = block.rows(); |
| 187 | Chunk chunk(block.getColumns(), num_rows); |
| 188 | |
| 189 | if (force_add_aggregating_info || has_aggregate_functions) |
| 190 | { |
| 191 | auto info = std::make_shared<AggregatedChunkInfo>(); |
nothing calls this directly
no test coverage detected