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 ARROW_EXPORT arrow::Status InferArrowType(PyObject* obj,
43  std::shared_ptr<arrow::DataType>* out_type);
45  PyObject* obj, int64_t* size, std::shared_ptr<arrow::DataType>* out_type);
46 ARROW_EXPORT arrow::Status InferArrowSize(PyObject* obj, int64_t* size);
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 // Size inference
57 ARROW_EXPORT
58 Status ConvertPySequence(PyObject* obj, MemoryPool* pool, std::shared_ptr<Array>* out,
59  const std::shared_ptr<DataType>& type);
60 
61 // No inference
62 ARROW_EXPORT
63 Status ConvertPySequence(PyObject* obj, MemoryPool* pool, std::shared_ptr<Array>* out,
64  const std::shared_ptr<DataType>& type, int64_t size);
65 
66 ARROW_EXPORT
67 Status InvalidConversion(PyObject* obj, const std::string& expected_type_name,
68  std::ostream* out);
69 
70 ARROW_EXPORT Status CheckPythonBytesAreFixedLength(PyObject* obj,
71  Py_ssize_t expected_length);
72 
73 } // namespace py
74 } // namespace arrow
75 
76 #endif // ARROW_PYTHON_ADAPTERS_BUILTIN_H
arrow::Status InferArrowSize(PyObject *obj, int64_t *size)
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:57
Definition: status.h:106
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: allocator.h:29
Status CheckPythonBytesAreFixedLength(PyObject *obj, Py_ssize_t expected_length)