Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
pyarrow.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 #ifndef ARROW_PYTHON_PYARROW_H
19 #define ARROW_PYTHON_PYARROW_H
20 
21 #include "arrow/python/platform.h"
22 
23 #include <memory>
24 
25 #include "arrow/util/visibility.h"
26 
27 namespace arrow {
28 
29 class Array;
30 class Buffer;
31 class Column;
32 class DataType;
33 class Field;
34 class RecordBatch;
35 class Schema;
36 class Status;
37 class Table;
38 class Tensor;
39 
40 namespace py {
41 
42 ARROW_EXPORT int import_pyarrow();
43 
44 ARROW_EXPORT bool is_buffer(PyObject* buffer);
45 ARROW_EXPORT Status unwrap_buffer(PyObject* buffer, std::shared_ptr<Buffer>* out);
46 ARROW_EXPORT PyObject* wrap_buffer(const std::shared_ptr<Buffer>& buffer);
47 
48 ARROW_EXPORT bool is_data_type(PyObject* data_type);
49 ARROW_EXPORT Status unwrap_data_type(PyObject* data_type, std::shared_ptr<DataType>* out);
50 ARROW_EXPORT PyObject* wrap_data_type(const std::shared_ptr<DataType>& type);
51 
52 ARROW_EXPORT bool is_field(PyObject* field);
53 ARROW_EXPORT Status unwrap_field(PyObject* field, std::shared_ptr<Field>* out);
54 ARROW_EXPORT PyObject* wrap_field(const std::shared_ptr<Field>& field);
55 
56 ARROW_EXPORT bool is_schema(PyObject* schema);
57 ARROW_EXPORT Status unwrap_schema(PyObject* schema, std::shared_ptr<Schema>* out);
58 ARROW_EXPORT PyObject* wrap_schema(const std::shared_ptr<Schema>& schema);
59 
60 ARROW_EXPORT bool is_array(PyObject* array);
61 ARROW_EXPORT Status unwrap_array(PyObject* array, std::shared_ptr<Array>* out);
62 ARROW_EXPORT PyObject* wrap_array(const std::shared_ptr<Array>& array);
63 
64 ARROW_EXPORT bool is_tensor(PyObject* tensor);
65 ARROW_EXPORT Status unwrap_tensor(PyObject* tensor, std::shared_ptr<Tensor>* out);
66 ARROW_EXPORT PyObject* wrap_tensor(const std::shared_ptr<Tensor>& tensor);
67 
68 ARROW_EXPORT bool is_column(PyObject* column);
69 ARROW_EXPORT Status unwrap_column(PyObject* column, std::shared_ptr<Column>* out);
70 ARROW_EXPORT PyObject* wrap_column(const std::shared_ptr<Column>& column);
71 
72 ARROW_EXPORT bool is_table(PyObject* table);
73 ARROW_EXPORT Status unwrap_table(PyObject* table, std::shared_ptr<Table>* out);
74 ARROW_EXPORT PyObject* wrap_table(const std::shared_ptr<Table>& table);
75 
76 ARROW_EXPORT bool is_record_batch(PyObject* batch);
77 ARROW_EXPORT Status unwrap_record_batch(PyObject* batch,
78  std::shared_ptr<RecordBatch>* out);
79 ARROW_EXPORT PyObject* wrap_record_batch(const std::shared_ptr<RecordBatch>& batch);
80 
81 } // namespace py
82 } // namespace arrow
83 
84 #endif // ARROW_PYTHON_PYARROW_H
bool is_field(PyObject *field)
bool is_table(PyObject *table)
Status unwrap_array(PyObject *array, std::shared_ptr< Array > *out)
Status unwrap_schema(PyObject *schema, std::shared_ptr< Schema > *out)
PyObject * wrap_record_batch(const std::shared_ptr< RecordBatch > &batch)
PyObject * wrap_schema(const std::shared_ptr< Schema > &schema)
bool is_array(PyObject *array)
bool is_schema(PyObject *schema)
Status unwrap_field(PyObject *field, std::shared_ptr< Field > *out)
bool is_column(PyObject *column)
PyObject * wrap_column(const std::shared_ptr< Column > &column)
bool is_buffer(PyObject *buffer)
int import_pyarrow()
Status unwrap_tensor(PyObject *tensor, std::shared_ptr< Tensor > *out)
PyObject * wrap_buffer(const std::shared_ptr< Buffer > &buffer)
std::shared_ptr< Field > field(const std::string &name, const std::shared_ptr< DataType > &type, bool nullable=true, const std::shared_ptr< const KeyValueMetadata > &metadata=NULLPTR)
Create a Field instance.
PyObject * wrap_tensor(const std::shared_ptr< Tensor > &tensor)
bool is_record_batch(PyObject *batch)
Status unwrap_buffer(PyObject *buffer, std::shared_ptr< Buffer > *out)
Top-level namespace for Apache Arrow C++ API.
Definition: allocator.h:29
Status unwrap_table(PyObject *table, std::shared_ptr< Table > *out)
PyObject * wrap_array(const std::shared_ptr< Array > &array)
Status unwrap_column(PyObject *column, std::shared_ptr< Column > *out)
bool is_data_type(PyObject *data_type)
PyObject * wrap_data_type(const std::shared_ptr< DataType > &type)
std::shared_ptr< Schema > schema(const std::vector< std::shared_ptr< Field >> &fields, const std::shared_ptr< const KeyValueMetadata > &metadata=NULLPTR)
Create a Schema instance.
Status unwrap_record_batch(PyObject *batch, std::shared_ptr< RecordBatch > *out)
PyObject * wrap_table(const std::shared_ptr< Table > &table)
PyObject * wrap_field(const std::shared_ptr< Field > &field)
bool is_tensor(PyObject *tensor)
Status unwrap_data_type(PyObject *data_type, std::shared_ptr< DataType > *out)