| 265 | } |
| 266 | |
| 267 | uint64_t SpillWriter::flush() { |
| 268 | if (batch_ == nullptr) { |
| 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | auto* file = ensureFile(); |
| 273 | BOLT_CHECK_NOT_NULL(file); |
| 274 | |
| 275 | IOBufOutputStream out( |
| 276 | *pool_, nullptr, std::max<int64_t>(64 * 1024, batch_->size())); |
| 277 | uint64_t flushTimeUs{0}; |
| 278 | { |
| 279 | MicrosecondTimer timer(&flushTimeUs); |
| 280 | batch_->flush(&out); |
| 281 | } |
| 282 | batch_.reset(); |
| 283 | |
| 284 | uint64_t writeTimeUs{0}; |
| 285 | uint64_t writtenBytes{0}; |
| 286 | auto iobuf = out.getIOBuf(); |
| 287 | { |
| 288 | MicrosecondTimer timer(&writeTimeUs); |
| 289 | writtenBytes = file->write(std::move(iobuf)); |
| 290 | } |
| 291 | updateWriteStats(writtenBytes, flushTimeUs, writeTimeUs); |
| 292 | updateAndCheckSpillLimitCb_(writtenBytes); |
| 293 | return writtenBytes; |
| 294 | } |
| 295 | |
| 296 | uint64_t SpillWriter::write( |
| 297 | const RowVectorPtr& rows, |