| 183 | } |
| 184 | |
| 185 | Status TupleFileWriter::Commit(RuntimeState* state) { |
| 186 | DCHECK_EQ(state_, State::InProgress); |
| 187 | DCHECK(tmp_file_ != nullptr); |
| 188 | |
| 189 | RETURN_IF_ERROR(DebugAction(state->query_options(), "TUPLE_FILE_WRITER_COMMIT")); |
| 190 | |
| 191 | // Sync() is called asychnronously by TupleCacheMgr's sync thread pool. |
| 192 | KUDU_RETURN_IF_ERROR(tmp_file_->Close(), "Failed to close cache file"); |
| 193 | |
| 194 | std::string src = TempPath(); |
| 195 | KUDU_RETURN_IF_ERROR(kudu::Env::Default()->RenameFile(src, path_), |
| 196 | "Failed to rename cache file"); |
| 197 | tmp_file_.reset(); |
| 198 | state_ = State::Committed; |
| 199 | return Status::OK(); |
| 200 | } |
| 201 | |
| 202 | std::ostream& operator<<(std::ostream& out, const TupleFileWriter::State& state) { |
| 203 | switch (state) { |