fanruan-tuco commented on code in PR #55629:
URL: https://github.com/apache/arrow/pull/55629#discussion_r4663652003
##########
cpp/src/parquet/column_writer.cc:
##########
@@ -1338,7 +1345,14 @@ class TypedColumnWriterImpl : public ColumnWriterImpl,
"Content-defined chunking is not supported in WriteBatch() or "
"WriteBatchSpaced(), use WriteArrow() instead.");
}
- return WriteBatchInternal(num_values, def_levels, rep_levels, values);
+ if (closed_ || failed_) {
+ throw ParquetException("Cannot write to a closed or failed column
writer");
+ }
+ failed_ = true;
Review Comment:
But I find both the macro and the RAII guard a bit hard to follow here.
There are already three states to keep track of, and I’d like to keep things
simple and stupid.
Could we use a BeginWrite() helper instead? It would check closed_ ||
failed_ and set failed_ = true. Then each caller would clear it only on success:
```cpp
BeginWrite();
const auto written = WriteBatchInternal(...);
failed_ = false;
return written;
```
WriteArrow could use ARROW_RETURN_NOT_OK before clearing failed_.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]