diff --git a/matlab/CMakeLists.txt b/matlab/CMakeLists.txt index 09c8839aaf0..5ee48a87c3a 100644 --- a/matlab/CMakeLists.txt +++ b/matlab/CMakeLists.txt @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.20) + set(CMAKE_CXX_STANDARD 11) set(MLARROW_VERSION "5.0.0-SNAPSHOT") @@ -29,22 +30,45 @@ if(EXISTS "${CPP_CMAKE_MODULES}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CPP_CMAKE_MODULES}) endif() -## Arrow is Required +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake_modules) + +# Arrow is Required find_package(Arrow REQUIRED) -## MATLAB is required to be installed to build MEX interfaces -set(MATLAB_ADDITIONAL_VERSIONS "R2018a=9.4") -find_package(Matlab REQUIRED MX_LIBRARY) - -# Build featherread mex file based on the arrow shared library -matlab_add_mex(NAME featherreadmex - SRC src/featherreadmex.cc src/feather_reader.cc src/util/handle_status.cc - src/util/unicode_conversion.cc - LINK_TO ${ARROW_SHARED_LIB}) -target_include_directories(featherreadmex PRIVATE ${ARROW_INCLUDE_DIR}) - -# Build featherwrite mex file based on the arrow shared library -matlab_add_mex(NAME featherwritemex - SRC src/featherwritemex.cc src/feather_writer.cc src/util/handle_status.cc - LINK_TO ${ARROW_SHARED_LIB}) -target_include_directories(featherwritemex PRIVATE ${ARROW_INCLUDE_DIR}) +# MATLAB is Required +find_package(Matlab REQUIRED) + +# Construct the absolute path to featherread's source files +set(featherread_sources featherreadmex.cc feather_reader.cc util/handle_status.cc + util/unicode_conversion.cc) +list(TRANSFORM featherread_sources PREPEND ${CMAKE_SOURCE_DIR}/src/) + +# Build featherreadmex MEX binary +matlab_add_mex(R2018a + NAME featherreadmex + SRC ${featherread_sources} + LINK_TO arrow_shared) + +# Construct the absolute path to featherwrite's source files +set(featherwrite_sources featherwritemex.cc feather_writer.cc util/handle_status.cc + util/unicode_conversion.cc) +list(TRANSFORM featherwrite_sources PREPEND ${CMAKE_SOURCE_DIR}/src/) + +# Build featherwritemex MEX binary +matlab_add_mex(R2018a + NAME featherwritemex + SRC ${featherwrite_sources} + LINK_TO arrow_shared) + +# Ensure the MEX binaries are placed in the src directory on all platforms +if(WIN32) + set_target_properties(featherreadmex PROPERTIES RUNTIME_OUTPUT_DIRECTORY + $<1:${CMAKE_SOURCE_DIR}/src>) + set_target_properties(featherwritemex PROPERTIES RUNTIME_OUTPUT_DIRECTORY + $<1:${CMAKE_SOURCE_DIR}/src>) +else() + set_target_properties(featherreadmex PROPERTIES LIBRARY_OUTPUT_DIRECTORY + $<1:${CMAKE_SOURCE_DIR}/src>) + set_target_properties(featherwritemex PROPERTIES LIBRARY_OUTPUT_DIRECTORY + $<1:${CMAKE_SOURCE_DIR}/src>) +endif() diff --git a/matlab/src/+mlarrow/+util/createMetadataStruct.m b/matlab/src/+mlarrow/+util/createMetadataStruct.m index 7a2397059b6..b1b8bc7edd9 100644 --- a/matlab/src/+mlarrow/+util/createMetadataStruct.m +++ b/matlab/src/+mlarrow/+util/createMetadataStruct.m @@ -1,4 +1,4 @@ -function metadata = createMetadataStruct(description, numRows, numVariables) +function metadata = createMetadataStruct(numRows, numVariables) % CREATEMETADATASTRUCT Helper function for creating Feather MEX metadata % struct. @@ -17,8 +17,7 @@ % implied. See the License for the specific language governing % permissions and limitations under the License. -metadata = struct('Description', description, ... - 'NumRows', numRows, ... +metadata = struct('NumRows', numRows, ... 'NumVariables', numVariables); end diff --git a/matlab/src/+mlarrow/+util/table2mlarrow.m b/matlab/src/+mlarrow/+util/table2mlarrow.m index 3103724f945..36e4d1d15a9 100644 --- a/matlab/src/+mlarrow/+util/table2mlarrow.m +++ b/matlab/src/+mlarrow/+util/table2mlarrow.m @@ -23,7 +23,6 @@ % % Field Name Class Description % ------------ ------- ---------------------------------------------- -% Description char Table description (T.Properties.Description) % NumRows double Number of table rows (height(T)) % NumVariables double Number of table variables (width(T)) % @@ -51,7 +50,7 @@ variables = repmat(createVariableStruct('', [], [], ''), 1, width(t)); % Struct representing table-level metadata. -metadata = createMetadataStruct(t.Properties.Description, height(t), width(t)); +metadata = createMetadataStruct(height(t), width(t)); % Iterate over each variable in the given table, % extracting the underlying array data. diff --git a/matlab/src/feather_reader.cc b/matlab/src/feather_reader.cc index 484c300e0e4..1cbb50541e7 100644 --- a/matlab/src/feather_reader.cc +++ b/matlab/src/feather_reader.cc @@ -18,16 +18,21 @@ #include #include +#include "feather_reader.h" + +#include +#include +#include #include #include +#include #include #include #include -#include - +#include +#include #include -#include "feather_reader.h" #include "matlab_traits.h" #include "util/handle_status.h" #include "util/unicode_conversion.h" @@ -52,11 +57,11 @@ mxArray* ReadNumericVariableData(const std::shared_ptr& column) { mxArray* variable_data = mxCreateNumericMatrix(column->length(), 1, matlab_class_id, mxREAL); - std::shared_ptr integer_array = + auto arrow_numeric_array = std::static_pointer_cast(column); // Get a raw pointer to the Arrow array data. - const MatlabType* source = integer_array->raw_values(); + const MatlabType* source = arrow_numeric_array->raw_values(); // Get a mutable pointer to the MATLAB array data and std::copy the // Arrow array data into it. @@ -121,8 +126,7 @@ void BitUnpackBuffer(const std::shared_ptr& source, int64_t length, // writes to a zero-initialized destination buffer. // Implements a fast path for the fully-valid and fully-invalid cases. // Returns true if the destination buffer was successfully populated. -bool TryBitUnpackFastPath(const std::shared_ptr& array, - mxLogical* destination) { +bool TryBitUnpackFastPath(const std::shared_ptr& array, mxLogical* destination) { const int64_t null_count = array->null_count(); const int64_t length = array->length(); @@ -177,32 +181,24 @@ Status FeatherReader::Open(const std::string& filename, *feather_reader = std::shared_ptr(new FeatherReader()); // Open file with given filename as a ReadableFile. - std::shared_ptr readable_file(nullptr); - - RETURN_NOT_OK(io::ReadableFile::Open(filename, &readable_file)); - - // TableReader expects a RandomAccessFile. - std::shared_ptr random_access_file(readable_file); - + ARROW_ASSIGN_OR_RAISE(auto readable_file, io::ReadableFile::Open(filename)); + // Open the Feather file for reading with a TableReader. - RETURN_NOT_OK(ipc::feather::TableReader::Open(random_access_file, - &(*feather_reader)->table_reader_)); - - // Read the table metadata from the Feather file. - (*feather_reader)->num_rows_ = (*feather_reader)->table_reader_->num_rows(); - (*feather_reader)->num_variables_ = (*feather_reader)->table_reader_->num_columns(); - (*feather_reader)->description_ = - (*feather_reader)->table_reader_->HasDescription() - ? (*feather_reader)->table_reader_->GetDescription() - : ""; - - if ((*feather_reader)->num_rows_ > internal::MAX_MATLAB_SIZE || - (*feather_reader)->num_variables_ > internal::MAX_MATLAB_SIZE) { - mexErrMsgIdAndTxt("MATLAB:arrow:SizeTooLarge", - "The table size exceeds MATLAB limits: %u x %u", - (*feather_reader)->num_rows_, (*feather_reader)->num_variables_); + ARROW_ASSIGN_OR_RAISE(auto reader, ipc::feather::Reader::Open(readable_file)); + + // Set the internal reader_ object. + (*feather_reader)->reader_ = reader; + + // Check the feather file version + auto version = reader->version(); + if (version == ipc::feather::kFeatherV2Version) { + return Status::NotImplemented("Support for Feather V2 has not been implemented."); + } else if (version != ipc::feather::kFeatherV1Version) { + return Status::Invalid("Unknown Feather format version."); } + // read the table metadata from the Feather file + (*feather_reader)->num_variables_ = reader->schema()->num_fields(); return Status::OK(); } @@ -225,15 +221,11 @@ mxArray* FeatherReader::ReadMetadata() const { mxSetField(metadata, 0, "NumVariables", mxCreateDoubleScalar(static_cast(num_variables_))); - // Set the description. - mxSetField(metadata, 0, "Description", - util::ConvertUTF8StringToUTF16CharMatrix(description_)); - return metadata; } // Read the table variables from the Feather file as a mxArray*. -mxArray* FeatherReader::ReadVariables() const { +mxArray* FeatherReader::ReadVariables() { const int32_t num_variable_fields = 4; const char* fieldnames[] = {"Name", "Type", "Data", "Valid"}; @@ -242,16 +234,34 @@ mxArray* FeatherReader::ReadVariables() const { mxArray* variables = mxCreateStructMatrix(1, num_variables_, num_variable_fields, fieldnames); - // Read all the table variables in the Feather file into memory. + std::shared_ptr table; + auto status = reader_->Read(&table); + if (!status.ok()) { + mexErrMsgIdAndTxt("MATLAB:arrow:FeatherReader::FailedToReadTable", + "Failed to read arrow::Table from Feather file. Reason: %s", + status.message().c_str()); + } + + // Set the number of rows + num_rows_ = table->num_rows(); + + if (num_rows_ > internal::MAX_MATLAB_SIZE || + num_variables_ > internal::MAX_MATLAB_SIZE) { + mexErrMsgIdAndTxt("MATLAB:arrow:SizeTooLarge", + "The table size exceeds MATLAB limits: %u x %u", num_rows_, + num_variables_); + } + + auto column_names = table->ColumnNames(); + for (int64_t i = 0; i < num_variables_; ++i) { - std::shared_ptr column; - util::HandleStatus(table_reader_->GetColumn(i, &column)); + auto column = table->column(i); if (column->num_chunks() != 1) { mexErrMsgIdAndTxt("MATLAB:arrow:FeatherReader::ReadVariables", "Chunked columns not yet supported"); } std::shared_ptr chunk = column->chunk(0); - const std::string column_name = table_reader_->GetColumnName(i); + const std::string column_name = column_names[i]; // set the struct fields data mxSetField(variables, i, "Name", internal::ReadVariableName(column_name)); diff --git a/matlab/src/feather_reader.h b/matlab/src/feather_reader.h index 00fea68f7ae..197e470bf6e 100644 --- a/matlab/src/feather_reader.h +++ b/matlab/src/feather_reader.h @@ -23,7 +23,6 @@ #include #include #include - #include namespace arrow { @@ -56,7 +55,7 @@ class FeatherReader { /// Clients are responsible for freeing the returned mxArray memory /// when it is no longer needed, or passing it to MATLAB to be managed. /// \return variables mxArray* struct array containing table variable data - mxArray* ReadVariables() const; + mxArray* ReadVariables(); /// \brief Initialize a FeatherReader object from a given Feather file. /// \param[in] filename path to a Feather file @@ -66,7 +65,7 @@ class FeatherReader { private: FeatherReader() = default; - std::unique_ptr table_reader_; + std::shared_ptr reader_; int64_t num_rows_; int64_t num_variables_; std::string description_; @@ -74,4 +73,3 @@ class FeatherReader { } // namespace matlab } // namespace arrow - diff --git a/matlab/src/feather_writer.cc b/matlab/src/feather_writer.cc index bd1576bca46..1a76ada1995 100644 --- a/matlab/src/feather_writer.cc +++ b/matlab/src/feather_writer.cc @@ -19,6 +19,8 @@ #include /* for std::multiplies */ #include /* for std::accumulate */ +#include "feather_writer.h" + #include #include #include @@ -26,11 +28,11 @@ #include #include #include -#include - +#include +#include +#include #include -#include "feather_writer.h" #include "matlab_traits.h" #include "util/handle_status.h" @@ -38,6 +40,37 @@ namespace arrow { namespace matlab { namespace internal { +// Returns the arrow::DataType that corresponds to the input type string +std::shared_ptr ConvertMatlabTypeStringToArrowDataType( + const std::string& t) { + if (t == "double") { + return arrow::float64(); + } else if (t == "single") { + return arrow::float32(); + } else if (t == "uint64") { + return arrow::uint64(); + } else if (t == "uint32") { + return arrow::uint32(); + } else if (t == "uint16") { + return arrow::uint16(); + } else if (t == "uint8") { + return arrow::uint8(); + } else if (t == "int64") { + return arrow::int64(); + } else if (t == "int32") { + return arrow::int32(); + } else if (t == "int16") { + return arrow::int16(); + } else if (t == "int8") { + return arrow::int8(); + } + mexErrMsgIdAndTxt("MATLAB:arrow:UnsupportedMatlabTypeString", + "Unsupported MATLAB type string: '%s'", t.c_str()); + + // mexErrMsgIdAndTxt throws unconditionally so we should never reach this line + return nullptr; +} + // Utility that helps verify the input mxArray struct field name and type. // Returns void since any errors will throw and terminate MEX execution. void ValidateMxStructField(const mxArray* struct_array, const char* fieldname, @@ -71,8 +104,7 @@ void ValidateMxStructField(const mxArray* struct_array, const char* fieldname, mxGetClassName(field), fieldname); } } - - // Some struct fields (like the table description) can be empty, while others + // Some struct fields (like Data) can be empty, while others // (like NumRows) should never be empty. This conditional helps account for both cases. if (!can_be_empty) { // Ensure that individual mxStructArray fields are non-empty. @@ -120,7 +152,7 @@ void ValidateNumRows(int64_t actual, int64_t expected) { } // Calculate the number of bytes required in the bit-packed validity buffer. -constexpr int64_t BitPackedLength(int64_t num_elements) { +int64_t BitPackedLength(int64_t num_elements) { // Since mxLogicalArray encodes [0, 1] in a full byte, we can compress that byte // down to a bit...therefore dividing the mxLogicalArray length by 8 here. return static_cast(std::ceil(num_elements / 8.0)); @@ -134,7 +166,7 @@ size_t GetNumberOfElements(const mxArray* array) { const size_t* dimensions = mxGetDimensions(array); // Iterate over the dimensions array and accumulate the total number of elements. - return std::accumulate(dimensions, dimensions + num_dimensions, 1, + return std::accumulate(dimensions, dimensions + num_dimensions, size_t{1}, std::multiplies()); } @@ -164,7 +196,7 @@ void BitPackBuffer(const mxArray* logical_array, // Iterate over the mxLogical array and write bit-packed bools to the arrow::Buffer. // Call into a loop-unrolled Arrow utility for better performance when bit-packing. - auto generator = [&]() -> uint8_t { return *unpacked_buffer_ptr++; }; + auto generator = [&]() -> bool { return *(unpacked_buffer_ptr++); }; const int64_t start_offset = 0; arrow::internal::GenerateBitsUnrolled(packed_buffer_ptr, start_offset, unpacked_buffer_length, generator); @@ -195,8 +227,8 @@ std::unique_ptr WriteNumericData(const mxArray* data, mxGetElementSize(data) * mxGetNumberOfElements(data)); // Construct arrow::NumericArray specialization using arrow::Buffer. - // Pass in nulls information...we could compute and provide the number of nulls here too, - // but passing -1 for now so that Arrow recomputes it if necessary. + // Pass in nulls information...we could compute and provide the number of nulls here + // too, but passing -1 for now so that Arrow recomputes it if necessary. return std::unique_ptr(new NumericArray( mxGetNumberOfElements(data), buffer, validity_bitmap, -1)); } @@ -228,7 +260,6 @@ std::unique_ptr WriteVariableData(const mxArray* data, const std::string& return WriteNumericData(data, validity_bitmap); case mxINT64_CLASS: return WriteNumericData(data, validity_bitmap); - default: { mexErrMsgIdAndTxt("MATLAB:arrow:UnsupportedArrowType", "Unsupported arrow::Type '%s' for variable '%s'", @@ -248,60 +279,41 @@ Status FeatherWriter::Open(const std::string& filename, *feather_writer = std::shared_ptr(new FeatherWriter()); // Open a FileOutputStream corresponding to the provided filename. - std::shared_ptr writable_file(nullptr); - ARROW_RETURN_NOT_OK(io::FileOutputStream::Open(filename, &writable_file)); - - // TableWriter::Open expects a shared_ptr to an OutputStream. - // Open the Feather file for writing with a TableWriter. - return ipc::feather::TableWriter::Open(writable_file, - &(*feather_writer)->table_writer_); -} - -// Write table metadata to the Feather file from a mxArray*. -void FeatherWriter::WriteMetadata(const mxArray* metadata) { - // Verify that all required fieldnames are provided. - internal::ValidateMxStructField(metadata, "Description", mxCHAR_CLASS, true); - internal::ValidateMxStructField(metadata, "NumRows", mxDOUBLE_CLASS, false); - internal::ValidateMxStructField(metadata, "NumVariables", mxDOUBLE_CLASS, false); - - // Convert Description to a std::string and set on FeatherWriter and TableWriter. - std::string description = - internal::MxArrayToString(mxGetField(metadata, 0, "Description")); - this->description_ = description; - this->table_writer_->SetDescription(description); - - // Get the NumRows field in the struct array and set on TableWriter. - this->num_rows_ = static_cast(mxGetScalar(mxGetField(metadata, 0, "NumRows"))); - this->table_writer_->SetNumRows(this->num_rows_); - - // Get the total number of variables. This is checked later for consistency with - // the provided number of columns before finishing the file write. - this->num_variables_ = - static_cast(mxGetScalar(mxGetField(metadata, 0, "NumVariables"))); + ARROW_ASSIGN_OR_RAISE((*feather_writer)->file_output_stream_, + io::FileOutputStream::Open(filename, &((*feather_writer)->file_output_stream_))); + return Status::OK(); } // Write mxArrays from MATLAB into a Feather file. -Status FeatherWriter::WriteVariables(const mxArray* variables) { +Status FeatherWriter::WriteVariables(const mxArray* variables, const mxArray* metadata) { // Verify that all required fieldnames are provided. internal::ValidateMxStructField(variables, "Name", mxCHAR_CLASS, true); internal::ValidateMxStructField(variables, "Type", mxCHAR_CLASS, false); internal::ValidateMxStructField(variables, "Data", mxUNKNOWN_CLASS, true); internal::ValidateMxStructField(variables, "Valid", mxLOGICAL_CLASS, true); + // Verify that all required fieldnames are provided. + internal::ValidateMxStructField(metadata, "NumRows", mxDOUBLE_CLASS, false); + internal::ValidateMxStructField(metadata, "NumVariables", mxDOUBLE_CLASS, false); + // Get the number of columns in the struct array. size_t num_columns = internal::GetNumberOfElements(variables); + // Get the NumRows field in the struct array and set on TableWriter. + num_rows_ = static_cast(mxGetScalar(mxGetField(metadata, 0, "NumRows"))); + // Get the total number of variables. This is checked later for consistency with + // the provided number of columns before finishing the file write. + num_variables_ = + static_cast(mxGetScalar(mxGetField(metadata, 0, "NumVariables"))); + // Verify that we have all the columns required for writing // Currently we need all columns to be passed in together in the WriteVariables method. - internal::ValidateNumColumns(static_cast(num_columns), this->num_variables_); + internal::ValidateNumColumns(static_cast(num_columns), num_variables_); + + arrow::SchemaBuilder schema_builder; + std::vector> table_columns; - // Allocate a packed validity bitmap for later arrow::Buffers to reference and populate. - // Since this is defined in the enclosing scope around any arrow::Buffer usage, this - // should outlive any arrow::Buffers created on this range, thus avoiding dangling - // references. - std::shared_ptr validity_bitmap; - ARROW_RETURN_NOT_OK(AllocateResizableBuffer(internal::BitPackedLength(this->num_rows_), - &validity_bitmap)); + const int64_t bitpacked_length = internal::BitPackedLength(num_rows_); // Iterate over the input columns and generate arrow arrays. for (int idx = 0; idx < num_columns; ++idx) { @@ -316,22 +328,38 @@ Status FeatherWriter::WriteVariables(const mxArray* variables) { std::string name_str = internal::MxArrayToString(name); std::string type_str = internal::MxArrayToString(type); + auto datatype = internal::ConvertMatlabTypeStringToArrowDataType(type_str); + auto field = std::make_shared(name_str, datatype); + + ARROW_ASSIGN_OR_RAISE(std::shared_ptr validity_bitmap, + arrow::AllocateResizableBuffer(internal::BitPackedLength(num_rows_))); + // Populate bit-packed arrow::Buffer using validity data in the mxArray*. internal::BitPackBuffer(valid, validity_bitmap); // Wrap mxArray data in an arrow::Array of the equivalent type. - std::unique_ptr array = + auto array = internal::WriteVariableData(data, type_str, validity_bitmap); // Verify that the arrow::Array has the right number of elements. - internal::ValidateNumRows(array->length(), this->num_rows_); + internal::ValidateNumRows(array->length(), num_rows_); - // Write another column to the Feather file. - ARROW_RETURN_NOT_OK(this->table_writer_->Append(name_str, *array)); + // Append the field to the schema builder + RETURN_NOT_OK(schema_builder.AddField(field)); + + // Store the table column + table_columns.push_back(std::move(array)); } + // Create the table schema + ARROW_ASSIGN_OR_RAISE(auto table_schema, schema_builder.Finish()); + + // Specify the feather file format version as V1 + arrow::ipc::feather::WriteProperties write_props; + write_props.version = arrow::ipc::feather::kFeatherV1Version; + std::shared_ptr table = arrow::Table::Make(table_schema, table_columns); // Write the Feather file metadata to the end of the file. - return this->table_writer_->Finalize(); + return ipc::feather::WriteTable(*table, file_output_stream_.get(), write_props); } } // namespace matlab diff --git a/matlab/src/feather_writer.h b/matlab/src/feather_writer.h index 4b402e01e17..a35b1434340 100644 --- a/matlab/src/feather_writer.h +++ b/matlab/src/feather_writer.h @@ -23,7 +23,6 @@ #include #include #include - #include namespace arrow { @@ -33,24 +32,21 @@ class FeatherWriter { public: ~FeatherWriter() = default; - /// \brief Write Feather file metadata using information from an mxArray* struct. - /// The input mxArray must be a scalar struct array with the following fields: - /// - "Description" :: Nx1 mxChar array, table-level description - /// - "NumRows" :: scalar mxDouble array, number of rows in table - /// - "NumVariables" :: scalar mxDouble array, total number of variables - /// \param[in] metadata mxArray* scalar struct containing table-level metadata - void WriteMetadata(const mxArray* metadata); - - /// \brief Write mxArrays to a Feather file. The input must be a N-by-1 mxStruct - // array with the following fields: + /// \brief Write mxArrays to a Feather file. The first input must be a N-by-1 mxStruct + /// array with the following fields: /// - "Name" :: Nx1 mxChar array, name of the column /// - "Type" :: Nx1 mxChar array, the variable's MATLAB datatype /// - "Data" :: Nx1 mxArray, data for this variable /// - "Valid" :: Nx1 mxLogical array, 0 represents invalid (null) values and /// 1 represents valid (non-null) values + /// The second input must be a scalar mxStruct with the following + /// fields: + /// - "NumRows" :: scalar mxDouble array, number of rows in table + /// - "NumVariables" :: scalar mxDouble array, total number of variables /// \param[in] variables mxArray* struct array containing table variable data + /// \param[in] metadata mxArray* scalar struct containing table-level metadata /// \return status - Status WriteVariables(const mxArray* variables); + Status WriteVariables(const mxArray* variables, const mxArray* metadata); /// \brief Initialize a FeatherWriter object that writes to a Feather file /// \param[in] filename path to the new Feather file @@ -62,12 +58,11 @@ class FeatherWriter { private: FeatherWriter() = default; - std::unique_ptr table_writer_; int64_t num_rows_; int64_t num_variables_; std::string description_; + std::shared_ptr file_output_stream_; }; } // namespace matlab } // namespace arrow - diff --git a/matlab/src/featherread.m b/matlab/src/featherread.m index 4ac8a565182..31bc426b877 100644 --- a/matlab/src/featherread.m +++ b/matlab/src/featherread.m @@ -83,8 +83,4 @@ t.Properties.VariableDescriptions = cellstr(variableDescriptions); end -% Set the Description property of the table based on the Feather file -% description. -t.Properties.Description = metadata.Description; - end diff --git a/matlab/src/featherwritemex.cc b/matlab/src/featherwritemex.cc index 3a6815e02c1..d8f90baafc5 100644 --- a/matlab/src/featherwritemex.cc +++ b/matlab/src/featherwritemex.cc @@ -32,6 +32,5 @@ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { arrow::matlab::FeatherWriter::Open(filename, &feather_writer)); // Write the Feather file table variables and table metadata from MATLAB. - feather_writer->WriteMetadata(prhs[2]); - arrow::matlab::util::HandleStatus(feather_writer->WriteVariables(prhs[1])); + arrow::matlab::util::HandleStatus(feather_writer->WriteVariables(prhs[1], prhs[2])); } diff --git a/matlab/test/tfeathermex.m b/matlab/test/tfeathermex.m index fa79b4bdef0..77070ad1421 100644 --- a/matlab/test/tfeathermex.m +++ b/matlab/test/tfeathermex.m @@ -60,7 +60,7 @@ function InvalidMATLABTableVariableNames(testCase) invalidVariable = mlarrow.util.createVariableStruct('double', 1, true, '@'); validVariable = mlarrow.util.createVariableStruct('double', 1, true, 'Valid'); variables = [invalidVariable, validVariable]; - metadata = mlarrow.util.createMetadataStruct('', 1, 2); + metadata = mlarrow.util.createMetadataStruct(1, 2); featherwritemex(filename, variables, metadata); t = featherread(filename); diff --git a/matlab/test/util/createVariablesAndMetadataStructs.m b/matlab/test/util/createVariablesAndMetadataStructs.m index 01a8f58261b..0c60cbfbbcc 100644 --- a/matlab/test/util/createVariablesAndMetadataStructs.m +++ b/matlab/test/util/createVariablesAndMetadataStructs.m @@ -90,9 +90,8 @@ singleVariable, ... doubleVariable]; -description = 'test'; numRows = 3; numVariables = length(variables); -metadata = createMetadataStruct(description, numRows, numVariables); +metadata = createMetadataStruct(numRows, numVariables); end