]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/matlab/src/feather_writer.h
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / matlab / src / feather_writer.h
CommitLineData
1d09f67e
TL
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#pragma once
19
20#include <memory>
21#include <string>
22
23#include <arrow/ipc/feather.h>
24#include <arrow/status.h>
25#include <arrow/type.h>
26#include <matrix.h>
27
28namespace arrow {
29namespace matlab {
30
31class FeatherWriter {
32 public:
33 ~FeatherWriter() = default;
34
35 /// \brief Write mxArrays to a Feather file. The first input must be a N-by-1 mxStruct
36 /// array with the following fields:
37 /// - "Name" :: Nx1 mxChar array, name of the column
38 /// - "Type" :: Nx1 mxChar array, the variable's MATLAB datatype
39 /// - "Data" :: Nx1 mxArray, data for this variable
40 /// - "Valid" :: Nx1 mxLogical array, 0 represents invalid (null) values and
41 /// 1 represents valid (non-null) values
42 /// The second input must be a scalar mxStruct with the following
43 /// fields:
44 /// - "NumRows" :: scalar mxDouble array, number of rows in table
45 /// - "NumVariables" :: scalar mxDouble array, total number of variables
46 /// \param[in] variables mxArray* struct array containing table variable data
47 /// \param[in] metadata mxArray* scalar struct containing table-level metadata
48 /// \return status
49 Status WriteVariables(const mxArray* variables, const mxArray* metadata);
50
51 /// \brief Initialize a FeatherWriter object that writes to a Feather file
52 /// \param[in] filename path to the new Feather file
53 /// \param[out] feather_writer uninitialized FeatherWriter object
54 /// \return status
55 static Status Open(const std::string& filename,
56 std::shared_ptr<FeatherWriter>* feather_writer);
57
58 private:
59 FeatherWriter() = default;
60
61 int64_t num_rows_;
62 int64_t num_variables_;
63 std::string description_;
64 std::shared_ptr<arrow::io::OutputStream> file_output_stream_;
65};
66
67} // namespace matlab
68} // namespace arrow