MCPcopy Create free account
hub / github.com/apache/arrow / ToRecordBatch

Method ToRecordBatch

cpp/src/arrow/compute/exec.cc:242–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242Result<std::shared_ptr<RecordBatch>> ExecBatch::ToRecordBatch(
243 std::shared_ptr<Schema> schema, MemoryPool* pool) const {
244 if (static_cast<size_t>(schema->num_fields()) > values.size()) {
245 return Status::Invalid("ExecBatch::ToRecordBatch mismatching schema size");
246 }
247 ArrayVector columns(schema->num_fields());
248
249 for (size_t i = 0; i < columns.size(); ++i) {
250 const Datum& value = values[i];
251 if (value.is_array()) {
252 columns[i] = value.make_array();
253 continue;
254 } else if (value.is_scalar()) {
255 ARROW_ASSIGN_OR_RAISE(columns[i],
256 MakeArrayFromScalar(*value.scalar(), length, pool));
257 } else {
258 return Status::TypeError("ExecBatch::ToRecordBatch value ", i, " with unsupported ",
259 "value kind ", ::arrow::ToString(value.kind()));
260 }
261 }
262
263 return RecordBatch::Make(std::move(schema), length, std::move(columns));
264}
265
266namespace {
267

Callers 14

ConsumeMethod · 0.80
ToEnumeratedRecordBatchFunction · 0.80
GenerateBatchesFunction · 0.80
ConsumeMethod · 0.80
ProcessBatchMethod · 0.80
ReadNextMethod · 0.80
operator()Method · 0.80
InputReceivedMethod · 0.80
ProcessMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.80
InputReceivedMethod · 0.80
TESTFunction · 0.80

Calls 13

is_arrayMethod · 0.80
make_arrayMethod · 0.80
is_scalarMethod · 0.80
InvalidFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
MakeArrayFromScalarFunction · 0.50
TypeErrorFunction · 0.50
ToStringFunction · 0.50
MakeFunction · 0.50
num_fieldsMethod · 0.45
sizeMethod · 0.45
scalarMethod · 0.45

Tested by 2

ASSERT_OK_AND_ASSIGNFunction · 0.64
TESTFunction · 0.64