Skip to content

Commit bd54ed4

Browse files
committed
DPL: improve catching of low memory related bugs
1 parent 6938e1e commit bd54ed4

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Framework/Core/src/DataAllocator.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,15 @@ void DataAllocator::adopt(const Output& spec, LifetimeHolder<FragmentToBatch>& f
263263
// Serialization happens in here, so that we can
264264
// get rid of the intermediate tree 2 table object, saving memory.
265265
auto batch = source.finalize();
266+
if (!batch) {
267+
throw std::runtime_error("FragmentToBatch::finalize() returned null RecordBatch");
268+
}
266269
auto mock = std::make_shared<arrow::io::MockOutputStream>();
267270
int64_t expectedSize = 0;
268271
auto mockWriter = arrow::ipc::MakeStreamWriter(mock.get(), batch->schema());
272+
if (!mockWriter.ok()) {
273+
throw std::runtime_error(fmt::format("Unable to create mock stream writer: {}", mockWriter.status().ToString()));
274+
}
269275
arrow::Status outStatus = mockWriter.ValueOrDie()->WriteRecordBatch(*batch);
270276

271277
expectedSize = mock->Tell().ValueOrDie();
@@ -275,6 +281,9 @@ void DataAllocator::adopt(const Output& spec, LifetimeHolder<FragmentToBatch>& f
275281
}
276282

277283
auto deferredWriterStream = source.streamer(buffer);
284+
if (!deferredWriterStream) {
285+
throw std::runtime_error("FragmentToBatch streamer returned null OutputStream");
286+
}
278287

279288
auto outBatch = arrow::ipc::MakeStreamWriter(deferredWriterStream, batch->schema());
280289
if (outBatch.ok() == false) {

0 commit comments

Comments
 (0)