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

Method make

matlab/src/cpp/arrow/matlab/tabular/proxy/record_batch.cc:82–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82libmexclass::proxy::MakeResult RecordBatch::make(
83 const libmexclass::proxy::FunctionArguments& constructor_arguments) {
84 namespace mda = ::matlab::data;
85 mda::StructArray opts = constructor_arguments[0];
86 const mda::TypedArray<uint64_t> arrow_array_proxy_ids = opts[0]["ArrayProxyIDs"];
87 const mda::StringArray column_names = opts[0]["ColumnNames"];
88
89 std::vector<std::shared_ptr<arrow::Array>> arrow_arrays;
90 // Retrieve all of the Arrow Array Proxy instances from the libmexclass ProxyManager.
91 for (const auto& arrow_array_proxy_id : arrow_array_proxy_ids) {
92 auto proxy = libmexclass::proxy::ProxyManager::getProxy(arrow_array_proxy_id);
93 auto arrow_array_proxy =
94 std::static_pointer_cast<arrow::matlab::array::proxy::Array>(proxy);
95 auto arrow_array = arrow_array_proxy->unwrap();
96 arrow_arrays.push_back(arrow_array);
97 }
98
99 std::vector<std::shared_ptr<Field>> fields;
100 for (size_t i = 0; i < arrow_arrays.size(); ++i) {
101 const auto type = arrow_arrays[i]->type();
102 const auto column_name_utf16 = std::u16string(column_names[i]);
103 MATLAB_ASSIGN_OR_ERROR(const auto column_name_utf8,
104 arrow::util::UTF16StringToUTF8(column_name_utf16),
105 error::UNICODE_CONVERSION_ERROR_ID);
106 fields.push_back(std::make_shared<arrow::Field>(column_name_utf8, type));
107 }
108
109 arrow::SchemaBuilder schema_builder;
110 MATLAB_ERROR_IF_NOT_OK(schema_builder.AddFields(fields),
111 error::SCHEMA_BUILDER_ADD_FIELDS_ERROR_ID);
112 MATLAB_ASSIGN_OR_ERROR(const auto schema, schema_builder.Finish(),
113 error::SCHEMA_BUILDER_FINISH_ERROR_ID);
114 const auto num_rows = arrow_arrays.size() == 0 ? 0 : arrow_arrays[0]->length();
115 const auto record_batch = arrow::RecordBatch::Make(schema, num_rows, arrow_arrays);
116 auto record_batch_proxy =
117 std::make_shared<arrow::matlab::tabular::proxy::RecordBatch>(record_batch);
118
119 return record_batch_proxy;
120}
121
122void RecordBatch::getNumRows(libmexclass::proxy::method::Context& context) {
123 namespace mda = ::matlab::data;

Callers

nothing calls this directly

Calls 7

push_backMethod · 0.80
AddFieldsMethod · 0.80
MakeFunction · 0.50
unwrapMethod · 0.45
sizeMethod · 0.45
typeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected