Conversion of RecordBatch to Tensor instances#

Arrow provides a method to convert RecordBatch objects to a Tensor with two dimensions:

std::shared_ptr<RecordBatch> batch;

ASSERT_OK_AND_ASSIGN(auto tensor, batch->ToTensor());
ASSERT_OK(tensor->Validate());

The conversion supports signed and unsigned integer types plus float types. In case the RecordBatch has null values the conversion succeeds if null_to_nan parameter is set to true. In this case all types will be promoted to a floating-point data type.

std::shared_ptr<RecordBatch> batch;

ASSERT_OK_AND_ASSIGN(auto tensor, batch->ToTensor(/*null_to_nan=*/true));
ASSERT_OK(tensor->Validate());

Currently only column-major conversion is supported.