Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
feather.h
Go to the documentation of this file.
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 // Public API for the "Feather" file format, originally created at
19 // http://github.com/wesm/feather
20 
21 #ifndef ARROW_IPC_FEATHER_H
22 #define ARROW_IPC_FEATHER_H
23 
24 #include <cstdint>
25 #include <memory>
26 #include <string>
27 
28 #include "arrow/util/visibility.h"
29 
30 namespace arrow {
31 
32 class Array;
33 class Column;
34 class Status;
35 
36 namespace io {
37 
38 class OutputStream;
39 class RandomAccessFile;
40 
41 } // namespace io
42 
43 namespace ipc {
44 namespace feather {
45 
46 static constexpr const int kFeatherVersion = 2;
47 
48 // ----------------------------------------------------------------------
49 // Metadata accessor classes
50 
53 class ARROW_EXPORT TableReader {
54  public:
55  TableReader();
56  ~TableReader();
57 
62  static Status Open(const std::shared_ptr<io::RandomAccessFile>& source,
63  std::unique_ptr<TableReader>* out);
64 
69  std::string GetDescription() const;
70 
72  bool HasDescription() const;
73 
75  int version() const;
76 
78  int64_t num_rows() const;
79 
81  int64_t num_columns() const;
82 
83  std::string GetColumnName(int i) const;
84 
92  Status GetColumn(int i, std::shared_ptr<Column>* out);
93 
94  private:
95  class ARROW_NO_EXPORT TableReaderImpl;
96  std::unique_ptr<TableReaderImpl> impl_;
97 };
98 
101 class ARROW_EXPORT TableWriter {
102  public:
103  ~TableWriter();
104 
109  static Status Open(const std::shared_ptr<io::OutputStream>& stream,
110  std::unique_ptr<TableWriter>* out);
111 
113  void SetDescription(const std::string& desc);
114 
116  void SetNumRows(int64_t num_rows);
117 
123  Status Append(const std::string& name, const Array& values);
124 
127  Status Finalize();
128 
129  private:
130  TableWriter();
131  class ARROW_NO_EXPORT TableWriterImpl;
132  std::unique_ptr<TableWriterImpl> impl_;
133 };
134 
135 } // namespace feather
136 } // namespace ipc
137 } // namespace arrow
138 
139 #endif // ARROW_IPC_FEATHER_H
Interface for writing Feather files.
Definition: feather.h:101
#define ARROW_NO_EXPORT
Definition: visibility.h:40
Definition: status.h:106
Top-level namespace for Apache Arrow C++ API.
Definition: allocator.h:29
Array base type Immutable data array with some logical type and some length.
Definition: array.h:180
An interface for reading columns from Feather files.
Definition: feather.h:53