| 136 | } |
| 137 | |
| 138 | void ZstdDeflatingWriteBuffer::finishImpl() |
| 139 | { |
| 140 | next(); |
| 141 | |
| 142 | out->nextIfAtEnd(); |
| 143 | |
| 144 | input.src = reinterpret_cast<unsigned char *>(working_buffer.begin()); |
| 145 | input.size = offset(); |
| 146 | input.pos = 0; |
| 147 | |
| 148 | output.dst = reinterpret_cast<unsigned char *>(out->buffer().begin()); |
| 149 | output.size = out->buffer().size(); |
| 150 | output.pos = out->offset(); |
| 151 | |
| 152 | size_t remaining = ZSTD_compressStream2(cctx, &output, &input, ZSTD_e_end); |
| 153 | if (ZSTD_isError(remaining)) |
| 154 | throw Exception(ErrorCodes::ZSTD_ENCODER_FAILED, "zstd stream encoder end failed: zstd version: {}", ZSTD_VERSION_STRING); |
| 155 | out->position() = out->buffer().begin() + output.pos; |
| 156 | } |
| 157 | |
| 158 | } |