Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
builtin_convert.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 // Functions for converting between CPython built-in data structures and Arrow
19 // data structures
20 
21 #ifndef ARROW_PYTHON_ADAPTERS_BUILTIN_H
22 #define ARROW_PYTHON_ADAPTERS_BUILTIN_H
23 
24 #include "arrow/python/platform.h"
25 
26 #include <memory>
27 #include <ostream>
28 #include <string>
29 
30 #include "arrow/type.h"
31 #include "arrow/util/visibility.h"
32 
33 #include "arrow/python/common.h"
34 
35 namespace arrow {
36 
37 class Array;
38 class Status;
39 
40 namespace py {
41 
42 // These three functions take a sequence input, not arbitrary iterables
43 ARROW_EXPORT arrow::Status InferArrowType(PyObject* obj,
44  std::shared_ptr<arrow::DataType>* out_type);
46  PyObject* obj, int64_t* size, std::shared_ptr<arrow::DataType>* out_type);
47 
48 ARROW_EXPORT arrow::Status AppendPySequence(PyObject* obj, int64_t size,
49  const std::shared_ptr<arrow::DataType>& type,
50  arrow::ArrayBuilder* builder,
51  bool from_pandas);
52 
53 // Type and size inference
54 ARROW_EXPORT
55 Status ConvertPySequence(PyObject* obj, MemoryPool* pool, bool from_pandas,
56  std::shared_ptr<Array>* out);
57 
58 // Type inference only
59 ARROW_EXPORT
60 Status ConvertPySequence(PyObject* obj, int64_t size, MemoryPool* pool, bool from_pandas,
61  std::shared_ptr<Array>* out);
62 
63 // Size inference only
64 ARROW_EXPORT
65 Status ConvertPySequence(PyObject* obj, const std::shared_ptr<DataType>& type,
66  MemoryPool* pool, bool from_pandas, std::shared_ptr<Array>* out);
67 
68 // No inference
69 ARROW_EXPORT
70 Status ConvertPySequence(PyObject* obj, int64_t size,
71  const std::shared_ptr<DataType>& type, MemoryPool* pool,
72  bool from_pandas, std::shared_ptr<Array>* out);
73 
74 ARROW_EXPORT
75 Status InvalidConversion(PyObject* obj, const std::string& expected_type_name,
76  std::ostream* out);
77 
78 } // namespace py
79 } // namespace arrow
80 
81 #endif // ARROW_PYTHON_ADAPTERS_BUILTIN_H
arrow::Status InferArrowTypeAndSize(PyObject *obj, int64_t *size, std::shared_ptr< arrow::DataType > *out_type)
Status InvalidConversion(PyObject *obj, const std::string &expected_type_name, std::ostream *out)
arrow::Status InferArrowType(PyObject *obj, std::shared_ptr< arrow::DataType > *out_type)
Base class for all data array builders.
Definition: builder.h:61
Definition: status.h:94
_object PyObject
Definition: python_to_arrow.h:30
Top-level namespace for Apache Arrow C++ API.
Definition: adapter.h:32
Status ConvertPySequence(PyObject *obj, MemoryPool *pool, bool from_pandas, std::shared_ptr< Array > *out)
arrow::Status AppendPySequence(PyObject *obj, int64_t size, const std::shared_ptr< arrow::DataType > &type, arrow::ArrayBuilder *builder, bool from_pandas)