CurtHagenlocher commented on code in PR #35996:
URL: https://github.com/apache/arrow/pull/35996#discussion_r1223333700
##########
csharp/src/Apache.Arrow/C/CArrowArrayStreamImporter.cs:
##########
@@ -99,24 +93,17 @@ public ValueTask<RecordBatch>
ReadNextRecordBatchAsync(CancellationToken cancell
}
RecordBatch result = null;
- CArrowArray* cArray = CArrowArray.Create();
- try
+ CArrowArray cArray = new CArrowArray();
+ fixed (CArrowArrayStream* cArrayStream = &_cArrayStream)
{
- int errno = _cArrayStream->get_next(_cArrayStream, cArray);
+ int errno = cArrayStream->get_next(cArrayStream, &cArray);
if (errno != 0)
{
throw new Exception($"Unexpected error recieved from
external stream. Errno: {errno}");
}
- if (cArray->release != null)
+ if (cArray.release != null)
{
- result = CArrowArrayImporter.ImportRecordBatch(cArray,
_schema);
- }
- }
- finally
- {
- if (result == null)
- {
- CArrowArray.Free(cArray);
Review Comment:
ImportRecordBatch always took ownership of the array data before. What's
changed is that the memory for cArray is now allocated on the stack instead of
the heap.
--
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]