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 
52 // Type and size inference
53 ARROW_EXPORT
54 Status ConvertPySequence(PyObject* obj, MemoryPool* pool, std::shared_ptr<Array>* out);
55 
56 // Type inference only
57 ARROW_EXPORT
58 Status ConvertPySequence(PyObject* obj, int64_t size, MemoryPool* pool,
59  std::shared_ptr<Array>* out);
60 
61 // Size inference only
62 ARROW_EXPORT
63 Status ConvertPySequence(PyObject* obj, const std::shared_ptr<DataType>& type,
64  MemoryPool* pool, std::shared_ptr<Array>* out);
65 
66 // No inference
67 ARROW_EXPORT
68 Status ConvertPySequence(PyObject* obj, int64_t size,
69  const std::shared_ptr<DataType>& type, MemoryPool* pool,
70  std::shared_ptr<Array>* out);
71 
72 ARROW_EXPORT
73 Status InvalidConversion(PyObject* obj, const std::string& expected_type_name,
74  std::ostream* out);
75 
76 } // namespace py
77 } // namespace arrow
78 
79 #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:60
Definition: status.h:93
arrow::Status AppendPySequence(PyObject *obj, int64_t size, const std::shared_ptr< arrow::DataType > &type, arrow::ArrayBuilder *builder)
Status ConvertPySequence(PyObject *obj, MemoryPool *pool, std::shared_ptr< Array > *out)
Top-level namespace for Apache Arrow C++ API.
Definition: adapter.h:32