jasonfan commited on
Commit
a4b46fe
·
verified ·
1 Parent(s): 69c353a

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/INSTALLER +1 -0
  2. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/METADATA +79 -0
  3. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/RECORD +856 -0
  4. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/WHEEL +5 -0
  5. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/licenses/LICENSE.txt +0 -0
  6. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/licenses/NOTICE.txt +81 -0
  7. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/top_level.txt +2 -0
  8. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_acero.pxd +118 -0
  9. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_cuda.pxd +109 -0
  10. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_dataset.pxd +423 -0
  11. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_dataset_parquet.pxd +107 -0
  12. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_feather.pxd +50 -0
  13. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_flight.pxd +621 -0
  14. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_fs.pxd +364 -0
  15. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_python.pxd +296 -0
  16. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_substrait.pxd +100 -0
  17. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libgandiva.pxd +298 -0
  18. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libparquet.pxd +634 -0
  19. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libparquet_encryption.pxd +187 -0
  20. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/__init__.py +20 -0
  21. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/buffer.py +107 -0
  22. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/column.py +529 -0
  23. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/dataframe.py +217 -0
  24. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/from_dataframe.py +614 -0
  25. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/parquet/__init__.py +20 -0
  26. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/parquet/core.py +2454 -0
  27. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/parquet/encryption.py +23 -0
  28. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/CMakeLists.txt +19 -0
  29. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/api.h +29 -0
  30. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/arrow_to_pandas.cc +2659 -0
  31. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/arrow_to_pandas.h +165 -0
  32. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/arrow_to_python_internal.h +49 -0
  33. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/async.h +60 -0
  34. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/benchmark.cc +38 -0
  35. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/benchmark.h +36 -0
  36. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/common.cc +246 -0
  37. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/common.h +457 -0
  38. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/config.cc +35 -0
  39. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/config.h +38 -0
  40. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/config_internal.h.cmake +18 -0
  41. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/csv.cc +62 -0
  42. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/csv.h +42 -0
  43. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/datetime.cc +665 -0
  44. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/datetime.h +231 -0
  45. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/decimal.cc +265 -0
  46. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/decimal.h +162 -0
  47. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/extension_type.cc +221 -0
  48. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/extension_type.h +85 -0
  49. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/filesystem.cc +206 -0
  50. miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/filesystem.h +130 -0
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/METADATA ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: pyarrow
3
+ Version: 23.0.1
4
+ Summary: Python library for Apache Arrow
5
+ Maintainer-email: Apache Arrow Developers <dev@arrow.apache.org>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://arrow.apache.org/
8
+ Project-URL: Documentation, https://arrow.apache.org/docs/python
9
+ Project-URL: Repository, https://github.com/apache/arrow
10
+ Project-URL: Issues, https://github.com/apache/arrow/issues
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE.txt
20
+ License-File: NOTICE.txt
21
+ Dynamic: license-file
22
+
23
+ <!---
24
+ Licensed to the Apache Software Foundation (ASF) under one
25
+ or more contributor license agreements. See the NOTICE file
26
+ distributed with this work for additional information
27
+ regarding copyright ownership. The ASF licenses this file
28
+ to you under the Apache License, Version 2.0 (the
29
+ "License"); you may not use this file except in compliance
30
+ with the License. You may obtain a copy of the License at
31
+
32
+ http://www.apache.org/licenses/LICENSE-2.0
33
+
34
+ Unless required by applicable law or agreed to in writing,
35
+ software distributed under the License is distributed on an
36
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
37
+ KIND, either express or implied. See the License for the
38
+ specific language governing permissions and limitations
39
+ under the License.
40
+ -->
41
+
42
+ ## Python library for Apache Arrow
43
+
44
+ [![pypi](https://img.shields.io/pypi/v/pyarrow.svg)](https://pypi.org/project/pyarrow/) [![conda-forge](https://anaconda.org/conda-forge/pyarrow/badges/version.svg)](https://anaconda.org/conda-forge/pyarrow)
45
+
46
+ This library provides a Python API for functionality provided by the Arrow C++
47
+ libraries, along with tools for Arrow integration and interoperability with
48
+ pandas, NumPy, and other software in the Python ecosystem.
49
+
50
+ ## Installing
51
+
52
+ Across platforms, you can install a recent version of pyarrow with the conda
53
+ package manager:
54
+
55
+ ```shell
56
+ conda install pyarrow -c conda-forge
57
+ ```
58
+
59
+ On Linux, macOS, and Windows, you can also install binary wheels from PyPI with
60
+ pip:
61
+
62
+ ```shell
63
+ pip install pyarrow
64
+ ```
65
+
66
+ If you encounter any issues importing the pip wheels on Windows, you may need
67
+ to install the latest [Visual C++ Redistributable for Visual Studio][3].
68
+
69
+ ## Development
70
+
71
+ See [Python Development][2] in the documentation subproject.
72
+
73
+ ### Building the documentation
74
+
75
+ See [documentation build instructions][1] in the documentation subproject.
76
+
77
+ [1]: https://github.com/apache/arrow/blob/main/docs/source/developers/documentation.rst
78
+ [2]: https://arrow.apache.org/docs/developers/python/index.html
79
+ [3]: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/RECORD ADDED
@@ -0,0 +1,856 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pyarrow-23.0.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ pyarrow-23.0.1.dist-info/METADATA,sha256=85PGLmy5cV6C3G58pQNpUXRyFyv2jhWE4pSUlJas290,3053
3
+ pyarrow-23.0.1.dist-info/RECORD,,
4
+ pyarrow-23.0.1.dist-info/WHEEL,sha256=yzF9ixp0XVYLhnovZSdud9vspTPdVe52BzwI7Tv3jTM,113
5
+ pyarrow-23.0.1.dist-info/licenses/LICENSE.txt,sha256=I_xF3OF2nZ3fSqxNbNrz9_DRT8xNkw3Q1K---i6jMio,113501
6
+ pyarrow-23.0.1.dist-info/licenses/NOTICE.txt,sha256=r9iV1hoAEB9tWkHPUYyDhl2BXoEJ6Vb1EqDOTqlzjAY,2916
7
+ pyarrow-23.0.1.dist-info/top_level.txt,sha256=Zuk_c1WeinXdMz20fXlEtGC67zfKOWuwU8adpEEU_nI,18
8
+ pyarrow/__init__.pxd,sha256=Wnar1phFqM_ZHnZmtbuqm6wJHsXlBoYKhV7Qmo2jUHA,2195
9
+ pyarrow/__init__.py,sha256=k2XINbsRZlOTmT0dYr7otJbKtGUJM5kFYKNYDk1f-30,18592
10
+ pyarrow/__pycache__/__init__.cpython-310.pyc,,
11
+ pyarrow/__pycache__/_compute_docstrings.cpython-310.pyc,,
12
+ pyarrow/__pycache__/_generated_version.cpython-310.pyc,,
13
+ pyarrow/__pycache__/acero.cpython-310.pyc,,
14
+ pyarrow/__pycache__/benchmark.cpython-310.pyc,,
15
+ pyarrow/__pycache__/cffi.cpython-310.pyc,,
16
+ pyarrow/__pycache__/compute.cpython-310.pyc,,
17
+ pyarrow/__pycache__/conftest.cpython-310.pyc,,
18
+ pyarrow/__pycache__/csv.cpython-310.pyc,,
19
+ pyarrow/__pycache__/cuda.cpython-310.pyc,,
20
+ pyarrow/__pycache__/dataset.cpython-310.pyc,,
21
+ pyarrow/__pycache__/feather.cpython-310.pyc,,
22
+ pyarrow/__pycache__/flight.cpython-310.pyc,,
23
+ pyarrow/__pycache__/fs.cpython-310.pyc,,
24
+ pyarrow/__pycache__/ipc.cpython-310.pyc,,
25
+ pyarrow/__pycache__/json.cpython-310.pyc,,
26
+ pyarrow/__pycache__/jvm.cpython-310.pyc,,
27
+ pyarrow/__pycache__/orc.cpython-310.pyc,,
28
+ pyarrow/__pycache__/pandas_compat.cpython-310.pyc,,
29
+ pyarrow/__pycache__/substrait.cpython-310.pyc,,
30
+ pyarrow/__pycache__/types.cpython-310.pyc,,
31
+ pyarrow/__pycache__/util.cpython-310.pyc,,
32
+ pyarrow/_acero.cpython-310-x86_64-linux-gnu.so,sha256=xdMgalbyoZVu-x1MFgBO3yv1OqACASvzaJ9AyxQKd3o,282872
33
+ pyarrow/_acero.pxd,sha256=5ish_GgGWvit4ebhzoZil7b-m0r2RuG5JwYoxsH34FI,1440
34
+ pyarrow/_acero.pyx,sha256=7Qo0ePiMF2tsytAj4t334f-32KA9XdJKU6LKye87usw,21586
35
+ pyarrow/_azurefs.cpython-310-x86_64-linux-gnu.so,sha256=V4kMp1cWfTunMtDnAGS2kmEBxOLGfBvZyQKYPU5-P1g,144928
36
+ pyarrow/_azurefs.pyx,sha256=mlieD3Ze2LeiQFAaq4ykjLAW7jCUiEtK_brgX5dvGCo,9148
37
+ pyarrow/_compute.cpython-310-x86_64-linux-gnu.so,sha256=RwQ03PEi4xv0GHgECquSs2VWf0UJTWii-QVI2jYA9kU,1288712
38
+ pyarrow/_compute.pxd,sha256=fhi87jkN6x4qG8JbAtRksx-4YTn3sFIw2zZxuK1flpM,2022
39
+ pyarrow/_compute.pyx,sha256=27FWJcYyU2xY6tKhWljYQlzIz5o0TJyPlJfM1LQq8vk,114180
40
+ pyarrow/_compute_docstrings.py,sha256=7_S5bqdASMSrndaEKSbr--ofVW4sbhT2iM24bGvvOYw,4936
41
+ pyarrow/_csv.cpython-310-x86_64-linux-gnu.so,sha256=dejRTRhDCRpqGVLvtMA7CICV0q3h6m23-BBXAfMG5CQ,353720
42
+ pyarrow/_csv.pxd,sha256=1Zk3Zpvvhy-Tb7c79Aqd4e7bBM21kc1JxWJkl02Y4DE,1638
43
+ pyarrow/_csv.pyx,sha256=MQ_b87VV18O9MifhdUm7TbBIdmnwhARfG4unidu1EYg,55449
44
+ pyarrow/_cuda.pxd,sha256=VzhM6j9dpNgrABlvFJKoMpRC0As55im-M3tgPTOuwEk,1922
45
+ pyarrow/_cuda.pyx,sha256=XPM0q9Cy-I0bcB5j9dpSkLfkxYvdfLv2UTJym9YAM8Q,35328
46
+ pyarrow/_dataset.cpython-310-x86_64-linux-gnu.so,sha256=_zArNF_dalTnUejSNjf5IXblJbLpiiFa9_rimL8sQSU,1007192
47
+ pyarrow/_dataset.pxd,sha256=Ag9rUhoBySU6ba3wFLeuZyWMJnz9VkAf9TQEzWG4hUU,4944
48
+ pyarrow/_dataset.pyx,sha256=tW56kG-2kD3jTTxwXjDGwfJ9wxpPhL7fWtsxnMBzueA,164256
49
+ pyarrow/_dataset_orc.cpython-310-x86_64-linux-gnu.so,sha256=BbBTJoGXShi4fPgdfKWIRpNwAF0ls77QnAEx1oB9Jdg,79544
50
+ pyarrow/_dataset_orc.pyx,sha256=JSFoRI0pfHtL2jeIuPg5TJHodcfuCNYmj_iEZ4xY87w,1499
51
+ pyarrow/_dataset_parquet.cpython-310-x86_64-linux-gnu.so,sha256=ACOpBFx6-88rqMwj-LS0kqwyIEv5w2fRjZo7W22ALig,354880
52
+ pyarrow/_dataset_parquet.pxd,sha256=y-3iKehyB_eB_oeqjtt4aQRbUpVGVN1oUMFGIY13brE,1572
53
+ pyarrow/_dataset_parquet.pyx,sha256=wdcEST6sLbbfKTrqjJpZEXpSZK0RA0h9sxkgsscNuHo,41608
54
+ pyarrow/_dataset_parquet_encryption.cpython-310-x86_64-linux-gnu.so,sha256=q3xqb-FoinZPpI-OGOXrufFQ8Z6N8Jh31SZG5UGLwkY,120336
55
+ pyarrow/_dataset_parquet_encryption.pyx,sha256=p7LDNUsp3jMVcWDcbOFp8a3CYJjASVPI_tfATpY-ePg,7229
56
+ pyarrow/_dlpack.pxi,sha256=clw0FkGoyZMEtUU8zPpO_DMtl2X-27kb2UtyhQuIc1s,1832
57
+ pyarrow/_feather.cpython-310-x86_64-linux-gnu.so,sha256=W0UcIxSe3qMd3PVicOI0lLq_fJE3xGDX9QUzzZOKg8M,108600
58
+ pyarrow/_feather.pyx,sha256=DWQI4U0uAWE1ZYUwPreBPJg1TGLEGmF3wPEIRL-PhPw,3773
59
+ pyarrow/_flight.cpython-310-x86_64-linux-gnu.so,sha256=Cjv2ENTUnUVS3t2ScK4IXFZ33G7OwS3dx0rvRrThAyI,1210952
60
+ pyarrow/_flight.pyx,sha256=DjaT1iEGJyX543tYv5MpgZ4rEGUhkAhQ9-exrgbjcnQ,114770
61
+ pyarrow/_fs.cpython-310-x86_64-linux-gnu.so,sha256=cWez-p27EbxkFyILN_RknjW7vI9BRGMe-i3takFqFc8,433528
62
+ pyarrow/_fs.pxd,sha256=SmHS31eyYU7VUZlVuP613HKgpd7bENnQGApvX_g2Lfw,2439
63
+ pyarrow/_fs.pyx,sha256=kLqIoSXeovlPrWe8EShzzPC3z3EgSCaeq8cSNH_ZWm4,53271
64
+ pyarrow/_gcsfs.cpython-310-x86_64-linux-gnu.so,sha256=Tb5ptGO9pXrPCOC2oP20X-ahAHUKJP2o1IpIz7dVwGo,136080
65
+ pyarrow/_gcsfs.pyx,sha256=sooI3ztzEQXVVKcahgin0UGm_6Sgy-uwfcMrACP690w,9046
66
+ pyarrow/_generated_version.py,sha256=0Mp6jhnPtGCgtUSwlvLLlUXsE-uaoh2ar69PMiRCvNA,706
67
+ pyarrow/_hdfs.cpython-310-x86_64-linux-gnu.so,sha256=nnbYNQ6FfroBvNNQ0mcwDw-STxUsD0hvIb-0YXirBxo,138128
68
+ pyarrow/_hdfs.pyx,sha256=QVkMqzz2iGoipaNufk0GPZRzjy1JKJzuuqqk88MdYA4,5802
69
+ pyarrow/_json.cpython-310-x86_64-linux-gnu.so,sha256=6am50l5d844DLPI-4BLemO9Qw8pUEfRICp8JQnrpAVI,128720
70
+ pyarrow/_json.pxd,sha256=tECTP14M12-b_ja5QI3snQbd0uWPWmmC9FwkWq23Vg0,1206
71
+ pyarrow/_json.pyx,sha256=VCdkaxuO0Q0SzAp7zxqoG2e5GImXp1ZERYMM6jG_5EI,12532
72
+ pyarrow/_orc.cpython-310-x86_64-linux-gnu.so,sha256=G-RXK0gONsEsDzyIF9JqcM27hja5crk_EBN-4BvzbGI,213848
73
+ pyarrow/_orc.pxd,sha256=6hL0cq1RufqQD-B_bV3ne1rhu2g-h4rDOFNQsSb6qps,5689
74
+ pyarrow/_orc.pyx,sha256=Pn7r4dzagWaqMf8rymbXBIWisxonBaStZgXCi7pfrZI,15556
75
+ pyarrow/_parquet.cpython-310-x86_64-linux-gnu.so,sha256=jnPQZzt4QHwJv27kYof4IsUd_jknw9i0Sg4CBZLN0H8,612480
76
+ pyarrow/_parquet.pxd,sha256=pCqIo5UzwVmo2qe6Uo4zQwnRp8nRBjA8NJNxhhompQI,4947
77
+ pyarrow/_parquet.pyx,sha256=q0OcpBOR4WzcQqKxb3u-MiLxvBLcPK6h_eOSJUVOosg,80049
78
+ pyarrow/_parquet_encryption.cpython-310-x86_64-linux-gnu.so,sha256=ViAN_4O7WBsHjuaGVpmecgqJFvUeqG5S6nEjdTrBSf0,342392
79
+ pyarrow/_parquet_encryption.pxd,sha256=WUPm2Kj50f06y5IYzb9lVF64XREzqIZwqJSWPs-1VSE,2871
80
+ pyarrow/_parquet_encryption.pyx,sha256=Am9cy5u732B5KmcNLVb_ARy6cxiq2MIXUut6JU3e6X8,26983
81
+ pyarrow/_pyarrow_cpp_tests.cpython-310-x86_64-linux-gnu.so,sha256=iPoGRnYBNqqmoSN3ocnV7DhjiFYqWXtgVQECbKVZ3vA,88160
82
+ pyarrow/_pyarrow_cpp_tests.pxd,sha256=nPyRmNtFbOUvSXCwegAApQFfh8UI_K9Hq5dN4oPAxdo,1199
83
+ pyarrow/_pyarrow_cpp_tests.pyx,sha256=gLeMzB9RWodZgXEpipX65_0aqWu12SjMld0JZmZVRP0,1753
84
+ pyarrow/_s3fs.cpython-310-x86_64-linux-gnu.so,sha256=dE0bV0GML01TUd4_w6ZUtsnAbM106xaie4CLgi5rNMo,228512
85
+ pyarrow/_s3fs.pyx,sha256=I5MF6knp3tYnS0VlWK0enMavJ9r54RcjgHJMoi2t6EQ,20584
86
+ pyarrow/_substrait.cpython-310-x86_64-linux-gnu.so,sha256=WFwJGuH5OCjbZHRwMmo3nyu_aeny3HF-C_UFfAwm8HE,205216
87
+ pyarrow/_substrait.pyx,sha256=fZT496mzp1ssSKIzqtmPeGBKeYq5f0vm8cWlWqaC408,15666
88
+ pyarrow/acero.py,sha256=yus6kVAtfYVoSenfPZPHgmeEmnaySb5UCM1lVMkzF1M,15743
89
+ pyarrow/array.pxi,sha256=RqssOhLS8qkLpny_KpE98KTPNIF-QJ23p0dGPxYCPwo,159297
90
+ pyarrow/benchmark.pxi,sha256=DYXdu-jMSH7XcTohbc8x8NiKRLtpX9IULfY20ohkffA,869
91
+ pyarrow/benchmark.py,sha256=k9Z3yQyoojpYz4lTA6DkCfqT6fPG3N2fJtsHKjpbYFo,856
92
+ pyarrow/builder.pxi,sha256=9QE4KAiA4JpA7-2JLgX3xo32jRtuWZ3YqC-T9GzUVDc,4634
93
+ pyarrow/cffi.py,sha256=hEcrPH9KeG6NES3ZCpSbOVYhOgDOuBB_2LgMMucgw-8,2396
94
+ pyarrow/compat.pxi,sha256=Sq5c3CKq0uj5aDyOoHHkPEO_VsSpZ90JRaL2rAKHk5I,1920
95
+ pyarrow/compute.py,sha256=EweboAC1SgLDPyrY7zgMV6YThGp2pqhqT-C-w7QxhwQ,24379
96
+ pyarrow/config.pxi,sha256=59eukT2QdWZSHuOMJhXEUsXGqVcN9g68ZFPZXCMb-dw,3926
97
+ pyarrow/conftest.py,sha256=54Oim0WylDduwtVx7l7fTKSQsJyPUbP_duPSYicHXs8,9891
98
+ pyarrow/csv.py,sha256=S6tm31Bra9HPf9IsYwBLltZBLMvNzypWfeCLySsjmds,974
99
+ pyarrow/cuda.py,sha256=j--8HcBAm5Ib-kbhK4d2M6SVQmDWkr7Mt5fnwU2LzdQ,1087
100
+ pyarrow/dataset.py,sha256=S3g4O9G9IhjWByr7tZ5q8HwMC35InoBmgKsiX2aGCYc,40507
101
+ pyarrow/device.pxi,sha256=kx9WnmI2bAKgt9txyGVQWackkRj9NPZLsE5q5H1RFgU,5563
102
+ pyarrow/error.pxi,sha256=Wj7-NGUfdvlEwAwd8Ta_JqRC8IUOUpm_PmpvizCFvfY,8909
103
+ pyarrow/feather.py,sha256=fOJRqGWBWrVchVSwruTcbNqN_KHDpueQ4xdoaTaEVm8,9943
104
+ pyarrow/flight.py,sha256=HLB04A0SZ35MZJumPIuBu5I2dpetjEc-CGMEdjQeQRQ,2177
105
+ pyarrow/fs.py,sha256=qL7lXu2QSbD3JbOwJEQwf642Y5Nne56tpW5nQ8O9t5A,14972
106
+ pyarrow/gandiva.pyx,sha256=sNXorsDoKVbr7iI7fwXmQZxorZA77WyCRiJtSdF_Ev8,24280
107
+ pyarrow/include/arrow/acero/accumulation_queue.h,sha256=fz0okH6sZqcSpBl2w3vOU9wSa9QlOIAXzikmb3mINPE,5985
108
+ pyarrow/include/arrow/acero/aggregate_node.h,sha256=9fhmBQGUphsqLd7bNmiOJaEg5NJxVyWA5RGs9UaTxR0,2201
109
+ pyarrow/include/arrow/acero/api.h,sha256=fRuKEHbKDYWRCwSHLc7vSD-6mQavyOsztluCR7evFCk,1151
110
+ pyarrow/include/arrow/acero/asof_join_node.h,sha256=Ko6r1wDjxg01FE9-xKkttx7WzCAzf43GxbpvGHgKZp8,1490
111
+ pyarrow/include/arrow/acero/backpressure_handler.h,sha256=mbJYVYeFMQlg40j_k7f0jFXZ8kRjo5lrE2dndC54Z7s,2395
112
+ pyarrow/include/arrow/acero/benchmark_util.h,sha256=T5bNabF1TDAp28S7V_vt_VIDn6l5Be0zOVCHhcTcFf8,1943
113
+ pyarrow/include/arrow/acero/bloom_filter.h,sha256=bFzzAzQrs9ePp2tCPQIuk1Oa9gG_Nyp72M_HM0dhakM,11978
114
+ pyarrow/include/arrow/acero/exec_plan.h,sha256=U0KA3tnNvVb75G0XQFLVbGzXCGdddGyRhW3zMa8oWJc,35909
115
+ pyarrow/include/arrow/acero/hash_join.h,sha256=zjljUjH2AQlI54Vz2_7hvJIAjTgaT0BPC_LVD7xNd2k,3022
116
+ pyarrow/include/arrow/acero/hash_join_dict.h,sha256=_BKJmK3Z_KdJuYHh4KQCuT_1rXlUohrtEgGLtEJ4fgQ,15360
117
+ pyarrow/include/arrow/acero/hash_join_node.h,sha256=FXT-aeXL7nNTuV75f9oXgdGyqMK_72GnqGUm9cmBnko,4378
118
+ pyarrow/include/arrow/acero/map_node.h,sha256=Bd1HcW0N5azoIVth2ATeHxgTKd9XmmEkz42YBNw5eK0,2628
119
+ pyarrow/include/arrow/acero/options.h,sha256=sLrKayGLs0MVJKcopQrO3pAOrqmvd1j3EfloUCMKECI,37654
120
+ pyarrow/include/arrow/acero/order_by_impl.h,sha256=dQqplP-AZWPZRKio8LmTjYWlCYz9VmW-usUrtaLpd_w,1691
121
+ pyarrow/include/arrow/acero/partition_util.h,sha256=xS8hayuTRimyrOHzf1xRm1IVjkyIeVCGXY78B2rJaJc,7437
122
+ pyarrow/include/arrow/acero/query_context.h,sha256=D364aGRS3uWe8lgYqCNRjVvs5sKetLOOXzACdp5GZeg,6212
123
+ pyarrow/include/arrow/acero/schema_util.h,sha256=KA_hV2xy2TRccMyksSzQrdH9_rdGo3tQyHOIvrWWYBQ,7961
124
+ pyarrow/include/arrow/acero/task_util.h,sha256=6pqILuYfcVwt9HqVhRfXFVJoOC-Q_dtk8mQ5SxjgwbY,3706
125
+ pyarrow/include/arrow/acero/test_nodes.h,sha256=xKeLWZZC8iokveVXPjseO1MOvWMcby-0xiMISy0qw8E,2877
126
+ pyarrow/include/arrow/acero/time_series_util.h,sha256=W9yzoaTGkB2jtYm8w2CYknSw1EjMbsdTfmEuuL2zMtk,1210
127
+ pyarrow/include/arrow/acero/tpch_node.h,sha256=l3zocxHTfGmXTjywJxwoXCIk9tjzURgWdYKSgSk8DAQ,2671
128
+ pyarrow/include/arrow/acero/type_fwd.h,sha256=4zLhtLJf_7MSXgrhQIZVGeLxjT7JrEDAn9yW75DTFlc,1103
129
+ pyarrow/include/arrow/acero/util.h,sha256=byhMEj5XoAUy-93AjLrx_p9_iUZdYn5uJ_cDkCJQt5Q,6121
130
+ pyarrow/include/arrow/acero/visibility.h,sha256=E-4G2O4F2YabXnFNJYnsI2VbVoKBtO7AXqh_SPuJi6k,1616
131
+ pyarrow/include/arrow/adapters/orc/adapter.h,sha256=G5SSGGYMSREILC43kqL5fqo94c4tKgukitO15m217tY,11031
132
+ pyarrow/include/arrow/adapters/orc/options.h,sha256=FMxda5YSskRrB6h9FvcAuMxl5qdavWrNYHPlanjtk48,3696
133
+ pyarrow/include/arrow/adapters/tensorflow/convert.h,sha256=ZGFAodnwTJK0ZoXfgYJdjgi_F4vfEhI9E87zejxVb6E,3465
134
+ pyarrow/include/arrow/api.h,sha256=Gs6HiRBYU5N7-a79hjTl9WMSda551XdUKpWthFY2v1s,2491
135
+ pyarrow/include/arrow/array.h,sha256=P5oW6hvD2j97bLaSTE4_UHuV6Y38DTwJVww3Eb3xdTQ,1981
136
+ pyarrow/include/arrow/array/array_base.h,sha256=kq08hubpDlrIVgDRhL4MEqPyaEftgmoznQ91ZVrLnAQ,12371
137
+ pyarrow/include/arrow/array/array_binary.h,sha256=JvtB8DoR0_tqfSFS_9nMRrJ39lt1cTm5yXh-DLkhqjU,11247
138
+ pyarrow/include/arrow/array/array_decimal.h,sha256=xRfrZ1IFO09EmkHEolCwrJ4lsXjLo5DXdfH5_v2gSyw,3105
139
+ pyarrow/include/arrow/array/array_dict.h,sha256=6AMbSnZoMj-nhQhZhG4RNnxy9VVPk2DvZjVblwIUhgY,7611
140
+ pyarrow/include/arrow/array/array_nested.h,sha256=MRFllX_LO6AQXNkyAujEdax2gEYrnQALySwB9tuP85U,37717
141
+ pyarrow/include/arrow/array/array_primitive.h,sha256=_U8_pTHg-aHY5jaSFjHZ4hqRPXdYiyKTpr2y3OcJcdg,8184
142
+ pyarrow/include/arrow/array/array_run_end.h,sha256=4zs3tcUrIgDOhSEOywJ1vGY2lsH-5QuEBn87mxnDbi8,5101
143
+ pyarrow/include/arrow/array/builder_adaptive.h,sha256=92DpiIZDXSI_yOrMftj7P60zlCLjNmwfGM5ubdbXWM4,6861
144
+ pyarrow/include/arrow/array/builder_base.h,sha256=CP9kS8pDFd4XyJQdgIlBp3pTIX9mND1Lvh85re4IC8w,13723
145
+ pyarrow/include/arrow/array/builder_binary.h,sha256=cfrm-LnXOZ73pQpn_kXSXw0Bh252DpsfP4KGHlPNy3g,33744
146
+ pyarrow/include/arrow/array/builder_decimal.h,sha256=DFxyFlpzWRZS9zdBhsjII5fFUOMY9bXHn3EIrIvmOMo,5051
147
+ pyarrow/include/arrow/array/builder_dict.h,sha256=FZjvCRIDmVuwmzx_HCcDK6ZjNoZKCEsSV-fGI0K974Y,27899
148
+ pyarrow/include/arrow/array/builder_nested.h,sha256=_VB9EUamHQcxQtJM0FiSy8Rs4vhzpOuqFMRfKa4qE5U,31231
149
+ pyarrow/include/arrow/array/builder_primitive.h,sha256=WX_3Y-FeCvTtoE2kHJ9L2cew_IN5W4uyQFfjsJ2lMLk,26031
150
+ pyarrow/include/arrow/array/builder_run_end.h,sha256=SZIdsUKK1qAc9pdonPGf0A_aikZHcxxzicezRGR5hLs,11416
151
+ pyarrow/include/arrow/array/builder_time.h,sha256=eLhc7UP9ttNJDbTeDdsf-ihMFORksmh7A0ScA5hLROI,2503
152
+ pyarrow/include/arrow/array/builder_union.h,sha256=8BF532sAMc7JxWIbSN-yX6Z9fqY9jmmsIa054DPvbWE,10144
153
+ pyarrow/include/arrow/array/concatenate.h,sha256=wBy-CBTz9MeRCmcnfXGvkXnvSRApvPOcfCf64A42ys8,2059
154
+ pyarrow/include/arrow/array/data.h,sha256=65s-2w9lskJAzQYio59NBAa9TH78JU95mcTX3_XRCoc,28949
155
+ pyarrow/include/arrow/array/diff.h,sha256=bYNKy2oLAxtt6VYDWvCfq2bnJTVNjG5KMTsGl-gT_kM,3344
156
+ pyarrow/include/arrow/array/statistics.h,sha256=f0_4nJyk9Su-7u4B-HR6lfyKLe7e5E9J1HNqhgnRU28,6914
157
+ pyarrow/include/arrow/array/util.h,sha256=qVHvCaVlALz8WJwAjyMwsBm5J2iN89CSgj7NpmmqlkI,3652
158
+ pyarrow/include/arrow/array/validate.h,sha256=JdDb3XJg4TmAfpv_zgu2ITfL2H9no10TQit-HPj9Myw,1710
159
+ pyarrow/include/arrow/buffer.h,sha256=aDZgA8fFnizg61OPvgpWxftsGRAGNd-EW2BMjE233ZA,23226
160
+ pyarrow/include/arrow/buffer_builder.h,sha256=qaMgLKbycOSsn5e5_nlOj3tdPHu0i45if78ZrFN2Lmc,17468
161
+ pyarrow/include/arrow/builder.h,sha256=mBxMko271lJ7Xbku0hCixj943Yx-d2i4Q5Hm2WfwiGM,1546
162
+ pyarrow/include/arrow/c/abi.h,sha256=GCjxzmA2jNWQ0ZWVkQ-hnbCbMHKPikO1-JkzYj96cnY,20318
163
+ pyarrow/include/arrow/c/bridge.h,sha256=6e6ZoIsG-pE8FQ5aU4nRJ71vVL3U9k697g7PYKDsVz4,21789
164
+ pyarrow/include/arrow/c/dlpack.h,sha256=IXIuMdfqbHJ_AdT_25tzp0z48mWC65w4xZMjTP3yl7Q,1983
165
+ pyarrow/include/arrow/c/dlpack_abi.h,sha256=mjp9WWq8qv6gkGirT4y0o3BL_ZI9VyHQpJ5aEpPFetI,9920
166
+ pyarrow/include/arrow/c/helpers.h,sha256=f0Q519PwoliFHpxsHp-QvbP6fpVMN2Ha35Tk-RBK6Ws,6279
167
+ pyarrow/include/arrow/chunk_resolver.h,sha256=oVm7DpbWRmjJhexj_h6BtispCBxFZPIHK1kl9goBGG8,12841
168
+ pyarrow/include/arrow/chunked_array.h,sha256=z6LA9OB3uhtmn7ZZe5wfi3Am3icVQ-L_e8s3KEMuq18,10647
169
+ pyarrow/include/arrow/compare.h,sha256=yp4ganiaR6xXokExmFAauUyfSPwOM8DuBmmAtyK0NJg,8059
170
+ pyarrow/include/arrow/compute/api.h,sha256=6z6HdNH6S0Amop2GUfrsifxOvgupfTqFDZf76YREt-4,2139
171
+ pyarrow/include/arrow/compute/api_aggregate.h,sha256=GCPpIA6qz6XL2UI4SyxXjyjPeC68OoT1tttpiue8eMY,21945
172
+ pyarrow/include/arrow/compute/api_scalar.h,sha256=qR-K4zRkfJmINCF0vTp3rMWf7hdi4PU4haD59wGO9Xg,70099
173
+ pyarrow/include/arrow/compute/api_vector.h,sha256=axkl_2Kz-VqeZkQgAsGCy9spxV62PkgJKhTklQyWWWs,34507
174
+ pyarrow/include/arrow/compute/cast.h,sha256=y8v-EYs-1zJ5NhulMGNzagKc9CkU14ld36VIbYdV94g,4245
175
+ pyarrow/include/arrow/compute/exec.h,sha256=2baXvq1FWwyfQfTV4r6qhF818LEYOxyn_DiTqE5AMCk,17975
176
+ pyarrow/include/arrow/compute/expression.h,sha256=LBwjf1LTtfCfTT3RGUq_3PI_V0LRf2HxtZ-Ovqslw-c,11164
177
+ pyarrow/include/arrow/compute/function.h,sha256=rtEKbrMURIqOWo3JgdOxHsDMk1F-Kk5_Jz_xcpXavxg,16419
178
+ pyarrow/include/arrow/compute/function_options.h,sha256=Q9rjkXPrU9-Xi64_fMLPbBbW_byhjJFsvHppP1CumdA,3088
179
+ pyarrow/include/arrow/compute/initialize.h,sha256=ms8mtCSHTaStTrWdapbNyNSpM0PO4ox32O9colbBR7k,1193
180
+ pyarrow/include/arrow/compute/kernel.h,sha256=d3BIi5NtSBqPsh2gyCsfT03LvRmO2vM_XgoXip_HuKA,32283
181
+ pyarrow/include/arrow/compute/ordering.h,sha256=8Vw3VzDi1mGgVwKGQZakz9TVj0A40wxcL13EvuqNVjU,4129
182
+ pyarrow/include/arrow/compute/registry.h,sha256=x7LHiaNEVvZ0VUssZFsasB52Z1AxRflkdI5tR1hhzqc,4837
183
+ pyarrow/include/arrow/compute/row/grouper.h,sha256=ID9sFjFawulQC5T_f-TQttvohhsSAmNkHIj1iXzDY-0,7520
184
+ pyarrow/include/arrow/compute/type_fwd.h,sha256=tiG7MrLEfXAPF53JKlnFdJ7kzjhNP9a_xCb2Ept3ozc,1555
185
+ pyarrow/include/arrow/compute/util.h,sha256=l1y6P1hHsI-mQ7lB6KNn_8AzYCxCxuhaSBOOG_wqjcs,9376
186
+ pyarrow/include/arrow/compute/visibility.h,sha256=_h6gB6GG5YSF3aak6oAerylqtJvjhTN9Tq8MZccpO0M,1597
187
+ pyarrow/include/arrow/config.h,sha256=8liyKI0CJO0G-Fz5I--QjIAwh0m4hosfyAOwvVVs0sU,3044
188
+ pyarrow/include/arrow/csv/api.h,sha256=LbwWhPyIsi_73hvsSr77RNR9uUxrVyXM__hp7QcSom0,907
189
+ pyarrow/include/arrow/csv/chunker.h,sha256=nTs8hdy4D3Nz3oZWm2JMuA02noY_0pWRYWq_RptqzHY,1171
190
+ pyarrow/include/arrow/csv/column_builder.h,sha256=5t3842eXFsAHtrLGJ4LQkH2epUAr06PbnF7POwlgQQw,2889
191
+ pyarrow/include/arrow/csv/column_decoder.h,sha256=10idcPJE2V_TbvgjzPqmFy1dd_qSGWvu9eDkenTuCz0,2358
192
+ pyarrow/include/arrow/csv/converter.h,sha256=cjtnz_hZFxm_dWjAMjr1iqqk1egXI2Yb8Bd0xC8md5E,2789
193
+ pyarrow/include/arrow/csv/invalid_row.h,sha256=gTHjEbjkpee6syLGA8hFY7spx1ROMJmtMcwhXv21x5Q,1889
194
+ pyarrow/include/arrow/csv/options.h,sha256=0ShMt1PduP3K-n20HjxhWRQMORKP_q4rsIRYeWzoDR0,8202
195
+ pyarrow/include/arrow/csv/parser.h,sha256=8PplRh3Qxckk8VPyM70P_f1MBb4WMGnNVpoeJ9kOdHU,8616
196
+ pyarrow/include/arrow/csv/reader.h,sha256=416pt3yNQsgn4RhIyRMsmSJmvv1sw3ouQotubXG91gQ,4606
197
+ pyarrow/include/arrow/csv/test_common.h,sha256=uEYzw8EROvd1QMBQ98d4MaZ7BqMlw2e0flAyz-du0Z4,1972
198
+ pyarrow/include/arrow/csv/type_fwd.h,sha256=ptVbengmY_a7Yz1w0SKmKL16yyw9yEeym0Q0cnRCSV4,984
199
+ pyarrow/include/arrow/csv/writer.h,sha256=Y1zErZ5H1r2QzjAta3TXpFrdl2btoardCF8USCAGtGg,3549
200
+ pyarrow/include/arrow/dataset/api.h,sha256=p7i-bncJLhmfBkfjJWS7684vD9Lke1m6tb7HQq7Tpn4,1322
201
+ pyarrow/include/arrow/dataset/dataset.h,sha256=NsXdSFYrO4BpJSEV2e4yJRrN-hdLxMJepwAyyqFWt-0,20327
202
+ pyarrow/include/arrow/dataset/dataset_writer.h,sha256=TQV75b_UigfGjIpBnPk8teOncM5WroKfKV15oicBRRY,4589
203
+ pyarrow/include/arrow/dataset/discovery.h,sha256=x7-5NBAyEeQWGlWanJDLZAoWksKiMwM96tlDx_M6n5c,11236
204
+ pyarrow/include/arrow/dataset/file_base.h,sha256=nUMWLbhh7lt5c3iOw5edAtcy4jrCzpBUX5JZ29FW0Tk,20385
205
+ pyarrow/include/arrow/dataset/file_csv.h,sha256=7PlvQW_2FJ5RRN-VH4-OBw5cZ6nkd0KE0sj1TQvCZeo,5016
206
+ pyarrow/include/arrow/dataset/file_ipc.h,sha256=6-btvXhflZsAH90T3wMkwzZkte6T4ixzeCEUn_5uYW8,4083
207
+ pyarrow/include/arrow/dataset/file_json.h,sha256=sPjOeMOtbZZbvOivnOdb4MvYKHltpTnY8fONkhB9PZs,3523
208
+ pyarrow/include/arrow/dataset/file_orc.h,sha256=P7nAD9nacVngDEjH8ChQRt0AQmDg4Z1wBx360LDOoSg,2452
209
+ pyarrow/include/arrow/dataset/file_parquet.h,sha256=_mhpCrrLGn9XPKSt9lsdbG4wosPOkMiqkjXDz-2D_So,16935
210
+ pyarrow/include/arrow/dataset/parquet_encryption_config.h,sha256=Upo0k5MijZaMaRZjPp5Xg8TRt1p8Zwh2c2tdimjVe1A,3425
211
+ pyarrow/include/arrow/dataset/partition.h,sha256=3wrNekD_-fPO1YW91Za-T4muCfQeAX7SZRIcsCN_czI,16815
212
+ pyarrow/include/arrow/dataset/plan.h,sha256=IjuR9K2sWD85_2HpVVoJ-3YUCq--UPblHU46exX5qRg,1181
213
+ pyarrow/include/arrow/dataset/projector.h,sha256=KfZijq09Ht0Z2cJHsrjg-sE3SiZ4TKainflReK-39cg,1135
214
+ pyarrow/include/arrow/dataset/scanner.h,sha256=fWeW3NZF5zQYAjSIDU6wJsitzaVrSRbOmrMUnNQE1RA,26176
215
+ pyarrow/include/arrow/dataset/type_fwd.h,sha256=YOUSRwdNAlXJ7meFLolpAFQ_mSlObs2F81zcOy0DoI4,3170
216
+ pyarrow/include/arrow/dataset/visibility.h,sha256=ckmf_sEI0WBo4W7DIgH1QrOq82skOHtoksl9B3yYvzU,1586
217
+ pyarrow/include/arrow/datum.h,sha256=XYaZ_URrAtVqHMq-_2YtXk_ETeQ4yZWLVAnsi-k2Mac,11511
218
+ pyarrow/include/arrow/device.h,sha256=mLz99tb74VdjxXtKt6RZCYKJQ8TYz93uaCFJ1ZiItMw,15344
219
+ pyarrow/include/arrow/device_allocation_type_set.h,sha256=ynoZ-XyFlOAjh01PU-R11mE_EOxuw3xzc94v5OXa0u4,3306
220
+ pyarrow/include/arrow/engine/api.h,sha256=ORM0M5KQeurjEG8Eoa5IeV_ZgKBRPlWyicyv3ORWkAY,886
221
+ pyarrow/include/arrow/engine/substrait/api.h,sha256=W9NB1RAm0ZVxztRXYA-GD7H8XLQNXFoYT7TdGFHoNTE,1079
222
+ pyarrow/include/arrow/engine/substrait/extension_set.h,sha256=z1IIQVd4bat5kRngg91IyoE5UYTv7bar1JQ5ck63YbY,21552
223
+ pyarrow/include/arrow/engine/substrait/extension_types.h,sha256=x5ZIuynNh6WFt3wRjW--zUsuC3SeDLk1qRg9_xhswWM,3075
224
+ pyarrow/include/arrow/engine/substrait/options.h,sha256=dtvUty_zoDmcFwVflppiDzelYkeOhCO74uRF6izQSzk,5820
225
+ pyarrow/include/arrow/engine/substrait/relation.h,sha256=V3VKFlDdE61e1OS8LbJiwvm5w0uq5bzBLhKqmgmKaws,2385
226
+ pyarrow/include/arrow/engine/substrait/serde.h,sha256=mjxfuFo4aPhCiwefpKAJMIlknF4UOHSr6gWU__1SwCc,16528
227
+ pyarrow/include/arrow/engine/substrait/test_plan_builder.h,sha256=REFa79D1AOIIjp2Iez73iw5gEnzG9Rac9t8WwiGLsuI,3003
228
+ pyarrow/include/arrow/engine/substrait/test_util.h,sha256=IHZeYrk50Sx9anJfC25DWP6XesItKEywDWUqvUJcjEQ,1517
229
+ pyarrow/include/arrow/engine/substrait/type_fwd.h,sha256=P9YRjAQpSgoIjDC0siYyxoQzcPVo3r9y85qjiMtudBs,1028
230
+ pyarrow/include/arrow/engine/substrait/util.h,sha256=_dRiQBaIMWNbsYG7kuXhs3dMk4dI63-pM0uSxYPOvgE,3570
231
+ pyarrow/include/arrow/engine/substrait/visibility.h,sha256=GRzH6U-UCPT8d60cywOkFfcanPSgiZKCDP6X2rIpbMs,1740
232
+ pyarrow/include/arrow/extension/bool8.h,sha256=VsHTtVyrqk6UKgvifad7LouuieoAZuZs_uVvegdGq4Q,2145
233
+ pyarrow/include/arrow/extension/fixed_shape_tensor.h,sha256=VOqvTSnwDIvnhbstYX5nnqWfhtZ7MaD-lSF89BEqlhE,5610
234
+ pyarrow/include/arrow/extension/json.h,sha256=bNh6R9aP3MK-rbTON8IzVn7FIt9RGMmUHGpQkFGfOMw,2026
235
+ pyarrow/include/arrow/extension/opaque.h,sha256=uMVqSScey_13Ho6V86vfkuoByZni9ufh5BGKgX4bTZk,2920
236
+ pyarrow/include/arrow/extension/uuid.h,sha256=DBzTD83Mh3oacfZzfU6fQuGC87gvtnGGaDue8s9M0Ws,2364
237
+ pyarrow/include/arrow/extension_type.h,sha256=YUvUzPz-0QiG-jOjs__TfyPEpsHWGkGO5PMVG1vMjkY,6639
238
+ pyarrow/include/arrow/filesystem/api.h,sha256=Xgy2GOZtBVwDjTaXPDyPPlS9Bwt9gjWXm5I_QbyRbFo,1383
239
+ pyarrow/include/arrow/filesystem/azurefs.h,sha256=M-7jR8AqyPu8uTXbw4INLb9RsZKrPmZlPO7T7MskQ_8,15299
240
+ pyarrow/include/arrow/filesystem/filesystem.h,sha256=tjRP-ZEWzES6bMfmDQ2MwnYr_3OGV5ZyfbZr3JqWZXM,29604
241
+ pyarrow/include/arrow/filesystem/filesystem_library.h,sha256=f2_p4Odzvq7zrMePwNcWFFet8oolnDI8SF0t55Z6T_Y,1765
242
+ pyarrow/include/arrow/filesystem/gcsfs.h,sha256=5HSHqA9a1T2zVnZO1rNZKnXjLVyq1aAm6DRmQmg_v5w,10372
243
+ pyarrow/include/arrow/filesystem/hdfs.h,sha256=Jn91pjfk6RMx-MuAWsEAKLTyKQ7bDPNA5jMEVzafSgc,4133
244
+ pyarrow/include/arrow/filesystem/localfs.h,sha256=eIhPrpABheQz21WE845ULleTk83e4EtJnES4jALW6mM,4972
245
+ pyarrow/include/arrow/filesystem/mockfs.h,sha256=kohu7s9s9xtd75sGTE2K_rsHW89swDOtSSSFxBixMcc,4768
246
+ pyarrow/include/arrow/filesystem/path_util.h,sha256=hrDVHk4F9M7oGABB4x2wKfQMjSlSAIS0IaLVv2jHrl4,5698
247
+ pyarrow/include/arrow/filesystem/s3_test_util.h,sha256=22B600fr84Gq4rGALdidIP0IzDs9G3aOqkLN4y-6xrI,2962
248
+ pyarrow/include/arrow/filesystem/s3fs.h,sha256=q79pFbxFmsfA30LE78bOh6hj5Iszh01Vtw8LUpIa6T8,18221
249
+ pyarrow/include/arrow/filesystem/test_util.h,sha256=IcdXbz8kXaZDvUPN6Oc77UpWI2Psv1f_CKZxB3UGg-I,11738
250
+ pyarrow/include/arrow/filesystem/type_fwd.h,sha256=zztDER55Wbt4rVnkd-ReeDO-YnrpemftFeFtZ7ZGidY,1462
251
+ pyarrow/include/arrow/flight/api.h,sha256=YotLTQn-KCl6y5BIg8coEFZ9n7PMtJ02ly7Pc5gmX7U,1257
252
+ pyarrow/include/arrow/flight/client.h,sha256=MdHgubO7ExcWgp8S-CP9B4UfJ_aRLgLat0yz0pXQEdg,17936
253
+ pyarrow/include/arrow/flight/client_auth.h,sha256=a3Dkm_jPOuqzNsDA4eejuMUwCEBMavM8uS7w81ihbRY,2216
254
+ pyarrow/include/arrow/flight/client_cookie_middleware.h,sha256=5zkCP2SxMFQuTX8N9NHxOve5J_ef2rFO6-xY4Tfnygk,1204
255
+ pyarrow/include/arrow/flight/client_middleware.h,sha256=aAZwCahuiBhP85iMPe7xNWvidBR9KeHGto2YAqJioI4,2948
256
+ pyarrow/include/arrow/flight/client_tracing_middleware.h,sha256=d0sTmUOfq5M9FMliIKK-flJkR6-7r69NjU2TpxhfqWo,1217
257
+ pyarrow/include/arrow/flight/middleware.h,sha256=JPQd8JnIVcwjTH6yOBck4BWR-WV95fpnAdhHyEYvfKE,2254
258
+ pyarrow/include/arrow/flight/otel_logging.h,sha256=riS9sZM2C3mH6VMbESizJ6lGmudqdJhfdCY9_cJJqMA,1139
259
+ pyarrow/include/arrow/flight/platform.h,sha256=1ZfzVaollAZosGyH_1JvzEA8iNR0hi9cUGz5eyLT1zc,1209
260
+ pyarrow/include/arrow/flight/server.h,sha256=GAcV0-THuBuj-bXfwqYrZ1P2bwZgKQSJLbu8ToltRvU,13185
261
+ pyarrow/include/arrow/flight/server_auth.h,sha256=xXkot_fmnEZ0yXHEBmiezAQCxM7vQem1Vo1V0vEwcW4,4457
262
+ pyarrow/include/arrow/flight/server_middleware.h,sha256=kRXm15c1mjPduoS7N61m0TG8nGIhN_ielsjK9yFlsgs,3155
263
+ pyarrow/include/arrow/flight/server_tracing_middleware.h,sha256=NzyufqTwzcTZ32FNuY-rwse4KmH8zoyoc1RhZxUMwFs,2186
264
+ pyarrow/include/arrow/flight/test_auth_handlers.h,sha256=XkvMWucv9GQjlt2ttvYxshym4kUubUdMh-timlQIt1I,3315
265
+ pyarrow/include/arrow/flight/test_definitions.h,sha256=U_HhBnNdNZmojraYzICBmBvuef0bTT5eYzFXp8iGFzc,13110
266
+ pyarrow/include/arrow/flight/test_flight_server.h,sha256=SbRhZP0U4ILnbg7lYQvGeXmvPM_B6bai12FTM_HD4RQ,3930
267
+ pyarrow/include/arrow/flight/test_util.h,sha256=1Tv0Yl5lth2j3fIZT7iI8n_kexzGgJHGxplV4xeu7TE,6668
268
+ pyarrow/include/arrow/flight/transport.h,sha256=ZDXc-f8o00TFWESwsGU1My7rR9OfM3X7OZjDcGXTwIA,12181
269
+ pyarrow/include/arrow/flight/transport_server.h,sha256=iVdXmrb2pemh4o6BxwvB7OZAV4UeoWrbhe4ePZ5Pi4s,5268
270
+ pyarrow/include/arrow/flight/type_fwd.h,sha256=tQFAM3QNKPdzB4VqUGdEUFjNPYXVZLApwGnSus2GQx8,1797
271
+ pyarrow/include/arrow/flight/types.h,sha256=BwMWMwRPSxdyYPcR1ocdi2KXpJvAXRepkz6vUfZVCmc,47383
272
+ pyarrow/include/arrow/flight/types_async.h,sha256=3nIQqwCYO4Ir3Mt2bG7BNntXxuNHYQNNpz-Yl3EaFTQ,2599
273
+ pyarrow/include/arrow/flight/visibility.h,sha256=N1k74cwyRvOaYFa_tCjdgUjiSdPBhmy20UuVGu0wTg0,1596
274
+ pyarrow/include/arrow/io/api.h,sha256=Pn4jZSTsLW8MAlMyXUokmJdupX54u154GYI5AvD5ByA,996
275
+ pyarrow/include/arrow/io/buffered.h,sha256=PHaMwCMaXu3vAjhDpZMC2xt5hKooJXVeMffhoDzTxNc,5912
276
+ pyarrow/include/arrow/io/caching.h,sha256=AAjoyKwQ06m2XiglFS6Ch_cdg2p4-wkA7GakGI_eX1E,6708
277
+ pyarrow/include/arrow/io/compressed.h,sha256=3JxIOo1q8VhjIErfwVM5ZLVkwwQKXd-FT5517j58etA,3774
278
+ pyarrow/include/arrow/io/concurrency.h,sha256=SmIr0OWCgMUR3j9ngVbjMJhWOUrU15jQf_jz2rUw7r4,7934
279
+ pyarrow/include/arrow/io/file.h,sha256=-ZEklW1Q0sj3pYCQLQ1ebirKd3s2GI3vUEIszFr8mVU,7625
280
+ pyarrow/include/arrow/io/hdfs.h,sha256=2s3f49ggAYgSCsX5SoqnomwsXd24_IZhW-VSBJclqTg,8559
281
+ pyarrow/include/arrow/io/interfaces.h,sha256=QIBHTJUobEkwcqnKMT_GEKu5ArzpeGmK-8v7z4qGHIQ,13428
282
+ pyarrow/include/arrow/io/memory.h,sha256=SY535DEFEOIXojttrsGmMtK5PClwGx5sHK8E_TlCGCQ,6321
283
+ pyarrow/include/arrow/io/mman.h,sha256=qoLBAGFcvpYTy96Ga7FNWDJKT3uhxpFAF3hbXIaDSiY,4111
284
+ pyarrow/include/arrow/io/slow.h,sha256=8-ZjQJq49EQJ4esQ6qHHjlKCeZNg4BSND7ire-ZtLYQ,3942
285
+ pyarrow/include/arrow/io/stdio.h,sha256=dqMTHoJbmiXcyNa2fN60tSWQsx0GPphZVCLdGiZNt8I,2095
286
+ pyarrow/include/arrow/io/test_common.h,sha256=SF59odb0E3rtGju5jABsQzZcUi9gl5TwHuKg4f0EQ5Y,2146
287
+ pyarrow/include/arrow/io/transform.h,sha256=W9XWonw69VymQAaQptfW7jD-6ry7VCpfPXlkB7aZzOE,1890
288
+ pyarrow/include/arrow/io/type_fwd.h,sha256=Pi7EFpFvBXsFN1xKOyZjTSP95xNDs6W5hxb5GucoVVE,2315
289
+ pyarrow/include/arrow/ipc/api.h,sha256=sbbb-uYHZtqE59AUlwNnAzUkP41h3Et9Rnu20gNKm9w,972
290
+ pyarrow/include/arrow/ipc/dictionary.h,sha256=UTjZPIG8mLZOk9IW2QnR9RZGr1npexZOp103fv-O70E,6104
291
+ pyarrow/include/arrow/ipc/feather.h,sha256=uCnxwO7eUH18kJ-lWz9IWwSj6AjfejqqLdoifJ-UBDo,4918
292
+ pyarrow/include/arrow/ipc/message.h,sha256=KtMCbIC2J4-5iyPG5Sijqu_MALxiuKWBYZhGnw0jxOQ,20011
293
+ pyarrow/include/arrow/ipc/options.h,sha256=rAnPbL2wXRg4tZpnC3FNkxWxPdhRR5xUM2tYkc1crZ4,7900
294
+ pyarrow/include/arrow/ipc/reader.h,sha256=NqdrqqAEItO1ecYUINRO7-qhKlYy-CHSJKGI2hdXlRQ,24106
295
+ pyarrow/include/arrow/ipc/test_common.h,sha256=kd6-NmmaT__0cDYIwes8lnOqbQDSqFZn8eg2N-SHfE4,6559
296
+ pyarrow/include/arrow/ipc/type_fwd.h,sha256=Ty8ET7nLI4JJeTqDMyP0pEH9QVj9xs7BpJkZrnrpaPY,1440
297
+ pyarrow/include/arrow/ipc/util.h,sha256=wTkfC9YFKZlAAjyzlmQVZcW90oOj_JatjDN4qz0IxHg,1414
298
+ pyarrow/include/arrow/ipc/writer.h,sha256=hum8E_orkG_X38vgyfyKhGbyvcLJ3AkXEykyBjAXIYg,18870
299
+ pyarrow/include/arrow/json/api.h,sha256=XRW1fP43zVqwy1yabaKctNK9MDZqnxkoHDH1fx5B3Y4,879
300
+ pyarrow/include/arrow/json/chunked_builder.h,sha256=DDuMwrImMECw6Mhfncn2xMOjkFcKUV1O1597_fSFSAs,2365
301
+ pyarrow/include/arrow/json/chunker.h,sha256=dkZOcxsF1Q3ek58P7IoA8f3lQyBQpFvGSFeynNV2Olc,1119
302
+ pyarrow/include/arrow/json/converter.h,sha256=3lXsP3BSdpLPIkFAJnYW9vP8BbX3neVYR_W0zFKClQ0,3134
303
+ pyarrow/include/arrow/json/from_string.h,sha256=y--AK08e-EivbrilSGU6xtPH1VpqBNZIYvCMUT2_V_E,4106
304
+ pyarrow/include/arrow/json/object_parser.h,sha256=Y_6Oceya06aUyeo-1k047dm2-JUMJa2_w9iyZ-goIRQ,1627
305
+ pyarrow/include/arrow/json/object_writer.h,sha256=UrIrjCkIz7Q5n_FpV5NNPD96gHHdTkvTJaekuGBHwTo,1428
306
+ pyarrow/include/arrow/json/options.h,sha256=EypQgDwLZQbrPnAh45nSPfpGGYrxvLgfp1eAG_l0p3Q,2227
307
+ pyarrow/include/arrow/json/parser.h,sha256=3oIzO5kUs2Takc7t_d5mH7bp1uIcc1M-qbuHmPoSI34,3383
308
+ pyarrow/include/arrow/json/rapidjson_defs.h,sha256=lBJlfuYWIeQQ8awPd3bk4jJc81efr_KzKwG8Klw7t1s,1474
309
+ pyarrow/include/arrow/json/reader.h,sha256=KNO9dCyc2RZs7WxUSEW7bpCYBh_h1C3U52YHYxBnP0M,5212
310
+ pyarrow/include/arrow/json/test_common.h,sha256=YiiY_jswpp7Nu6IW1Y2lBhqWSFRoNaNEy1jHd5qkYHQ,10874
311
+ pyarrow/include/arrow/json/type_fwd.h,sha256=o9aigB5losknJFFei1k25pDVYZgkC2elmRMX1C6aTjo,942
312
+ pyarrow/include/arrow/memory_pool.h,sha256=sKBdu-Aidm_X3qbPnfpur5LX7nuwlsnCraPsGR2Up70,12911
313
+ pyarrow/include/arrow/memory_pool_test.h,sha256=qv7csk6hZiO2ELFF-1yukpppjETDDX0nuBFBbPFHtMU,3350
314
+ pyarrow/include/arrow/pretty_print.h,sha256=Z36O7Rp3wp8gCG51YHh-x8ytrrENDpFZSPmSSXs9TAo,5716
315
+ pyarrow/include/arrow/python/api.h,sha256=2XyYOFAmorPGXrTVYZkiKL67nuH8w1ha6D1reU7K-Vs,1179
316
+ pyarrow/include/arrow/python/arrow_to_pandas.h,sha256=jQiSTN8IL95onwaclaWqCR5Nb2RHrBtubRyEOJR9eRE,6215
317
+ pyarrow/include/arrow/python/async.h,sha256=C0f8YYmgwBGgDau4xEFsdjukiZB4YvpylETHEZryHOo,2352
318
+ pyarrow/include/arrow/python/benchmark.h,sha256=f-kzyMOlPKDse2bcLWhyMrDEMZrG_JHAPpDJgGW0bXU,1192
319
+ pyarrow/include/arrow/python/common.h,sha256=9IQC__JUqTRXv5MfAqKM6ivMwuQ-uMZKEguGDEODkiA,14389
320
+ pyarrow/include/arrow/python/config.h,sha256=SQa6SuM3oAfQ7wEbwVJqlPfqslqlq2DXK_FK6-K08Kg,1150
321
+ pyarrow/include/arrow/python/csv.h,sha256=QxU3B-Hv_RsoEcMGS9-1434ugouL2ygC64Lq6FgviNM,1397
322
+ pyarrow/include/arrow/python/datetime.h,sha256=Bny_THGi2tyUeHxcOuw01O7hNE8B_gave5ABAZQtwTQ,7931
323
+ pyarrow/include/arrow/python/decimal.h,sha256=K9ScmzSa7XCuuwpXKnq0GPbRDTuRU5yXfWr9zGtOchc,6362
324
+ pyarrow/include/arrow/python/extension_type.h,sha256=0gzb42y_mbw4fsYs3u8cwPFLBRlG-kkHQLgbvGtrY0U,3181
325
+ pyarrow/include/arrow/python/filesystem.h,sha256=FG0AcLekqaDf9IQPqKixAfIcY_ZLgIKP5NvvXdtBVUM,5126
326
+ pyarrow/include/arrow/python/flight.h,sha256=t4ZD8gWaubbO_mBDv0XZ58TCo1VQl0hzHn1_7w4U64I,14450
327
+ pyarrow/include/arrow/python/gdb.h,sha256=H-qvM-nU8a_3Z5tk8PvppTwQtBMSZhQKQIVgRAsRfFg,972
328
+ pyarrow/include/arrow/python/helpers.h,sha256=Q3TmwyffFpVYQEp55ZoWTDDhnte7zQKiXylsfbEMCuI,5479
329
+ pyarrow/include/arrow/python/inference.h,sha256=FUFvB4Zy7V-tueXdmbDcqTeLK4xj5GZEeRW5yhiJlsU,2038
330
+ pyarrow/include/arrow/python/io.h,sha256=4jGnodpSUlnVqAVh9fWId7H4WldlLPkXyroABpdaW6w,3858
331
+ pyarrow/include/arrow/python/ipc.h,sha256=SZbw6jCCqLiLNCY3k632GmwHeD_r_xrDS0dhqV49VhY,2259
332
+ pyarrow/include/arrow/python/iterators.h,sha256=Ugfm3JvetAH0l-oAjjpZfhrUBqRimVMaw4-xusvqLSg,7327
333
+ pyarrow/include/arrow/python/lib.h,sha256=NSqX1jl5ZWssVm0SmNFHp4PckJYy8YCJxlL02MKa4Uc,4562
334
+ pyarrow/include/arrow/python/lib_api.h,sha256=rm6EBrvNbQHNzt_TJGbbdIo5T_1IC2WBAXIQnpMzsNA,20132
335
+ pyarrow/include/arrow/python/numpy_convert.h,sha256=y13eHwfe1lJKzadoTr2-GyX6xPsE6Z7FN31s7PN-2Rk,4870
336
+ pyarrow/include/arrow/python/numpy_init.h,sha256=FniVHP7W2YBlenoMYhQrODvoqqvDMSls2JANGtNPQts,999
337
+ pyarrow/include/arrow/python/numpy_interop.h,sha256=rI6ek8JTOYtjo7gEADSDBS6QuAOHa2A0YQPZ2GeypFw,3418
338
+ pyarrow/include/arrow/python/numpy_to_arrow.h,sha256=z9KapsuoOSpWILPt9bea7GR4BL6AQ28T6DUO0mSkh3k,2760
339
+ pyarrow/include/arrow/python/parquet_encryption.h,sha256=7KjqRuxbO0UxxHikTDvrLH733UVe0uvTf_bQMiI_xCA,5596
340
+ pyarrow/include/arrow/python/platform.h,sha256=AtkGgpUVqPHs9Z8Tm07yb2zN_wOtb2cvlf-5xFBkc4k,1268
341
+ pyarrow/include/arrow/python/pyarrow.h,sha256=TK3BtD9n3QKOQ9dX3LXbQc0hu9alWcufV0O93iQW7B0,2761
342
+ pyarrow/include/arrow/python/pyarrow_api.h,sha256=7l0G4-_m9yALYoifsY8Z6qh3HHD0PgkpVSgCn_JaGU4,867
343
+ pyarrow/include/arrow/python/pyarrow_lib.h,sha256=-70_Ckj3_0ImlzaXSJOE_d3w9pGM66lXiGPyln9c96Y,863
344
+ pyarrow/include/arrow/python/python_test.h,sha256=ea32mM20uHySlygi9MtVxr26O-ydTZHCUQIlxaIMjT4,1195
345
+ pyarrow/include/arrow/python/python_to_arrow.h,sha256=BoVytf6P7PBYXyznchElKZSFvEsFyimB-tLFdw0AUNo,2521
346
+ pyarrow/include/arrow/python/type_traits.h,sha256=U7dW4sajVVmjXALsP-B8ZZwI4GgIUG3t-rbp2fwrHWI,10236
347
+ pyarrow/include/arrow/python/udf.h,sha256=de3R8PhNJO5lT9oCqRxe8e2_SE3jBpHOkwbNqCrlgjQ,3104
348
+ pyarrow/include/arrow/python/util.h,sha256=sP2CEGG7NNqwjrEeNKB-VFqkKxn5P2Tsc0jPUMXQuLg,1732
349
+ pyarrow/include/arrow/python/vendored/pythoncapi_compat.h,sha256=bzMnlHTCfjk5DQRIxwytunYh5aQxU3iSElaaDyNnAY8,40900
350
+ pyarrow/include/arrow/python/visibility.h,sha256=hwJw5sGrWJckQkNaAuLe4Tf-VDjQbXknyzNOVgZI3FI,1381
351
+ pyarrow/include/arrow/record_batch.h,sha256=DZ_GZUGTEBv7uJeNnxPoY1ZnB-m7tfSYcHuNdL6iXVU,18947
352
+ pyarrow/include/arrow/result.h,sha256=sh0Yp4pFT07H-ro8CFzK-Iye_0PF-unu-vz4C0hcoHA,18357
353
+ pyarrow/include/arrow/scalar.h,sha256=rsZGG1akIQJRRTw-_dlXLjkPT6NTONiwv70L_1zPxho,37320
354
+ pyarrow/include/arrow/sparse_tensor.h,sha256=1EetIzwI_JvNITcy3LS9Ra0wFiDWLB0hXjy26VOCg2s,25205
355
+ pyarrow/include/arrow/status.h,sha256=r9B963ikSEuSQpbnuGBV-pl1Dtfi5Co0gFd7hI0AMUE,17392
356
+ pyarrow/include/arrow/stl.h,sha256=2PEb_N_ZOWrwBJnFWah96GuLmEBc5Vl4_IFws9NCF2k,19343
357
+ pyarrow/include/arrow/stl_allocator.h,sha256=TBbvjbuQIH9y88FI2SaqAL7pOIt3wZ1xMKwXqeKNiJE,4956
358
+ pyarrow/include/arrow/stl_iterator.h,sha256=RelNQrADHupKWTuFBCCkqVlyuGHXU3yB6gcsDpQpra8,9953
359
+ pyarrow/include/arrow/table.h,sha256=0RFiXqJcNfcdH9jcDcBiRunPdWcHZn4A0blWdSR-MqE,15300
360
+ pyarrow/include/arrow/table_builder.h,sha256=LRcLCL2iUrj6vF4f9AjPswVjqtqlMw7z_8VBAfUJeCo,3763
361
+ pyarrow/include/arrow/tensor.h,sha256=t5qdeufYoYG1Tl4DCiDzeZkOhyiQQPOGbMKCLa0u7WM,9089
362
+ pyarrow/include/arrow/tensor/converter.h,sha256=RZq0Try_kiZ085_d_CvhewMsd57InGb2TCeiveaf-Oo,2891
363
+ pyarrow/include/arrow/testing/async_test_util.h,sha256=IrHWfPeIyhrgeTGHUPLt92LdsofmFX6khjngWsZv3dY,2262
364
+ pyarrow/include/arrow/testing/builder.h,sha256=4x0bWOedaVomWU0m7dF99irOv3flR-_p-IMofTDZtwo,8556
365
+ pyarrow/include/arrow/testing/executor_util.h,sha256=38_rF-V_9zF1ttJMspkPiI-34VU1RDjg1ADBS8lUFHk,1885
366
+ pyarrow/include/arrow/testing/extension_type.h,sha256=2xHmtD1bnK-u8Or38keTBvDuXhgKvsVyiiO-exlWHXg,8113
367
+ pyarrow/include/arrow/testing/fixed_width_test_util.h,sha256=g6yB7RkziU7HEhNJnxOhkn2nE5HeXaFX3tbBX3q9_sE,3091
368
+ pyarrow/include/arrow/testing/future_util.h,sha256=qIhi417OGMWSMUSDHjkGTYd-ihZbqw8ZSIRwJ01vbKg,6246
369
+ pyarrow/include/arrow/testing/generator.h,sha256=zwEI_ZS-nxOIoYZUW_X9VE0wg5ILk8PzBpeo6kqXUDM,13525
370
+ pyarrow/include/arrow/testing/gtest_compat.h,sha256=0NqH39my7m1FMpsrQYnxQx4bdEE10SCXZaysN6yjQFA,1311
371
+ pyarrow/include/arrow/testing/gtest_util.h,sha256=s6hzot0wcsaVvajwRlBYmWGUjSvJ13o8AlNGLhEtPr4,24381
372
+ pyarrow/include/arrow/testing/matchers.h,sha256=Z6jJW4fGlvtpc7oWpPlx5ynLk2tnLwF-dhv5fQIcvqc,16832
373
+ pyarrow/include/arrow/testing/math.h,sha256=YLDNNqYpSHBT1jZo06pYN-TG_RtOJFOJ29YJ0hSP8g0,1424
374
+ pyarrow/include/arrow/testing/process.h,sha256=AzPW3Lh2R4sTm-RUUi4Od3aSba9zoLcS_zHBxztv4zI,1372
375
+ pyarrow/include/arrow/testing/random.h,sha256=U17nEG1fl4vAMGULYVMWUtdIv15R87EoK-SKZirujAc,38331
376
+ pyarrow/include/arrow/testing/uniform_real.h,sha256=-G_2J9cvevoCtB55vsCsWtJkMUHLIMyOwdT6G8ZW45Y,2970
377
+ pyarrow/include/arrow/testing/util.h,sha256=bvrOS5Uvcfn4Crb-bf_4_02Jb5MPQsItf9AnWC6CKmA,5662
378
+ pyarrow/include/arrow/testing/visibility.h,sha256=-wjc00QIhygXJa7tknbIL685AQ1wnyCPr-EtVzkzmq0,1606
379
+ pyarrow/include/arrow/type.h,sha256=6X9yEP8xA0EmrVo96fG0w4QsGfafqgy9333qinsS4YU,97136
380
+ pyarrow/include/arrow/type_fwd.h,sha256=04ZjJ5UYWHsFofNPN5yx94VEeFh3__906P5J1QHQaqc,23665
381
+ pyarrow/include/arrow/type_traits.h,sha256=nKDVrC4_4EBfyEbHQdVr4mgmAaSvdp6cJE2XPZfUwaA,56056
382
+ pyarrow/include/arrow/util/algorithm.h,sha256=045EVzsC9rThlRVFaCoBmmtWZmFy5y28PR9yapn9sXY,1229
383
+ pyarrow/include/arrow/util/align_util.h,sha256=DG2L24KReTiU8nFpXLigbflkKouKWTPUf6osQs6mxiY,10669
384
+ pyarrow/include/arrow/util/aligned_storage.h,sha256=e0pCTBZ9hn9VAVTnENubbEii_witF73xUeBZNIQd73I,4254
385
+ pyarrow/include/arrow/util/async_generator.h,sha256=avVH3JPaDk_vrEh8uhPLopVN3LSn-29yst23GoptZR8,78200
386
+ pyarrow/include/arrow/util/async_generator_fwd.h,sha256=Q8sueYZWwdxkaVDabuglHM3XuP--NerYgq8UxsVHgFY,1728
387
+ pyarrow/include/arrow/util/async_util.h,sha256=1nnAJZ22iK7wSzmvZDo3PMhuWqJIt2qKdlXzTyhoCK4,19759
388
+ pyarrow/include/arrow/util/base64.h,sha256=qzcBE98cg8Tx5iPJAvQ4Pdf2yc6R2r-4yGJS1_DEIeY,1095
389
+ pyarrow/include/arrow/util/basic_decimal.h,sha256=Q2zfksUdYc92TL8po81I_aQOmwHTwZGPjqXvJM7cgek,33569
390
+ pyarrow/include/arrow/util/benchmark_util.h,sha256=SG3gfwE-wGNZAwpL3TvffnSiZGM2cztV5xRBnbqy2Mw,7641
391
+ pyarrow/include/arrow/util/binary_view_util.h,sha256=-sFAQX9cnfWmmZJo8stFX5vkJki7T2UloAvDzYO0MN8,4625
392
+ pyarrow/include/arrow/util/bit_block_counter.h,sha256=iSIemzizxVokwC0Ze6SjSi-al_nrP2ViXF6JPoIVUWc,20162
393
+ pyarrow/include/arrow/util/bit_run_reader.h,sha256=1G9jN387hUCm0q9LvoSPEjY5v4fBOC8Aq_-riu-Sklw,17290
394
+ pyarrow/include/arrow/util/bit_util.h,sha256=gABDSW-EqgHu559EFfYvPkR7feICKR7YDbLx-Kh10uU,16397
395
+ pyarrow/include/arrow/util/bitmap.h,sha256=eGjGlh6s4Dubhfrk-Kp931YgR8KyaHNcxbTW1rqtqbI,17459
396
+ pyarrow/include/arrow/util/bitmap_builders.h,sha256=28rjB9AGwG-VMzuen9FARssdMul0RJx2ZmPFQL9SV1E,1596
397
+ pyarrow/include/arrow/util/bitmap_generate.h,sha256=m6ZsNwx1GhsEktQr63NxXHQkX2B7Nti011XYsPg2xfo,3661
398
+ pyarrow/include/arrow/util/bitmap_ops.h,sha256=fPPD_cvXebYLrAeQOCCYydU1AwF0faN5DwQKV8op-Es,10877
399
+ pyarrow/include/arrow/util/bitmap_reader.h,sha256=-EePBZDJyoF1GDQLHi5a9GK6rPQ-NRZS8iZZUSw6WmE,8392
400
+ pyarrow/include/arrow/util/bitmap_visit.h,sha256=myn8k66VrvZnL6R6VW6IDPTfO68VxjbJ8Up5IuSjFL4,3470
401
+ pyarrow/include/arrow/util/bitmap_writer.h,sha256=a4goXhLlY0qcfvYxbfbGD_HZ8Au1wFcbV1tVF3BPaXs,9383
402
+ pyarrow/include/arrow/util/byte_size.h,sha256=Pd2c_3a0IeSOUevhPIlXNkDmgoB06g4c9YCsuRwwSKM,3997
403
+ pyarrow/include/arrow/util/cancel.h,sha256=SgAy5S0TBISnCypp4R_OI-jPUQ997qtsLOSdXo8l5bM,3659
404
+ pyarrow/include/arrow/util/checked_cast.h,sha256=SR9Qg8NuLSBJw2w1UfgeGvCfT8k7wrbN7BzADQOZfAU,2076
405
+ pyarrow/include/arrow/util/compare.h,sha256=OLrSSyllkY4Sv00IK-37A2d68gr4OwnWJsxn1aF9xTU,1982
406
+ pyarrow/include/arrow/util/compression.h,sha256=fvlURoWJsgO8Hr6Xs_VNaqiOatmIGn9ktVUkYv7pIu4,8427
407
+ pyarrow/include/arrow/util/concurrent_map.h,sha256=wMi9WDHfRuJ_aSFgcJPpsVwGJ9vIJ5agaZ3rVUlwGe4,1775
408
+ pyarrow/include/arrow/util/config.h,sha256=WjSomLcG1dvYoc0O6r_ePvTfEEgU_a6DpbScKs_OOy4,2090
409
+ pyarrow/include/arrow/util/converter.h,sha256=PILfos6VlnLK6fOFMfLIUhiKl3o1dJo9T4HJXeR7V5E,14637
410
+ pyarrow/include/arrow/util/cpu_info.h,sha256=MqLdJabBZkzDjiScaQ7if9dmoAGvXT2QavGoGkho3lU,3964
411
+ pyarrow/include/arrow/util/crc32.h,sha256=4gN0M-SRnxaGKci2ATPbMWZG2TG3YULXjaTpadV0Udk,1337
412
+ pyarrow/include/arrow/util/debug.h,sha256=CPB_oDOuZ_u89e9wM8bGn88mGvClgfa7UDxDph6v9sY,971
413
+ pyarrow/include/arrow/util/decimal.h,sha256=cEQRH5x5kN_MAsWNOPCLjz57QjW4ErfppMHG4b-0EOA,20291
414
+ pyarrow/include/arrow/util/delimiting.h,sha256=JYe9YcWMeFT_ISuojx_VgVqOYLvZ2TiiR2sNn-WdeBQ,7317
415
+ pyarrow/include/arrow/util/endian.h,sha256=PPai9ig8DtGVouKksjTq7H_anm0BjgoTMaVTkWlMKWY,8236
416
+ pyarrow/include/arrow/util/float16.h,sha256=3RfWoQ0sIPCk2yXniIYw-g7X-EEmaos_IG9z8cnXCmQ,7454
417
+ pyarrow/include/arrow/util/formatting.h,sha256=3D0xE7sTcJR6XEUb12LKSqL-A3bX_Pyp1oVkPScjCwQ,22516
418
+ pyarrow/include/arrow/util/functional.h,sha256=4ljKXSWX3G_lBT2BfLXuG44pzZwVKeaojpLWCniqKyc,5612
419
+ pyarrow/include/arrow/util/future.h,sha256=tsSVDEH2dhXKyvIKl6R9BVBolpPdZXoRRf2-YRbtdxg,32296
420
+ pyarrow/include/arrow/util/hash_util.h,sha256=CjiNVPUJPxXvVJy7ys79aIb7YB6Bm-5nTJAR4DHsxcs,1918
421
+ pyarrow/include/arrow/util/hashing.h,sha256=2rIuTiAhMVsIt52fc9RR6vVM9NNfzeFJPsAPWCd6vX8,34224
422
+ pyarrow/include/arrow/util/int_util.h,sha256=zTOAq57M4pUe469WpnW6I5hNtxe3vGRHlZWhngA1DzM,4859
423
+ pyarrow/include/arrow/util/int_util_overflow.h,sha256=7eLu26N5xY2VYM8aSJOZyfmwqIc3IdMXsshsjmuge74,8218
424
+ pyarrow/include/arrow/util/io_util.h,sha256=2s53VCM_Rd7j7IsXzDHK6-Hwqx5bp6BlKFUybn75ebM,13762
425
+ pyarrow/include/arrow/util/iterator.h,sha256=FymwfXvx9akIj1hAvLgrFQ01BWJbvAv4xx06TNDc9dc,18345
426
+ pyarrow/include/arrow/util/key_value_metadata.h,sha256=wjU6uQGcSmy-YFqMs6rwLP7E4X-0IFBjPrWZstistzQ,3590
427
+ pyarrow/include/arrow/util/launder.h,sha256=C3rNBRh4reuUp8YuRdGQU95WPc8vl4bAY-z5LXgDiuA,1046
428
+ pyarrow/include/arrow/util/list_util.h,sha256=_OmtsDqe-mnZ_7tVWxB2yHdgCJhpiME_RP3nXHzKbdI,2028
429
+ pyarrow/include/arrow/util/logger.h,sha256=p9i4dNgne36LWpFmNSYBYgTQ4kFSao20dJ40LgRRZKQ,6693
430
+ pyarrow/include/arrow/util/logging.h,sha256=63wlnOug1zSd1ur7caDp0F0z2IG7QjHbUFGChE8f-nA,9139
431
+ pyarrow/include/arrow/util/macros.h,sha256=a5_NbnOnb2z4MYLM3mXSRk0oMH-CfkrOa7lzNJKjNy0,9884
432
+ pyarrow/include/arrow/util/math_constants.h,sha256=2sfWoVc8syHz8X26XgBmejzXStl7hmvKiOh9622oUZA,1112
433
+ pyarrow/include/arrow/util/mutex.h,sha256=n4bsrHK2Q8zbYsQEyNaFqNu__vvqgwo1AfrLLCxfkpU,2554
434
+ pyarrow/include/arrow/util/parallel.h,sha256=_43wTVSrtJwOkRt3KJcJF1DyYHwhoWbWPsrAswftP-Q,3817
435
+ pyarrow/include/arrow/util/pcg_random.h,sha256=nbXowfCJFiy4GjVfF9I8VvB6fxkyR5zNB1FKdnFsYTQ,1252
436
+ pyarrow/include/arrow/util/prefetch.h,sha256=vaE4FPdscbtO0cPbzl8F1PzB1NDO18ytYlEmZCHDjHs,1251
437
+ pyarrow/include/arrow/util/queue.h,sha256=X9vRZQX3YL_a2Lzwe-zcNNHguR7FoGYmD-Q0THqsCBM,1017
438
+ pyarrow/include/arrow/util/range.h,sha256=WJ1v4BaQ4iMLuh-fgdGyWqY88rzR6Z9rqDQj5RC84XE,8725
439
+ pyarrow/include/arrow/util/ree_util.h,sha256=NO71naM7twCfCrX52vPmWoNhL90XP4PFEdc6AI9-OCs,22397
440
+ pyarrow/include/arrow/util/regex.h,sha256=Tj92CttOh2HxS0EKQ_9-sxMBAsQrDOUKNP0ngIJFdP8,1742
441
+ pyarrow/include/arrow/util/rows_to_batches.h,sha256=PZNoLeMCfJJdeHVvUny0UHc5AtS0hctUCi7zUztJpeE,7120
442
+ pyarrow/include/arrow/util/secure_string.h,sha256=0T9JxwkqXpGszGfcrstxJyRZztV9VRsFqVcGhDcEmhM,2476
443
+ pyarrow/include/arrow/util/simd.h,sha256=PpKm-aWpZYIYP0NnyGrQceOO9m3_7JbN4uro0IhIT9w,1679
444
+ pyarrow/include/arrow/util/small_vector.h,sha256=hXkuEMONoYd7vFS_6lLPwP49SVdBpAhSlvMK-1d3PrE,14439
445
+ pyarrow/include/arrow/util/span.h,sha256=FjFcz8VzZDSF-nR-dFbyd1wzL5XQpupI0db2-r0FyP4,4298
446
+ pyarrow/include/arrow/util/string.h,sha256=UStQlZ3Fkhmwm5IcKDsbUABENDRnjV1cU5dRXnEv8IQ,5296
447
+ pyarrow/include/arrow/util/string_util.h,sha256=0IUIcjSf2zMP8rVoVx5y1satijO7cr0PvOgG32d0lFA,2364
448
+ pyarrow/include/arrow/util/task_group.h,sha256=fI330NoJT8u84AEUA6pSxWrE7UBKn2LaM4DfPFoalqA,4362
449
+ pyarrow/include/arrow/util/test_common.h,sha256=OqhWyOEVmWbzhr2JfiaMn1flC84pU6kHL5vYZV1bhUM,2981
450
+ pyarrow/include/arrow/util/thread_pool.h,sha256=Q2KzKTxcikTEgdNAouFwjwsorFa3wE9IVkKqYd8o_Lw,25530
451
+ pyarrow/include/arrow/util/time.h,sha256=_s6yyeTNkNPiLjtaWceItyD8_yGTx2GMiXj1ICVlzyU,3439
452
+ pyarrow/include/arrow/util/tracing.h,sha256=sVfC_Rj2gwkWKVSKT0l0FOO5c2EGsfYwlkZX4d9ncxA,1286
453
+ pyarrow/include/arrow/util/type_fwd.h,sha256=JeZ1muIiVKxHcAXzBikMCmk_7SxFz_IqmzuT6yY1F-A,1803
454
+ pyarrow/include/arrow/util/type_traits.h,sha256=iRrIf4YhuMOGL5DJWIJoV2bUEhZRHWuce8TXm-JMkns,2155
455
+ pyarrow/include/arrow/util/ubsan.h,sha256=dJiINEVEdpLSr5-Z_a7BxoYGvA1-pCfHia_xiF0TfYo,3228
456
+ pyarrow/include/arrow/util/union_util.h,sha256=PSssBiw-v-PDen_q75c6OkNO5PwyIPhGbf9PMJj7P2M,1211
457
+ pyarrow/include/arrow/util/unreachable.h,sha256=O1TG4ozCYT3_xvDpJouKWrlFADIEpIemQ28y4DqIwu4,1070
458
+ pyarrow/include/arrow/util/uri.h,sha256=D24zebazFcrKGt7iGpkcGQ87DuF-2AbjPKVkDlq9Nuk,3886
459
+ pyarrow/include/arrow/util/utf8.h,sha256=flGZ786kHo33Xg_zw0zVA9GAT8jYdPUHTVhIPHGjOj8,2031
460
+ pyarrow/include/arrow/util/value_parsing.h,sha256=p_7p_fUUw3jfUkiVnKADdHb3KCdJ7Xg2JQnc39uQHMI,30654
461
+ pyarrow/include/arrow/util/vector.h,sha256=OKnWECz72otbpw6UZSzZIZHJXCXGb9IsPiFI-l3wODY,5609
462
+ pyarrow/include/arrow/util/visibility.h,sha256=zuHLTwNcR34LcCtbhj1YXzfNL8NxO-3XHY_UgUJgdZY,3238
463
+ pyarrow/include/arrow/util/windows_compatibility.h,sha256=Chme9fWRqYRzfIbLw7V_yeiIWd3F4dFeG6ImHHr4Xqw,1255
464
+ pyarrow/include/arrow/util/windows_fixup.h,sha256=hjoh6zvB8u8OVUQqLtdcrmohMzoAoLy6XJFLxcfFhK0,1435
465
+ pyarrow/include/arrow/vendored/ProducerConsumerQueue.h,sha256=Bz1ks3NDgXXLfT8TMUkE38RpMOSwKRRtwU1e37Y1CUw,6101
466
+ pyarrow/include/arrow/vendored/datetime.h,sha256=tsFbz8LKBFzRzTEOAKZyWRbdFLfnCnZRCK9Tyi1PANs,1103
467
+ pyarrow/include/arrow/vendored/datetime/date.h,sha256=fa_tmkMHwmx9vZHjH5lZVhZFCYEcHi5xmueW3F1tDE4,237808
468
+ pyarrow/include/arrow/vendored/datetime/ios.h,sha256=Qnu0iuy2-ein9KkVoSL1t71_W_VFZkdjDVsOnYTnP38,1641
469
+ pyarrow/include/arrow/vendored/datetime/tz.h,sha256=m5JJv7LE7Vukp8h50r90sCfbOSAD2bMVIVQUUxNZeDQ,85347
470
+ pyarrow/include/arrow/vendored/datetime/tz_private.h,sha256=pDkKXYdzfzQ5uh-jcUhURBLqHo00t0UnlimUdiM53Cs,10706
471
+ pyarrow/include/arrow/vendored/datetime/visibility.h,sha256=VCGKzhQOgL1zwGXKl_7lLULfSy0OsPt8FLWHwA4sOtU,1002
472
+ pyarrow/include/arrow/vendored/double-conversion/bignum-dtoa.h,sha256=imGhcg0RywMsFNMYTqp6rlXw2HZCIAla8SC_n92gCqE,4358
473
+ pyarrow/include/arrow/vendored/double-conversion/bignum.h,sha256=RnQ2CPL8Pt6fVCGh_8VDF11e_GyrrwO0IH0uMnTcsEs,5949
474
+ pyarrow/include/arrow/vendored/double-conversion/cached-powers.h,sha256=jjwfR3bue7mNlE5lbTrFR2KlgjRew2OkmjBa7oQO0Qg,3079
475
+ pyarrow/include/arrow/vendored/double-conversion/diy-fp.h,sha256=J-RgqH27jspT5Ubth9pTA9NAZH6e7n1OVhxModgi8Sc,5088
476
+ pyarrow/include/arrow/vendored/double-conversion/double-conversion.h,sha256=J1Tl5-8aFY0A9SnaA9z5Q90jnMxw55illPIuE-jdD5Q,1804
477
+ pyarrow/include/arrow/vendored/double-conversion/double-to-string.h,sha256=C-tKRi0IuLycXgS6CC1oiFkCroOo_-AO0VOjmfe0tlE,23925
478
+ pyarrow/include/arrow/vendored/double-conversion/fast-dtoa.h,sha256=ZAho25fqeP3t2RM0XgqfhTBXQIIicACLpdyHHMRX3JU,4122
479
+ pyarrow/include/arrow/vendored/double-conversion/fixed-dtoa.h,sha256=HLnpxkHjKldm-FBiDRbADYljJBSYbQGP4Gz-sVbiSJU,2828
480
+ pyarrow/include/arrow/vendored/double-conversion/ieee.h,sha256=CVKA9RXSjv4ZygqDHMiF-H2hUh3QHQvp1GZYC3MAhkE,15281
481
+ pyarrow/include/arrow/vendored/double-conversion/string-to-double.h,sha256=Ul6b-2R0pjUaAWNM3Ki4kH933LqrW6_XfPz4BSiE2v8,10906
482
+ pyarrow/include/arrow/vendored/double-conversion/strtod.h,sha256=6xCRm47vmcghYJug5mhhTVbsZ3m3Y6tQfMehEyVZNx0,3096
483
+ pyarrow/include/arrow/vendored/double-conversion/utils.h,sha256=wFRb5cGABiNoUSCnvKmdv_KIMcBtX1PX89tPFfvgbQI,15614
484
+ pyarrow/include/arrow/vendored/pcg/pcg_extras.hpp,sha256=FEYzq8NFxPfdJyLs4kVtTBLkaD6iO71INz9EJnaxTdc,19784
485
+ pyarrow/include/arrow/vendored/pcg/pcg_random.hpp,sha256=7TaV3nZhcwpf6XxlZ6cod1GaW5gm-iUn67t2fiMPNbA,73501
486
+ pyarrow/include/arrow/vendored/pcg/pcg_uint128.hpp,sha256=DyavmKgq9ob13z--Lee8WKfiMBk1cvKhkZlDxQyQNOA,28750
487
+ pyarrow/include/arrow/vendored/portable-snippets/debug-trap.h,sha256=9KphJ9gRtDT9DXR9iZ7aS23xa2T8tLmLsFEJMg0pLDQ,3081
488
+ pyarrow/include/arrow/vendored/safeint/safe_math.h,sha256=HgcHut9A9VZGoZe6A-669uv1N8ydMJE9a3bJzZiOwFA,78099
489
+ pyarrow/include/arrow/vendored/safeint/safe_math_impl.h,sha256=wzI4AvijLrtEg9aTtqoY1SQNOZ1XxsP5GyuN3juC6K4,61119
490
+ pyarrow/include/arrow/vendored/strptime.h,sha256=q1IZi5CvyUp_PNzbQ4_XLroAV24VEovBEz2TkpwUJ9c,1212
491
+ pyarrow/include/arrow/vendored/xxhash.h,sha256=MUwtyzu7xjkx9mBcS65SaDcCK7tgeqQgj-KYEMxcHWc,844
492
+ pyarrow/include/arrow/vendored/xxhash/xxhash.h,sha256=PDFiHmNL4ul4A0wiSLDpY9JSrDS73RMulr1W9aNEW8s,279426
493
+ pyarrow/include/arrow/visit_array_inline.h,sha256=XuQjuME8XZeJp7W86YuCsuoVVgmG1NulXAA0KJkmmB0,2446
494
+ pyarrow/include/arrow/visit_data_inline.h,sha256=4MkdFVsrjhMyTDNrScQtOYV_nwzqR2ddSS2yYnbyLt0,12460
495
+ pyarrow/include/arrow/visit_scalar_inline.h,sha256=KvNY0j8nE9gs_805LXMV3ATgvxvUqW4UeKpXUxR3rMA,2419
496
+ pyarrow/include/arrow/visit_type_inline.h,sha256=O0BURx2TowqdO61W9DJEr5cKP5BsVkUt8Bpc8VuiXec,4387
497
+ pyarrow/include/arrow/visitor.h,sha256=NKos98j54uY9tdXzctI_n_nwFRrXNOwanxLDqDZONw4,8690
498
+ pyarrow/include/arrow/visitor_generate.h,sha256=n2YKZW-5hY7ICQSwEUBZIYh2eg9ZoTfD54XRd9OlNDo,3324
499
+ pyarrow/include/parquet/api/io.h,sha256=Ricq0d2R4QXHiGZCbjxZ_0F_QmKq0IrfTidNu5NoXPI,847
500
+ pyarrow/include/parquet/api/reader.h,sha256=vnM5XDPn1TVsDJk4SDgb3ZU2Ta4vdrRzCpDWO90rYHk,1204
501
+ pyarrow/include/parquet/api/schema.h,sha256=KsNJ529pEh7bGUa0rLUCcfanI9rW2uSTirgpvKq0hdc,855
502
+ pyarrow/include/parquet/api/writer.h,sha256=UJZbY8QGVRMtAmozzjoM9TnI4gssqlNFUKCXBw2IfuI,1007
503
+ pyarrow/include/parquet/arrow/reader.h,sha256=oZXb2Oof-MH37vKuq58SucwtWnBlZ57M5PsrgUnURBw,16361
504
+ pyarrow/include/parquet/arrow/schema.h,sha256=Mi56ul7itNS6NDbMpKOJCufjHVqaSY5_rbsNRNLE560,6204
505
+ pyarrow/include/parquet/arrow/test_util.h,sha256=qCUHfC-7P2D32n2__AV35MbzKoL5KEgNHJQaiElFx6M,18849
506
+ pyarrow/include/parquet/arrow/writer.h,sha256=0edx0fgyze6uxTgpDyacSljKMUay86pRqvIRQ7AZpXk,7005
507
+ pyarrow/include/parquet/benchmark_util.h,sha256=emDpaIbtfUNlK0M2zMP-oTy2S2raQ-LpQULK_G74OtM,1758
508
+ pyarrow/include/parquet/bloom_filter.h,sha256=TC3OxK0J2v6tHxT_Bbw7mlYtM0603KXgBoHRvmzM9aA,14999
509
+ pyarrow/include/parquet/bloom_filter_reader.h,sha256=63kpHYKs5TPrbRamkBLZsDYbD-I9UeVhF-R8d7JHeLg,2892
510
+ pyarrow/include/parquet/column_page.h,sha256=7w2hQDqkIhqpHLRh2LHk0ujnuknSPHVtuvJ21LS--n0,6942
511
+ pyarrow/include/parquet/column_reader.h,sha256=HQPo-owohtevjPItqajvEDWj8OR1u6oW6i9xvjP9Yiw,19255
512
+ pyarrow/include/parquet/column_scanner.h,sha256=HecBvh-z0n_1HJsD-GIdcGHQAvDOHKlLzppB9RBsD9s,8863
513
+ pyarrow/include/parquet/column_writer.h,sha256=lDOsSuqIxI8e8hTdAvZfBm-b0D6uMfpC1L5HLykE3bo,12452
514
+ pyarrow/include/parquet/encoding.h,sha256=SDGAMKCvNwOz92WiadNmhVO2bPG-IVUJJ4vb_pShtpo,16872
515
+ pyarrow/include/parquet/encryption/crypto_factory.h,sha256=NutbypTw9971ju95UkWtW-g8TYnR94TWZAnx5-dznPA,7064
516
+ pyarrow/include/parquet/encryption/encryption.h,sha256=pXcGO8WhWVzaS8hDrphLS_M2sHX0mtGMCs4G9d3ZA1c,16552
517
+ pyarrow/include/parquet/encryption/file_key_material_store.h,sha256=YzAVO3M2H5v5Fz2b_WlmB3GE5wVbMEnFTL3S9XPH6k0,2200
518
+ pyarrow/include/parquet/encryption/file_key_unwrapper.h,sha256=VBuBwYeLqYHq_WGnjL2tfwB6mH3jjFVb-TpPKa6lb50,4717
519
+ pyarrow/include/parquet/encryption/file_key_wrapper.h,sha256=xXlS-yyYhUW20S31REsSj5JxbVbij_td0WlPbgxNaYg,3778
520
+ pyarrow/include/parquet/encryption/file_system_key_material_store.h,sha256=xAccp-7Il2UrnItxLmOE4ywhQKgeapyxVNwshDpan0Y,3695
521
+ pyarrow/include/parquet/encryption/key_encryption_key.h,sha256=6dJNBYA_4Z_dyMph71Q5KI0axe-yzdjTnRgG_zj2OX0,2318
522
+ pyarrow/include/parquet/encryption/key_material.h,sha256=kPTSIuRFYOnH4BCPIB33zG9hp5D2Ba-5kZVlq3rFnRI,6221
523
+ pyarrow/include/parquet/encryption/key_metadata.h,sha256=Pc0nA9LW3Fc9NLMMxz7osbw8si2jSiOVTES-J-9R0y0,4003
524
+ pyarrow/include/parquet/encryption/key_toolkit.h,sha256=xLHCsTK6bcrXd_MQv7GDTrLoZNeE_-WFb192LdYpcH0,4645
525
+ pyarrow/include/parquet/encryption/kms_client.h,sha256=MM870qRC_yc4hkzx7xVPaPm12ErR8sqFgDTHLWHcRX0,3222
526
+ pyarrow/include/parquet/encryption/kms_client_factory.h,sha256=VZ97CMgDQxx5oZWFGprjXsaM1hZ0wNudPmFU1_lniAc,1293
527
+ pyarrow/include/parquet/encryption/local_wrap_kms_client.h,sha256=dW5Fe3lUHP8dmsSPDGMbldGl2GlnER4I9zWhCU6g_78,4037
528
+ pyarrow/include/parquet/encryption/test_encryption_util.h,sha256=rYdlDq1nmZu3gsc7vPcBDVOwdxESyVcnVTDCNMPdmoA,5349
529
+ pyarrow/include/parquet/encryption/test_in_memory_kms.h,sha256=c6GA-eObXQtCtzehYKr4uGMpjtLRUW0C5VIQQk8EynM,3743
530
+ pyarrow/include/parquet/encryption/two_level_cache_with_expiration.h,sha256=2kNvixV36bYjUlUJquqnaaOO-NI7e8O3Vm1x-xDPyDA,4818
531
+ pyarrow/include/parquet/encryption/type_fwd.h,sha256=dL8snyUwNjhTQE2FQ2dXAUjTboEXhH2JOehQovHfixc,955
532
+ pyarrow/include/parquet/exception.h,sha256=TJbx6X_khxV6e61rUfHY0Pr65EoxKTu2xpvOAdh9BMo,6104
533
+ pyarrow/include/parquet/file_reader.h,sha256=Z1RiOP74Y9tMv7kZ7FWX05IR05qzgSOTRKrY71pLOJE,11185
534
+ pyarrow/include/parquet/file_writer.h,sha256=6fK6Mn-MdiQ-J4oo8BTi_eVVVshlffoQiJzFaLRrqco,9343
535
+ pyarrow/include/parquet/geospatial/statistics.h,sha256=77ieKxQcY46FB7jgCZhk03fa2G_J2S9NJ8R0_JU-qGs,8892
536
+ pyarrow/include/parquet/hasher.h,sha256=z_U9ojA6y_f4AQtYP6DhuUWp-MX3uywCHd4aWDXAqyE,5242
537
+ pyarrow/include/parquet/level_comparison.h,sha256=5z4fUJJPWq9W60l2CsAI7T7E2auGYD7m0fpR5rfLmsw,1306
538
+ pyarrow/include/parquet/level_comparison_inc.h,sha256=r20_6Rv5L7UmFGJ68f-JaZ5hLXb87wvZa80hZNQoF-I,2494
539
+ pyarrow/include/parquet/level_conversion.h,sha256=OsuqK1xiUnEnOLPKwfm9X-pXTaXRMlDIkj3lwGb2ggI,9432
540
+ pyarrow/include/parquet/level_conversion_inc.h,sha256=Q_ZZ-Ody9s8rSZlBzIwNcgcPikXtnAcv475gCgqRk5o,14248
541
+ pyarrow/include/parquet/metadata.h,sha256=HA2wE85mSzg37qqsxGmolMYpBLaSSwdiwxkeQOP1n_g,21191
542
+ pyarrow/include/parquet/page_index.h,sha256=AqvLT6M81jY13YbpX-s-hOzCVz0AGNkZJ9om3_tp4Vk,17307
543
+ pyarrow/include/parquet/parquet_version.h,sha256=57JJTZUgqXX1m2WHAKXRKKn15LVMK1X-Q8zSXhnYJkg,1164
544
+ pyarrow/include/parquet/platform.h,sha256=DUf6vCMAV4eS-dOZzHDE7G_EAGIwDaQ-J3X3bpY8rgk,3939
545
+ pyarrow/include/parquet/printer.h,sha256=hXqzwuj5p1oKY2awZkVOq7qXx-Rsoo6QPH1oTE94AHU,1548
546
+ pyarrow/include/parquet/properties.h,sha256=YNL9gevyuQMsCjo3znl5xyleCDsI-KnFA8_G6JWn_n8,57689
547
+ pyarrow/include/parquet/schema.h,sha256=CjZh2i9WN5VeoDbLqy7M1AZtopZ43_C9blWG3OT2IfU,18222
548
+ pyarrow/include/parquet/size_statistics.h,sha256=Ahr8qyIVre8U_JVRLHL0BbSoYpdJjo2OUeE1UD4I1tw,4327
549
+ pyarrow/include/parquet/statistics.h,sha256=3LFLy_k0KuIjsYBZWFJJShrkHIEm8Zk_QRDfRKj_9XA,18005
550
+ pyarrow/include/parquet/stream_reader.h,sha256=1WmN0vYCqTz1Lwb_Di4xPWTE-VbCQQuzZralSpWQm3U,8791
551
+ pyarrow/include/parquet/stream_writer.h,sha256=NIC3WYnGNPZxJm3k8Bms5A5wtg8OXj1li9JPbdPSGxA,7831
552
+ pyarrow/include/parquet/test_util.h,sha256=VHF8cjNduIW8P6Kw2sLUJmvbL7tmTG_kWIWOaC7G5OA,33538
553
+ pyarrow/include/parquet/type_fwd.h,sha256=xmvMW2wSIFvoEZBwVql7hzcPBzOHZnmTlEtIjwp_pzM,3065
554
+ pyarrow/include/parquet/types.h,sha256=mOx1d2y3BhZv5CXdAtylBFBvkMflOdJG_uWNamBFJKQ,27304
555
+ pyarrow/include/parquet/windows_compatibility.h,sha256=xIEGHW354URgdIP9A4V303TJL8A1IkCEvp08bMKsHTU,897
556
+ pyarrow/include/parquet/windows_fixup.h,sha256=DpyWCywx8YIqouun6BJcgMrHFMTCBgowWdJ1mnJnQ2s,1052
557
+ pyarrow/include/parquet/xxhasher.h,sha256=QAa7ZE7S3UFtU_Voz3oi3YclIYhbhviJkafLOYgiuWg,2074
558
+ pyarrow/includes/__init__.pxd,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
559
+ pyarrow/includes/common.pxd,sha256=me4htiESPFmZok1M8eDXk9OS-7p9Om_1pazNowvttuc,4950
560
+ pyarrow/includes/libarrow.pxd,sha256=fP5_tqqVqGtS1my5j9-UxTv3NHNI4oBDPjbBcikTu2A,121041
561
+ pyarrow/includes/libarrow_acero.pxd,sha256=c84RdYfIuFWW_36-1RELJsowfQwXhgUxbdC_xKQyFCI,5298
562
+ pyarrow/includes/libarrow_cuda.pxd,sha256=0fRcHbCZY_gFdwIXIElnpGvTxeA5xVxZH1-vwZh16SM,4942
563
+ pyarrow/includes/libarrow_dataset.pxd,sha256=cqV1LQvfsKtRwePFaWUh8dCFlb6JED8tLGCsrtS_Ml8,17270
564
+ pyarrow/includes/libarrow_dataset_parquet.pxd,sha256=PW8g6CD2yjwgwoJgYQ9Ntg2e2v6Vfu4AYL5kiM4sq0Q,4584
565
+ pyarrow/includes/libarrow_feather.pxd,sha256=MTJUDQbfKP8Ir700Fobl7xcbjX7WcrsUV4mxFXlfwn0,2140
566
+ pyarrow/includes/libarrow_flight.pxd,sha256=QO7RJ5TUVA65gtkJLenjIOEW2eIbPuKLw-nGWD9oHRY,24724
567
+ pyarrow/includes/libarrow_fs.pxd,sha256=PHdXeBI1oD-fLV_POryp-kcyt5084X0DdP3N0aLRmNQ,15379
568
+ pyarrow/includes/libarrow_python.pxd,sha256=6RxtLurxWwDzN-GtJ7Mo0qXoNnP3mOU8DcavIdumXM4,11647
569
+ pyarrow/includes/libarrow_substrait.pxd,sha256=PtgwVFqsCQBzCHzK-VqhQOdTyU9J4SziQ_lnxRwChfs,4061
570
+ pyarrow/includes/libgandiva.pxd,sha256=o28v4Q43dYXQEcwldKO6RYs0tke2U6GZVxQmjq4rAt4,11530
571
+ pyarrow/includes/libparquet.pxd,sha256=dDV_i74prFbqBrYQ8bn2Jfp1CCChHznNAckD81VJZkw,26321
572
+ pyarrow/includes/libparquet_encryption.pxd,sha256=oyvw0ZLyLWrHwMiOt6mbWYyTKb3rN9kmjOMMW1P2EsM,8690
573
+ pyarrow/interchange/__init__.py,sha256=DH0bwbKpdjD1WCW1VinnXEuVLY098uHKkirv7DFc9JM,845
574
+ pyarrow/interchange/__pycache__/__init__.cpython-310.pyc,,
575
+ pyarrow/interchange/__pycache__/buffer.cpython-310.pyc,,
576
+ pyarrow/interchange/__pycache__/column.cpython-310.pyc,,
577
+ pyarrow/interchange/__pycache__/dataframe.cpython-310.pyc,,
578
+ pyarrow/interchange/__pycache__/from_dataframe.cpython-310.pyc,,
579
+ pyarrow/interchange/buffer.py,sha256=NF_GU1uQ6INqHqCwzY6XQQqRxKDh6znEeDHiRqaEIQ0,3359
580
+ pyarrow/interchange/column.py,sha256=n9f3mlViqUFOa3Kofdwoo52qC-WYVpyF2YilRsl4uaw,19350
581
+ pyarrow/interchange/dataframe.py,sha256=tmSMmBvBAc-ZSUzE8tBNbvQLHuuxLuBkMkK6KYwtS8M,8405
582
+ pyarrow/interchange/from_dataframe.py,sha256=JfkP4wuY_9x76H6RDtmsOzs6B6qe-1WS7zxpKeD481s,19709
583
+ pyarrow/io.pxi,sha256=gDtFPrwdBrxT88jpNwddg9mM-KSt_XFv333W2IbF3I4,86228
584
+ pyarrow/ipc.pxi,sha256=NTZxt0qAu-HIjDbbczp91sKUJoJQBz48z-IxcKn9b6w,44752
585
+ pyarrow/ipc.py,sha256=ssicn1x2jRZt2m1nQZ4sB70sa1FB3d8PoqiOnWO-tzg,9603
586
+ pyarrow/json.py,sha256=JMEXB5jNZp-DOYmGBrzs2RtwOCLdKCRa3E5kUfH0Ceg,869
587
+ pyarrow/jvm.py,sha256=_cyen6Bi-cBUlg-OAb_RTG6nj2W57kMrR1HuAWVcEQs,9577
588
+ pyarrow/lib.cpython-310-x86_64-linux-gnu.so,sha256=weFjiFPhFN9tT2nNPpxEW_6Gu8tpRp0TGhiQhj6TtyI,4283368
589
+ pyarrow/lib.h,sha256=NSqX1jl5ZWssVm0SmNFHp4PckJYy8YCJxlL02MKa4Uc,4562
590
+ pyarrow/lib.pxd,sha256=HHKBlMGhU4NkQKqPcTCkYPojbExu2jSt8C4YTeCWdck,17838
591
+ pyarrow/lib.pyx,sha256=cssmzMbq2cOOgMLKQUSkLwvXRmS46ED6U-8d4B91bUo,6174
592
+ pyarrow/lib_api.h,sha256=rm6EBrvNbQHNzt_TJGbbdIo5T_1IC2WBAXIQnpMzsNA,20132
593
+ pyarrow/libarrow.so.2300,sha256=0wrfak57rAFFaA5nzu0-nS_0ospXmhR8-IFaaUmixC4,52334816
594
+ pyarrow/libarrow_acero.so.2300,sha256=bpsqCjL8Fp1diKCNfJH5FvZzVff9Ks_jlv9FEzic4T4,1899056
595
+ pyarrow/libarrow_compute.so.2300,sha256=K0xSJnlFmhYopvdcPEojr1iSJutmPhzCAh6f6sr2vEQ,18887496
596
+ pyarrow/libarrow_dataset.so.2300,sha256=KRgRLNGSuhCKjqdqPdIYOw0vozKKIqDHC5rqBbjzlnU,2331344
597
+ pyarrow/libarrow_flight.so.2300,sha256=FHZ-B9W3uPrH0z9WFoCjLQFpW4h5CNeGW9PTaLARleA,26444648
598
+ pyarrow/libarrow_python.so,sha256=IUO7OhzaWJk7G0ptfwsdECSFUlfv723dv2h_F1EEKm0,2342392
599
+ pyarrow/libarrow_python.so.2300,sha256=IUO7OhzaWJk7G0ptfwsdECSFUlfv723dv2h_F1EEKm0,2342392
600
+ pyarrow/libarrow_python.so.2300.1.0,sha256=IUO7OhzaWJk7G0ptfwsdECSFUlfv723dv2h_F1EEKm0,2342392
601
+ pyarrow/libarrow_python_flight.so,sha256=B52L6RjU5pvT7_o2AmoeV2Tr1uPJmhl-A6vGO6YJy8I,104024
602
+ pyarrow/libarrow_python_flight.so.2300,sha256=B52L6RjU5pvT7_o2AmoeV2Tr1uPJmhl-A6vGO6YJy8I,104024
603
+ pyarrow/libarrow_python_flight.so.2300.1.0,sha256=B52L6RjU5pvT7_o2AmoeV2Tr1uPJmhl-A6vGO6YJy8I,104024
604
+ pyarrow/libarrow_python_parquet_encryption.so,sha256=e3JVUNOPI0fCLFXewNtovNzMTMXXZAnAy9vSgb9x7H4,38448
605
+ pyarrow/libarrow_python_parquet_encryption.so.2300,sha256=e3JVUNOPI0fCLFXewNtovNzMTMXXZAnAy9vSgb9x7H4,38448
606
+ pyarrow/libarrow_python_parquet_encryption.so.2300.1.0,sha256=e3JVUNOPI0fCLFXewNtovNzMTMXXZAnAy9vSgb9x7H4,38448
607
+ pyarrow/libarrow_substrait.so.2300,sha256=RBpdd1C8B9s5t7wDcr8_OOe34qEcW45r0-g1NO5aXuo,5761616
608
+ pyarrow/libparquet.so.2300,sha256=BUZNufKfPjxyvaUGJbLDrhWTGyp13-o1KghADaTxoU8,12416216
609
+ pyarrow/memory.pxi,sha256=cZSlJ8Brteb9aWa7VzvCrpnw26wRkplF9KtF2nqtH8M,8806
610
+ pyarrow/orc.py,sha256=yDp3vD4gOdOsOBmXKFe24Kq3xO3FDBfIOHvsvzQUkKY,12602
611
+ pyarrow/pandas-shim.pxi,sha256=RM38cacj1TlQ5IN79CprIr4AUbbY5GiWdiLsnx0zn3g,8817
612
+ pyarrow/pandas_compat.py,sha256=y1dLv-lrnpJleFwWnSO5_rBM-Uwky6ZgtKUMYTPhbN8,45916
613
+ pyarrow/parquet/__init__.py,sha256=4W64CbvwvO60tG58nfNtyCwMVCfuPumtu82p-kiGPaE,822
614
+ pyarrow/parquet/__pycache__/__init__.cpython-310.pyc,,
615
+ pyarrow/parquet/__pycache__/core.cpython-310.pyc,,
616
+ pyarrow/parquet/__pycache__/encryption.cpython-310.pyc,,
617
+ pyarrow/parquet/core.py,sha256=0-Te7kjeh7zKT3jd4VBK2IMOycQ3uHwjzqgqRFY6aro,95541
618
+ pyarrow/parquet/encryption.py,sha256=-XW7Qcbl-jQhpZsR610uQ8-z9ZVE_NL045Jdnp1TZ9M,1153
619
+ pyarrow/public-api.pxi,sha256=G6tk0gOWMBoQaQGo4lyp0OLSkqEZqMhB0z27MoQR3rU,14064
620
+ pyarrow/scalar.pxi,sha256=2-ttwuILFVqcf8gcMBWbEkwA-3vdnxGN-8ah6YDvrlA,52384
621
+ pyarrow/src/arrow/python/CMakeLists.txt,sha256=D4Ypror_508aAd_juYkrS9Qu2maeirK4QXzwGEZEj0M,855
622
+ pyarrow/src/arrow/python/api.h,sha256=2XyYOFAmorPGXrTVYZkiKL67nuH8w1ha6D1reU7K-Vs,1179
623
+ pyarrow/src/arrow/python/arrow_to_pandas.cc,sha256=0lQ5wG_eqXa76QfuHdCr7Uex1yDM7nneD5G62ykDCzg,96642
624
+ pyarrow/src/arrow/python/arrow_to_pandas.h,sha256=jQiSTN8IL95onwaclaWqCR5Nb2RHrBtubRyEOJR9eRE,6215
625
+ pyarrow/src/arrow/python/arrow_to_python_internal.h,sha256=nQXPZTL3xa4Sm-a-Gv-8bpFs-qAOZHkqWmA_m-dSLVw,1740
626
+ pyarrow/src/arrow/python/async.h,sha256=C0f8YYmgwBGgDau4xEFsdjukiZB4YvpylETHEZryHOo,2352
627
+ pyarrow/src/arrow/python/benchmark.cc,sha256=z6qYRx4qMuNXPaC8fuPJlQd92aosMN85u1aD50R1-UU,1293
628
+ pyarrow/src/arrow/python/benchmark.h,sha256=f-kzyMOlPKDse2bcLWhyMrDEMZrG_JHAPpDJgGW0bXU,1192
629
+ pyarrow/src/arrow/python/common.cc,sha256=HExYdSkfggXu96XWNXBvK1XukCfPotLVFtk8D9FVaOw,7603
630
+ pyarrow/src/arrow/python/common.h,sha256=9IQC__JUqTRXv5MfAqKM6ivMwuQ-uMZKEguGDEODkiA,14389
631
+ pyarrow/src/arrow/python/config.cc,sha256=yRQYqXioit9N4uAVyLrBbb70Bto79wh6ZAwvyeX9HBs,1097
632
+ pyarrow/src/arrow/python/config.h,sha256=SQa6SuM3oAfQ7wEbwVJqlPfqslqlq2DXK_FK6-K08Kg,1150
633
+ pyarrow/src/arrow/python/config_internal.h.cmake,sha256=kU0GNa9lLgI7_eJseYzfo-C9s8762Tb1sep47Oux3hk,855
634
+ pyarrow/src/arrow/python/csv.cc,sha256=ql5AY76AqiFksWsrmzSl551k5s9vS8YcmypM2A9rhw8,1803
635
+ pyarrow/src/arrow/python/csv.h,sha256=QxU3B-Hv_RsoEcMGS9-1434ugouL2ygC64Lq6FgviNM,1397
636
+ pyarrow/src/arrow/python/datetime.cc,sha256=WQoJT6a1ocd3SItRC_q8EA5-4Z9sWNdGFxXen3m0xeU,23013
637
+ pyarrow/src/arrow/python/datetime.h,sha256=Bny_THGi2tyUeHxcOuw01O7hNE8B_gave5ABAZQtwTQ,7931
638
+ pyarrow/src/arrow/python/decimal.cc,sha256=4CNaLDOWZelTllSIPdIKDlIhUy6AgKJxKG0WmzJyq94,9699
639
+ pyarrow/src/arrow/python/decimal.h,sha256=K9ScmzSa7XCuuwpXKnq0GPbRDTuRU5yXfWr9zGtOchc,6362
640
+ pyarrow/src/arrow/python/extension_type.cc,sha256=SOhG7u7MNnJkSe-dWi5-ZsGuzQC-M7PihaYFAr6x6hA,7033
641
+ pyarrow/src/arrow/python/extension_type.h,sha256=0gzb42y_mbw4fsYs3u8cwPFLBRlG-kkHQLgbvGtrY0U,3181
642
+ pyarrow/src/arrow/python/filesystem.cc,sha256=0twavI91TE20Otq5kkVUwnN5sindU_mBWoVAvz1ZMgI,6152
643
+ pyarrow/src/arrow/python/filesystem.h,sha256=FG0AcLekqaDf9IQPqKixAfIcY_ZLgIKP5NvvXdtBVUM,5126
644
+ pyarrow/src/arrow/python/flight.cc,sha256=tL3nFVTjDlmiuqDOSxf7HODdpqIMUSbSsNc1vaveP1w,14192
645
+ pyarrow/src/arrow/python/flight.h,sha256=t4ZD8gWaubbO_mBDv0XZ58TCo1VQl0hzHn1_7w4U64I,14450
646
+ pyarrow/src/arrow/python/gdb.cc,sha256=hkATQV6YlpxkBaLfY9_C24XJ6qYSg2T0DfQX4XfpvFY,22556
647
+ pyarrow/src/arrow/python/gdb.h,sha256=H-qvM-nU8a_3Z5tk8PvppTwQtBMSZhQKQIVgRAsRfFg,972
648
+ pyarrow/src/arrow/python/helpers.cc,sha256=MqeJ1PD1g97tKL9suvE1LWD2cO-MWMwo8-ag3FXAauY,16934
649
+ pyarrow/src/arrow/python/helpers.h,sha256=Q3TmwyffFpVYQEp55ZoWTDDhnte7zQKiXylsfbEMCuI,5479
650
+ pyarrow/src/arrow/python/inference.cc,sha256=Wz_zlalsCa4_BWntagf6l7QLb_nONJZKl5TQa4YVMWE,26293
651
+ pyarrow/src/arrow/python/inference.h,sha256=FUFvB4Zy7V-tueXdmbDcqTeLK4xj5GZEeRW5yhiJlsU,2038
652
+ pyarrow/src/arrow/python/io.cc,sha256=k2pgFsCFXaI7naqXcxDtZJJp7K06NnEhsDEoMQvbaxc,11948
653
+ pyarrow/src/arrow/python/io.h,sha256=4jGnodpSUlnVqAVh9fWId7H4WldlLPkXyroABpdaW6w,3858
654
+ pyarrow/src/arrow/python/ipc.cc,sha256=3D9iMbOFHlhNXX4432wsfbfjWvDryZWgdA0Ak19V_8Q,4472
655
+ pyarrow/src/arrow/python/ipc.h,sha256=SZbw6jCCqLiLNCY3k632GmwHeD_r_xrDS0dhqV49VhY,2259
656
+ pyarrow/src/arrow/python/iterators.h,sha256=Ugfm3JvetAH0l-oAjjpZfhrUBqRimVMaw4-xusvqLSg,7327
657
+ pyarrow/src/arrow/python/numpy_convert.cc,sha256=166BIW7zVTRMKogxLUuhV4e5jOevmonvRtXDydNujgc,21194
658
+ pyarrow/src/arrow/python/numpy_convert.h,sha256=y13eHwfe1lJKzadoTr2-GyX6xPsE6Z7FN31s7PN-2Rk,4870
659
+ pyarrow/src/arrow/python/numpy_init.cc,sha256=cJKOH946T7VCcB-gVIoGgfbWTrbj3FPkI4TgnsLTf7s,1178
660
+ pyarrow/src/arrow/python/numpy_init.h,sha256=FniVHP7W2YBlenoMYhQrODvoqqvDMSls2JANGtNPQts,999
661
+ pyarrow/src/arrow/python/numpy_internal.h,sha256=1R_tNINnHYMGNTA5k_BMbGWFlA297f3Yj4ufrhm-yiE,5320
662
+ pyarrow/src/arrow/python/numpy_interop.h,sha256=rI6ek8JTOYtjo7gEADSDBS6QuAOHa2A0YQPZ2GeypFw,3418
663
+ pyarrow/src/arrow/python/numpy_to_arrow.cc,sha256=uuQo_rewpuc882cuFy-uMmtRLR1iMT3Ew3JystLBXfc,31961
664
+ pyarrow/src/arrow/python/numpy_to_arrow.h,sha256=z9KapsuoOSpWILPt9bea7GR4BL6AQ28T6DUO0mSkh3k,2760
665
+ pyarrow/src/arrow/python/parquet_encryption.cc,sha256=5ilofycsTj6IP0RGCUZFHucHN53oZAmx32L6el7RQh0,4408
666
+ pyarrow/src/arrow/python/parquet_encryption.h,sha256=7KjqRuxbO0UxxHikTDvrLH733UVe0uvTf_bQMiI_xCA,5596
667
+ pyarrow/src/arrow/python/platform.h,sha256=AtkGgpUVqPHs9Z8Tm07yb2zN_wOtb2cvlf-5xFBkc4k,1268
668
+ pyarrow/src/arrow/python/pyarrow.cc,sha256=vukhk0aEmqI2QZ54XMwyC3930mJHGUVSSW49GSgifWw,3683
669
+ pyarrow/src/arrow/python/pyarrow.h,sha256=TK3BtD9n3QKOQ9dX3LXbQc0hu9alWcufV0O93iQW7B0,2761
670
+ pyarrow/src/arrow/python/pyarrow_api.h,sha256=7l0G4-_m9yALYoifsY8Z6qh3HHD0PgkpVSgCn_JaGU4,867
671
+ pyarrow/src/arrow/python/pyarrow_lib.h,sha256=-70_Ckj3_0ImlzaXSJOE_d3w9pGM66lXiGPyln9c96Y,863
672
+ pyarrow/src/arrow/python/python_test.cc,sha256=7WZnh-qh0SvzAin20DHAAd_vdcj2EZQYCNhgqyECdN0,33047
673
+ pyarrow/src/arrow/python/python_test.h,sha256=ea32mM20uHySlygi9MtVxr26O-ydTZHCUQIlxaIMjT4,1195
674
+ pyarrow/src/arrow/python/python_to_arrow.cc,sha256=DjnP866Q8RUY9WnE8moCI5nExs5Rni4oYz2kuytZ0-8,47894
675
+ pyarrow/src/arrow/python/python_to_arrow.h,sha256=BoVytf6P7PBYXyznchElKZSFvEsFyimB-tLFdw0AUNo,2521
676
+ pyarrow/src/arrow/python/type_traits.h,sha256=U7dW4sajVVmjXALsP-B8ZZwI4GgIUG3t-rbp2fwrHWI,10236
677
+ pyarrow/src/arrow/python/udf.cc,sha256=tRd7cPh66N5tU4DdO70F8x1FqODcGZ3HtrYjF4BSs9w,29820
678
+ pyarrow/src/arrow/python/udf.h,sha256=de3R8PhNJO5lT9oCqRxe8e2_SE3jBpHOkwbNqCrlgjQ,3104
679
+ pyarrow/src/arrow/python/util.cc,sha256=Tkgz17XmYFzVybvQ9Vo9LChVo98R5BlbjqCNMHk86DM,1852
680
+ pyarrow/src/arrow/python/util.h,sha256=sP2CEGG7NNqwjrEeNKB-VFqkKxn5P2Tsc0jPUMXQuLg,1732
681
+ pyarrow/src/arrow/python/vendored/CMakeLists.txt,sha256=02XvDJAdKiajCEBOmnMKBpmzbRU7FPkNdlNXtw0-A24,837
682
+ pyarrow/src/arrow/python/vendored/pythoncapi_compat.h,sha256=bzMnlHTCfjk5DQRIxwytunYh5aQxU3iSElaaDyNnAY8,40900
683
+ pyarrow/src/arrow/python/visibility.h,sha256=hwJw5sGrWJckQkNaAuLe4Tf-VDjQbXknyzNOVgZI3FI,1381
684
+ pyarrow/substrait.py,sha256=yOMgCb-A5XW9t2DKgutRydDHpFvQkiNNq6ZIu0hIUB8,1230
685
+ pyarrow/table.pxi,sha256=UY25fBtFThwdRT87cNAadUFJmVYHjSwAxcT7qVVBc4c,208768
686
+ pyarrow/tensor.pxi,sha256=vWs4_2-xeSkFsvL0VMVciIntRWiaH-6QxZyx8j00v1U,43661
687
+ pyarrow/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
688
+ pyarrow/tests/__pycache__/__init__.cpython-310.pyc,,
689
+ pyarrow/tests/__pycache__/arrow_16597.cpython-310.pyc,,
690
+ pyarrow/tests/__pycache__/arrow_39313.cpython-310.pyc,,
691
+ pyarrow/tests/__pycache__/arrow_7980.cpython-310.pyc,,
692
+ pyarrow/tests/__pycache__/conftest.cpython-310.pyc,,
693
+ pyarrow/tests/__pycache__/pandas_examples.cpython-310.pyc,,
694
+ pyarrow/tests/__pycache__/pandas_threaded_import.cpython-310.pyc,,
695
+ pyarrow/tests/__pycache__/read_record_batch.cpython-310.pyc,,
696
+ pyarrow/tests/__pycache__/strategies.cpython-310.pyc,,
697
+ pyarrow/tests/__pycache__/test_acero.cpython-310.pyc,,
698
+ pyarrow/tests/__pycache__/test_adhoc_memory_leak.cpython-310.pyc,,
699
+ pyarrow/tests/__pycache__/test_array.cpython-310.pyc,,
700
+ pyarrow/tests/__pycache__/test_builder.cpython-310.pyc,,
701
+ pyarrow/tests/__pycache__/test_cffi.cpython-310.pyc,,
702
+ pyarrow/tests/__pycache__/test_compute.cpython-310.pyc,,
703
+ pyarrow/tests/__pycache__/test_convert_builtin.cpython-310.pyc,,
704
+ pyarrow/tests/__pycache__/test_cpp_internals.cpython-310.pyc,,
705
+ pyarrow/tests/__pycache__/test_csv.cpython-310.pyc,,
706
+ pyarrow/tests/__pycache__/test_cuda.cpython-310.pyc,,
707
+ pyarrow/tests/__pycache__/test_cuda_numba_interop.cpython-310.pyc,,
708
+ pyarrow/tests/__pycache__/test_cython.cpython-310.pyc,,
709
+ pyarrow/tests/__pycache__/test_dataset.cpython-310.pyc,,
710
+ pyarrow/tests/__pycache__/test_dataset_encryption.cpython-310.pyc,,
711
+ pyarrow/tests/__pycache__/test_deprecations.cpython-310.pyc,,
712
+ pyarrow/tests/__pycache__/test_device.cpython-310.pyc,,
713
+ pyarrow/tests/__pycache__/test_dlpack.cpython-310.pyc,,
714
+ pyarrow/tests/__pycache__/test_exec_plan.cpython-310.pyc,,
715
+ pyarrow/tests/__pycache__/test_extension_type.cpython-310.pyc,,
716
+ pyarrow/tests/__pycache__/test_feather.cpython-310.pyc,,
717
+ pyarrow/tests/__pycache__/test_flight.cpython-310.pyc,,
718
+ pyarrow/tests/__pycache__/test_flight_async.cpython-310.pyc,,
719
+ pyarrow/tests/__pycache__/test_fs.cpython-310.pyc,,
720
+ pyarrow/tests/__pycache__/test_gandiva.cpython-310.pyc,,
721
+ pyarrow/tests/__pycache__/test_gdb.cpython-310.pyc,,
722
+ pyarrow/tests/__pycache__/test_io.cpython-310.pyc,,
723
+ pyarrow/tests/__pycache__/test_ipc.cpython-310.pyc,,
724
+ pyarrow/tests/__pycache__/test_json.cpython-310.pyc,,
725
+ pyarrow/tests/__pycache__/test_jvm.cpython-310.pyc,,
726
+ pyarrow/tests/__pycache__/test_memory.cpython-310.pyc,,
727
+ pyarrow/tests/__pycache__/test_misc.cpython-310.pyc,,
728
+ pyarrow/tests/__pycache__/test_orc.cpython-310.pyc,,
729
+ pyarrow/tests/__pycache__/test_pandas.cpython-310.pyc,,
730
+ pyarrow/tests/__pycache__/test_scalars.cpython-310.pyc,,
731
+ pyarrow/tests/__pycache__/test_schema.cpython-310.pyc,,
732
+ pyarrow/tests/__pycache__/test_sparse_tensor.cpython-310.pyc,,
733
+ pyarrow/tests/__pycache__/test_strategies.cpython-310.pyc,,
734
+ pyarrow/tests/__pycache__/test_substrait.cpython-310.pyc,,
735
+ pyarrow/tests/__pycache__/test_table.cpython-310.pyc,,
736
+ pyarrow/tests/__pycache__/test_tensor.cpython-310.pyc,,
737
+ pyarrow/tests/__pycache__/test_types.cpython-310.pyc,,
738
+ pyarrow/tests/__pycache__/test_udf.cpython-310.pyc,,
739
+ pyarrow/tests/__pycache__/test_util.cpython-310.pyc,,
740
+ pyarrow/tests/__pycache__/test_without_numpy.cpython-310.pyc,,
741
+ pyarrow/tests/__pycache__/util.cpython-310.pyc,,
742
+ pyarrow/tests/__pycache__/wsgi_examples.cpython-310.pyc,,
743
+ pyarrow/tests/arrow_16597.py,sha256=DNb41h9E3ITGvAJJu86i5SfsKrwstQJ0E5gT_bpTS_k,1354
744
+ pyarrow/tests/arrow_39313.py,sha256=0pyBixoX38fldTPO1Vwshi_H0XBACrz8esYoL4o71KI,1431
745
+ pyarrow/tests/arrow_7980.py,sha256=tZKb_tRLfxHaosDk9Yu2GLEsJjMaruXD5CKhbK_6Hq8,1094
746
+ pyarrow/tests/bound_function_visit_strings.pyx,sha256=vDEFoNYR8BWNkCntKDuBUT8sXNRBex_5G2bFKogr1Bs,2026
747
+ pyarrow/tests/conftest.py,sha256=yhbHWUARnpRonmxVtXkPv7YBOr_K-B0DRWfkrW4wnCE,10386
748
+ pyarrow/tests/data/feather/v0.17.0.version.2-compression.lz4.feather,sha256=qzcc7Bo4OWBXYsyyKdDJwdTRstMqB1Zz0GiGYtndBnE,594
749
+ pyarrow/tests/data/orc/README.md,sha256=_4X5XszZqQtWAVEz5N1Va4VyyayGQgNDKrcdMX2Ib4s,932
750
+ pyarrow/tests/data/orc/TestOrcFile.emptyFile.jsn.gz,sha256=xLjAXd-3scx3DCyeAsmxTO3dv1cj9KRvYopKe5rQNiI,50
751
+ pyarrow/tests/data/orc/TestOrcFile.emptyFile.orc,sha256=zj0579dQBXhF7JuB-ZphkmQ81ybLo6Ca4zPV4HXoImY,523
752
+ pyarrow/tests/data/orc/TestOrcFile.test1.jsn.gz,sha256=kLxmwMVHtfzpHqBztFjfY_PTCloaXpfHq9DDDszb8Wk,323
753
+ pyarrow/tests/data/orc/TestOrcFile.test1.orc,sha256=A4JxgMCffTkz9-XT1QT1tg2TlYZRRz1g7iIMmqzovqA,1711
754
+ pyarrow/tests/data/orc/TestOrcFile.testDate1900.jsn.gz,sha256=oWf7eBR3ZtOA91OTvdeQJYos1an56msGsJwhGOan3lo,182453
755
+ pyarrow/tests/data/orc/TestOrcFile.testDate1900.orc,sha256=nYsVYhUGGOL80gHj37si_vX0dh8QhIMSeU4sHjNideM,30941
756
+ pyarrow/tests/data/orc/decimal.jsn.gz,sha256=kTEyYdPDAASFUX8Niyry5mRDF-Y-LsrhSAjbu453mvA,19313
757
+ pyarrow/tests/data/orc/decimal.orc,sha256=W5cV2WdLy4OrSTnd_Qv5ntphG4TcB-MyG4UpRFwSxJY,16337
758
+ pyarrow/tests/data/parquet/v0.7.1.all-named-index.parquet,sha256=YPGUXtw-TsOPbiNDieZHobNp3or7nHhAxJGjmIDAyqE,3948
759
+ pyarrow/tests/data/parquet/v0.7.1.column-metadata-handling.parquet,sha256=7sebZgpfdcP37QksT3FhDL6vOA9gR6GBaq44NCVtOYw,2012
760
+ pyarrow/tests/data/parquet/v0.7.1.parquet,sha256=vmdzhIzpBbmRkq3Gjww7KqurfSFNtQuSpSIDeQVmqys,4372
761
+ pyarrow/tests/data/parquet/v0.7.1.some-named-index.parquet,sha256=VGgSjqihCRtdBxlUcfP5s3BSR7aUQKukW-bGgJLf_HY,4008
762
+ pyarrow/tests/extensions.pyx,sha256=UVfIEnGYy2SDiYkMW6jp6zTo1tvO7gUREH4OGEWjU2k,3046
763
+ pyarrow/tests/interchange/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
764
+ pyarrow/tests/interchange/__pycache__/__init__.cpython-310.pyc,,
765
+ pyarrow/tests/interchange/__pycache__/test_conversion.cpython-310.pyc,,
766
+ pyarrow/tests/interchange/__pycache__/test_interchange_spec.cpython-310.pyc,,
767
+ pyarrow/tests/interchange/test_conversion.py,sha256=23e5tpKBL-ekA5uWpM6-f6HVPF937Hnzfune0Ty9moo,18609
768
+ pyarrow/tests/interchange/test_interchange_spec.py,sha256=AwqwD8b2gV1f5HERtzG6UtOIshFGafUI_9CQOVLPnho,9381
769
+ pyarrow/tests/pandas_examples.py,sha256=SDPL87Ea997nGi7afOqlceq6wH4Bh5IR5S0fHZV3Acs,5107
770
+ pyarrow/tests/pandas_threaded_import.py,sha256=b_ubLr5dj4dWJht9552qc3S3Yt3fQQgaUH6208oZvHg,1429
771
+ pyarrow/tests/parquet/__init__.py,sha256=dKsXU9M-sJyz2wYIuqwsKM9meOlK_qY6qhmQzIvEpCE,931
772
+ pyarrow/tests/parquet/__pycache__/__init__.cpython-310.pyc,,
773
+ pyarrow/tests/parquet/__pycache__/common.cpython-310.pyc,,
774
+ pyarrow/tests/parquet/__pycache__/conftest.cpython-310.pyc,,
775
+ pyarrow/tests/parquet/__pycache__/encryption.cpython-310.pyc,,
776
+ pyarrow/tests/parquet/__pycache__/test_basic.cpython-310.pyc,,
777
+ pyarrow/tests/parquet/__pycache__/test_compliant_nested_type.cpython-310.pyc,,
778
+ pyarrow/tests/parquet/__pycache__/test_data_types.cpython-310.pyc,,
779
+ pyarrow/tests/parquet/__pycache__/test_dataset.cpython-310.pyc,,
780
+ pyarrow/tests/parquet/__pycache__/test_datetime.cpython-310.pyc,,
781
+ pyarrow/tests/parquet/__pycache__/test_encryption.cpython-310.pyc,,
782
+ pyarrow/tests/parquet/__pycache__/test_metadata.cpython-310.pyc,,
783
+ pyarrow/tests/parquet/__pycache__/test_pandas.cpython-310.pyc,,
784
+ pyarrow/tests/parquet/__pycache__/test_parquet_file.cpython-310.pyc,,
785
+ pyarrow/tests/parquet/__pycache__/test_parquet_writer.cpython-310.pyc,,
786
+ pyarrow/tests/parquet/common.py,sha256=ezd4yAsRXI1R-MxE1iIbyHHIlEGyKumckQzVHAx46rM,6149
787
+ pyarrow/tests/parquet/conftest.py,sha256=CyKJlVT-pQNb2f2BwlUaIAoWtobcZ65Y0vgpGX2ttnA,3157
788
+ pyarrow/tests/parquet/encryption.py,sha256=Nr232E2ueexYXGWNZQOfQpw3LkPTbSNHWSfwf1DuBVI,5218
789
+ pyarrow/tests/parquet/test_basic.py,sha256=0tZ7Y8-Df2O4e-QavU2s0RR8xHuIVf3cIdAAWrJPH_0,36873
790
+ pyarrow/tests/parquet/test_compliant_nested_type.py,sha256=Lz7tCPrSpv9GrKPMS-eu1LehsCTwz7KdUdCYJ8tF8dE,3901
791
+ pyarrow/tests/parquet/test_data_types.py,sha256=Y_RqQBfDgrxQnOc0IjuHA7ueIOmotH8CMkmqQ4prz9I,19319
792
+ pyarrow/tests/parquet/test_dataset.py,sha256=U144J3RrIA3rCQIJXxpgy5PQVn5-7gYsy-f3pD20nPs,42020
793
+ pyarrow/tests/parquet/test_datetime.py,sha256=A3ZaRj88u0IrlhCNp2KY_A8txrb7y2pKPgEVvI7e7bU,16398
794
+ pyarrow/tests/parquet/test_encryption.py,sha256=eULJdOgRNMrd6klGgW5ElotrejsL9ev_dBz3LG2P9L8,28357
795
+ pyarrow/tests/parquet/test_metadata.py,sha256=340mr8FxLTVfLMSDDDRm8WWblCzRz7FD77mr4BoJodg,27732
796
+ pyarrow/tests/parquet/test_pandas.py,sha256=4r9sip2N0XbkBb6SZuh51SUHJn9BlAtfjbzB3d3Gk_M,23543
797
+ pyarrow/tests/parquet/test_parquet_file.py,sha256=VlsY4JwZUckF5uxDrVlrJRBVnvTmuuajd0h37BMkbOo,13872
798
+ pyarrow/tests/parquet/test_parquet_writer.py,sha256=9-BjKiXjLzgKC0IodiT8KnCtSPBo1ZKinS_spFX8uWs,18215
799
+ pyarrow/tests/pyarrow_cython_example.pyx,sha256=fx6zT1bUb2-cDnwKoG71K3ozpmrNJ53kKQHHJTExGz8,2115
800
+ pyarrow/tests/read_record_batch.py,sha256=9Y0X0h03hUXwOKZz7jBBZSwgIrjxT-FkWIw6pu38Frc,953
801
+ pyarrow/tests/strategies.py,sha256=eJkCeVCPB714DisrR1Q1INIUqIBX9v1rF2lNtBamlTY,15581
802
+ pyarrow/tests/test_acero.py,sha256=t1TIMZJ9zfCYu9V_Mg_i6SvtoIXFo2GZbxDJh3Luu60,18009
803
+ pyarrow/tests/test_adhoc_memory_leak.py,sha256=Pn4PcIbOBRtSJuz9Ar_ocubco0QOMZ-eAE9Bs7Wp4mA,1453
804
+ pyarrow/tests/test_array.py,sha256=m42aqjvL-_hLP2faOY4asW6k7Uy-L4WfhT5vyqx922o,146212
805
+ pyarrow/tests/test_builder.py,sha256=zNEcslLwyb40oYbG7lInQcI81QHMKDOzi1zthw1Je7c,2803
806
+ pyarrow/tests/test_cffi.py,sha256=ZkOKn6qfySL7LPqR-1FAlRS7n8h3npF5WmqSV8eBVg8,26339
807
+ pyarrow/tests/test_compute.py,sha256=cdgZXDHpTVKkuhuGP1ONc4wo_RUavcrY0hSp4V61T9U,157487
808
+ pyarrow/tests/test_convert_builtin.py,sha256=yhFtMOj6Sqx5TyLs6dxQQl9_ceX_Qbm5MmTyEulpDk0,82323
809
+ pyarrow/tests/test_cpp_internals.py,sha256=Xg4CUB6zohQkcYG64Lj_Uf2BscI27Vv0JC_CqNkDQuE,2006
810
+ pyarrow/tests/test_csv.py,sha256=45yAVGgLS7cS5tJpnzz-yEZbrp5PXCbDIVtv-oVZX8w,77863
811
+ pyarrow/tests/test_cuda.py,sha256=81lyEjUUd2UWbeFW-JJECYJ9UZKAXOTys55uMd2i0so,36153
812
+ pyarrow/tests/test_cuda_numba_interop.py,sha256=iHP_FE4sWbsKwNNXRcYnVozp3Wd1o0Mg6BDymx710G4,8794
813
+ pyarrow/tests/test_cython.py,sha256=p3Pz_w8Ysd6pMQfvjGPsBA-fYjX7os9M9B9K9UB42m8,7040
814
+ pyarrow/tests/test_dataset.py,sha256=TA9e4J0nL05TpISLgCzAOyY8g7vAmM4j8PYNaTkCw7U,218325
815
+ pyarrow/tests/test_dataset_encryption.py,sha256=EpD2zXVcLS_3i4fwli7Z45ibDFSgXCFFQ2qiXtAxBsg,18023
816
+ pyarrow/tests/test_deprecations.py,sha256=W_rneq4jC6zqCNoGhBDf1F28Q-0LHI7YKLgtsbV6LHM,891
817
+ pyarrow/tests/test_device.py,sha256=qe9Wiwo-XVazt9pdxyqQJUz6fNR0jTs9CHiyaoppNA4,2550
818
+ pyarrow/tests/test_dlpack.py,sha256=sdubFfaU6ZCjZFoj-vbqnT-Yf79kI2ZBOe9Qi_J0Vfk,5974
819
+ pyarrow/tests/test_exec_plan.py,sha256=pjOkSaWeqjN6celKxUEH3tBGXLh8kKbmSSsvKOWsbQQ,10096
820
+ pyarrow/tests/test_extension_type.py,sha256=q-Y3BI469ePC0aLG5LUSTObdeMqkeQtnD-oRLBx_9kM,67567
821
+ pyarrow/tests/test_feather.py,sha256=QMFIyOh2bGwatHq3gE1OZWIgIdfJ2i5UjhNTN0DVK5U,25616
822
+ pyarrow/tests/test_flight.py,sha256=kZsX-0YWYtrIrcqkdg8yNmjxMuVQSo_Ly5rqD6y2H80,102280
823
+ pyarrow/tests/test_flight_async.py,sha256=kP2wIrUz1HIbrr4CE0SxSg4Zc56ta3xX6EdibAI2yVM,2848
824
+ pyarrow/tests/test_fs.py,sha256=G97d6CLdiFCnWo18H_OHCWt-JHeSqYCv7rs5quosI3U,72758
825
+ pyarrow/tests/test_gandiva.py,sha256=AEf9ln-j5MmIMQ0JTQPhnZwbNh82ynSURsWPaKaNing,15623
826
+ pyarrow/tests/test_gdb.py,sha256=mircGfK7H3PQgn4dVYfDUYbC03CzuAXqGW4oOmd-uZw,45052
827
+ pyarrow/tests/test_io.py,sha256=fBEyAu9zTMHu9ovgwOwv7kEslYhY38sd0GNR78d-ECg,63736
828
+ pyarrow/tests/test_ipc.py,sha256=KFK4E6Ee_zZ52k9hbxS6nMFNo41asuoppiFsJW8PGEI,46053
829
+ pyarrow/tests/test_json.py,sha256=yTOKNdiCcJxmPCAiUfNojAOqsytj_w9uZ0YPJd3yNWU,23003
830
+ pyarrow/tests/test_jvm.py,sha256=QLRHeFx8Gbz1UywlnDi2akV6DBtqGHReQEuNl2vSbcE,15475
831
+ pyarrow/tests/test_memory.py,sha256=j8fs5HqguRobzbcHSvyRzd0ICT7IMeonMvcs147DEd4,9860
832
+ pyarrow/tests/test_misc.py,sha256=1febCUPe9YTPl7QU5jH8Tlo2q_5UpoYoqsg_esZpCiU,7626
833
+ pyarrow/tests/test_orc.py,sha256=UrDyNHJoTX72KFGVLf-WRzzC8e6nsP-GsCm97x0l43o,21565
834
+ pyarrow/tests/test_pandas.py,sha256=NuZGxTh6PNJM2cV2fOrEWLZexc4OSn8G10hMcEJbqyw,195140
835
+ pyarrow/tests/test_scalars.py,sha256=8LPIZy1LmqOTK6-e_RZjiRM9owLodVvMFtRfFSiWBrc,30289
836
+ pyarrow/tests/test_schema.py,sha256=x5MSVt6kOhvSPTCIMIFVTm27Lp6znJ4emk9L5ziqJwc,23347
837
+ pyarrow/tests/test_sparse_tensor.py,sha256=bGO7Es4D65zmGNRN013G9VUCQ_v-mPUb90sAk--3yyw,17666
838
+ pyarrow/tests/test_strategies.py,sha256=ZPJiWvj26qQPsR9aZCF-VUsT6PyWPrJsr6q2oXJshSs,1829
839
+ pyarrow/tests/test_substrait.py,sha256=rsLPNlDPDAxZ1OIu-LAINSD4q_UZJhOvtTzPfXjrWM8,32223
840
+ pyarrow/tests/test_table.py,sha256=aRgarP_oVThWXp41TBe6MLVPgmoZqCgwdKMVhq2KHig,123867
841
+ pyarrow/tests/test_tensor.py,sha256=LYSEYGUjtdnsbL0WAir9jFindo-r0bLySiDA1uAXL8E,6643
842
+ pyarrow/tests/test_types.py,sha256=XaGZSzq556PewtGRcUEQ6T5T6D5QidchC7RrmRQYI-8,44212
843
+ pyarrow/tests/test_udf.py,sha256=WA9E5skUqh7uMr_zH3rQ11LRx0SK2G3WO8HjVHGWyQY,29792
844
+ pyarrow/tests/test_util.py,sha256=ozTlooHBMOP3nbX5b3dG2aanrXwxXHx1giicm0QQyPM,5030
845
+ pyarrow/tests/test_without_numpy.py,sha256=ysbB-jML318I04ViQT4Ok7iMg1cI-NU8kguPu-FTSl4,1855
846
+ pyarrow/tests/util.py,sha256=o_opaXvKIDveE2cf_jjo6fHRuRk2CjLGu6OsFFbt-mM,13665
847
+ pyarrow/tests/wsgi_examples.py,sha256=vQIDb5989sRVLsELw-fRHhfX-dE96sTl5J2lEuEKup8,1348
848
+ pyarrow/types.pxi,sha256=M1_lSb4uNHl2akZkQlgOf21SnfvrWQz6rybtCIVAdYQ,162774
849
+ pyarrow/types.py,sha256=d79cmgr2MDz79UQy6ChoKf4MScKCtDvtOBVGIbV1644,9734
850
+ pyarrow/util.py,sha256=8cQQMKLvvoQitDnz1Tv-w2zJgsIKJUNvtbqupk5TJZs,8679
851
+ pyarrow/vendored/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
852
+ pyarrow/vendored/__pycache__/__init__.cpython-310.pyc,,
853
+ pyarrow/vendored/__pycache__/docscrape.cpython-310.pyc,,
854
+ pyarrow/vendored/__pycache__/version.cpython-310.pyc,,
855
+ pyarrow/vendored/docscrape.py,sha256=phTjwuzoO5hB88QerZk3uGu9c5OrZwjFzI7vEIIbCUQ,22975
856
+ pyarrow/vendored/version.py,sha256=5-Vo4Q3kPJrm1DSGusnMlTxuA8ynI4hAryApBd6MnpQ,14345
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-manylinux_2_28_x86_64
5
+
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/licenses/LICENSE.txt ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/licenses/NOTICE.txt ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache Arrow
2
+ Copyright 2016-2026 The Apache Software Foundation
3
+
4
+ This product includes software developed at
5
+ The Apache Software Foundation (http://www.apache.org/).
6
+
7
+ This product includes software from the SFrame project (BSD, 3-clause).
8
+ * Copyright (C) 2015 Dato, Inc.
9
+ * Copyright (c) 2009 Carnegie Mellon University.
10
+
11
+ This product includes software from the Feather project (Apache 2.0)
12
+ https://github.com/wesm/feather
13
+
14
+ This product includes software from the DyND project (BSD 2-clause)
15
+ https://github.com/libdynd
16
+
17
+ This product includes software from the LLVM project
18
+ * distributed under the University of Illinois Open Source
19
+
20
+ This product includes software from the mman-win32 project
21
+ * Copyright https://code.google.com/p/mman-win32/
22
+ * Licensed under the MIT License;
23
+
24
+ This product includes software from the LevelDB project
25
+ * Copyright (c) 2011 The LevelDB Authors. All rights reserved.
26
+ * Use of this source code is governed by a BSD-style license that can be
27
+ * Moved from Kudu http://github.com/cloudera/kudu
28
+
29
+ This product includes software from the CMake project
30
+ * Copyright 2001-2009 Kitware, Inc.
31
+ * Copyright 2012-2014 Continuum Analytics, Inc.
32
+ * All rights reserved.
33
+
34
+ This product includes software from https://github.com/matthew-brett/multibuild (BSD 2-clause)
35
+ * Copyright (c) 2013-2016, Matt Terry and Matthew Brett; all rights reserved.
36
+
37
+ This product includes software from the Ibis project (Apache 2.0)
38
+ * Copyright (c) 2015 Cloudera, Inc.
39
+ * https://github.com/cloudera/ibis
40
+
41
+ This product includes software from Dremio (Apache 2.0)
42
+ * Copyright (C) 2017-2018 Dremio Corporation
43
+ * https://github.com/dremio/dremio-oss
44
+
45
+ This product includes software from Google Guava (Apache 2.0)
46
+ * Copyright (C) 2007 The Guava Authors
47
+ * https://github.com/google/guava
48
+
49
+ This product include software from CMake (BSD 3-Clause)
50
+ * CMake - Cross Platform Makefile Generator
51
+ * Copyright 2000-2019 Kitware, Inc. and Contributors
52
+
53
+ The web site includes files generated by Jekyll.
54
+
55
+ --------------------------------------------------------------------------------
56
+
57
+ This product includes code from Apache Kudu, which includes the following in
58
+ its NOTICE file:
59
+
60
+ Apache Kudu
61
+ Copyright 2016 The Apache Software Foundation
62
+
63
+ This product includes software developed at
64
+ The Apache Software Foundation (http://www.apache.org/).
65
+
66
+ Portions of this software were developed at
67
+ Cloudera, Inc (http://www.cloudera.com/).
68
+
69
+ --------------------------------------------------------------------------------
70
+
71
+ This product includes code from Apache ORC, which includes the following in
72
+ its NOTICE file:
73
+
74
+ Apache ORC
75
+ Copyright 2013-2019 The Apache Software Foundation
76
+
77
+ This product includes software developed by The Apache Software
78
+ Foundation (http://www.apache.org/).
79
+
80
+ This product includes software developed by Hewlett-Packard:
81
+ (c) Copyright [2014-2015] Hewlett-Packard Development Company, L.P
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow-23.0.1.dist-info/top_level.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ __dummy__
2
+ pyarrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_acero.pxd ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.common cimport *
21
+ from pyarrow.includes.libarrow cimport *
22
+
23
+
24
+ cdef extern from "arrow/acero/options.h" namespace "arrow::acero" nogil:
25
+ cdef enum CJoinType "arrow::acero::JoinType":
26
+ CJoinType_LEFT_SEMI "arrow::acero::JoinType::LEFT_SEMI"
27
+ CJoinType_RIGHT_SEMI "arrow::acero::JoinType::RIGHT_SEMI"
28
+ CJoinType_LEFT_ANTI "arrow::acero::JoinType::LEFT_ANTI"
29
+ CJoinType_RIGHT_ANTI "arrow::acero::JoinType::RIGHT_ANTI"
30
+ CJoinType_INNER "arrow::acero::JoinType::INNER"
31
+ CJoinType_LEFT_OUTER "arrow::acero::JoinType::LEFT_OUTER"
32
+ CJoinType_RIGHT_OUTER "arrow::acero::JoinType::RIGHT_OUTER"
33
+ CJoinType_FULL_OUTER "arrow::acero::JoinType::FULL_OUTER"
34
+
35
+ cdef cppclass CExecNodeOptions "arrow::acero::ExecNodeOptions":
36
+ pass
37
+
38
+ cdef cppclass CSourceNodeOptions "arrow::acero::SourceNodeOptions"(CExecNodeOptions):
39
+ pass
40
+
41
+ cdef cppclass CTableSourceNodeOptions "arrow::acero::TableSourceNodeOptions"(CExecNodeOptions):
42
+ CTableSourceNodeOptions(shared_ptr[CTable] table)
43
+ CTableSourceNodeOptions(shared_ptr[CTable] table, int64_t max_batch_size)
44
+
45
+ cdef cppclass CSinkNodeOptions "arrow::acero::SinkNodeOptions"(CExecNodeOptions):
46
+ pass
47
+
48
+ cdef cppclass CFilterNodeOptions "arrow::acero::FilterNodeOptions"(CExecNodeOptions):
49
+ CFilterNodeOptions(CExpression)
50
+
51
+ cdef cppclass CProjectNodeOptions "arrow::acero::ProjectNodeOptions"(CExecNodeOptions):
52
+ CProjectNodeOptions(vector[CExpression] expressions)
53
+ CProjectNodeOptions(vector[CExpression] expressions,
54
+ vector[c_string] names)
55
+
56
+ cdef cppclass CAggregateNodeOptions "arrow::acero::AggregateNodeOptions"(CExecNodeOptions):
57
+ CAggregateNodeOptions(vector[CAggregate] aggregates, vector[CFieldRef] names)
58
+
59
+ cdef cppclass COrderByNodeOptions "arrow::acero::OrderByNodeOptions"(CExecNodeOptions):
60
+ COrderByNodeOptions(COrdering ordering)
61
+
62
+ cdef cppclass CHashJoinNodeOptions "arrow::acero::HashJoinNodeOptions"(CExecNodeOptions):
63
+ CHashJoinNodeOptions(CJoinType, vector[CFieldRef] in_left_keys,
64
+ vector[CFieldRef] in_right_keys)
65
+ CHashJoinNodeOptions(CJoinType, vector[CFieldRef] in_left_keys,
66
+ vector[CFieldRef] in_right_keys,
67
+ CExpression filter,
68
+ c_string output_suffix_for_left,
69
+ c_string output_suffix_for_right)
70
+ CHashJoinNodeOptions(CJoinType join_type,
71
+ vector[CFieldRef] left_keys,
72
+ vector[CFieldRef] right_keys,
73
+ vector[CFieldRef] left_output,
74
+ vector[CFieldRef] right_output,
75
+ CExpression filter,
76
+ c_string output_suffix_for_left,
77
+ c_string output_suffix_for_right)
78
+
79
+ cdef struct CAsofJoinKeys "arrow::acero::AsofJoinNodeOptions::Keys":
80
+ CFieldRef on_key
81
+ vector[CFieldRef] by_key
82
+
83
+ cdef cppclass CAsofJoinNodeOptions "arrow::acero::AsofJoinNodeOptions"(CExecNodeOptions):
84
+ CAsofJoinNodeOptions(vector[CAsofJoinKeys] keys, int64_t tolerance)
85
+
86
+
87
+ cdef extern from "arrow/acero/exec_plan.h" namespace "arrow::acero" nogil:
88
+ cdef cppclass CDeclaration "arrow::acero::Declaration":
89
+ cppclass Input:
90
+ Input(CExecNode*)
91
+ Input(CDeclaration)
92
+
93
+ c_string label
94
+ vector[Input] inputs
95
+
96
+ CDeclaration()
97
+ CDeclaration(c_string factory_name, CExecNodeOptions options)
98
+ CDeclaration(c_string factory_name, vector[Input] inputs, shared_ptr[CExecNodeOptions] options)
99
+
100
+ @staticmethod
101
+ CDeclaration Sequence(vector[CDeclaration] decls)
102
+
103
+ cdef cppclass CExecNode "arrow::acero::ExecNode":
104
+ const vector[CExecNode*]& inputs() const
105
+ const shared_ptr[CSchema]& output_schema() const
106
+
107
+ CResult[shared_ptr[CTable]] DeclarationToTable(
108
+ CDeclaration declaration, c_bool use_threads
109
+ )
110
+ CResult[shared_ptr[CTable]] DeclarationToTable(
111
+ CDeclaration declaration, c_bool use_threads,
112
+ CMemoryPool* memory_pool, CFunctionRegistry* function_registry
113
+ )
114
+ CResult[unique_ptr[CRecordBatchReader]] DeclarationToReader(
115
+ CDeclaration declaration, c_bool use_threads
116
+ )
117
+
118
+ CResult[c_string] DeclarationToString(const CDeclaration& declaration)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_cuda.pxd ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.libarrow cimport *
21
+
22
+ cdef extern from "arrow/gpu/cuda_api.h" namespace "arrow::cuda" nogil:
23
+
24
+ cdef cppclass CCudaDeviceManager" arrow::cuda::CudaDeviceManager":
25
+ @staticmethod
26
+ CResult[CCudaDeviceManager*] Instance()
27
+ CResult[shared_ptr[CCudaContext]] GetContext(int gpu_number)
28
+ CResult[shared_ptr[CCudaContext]] GetSharedContext(int gpu_number,
29
+ void* handle)
30
+ CStatus AllocateHost(int device_number, int64_t nbytes,
31
+ shared_ptr[CCudaHostBuffer]* buffer)
32
+ int num_devices() const
33
+
34
+ cdef cppclass CCudaContext" arrow::cuda::CudaContext":
35
+ CResult[shared_ptr[CCudaBuffer]] Allocate(int64_t nbytes)
36
+ CResult[shared_ptr[CCudaBuffer]] View(uint8_t* data, int64_t nbytes)
37
+ CResult[shared_ptr[CCudaBuffer]] OpenIpcBuffer(
38
+ const CCudaIpcMemHandle& ipc_handle)
39
+ CStatus Synchronize()
40
+ int64_t bytes_allocated() const
41
+ const void* handle() const
42
+ int device_number() const
43
+ CResult[uintptr_t] GetDeviceAddress(uintptr_t addr)
44
+ shared_ptr[CDevice] device() const
45
+ shared_ptr[CMemoryManager] memory_manager() const
46
+
47
+ cdef cppclass CCudaIpcMemHandle" arrow::cuda::CudaIpcMemHandle":
48
+ @staticmethod
49
+ CResult[shared_ptr[CCudaIpcMemHandle]] FromBuffer(
50
+ const void* opaque_handle)
51
+ CResult[shared_ptr[CBuffer]] Serialize(CMemoryPool* pool) const
52
+
53
+ cdef cppclass CCudaBuffer" arrow::cuda::CudaBuffer"(CBuffer):
54
+ CCudaBuffer(uint8_t* data, int64_t size,
55
+ const shared_ptr[CCudaContext]& context,
56
+ c_bool own_data=false, c_bool is_ipc=false)
57
+ CCudaBuffer(const shared_ptr[CCudaBuffer]& parent,
58
+ const int64_t offset, const int64_t size)
59
+
60
+ @staticmethod
61
+ CResult[shared_ptr[CCudaBuffer]] FromBuffer(shared_ptr[CBuffer] buf)
62
+
63
+ CStatus CopyToHost(const int64_t position, const int64_t nbytes,
64
+ void* out) const
65
+ CStatus CopyFromHost(const int64_t position, const void* data,
66
+ int64_t nbytes)
67
+ CStatus CopyFromDevice(const int64_t position, const void* data,
68
+ int64_t nbytes)
69
+ CStatus CopyFromAnotherDevice(const shared_ptr[CCudaContext]& src_ctx,
70
+ const int64_t position, const void* data,
71
+ int64_t nbytes)
72
+ CResult[shared_ptr[CCudaIpcMemHandle]] ExportForIpc()
73
+ shared_ptr[CCudaContext] context() const
74
+
75
+ cdef cppclass \
76
+ CCudaHostBuffer" arrow::cuda::CudaHostBuffer"(CMutableBuffer):
77
+ pass
78
+
79
+ cdef cppclass \
80
+ CCudaBufferReader" arrow::cuda::CudaBufferReader"(CBufferReader):
81
+ CCudaBufferReader(const shared_ptr[CBuffer]& buffer)
82
+ CResult[int64_t] Read(int64_t nbytes, void* buffer)
83
+ CResult[shared_ptr[CBuffer]] Read(int64_t nbytes)
84
+
85
+ cdef cppclass \
86
+ CCudaBufferWriter" arrow::cuda::CudaBufferWriter"(WritableFile):
87
+ CCudaBufferWriter(const shared_ptr[CCudaBuffer]& buffer)
88
+ CStatus Close()
89
+ CStatus Write(const void* data, int64_t nbytes)
90
+ CStatus WriteAt(int64_t position, const void* data, int64_t nbytes)
91
+ CStatus SetBufferSize(const int64_t buffer_size)
92
+ int64_t buffer_size()
93
+ int64_t num_bytes_buffered() const
94
+
95
+ CResult[shared_ptr[CCudaHostBuffer]] AllocateCudaHostBuffer(
96
+ int device_number, const int64_t size)
97
+
98
+ # Cuda prefix is added to avoid picking up arrow::cuda functions
99
+ # from arrow namespace.
100
+ CResult[shared_ptr[CCudaBuffer]] \
101
+ CudaSerializeRecordBatch" arrow::cuda::SerializeRecordBatch"\
102
+ (const CRecordBatch& batch,
103
+ CCudaContext* ctx)
104
+ CResult[shared_ptr[CRecordBatch]] \
105
+ CudaReadRecordBatch" arrow::cuda::ReadRecordBatch"\
106
+ (const shared_ptr[CSchema]& schema,
107
+ CDictionaryMemo* dictionary_memo,
108
+ const shared_ptr[CCudaBuffer]& buffer,
109
+ CMemoryPool* pool)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_dataset.pxd ADDED
@@ -0,0 +1,423 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from libcpp.unordered_map cimport unordered_map
21
+ from libcpp cimport bool as c_bool
22
+
23
+ from pyarrow.includes.common cimport *
24
+ from pyarrow.includes.libarrow cimport *
25
+ from pyarrow.includes.libarrow_acero cimport *
26
+ from pyarrow.includes.libarrow_fs cimport *
27
+
28
+
29
+ cdef extern from "arrow/dataset/plan.h" namespace "arrow::dataset::internal" nogil:
30
+
31
+ cdef void Initialize()
32
+
33
+
34
+ ctypedef CStatus cb_writer_finish_internal(CFileWriter*)
35
+ ctypedef void cb_writer_finish(dict, CFileWriter*)
36
+
37
+ cdef extern from "arrow/dataset/api.h" namespace "arrow::dataset" nogil:
38
+
39
+ cdef enum ExistingDataBehavior" arrow::dataset::ExistingDataBehavior":
40
+ ExistingDataBehavior_DELETE_MATCHING" \
41
+ arrow::dataset::ExistingDataBehavior::kDeleteMatchingPartitions"
42
+ ExistingDataBehavior_OVERWRITE_OR_IGNORE" \
43
+ arrow::dataset::ExistingDataBehavior::kOverwriteOrIgnore"
44
+ ExistingDataBehavior_ERROR" \
45
+ arrow::dataset::ExistingDataBehavior::kError"
46
+
47
+ cdef cppclass CScanOptions "arrow::dataset::ScanOptions":
48
+ shared_ptr[CSchema] dataset_schema
49
+ shared_ptr[CSchema] projected_schema
50
+ c_bool use_threads
51
+ c_bool cache_metadata
52
+ CExpression filter
53
+
54
+ cdef cppclass CScanNodeOptions "arrow::dataset::ScanNodeOptions"(CExecNodeOptions):
55
+ CScanNodeOptions(shared_ptr[CDataset] dataset, shared_ptr[CScanOptions] scan_options, bint require_sequenced_output, bint implicit_ordering)
56
+
57
+ shared_ptr[CScanOptions] scan_options
58
+
59
+ cdef cppclass CFragmentScanOptions "arrow::dataset::FragmentScanOptions":
60
+ c_string type_name() const
61
+
62
+ ctypedef CIterator[shared_ptr[CScanTask]] CScanTaskIterator \
63
+ "arrow::dataset::ScanTaskIterator"
64
+
65
+ cdef cppclass CScanTask" arrow::dataset::ScanTask":
66
+ CResult[CRecordBatchIterator] Execute()
67
+
68
+ cdef cppclass CFragment "arrow::dataset::Fragment":
69
+ CResult[shared_ptr[CSchema]] ReadPhysicalSchema()
70
+ CResult[CScanTaskIterator] Scan(shared_ptr[CScanOptions] options)
71
+ c_bool splittable() const
72
+ c_string type_name() const
73
+ const CExpression& partition_expression() const
74
+
75
+ ctypedef vector[shared_ptr[CFragment]] CFragmentVector \
76
+ "arrow::dataset::FragmentVector"
77
+
78
+ ctypedef CIterator[shared_ptr[CFragment]] CFragmentIterator \
79
+ "arrow::dataset::FragmentIterator"
80
+
81
+ cdef cppclass CInMemoryFragment "arrow::dataset::InMemoryFragment"(
82
+ CFragment):
83
+ CInMemoryFragment(vector[shared_ptr[CRecordBatch]] record_batches,
84
+ CExpression partition_expression)
85
+
86
+ cdef cppclass CTaggedRecordBatch "arrow::dataset::TaggedRecordBatch":
87
+ shared_ptr[CRecordBatch] record_batch
88
+ shared_ptr[CFragment] fragment
89
+
90
+ ctypedef CIterator[CTaggedRecordBatch] CTaggedRecordBatchIterator \
91
+ "arrow::dataset::TaggedRecordBatchIterator"
92
+
93
+ cdef cppclass CScanner "arrow::dataset::Scanner":
94
+ CScanner(shared_ptr[CDataset], shared_ptr[CScanOptions])
95
+ CScanner(shared_ptr[CFragment], shared_ptr[CScanOptions])
96
+ CResult[CScanTaskIterator] Scan()
97
+ CResult[CTaggedRecordBatchIterator] ScanBatches()
98
+ CResult[shared_ptr[CTable]] ToTable()
99
+ CResult[shared_ptr[CTable]] TakeRows(const CArray& indices)
100
+ CResult[shared_ptr[CTable]] Head(int64_t num_rows)
101
+ CResult[int64_t] CountRows()
102
+ CResult[CFragmentIterator] GetFragments()
103
+ CResult[shared_ptr[CRecordBatchReader]] ToRecordBatchReader()
104
+ const shared_ptr[CScanOptions]& options()
105
+
106
+ cdef cppclass CScannerBuilder "arrow::dataset::ScannerBuilder":
107
+ CScannerBuilder(shared_ptr[CDataset],
108
+ shared_ptr[CScanOptions] scan_options)
109
+ CScannerBuilder(shared_ptr[CSchema], shared_ptr[CFragment],
110
+ shared_ptr[CScanOptions] scan_options)
111
+
112
+ @staticmethod
113
+ shared_ptr[CScannerBuilder] FromRecordBatchReader(
114
+ shared_ptr[CRecordBatchReader] reader)
115
+ CStatus ProjectColumns "Project"(const vector[c_string]& columns)
116
+ CStatus Project(vector[CExpression]& exprs, vector[c_string]& columns)
117
+ CStatus Filter(CExpression filter)
118
+ CStatus UseThreads(c_bool use_threads)
119
+ CStatus CacheMetadata(c_bool cache_metadata)
120
+ CStatus Pool(CMemoryPool* pool)
121
+ CStatus BatchSize(int64_t batch_size)
122
+ CStatus BatchReadahead(int32_t batch_readahead)
123
+ CStatus FragmentReadahead(int32_t fragment_readahead)
124
+ CStatus FragmentScanOptions(
125
+ shared_ptr[CFragmentScanOptions] fragment_scan_options)
126
+ CResult[shared_ptr[CScanOptions]] GetScanOptions()
127
+ CResult[shared_ptr[CScanner]] Finish()
128
+ shared_ptr[CSchema] schema() const
129
+
130
+ ctypedef vector[shared_ptr[CDataset]] CDatasetVector \
131
+ "arrow::dataset::DatasetVector"
132
+
133
+ cdef cppclass CDataset "arrow::dataset::Dataset":
134
+ const shared_ptr[CSchema] & schema()
135
+ CResult[CFragmentIterator] GetFragments()
136
+ CResult[CFragmentIterator] GetFragments(CExpression predicate)
137
+ const CExpression & partition_expression()
138
+ c_string type_name()
139
+
140
+ CResult[shared_ptr[CDataset]] ReplaceSchema(shared_ptr[CSchema])
141
+
142
+ CResult[shared_ptr[CScannerBuilder]] NewScan()
143
+
144
+ cdef cppclass CInMemoryDataset "arrow::dataset::InMemoryDataset"(
145
+ CDataset):
146
+ CInMemoryDataset(shared_ptr[CRecordBatchReader])
147
+ CInMemoryDataset(shared_ptr[CTable])
148
+
149
+ cdef cppclass CUnionDataset "arrow::dataset::UnionDataset"(
150
+ CDataset):
151
+ @staticmethod
152
+ CResult[shared_ptr[CUnionDataset]] Make(shared_ptr[CSchema] schema,
153
+ CDatasetVector children)
154
+
155
+ const CDatasetVector& children() const
156
+
157
+ cdef cppclass CInspectOptions "arrow::dataset::InspectOptions":
158
+ int fragments
159
+ CField.CMergeOptions field_merge_options
160
+
161
+ cdef cppclass CFinishOptions "arrow::dataset::FinishOptions":
162
+ shared_ptr[CSchema] schema
163
+ CInspectOptions inspect_options
164
+ c_bool validate_fragments
165
+
166
+ cdef cppclass CDatasetFactory "arrow::dataset::DatasetFactory":
167
+ CResult[vector[shared_ptr[CSchema]]] InspectSchemas(CInspectOptions)
168
+ CResult[shared_ptr[CSchema]] Inspect(CInspectOptions)
169
+ CResult[shared_ptr[CDataset]] FinishWithSchema "Finish"(
170
+ const shared_ptr[CSchema]& schema)
171
+ CResult[shared_ptr[CDataset]] Finish()
172
+ const CExpression& root_partition()
173
+ CStatus SetRootPartition(CExpression partition)
174
+
175
+ cdef cppclass CUnionDatasetFactory "arrow::dataset::UnionDatasetFactory":
176
+ @staticmethod
177
+ CResult[shared_ptr[CDatasetFactory]] Make(
178
+ vector[shared_ptr[CDatasetFactory]] factories)
179
+
180
+ cdef cppclass CFileSource "arrow::dataset::FileSource":
181
+ const c_string& path() const
182
+ const shared_ptr[CFileSystem]& filesystem() const
183
+ const shared_ptr[CBuffer]& buffer() const
184
+ const int64_t size() const
185
+ CResult[shared_ptr[CRandomAccessFile]] Open() const
186
+ # HACK: Cython can't handle all the overloads so don't declare them.
187
+ # This means invalid construction of CFileSource won't be caught in
188
+ # the C++ generation phase (though it will still be caught when
189
+ # the generated C++ is compiled).
190
+ CFileSource(...)
191
+
192
+ cdef cppclass CFileWriteOptions \
193
+ "arrow::dataset::FileWriteOptions":
194
+ const shared_ptr[CFileFormat]& format() const
195
+ c_string type_name() const
196
+
197
+ cdef cppclass CFileWriter \
198
+ "arrow::dataset::FileWriter":
199
+ const shared_ptr[CFileFormat]& format() const
200
+ const shared_ptr[CSchema]& schema() const
201
+ const shared_ptr[CFileWriteOptions]& options() const
202
+ const CFileLocator& destination() const
203
+ CResult[int64_t] GetBytesWritten()
204
+
205
+ cdef cppclass CFileFormat "arrow::dataset::FileFormat":
206
+ shared_ptr[CFragmentScanOptions] default_fragment_scan_options
207
+ c_string type_name() const
208
+ CResult[shared_ptr[CSchema]] Inspect(const CFileSource&) const
209
+ CResult[shared_ptr[CFileFragment]] MakeFragment(
210
+ CFileSource source,
211
+ CExpression partition_expression,
212
+ shared_ptr[CSchema] physical_schema)
213
+ shared_ptr[CFileWriteOptions] DefaultWriteOptions()
214
+
215
+ cdef cppclass CFileFragment "arrow::dataset::FileFragment"(
216
+ CFragment):
217
+ const CFileSource& source() const
218
+ const shared_ptr[CFileFormat]& format() const
219
+
220
+ cdef cppclass CFileSystemDatasetWriteOptions \
221
+ "arrow::dataset::FileSystemDatasetWriteOptions":
222
+ shared_ptr[CFileWriteOptions] file_write_options
223
+ shared_ptr[CFileSystem] filesystem
224
+ c_string base_dir
225
+ shared_ptr[CPartitioning] partitioning
226
+ c_bool preserve_order
227
+ int max_partitions
228
+ c_string basename_template
229
+ function[cb_writer_finish_internal] writer_pre_finish
230
+ function[cb_writer_finish_internal] writer_post_finish
231
+ ExistingDataBehavior existing_data_behavior
232
+ c_bool create_dir
233
+ uint32_t max_open_files
234
+ uint64_t max_rows_per_file
235
+ uint64_t min_rows_per_group
236
+ uint64_t max_rows_per_group
237
+
238
+ cdef cppclass CFileSystemDataset \
239
+ "arrow::dataset::FileSystemDataset"(CDataset):
240
+ @staticmethod
241
+ CResult[shared_ptr[CDataset]] Make(
242
+ shared_ptr[CSchema] schema,
243
+ CExpression source_partition,
244
+ shared_ptr[CFileFormat] format,
245
+ shared_ptr[CFileSystem] filesystem,
246
+ vector[shared_ptr[CFileFragment]] fragments)
247
+
248
+ @staticmethod
249
+ CStatus Write(
250
+ const CFileSystemDatasetWriteOptions& write_options,
251
+ shared_ptr[CScanner] scanner)
252
+
253
+ c_string type()
254
+ vector[c_string] files()
255
+ const shared_ptr[CFileFormat]& format() const
256
+ const shared_ptr[CFileSystem]& filesystem() const
257
+ const shared_ptr[CPartitioning]& partitioning() const
258
+
259
+ cdef cppclass CIpcFileWriteOptions \
260
+ "arrow::dataset::IpcFileWriteOptions"(CFileWriteOptions):
261
+ shared_ptr[CIpcWriteOptions] options
262
+
263
+ cdef cppclass CIpcFileFormat "arrow::dataset::IpcFileFormat"(
264
+ CFileFormat):
265
+ pass
266
+
267
+ cdef cppclass COrcFileFormat "arrow::dataset::OrcFileFormat"(
268
+ CFileFormat):
269
+ pass
270
+
271
+ cdef cppclass CCsvFileWriteOptions \
272
+ "arrow::dataset::CsvFileWriteOptions"(CFileWriteOptions):
273
+ shared_ptr[CCSVWriteOptions] write_options
274
+ CMemoryPool* pool
275
+
276
+ cdef cppclass CCsvFileFormat "arrow::dataset::CsvFileFormat"(
277
+ CFileFormat):
278
+ CCSVParseOptions parse_options
279
+
280
+ cdef cppclass CCsvFragmentScanOptions \
281
+ "arrow::dataset::CsvFragmentScanOptions"(CFragmentScanOptions):
282
+ CCSVConvertOptions convert_options
283
+ CCSVReadOptions read_options
284
+ function[StreamWrapFunc] stream_transform_func
285
+
286
+ cdef cppclass CJsonFileFormat "arrow::dataset::JsonFileFormat"(CFileFormat):
287
+ pass
288
+
289
+ cdef cppclass CJsonFragmentScanOptions "arrow::dataset::JsonFragmentScanOptions"(CFragmentScanOptions):
290
+ CJSONParseOptions parse_options
291
+ CJSONReadOptions read_options
292
+
293
+ cdef struct CPartitionPathFormat "arrow::dataset::PartitionPathFormat":
294
+ c_string directory
295
+ c_string filename
296
+
297
+ cdef cppclass CPartitioning "arrow::dataset::Partitioning":
298
+ c_string type_name() const
299
+ CResult[CExpression] Parse(const c_string & path) const
300
+ CResult[CPartitionPathFormat] Format(const CExpression & expr) const
301
+ const shared_ptr[CSchema] & schema()
302
+ c_bool Equals(const CPartitioning& other) const
303
+
304
+ cdef cppclass CSegmentEncoding" arrow::dataset::SegmentEncoding":
305
+ bint operator==(CSegmentEncoding)
306
+
307
+ CSegmentEncoding CSegmentEncoding_None\
308
+ " arrow::dataset::SegmentEncoding::None"
309
+ CSegmentEncoding CSegmentEncoding_Uri\
310
+ " arrow::dataset::SegmentEncoding::Uri"
311
+
312
+ cdef cppclass CKeyValuePartitioningOptions \
313
+ "arrow::dataset::KeyValuePartitioningOptions":
314
+ CSegmentEncoding segment_encoding
315
+
316
+ cdef cppclass CHivePartitioningOptions \
317
+ "arrow::dataset::HivePartitioningOptions":
318
+ CSegmentEncoding segment_encoding
319
+ c_string null_fallback
320
+
321
+ cdef cppclass CPartitioningFactoryOptions \
322
+ "arrow::dataset::PartitioningFactoryOptions":
323
+ c_bool infer_dictionary
324
+ shared_ptr[CSchema] schema
325
+ CSegmentEncoding segment_encoding
326
+
327
+ cdef cppclass CHivePartitioningFactoryOptions \
328
+ "arrow::dataset::HivePartitioningFactoryOptions":
329
+ c_bool infer_dictionary
330
+ c_string null_fallback
331
+ shared_ptr[CSchema] schema
332
+ CSegmentEncoding segment_encoding
333
+
334
+ cdef cppclass CPartitioningFactory "arrow::dataset::PartitioningFactory":
335
+ c_string type_name() const
336
+
337
+ cdef cppclass CKeyValuePartitioning \
338
+ "arrow::dataset::KeyValuePartitioning"(CPartitioning):
339
+ CKeyValuePartitioning(shared_ptr[CSchema] schema,
340
+ vector[shared_ptr[CArray]] dictionaries,
341
+ CKeyValuePartitioningOptions options)
342
+
343
+ vector[shared_ptr[CArray]] dictionaries() const
344
+ CSegmentEncoding segment_encoding()
345
+
346
+ cdef cppclass CDirectoryPartitioning \
347
+ "arrow::dataset::DirectoryPartitioning"(CPartitioning):
348
+ CDirectoryPartitioning(shared_ptr[CSchema] schema,
349
+ vector[shared_ptr[CArray]] dictionaries)
350
+
351
+ @staticmethod
352
+ shared_ptr[CPartitioningFactory] MakeFactory(
353
+ vector[c_string] field_names, CPartitioningFactoryOptions)
354
+
355
+ vector[shared_ptr[CArray]] dictionaries() const
356
+
357
+ cdef cppclass CHivePartitioning \
358
+ "arrow::dataset::HivePartitioning"(CPartitioning):
359
+ CHivePartitioning(shared_ptr[CSchema] schema,
360
+ vector[shared_ptr[CArray]] dictionaries,
361
+ CHivePartitioningOptions options)
362
+
363
+ @staticmethod
364
+ shared_ptr[CPartitioningFactory] MakeFactory(
365
+ CHivePartitioningFactoryOptions)
366
+
367
+ vector[shared_ptr[CArray]] dictionaries() const
368
+ c_string null_fallback() const
369
+
370
+ cdef cppclass CFilenamePartitioning \
371
+ "arrow::dataset::FilenamePartitioning"(CPartitioning):
372
+ CFilenamePartitioning(shared_ptr[CSchema] schema,
373
+ vector[shared_ptr[CArray]] dictionaries)
374
+
375
+ @staticmethod
376
+ shared_ptr[CPartitioningFactory] MakeFactory(
377
+ vector[c_string] field_names, CPartitioningFactoryOptions)
378
+
379
+ vector[shared_ptr[CArray]] dictionaries() const
380
+
381
+ cdef cppclass CPartitioningOrFactory \
382
+ "arrow::dataset::PartitioningOrFactory":
383
+ CPartitioningOrFactory(shared_ptr[CPartitioning])
384
+ CPartitioningOrFactory(shared_ptr[CPartitioningFactory])
385
+ CPartitioningOrFactory & operator = (shared_ptr[CPartitioning])
386
+ CPartitioningOrFactory & operator = (
387
+ shared_ptr[CPartitioningFactory])
388
+ shared_ptr[CPartitioning] partitioning() const
389
+ shared_ptr[CPartitioningFactory] factory() const
390
+
391
+ cdef cppclass CFileSystemFactoryOptions \
392
+ "arrow::dataset::FileSystemFactoryOptions":
393
+ CPartitioningOrFactory partitioning
394
+ c_string partition_base_dir
395
+ c_bool exclude_invalid_files
396
+ vector[c_string] selector_ignore_prefixes
397
+
398
+ cdef cppclass CFileSystemDatasetFactory \
399
+ "arrow::dataset::FileSystemDatasetFactory"(
400
+ CDatasetFactory):
401
+ @staticmethod
402
+ CResult[shared_ptr[CDatasetFactory]] MakeFromPaths "Make"(
403
+ shared_ptr[CFileSystem] filesystem,
404
+ vector[c_string] paths,
405
+ shared_ptr[CFileFormat] format,
406
+ CFileSystemFactoryOptions options
407
+ )
408
+
409
+ @staticmethod
410
+ CResult[shared_ptr[CDatasetFactory]] MakeFromSelector "Make"(
411
+ shared_ptr[CFileSystem] filesystem,
412
+ CFileSelector,
413
+ shared_ptr[CFileFormat] format,
414
+ CFileSystemFactoryOptions options
415
+ )
416
+
417
+ @staticmethod
418
+ CResult[shared_ptr[CDatasetFactory]] MakeFromFileInfos "Make"(
419
+ shared_ptr[CFileSystem] filesystem,
420
+ vector[CFileInfo] files,
421
+ shared_ptr[CFileFormat] format,
422
+ CFileSystemFactoryOptions options
423
+ )
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_dataset_parquet.pxd ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.libarrow_dataset cimport *
21
+ from pyarrow.includes.libparquet_encryption cimport *
22
+
23
+ from pyarrow._parquet cimport *
24
+
25
+
26
+ cdef extern from "arrow/dataset/parquet_encryption_config.h" namespace "arrow::dataset" nogil:
27
+ cdef cppclass CParquetEncryptionConfig "arrow::dataset::ParquetEncryptionConfig":
28
+ shared_ptr[CCryptoFactory] crypto_factory
29
+ shared_ptr[CKmsConnectionConfig] kms_connection_config
30
+ shared_ptr[CEncryptionConfiguration] encryption_config
31
+
32
+ cdef cppclass CParquetDecryptionConfig "arrow::dataset::ParquetDecryptionConfig":
33
+ shared_ptr[CCryptoFactory] crypto_factory
34
+ shared_ptr[CKmsConnectionConfig] kms_connection_config
35
+ shared_ptr[CDecryptionConfiguration] decryption_config
36
+
37
+
38
+ cdef extern from "arrow/dataset/api.h" namespace "arrow::dataset" nogil:
39
+
40
+ cdef cppclass CParquetFileWriter \
41
+ "arrow::dataset::ParquetFileWriter"(CFileWriter):
42
+ const shared_ptr[FileWriter]& parquet_writer() const
43
+
44
+ cdef cppclass CParquetFileWriteOptions \
45
+ "arrow::dataset::ParquetFileWriteOptions"(CFileWriteOptions):
46
+ shared_ptr[WriterProperties] writer_properties
47
+ shared_ptr[ArrowWriterProperties] arrow_writer_properties
48
+ shared_ptr[CParquetEncryptionConfig] parquet_encryption_config
49
+
50
+ cdef cppclass CParquetFileFragment "arrow::dataset::ParquetFileFragment"(
51
+ CFileFragment):
52
+ const vector[int]& row_groups() const
53
+ shared_ptr[CFileMetaData] metadata() const
54
+ CResult[vector[shared_ptr[CFragment]]] SplitByRowGroup(
55
+ CExpression predicate)
56
+ CResult[shared_ptr[CFragment]] SubsetWithFilter "Subset"(
57
+ CExpression predicate)
58
+ CResult[shared_ptr[CFragment]] SubsetWithIds "Subset"(
59
+ vector[int] row_group_ids)
60
+ CStatus EnsureCompleteMetadata()
61
+
62
+ cdef cppclass CParquetFileFormatReaderOptions \
63
+ "arrow::dataset::ParquetFileFormat::ReaderOptions":
64
+ unordered_set[c_string] dict_columns
65
+ TimeUnit coerce_int96_timestamp_unit
66
+ Type binary_type
67
+ Type list_type
68
+
69
+ cdef cppclass CParquetFileFormat "arrow::dataset::ParquetFileFormat"(
70
+ CFileFormat):
71
+ CParquetFileFormatReaderOptions reader_options
72
+ CResult[shared_ptr[CFileFragment]] MakeFragment(
73
+ CFileSource source,
74
+ CExpression partition_expression,
75
+ shared_ptr[CSchema] physical_schema,
76
+ vector[int] row_groups)
77
+
78
+ cdef cppclass CParquetFragmentScanOptions \
79
+ "arrow::dataset::ParquetFragmentScanOptions"(CFragmentScanOptions):
80
+ shared_ptr[CReaderProperties] reader_properties
81
+ shared_ptr[ArrowReaderProperties] arrow_reader_properties
82
+ shared_ptr[CParquetDecryptionConfig] parquet_decryption_config
83
+
84
+ cdef cppclass CParquetFactoryOptions \
85
+ "arrow::dataset::ParquetFactoryOptions":
86
+ CPartitioningOrFactory partitioning
87
+ c_string partition_base_dir
88
+ c_bool validate_column_chunk_paths
89
+
90
+ cdef cppclass CParquetDatasetFactory \
91
+ "arrow::dataset::ParquetDatasetFactory"(CDatasetFactory):
92
+ @staticmethod
93
+ CResult[shared_ptr[CDatasetFactory]] MakeFromMetaDataPath "Make"(
94
+ const c_string& metadata_path,
95
+ shared_ptr[CFileSystem] filesystem,
96
+ shared_ptr[CParquetFileFormat] format,
97
+ CParquetFactoryOptions options
98
+ )
99
+
100
+ @staticmethod
101
+ CResult[shared_ptr[CDatasetFactory]] MakeFromMetaDataSource "Make"(
102
+ const CFileSource& metadata_path,
103
+ const c_string& base_path,
104
+ shared_ptr[CFileSystem] filesystem,
105
+ shared_ptr[CParquetFileFormat] format,
106
+ CParquetFactoryOptions options
107
+ )
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_feather.pxd ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.libarrow cimport (CCompressionType, CStatus, CTable,
21
+ COutputStream, CResult, shared_ptr,
22
+ vector, CRandomAccessFile, CSchema,
23
+ c_string, CIpcReadOptions)
24
+
25
+
26
+ cdef extern from "arrow/ipc/api.h" namespace "arrow::ipc" nogil:
27
+ int kFeatherV1Version" arrow::ipc::feather::kFeatherV1Version"
28
+ int kFeatherV2Version" arrow::ipc::feather::kFeatherV2Version"
29
+
30
+ cdef cppclass CFeatherProperties" arrow::ipc::feather::WriteProperties":
31
+ int version
32
+ int chunksize
33
+ CCompressionType compression
34
+ int compression_level
35
+
36
+ CStatus WriteFeather" arrow::ipc::feather::WriteTable" \
37
+ (const CTable& table, COutputStream* out,
38
+ CFeatherProperties properties)
39
+
40
+ cdef cppclass CFeatherReader" arrow::ipc::feather::Reader":
41
+ @staticmethod
42
+ CResult[shared_ptr[CFeatherReader]] Open(
43
+ const shared_ptr[CRandomAccessFile]& file,
44
+ const CIpcReadOptions& options)
45
+ int version()
46
+ shared_ptr[CSchema] schema()
47
+
48
+ CStatus Read(shared_ptr[CTable]* out)
49
+ CStatus Read(const vector[int] indices, shared_ptr[CTable]* out)
50
+ CStatus Read(const vector[c_string] names, shared_ptr[CTable]* out)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_flight.pxd ADDED
@@ -0,0 +1,621 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.common cimport *
21
+ from pyarrow.includes.libarrow cimport *
22
+ from pyarrow.includes.libarrow_python cimport CTimePoint
23
+
24
+ from libcpp.map cimport multimap
25
+
26
+
27
+ cdef extern from "arrow/flight/api.h" namespace "arrow" nogil:
28
+ cdef char* CTracingServerMiddlewareName\
29
+ " arrow::flight::TracingServerMiddleware::kMiddlewareName"
30
+
31
+ cdef cppclass CActionType" arrow::flight::ActionType":
32
+ c_string type
33
+ c_string description
34
+ bint operator==(CActionType)
35
+ CResult[c_string] SerializeToString()
36
+
37
+ @staticmethod
38
+ CResult[CActionType] Deserialize(const c_string& serialized)
39
+
40
+ cdef cppclass CAction" arrow::flight::Action":
41
+ c_string type
42
+ shared_ptr[CBuffer] body
43
+ bint operator==(CAction)
44
+ CResult[c_string] SerializeToString()
45
+ c_string ToString()
46
+
47
+ @staticmethod
48
+ CResult[CAction] Deserialize(const c_string& serialized)
49
+
50
+ cdef cppclass CFlightResult" arrow::flight::Result":
51
+ CFlightResult()
52
+ CFlightResult(CFlightResult)
53
+ shared_ptr[CBuffer] body
54
+ bint operator==(CFlightResult)
55
+ CResult[c_string] SerializeToString()
56
+ c_string ToString()
57
+
58
+ @staticmethod
59
+ CResult[CFlightResult] Deserialize(const c_string& serialized)
60
+
61
+ cdef cppclass CBasicAuth" arrow::flight::BasicAuth":
62
+ CBasicAuth()
63
+ CBasicAuth(CBuffer)
64
+ CBasicAuth(CBasicAuth)
65
+ c_string username
66
+ c_string password
67
+ bint operator==(CBasicAuth)
68
+ CResult[c_string] SerializeToString()
69
+ c_string ToString()
70
+
71
+ @staticmethod
72
+ CResult[CBasicAuth] Deserialize(const c_string& serialized)
73
+
74
+ cdef cppclass CResultStream" arrow::flight::ResultStream":
75
+ CResult[unique_ptr[CFlightResult]] Next()
76
+
77
+ cdef cppclass CDescriptorType \
78
+ " arrow::flight::FlightDescriptor::DescriptorType":
79
+ bint operator==(CDescriptorType)
80
+
81
+ CDescriptorType CDescriptorTypeUnknown\
82
+ " arrow::flight::FlightDescriptor::UNKNOWN"
83
+ CDescriptorType CDescriptorTypePath\
84
+ " arrow::flight::FlightDescriptor::PATH"
85
+ CDescriptorType CDescriptorTypeCmd\
86
+ " arrow::flight::FlightDescriptor::CMD"
87
+
88
+ cdef cppclass CFlightDescriptor" arrow::flight::FlightDescriptor":
89
+ CDescriptorType type
90
+ c_string cmd
91
+ vector[c_string] path
92
+ bint operator==(CFlightDescriptor)
93
+ CResult[c_string] SerializeToString()
94
+ c_string ToString()
95
+
96
+ @staticmethod
97
+ CResult[CFlightDescriptor] Deserialize(const c_string& serialized)
98
+
99
+ cdef cppclass CTicket" arrow::flight::Ticket":
100
+ CTicket()
101
+ c_string ticket
102
+ bint operator==(CTicket)
103
+ CResult[c_string] SerializeToString()
104
+ c_string ToString()
105
+
106
+ @staticmethod
107
+ CResult[CTicket] Deserialize(const c_string& serialized)
108
+
109
+ cdef cppclass CCriteria" arrow::flight::Criteria":
110
+ CCriteria()
111
+ c_string expression
112
+ bint operator==(CCriteria)
113
+ CResult[c_string] SerializeToString()
114
+
115
+ @staticmethod
116
+ CResult[CCriteria] Deserialize(const c_string& serialized)
117
+
118
+ cdef cppclass CLocation" arrow::flight::Location":
119
+ CLocation()
120
+ c_string ToString()
121
+ c_bool Equals(const CLocation& other)
122
+
123
+ @staticmethod
124
+ CResult[CLocation] Parse(const c_string& uri_string)
125
+
126
+ @staticmethod
127
+ CResult[CLocation] ForGrpcTcp(const c_string& host, int port)
128
+
129
+ @staticmethod
130
+ CResult[CLocation] ForGrpcTls(const c_string& host, int port)
131
+
132
+ @staticmethod
133
+ CResult[CLocation] ForGrpcUnix(const c_string& path)
134
+
135
+ cdef cppclass CFlightEndpoint" arrow::flight::FlightEndpoint":
136
+ CFlightEndpoint()
137
+
138
+ CTicket ticket
139
+ vector[CLocation] locations
140
+ optional[CTimePoint] expiration_time
141
+ c_string app_metadata
142
+
143
+ bint operator==(CFlightEndpoint)
144
+ CResult[c_string] SerializeToString()
145
+ c_string ToString()
146
+
147
+ @staticmethod
148
+ CResult[CFlightEndpoint] Deserialize(const c_string& serialized)
149
+
150
+ cdef cppclass CFlightInfo" arrow::flight::FlightInfo":
151
+ CFlightInfo(CFlightInfo info)
152
+ int64_t total_records()
153
+ int64_t total_bytes()
154
+ c_bool ordered()
155
+ c_string app_metadata()
156
+ CResult[shared_ptr[CSchema]] GetSchema(CDictionaryMemo* memo)
157
+ CFlightDescriptor& descriptor()
158
+ const vector[CFlightEndpoint]& endpoints()
159
+ CResult[c_string] SerializeToString()
160
+ c_string ToString()
161
+ bint operator==(CFlightInfo)
162
+
163
+ @staticmethod
164
+ CResult[unique_ptr[CFlightInfo]] Deserialize(
165
+ const c_string& serialized)
166
+
167
+ cdef cppclass CSchemaResult" arrow::flight::SchemaResult":
168
+ CSchemaResult()
169
+ CSchemaResult(CSchemaResult result)
170
+ CResult[shared_ptr[CSchema]] GetSchema(CDictionaryMemo* memo)
171
+ bint operator==(CSchemaResult)
172
+ CResult[c_string] SerializeToString()
173
+ c_string ToString()
174
+
175
+ @staticmethod
176
+ CResult[CSchemaResult] Deserialize(const c_string& serialized)
177
+
178
+ cdef cppclass CFlightListing" arrow::flight::FlightListing":
179
+ CResult[unique_ptr[CFlightInfo]] Next()
180
+
181
+ cdef cppclass CSimpleFlightListing" arrow::flight::SimpleFlightListing":
182
+ # This doesn't work with Cython >= 3
183
+ # CSimpleFlightListing(vector[CFlightInfo]&& info)
184
+ CSimpleFlightListing(const vector[CFlightInfo]& info)
185
+
186
+ cdef cppclass CFlightPayload" arrow::flight::FlightPayload":
187
+ shared_ptr[CBuffer] descriptor
188
+ shared_ptr[CBuffer] app_metadata
189
+ CIpcPayload ipc_message
190
+
191
+ cdef cppclass CFlightDataStream" arrow::flight::FlightDataStream":
192
+ shared_ptr[CSchema] schema()
193
+ CResult[CFlightPayload] Next()
194
+
195
+ cdef cppclass CFlightStreamChunk" arrow::flight::FlightStreamChunk":
196
+ CFlightStreamChunk()
197
+ shared_ptr[CRecordBatch] data
198
+ shared_ptr[CBuffer] app_metadata
199
+
200
+ cdef cppclass CMetadataRecordBatchReader \
201
+ " arrow::flight::MetadataRecordBatchReader":
202
+ CResult[shared_ptr[CSchema]] GetSchema()
203
+ CResult[CFlightStreamChunk] Next()
204
+ CResult[shared_ptr[CTable]] ToTable()
205
+ CIpcReadStats stats() const
206
+
207
+ CResult[shared_ptr[CRecordBatchReader]] MakeRecordBatchReader\
208
+ " arrow::flight::MakeRecordBatchReader"(
209
+ shared_ptr[CMetadataRecordBatchReader])
210
+
211
+ cdef cppclass CMetadataRecordBatchWriter \
212
+ " arrow::flight::MetadataRecordBatchWriter"(CRecordBatchWriter):
213
+ CStatus Begin(shared_ptr[CSchema] schema,
214
+ const CIpcWriteOptions& options)
215
+ CStatus WriteMetadata(shared_ptr[CBuffer] app_metadata)
216
+ CStatus WriteWithMetadata(const CRecordBatch& batch,
217
+ shared_ptr[CBuffer] app_metadata)
218
+
219
+ cdef cppclass CFlightStreamReader \
220
+ " arrow::flight::FlightStreamReader"(CMetadataRecordBatchReader):
221
+ void Cancel()
222
+ CResult[shared_ptr[CTable]] ToTableWithStopToken" ToTable"\
223
+ (const CStopToken& stop_token)
224
+
225
+ cdef cppclass CFlightMessageReader \
226
+ " arrow::flight::FlightMessageReader"(CMetadataRecordBatchReader):
227
+ CFlightDescriptor& descriptor()
228
+
229
+ cdef cppclass CFlightMessageWriter \
230
+ " arrow::flight::FlightMessageWriter"(CMetadataRecordBatchWriter):
231
+ pass
232
+
233
+ cdef cppclass CFlightStreamWriter \
234
+ " arrow::flight::FlightStreamWriter"(CMetadataRecordBatchWriter):
235
+ CStatus DoneWriting()
236
+
237
+ cdef cppclass CRecordBatchStream \
238
+ " arrow::flight::RecordBatchStream"(CFlightDataStream):
239
+ CRecordBatchStream(shared_ptr[CRecordBatchReader]& reader,
240
+ const CIpcWriteOptions& options)
241
+
242
+ cdef cppclass CFlightMetadataReader" arrow::flight::FlightMetadataReader":
243
+ CStatus ReadMetadata(shared_ptr[CBuffer]* out)
244
+
245
+ cdef cppclass CFlightMetadataWriter" arrow::flight::FlightMetadataWriter":
246
+ CStatus WriteMetadata(const CBuffer& message)
247
+
248
+ cdef cppclass CServerAuthReader" arrow::flight::ServerAuthReader":
249
+ CStatus Read(c_string* token)
250
+
251
+ cdef cppclass CServerAuthSender" arrow::flight::ServerAuthSender":
252
+ CStatus Write(c_string& token)
253
+
254
+ cdef cppclass CClientAuthReader" arrow::flight::ClientAuthReader":
255
+ CStatus Read(c_string* token)
256
+
257
+ cdef cppclass CClientAuthSender" arrow::flight::ClientAuthSender":
258
+ CStatus Write(c_string& token)
259
+
260
+ cdef cppclass CServerAuthHandler" arrow::flight::ServerAuthHandler":
261
+ pass
262
+
263
+ cdef cppclass CClientAuthHandler" arrow::flight::ClientAuthHandler":
264
+ pass
265
+
266
+ cdef cppclass CServerCallContext" arrow::flight::ServerCallContext":
267
+ c_string& peer_identity()
268
+ c_string& peer()
269
+ c_bool is_cancelled()
270
+ void AddHeader(const c_string& key, const c_string& value)
271
+ void AddTrailer(const c_string& key, const c_string& value)
272
+ CServerMiddleware* GetMiddleware(const c_string& key)
273
+
274
+ cdef cppclass CTimeoutDuration" arrow::flight::TimeoutDuration":
275
+ CTimeoutDuration(double)
276
+ double count()
277
+
278
+ cdef cppclass CFlightCallOptions" arrow::flight::FlightCallOptions":
279
+ CFlightCallOptions()
280
+ CTimeoutDuration timeout
281
+ CIpcWriteOptions write_options
282
+ CIpcReadOptions read_options
283
+ vector[pair[c_string, c_string]] headers
284
+ CStopToken stop_token
285
+
286
+ cdef cppclass CCertKeyPair" arrow::flight::CertKeyPair":
287
+ CCertKeyPair()
288
+ c_string pem_cert
289
+ c_string pem_key
290
+
291
+ cdef cppclass CFlightMethod" arrow::flight::FlightMethod":
292
+ bint operator==(CFlightMethod)
293
+
294
+ CFlightMethod CFlightMethodInvalid\
295
+ " arrow::flight::FlightMethod::Invalid"
296
+ CFlightMethod CFlightMethodHandshake\
297
+ " arrow::flight::FlightMethod::Handshake"
298
+ CFlightMethod CFlightMethodListFlights\
299
+ " arrow::flight::FlightMethod::ListFlights"
300
+ CFlightMethod CFlightMethodGetFlightInfo\
301
+ " arrow::flight::FlightMethod::GetFlightInfo"
302
+ CFlightMethod CFlightMethodGetSchema\
303
+ " arrow::flight::FlightMethod::GetSchema"
304
+ CFlightMethod CFlightMethodDoGet\
305
+ " arrow::flight::FlightMethod::DoGet"
306
+ CFlightMethod CFlightMethodDoPut\
307
+ " arrow::flight::FlightMethod::DoPut"
308
+ CFlightMethod CFlightMethodDoAction\
309
+ " arrow::flight::FlightMethod::DoAction"
310
+ CFlightMethod CFlightMethodListActions\
311
+ " arrow::flight::FlightMethod::ListActions"
312
+ CFlightMethod CFlightMethodDoExchange\
313
+ " arrow::flight::FlightMethod::DoExchange"
314
+
315
+ cdef cppclass CCallInfo" arrow::flight::CallInfo":
316
+ CFlightMethod method
317
+
318
+ ctypedef multimap[cpp_string_view, cpp_string_view] CCallHeaders\
319
+ " arrow::flight::CallHeaders"
320
+
321
+ cdef cppclass CAddCallHeaders" arrow::flight::AddCallHeaders":
322
+ void AddHeader(const c_string& key, const c_string& value)
323
+
324
+ cdef cppclass CServerMiddleware" arrow::flight::ServerMiddleware":
325
+ c_string name()
326
+
327
+ cdef cppclass CServerMiddlewareFactory\
328
+ " arrow::flight::ServerMiddlewareFactory":
329
+ pass
330
+
331
+ cdef cppclass CClientMiddleware" arrow::flight::ClientMiddleware":
332
+ pass
333
+
334
+ cdef cppclass CClientMiddlewareFactory\
335
+ " arrow::flight::ClientMiddlewareFactory":
336
+ pass
337
+
338
+ cpdef cppclass CTracingServerMiddlewareTraceKey\
339
+ " arrow::flight::TracingServerMiddleware::TraceKey":
340
+ CTracingServerMiddlewareTraceKey()
341
+ c_string key
342
+ c_string value
343
+
344
+ cdef cppclass CTracingServerMiddleware\
345
+ " arrow::flight::TracingServerMiddleware"(CServerMiddleware):
346
+ vector[CTracingServerMiddlewareTraceKey] GetTraceContext()
347
+
348
+ cdef shared_ptr[CServerMiddlewareFactory] \
349
+ MakeTracingServerMiddlewareFactory\
350
+ " arrow::flight::MakeTracingServerMiddlewareFactory"()
351
+
352
+ cdef cppclass CFlightServerOptions" arrow::flight::FlightServerOptions":
353
+ CFlightServerOptions(const CLocation& location)
354
+ CLocation location
355
+ unique_ptr[CServerAuthHandler] auth_handler
356
+ vector[CCertKeyPair] tls_certificates
357
+ c_bool verify_client
358
+ c_string root_certificates
359
+ vector[pair[c_string, shared_ptr[CServerMiddlewareFactory]]] middleware
360
+
361
+ cdef cppclass CFlightClientOptions" arrow::flight::FlightClientOptions":
362
+ c_string tls_root_certs
363
+ c_string cert_chain
364
+ c_string private_key
365
+ c_string override_hostname
366
+ vector[shared_ptr[CClientMiddlewareFactory]] middleware
367
+ int64_t write_size_limit_bytes
368
+ vector[pair[c_string, CIntStringVariant]] generic_options
369
+ c_bool disable_server_verification
370
+
371
+ @staticmethod
372
+ CFlightClientOptions Defaults()
373
+
374
+ cdef cppclass CDoPutResult" arrow::flight::FlightClient::DoPutResult":
375
+ unique_ptr[CFlightStreamWriter] writer
376
+ unique_ptr[CFlightMetadataReader] reader
377
+
378
+ cdef cppclass CDoExchangeResult" arrow::flight::FlightClient::DoExchangeResult":
379
+ unique_ptr[CFlightStreamWriter] writer
380
+ unique_ptr[CFlightStreamReader] reader
381
+
382
+ cdef cppclass CFlightClient" arrow::flight::FlightClient":
383
+ @staticmethod
384
+ CResult[unique_ptr[CFlightClient]] Connect(const CLocation& location,
385
+ const CFlightClientOptions& options)
386
+
387
+ c_bool supports_async()
388
+ CStatus CheckAsyncSupport()
389
+
390
+ CStatus Authenticate(CFlightCallOptions& options,
391
+ unique_ptr[CClientAuthHandler] auth_handler)
392
+
393
+ CResult[pair[c_string, c_string]] AuthenticateBasicToken(
394
+ CFlightCallOptions& options,
395
+ const c_string& username,
396
+ const c_string& password)
397
+
398
+ CResult[unique_ptr[CResultStream]] DoAction(CFlightCallOptions& options, CAction& action)
399
+ CResult[vector[CActionType]] ListActions(CFlightCallOptions& options)
400
+
401
+ CResult[unique_ptr[CFlightListing]] ListFlights(CFlightCallOptions& options, CCriteria criteria)
402
+ CResult[unique_ptr[CFlightInfo]] GetFlightInfo(CFlightCallOptions& options,
403
+ CFlightDescriptor& descriptor)
404
+ CFuture[CFlightInfo] GetFlightInfoAsync(CFlightCallOptions& options,
405
+ CFlightDescriptor& descriptor)
406
+ CResult[unique_ptr[CSchemaResult]] GetSchema(CFlightCallOptions& options,
407
+ CFlightDescriptor& descriptor)
408
+ CResult[unique_ptr[CFlightStreamReader]] DoGet(CFlightCallOptions& options, CTicket& ticket)
409
+ CResult[CDoPutResult] DoPut(CFlightCallOptions& options,
410
+ CFlightDescriptor& descriptor,
411
+ shared_ptr[CSchema]& schema)
412
+ CResult[CDoExchangeResult] DoExchange(CFlightCallOptions& options,
413
+ CFlightDescriptor& descriptor)
414
+ CStatus Close()
415
+
416
+ cdef cppclass CFlightStatusCode" arrow::flight::FlightStatusCode":
417
+ bint operator==(CFlightStatusCode)
418
+
419
+ CFlightStatusCode CFlightStatusInternal \
420
+ " arrow::flight::FlightStatusCode::Internal"
421
+ CFlightStatusCode CFlightStatusTimedOut \
422
+ " arrow::flight::FlightStatusCode::TimedOut"
423
+ CFlightStatusCode CFlightStatusCancelled \
424
+ " arrow::flight::FlightStatusCode::Cancelled"
425
+ CFlightStatusCode CFlightStatusUnauthenticated \
426
+ " arrow::flight::FlightStatusCode::Unauthenticated"
427
+ CFlightStatusCode CFlightStatusUnauthorized \
428
+ " arrow::flight::FlightStatusCode::Unauthorized"
429
+ CFlightStatusCode CFlightStatusUnavailable \
430
+ " arrow::flight::FlightStatusCode::Unavailable"
431
+ CFlightStatusCode CFlightStatusFailed \
432
+ " arrow::flight::FlightStatusCode::Failed"
433
+
434
+ cdef cppclass FlightStatusDetail" arrow::flight::FlightStatusDetail":
435
+ CFlightStatusCode code()
436
+ c_string extra_info()
437
+
438
+ @staticmethod
439
+ shared_ptr[FlightStatusDetail] UnwrapStatus(const CStatus& status)
440
+
441
+ cdef cppclass FlightWriteSizeStatusDetail\
442
+ " arrow::flight::FlightWriteSizeStatusDetail":
443
+ int64_t limit()
444
+ int64_t actual()
445
+
446
+ @staticmethod
447
+ shared_ptr[FlightWriteSizeStatusDetail] UnwrapStatus(
448
+ const CStatus& status)
449
+
450
+ cdef CStatus MakeFlightError" arrow::flight::MakeFlightError" \
451
+ (CFlightStatusCode code, const c_string& message)
452
+
453
+ cdef CStatus MakeFlightError" arrow::flight::MakeFlightError" \
454
+ (CFlightStatusCode code,
455
+ const c_string& message,
456
+ const c_string& extra_info)
457
+
458
+ # Callbacks for implementing Flight servers
459
+ # Use typedef to emulate syntax for std::function<void(..)>
460
+ ctypedef CStatus cb_list_flights(object, const CServerCallContext&,
461
+ const CCriteria*,
462
+ unique_ptr[CFlightListing]*)
463
+ ctypedef CStatus cb_get_flight_info(object, const CServerCallContext&,
464
+ const CFlightDescriptor&,
465
+ unique_ptr[CFlightInfo]*)
466
+ ctypedef CStatus cb_get_schema(object, const CServerCallContext&,
467
+ const CFlightDescriptor&,
468
+ unique_ptr[CSchemaResult]*)
469
+ ctypedef CStatus cb_do_put(object, const CServerCallContext&,
470
+ unique_ptr[CFlightMessageReader],
471
+ unique_ptr[CFlightMetadataWriter])
472
+ ctypedef CStatus cb_do_get(object, const CServerCallContext&,
473
+ const CTicket&,
474
+ unique_ptr[CFlightDataStream]*)
475
+ ctypedef CStatus cb_do_exchange(object, const CServerCallContext&,
476
+ unique_ptr[CFlightMessageReader],
477
+ unique_ptr[CFlightMessageWriter])
478
+ ctypedef CStatus cb_do_action(object, const CServerCallContext&,
479
+ const CAction&,
480
+ unique_ptr[CResultStream]*)
481
+ ctypedef CStatus cb_list_actions(object, const CServerCallContext&,
482
+ vector[CActionType]*)
483
+ ctypedef CStatus cb_result_next(object, unique_ptr[CFlightResult]*)
484
+ ctypedef CStatus cb_data_stream_next(object, CFlightPayload*)
485
+ ctypedef CStatus cb_server_authenticate(object, CServerAuthSender*,
486
+ CServerAuthReader*)
487
+ ctypedef CStatus cb_is_valid(object, const c_string&, c_string*)
488
+ ctypedef CStatus cb_client_authenticate(object, CClientAuthSender*,
489
+ CClientAuthReader*)
490
+ ctypedef CStatus cb_get_token(object, c_string*)
491
+
492
+ ctypedef CStatus cb_middleware_sending_headers(object, CAddCallHeaders*)
493
+ ctypedef CStatus cb_middleware_call_completed(object, const CStatus&)
494
+ ctypedef CStatus cb_client_middleware_received_headers(
495
+ object, const CCallHeaders&)
496
+ ctypedef CStatus cb_server_middleware_start_call(
497
+ object,
498
+ const CCallInfo&,
499
+ const CCallHeaders&,
500
+ shared_ptr[CServerMiddleware]*)
501
+ ctypedef CStatus cb_client_middleware_start_call(
502
+ object,
503
+ const CCallInfo&,
504
+ unique_ptr[CClientMiddleware]*)
505
+
506
+ cdef extern from "arrow/python/flight.h" namespace "arrow::py::flight" nogil:
507
+ cdef char* CPyServerMiddlewareName\
508
+ " arrow::py::flight::kPyServerMiddlewareName"
509
+
510
+ cdef cppclass PyFlightServerVtable:
511
+ PyFlightServerVtable()
512
+ function[cb_list_flights] list_flights
513
+ function[cb_get_flight_info] get_flight_info
514
+ function[cb_get_schema] get_schema
515
+ function[cb_do_put] do_put
516
+ function[cb_do_get] do_get
517
+ function[cb_do_exchange] do_exchange
518
+ function[cb_do_action] do_action
519
+ function[cb_list_actions] list_actions
520
+
521
+ cdef cppclass PyServerAuthHandlerVtable:
522
+ PyServerAuthHandlerVtable()
523
+ function[cb_server_authenticate] authenticate
524
+ function[cb_is_valid] is_valid
525
+
526
+ cdef cppclass PyClientAuthHandlerVtable:
527
+ PyClientAuthHandlerVtable()
528
+ function[cb_client_authenticate] authenticate
529
+ function[cb_get_token] get_token
530
+
531
+ cdef cppclass PyFlightServer:
532
+ PyFlightServer(object server, PyFlightServerVtable vtable)
533
+
534
+ CStatus Init(CFlightServerOptions& options)
535
+ int port()
536
+ CStatus ServeWithSignals() except *
537
+ CStatus Shutdown()
538
+ CStatus Wait()
539
+
540
+ cdef cppclass PyServerAuthHandler\
541
+ " arrow::py::flight::PyServerAuthHandler"(CServerAuthHandler):
542
+ PyServerAuthHandler(object handler, PyServerAuthHandlerVtable vtable)
543
+
544
+ cdef cppclass PyClientAuthHandler\
545
+ " arrow::py::flight::PyClientAuthHandler"(CClientAuthHandler):
546
+ PyClientAuthHandler(object handler, PyClientAuthHandlerVtable vtable)
547
+
548
+ cdef cppclass CPyFlightResultStream\
549
+ " arrow::py::flight::PyFlightResultStream"(CResultStream):
550
+ CPyFlightResultStream(object generator,
551
+ function[cb_result_next] callback)
552
+
553
+ cdef cppclass CPyFlightDataStream\
554
+ " arrow::py::flight::PyFlightDataStream"(CFlightDataStream):
555
+ CPyFlightDataStream(object data_source,
556
+ unique_ptr[CFlightDataStream] stream)
557
+
558
+ cdef cppclass CPyGeneratorFlightDataStream\
559
+ " arrow::py::flight::PyGeneratorFlightDataStream"\
560
+ (CFlightDataStream):
561
+ CPyGeneratorFlightDataStream(object generator,
562
+ shared_ptr[CSchema] schema,
563
+ function[cb_data_stream_next] callback,
564
+ const CIpcWriteOptions& options)
565
+
566
+ cdef cppclass PyServerMiddlewareVtable\
567
+ " arrow::py::flight::PyServerMiddleware::Vtable":
568
+ PyServerMiddlewareVtable()
569
+ function[cb_middleware_sending_headers] sending_headers
570
+ function[cb_middleware_call_completed] call_completed
571
+
572
+ cdef cppclass PyClientMiddlewareVtable\
573
+ " arrow::py::flight::PyClientMiddleware::Vtable":
574
+ PyClientMiddlewareVtable()
575
+ function[cb_middleware_sending_headers] sending_headers
576
+ function[cb_client_middleware_received_headers] received_headers
577
+ function[cb_middleware_call_completed] call_completed
578
+
579
+ cdef cppclass CPyServerMiddleware\
580
+ " arrow::py::flight::PyServerMiddleware"(CServerMiddleware):
581
+ CPyServerMiddleware(object middleware, PyServerMiddlewareVtable vtable)
582
+ void* py_object()
583
+
584
+ cdef cppclass CPyServerMiddlewareFactory\
585
+ " arrow::py::flight::PyServerMiddlewareFactory"\
586
+ (CServerMiddlewareFactory):
587
+ CPyServerMiddlewareFactory(
588
+ object factory,
589
+ function[cb_server_middleware_start_call] start_call)
590
+
591
+ cdef cppclass CPyClientMiddleware\
592
+ " arrow::py::flight::PyClientMiddleware"(CClientMiddleware):
593
+ CPyClientMiddleware(object middleware, PyClientMiddlewareVtable vtable)
594
+
595
+ cdef cppclass CPyClientMiddlewareFactory\
596
+ " arrow::py::flight::PyClientMiddlewareFactory"\
597
+ (CClientMiddlewareFactory):
598
+ CPyClientMiddlewareFactory(
599
+ object factory,
600
+ function[cb_client_middleware_start_call] start_call)
601
+
602
+ cdef CStatus CreateFlightInfo" arrow::py::flight::CreateFlightInfo"(
603
+ shared_ptr[CSchema] schema,
604
+ CFlightDescriptor& descriptor,
605
+ vector[CFlightEndpoint] endpoints,
606
+ int64_t total_records,
607
+ int64_t total_bytes,
608
+ c_bool ordered,
609
+ const c_string& app_metadata,
610
+ unique_ptr[CFlightInfo]* out)
611
+
612
+ cdef CStatus CreateSchemaResult" arrow::py::flight::CreateSchemaResult"(
613
+ shared_ptr[CSchema] schema,
614
+ unique_ptr[CSchemaResult]* out)
615
+
616
+
617
+ cdef extern from "<variant>" namespace "std" nogil:
618
+ cdef cppclass CIntStringVariant" std::variant<int, std::string>":
619
+ CIntStringVariant()
620
+ CIntStringVariant(int)
621
+ CIntStringVariant(c_string)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_fs.pxd ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.common cimport *
21
+ from pyarrow.includes.libarrow cimport *
22
+ from pyarrow.includes.libarrow_python cimport CTimePoint
23
+
24
+ cdef extern from "arrow/filesystem/api.h" namespace "arrow::fs" nogil:
25
+
26
+ ctypedef enum CFileType "arrow::fs::FileType":
27
+ CFileType_NotFound "arrow::fs::FileType::NotFound"
28
+ CFileType_Unknown "arrow::fs::FileType::Unknown"
29
+ CFileType_File "arrow::fs::FileType::File"
30
+ CFileType_Directory "arrow::fs::FileType::Directory"
31
+
32
+ cdef cppclass CFileInfo "arrow::fs::FileInfo":
33
+ CFileInfo()
34
+ CFileInfo(CFileInfo)
35
+ CFileInfo& operator=(CFileInfo)
36
+ CFileInfo(const CFileInfo&)
37
+ CFileInfo& operator=(const CFileInfo&)
38
+
39
+ CFileType type()
40
+ void set_type(CFileType type)
41
+ c_string path()
42
+ void set_path(const c_string& path)
43
+ c_string base_name()
44
+ int64_t size()
45
+ void set_size(int64_t size)
46
+ c_string extension()
47
+ CTimePoint mtime()
48
+ void set_mtime(CTimePoint mtime)
49
+
50
+ cdef cppclass CFileSelector "arrow::fs::FileSelector":
51
+ CFileSelector()
52
+ c_string base_dir
53
+ c_bool allow_not_found
54
+ c_bool recursive
55
+
56
+ cdef cppclass CFileLocator "arrow::fs::FileLocator":
57
+ shared_ptr[CFileSystem] filesystem
58
+ c_string path
59
+
60
+ cdef cppclass CFileSystem "arrow::fs::FileSystem":
61
+ shared_ptr[CFileSystem] shared_from_this()
62
+ c_string type_name() const
63
+ CResult[c_string] NormalizePath(c_string path)
64
+ CResult[c_string] MakeUri(c_string path)
65
+ CResult[CFileInfo] GetFileInfo(const c_string& path)
66
+ CResult[vector[CFileInfo]] GetFileInfo(
67
+ const vector[c_string]& paths)
68
+ CResult[vector[CFileInfo]] GetFileInfo(const CFileSelector& select)
69
+ CStatus CreateDir(const c_string& path, c_bool recursive)
70
+ CStatus DeleteDir(const c_string& path)
71
+ CStatus DeleteDirContents(const c_string& path, c_bool missing_dir_ok)
72
+ CStatus DeleteRootDirContents()
73
+ CStatus DeleteFile(const c_string& path)
74
+ CStatus DeleteFiles(const vector[c_string]& paths)
75
+ CStatus Move(const c_string& src, const c_string& dest)
76
+ CStatus CopyFile(const c_string& src, const c_string& dest)
77
+ CResult[shared_ptr[CInputStream]] OpenInputStream(
78
+ const c_string& path)
79
+ CResult[shared_ptr[CRandomAccessFile]] OpenInputFile(
80
+ const c_string& path)
81
+ CResult[shared_ptr[COutputStream]] OpenOutputStream(
82
+ const c_string& path, const shared_ptr[const CKeyValueMetadata]&)
83
+ CResult[shared_ptr[COutputStream]] OpenAppendStream(
84
+ const c_string& path, const shared_ptr[const CKeyValueMetadata]&)
85
+ c_bool Equals(const CFileSystem& other)
86
+ c_bool Equals(shared_ptr[CFileSystem] other)
87
+
88
+ CResult[shared_ptr[CFileSystem]] CFileSystemFromUri \
89
+ "arrow::fs::FileSystemFromUri"(const c_string& uri)
90
+ CResult[shared_ptr[CFileSystem]] CFileSystemFromUri \
91
+ "arrow::fs::FileSystemFromUri"(const c_string& uri, c_string* out_path)
92
+ CResult[shared_ptr[CFileSystem]] CFileSystemFromUriOrPath \
93
+ "arrow::fs::FileSystemFromUriOrPath"(const c_string& uri,
94
+ c_string* out_path)
95
+
96
+ cdef cppclass CFileSystemGlobalOptions \
97
+ "arrow::fs::FileSystemGlobalOptions":
98
+ c_string tls_ca_file_path
99
+ c_string tls_ca_dir_path
100
+
101
+ CStatus CFileSystemsInitialize "arrow::fs::Initialize" \
102
+ (const CFileSystemGlobalOptions& options)
103
+
104
+ cdef cppclass CSubTreeFileSystem \
105
+ "arrow::fs::SubTreeFileSystem"(CFileSystem):
106
+ CSubTreeFileSystem(const c_string& base_path,
107
+ shared_ptr[CFileSystem] base_fs)
108
+ c_string base_path()
109
+ shared_ptr[CFileSystem] base_fs()
110
+
111
+ ctypedef enum CS3LogLevel "arrow::fs::S3LogLevel":
112
+ CS3LogLevel_Off "arrow::fs::S3LogLevel::Off"
113
+ CS3LogLevel_Fatal "arrow::fs::S3LogLevel::Fatal"
114
+ CS3LogLevel_Error "arrow::fs::S3LogLevel::Error"
115
+ CS3LogLevel_Warn "arrow::fs::S3LogLevel::Warn"
116
+ CS3LogLevel_Info "arrow::fs::S3LogLevel::Info"
117
+ CS3LogLevel_Debug "arrow::fs::S3LogLevel::Debug"
118
+ CS3LogLevel_Trace "arrow::fs::S3LogLevel::Trace"
119
+
120
+ cdef struct CS3GlobalOptions "arrow::fs::S3GlobalOptions":
121
+ CS3LogLevel log_level
122
+ int num_event_loop_threads
123
+
124
+ cdef cppclass CS3ProxyOptions "arrow::fs::S3ProxyOptions":
125
+ c_string scheme
126
+ c_string host
127
+ int port
128
+ c_string username
129
+ c_string password
130
+ c_bool Equals(const CS3ProxyOptions& other)
131
+
132
+ @staticmethod
133
+ CResult[CS3ProxyOptions] FromUriString "FromUri"(
134
+ const c_string& uri_string)
135
+
136
+ ctypedef enum CS3CredentialsKind "arrow::fs::S3CredentialsKind":
137
+ CS3CredentialsKind_Anonymous "arrow::fs::S3CredentialsKind::Anonymous"
138
+ CS3CredentialsKind_Default "arrow::fs::S3CredentialsKind::Default"
139
+ CS3CredentialsKind_Explicit "arrow::fs::S3CredentialsKind::Explicit"
140
+ CS3CredentialsKind_Role "arrow::fs::S3CredentialsKind::Role"
141
+ CS3CredentialsKind_WebIdentity \
142
+ "arrow::fs::S3CredentialsKind::WebIdentity"
143
+
144
+ cdef cppclass CS3RetryStrategy "arrow::fs::S3RetryStrategy":
145
+ @staticmethod
146
+ shared_ptr[CS3RetryStrategy] GetAwsDefaultRetryStrategy(int64_t max_attempts)
147
+
148
+ @staticmethod
149
+ shared_ptr[CS3RetryStrategy] GetAwsStandardRetryStrategy(int64_t max_attempts)
150
+
151
+ cdef cppclass CS3Options "arrow::fs::S3Options":
152
+ c_string region
153
+ double connect_timeout
154
+ double request_timeout
155
+ c_string endpoint_override
156
+ c_string scheme
157
+ c_bool background_writes
158
+ c_bool allow_delayed_open
159
+ c_bool allow_bucket_creation
160
+ c_bool allow_bucket_deletion
161
+ c_bool check_directory_existence_before_creation
162
+ c_bool force_virtual_addressing
163
+ c_string tls_ca_file_path
164
+ shared_ptr[const CKeyValueMetadata] default_metadata
165
+ c_string role_arn
166
+ c_string session_name
167
+ c_string external_id
168
+ int load_frequency
169
+ CS3ProxyOptions proxy_options
170
+ CS3CredentialsKind credentials_kind
171
+ shared_ptr[CS3RetryStrategy] retry_strategy
172
+ void ConfigureDefaultCredentials()
173
+ void ConfigureAccessKey(const c_string& access_key,
174
+ const c_string& secret_key,
175
+ const c_string& session_token)
176
+ c_string GetAccessKey()
177
+ c_string GetSecretKey()
178
+ c_string GetSessionToken()
179
+ c_bool Equals(const CS3Options& other)
180
+
181
+ @staticmethod
182
+ CS3Options Defaults()
183
+
184
+ @staticmethod
185
+ CS3Options Anonymous()
186
+
187
+ @staticmethod
188
+ CS3Options FromAccessKey(const c_string& access_key,
189
+ const c_string& secret_key,
190
+ const c_string& session_token)
191
+
192
+ @staticmethod
193
+ CS3Options FromAssumeRole(const c_string& role_arn,
194
+ const c_string& session_name,
195
+ const c_string& external_id,
196
+ const int load_frequency)
197
+
198
+ cdef cppclass CS3FileSystem "arrow::fs::S3FileSystem"(CFileSystem):
199
+ @staticmethod
200
+ CResult[shared_ptr[CS3FileSystem]] Make(const CS3Options& options)
201
+ CS3Options options()
202
+ c_string region()
203
+
204
+ cdef CStatus CInitializeS3 "arrow::fs::InitializeS3"(
205
+ const CS3GlobalOptions& options)
206
+ cdef CStatus CEnsureS3Initialized "arrow::fs::EnsureS3Initialized"()
207
+ cdef CStatus CFinalizeS3 "arrow::fs::FinalizeS3"()
208
+ cdef CStatus CEnsureS3Finalized "arrow::fs::EnsureS3Finalized"()
209
+
210
+ cdef CResult[c_string] ResolveS3BucketRegion(const c_string& bucket)
211
+
212
+ cdef cppclass CGcsCredentials "arrow::fs::GcsCredentials":
213
+ c_bool anonymous()
214
+ CTimePoint expiration()
215
+ c_string access_token()
216
+ c_string target_service_account()
217
+
218
+ cdef cppclass CGcsOptions "arrow::fs::GcsOptions":
219
+ CGcsCredentials credentials
220
+ c_string endpoint_override
221
+ c_string scheme
222
+ c_string default_bucket_location
223
+ optional[c_string] project_id
224
+ optional[double] retry_limit_seconds
225
+ shared_ptr[const CKeyValueMetadata] default_metadata
226
+ c_bool Equals(const CS3Options& other)
227
+
228
+ @staticmethod
229
+ CGcsOptions Defaults()
230
+
231
+ @staticmethod
232
+ CGcsOptions Anonymous()
233
+
234
+ @staticmethod
235
+ CGcsOptions FromAccessToken(const c_string& access_token,
236
+ CTimePoint expiration)
237
+
238
+ @staticmethod
239
+ CGcsOptions FromImpersonatedServiceAccount(const CGcsCredentials& base_credentials,
240
+ c_string& target_service_account)
241
+
242
+ cdef cppclass CGcsFileSystem "arrow::fs::GcsFileSystem":
243
+ @staticmethod
244
+ CResult[shared_ptr[CGcsFileSystem]] Make(const CGcsOptions& options)
245
+ CGcsOptions options()
246
+
247
+ cdef cppclass CAzureOptions "arrow::fs::AzureOptions":
248
+ c_string account_name
249
+ c_string blob_storage_authority
250
+ c_string dfs_storage_authority
251
+ c_string blob_storage_scheme
252
+ c_string dfs_storage_scheme
253
+
254
+ c_bool Equals(const CAzureOptions& other)
255
+ CStatus ConfigureDefaultCredential()
256
+ CStatus ConfigureAccountKeyCredential(c_string account_key)
257
+ CStatus ConfigureSASCredential(c_string sas_token)
258
+ CStatus ConfigureManagedIdentityCredential(c_string client_id)
259
+ CStatus ConfigureClientSecretCredential(c_string tenant_id,
260
+ c_string client_id,
261
+ c_string client_secret)
262
+
263
+ cdef cppclass CAzureFileSystem "arrow::fs::AzureFileSystem":
264
+ @staticmethod
265
+ CResult[shared_ptr[CAzureFileSystem]] Make(const CAzureOptions& options)
266
+ CAzureOptions options()
267
+
268
+ cdef cppclass CHdfsOptions "arrow::fs::HdfsOptions":
269
+ HdfsConnectionConfig connection_config
270
+ int32_t buffer_size
271
+ int16_t replication
272
+ int64_t default_block_size
273
+
274
+ @staticmethod
275
+ CResult[CHdfsOptions] FromUriString "FromUri"(
276
+ const c_string& uri_string)
277
+ void ConfigureEndPoint(c_string host, int port)
278
+ void ConfigureDriver(c_bool use_hdfs3)
279
+ void ConfigureReplication(int16_t replication)
280
+ void ConfigureUser(c_string user_name)
281
+ void ConfigureBufferSize(int32_t buffer_size)
282
+ void ConfigureBlockSize(int64_t default_block_size)
283
+ void ConfigureKerberosTicketCachePath(c_string path)
284
+ void ConfigureExtraConf(c_string key, c_string value)
285
+
286
+ cdef cppclass CHadoopFileSystem "arrow::fs::HadoopFileSystem"(CFileSystem):
287
+ @staticmethod
288
+ CResult[shared_ptr[CHadoopFileSystem]] Make(
289
+ const CHdfsOptions& options)
290
+ CHdfsOptions options()
291
+
292
+ cdef cppclass CMockFileSystem "arrow::fs::internal::MockFileSystem"(
293
+ CFileSystem):
294
+ CMockFileSystem(CTimePoint current_time)
295
+
296
+ CStatus CCopyFiles "arrow::fs::CopyFiles"(
297
+ const vector[CFileLocator]& sources,
298
+ const vector[CFileLocator]& destinations,
299
+ const CIOContext& io_context,
300
+ int64_t chunk_size, c_bool use_threads)
301
+ CStatus CCopyFilesWithSelector "arrow::fs::CopyFiles"(
302
+ const shared_ptr[CFileSystem]& source_fs,
303
+ const CFileSelector& source_sel,
304
+ const shared_ptr[CFileSystem]& destination_fs,
305
+ const c_string& destination_base_dir,
306
+ const CIOContext& io_context,
307
+ int64_t chunk_size, c_bool use_threads)
308
+
309
+
310
+ # Callbacks for implementing Python filesystems
311
+ # Use typedef to emulate syntax for std::function<void(..)>
312
+ ctypedef void CallbackGetTypeName(object, c_string*)
313
+ ctypedef c_bool CallbackEquals(object, const CFileSystem&)
314
+
315
+ ctypedef void CallbackGetFileInfo(object, const c_string&, CFileInfo*)
316
+ ctypedef void CallbackGetFileInfoVector(object, const vector[c_string]&,
317
+ vector[CFileInfo]*)
318
+ ctypedef void CallbackGetFileInfoSelector(object, const CFileSelector&,
319
+ vector[CFileInfo]*)
320
+ ctypedef void CallbackCreateDir(object, const c_string&, c_bool)
321
+ ctypedef void CallbackDeleteDir(object, const c_string&)
322
+ ctypedef void CallbackDeleteDirContents(object, const c_string&, c_bool)
323
+ ctypedef void CallbackDeleteRootDirContents(object)
324
+ ctypedef void CallbackDeleteFile(object, const c_string&)
325
+ ctypedef void CallbackMove(object, const c_string&, const c_string&)
326
+ ctypedef void CallbackCopyFile(object, const c_string&, const c_string&)
327
+
328
+ ctypedef void CallbackOpenInputStream(object, const c_string&,
329
+ shared_ptr[CInputStream]*)
330
+ ctypedef void CallbackOpenInputFile(object, const c_string&,
331
+ shared_ptr[CRandomAccessFile]*)
332
+ ctypedef void CallbackOpenOutputStream(
333
+ object, const c_string&, const shared_ptr[const CKeyValueMetadata]&,
334
+ shared_ptr[COutputStream]*)
335
+ ctypedef void CallbackNormalizePath(object, const c_string&, c_string*)
336
+
337
+ cdef extern from "arrow/python/filesystem.h" namespace "arrow::py::fs" nogil:
338
+
339
+ cdef cppclass CPyFileSystemVtable "arrow::py::fs::PyFileSystemVtable":
340
+ PyFileSystemVtable()
341
+ function[CallbackGetTypeName] get_type_name
342
+ function[CallbackEquals] equals
343
+ function[CallbackGetFileInfo] get_file_info
344
+ function[CallbackGetFileInfoVector] get_file_info_vector
345
+ function[CallbackGetFileInfoSelector] get_file_info_selector
346
+ function[CallbackCreateDir] create_dir
347
+ function[CallbackDeleteDir] delete_dir
348
+ function[CallbackDeleteDirContents] delete_dir_contents
349
+ function[CallbackDeleteRootDirContents] delete_root_dir_contents
350
+ function[CallbackDeleteFile] delete_file
351
+ function[CallbackMove] move
352
+ function[CallbackCopyFile] copy_file
353
+ function[CallbackOpenInputStream] open_input_stream
354
+ function[CallbackOpenInputFile] open_input_file
355
+ function[CallbackOpenOutputStream] open_output_stream
356
+ function[CallbackOpenOutputStream] open_append_stream
357
+ function[CallbackNormalizePath] normalize_path
358
+
359
+ cdef cppclass CPyFileSystem "arrow::py::fs::PyFileSystem":
360
+ @staticmethod
361
+ shared_ptr[CPyFileSystem] Make(object handler,
362
+ CPyFileSystemVtable vtable)
363
+
364
+ PyObject* handler()
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_python.pxd ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.common cimport *
21
+ from pyarrow.includes.libarrow cimport *
22
+
23
+
24
+ ctypedef CInvalidRowResult PyInvalidRowCallback(object,
25
+ const CCSVInvalidRow&)
26
+
27
+
28
+ cdef extern from "arrow/python/csv.h" namespace "arrow::py::csv":
29
+
30
+ function[CInvalidRowHandler] MakeInvalidRowHandler(
31
+ function[PyInvalidRowCallback], object handler)
32
+
33
+
34
+ cdef extern from "arrow/python/api.h" namespace "arrow::py":
35
+ # Requires GIL
36
+ CResult[shared_ptr[CDataType]] InferArrowType(
37
+ object obj, object mask, c_bool pandas_null_sentinels)
38
+
39
+
40
+ cdef extern from "arrow/python/api.h" namespace "arrow::py::internal":
41
+ object NewMonthDayNanoTupleType()
42
+ CResult[PyObject*] MonthDayNanoIntervalArrayToPyList(
43
+ const CMonthDayNanoIntervalArray& array)
44
+ CResult[PyObject*] MonthDayNanoIntervalScalarToPyObject(
45
+ const CMonthDayNanoIntervalScalar& scalar)
46
+
47
+
48
+ cdef extern from "arrow/python/arrow_to_pandas.h" namespace "arrow::py::MapConversionType":
49
+ cdef enum MapConversionType "arrow::py::MapConversionType":
50
+ DEFAULT,
51
+ LOSSY,
52
+ STRICT_
53
+
54
+
55
+ cdef extern from "arrow/python/api.h" namespace "arrow::py" nogil:
56
+ shared_ptr[CDataType] GetPrimitiveType(Type type)
57
+
58
+ object PyFloat_FromHalf(uint16_t value)
59
+
60
+ cdef cppclass PyConversionOptions:
61
+ PyConversionOptions()
62
+
63
+ shared_ptr[CDataType] type
64
+ int64_t size
65
+ CMemoryPool* pool
66
+ c_bool from_pandas
67
+ c_bool ignore_timezone
68
+ c_bool strict
69
+
70
+ # TODO Some functions below are not actually "nogil"
71
+
72
+ CResult[shared_ptr[CChunkedArray]] ConvertPySequence(
73
+ object obj, object mask, const PyConversionOptions& options,
74
+ CMemoryPool* pool)
75
+
76
+ CResult[shared_ptr[CArray]] Arange(int64_t start, int64_t stop,
77
+ int64_t step, CMemoryPool* pool)
78
+
79
+ CResult[shared_ptr[CDataType]] NumPyDtypeToArrow(object dtype)
80
+
81
+ CStatus NdarrayToArrow(CMemoryPool* pool, object ao, object mo,
82
+ c_bool from_pandas,
83
+ const shared_ptr[CDataType]& type,
84
+ shared_ptr[CChunkedArray]* out)
85
+
86
+ CStatus NdarrayToArrow(CMemoryPool* pool, object ao, object mo,
87
+ c_bool from_pandas,
88
+ const shared_ptr[CDataType]& type,
89
+ const CCastOptions& cast_options,
90
+ shared_ptr[CChunkedArray]* out)
91
+
92
+ CStatus NdarrayToTensor(CMemoryPool* pool, object ao,
93
+ const vector[c_string]& dim_names,
94
+ shared_ptr[CTensor]* out)
95
+
96
+ CStatus TensorToNdarray(const shared_ptr[CTensor]& tensor, object base,
97
+ PyObject** out)
98
+
99
+ CStatus SparseCOOTensorToNdarray(
100
+ const shared_ptr[CSparseCOOTensor]& sparse_tensor, object base,
101
+ PyObject** out_data, PyObject** out_coords)
102
+
103
+ CStatus SparseCSRMatrixToNdarray(
104
+ const shared_ptr[CSparseCSRMatrix]& sparse_tensor, object base,
105
+ PyObject** out_data, PyObject** out_indptr, PyObject** out_indices)
106
+
107
+ CStatus SparseCSCMatrixToNdarray(
108
+ const shared_ptr[CSparseCSCMatrix]& sparse_tensor, object base,
109
+ PyObject** out_data, PyObject** out_indptr, PyObject** out_indices)
110
+
111
+ CStatus SparseCSFTensorToNdarray(
112
+ const shared_ptr[CSparseCSFTensor]& sparse_tensor, object base,
113
+ PyObject** out_data, PyObject** out_indptr, PyObject** out_indices)
114
+
115
+ CStatus NdarraysToSparseCOOTensor(CMemoryPool* pool, object data_ao,
116
+ object coords_ao,
117
+ const vector[int64_t]& shape,
118
+ const vector[c_string]& dim_names,
119
+ shared_ptr[CSparseCOOTensor]* out)
120
+
121
+ CStatus NdarraysToSparseCSRMatrix(CMemoryPool* pool, object data_ao,
122
+ object indptr_ao, object indices_ao,
123
+ const vector[int64_t]& shape,
124
+ const vector[c_string]& dim_names,
125
+ shared_ptr[CSparseCSRMatrix]* out)
126
+
127
+ CStatus NdarraysToSparseCSCMatrix(CMemoryPool* pool, object data_ao,
128
+ object indptr_ao, object indices_ao,
129
+ const vector[int64_t]& shape,
130
+ const vector[c_string]& dim_names,
131
+ shared_ptr[CSparseCSCMatrix]* out)
132
+
133
+ CStatus NdarraysToSparseCSFTensor(CMemoryPool* pool, object data_ao,
134
+ object indptr_ao, object indices_ao,
135
+ const vector[int64_t]& shape,
136
+ const vector[int64_t]& axis_order,
137
+ const vector[c_string]& dim_names,
138
+ shared_ptr[CSparseCSFTensor]* out)
139
+
140
+ CStatus TensorToSparseCOOTensor(shared_ptr[CTensor],
141
+ shared_ptr[CSparseCOOTensor]* out)
142
+
143
+ CStatus TensorToSparseCSRMatrix(shared_ptr[CTensor],
144
+ shared_ptr[CSparseCSRMatrix]* out)
145
+
146
+ CStatus TensorToSparseCSCMatrix(shared_ptr[CTensor],
147
+ shared_ptr[CSparseCSCMatrix]* out)
148
+
149
+ CStatus TensorToSparseCSFTensor(shared_ptr[CTensor],
150
+ shared_ptr[CSparseCSFTensor]* out)
151
+
152
+ CStatus ConvertArrayToPandas(const PandasOptions& options,
153
+ shared_ptr[CArray] arr,
154
+ object py_ref, PyObject** out)
155
+
156
+ CStatus ConvertChunkedArrayToPandas(const PandasOptions& options,
157
+ shared_ptr[CChunkedArray] arr,
158
+ object py_ref, PyObject** out)
159
+
160
+ CStatus ConvertTableToPandas(const PandasOptions& options,
161
+ shared_ptr[CTable] table,
162
+ PyObject** out)
163
+
164
+ void c_set_default_memory_pool \
165
+ " arrow::py::set_default_memory_pool"(CMemoryPool* pool)\
166
+
167
+ CMemoryPool* c_get_memory_pool \
168
+ " arrow::py::get_memory_pool"()
169
+
170
+ cdef cppclass PyBuffer(CBuffer):
171
+ @staticmethod
172
+ CResult[shared_ptr[CBuffer]] FromPyObject(object obj)
173
+
174
+ cdef cppclass PyForeignBuffer(CBuffer):
175
+ @staticmethod
176
+ CStatus Make(const uint8_t* data, int64_t size, object base,
177
+ shared_ptr[CBuffer]* out)
178
+
179
+ cdef cppclass PyReadableFile(CRandomAccessFile):
180
+ PyReadableFile(object fo)
181
+
182
+ cdef cppclass PyOutputStream(COutputStream):
183
+ PyOutputStream(object fo)
184
+
185
+ cdef cppclass PandasOptions:
186
+ CMemoryPool* pool
187
+ c_bool strings_to_categorical
188
+ c_bool zero_copy_only
189
+ c_bool integer_object_nulls
190
+ c_bool date_as_object
191
+ c_bool timestamp_as_object
192
+ c_bool use_threads
193
+ c_bool coerce_temporal_nanoseconds
194
+ c_bool ignore_timezone
195
+ c_bool deduplicate_objects
196
+ c_bool safe_cast
197
+ c_bool split_blocks
198
+ c_bool self_destruct
199
+ MapConversionType maps_as_pydicts
200
+ c_bool decode_dictionaries
201
+ shared_ptr[const unordered_set[c_string]] categorical_columns
202
+ shared_ptr[const unordered_set[c_string]] extension_columns
203
+ c_bool to_numpy
204
+
205
+
206
+ cdef extern from "arrow/python/api.h" namespace "arrow::py::internal" nogil:
207
+ cdef cppclass CTimePoint "arrow::py::internal::TimePoint":
208
+ pass
209
+
210
+ CTimePoint PyDateTime_to_TimePoint(PyDateTime_DateTime* pydatetime)
211
+ int64_t TimePoint_to_ns(CTimePoint val)
212
+ CTimePoint TimePoint_from_s(double val)
213
+ CTimePoint TimePoint_from_ns(int64_t val)
214
+
215
+ CResult[c_string] TzinfoToString(PyObject* pytzinfo)
216
+ CResult[PyObject*] StringToTzinfo(c_string)
217
+
218
+
219
+ cdef extern from "arrow/python/numpy_init.h" namespace "arrow::py":
220
+ int arrow_init_numpy() except -1
221
+
222
+
223
+ cdef extern from "arrow/python/pyarrow.h" namespace "arrow::py":
224
+ int import_pyarrow() except -1
225
+
226
+
227
+ cdef extern from "arrow/python/common.h" namespace "arrow::py":
228
+ c_bool IsPyError(const CStatus& status)
229
+ void RestorePyError(const CStatus& status) except *
230
+
231
+
232
+ cdef extern from "arrow/python/common.h" namespace "arrow::py" nogil:
233
+ cdef cppclass SharedPtrNoGIL[T](shared_ptr[T]):
234
+ # This looks like the only way to satisfy both Cython 2 and Cython 3
235
+ SharedPtrNoGIL& operator=(...)
236
+ cdef cppclass UniquePtrNoGIL[T, DELETER=*](unique_ptr[T, DELETER]):
237
+ UniquePtrNoGIL& operator=(...)
238
+
239
+
240
+ cdef extern from "arrow/python/inference.h" namespace "arrow::py":
241
+ c_bool IsPyBool(object o)
242
+ c_bool IsPyInt(object o)
243
+ c_bool IsPyFloat(object o)
244
+
245
+
246
+ cdef extern from "arrow/python/ipc.h" namespace "arrow::py":
247
+ cdef cppclass CPyRecordBatchReader" arrow::py::PyRecordBatchReader" \
248
+ (CRecordBatchReader):
249
+ @staticmethod
250
+ CResult[shared_ptr[CRecordBatchReader]] Make(shared_ptr[CSchema],
251
+ object)
252
+
253
+
254
+ cdef extern from "arrow/python/ipc.h" namespace "arrow::py" nogil:
255
+ cdef cppclass CCastingRecordBatchReader" arrow::py::CastingRecordBatchReader" \
256
+ (CRecordBatchReader):
257
+ @staticmethod
258
+ CResult[shared_ptr[CRecordBatchReader]] Make(shared_ptr[CRecordBatchReader],
259
+ shared_ptr[CSchema])
260
+
261
+
262
+ cdef extern from "arrow/python/extension_type.h" namespace "arrow::py":
263
+ cdef cppclass CPyExtensionType \
264
+ " arrow::py::PyExtensionType"(CExtensionType):
265
+ @staticmethod
266
+ CStatus FromClass(const shared_ptr[CDataType] storage_type,
267
+ const c_string extension_name, object typ,
268
+ shared_ptr[CExtensionType]* out)
269
+
270
+ @staticmethod
271
+ CStatus FromInstance(shared_ptr[CDataType] storage_type,
272
+ object inst, shared_ptr[CExtensionType]* out)
273
+
274
+ object GetInstance()
275
+ CStatus SetInstance(object)
276
+
277
+ c_string PyExtensionName()
278
+ CStatus RegisterPyExtensionType(shared_ptr[CDataType])
279
+ CStatus UnregisterPyExtensionType(c_string type_name)
280
+
281
+
282
+ cdef extern from "arrow/python/benchmark.h" namespace "arrow::py::benchmark":
283
+ void Benchmark_PandasObjectIsNull(object lst) except *
284
+
285
+
286
+ cdef extern from "arrow/python/gdb.h" namespace "arrow::gdb" nogil:
287
+ void GdbTestSession "arrow::gdb::TestSession"()
288
+
289
+ cdef extern from "arrow/python/helpers.h" namespace "arrow::py::internal":
290
+ c_bool IsThreadingEnabled()
291
+
292
+ cdef extern from "arrow/python/config.h" namespace "arrow::py":
293
+ cdef cppclass CBuildInfo "arrow::py::BuildInfo":
294
+ c_string build_type
295
+
296
+ const CBuildInfo& GetBuildInfo "arrow::py::GetBuildInfo"()
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libarrow_substrait.pxd ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from libcpp.vector cimport vector as std_vector
21
+
22
+ from pyarrow.includes.common cimport *
23
+ from pyarrow.includes.libarrow cimport *
24
+ from pyarrow.includes.libarrow_acero cimport *
25
+
26
+ ctypedef CResult[CDeclaration] CNamedTableProvider(const std_vector[c_string]&, const CSchema&)
27
+
28
+ cdef extern from "arrow/engine/substrait/options.h" namespace "arrow::engine" nogil:
29
+ cdef enum ConversionStrictness \
30
+ "arrow::engine::ConversionStrictness":
31
+ EXACT_ROUNDTRIP \
32
+ "arrow::engine::ConversionStrictness::EXACT_ROUNDTRIP"
33
+ PRESERVE_STRUCTURE \
34
+ "arrow::engine::ConversionStrictness::PRESERVE_STRUCTURE"
35
+ BEST_EFFORT \
36
+ "arrow::engine::ConversionStrictness::BEST_EFFORT"
37
+
38
+ cdef cppclass CConversionOptions \
39
+ "arrow::engine::ConversionOptions":
40
+ CConversionOptions()
41
+ ConversionStrictness strictness
42
+ function[CNamedTableProvider] named_table_provider
43
+ c_bool allow_arrow_extensions
44
+
45
+ cdef extern from "arrow/engine/substrait/extension_set.h" \
46
+ namespace "arrow::engine" nogil:
47
+
48
+ cdef struct CSubstraitId "arrow::engine::Id":
49
+ cpp_string_view uri
50
+ cpp_string_view name
51
+
52
+ cdef struct CExtensionSetTypeRecord "arrow::engine::ExtensionSet::TypeRecord":
53
+ CSubstraitId id
54
+ shared_ptr[CDataType] type
55
+
56
+ cdef cppclass CExtensionSet "arrow::engine::ExtensionSet":
57
+ CExtensionSet()
58
+ unordered_map[uint32_t, cpp_string_view]& uris()
59
+ CResult[uint32_t] EncodeType(const CDataType&)
60
+ CResult[CExtensionSetTypeRecord] DecodeType(uint32_t)
61
+
62
+ cdef cppclass ExtensionIdRegistry:
63
+ std_vector[c_string] GetSupportedSubstraitFunctions()
64
+
65
+ ExtensionIdRegistry* default_extension_id_registry()
66
+
67
+ cdef extern from "arrow/engine/substrait/relation.h" namespace "arrow::engine" nogil:
68
+
69
+ cdef cppclass CNamedExpression "arrow::engine::NamedExpression":
70
+ CExpression expression
71
+ c_string name
72
+
73
+ cdef cppclass CBoundExpressions "arrow::engine::BoundExpressions":
74
+ std_vector[CNamedExpression] named_expressions
75
+ shared_ptr[CSchema] schema
76
+
77
+ cdef extern from "arrow/engine/substrait/serde.h" namespace "arrow::engine" nogil:
78
+
79
+ CResult[shared_ptr[CBuffer]] SerializeExpressions(
80
+ const CBoundExpressions& bound_expressions, const CConversionOptions& conversion_options)
81
+
82
+ CResult[CBoundExpressions] DeserializeExpressions(
83
+ const CBuffer& serialized_expressions)
84
+
85
+ CResult[shared_ptr[CBuffer]] SerializeSchema(
86
+ const CSchema &schema, CExtensionSet* extension_set,
87
+ const CConversionOptions& conversion_options)
88
+
89
+ CResult[shared_ptr[CSchema]] DeserializeSchema(
90
+ const CBuffer& serialized_schema, const CExtensionSet& extension_set,
91
+ const CConversionOptions& conversion_options)
92
+
93
+
94
+ cdef extern from "arrow/engine/substrait/util.h" namespace "arrow::engine" nogil:
95
+ CResult[shared_ptr[CRecordBatchReader]] ExecuteSerializedPlan(
96
+ const CBuffer& substrait_buffer, const ExtensionIdRegistry* registry,
97
+ CFunctionRegistry* func_registry, const CConversionOptions& conversion_options,
98
+ c_bool use_threads)
99
+
100
+ CResult[shared_ptr[CBuffer]] SerializeJsonPlan(const c_string& substrait_json)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libgandiva.pxd ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from libcpp.string cimport string as c_string
21
+ from libcpp.unordered_set cimport unordered_set as c_unordered_set
22
+ from libc.stdint cimport int64_t, int32_t, uint8_t, uintptr_t
23
+
24
+ from pyarrow.includes.common cimport *
25
+ from pyarrow.includes.libarrow cimport *
26
+
27
+ cdef extern from "gandiva/node.h" namespace "gandiva" nogil:
28
+
29
+ cdef cppclass CNode" gandiva::Node":
30
+ c_string ToString()
31
+ shared_ptr[CDataType] return_type()
32
+
33
+ cdef cppclass CGandivaExpression" gandiva::Expression":
34
+ c_string ToString()
35
+ shared_ptr[CNode] root()
36
+ shared_ptr[CField] result()
37
+
38
+ ctypedef vector[shared_ptr[CNode]] CNodeVector" gandiva::NodeVector"
39
+
40
+ ctypedef vector[shared_ptr[CGandivaExpression]] \
41
+ CExpressionVector" gandiva::ExpressionVector"
42
+
43
+ cdef extern from "gandiva/selection_vector.h" namespace "gandiva" nogil:
44
+
45
+ cdef cppclass CSelectionVector" gandiva::SelectionVector":
46
+
47
+ shared_ptr[CArray] ToArray()
48
+
49
+ enum CSelectionVector_Mode" gandiva::SelectionVector::Mode":
50
+ CSelectionVector_Mode_NONE" gandiva::SelectionVector::Mode::MODE_NONE"
51
+ CSelectionVector_Mode_UINT16" \
52
+ gandiva::SelectionVector::Mode::MODE_UINT16"
53
+ CSelectionVector_Mode_UINT32" \
54
+ gandiva::SelectionVector::Mode::MODE_UINT32"
55
+ CSelectionVector_Mode_UINT64" \
56
+ gandiva::SelectionVector::Mode::MODE_UINT64"
57
+
58
+ cdef CStatus SelectionVector_MakeInt16\
59
+ "gandiva::SelectionVector::MakeInt16"(
60
+ int64_t max_slots, CMemoryPool* pool,
61
+ shared_ptr[CSelectionVector]* selection_vector)
62
+
63
+ cdef CStatus SelectionVector_MakeInt32\
64
+ "gandiva::SelectionVector::MakeInt32"(
65
+ int64_t max_slots, CMemoryPool* pool,
66
+ shared_ptr[CSelectionVector]* selection_vector)
67
+
68
+ cdef CStatus SelectionVector_MakeInt64\
69
+ "gandiva::SelectionVector::MakeInt64"(
70
+ int64_t max_slots, CMemoryPool* pool,
71
+ shared_ptr[CSelectionVector]* selection_vector)
72
+
73
+ cdef inline CSelectionVector_Mode _ensure_selection_mode(str name) except *:
74
+ uppercase = name.upper()
75
+ if uppercase == 'NONE':
76
+ return CSelectionVector_Mode_NONE
77
+ elif uppercase == 'UINT16':
78
+ return CSelectionVector_Mode_UINT16
79
+ elif uppercase == 'UINT32':
80
+ return CSelectionVector_Mode_UINT32
81
+ elif uppercase == 'UINT64':
82
+ return CSelectionVector_Mode_UINT64
83
+ else:
84
+ raise ValueError(f'Invalid value for Selection Mode: {name!r}')
85
+
86
+ cdef inline str _selection_mode_name(CSelectionVector_Mode ctype):
87
+ if ctype == CSelectionVector_Mode_NONE:
88
+ return 'NONE'
89
+ elif ctype == CSelectionVector_Mode_UINT16:
90
+ return 'UINT16'
91
+ elif ctype == CSelectionVector_Mode_UINT32:
92
+ return 'UINT32'
93
+ elif ctype == CSelectionVector_Mode_UINT64:
94
+ return 'UINT64'
95
+ else:
96
+ raise RuntimeError('Unexpected CSelectionVector_Mode value')
97
+
98
+ cdef extern from "gandiva/condition.h" namespace "gandiva" nogil:
99
+
100
+ cdef cppclass CCondition" gandiva::Condition":
101
+ c_string ToString()
102
+ shared_ptr[CNode] root()
103
+ shared_ptr[CField] result()
104
+
105
+ cdef extern from "gandiva/arrow.h" namespace "gandiva" nogil:
106
+
107
+ ctypedef vector[shared_ptr[CArray]] CArrayVector" gandiva::ArrayVector"
108
+
109
+
110
+ cdef extern from "gandiva/tree_expr_builder.h" namespace "gandiva" nogil:
111
+
112
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeBoolLiteral \
113
+ "gandiva::TreeExprBuilder::MakeLiteral"(c_bool value)
114
+
115
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeUInt8Literal \
116
+ "gandiva::TreeExprBuilder::MakeLiteral"(uint8_t value)
117
+
118
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeUInt16Literal \
119
+ "gandiva::TreeExprBuilder::MakeLiteral"(uint16_t value)
120
+
121
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeUInt32Literal \
122
+ "gandiva::TreeExprBuilder::MakeLiteral"(uint32_t value)
123
+
124
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeUInt64Literal \
125
+ "gandiva::TreeExprBuilder::MakeLiteral"(uint64_t value)
126
+
127
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInt8Literal \
128
+ "gandiva::TreeExprBuilder::MakeLiteral"(int8_t value)
129
+
130
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInt16Literal \
131
+ "gandiva::TreeExprBuilder::MakeLiteral"(int16_t value)
132
+
133
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInt32Literal \
134
+ "gandiva::TreeExprBuilder::MakeLiteral"(int32_t value)
135
+
136
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInt64Literal \
137
+ "gandiva::TreeExprBuilder::MakeLiteral"(int64_t value)
138
+
139
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeFloatLiteral \
140
+ "gandiva::TreeExprBuilder::MakeLiteral"(float value)
141
+
142
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeDoubleLiteral \
143
+ "gandiva::TreeExprBuilder::MakeLiteral"(double value)
144
+
145
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeStringLiteral \
146
+ "gandiva::TreeExprBuilder::MakeStringLiteral"(const c_string& value)
147
+
148
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeBinaryLiteral \
149
+ "gandiva::TreeExprBuilder::MakeBinaryLiteral"(const c_string& value)
150
+
151
+ cdef shared_ptr[CGandivaExpression] TreeExprBuilder_MakeExpression\
152
+ "gandiva::TreeExprBuilder::MakeExpression"(
153
+ shared_ptr[CNode] root_node, shared_ptr[CField] result_field)
154
+
155
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeFunction \
156
+ "gandiva::TreeExprBuilder::MakeFunction"(
157
+ const c_string& name, const CNodeVector& children,
158
+ shared_ptr[CDataType] return_type)
159
+
160
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeField \
161
+ "gandiva::TreeExprBuilder::MakeField"(shared_ptr[CField] field)
162
+
163
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeIf \
164
+ "gandiva::TreeExprBuilder::MakeIf"(
165
+ shared_ptr[CNode] condition, shared_ptr[CNode] this_node,
166
+ shared_ptr[CNode] else_node, shared_ptr[CDataType] return_type)
167
+
168
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeAnd \
169
+ "gandiva::TreeExprBuilder::MakeAnd"(const CNodeVector& children)
170
+
171
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeOr \
172
+ "gandiva::TreeExprBuilder::MakeOr"(const CNodeVector& children)
173
+
174
+ cdef shared_ptr[CCondition] TreeExprBuilder_MakeCondition \
175
+ "gandiva::TreeExprBuilder::MakeCondition"(
176
+ shared_ptr[CNode] condition)
177
+
178
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionInt32 \
179
+ "gandiva::TreeExprBuilder::MakeInExpressionInt32"(
180
+ shared_ptr[CNode] node, const c_unordered_set[int32_t]& values)
181
+
182
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionInt64 \
183
+ "gandiva::TreeExprBuilder::MakeInExpressionInt64"(
184
+ shared_ptr[CNode] node, const c_unordered_set[int64_t]& values)
185
+
186
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionTime32 \
187
+ "gandiva::TreeExprBuilder::MakeInExpressionTime32"(
188
+ shared_ptr[CNode] node, const c_unordered_set[int32_t]& values)
189
+
190
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionTime64 \
191
+ "gandiva::TreeExprBuilder::MakeInExpressionTime64"(
192
+ shared_ptr[CNode] node, const c_unordered_set[int64_t]& values)
193
+
194
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionDate32 \
195
+ "gandiva::TreeExprBuilder::MakeInExpressionDate32"(
196
+ shared_ptr[CNode] node, const c_unordered_set[int32_t]& values)
197
+
198
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionDate64 \
199
+ "gandiva::TreeExprBuilder::MakeInExpressionDate64"(
200
+ shared_ptr[CNode] node, const c_unordered_set[int64_t]& values)
201
+
202
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionTimeStamp \
203
+ "gandiva::TreeExprBuilder::MakeInExpressionTimeStamp"(
204
+ shared_ptr[CNode] node, const c_unordered_set[int64_t]& values)
205
+
206
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionString \
207
+ "gandiva::TreeExprBuilder::MakeInExpressionString"(
208
+ shared_ptr[CNode] node, const c_unordered_set[c_string]& values)
209
+
210
+ cdef shared_ptr[CNode] TreeExprBuilder_MakeInExpressionBinary \
211
+ "gandiva::TreeExprBuilder::MakeInExpressionBinary"(
212
+ shared_ptr[CNode] node, const c_unordered_set[c_string]& values)
213
+
214
+ cdef extern from "gandiva/projector.h" namespace "gandiva" nogil:
215
+
216
+ cdef cppclass CProjector" gandiva::Projector":
217
+
218
+ CStatus Evaluate(
219
+ const CRecordBatch& batch, CMemoryPool* pool,
220
+ const CArrayVector* output)
221
+
222
+ CStatus Evaluate(
223
+ const CRecordBatch& batch,
224
+ const CSelectionVector* selection,
225
+ CMemoryPool* pool,
226
+ const CArrayVector* output)
227
+
228
+ c_string DumpIR()
229
+
230
+ cdef CStatus Projector_Make \
231
+ "gandiva::Projector::Make"(
232
+ shared_ptr[CSchema] schema, const CExpressionVector& children,
233
+ shared_ptr[CProjector]* projector)
234
+
235
+ cdef CStatus Projector_Make \
236
+ "gandiva::Projector::Make"(
237
+ shared_ptr[CSchema] schema, const CExpressionVector& children,
238
+ CSelectionVector_Mode mode,
239
+ shared_ptr[CConfiguration] configuration,
240
+ shared_ptr[CProjector]* projector)
241
+
242
+ cdef extern from "gandiva/filter.h" namespace "gandiva" nogil:
243
+
244
+ cdef cppclass CFilter" gandiva::Filter":
245
+
246
+ CStatus Evaluate(
247
+ const CRecordBatch& batch,
248
+ shared_ptr[CSelectionVector] out_selection)
249
+
250
+ c_string DumpIR()
251
+
252
+ cdef CStatus Filter_Make \
253
+ "gandiva::Filter::Make"(
254
+ shared_ptr[CSchema] schema, shared_ptr[CCondition] condition,
255
+ shared_ptr[CConfiguration] configuration,
256
+ shared_ptr[CFilter]* filter)
257
+
258
+ cdef extern from "gandiva/function_signature.h" namespace "gandiva" nogil:
259
+
260
+ cdef cppclass CFunctionSignature" gandiva::FunctionSignature":
261
+
262
+ CFunctionSignature(const c_string& base_name,
263
+ vector[shared_ptr[CDataType]] param_types,
264
+ shared_ptr[CDataType] ret_type)
265
+
266
+ shared_ptr[CDataType] ret_type() const
267
+
268
+ const c_string& base_name() const
269
+
270
+ vector[shared_ptr[CDataType]] param_types() const
271
+
272
+ c_string ToString() const
273
+
274
+ cdef extern from "gandiva/expression_registry.h" namespace "gandiva" nogil:
275
+
276
+ cdef vector[shared_ptr[CFunctionSignature]] \
277
+ GetRegisteredFunctionSignatures()
278
+
279
+ cdef extern from "gandiva/configuration.h" namespace "gandiva" nogil:
280
+
281
+ cdef cppclass CConfiguration" gandiva::Configuration":
282
+
283
+ CConfiguration()
284
+
285
+ CConfiguration(bint optimize, bint dump_ir)
286
+
287
+ void set_optimize(bint optimize)
288
+
289
+ void set_dump_ir(bint dump_ir)
290
+
291
+ cdef cppclass CConfigurationBuilder \
292
+ " gandiva::ConfigurationBuilder":
293
+ @staticmethod
294
+ shared_ptr[CConfiguration] DefaultConfiguration()
295
+
296
+ CConfigurationBuilder()
297
+
298
+ shared_ptr[CConfiguration] build()
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libparquet.pxd ADDED
@@ -0,0 +1,634 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.common cimport *
21
+ from pyarrow.includes.libarrow cimport (Type, CChunkedArray, CScalar, CSchema,
22
+ CStatus, CTable, CMemoryPool, CBuffer,
23
+ CKeyValueMetadata, CRandomAccessFile,
24
+ COutputStream, CCacheOptions,
25
+ TimeUnit, CRecordBatchReader)
26
+
27
+
28
+ cdef extern from "parquet/api/schema.h" namespace "parquet::schema" nogil:
29
+ cdef cppclass Node:
30
+ pass
31
+
32
+ cdef cppclass GroupNode(Node):
33
+ pass
34
+
35
+ cdef cppclass PrimitiveNode(Node):
36
+ pass
37
+
38
+ cdef cppclass ColumnPath:
39
+ c_string ToDotString()
40
+ vector[c_string] ToDotVector()
41
+
42
+
43
+ cdef extern from "parquet/api/schema.h" namespace "parquet" nogil:
44
+ enum ParquetType" parquet::Type::type":
45
+ ParquetType_BOOLEAN" parquet::Type::BOOLEAN"
46
+ ParquetType_INT32" parquet::Type::INT32"
47
+ ParquetType_INT64" parquet::Type::INT64"
48
+ ParquetType_INT96" parquet::Type::INT96"
49
+ ParquetType_FLOAT" parquet::Type::FLOAT"
50
+ ParquetType_DOUBLE" parquet::Type::DOUBLE"
51
+ ParquetType_BYTE_ARRAY" parquet::Type::BYTE_ARRAY"
52
+ ParquetType_FIXED_LEN_BYTE_ARRAY" parquet::Type::FIXED_LEN_BYTE_ARRAY"
53
+
54
+ enum ParquetLogicalTypeId" parquet::LogicalType::Type::type":
55
+ ParquetLogicalType_UNDEFINED" parquet::LogicalType::Type::UNDEFINED"
56
+ ParquetLogicalType_STRING" parquet::LogicalType::Type::STRING"
57
+ ParquetLogicalType_MAP" parquet::LogicalType::Type::MAP"
58
+ ParquetLogicalType_LIST" parquet::LogicalType::Type::LIST"
59
+ ParquetLogicalType_ENUM" parquet::LogicalType::Type::ENUM"
60
+ ParquetLogicalType_DECIMAL" parquet::LogicalType::Type::DECIMAL"
61
+ ParquetLogicalType_DATE" parquet::LogicalType::Type::DATE"
62
+ ParquetLogicalType_TIME" parquet::LogicalType::Type::TIME"
63
+ ParquetLogicalType_TIMESTAMP" parquet::LogicalType::Type::TIMESTAMP"
64
+ ParquetLogicalType_INT" parquet::LogicalType::Type::INT"
65
+ ParquetLogicalType_FLOAT16" parquet::LogicalType::Type::FLOAT16"
66
+ ParquetLogicalType_JSON" parquet::LogicalType::Type::JSON"
67
+ ParquetLogicalType_BSON" parquet::LogicalType::Type::BSON"
68
+ ParquetLogicalType_UUID" parquet::LogicalType::Type::UUID"
69
+ ParquetLogicalType_GEOMETRY" parquet::LogicalType::Type::GEOMETRY"
70
+ ParquetLogicalType_GEOGRAPHY" parquet::LogicalType::Type::GEOGRAPHY"
71
+ ParquetLogicalType_NONE" parquet::LogicalType::Type::NONE"
72
+
73
+ enum ParquetTimeUnit" parquet::LogicalType::TimeUnit::unit":
74
+ ParquetTimeUnit_UNKNOWN" parquet::LogicalType::TimeUnit::UNKNOWN"
75
+ ParquetTimeUnit_MILLIS" parquet::LogicalType::TimeUnit::MILLIS"
76
+ ParquetTimeUnit_MICROS" parquet::LogicalType::TimeUnit::MICROS"
77
+ ParquetTimeUnit_NANOS" parquet::LogicalType::TimeUnit::NANOS"
78
+
79
+ enum ParquetEdgeInterpolationAlgorithm" parquet::LogicalType::EdgeInterpolationAlgorithm":
80
+ ParquetEdgeInterpolationAlgorithm_UNKNOWN" parquet::LogicalType::EdgeInterpolationAlgorithm::UNKNOWN"
81
+ ParquetEdgeInterpolationAlgorithm_SPHERICAL" parquet::LogicalType::EdgeInterpolationAlgorithm::SPHERICAL"
82
+ ParquetEdgeInterpolationAlgorithm_VINCENTY" parquet::LogicalType::EdgeInterpolationAlgorithm::VINCENTY"
83
+ ParquetEdgeInterpolationAlgorithm_THOMAS" parquet::LogicalType::EdgeInterpolationAlgorithm::THOMAS"
84
+ ParquetEdgeInterpolationAlgorithm_ANDOYER" parquet::LogicalType::EdgeInterpolationAlgorithm::ANDOYER"
85
+ ParquetEdgeInterpolationAlgorithm_KARNEY" parquet::LogicalType::EdgeInterpolationAlgorithm::KARNEY"
86
+
87
+ enum ParquetConvertedType" parquet::ConvertedType::type":
88
+ ParquetConvertedType_NONE" parquet::ConvertedType::NONE"
89
+ ParquetConvertedType_UTF8" parquet::ConvertedType::UTF8"
90
+ ParquetConvertedType_MAP" parquet::ConvertedType::MAP"
91
+ ParquetConvertedType_MAP_KEY_VALUE \
92
+ " parquet::ConvertedType::MAP_KEY_VALUE"
93
+ ParquetConvertedType_LIST" parquet::ConvertedType::LIST"
94
+ ParquetConvertedType_ENUM" parquet::ConvertedType::ENUM"
95
+ ParquetConvertedType_DECIMAL" parquet::ConvertedType::DECIMAL"
96
+ ParquetConvertedType_DATE" parquet::ConvertedType::DATE"
97
+ ParquetConvertedType_TIME_MILLIS" parquet::ConvertedType::TIME_MILLIS"
98
+ ParquetConvertedType_TIME_MICROS" parquet::ConvertedType::TIME_MICROS"
99
+ ParquetConvertedType_TIMESTAMP_MILLIS \
100
+ " parquet::ConvertedType::TIMESTAMP_MILLIS"
101
+ ParquetConvertedType_TIMESTAMP_MICROS \
102
+ " parquet::ConvertedType::TIMESTAMP_MICROS"
103
+ ParquetConvertedType_UINT_8" parquet::ConvertedType::UINT_8"
104
+ ParquetConvertedType_UINT_16" parquet::ConvertedType::UINT_16"
105
+ ParquetConvertedType_UINT_32" parquet::ConvertedType::UINT_32"
106
+ ParquetConvertedType_UINT_64" parquet::ConvertedType::UINT_64"
107
+ ParquetConvertedType_INT_8" parquet::ConvertedType::INT_8"
108
+ ParquetConvertedType_INT_16" parquet::ConvertedType::INT_16"
109
+ ParquetConvertedType_INT_32" parquet::ConvertedType::INT_32"
110
+ ParquetConvertedType_INT_64" parquet::ConvertedType::INT_64"
111
+ ParquetConvertedType_JSON" parquet::ConvertedType::JSON"
112
+ ParquetConvertedType_BSON" parquet::ConvertedType::BSON"
113
+ ParquetConvertedType_INTERVAL" parquet::ConvertedType::INTERVAL"
114
+
115
+ enum ParquetRepetition" parquet::Repetition::type":
116
+ ParquetRepetition_REQUIRED" parquet::REPETITION::REQUIRED"
117
+ ParquetRepetition_OPTIONAL" parquet::REPETITION::OPTIONAL"
118
+ ParquetRepetition_REPEATED" parquet::REPETITION::REPEATED"
119
+
120
+ enum ParquetEncoding" parquet::Encoding::type":
121
+ ParquetEncoding_PLAIN" parquet::Encoding::PLAIN"
122
+ ParquetEncoding_PLAIN_DICTIONARY" parquet::Encoding::PLAIN_DICTIONARY"
123
+ ParquetEncoding_RLE" parquet::Encoding::RLE"
124
+ ParquetEncoding_BIT_PACKED" parquet::Encoding::BIT_PACKED"
125
+ ParquetEncoding_DELTA_BINARY_PACKED \
126
+ " parquet::Encoding::DELTA_BINARY_PACKED"
127
+ ParquetEncoding_DELTA_LENGTH_BYTE_ARRAY \
128
+ " parquet::Encoding::DELTA_LENGTH_BYTE_ARRAY"
129
+ ParquetEncoding_DELTA_BYTE_ARRAY" parquet::Encoding::DELTA_BYTE_ARRAY"
130
+ ParquetEncoding_RLE_DICTIONARY" parquet::Encoding::RLE_DICTIONARY"
131
+ ParquetEncoding_BYTE_STREAM_SPLIT \
132
+ " parquet::Encoding::BYTE_STREAM_SPLIT"
133
+
134
+ enum ParquetCompression" parquet::Compression::type":
135
+ ParquetCompression_UNCOMPRESSED" parquet::Compression::UNCOMPRESSED"
136
+ ParquetCompression_SNAPPY" parquet::Compression::SNAPPY"
137
+ ParquetCompression_GZIP" parquet::Compression::GZIP"
138
+ ParquetCompression_LZO" parquet::Compression::LZO"
139
+ ParquetCompression_BROTLI" parquet::Compression::BROTLI"
140
+ ParquetCompression_LZ4" parquet::Compression::LZ4"
141
+ ParquetCompression_ZSTD" parquet::Compression::ZSTD"
142
+
143
+ enum ParquetVersion" parquet::ParquetVersion::type":
144
+ ParquetVersion_V1" parquet::ParquetVersion::PARQUET_1_0"
145
+ ParquetVersion_V2_4" parquet::ParquetVersion::PARQUET_2_4"
146
+ ParquetVersion_V2_6" parquet::ParquetVersion::PARQUET_2_6"
147
+
148
+ enum ParquetSortOrder" parquet::SortOrder::type":
149
+ ParquetSortOrder_SIGNED" parquet::SortOrder::SIGNED"
150
+ ParquetSortOrder_UNSIGNED" parquet::SortOrder::UNSIGNED"
151
+ ParquetSortOrder_UNKNOWN" parquet::SortOrder::UNKNOWN"
152
+
153
+ cdef cppclass CParquetLogicalType" parquet::LogicalType":
154
+ c_string ToString() const
155
+ c_string ToJSON() const
156
+ ParquetLogicalTypeId type() const
157
+
158
+ cdef cppclass CParquetDecimalType \
159
+ " parquet::DecimalLogicalType"(CParquetLogicalType):
160
+ int32_t precision() const
161
+ int32_t scale() const
162
+
163
+ cdef cppclass CParquetIntType \
164
+ " parquet::IntLogicalType"(CParquetLogicalType):
165
+ int bit_width() const
166
+ c_bool is_signed() const
167
+
168
+ cdef cppclass CParquetTimeType \
169
+ " parquet::TimeLogicalType"(CParquetLogicalType):
170
+ c_bool is_adjusted_to_utc() const
171
+ ParquetTimeUnit time_unit() const
172
+
173
+ cdef cppclass CParquetTimestampType \
174
+ " parquet::TimestampLogicalType"(CParquetLogicalType):
175
+ c_bool is_adjusted_to_utc() const
176
+ ParquetTimeUnit time_unit() const
177
+
178
+ cdef cppclass CParquetGeometryType \
179
+ " parquet::GeometryLogicalType"(CParquetLogicalType):
180
+ c_string crs() const
181
+
182
+ cdef cppclass CParquetGeographyType \
183
+ " parquet::GeographyLogicalType"(CParquetLogicalType):
184
+ c_string crs() const
185
+ ParquetEdgeInterpolationAlgorithm algorithm() const
186
+
187
+ cdef cppclass ColumnDescriptor" parquet::ColumnDescriptor":
188
+ c_bool Equals(const ColumnDescriptor& other)
189
+
190
+ shared_ptr[ColumnPath] path()
191
+ int16_t max_definition_level()
192
+ int16_t max_repetition_level()
193
+
194
+ ParquetType physical_type()
195
+ const shared_ptr[const CParquetLogicalType]& logical_type()
196
+ ParquetConvertedType converted_type()
197
+ const c_string& name()
198
+ int type_length()
199
+ int type_precision()
200
+ int type_scale()
201
+
202
+ cdef cppclass SchemaDescriptor:
203
+ const ColumnDescriptor* Column(int i)
204
+ shared_ptr[Node] schema()
205
+ GroupNode* group()
206
+ c_bool Equals(const SchemaDescriptor& other)
207
+ c_string ToString()
208
+ int num_columns()
209
+
210
+ cdef c_string FormatStatValue(ParquetType parquet_type, c_string val)
211
+
212
+ enum ParquetCipher" parquet::ParquetCipher::type":
213
+ ParquetCipher_AES_GCM_V1" parquet::ParquetCipher::AES_GCM_V1"
214
+ ParquetCipher_AES_GCM_CTR_V1" parquet::ParquetCipher::AES_GCM_CTR_V1"
215
+
216
+ struct AadMetadata:
217
+ c_string aad_prefix
218
+ c_string aad_file_unique
219
+ c_bool supply_aad_prefix
220
+
221
+ struct EncryptionAlgorithm:
222
+ ParquetCipher algorithm
223
+ AadMetadata aad
224
+
225
+
226
+ # Specific array<> types needed for GeoStatistics
227
+ cdef extern from "<array>" namespace "std" nogil:
228
+ cdef cppclass double_array4 "std::array<double, 4>":
229
+ double_array4() except +
230
+ double& operator[](size_t)
231
+
232
+ cdef cppclass bool_array4 "std::array<bool, 4>":
233
+ bool_array4() except +
234
+ c_bool& operator[](size_t)
235
+
236
+
237
+ cdef extern from "parquet/geospatial/statistics.h" namespace "parquet" nogil:
238
+
239
+ cdef cppclass CParquetGeoStatistics" parquet::geospatial::GeoStatistics":
240
+ c_bool is_valid() const
241
+
242
+ double_array4 lower_bound() const
243
+ double_array4 upper_bound() const
244
+ bool_array4 dimension_valid() const
245
+ bool_array4 dimension_empty() const
246
+
247
+ optional[vector[int32_t]] geometry_types() const
248
+
249
+ c_string ToString() const
250
+
251
+
252
+ cdef extern from "parquet/api/reader.h" namespace "parquet" nogil:
253
+ cdef cppclass ColumnReader:
254
+ pass
255
+
256
+ cdef cppclass BoolReader(ColumnReader):
257
+ pass
258
+
259
+ cdef cppclass Int32Reader(ColumnReader):
260
+ pass
261
+
262
+ cdef cppclass Int64Reader(ColumnReader):
263
+ pass
264
+
265
+ cdef cppclass Int96Reader(ColumnReader):
266
+ pass
267
+
268
+ cdef cppclass FloatReader(ColumnReader):
269
+ pass
270
+
271
+ cdef cppclass DoubleReader(ColumnReader):
272
+ pass
273
+
274
+ cdef cppclass ByteArrayReader(ColumnReader):
275
+ pass
276
+
277
+ cdef cppclass RowGroupReader:
278
+ pass
279
+
280
+ cdef cppclass CEncodedStatistics" parquet::EncodedStatistics":
281
+ const c_string& max() const
282
+ const c_string& min() const
283
+ int64_t null_count
284
+ int64_t distinct_count
285
+ bint has_min
286
+ bint has_max
287
+ bint has_null_count
288
+ bint has_distinct_count
289
+
290
+ cdef cppclass ParquetByteArray" parquet::ByteArray":
291
+ uint32_t len
292
+ const uint8_t* ptr
293
+
294
+ cdef cppclass ParquetFLBA" parquet::FLBA":
295
+ const uint8_t* ptr
296
+
297
+ cdef cppclass CStatistics" parquet::Statistics":
298
+ int64_t null_count() const
299
+ int64_t distinct_count() const
300
+ int64_t num_values() const
301
+ bint HasMinMax()
302
+ bint HasNullCount()
303
+ bint HasDistinctCount()
304
+ c_bool Equals(const CStatistics&) const
305
+ void Reset()
306
+ c_string EncodeMin()
307
+ c_string EncodeMax()
308
+ CEncodedStatistics Encode()
309
+ void SetComparator()
310
+ ParquetType physical_type() const
311
+ const ColumnDescriptor* descr() const
312
+
313
+ cdef cppclass CBoolStatistics" parquet::BoolStatistics"(CStatistics):
314
+ c_bool min()
315
+ c_bool max()
316
+
317
+ cdef cppclass CInt32Statistics" parquet::Int32Statistics"(CStatistics):
318
+ int32_t min()
319
+ int32_t max()
320
+
321
+ cdef cppclass CInt64Statistics" parquet::Int64Statistics"(CStatistics):
322
+ int64_t min()
323
+ int64_t max()
324
+
325
+ cdef cppclass CFloatStatistics" parquet::FloatStatistics"(CStatistics):
326
+ float min()
327
+ float max()
328
+
329
+ cdef cppclass CDoubleStatistics" parquet::DoubleStatistics"(CStatistics):
330
+ double min()
331
+ double max()
332
+
333
+ cdef cppclass CByteArrayStatistics \
334
+ " parquet::ByteArrayStatistics"(CStatistics):
335
+ ParquetByteArray min()
336
+ ParquetByteArray max()
337
+
338
+ cdef cppclass CFLBAStatistics" parquet::FLBAStatistics"(CStatistics):
339
+ ParquetFLBA min()
340
+ ParquetFLBA max()
341
+
342
+ cdef cppclass CColumnCryptoMetaData" parquet::ColumnCryptoMetaData":
343
+ shared_ptr[ColumnPath] path_in_schema() const
344
+ c_bool encrypted_with_footer_key() const
345
+ const c_string& key_metadata() const
346
+
347
+ cdef cppclass ParquetIndexLocation" parquet::IndexLocation":
348
+ int64_t offset
349
+ int32_t length
350
+
351
+ cdef cppclass CColumnChunkMetaData" parquet::ColumnChunkMetaData":
352
+ int64_t file_offset() const
353
+ const c_string& file_path() const
354
+
355
+ c_bool is_metadata_set() const
356
+ ParquetType type() const
357
+ int64_t num_values() const
358
+ shared_ptr[ColumnPath] path_in_schema() const
359
+ bint is_stats_set() const
360
+ shared_ptr[CStatistics] statistics() const
361
+ c_bool is_geo_stats_set() const
362
+ shared_ptr[CParquetGeoStatistics] geo_statistics() const
363
+ ParquetCompression compression() const
364
+ const vector[ParquetEncoding]& encodings() const
365
+ c_bool Equals(const CColumnChunkMetaData&) const
366
+
367
+ int64_t has_dictionary_page() const
368
+ int64_t dictionary_page_offset() const
369
+ int64_t data_page_offset() const
370
+ int64_t index_page_offset() const
371
+ int64_t total_compressed_size() const
372
+ int64_t total_uncompressed_size() const
373
+ unique_ptr[CColumnCryptoMetaData] crypto_metadata() const
374
+ optional[ParquetIndexLocation] GetColumnIndexLocation() const
375
+ optional[ParquetIndexLocation] GetOffsetIndexLocation() const
376
+ shared_ptr[const CKeyValueMetadata] key_value_metadata() const
377
+
378
+ struct CSortingColumn" parquet::SortingColumn":
379
+ int column_idx
380
+ c_bool descending
381
+ c_bool nulls_first
382
+
383
+ cdef cppclass CRowGroupMetaData" parquet::RowGroupMetaData":
384
+ c_bool Equals(const CRowGroupMetaData&) const
385
+ int num_columns() const
386
+ int64_t num_rows() const
387
+ int64_t total_byte_size() const
388
+ vector[CSortingColumn] sorting_columns() const
389
+ unique_ptr[CColumnChunkMetaData] ColumnChunk(int i) const
390
+
391
+ cdef cppclass CFileMetaData" parquet::FileMetaData":
392
+ c_bool Equals(const CFileMetaData&) const
393
+ uint32_t size()
394
+ int num_columns()
395
+ int64_t num_rows()
396
+ int num_row_groups()
397
+ ParquetVersion version()
398
+ const c_string created_by()
399
+ int num_schema_elements()
400
+
401
+ void set_file_path(const c_string& path)
402
+ void AppendRowGroups(const CFileMetaData& other) except +
403
+
404
+ unique_ptr[CRowGroupMetaData] RowGroup(int i)
405
+ const SchemaDescriptor* schema()
406
+ shared_ptr[const CKeyValueMetadata] key_value_metadata() const
407
+ void WriteTo(COutputStream* dst) const
408
+
409
+ inline c_bool is_encryption_algorithm_set() const
410
+ inline EncryptionAlgorithm encryption_algorithm() const
411
+ inline const c_string& footer_signing_key_metadata() const
412
+
413
+ cdef shared_ptr[CFileMetaData] CFileMetaData_Make \
414
+ " parquet::FileMetaData::Make"(const void* serialized_metadata,
415
+ uint32_t* metadata_len)
416
+
417
+ cdef cppclass CReaderProperties" parquet::ReaderProperties":
418
+ c_bool is_buffered_stream_enabled() const
419
+ void enable_buffered_stream()
420
+ void disable_buffered_stream()
421
+
422
+ void set_buffer_size(int64_t buf_size)
423
+ int64_t buffer_size() const
424
+
425
+ void set_thrift_string_size_limit(int32_t size)
426
+ int32_t thrift_string_size_limit() const
427
+
428
+ void set_thrift_container_size_limit(int32_t size)
429
+ int32_t thrift_container_size_limit() const
430
+
431
+ void file_decryption_properties(shared_ptr[CFileDecryptionProperties]
432
+ decryption)
433
+ shared_ptr[CFileDecryptionProperties] file_decryption_properties() \
434
+ const
435
+
436
+ c_bool page_checksum_verification() const
437
+ void set_page_checksum_verification(c_bool check_crc)
438
+
439
+ CReaderProperties default_reader_properties()
440
+
441
+ cdef cppclass ArrowReaderProperties:
442
+ ArrowReaderProperties()
443
+ void set_binary_type(Type binary_type)
444
+ Type binary_type()
445
+ void set_list_type(Type list_type)
446
+ Type list_type()
447
+ void set_read_dictionary(int column_index, c_bool read_dict)
448
+ c_bool read_dictionary(int column_index)
449
+ void set_batch_size(int64_t batch_size)
450
+ int64_t batch_size()
451
+ void set_pre_buffer(c_bool pre_buffer)
452
+ c_bool pre_buffer() const
453
+ void set_cache_options(CCacheOptions options)
454
+ CCacheOptions cache_options() const
455
+ void set_coerce_int96_timestamp_unit(TimeUnit unit)
456
+ TimeUnit coerce_int96_timestamp_unit() const
457
+ void set_arrow_extensions_enabled(c_bool extensions_enabled)
458
+ c_bool get_arrow_extensions_enabled() const
459
+
460
+ ArrowReaderProperties default_arrow_reader_properties()
461
+
462
+ cdef cppclass ParquetFileReader:
463
+ shared_ptr[CFileMetaData] metadata()
464
+
465
+
466
+ cdef extern from "parquet/api/writer.h" namespace "parquet" nogil:
467
+ cdef cppclass CdcOptions:
468
+ int64_t min_chunk_size
469
+ int64_t max_chunk_size
470
+ int norm_level
471
+
472
+ cdef cppclass WriterProperties:
473
+ cppclass Builder:
474
+ Builder* data_page_version(ParquetDataPageVersion version)
475
+ Builder* version(ParquetVersion version)
476
+ Builder* compression(ParquetCompression codec)
477
+ Builder* compression(const c_string& path,
478
+ ParquetCompression codec)
479
+ Builder* compression_level(int compression_level)
480
+ Builder* compression_level(const c_string& path,
481
+ int compression_level)
482
+ Builder* encryption(
483
+ shared_ptr[CFileEncryptionProperties]
484
+ file_encryption_properties)
485
+ Builder* disable_dictionary()
486
+ Builder* enable_dictionary()
487
+ Builder* enable_dictionary(const c_string& path)
488
+ Builder* set_sorting_columns(vector[CSortingColumn] sorting_columns)
489
+ Builder* disable_statistics()
490
+ Builder* enable_statistics()
491
+ Builder* enable_statistics(const c_string& path)
492
+ Builder* enable_store_decimal_as_integer()
493
+ Builder* disable_store_decimal_as_integer()
494
+ Builder* data_pagesize(int64_t size)
495
+ Builder* max_rows_per_page(int64_t max_rows)
496
+ Builder* encoding(ParquetEncoding encoding)
497
+ Builder* encoding(const c_string& path,
498
+ ParquetEncoding encoding)
499
+ Builder* max_row_group_length(int64_t size)
500
+ Builder* write_batch_size(int64_t batch_size)
501
+ Builder* dictionary_pagesize_limit(int64_t dictionary_pagesize_limit)
502
+ Builder* enable_write_page_index()
503
+ Builder* disable_write_page_index()
504
+ Builder* enable_page_checksum()
505
+ Builder* disable_page_checksum()
506
+ Builder* enable_content_defined_chunking()
507
+ Builder* disable_content_defined_chunking()
508
+ Builder* content_defined_chunking_options(CdcOptions options)
509
+ shared_ptr[WriterProperties] build()
510
+
511
+ cdef cppclass ArrowWriterProperties:
512
+ cppclass Builder:
513
+ Builder()
514
+ Builder* disable_deprecated_int96_timestamps()
515
+ Builder* enable_deprecated_int96_timestamps()
516
+ Builder* coerce_timestamps(TimeUnit unit)
517
+ Builder* allow_truncated_timestamps()
518
+ Builder* disallow_truncated_timestamps()
519
+ Builder* store_schema()
520
+ Builder* enable_compliant_nested_types()
521
+ Builder* disable_compliant_nested_types()
522
+ Builder* set_engine_version(ArrowWriterEngineVersion version)
523
+ Builder* set_time_adjusted_to_utc(c_bool adjusted)
524
+ shared_ptr[ArrowWriterProperties] build()
525
+ c_bool support_deprecated_int96_timestamps()
526
+
527
+ cdef extern from "parquet/arrow/reader.h" namespace "parquet::arrow" nogil:
528
+ cdef cppclass FileReader:
529
+ FileReader(CMemoryPool* pool, unique_ptr[ParquetFileReader] reader)
530
+
531
+ CStatus GetSchema(shared_ptr[CSchema]* out)
532
+
533
+ CStatus ReadColumn(int i, shared_ptr[CChunkedArray]* out)
534
+ CStatus ReadSchemaField(int i, shared_ptr[CChunkedArray]* out)
535
+
536
+ int num_row_groups()
537
+ CStatus ReadRowGroup(int i, shared_ptr[CTable]* out)
538
+ CStatus ReadRowGroup(int i, const vector[int]& column_indices,
539
+ shared_ptr[CTable]* out)
540
+
541
+ CStatus ReadRowGroups(const vector[int]& row_groups,
542
+ shared_ptr[CTable]* out)
543
+ CStatus ReadRowGroups(const vector[int]& row_groups,
544
+ const vector[int]& column_indices,
545
+ shared_ptr[CTable]* out)
546
+
547
+ CResult[unique_ptr[CRecordBatchReader]] GetRecordBatchReader(const vector[int]& row_group_indices,
548
+ const vector[int]& column_indices)
549
+ CResult[unique_ptr[CRecordBatchReader]] GetRecordBatchReader(const vector[int]& row_group_indices)
550
+
551
+ CStatus ReadTable(shared_ptr[CTable]* out)
552
+ CStatus ReadTable(const vector[int]& column_indices,
553
+ shared_ptr[CTable]* out)
554
+
555
+ CStatus ScanContents(vector[int] columns, int32_t column_batch_size,
556
+ int64_t* num_rows)
557
+
558
+ const ParquetFileReader* parquet_reader()
559
+
560
+ void set_use_threads(c_bool use_threads)
561
+
562
+ void set_batch_size(int64_t batch_size)
563
+
564
+ cdef cppclass FileReaderBuilder:
565
+ FileReaderBuilder()
566
+ CStatus Open(const shared_ptr[CRandomAccessFile]& file,
567
+ const CReaderProperties& properties,
568
+ const shared_ptr[CFileMetaData]& metadata)
569
+
570
+ ParquetFileReader* raw_reader()
571
+ FileReaderBuilder* memory_pool(CMemoryPool*)
572
+ FileReaderBuilder* properties(const ArrowReaderProperties&)
573
+ CStatus Build(unique_ptr[FileReader]* out)
574
+
575
+ CStatus FromParquetSchema(
576
+ const SchemaDescriptor* parquet_schema,
577
+ const ArrowReaderProperties& properties,
578
+ const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
579
+ shared_ptr[CSchema]* out)
580
+
581
+ CStatus StatisticsAsScalars(const CStatistics& Statistics,
582
+ shared_ptr[CScalar]* min,
583
+ shared_ptr[CScalar]* max)
584
+
585
+ cdef extern from "parquet/arrow/schema.h" namespace "parquet::arrow" nogil:
586
+
587
+ CStatus ToParquetSchema(
588
+ const CSchema* arrow_schema,
589
+ const WriterProperties& properties,
590
+ const ArrowWriterProperties& arrow_properties,
591
+ shared_ptr[SchemaDescriptor]* out)
592
+
593
+
594
+ cdef extern from "parquet/properties.h" namespace "parquet" nogil:
595
+ cdef enum ArrowWriterEngineVersion:
596
+ V1 "parquet::ArrowWriterProperties::V1",
597
+ V2 "parquet::ArrowWriterProperties::V2"
598
+
599
+ cdef cppclass ParquetDataPageVersion:
600
+ pass
601
+
602
+ cdef ParquetDataPageVersion ParquetDataPageVersion_V1 \
603
+ " parquet::ParquetDataPageVersion::V1"
604
+ cdef ParquetDataPageVersion ParquetDataPageVersion_V2 \
605
+ " parquet::ParquetDataPageVersion::V2"
606
+
607
+ cdef extern from "parquet/arrow/writer.h" namespace "parquet::arrow" nogil:
608
+ cdef cppclass FileWriter:
609
+
610
+ @staticmethod
611
+ CResult[unique_ptr[FileWriter]] Open(const CSchema& schema, CMemoryPool* pool,
612
+ const shared_ptr[COutputStream]& sink,
613
+ const shared_ptr[WriterProperties]& properties,
614
+ const shared_ptr[ArrowWriterProperties]& arrow_properties)
615
+
616
+ CStatus WriteTable(const CTable& table, int64_t chunk_size)
617
+ CStatus NewRowGroup()
618
+ CStatus Close()
619
+ CStatus AddKeyValueMetadata(const shared_ptr[const CKeyValueMetadata]& key_value_metadata)
620
+
621
+ const shared_ptr[CFileMetaData] metadata() const
622
+
623
+ CStatus WriteMetaDataFile(
624
+ const CFileMetaData& file_metadata,
625
+ const COutputStream* sink)
626
+
627
+ cdef extern from "parquet/encryption/encryption.h" namespace "parquet" nogil:
628
+ cdef cppclass CFileDecryptionProperties\
629
+ " parquet::FileDecryptionProperties":
630
+ pass
631
+
632
+ cdef cppclass CFileEncryptionProperties\
633
+ " parquet::FileEncryptionProperties":
634
+ pass
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/includes/libparquet_encryption.pxd ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # distutils: language = c++
19
+
20
+ from pyarrow.includes.common cimport *
21
+ from pyarrow.includes.libarrow cimport CSecureString
22
+ from pyarrow.includes.libarrow_fs cimport CFileSystem
23
+ from pyarrow._parquet cimport (ParquetCipher,
24
+ CFileEncryptionProperties,
25
+ CFileDecryptionProperties,
26
+ ParquetCipher_AES_GCM_V1,
27
+ ParquetCipher_AES_GCM_CTR_V1)
28
+
29
+
30
+ cdef extern from "parquet/encryption/kms_client.h" \
31
+ namespace "parquet::encryption" nogil:
32
+ cdef cppclass CKmsClient" parquet::encryption::KmsClient":
33
+ c_string WrapKey(const CSecureString& key,
34
+ const c_string& master_key_identifier) except +
35
+ CSecureString UnwrapKey(const c_string& wrapped_key,
36
+ const c_string& master_key_identifier) except +
37
+
38
+ cdef cppclass CKeyAccessToken" parquet::encryption::KeyAccessToken":
39
+ CKeyAccessToken(const c_string value)
40
+ void Refresh(const c_string& new_value)
41
+ const c_string& value() const
42
+
43
+ cdef cppclass CKmsConnectionConfig \
44
+ " parquet::encryption::KmsConnectionConfig":
45
+ CKmsConnectionConfig()
46
+ c_string kms_instance_id
47
+ c_string kms_instance_url
48
+ shared_ptr[CKeyAccessToken] refreshable_key_access_token
49
+ unordered_map[c_string, c_string] custom_kms_conf
50
+
51
+ # Callbacks for implementing Python kms clients
52
+ # Use typedef to emulate syntax for std::function<void(..)>
53
+ ctypedef void CallbackWrapKey(
54
+ object, const CSecureString&, const c_string&, c_string*)
55
+ ctypedef void CallbackUnwrapKey(
56
+ object, const c_string&, const c_string&, CSecureString*)
57
+
58
+ cdef extern from "parquet/encryption/kms_client_factory.h" \
59
+ namespace "parquet::encryption" nogil:
60
+ cdef cppclass CKmsClientFactory" parquet::encryption::KmsClientFactory":
61
+ shared_ptr[CKmsClient] CreateKmsClient(
62
+ const CKmsConnectionConfig& kms_connection_config) except +
63
+
64
+ # Callbacks for implementing Python kms client factories
65
+ # Use typedef to emulate syntax for std::function<void(..)>
66
+ ctypedef void CallbackCreateKmsClient(
67
+ object,
68
+ const CKmsConnectionConfig&, shared_ptr[CKmsClient]*)
69
+
70
+ cdef extern from "parquet/encryption/crypto_factory.h" \
71
+ namespace "parquet::encryption" nogil:
72
+ cdef cppclass CEncryptionConfiguration\
73
+ " parquet::encryption::EncryptionConfiguration":
74
+ CEncryptionConfiguration(const c_string& footer_key) except +
75
+ c_string footer_key
76
+ c_string column_keys
77
+ c_bool uniform_encryption
78
+ ParquetCipher encryption_algorithm
79
+ c_bool plaintext_footer
80
+ c_bool double_wrapping
81
+ double cache_lifetime_seconds
82
+ c_bool internal_key_material
83
+ int32_t data_key_length_bits
84
+
85
+ cdef cppclass CDecryptionConfiguration\
86
+ " parquet::encryption::DecryptionConfiguration":
87
+ CDecryptionConfiguration() except +
88
+ double cache_lifetime_seconds
89
+
90
+ cdef cppclass CCryptoFactory" parquet::encryption::CryptoFactory":
91
+ void RegisterKmsClientFactory(
92
+ shared_ptr[CKmsClientFactory] kms_client_factory) except +
93
+ shared_ptr[CFileEncryptionProperties] GetFileEncryptionProperties(
94
+ const CKmsConnectionConfig& kms_connection_config,
95
+ const CEncryptionConfiguration& encryption_config,
96
+ const c_string parquet_file_path,
97
+ const shared_ptr[CFileSystem] file_system) except +*
98
+ shared_ptr[CFileDecryptionProperties] GetFileDecryptionProperties(
99
+ const CKmsConnectionConfig& kms_connection_config,
100
+ const CDecryptionConfiguration& decryption_config,
101
+ const c_string parquet_file_path,
102
+ const shared_ptr[CFileSystem] file_system) except +*
103
+ void RemoveCacheEntriesForToken(const c_string& access_token) except +
104
+ void RemoveCacheEntriesForAllTokens() except +
105
+ void RotateMasterKeys(const CKmsConnectionConfig& kms_connection_config,
106
+ const c_string parquet_file_path,
107
+ const shared_ptr[CFileSystem] file_system,
108
+ c_bool double_wrapping,
109
+ double cache_lifetime_seconds)
110
+
111
+ cdef extern from "parquet/encryption/file_key_material_store.h" \
112
+ namespace "parquet::encryption" nogil:
113
+ cdef cppclass CFileKeyMaterialStore\
114
+ "parquet::encryption::FileKeyMaterialStore":
115
+ @staticmethod
116
+ c_string GetKeyMaterial(c_string key_id_in_file) except +
117
+ vector[c_string] GetKeyIDSet() except +
118
+
119
+ cdef extern from "parquet/encryption/file_system_key_material_store.h" \
120
+ namespace "parquet::encryption" nogil:
121
+ cdef cppclass CFileSystemKeyMaterialStore\
122
+ "parquet::encryption::FileSystemKeyMaterialStore":
123
+
124
+ @staticmethod
125
+ shared_ptr[CFileSystemKeyMaterialStore] Make(c_string parquet_file_path,
126
+ shared_ptr[CFileSystem] file_system,
127
+ c_bool use_tmp_prefix) except +
128
+
129
+ c_string GetKeyMaterial(c_string key_id_in_file) except +
130
+
131
+ vector[c_string] GetKeyIDSet() except +
132
+
133
+ cdef extern from "parquet/encryption/key_material.h" \
134
+ namespace "parquet::encryption" nogil:
135
+ cdef cppclass CKeyMaterial "parquet::encryption::KeyMaterial":
136
+ @staticmethod
137
+ CKeyMaterial Parse(const c_string& key_material_string)
138
+ c_bool is_footer_key()
139
+ c_bool is_double_wrapped()
140
+ const c_string& master_key_id()
141
+ const c_string& wrapped_dek()
142
+ const c_string& kek_id()
143
+ const c_string& wrapped_kek()
144
+ const c_string& kms_instance_id()
145
+ const c_string& kms_instance_url()
146
+
147
+ cdef extern from "arrow/python/parquet_encryption.h" \
148
+ namespace "arrow::py::parquet::encryption" nogil:
149
+ cdef cppclass CPyKmsClientVtable \
150
+ " arrow::py::parquet::encryption::PyKmsClientVtable":
151
+ CPyKmsClientVtable()
152
+ function[CallbackWrapKey] wrap_key
153
+ function[CallbackUnwrapKey] unwrap_key
154
+
155
+ cdef cppclass CPyKmsClient\
156
+ " arrow::py::parquet::encryption::PyKmsClient"(CKmsClient):
157
+ CPyKmsClient(object handler, CPyKmsClientVtable vtable)
158
+
159
+ cdef cppclass CPyKmsClientFactoryVtable\
160
+ " arrow::py::parquet::encryption::PyKmsClientFactoryVtable":
161
+ CPyKmsClientFactoryVtable()
162
+ function[CallbackCreateKmsClient] create_kms_client
163
+
164
+ cdef cppclass CPyKmsClientFactory\
165
+ " arrow::py::parquet::encryption::PyKmsClientFactory"(
166
+ CKmsClientFactory):
167
+ CPyKmsClientFactory(object handler, CPyKmsClientFactoryVtable vtable)
168
+
169
+ cdef cppclass CPyCryptoFactory\
170
+ " arrow::py::parquet::encryption::PyCryptoFactory"(CCryptoFactory):
171
+ CResult[shared_ptr[CFileEncryptionProperties]] \
172
+ SafeGetFileEncryptionProperties(
173
+ const CKmsConnectionConfig& kms_connection_config,
174
+ const CEncryptionConfiguration& encryption_config,
175
+ const c_string parquet_file_path,
176
+ const shared_ptr[CFileSystem] filesystem)
177
+ CResult[shared_ptr[CFileDecryptionProperties]] \
178
+ SafeGetFileDecryptionProperties(
179
+ const CKmsConnectionConfig& kms_connection_config,
180
+ const CDecryptionConfiguration& decryption_config,
181
+ const c_string parquet_file_path,
182
+ const shared_ptr[CFileSystem] filesystem)
183
+ CStatus SafeRotateMasterKeys(const CKmsConnectionConfig& kms_connection_config,
184
+ const c_string parquet_file_path,
185
+ const shared_ptr[CFileSystem] filesystem,
186
+ c_bool double_wrapping,
187
+ double cache_lifetime_seconds)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/__init__.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # flake8: noqa
19
+
20
+ from .from_dataframe import from_dataframe
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/buffer.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from __future__ import annotations
19
+ import enum
20
+
21
+ import pyarrow as pa
22
+
23
+
24
+ class DlpackDeviceType(enum.IntEnum):
25
+ """Integer enum for device type codes matching DLPack."""
26
+
27
+ CPU = 1
28
+ CUDA = 2
29
+ CPU_PINNED = 3
30
+ OPENCL = 4
31
+ VULKAN = 7
32
+ METAL = 8
33
+ VPI = 9
34
+ ROCM = 10
35
+
36
+
37
+ class _PyArrowBuffer:
38
+ """
39
+ Data in the buffer is guaranteed to be contiguous in memory.
40
+
41
+ Note that there is no dtype attribute present, a buffer can be thought of
42
+ as simply a block of memory. However, if the column that the buffer is
43
+ attached to has a dtype that's supported by DLPack and ``__dlpack__`` is
44
+ implemented, then that dtype information will be contained in the return
45
+ value from ``__dlpack__``.
46
+
47
+ This distinction is useful to support both data exchange via DLPack on a
48
+ buffer and (b) dtypes like variable-length strings which do not have a
49
+ fixed number of bytes per element.
50
+ """
51
+
52
+ def __init__(self, x: pa.Buffer, allow_copy: bool = True) -> None:
53
+ """
54
+ Handle PyArrow Buffers.
55
+ """
56
+ self._x = x
57
+
58
+ @property
59
+ def bufsize(self) -> int:
60
+ """
61
+ Buffer size in bytes.
62
+ """
63
+ return self._x.size
64
+
65
+ @property
66
+ def ptr(self) -> int:
67
+ """
68
+ Pointer to start of the buffer as an integer.
69
+ """
70
+ return self._x.address
71
+
72
+ def __dlpack__(self):
73
+ """
74
+ Produce DLPack capsule (see array API standard).
75
+
76
+ Raises:
77
+ - TypeError : if the buffer contains unsupported dtypes.
78
+ - NotImplementedError : if DLPack support is not implemented
79
+
80
+ Useful to have to connect to array libraries. Support optional because
81
+ it's not completely trivial to implement for a Python-only library.
82
+ """
83
+ raise NotImplementedError("__dlpack__")
84
+
85
+ def __dlpack_device__(self) -> tuple[DlpackDeviceType, int | None]:
86
+ """
87
+ Device type and device ID for where the data in the buffer resides.
88
+ Uses device type codes matching DLPack.
89
+ Note: must be implemented even if ``__dlpack__`` is not.
90
+ """
91
+ if self._x.is_cpu:
92
+ return (DlpackDeviceType.CPU, None)
93
+ else:
94
+ raise NotImplementedError("__dlpack_device__")
95
+
96
+ def __repr__(self) -> str:
97
+ return (
98
+ "PyArrowBuffer(" +
99
+ str(
100
+ {
101
+ "bufsize": self.bufsize,
102
+ "ptr": self.ptr,
103
+ "device": self.__dlpack_device__()[0].name,
104
+ }
105
+ ) +
106
+ ")"
107
+ )
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/column.py ADDED
@@ -0,0 +1,529 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from __future__ import annotations
19
+
20
+ import enum
21
+ from typing import (
22
+ Any,
23
+ Dict,
24
+ Iterable,
25
+ Optional,
26
+ Tuple,
27
+ )
28
+
29
+ import sys
30
+ if sys.version_info >= (3, 8):
31
+ from typing import TypedDict
32
+ else:
33
+ from typing_extensions import TypedDict
34
+
35
+ import pyarrow as pa
36
+ import pyarrow.compute as pc
37
+ from pyarrow.interchange.buffer import _PyArrowBuffer
38
+
39
+
40
+ class DtypeKind(enum.IntEnum):
41
+ """
42
+ Integer enum for data types.
43
+
44
+ Attributes
45
+ ----------
46
+ INT : int
47
+ Matches to signed integer data type.
48
+ UINT : int
49
+ Matches to unsigned integer data type.
50
+ FLOAT : int
51
+ Matches to floating point data type.
52
+ BOOL : int
53
+ Matches to boolean data type.
54
+ STRING : int
55
+ Matches to string data type (UTF-8 encoded).
56
+ DATETIME : int
57
+ Matches to datetime data type.
58
+ CATEGORICAL : int
59
+ Matches to categorical data type.
60
+ """
61
+
62
+ INT = 0
63
+ UINT = 1
64
+ FLOAT = 2
65
+ BOOL = 20
66
+ STRING = 21 # UTF-8
67
+ DATETIME = 22
68
+ CATEGORICAL = 23
69
+
70
+
71
+ Dtype = Tuple[DtypeKind, int, str, str] # see Column.dtype
72
+
73
+
74
+ _PYARROW_KINDS = {
75
+ pa.int8(): (DtypeKind.INT, "c"),
76
+ pa.int16(): (DtypeKind.INT, "s"),
77
+ pa.int32(): (DtypeKind.INT, "i"),
78
+ pa.int64(): (DtypeKind.INT, "l"),
79
+ pa.uint8(): (DtypeKind.UINT, "C"),
80
+ pa.uint16(): (DtypeKind.UINT, "S"),
81
+ pa.uint32(): (DtypeKind.UINT, "I"),
82
+ pa.uint64(): (DtypeKind.UINT, "L"),
83
+ pa.float16(): (DtypeKind.FLOAT, "e"),
84
+ pa.float32(): (DtypeKind.FLOAT, "f"),
85
+ pa.float64(): (DtypeKind.FLOAT, "g"),
86
+ pa.bool_(): (DtypeKind.BOOL, "b"),
87
+ pa.string(): (DtypeKind.STRING, "u"),
88
+ pa.large_string(): (DtypeKind.STRING, "U"),
89
+ }
90
+
91
+
92
+ class ColumnNullType(enum.IntEnum):
93
+ """
94
+ Integer enum for null type representation.
95
+
96
+ Attributes
97
+ ----------
98
+ NON_NULLABLE : int
99
+ Non-nullable column.
100
+ USE_NAN : int
101
+ Use explicit float NaN value.
102
+ USE_SENTINEL : int
103
+ Sentinel value besides NaN.
104
+ USE_BITMASK : int
105
+ The bit is set/unset representing a null on a certain position.
106
+ USE_BYTEMASK : int
107
+ The byte is set/unset representing a null on a certain position.
108
+ """
109
+
110
+ NON_NULLABLE = 0
111
+ USE_NAN = 1
112
+ USE_SENTINEL = 2
113
+ USE_BITMASK = 3
114
+ USE_BYTEMASK = 4
115
+
116
+
117
+ class ColumnBuffers(TypedDict):
118
+ # first element is a buffer containing the column data;
119
+ # second element is the data buffer's associated dtype
120
+ data: Tuple[_PyArrowBuffer, Dtype]
121
+
122
+ # first element is a buffer containing mask values indicating missing data;
123
+ # second element is the mask value buffer's associated dtype.
124
+ # None if the null representation is not a bit or byte mask
125
+ validity: Optional[Tuple[_PyArrowBuffer, Dtype]]
126
+
127
+ # first element is a buffer containing the offset values for
128
+ # variable-size binary data (e.g., variable-length strings);
129
+ # second element is the offsets buffer's associated dtype.
130
+ # None if the data buffer does not have an associated offsets buffer
131
+ offsets: Optional[Tuple[_PyArrowBuffer, Dtype]]
132
+
133
+
134
+ class CategoricalDescription(TypedDict):
135
+ # whether the ordering of dictionary indices is semantically meaningful
136
+ is_ordered: bool
137
+ # whether a dictionary-style mapping of categorical values to other objects
138
+ # exists
139
+ is_dictionary: bool
140
+ # Python-level only (e.g. ``{int: str}``).
141
+ # None if not a dictionary-style categorical.
142
+ categories: Optional[_PyArrowColumn]
143
+
144
+
145
+ class Endianness:
146
+ """Enum indicating the byte-order of a data-type."""
147
+
148
+ LITTLE = "<"
149
+ BIG = ">"
150
+ NATIVE = "="
151
+ NA = "|"
152
+
153
+
154
+ class NoBufferPresent(Exception):
155
+ """Exception to signal that there is no requested buffer."""
156
+
157
+
158
+ class _PyArrowColumn:
159
+ """
160
+ A column object, with only the methods and properties required by the
161
+ interchange protocol defined.
162
+
163
+ A column can contain one or more chunks. Each chunk can contain up to three
164
+ buffers - a data buffer, a mask buffer (depending on null representation),
165
+ and an offsets buffer (if variable-size binary; e.g., variable-length
166
+ strings).
167
+
168
+ TBD: Arrow has a separate "null" dtype, and has no separate mask concept.
169
+ Instead, it seems to use "children" for both columns with a bit mask,
170
+ and for nested dtypes. Unclear whether this is elegant or confusing.
171
+ This design requires checking the null representation explicitly.
172
+
173
+ The Arrow design requires checking:
174
+ 1. the ARROW_FLAG_NULLABLE (for sentinel values)
175
+ 2. if a column has two children, combined with one of those children
176
+ having a null dtype.
177
+
178
+ Making the mask concept explicit seems useful. One null dtype would
179
+ not be enough to cover both bit and byte masks, so that would mean
180
+ even more checking if we did it the Arrow way.
181
+
182
+ TBD: there's also the "chunk" concept here, which is implicit in Arrow as
183
+ multiple buffers per array (= column here). Semantically it may make
184
+ sense to have both: chunks were meant for example for lazy evaluation
185
+ of data which doesn't fit in memory, while multiple buffers per column
186
+ could also come from doing a selection operation on a single
187
+ contiguous buffer.
188
+
189
+ Given these concepts, one would expect chunks to be all of the same
190
+ size (say a 10,000 row dataframe could have 10 chunks of 1,000 rows),
191
+ while multiple buffers could have data-dependent lengths. Not an issue
192
+ in pandas if one column is backed by a single NumPy array, but in
193
+ Arrow it seems possible.
194
+ Are multiple chunks *and* multiple buffers per column necessary for
195
+ the purposes of this interchange protocol, or must producers either
196
+ reuse the chunk concept for this or copy the data?
197
+
198
+ Note: this Column object can only be produced by ``__dataframe__``, so
199
+ doesn't need its own version or ``__column__`` protocol.
200
+ """
201
+
202
+ def __init__(
203
+ self, column: pa.Array | pa.ChunkedArray, allow_copy: bool = True
204
+ ) -> None:
205
+ """
206
+ Handles PyArrow Arrays and ChunkedArrays.
207
+ """
208
+ # Store the column as a private attribute
209
+ if isinstance(column, pa.ChunkedArray):
210
+ if column.num_chunks == 1:
211
+ column = column.chunk(0)
212
+ else:
213
+ if not allow_copy:
214
+ raise RuntimeError(
215
+ "Chunks will be combined and a copy is required which "
216
+ "is forbidden by allow_copy=False"
217
+ )
218
+ column = column.combine_chunks()
219
+
220
+ self._allow_copy = allow_copy
221
+
222
+ if pa.types.is_boolean(column.type):
223
+ if not allow_copy:
224
+ raise RuntimeError(
225
+ "Boolean column will be casted to uint8 and a copy "
226
+ "is required which is forbidden by allow_copy=False"
227
+ )
228
+ self._dtype = self._dtype_from_arrowdtype(column.type, 8)
229
+ self._col = pc.cast(column, pa.uint8())
230
+ else:
231
+ self._col = column
232
+ dtype = self._col.type
233
+ try:
234
+ bit_width = dtype.bit_width
235
+ except ValueError:
236
+ # in case of a variable-length strings, considered as array
237
+ # of bytes (8 bits)
238
+ bit_width = 8
239
+ self._dtype = self._dtype_from_arrowdtype(dtype, bit_width)
240
+
241
+ def size(self) -> int:
242
+ """
243
+ Size of the column, in elements.
244
+
245
+ Corresponds to DataFrame.num_rows() if column is a single chunk;
246
+ equal to size of this current chunk otherwise.
247
+
248
+ Is a method rather than a property because it may cause a (potentially
249
+ expensive) computation for some dataframe implementations.
250
+ """
251
+ return len(self._col)
252
+
253
+ @property
254
+ def offset(self) -> int:
255
+ """
256
+ Offset of first element.
257
+
258
+ May be > 0 if using chunks; for example for a column with N chunks of
259
+ equal size M (only the last chunk may be shorter),
260
+ ``offset = n * M``, ``n = 0 .. N-1``.
261
+ """
262
+ return self._col.offset
263
+
264
+ @property
265
+ def dtype(self) -> Tuple[DtypeKind, int, str, str]:
266
+ """
267
+ Dtype description as a tuple ``(kind, bit-width, format string,
268
+ endianness)``.
269
+
270
+ Bit-width : the number of bits as an integer
271
+ Format string : data type description format string in Apache Arrow C
272
+ Data Interface format.
273
+ Endianness : current only native endianness (``=``) is supported
274
+
275
+ Notes:
276
+ - Kind specifiers are aligned with DLPack where possible (hence the
277
+ jump to 20, leave enough room for future extension)
278
+ - Masks must be specified as boolean with either bit width 1 (for
279
+ bit masks) or 8 (for byte masks).
280
+ - Dtype width in bits was preferred over bytes
281
+ - Endianness isn't too useful, but included now in case in the
282
+ future we need to support non-native endianness
283
+ - Went with Apache Arrow format strings over NumPy format strings
284
+ because they're more complete from a dataframe perspective
285
+ - Format strings are mostly useful for datetime specification, and
286
+ for categoricals.
287
+ - For categoricals, the format string describes the type of the
288
+ categorical in the data buffer. In case of a separate encoding of
289
+ the categorical (e.g. an integer to string mapping), this can
290
+ be derived from ``self.describe_categorical``.
291
+ - Data types not included: complex, Arrow-style null, binary,
292
+ decimal, and nested (list, struct, map, union) dtypes.
293
+ """
294
+ return self._dtype
295
+
296
+ def _dtype_from_arrowdtype(
297
+ self, dtype: pa.DataType, bit_width: int
298
+ ) -> Tuple[DtypeKind, int, str, str]:
299
+ """
300
+ See `self.dtype` for details.
301
+ """
302
+ # Note: 'c' (complex) not handled yet (not in array spec v1).
303
+ # 'b', 'B' (bytes), 'S', 'a', (old-style string) 'V' (void)
304
+ # not handled datetime and timedelta both map to datetime
305
+ # (is timedelta handled?)
306
+
307
+ if pa.types.is_timestamp(dtype):
308
+ kind = DtypeKind.DATETIME
309
+ ts = dtype.unit[0]
310
+ tz = dtype.tz if dtype.tz else ""
311
+ f_string = f"ts{ts}:{tz}"
312
+ return kind, bit_width, f_string, Endianness.NATIVE
313
+ elif pa.types.is_dictionary(dtype):
314
+ kind = DtypeKind.CATEGORICAL
315
+ arr = self._col
316
+ indices_dtype = arr.indices.type
317
+ _, f_string = _PYARROW_KINDS.get(indices_dtype)
318
+ return kind, bit_width, f_string, Endianness.NATIVE
319
+ else:
320
+ kind, f_string = _PYARROW_KINDS.get(dtype, (None, None))
321
+ if kind is None:
322
+ raise ValueError(
323
+ f"Data type {dtype} not supported by interchange protocol")
324
+
325
+ return kind, bit_width, f_string, Endianness.NATIVE
326
+
327
+ @property
328
+ def describe_categorical(self) -> CategoricalDescription:
329
+ """
330
+ If the dtype is categorical, there are two options:
331
+ - There are only values in the data buffer.
332
+ - There is a separate non-categorical Column encoding categorical
333
+ values.
334
+
335
+ Raises TypeError if the dtype is not categorical
336
+
337
+ Returns the dictionary with description on how to interpret the
338
+ data buffer:
339
+ - "is_ordered" : bool, whether the ordering of dictionary indices
340
+ is semantically meaningful.
341
+ - "is_dictionary" : bool, whether a mapping of
342
+ categorical values to other objects exists
343
+ - "categories" : Column representing the (implicit) mapping of
344
+ indices to category values (e.g. an array of
345
+ cat1, cat2, ...). None if not a dictionary-style
346
+ categorical.
347
+
348
+ TBD: are there any other in-memory representations that are needed?
349
+ """
350
+ arr = self._col
351
+ if not pa.types.is_dictionary(arr.type):
352
+ raise TypeError(
353
+ "describe_categorical only works on a column with "
354
+ "categorical dtype!"
355
+ )
356
+
357
+ return {
358
+ "is_ordered": self._col.type.ordered,
359
+ "is_dictionary": True,
360
+ "categories": _PyArrowColumn(arr.dictionary),
361
+ }
362
+
363
+ @property
364
+ def describe_null(self) -> Tuple[ColumnNullType, Any]:
365
+ """
366
+ Return the missing value (or "null") representation the column dtype
367
+ uses, as a tuple ``(kind, value)``.
368
+
369
+ Value : if kind is "sentinel value", the actual value. If kind is a bit
370
+ mask or a byte mask, the value (0 or 1) indicating a missing value.
371
+ None otherwise.
372
+ """
373
+ # In case of no missing values, we need to set ColumnNullType to
374
+ # non nullable as in the current __dataframe__ protocol bit/byte masks
375
+ # cannot be None
376
+ if self.null_count == 0:
377
+ return ColumnNullType.NON_NULLABLE, None
378
+ else:
379
+ return ColumnNullType.USE_BITMASK, 0
380
+
381
+ @property
382
+ def null_count(self) -> int:
383
+ """
384
+ Number of null elements, if known.
385
+
386
+ Note: Arrow uses -1 to indicate "unknown", but None seems cleaner.
387
+ """
388
+ arrow_null_count = self._col.null_count
389
+ n = arrow_null_count if arrow_null_count != -1 else None
390
+ return n
391
+
392
+ @property
393
+ def metadata(self) -> Dict[str, Any]:
394
+ """
395
+ The metadata for the column. See `DataFrame.metadata` for more details.
396
+ """
397
+ pass
398
+
399
+ def num_chunks(self) -> int:
400
+ """
401
+ Return the number of chunks the column consists of.
402
+ """
403
+ return 1
404
+
405
+ def get_chunks(
406
+ self, n_chunks: Optional[int] = None
407
+ ) -> Iterable[_PyArrowColumn]:
408
+ """
409
+ Return an iterator yielding the chunks.
410
+
411
+ See `DataFrame.get_chunks` for details on ``n_chunks``.
412
+ """
413
+ if n_chunks and n_chunks > 1:
414
+ chunk_size = self.size() // n_chunks
415
+ if self.size() % n_chunks != 0:
416
+ chunk_size += 1
417
+
418
+ array = self._col
419
+ i = 0
420
+ for start in range(0, chunk_size * n_chunks, chunk_size):
421
+ yield _PyArrowColumn(
422
+ array.slice(start, chunk_size), self._allow_copy
423
+ )
424
+ i += 1
425
+ else:
426
+ yield self
427
+
428
+ def get_buffers(self) -> ColumnBuffers:
429
+ """
430
+ Return a dictionary containing the underlying buffers.
431
+
432
+ The returned dictionary has the following contents:
433
+
434
+ - "data": a two-element tuple whose first element is a buffer
435
+ containing the data and whose second element is the data
436
+ buffer's associated dtype.
437
+ - "validity": a two-element tuple whose first element is a buffer
438
+ containing mask values indicating missing data and
439
+ whose second element is the mask value buffer's
440
+ associated dtype. None if the null representation is
441
+ not a bit or byte mask.
442
+ - "offsets": a two-element tuple whose first element is a buffer
443
+ containing the offset values for variable-size binary
444
+ data (e.g., variable-length strings) and whose second
445
+ element is the offsets buffer's associated dtype. None
446
+ if the data buffer does not have an associated offsets
447
+ buffer.
448
+ """
449
+ buffers: ColumnBuffers = {
450
+ "data": self._get_data_buffer(),
451
+ "validity": None,
452
+ "offsets": None,
453
+ }
454
+
455
+ try:
456
+ buffers["validity"] = self._get_validity_buffer()
457
+ except NoBufferPresent:
458
+ pass
459
+
460
+ try:
461
+ buffers["offsets"] = self._get_offsets_buffer()
462
+ except NoBufferPresent:
463
+ pass
464
+
465
+ return buffers
466
+
467
+ def _get_data_buffer(
468
+ self,
469
+ ) -> Tuple[_PyArrowBuffer, Any]: # Any is for self.dtype tuple
470
+ """
471
+ Return the buffer containing the data and the buffer's
472
+ associated dtype.
473
+ """
474
+ array = self._col
475
+ dtype = self.dtype
476
+
477
+ # In case of dictionary arrays, use indices
478
+ # to define a buffer, codes are transferred through
479
+ # describe_categorical()
480
+ if pa.types.is_dictionary(array.type):
481
+ array = array.indices
482
+ dtype = _PyArrowColumn(array).dtype
483
+
484
+ n = len(array.buffers())
485
+ if n == 2:
486
+ return _PyArrowBuffer(array.buffers()[1]), dtype
487
+ elif n == 3:
488
+ return _PyArrowBuffer(array.buffers()[2]), dtype
489
+
490
+ def _get_validity_buffer(self) -> Tuple[_PyArrowBuffer, Any]:
491
+ """
492
+ Return the buffer containing the mask values indicating missing data
493
+ and the buffer's associated dtype.
494
+ Raises NoBufferPresent if null representation is not a bit or byte
495
+ mask.
496
+ """
497
+ # Define the dtype of the returned buffer
498
+ dtype = (DtypeKind.BOOL, 1, "b", Endianness.NATIVE)
499
+ array = self._col
500
+ buff = array.buffers()[0]
501
+ if buff:
502
+ return _PyArrowBuffer(buff), dtype
503
+ else:
504
+ raise NoBufferPresent(
505
+ "There are no missing values so "
506
+ "does not have a separate mask")
507
+
508
+ def _get_offsets_buffer(self) -> Tuple[_PyArrowBuffer, Any]:
509
+ """
510
+ Return the buffer containing the offset values for variable-size binary
511
+ data (e.g., variable-length strings) and the buffer's associated dtype.
512
+ Raises NoBufferPresent if the data buffer does not have an associated
513
+ offsets buffer.
514
+ """
515
+ array = self._col
516
+ n = len(array.buffers())
517
+ if n == 2:
518
+ raise NoBufferPresent(
519
+ "This column has a fixed-length dtype so "
520
+ "it does not have an offsets buffer"
521
+ )
522
+ elif n == 3:
523
+ # Define the dtype of the returned buffer
524
+ dtype = self._col.type
525
+ if pa.types.is_large_string(dtype):
526
+ dtype = (DtypeKind.INT, 64, "l", Endianness.NATIVE)
527
+ else:
528
+ dtype = (DtypeKind.INT, 32, "i", Endianness.NATIVE)
529
+ return _PyArrowBuffer(array.buffers()[1]), dtype
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/dataframe.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from __future__ import annotations
19
+ from typing import (
20
+ Any,
21
+ Iterable,
22
+ Optional,
23
+ Sequence,
24
+ )
25
+
26
+ import pyarrow as pa
27
+
28
+ from pyarrow.interchange.column import _PyArrowColumn
29
+
30
+
31
+ class _PyArrowDataFrame:
32
+ """
33
+ A data frame class, with only the methods required by the interchange
34
+ protocol defined.
35
+
36
+ A "data frame" represents an ordered collection of named columns.
37
+ A column's "name" must be a unique string.
38
+ Columns may be accessed by name or by position.
39
+
40
+ This could be a public data frame class, or an object with the methods and
41
+ attributes defined on this DataFrame class could be returned from the
42
+ ``__dataframe__`` method of a public data frame class in a library adhering
43
+ to the dataframe interchange protocol specification.
44
+ """
45
+
46
+ def __init__(
47
+ self, df: pa.Table | pa.RecordBatch,
48
+ nan_as_null: bool = False,
49
+ allow_copy: bool = True
50
+ ) -> None:
51
+ """
52
+ Constructor - an instance of this (private) class is returned from
53
+ `pa.Table.__dataframe__` or `pa.RecordBatch.__dataframe__`.
54
+ """
55
+ self._df = df
56
+ # ``nan_as_null`` is a keyword intended for the consumer to tell the
57
+ # producer to overwrite null values in the data with ``NaN`` (or
58
+ # ``NaT``).
59
+ if nan_as_null is True:
60
+ raise RuntimeError(
61
+ "nan_as_null=True currently has no effect, "
62
+ "use the default nan_as_null=False"
63
+ )
64
+ self._nan_as_null = nan_as_null
65
+ self._allow_copy = allow_copy
66
+
67
+ def __dataframe__(
68
+ self, nan_as_null: bool = False, allow_copy: bool = True
69
+ ) -> _PyArrowDataFrame:
70
+ """
71
+ Construct a new exchange object, potentially changing the parameters.
72
+ ``nan_as_null`` is a keyword intended for the consumer to tell the
73
+ producer to overwrite null values in the data with ``NaN``.
74
+ It is intended for cases where the consumer does not support the bit
75
+ mask or byte mask that is the producer's native representation.
76
+ ``allow_copy`` is a keyword that defines whether or not the library is
77
+ allowed to make a copy of the data. For example, copying data would be
78
+ necessary if a library supports strided buffers, given that this
79
+ protocol specifies contiguous buffers.
80
+ """
81
+ return _PyArrowDataFrame(self._df, nan_as_null, allow_copy)
82
+
83
+ @property
84
+ def metadata(self) -> dict[str, Any]:
85
+ """
86
+ The metadata for the data frame, as a dictionary with string keys. The
87
+ contents of `metadata` may be anything, they are meant for a library
88
+ to store information that it needs to, e.g., roundtrip losslessly or
89
+ for two implementations to share data that is not (yet) part of the
90
+ interchange protocol specification. For avoiding collisions with other
91
+ entries, please add name the keys with the name of the library
92
+ followed by a period and the desired name, e.g, ``pandas.indexcol``.
93
+ """
94
+ # The metadata for the data frame, as a dictionary with string keys.
95
+ # Add schema metadata here (pandas metadata or custom metadata)
96
+ if self._df.schema.metadata:
97
+ schema_metadata = {"pyarrow." + k.decode('utf8'): v.decode('utf8')
98
+ for k, v in self._df.schema.metadata.items()}
99
+ return schema_metadata
100
+ else:
101
+ return {}
102
+
103
+ def num_columns(self) -> int:
104
+ """
105
+ Return the number of columns in the DataFrame.
106
+ """
107
+ return self._df.num_columns
108
+
109
+ def num_rows(self) -> int:
110
+ """
111
+ Return the number of rows in the DataFrame, if available.
112
+ """
113
+ return self._df.num_rows
114
+
115
+ def num_chunks(self) -> int:
116
+ """
117
+ Return the number of chunks the DataFrame consists of.
118
+ """
119
+ if isinstance(self._df, pa.RecordBatch):
120
+ return 1
121
+ else:
122
+ # pyarrow.Table can have columns with different number
123
+ # of chunks so we take the number of chunks that
124
+ # .to_batches() returns as it takes the min chunk size
125
+ # of all the columns (to_batches is a zero copy method)
126
+ batches = self._df.to_batches()
127
+ return len(batches)
128
+
129
+ def column_names(self) -> Iterable[str]:
130
+ """
131
+ Return an iterator yielding the column names.
132
+ """
133
+ return self._df.schema.names
134
+
135
+ def get_column(self, i: int) -> _PyArrowColumn:
136
+ """
137
+ Return the column at the indicated position.
138
+ """
139
+ return _PyArrowColumn(self._df.column(i),
140
+ allow_copy=self._allow_copy)
141
+
142
+ def get_column_by_name(self, name: str) -> _PyArrowColumn:
143
+ """
144
+ Return the column whose name is the indicated name.
145
+ """
146
+ return _PyArrowColumn(self._df.column(name),
147
+ allow_copy=self._allow_copy)
148
+
149
+ def get_columns(self) -> Iterable[_PyArrowColumn]:
150
+ """
151
+ Return an iterator yielding the columns.
152
+ """
153
+ return [
154
+ _PyArrowColumn(col, allow_copy=self._allow_copy)
155
+ for col in self._df.columns
156
+ ]
157
+
158
+ def select_columns(self, indices: Sequence[int]) -> _PyArrowDataFrame:
159
+ """
160
+ Create a new DataFrame by selecting a subset of columns by index.
161
+ """
162
+ return _PyArrowDataFrame(
163
+ self._df.select(list(indices)), self._nan_as_null, self._allow_copy
164
+ )
165
+
166
+ def select_columns_by_name(
167
+ self, names: Sequence[str]
168
+ ) -> _PyArrowDataFrame:
169
+ """
170
+ Create a new DataFrame by selecting a subset of columns by name.
171
+ """
172
+ return _PyArrowDataFrame(
173
+ self._df.select(list(names)), self._nan_as_null, self._allow_copy
174
+ )
175
+
176
+ def get_chunks(
177
+ self, n_chunks: Optional[int] = None
178
+ ) -> Iterable[_PyArrowDataFrame]:
179
+ """
180
+ Return an iterator yielding the chunks.
181
+
182
+ By default (None), yields the chunks that the data is stored as by the
183
+ producer. If given, ``n_chunks`` must be a multiple of
184
+ ``self.num_chunks()``, meaning the producer must subdivide each chunk
185
+ before yielding it.
186
+
187
+ Note that the producer must ensure that all columns are chunked the
188
+ same way.
189
+ """
190
+ # Subdivide chunks
191
+ if n_chunks and n_chunks > 1:
192
+ chunk_size = self.num_rows() // n_chunks
193
+ if self.num_rows() % n_chunks != 0:
194
+ chunk_size += 1
195
+ if isinstance(self._df, pa.Table):
196
+ batches = self._df.to_batches(max_chunksize=chunk_size)
197
+ else:
198
+ batches = []
199
+ for start in range(0, chunk_size * n_chunks, chunk_size):
200
+ batches.append(self._df.slice(start, chunk_size))
201
+ # In case when the size of the chunk is such that the resulting
202
+ # list is one less chunk then n_chunks -> append an empty chunk
203
+ if len(batches) == n_chunks - 1:
204
+ batches.append(pa.record_batch([[]], schema=self._df.schema))
205
+ # yields the chunks that the data is stored as
206
+ else:
207
+ if isinstance(self._df, pa.Table):
208
+ batches = self._df.to_batches()
209
+ else:
210
+ batches = [self._df]
211
+
212
+ # Create an iterator of RecordBatches
213
+ iterator = [_PyArrowDataFrame(batch,
214
+ self._nan_as_null,
215
+ self._allow_copy)
216
+ for batch in batches]
217
+ return iterator
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/interchange/from_dataframe.py ADDED
@@ -0,0 +1,614 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from __future__ import annotations
19
+
20
+ from typing import (
21
+ Any,
22
+ Tuple,
23
+ )
24
+
25
+ from pyarrow.interchange.column import (
26
+ DtypeKind,
27
+ ColumnBuffers,
28
+ ColumnNullType,
29
+ )
30
+
31
+ import pyarrow as pa
32
+ import re
33
+
34
+ import pyarrow.compute as pc
35
+ from pyarrow.interchange.column import Dtype
36
+
37
+
38
+ # A typing protocol could be added later to let Mypy validate code using
39
+ # `from_dataframe` better.
40
+ DataFrameObject = Any
41
+ ColumnObject = Any
42
+ BufferObject = Any
43
+
44
+
45
+ _PYARROW_DTYPES: dict[DtypeKind, dict[int, Any]] = {
46
+ DtypeKind.INT: {8: pa.int8(),
47
+ 16: pa.int16(),
48
+ 32: pa.int32(),
49
+ 64: pa.int64()},
50
+ DtypeKind.UINT: {8: pa.uint8(),
51
+ 16: pa.uint16(),
52
+ 32: pa.uint32(),
53
+ 64: pa.uint64()},
54
+ DtypeKind.FLOAT: {16: pa.float16(),
55
+ 32: pa.float32(),
56
+ 64: pa.float64()},
57
+ DtypeKind.BOOL: {1: pa.bool_(),
58
+ 8: pa.uint8()},
59
+ DtypeKind.STRING: {8: pa.string()},
60
+ }
61
+
62
+
63
+ def from_dataframe(df: DataFrameObject, allow_copy=True) -> pa.Table:
64
+ """
65
+ Build a ``pa.Table`` from any DataFrame supporting the interchange protocol.
66
+
67
+ Parameters
68
+ ----------
69
+ df : DataFrameObject
70
+ Object supporting the interchange protocol, i.e. `__dataframe__`
71
+ method.
72
+ allow_copy : bool, default: True
73
+ Whether to allow copying the memory to perform the conversion
74
+ (if false then zero-copy approach is requested).
75
+
76
+ Returns
77
+ -------
78
+ pa.Table
79
+
80
+ Examples
81
+ --------
82
+ >>> import pyarrow
83
+ >>> from pyarrow.interchange import from_dataframe
84
+
85
+ Convert a pandas dataframe to a pyarrow table:
86
+
87
+ >>> import pandas as pd
88
+ >>> df = pd.DataFrame({
89
+ ... "n_attendees": [100, 10, 1],
90
+ ... "country": ["Italy", "Spain", "Slovenia"],
91
+ ... })
92
+ >>> df
93
+ n_attendees country
94
+ 0 100 Italy
95
+ 1 10 Spain
96
+ 2 1 Slovenia
97
+ >>> from_dataframe(df)
98
+ pyarrow.Table
99
+ n_attendees: int64
100
+ country: large_string
101
+ ----
102
+ n_attendees: [[100,10,1]]
103
+ country: [["Italy","Spain","Slovenia"]]
104
+ """
105
+ if isinstance(df, pa.Table):
106
+ return df
107
+ elif isinstance(df, pa.RecordBatch):
108
+ return pa.Table.from_batches([df])
109
+
110
+ if not hasattr(df, "__dataframe__"):
111
+ raise ValueError("`df` does not support __dataframe__")
112
+
113
+ return _from_dataframe(df.__dataframe__(allow_copy=allow_copy),
114
+ allow_copy=allow_copy)
115
+
116
+
117
+ def _from_dataframe(df: DataFrameObject, allow_copy=True):
118
+ """
119
+ Build a ``pa.Table`` from the DataFrame interchange object.
120
+
121
+ Parameters
122
+ ----------
123
+ df : DataFrameObject
124
+ Object supporting the interchange protocol, i.e. `__dataframe__`
125
+ method.
126
+ allow_copy : bool, default: True
127
+ Whether to allow copying the memory to perform the conversion
128
+ (if false then zero-copy approach is requested).
129
+
130
+ Returns
131
+ -------
132
+ pa.Table
133
+ """
134
+ batches = []
135
+ for chunk in df.get_chunks():
136
+ batch = protocol_df_chunk_to_pyarrow(chunk, allow_copy)
137
+ batches.append(batch)
138
+
139
+ if not batches:
140
+ batch = protocol_df_chunk_to_pyarrow(df)
141
+ batches.append(batch)
142
+
143
+ return pa.Table.from_batches(batches)
144
+
145
+
146
+ def protocol_df_chunk_to_pyarrow(
147
+ df: DataFrameObject,
148
+ allow_copy: bool = True
149
+ ) -> pa.RecordBatch:
150
+ """
151
+ Convert interchange protocol chunk to ``pa.RecordBatch``.
152
+
153
+ Parameters
154
+ ----------
155
+ df : DataFrameObject
156
+ Object supporting the interchange protocol, i.e. `__dataframe__`
157
+ method.
158
+ allow_copy : bool, default: True
159
+ Whether to allow copying the memory to perform the conversion
160
+ (if false then zero-copy approach is requested).
161
+
162
+ Returns
163
+ -------
164
+ pa.RecordBatch
165
+ """
166
+ # We need a dict of columns here, with each column being a pa.Array
167
+ columns: dict[str, pa.Array] = {}
168
+ for name in df.column_names():
169
+ if not isinstance(name, str):
170
+ raise ValueError(f"Column {name} is not a string")
171
+ if name in columns:
172
+ raise ValueError(f"Column {name} is not unique")
173
+ col = df.get_column_by_name(name)
174
+ dtype = col.dtype[0]
175
+ if dtype in (
176
+ DtypeKind.INT,
177
+ DtypeKind.UINT,
178
+ DtypeKind.FLOAT,
179
+ DtypeKind.STRING,
180
+ DtypeKind.DATETIME,
181
+ ):
182
+ columns[name] = column_to_array(col, allow_copy)
183
+ elif dtype == DtypeKind.BOOL:
184
+ columns[name] = bool_column_to_array(col, allow_copy)
185
+ elif dtype == DtypeKind.CATEGORICAL:
186
+ columns[name] = categorical_column_to_dictionary(col, allow_copy)
187
+ else:
188
+ raise NotImplementedError(f"Data type {dtype} not handled yet")
189
+
190
+ return pa.RecordBatch.from_pydict(columns)
191
+
192
+
193
+ def column_to_array(
194
+ col: ColumnObject,
195
+ allow_copy: bool = True,
196
+ ) -> pa.Array:
197
+ """
198
+ Convert a column holding one of the primitive dtypes to a PyArrow array.
199
+ A primitive type is one of: int, uint, float, bool (1 bit).
200
+
201
+ Parameters
202
+ ----------
203
+ col : ColumnObject
204
+ allow_copy : bool, default: True
205
+ Whether to allow copying the memory to perform the conversion
206
+ (if false then zero-copy approach is requested).
207
+
208
+ Returns
209
+ -------
210
+ pa.Array
211
+ """
212
+ buffers = col.get_buffers()
213
+ data_type = col.dtype
214
+ data = buffers_to_array(buffers, data_type,
215
+ col.size(),
216
+ col.describe_null,
217
+ col.offset,
218
+ allow_copy)
219
+ return data
220
+
221
+
222
+ def bool_column_to_array(
223
+ col: ColumnObject,
224
+ allow_copy: bool = True,
225
+ ) -> pa.Array:
226
+ """
227
+ Convert a column holding boolean dtype to a PyArrow array.
228
+
229
+ Parameters
230
+ ----------
231
+ col : ColumnObject
232
+ allow_copy : bool, default: True
233
+ Whether to allow copying the memory to perform the conversion
234
+ (if false then zero-copy approach is requested).
235
+
236
+ Returns
237
+ -------
238
+ pa.Array
239
+ """
240
+ buffers = col.get_buffers()
241
+ size = buffers["data"][1][1]
242
+
243
+ # If booleans are byte-packed a copy to bit-packed will be made
244
+ if size == 8 and not allow_copy:
245
+ raise RuntimeError(
246
+ "Boolean column will be casted from uint8 and a copy "
247
+ "is required which is forbidden by allow_copy=False"
248
+ )
249
+
250
+ data_type = col.dtype
251
+ data = buffers_to_array(buffers, data_type,
252
+ col.size(),
253
+ col.describe_null,
254
+ col.offset)
255
+ if size == 8:
256
+ data = pc.cast(data, pa.bool_())
257
+
258
+ return data
259
+
260
+
261
+ def categorical_column_to_dictionary(
262
+ col: ColumnObject,
263
+ allow_copy: bool = True,
264
+ ) -> pa.DictionaryArray:
265
+ """
266
+ Convert a column holding categorical data to a pa.DictionaryArray.
267
+
268
+ Parameters
269
+ ----------
270
+ col : ColumnObject
271
+ allow_copy : bool, default: True
272
+ Whether to allow copying the memory to perform the conversion
273
+ (if false then zero-copy approach is requested).
274
+
275
+ Returns
276
+ -------
277
+ pa.DictionaryArray
278
+ """
279
+ if not allow_copy:
280
+ raise RuntimeError(
281
+ "Categorical column will be casted from uint8 and a copy "
282
+ "is required which is forbidden by allow_copy=False"
283
+ )
284
+
285
+ categorical = col.describe_categorical
286
+
287
+ if not categorical["is_dictionary"]:
288
+ raise NotImplementedError(
289
+ "Non-dictionary categoricals not supported yet")
290
+
291
+ # We need to first convert the dictionary column
292
+ cat_column = categorical["categories"]
293
+ dictionary = column_to_array(cat_column)
294
+ # Then we need to convert the indices
295
+ # Here we need to use the buffer data type!
296
+ buffers = col.get_buffers()
297
+ _, data_type = buffers["data"]
298
+ indices = buffers_to_array(buffers, data_type,
299
+ col.size(),
300
+ col.describe_null,
301
+ col.offset)
302
+
303
+ # Constructing a pa.DictionaryArray
304
+ dict_array = pa.DictionaryArray.from_arrays(indices, dictionary)
305
+
306
+ return dict_array
307
+
308
+
309
+ def parse_datetime_format_str(format_str):
310
+ """Parse datetime `format_str` to interpret the `data`."""
311
+
312
+ # timestamp 'ts{unit}:tz'
313
+ timestamp_meta = re.match(r"ts([smun]):(.*)", format_str)
314
+ if timestamp_meta:
315
+ unit, tz = timestamp_meta.group(1), timestamp_meta.group(2)
316
+ if unit != "s":
317
+ # the format string describes only a first letter of the unit, so
318
+ # add one extra letter to convert the unit to numpy-style:
319
+ # 'm' -> 'ms', 'u' -> 'us', 'n' -> 'ns'
320
+ unit += "s"
321
+
322
+ return unit, tz
323
+
324
+ raise NotImplementedError(f"DateTime kind is not supported: {format_str}")
325
+
326
+
327
+ def map_date_type(data_type):
328
+ """Map column date type to pyarrow date type. """
329
+ kind, bit_width, f_string, _ = data_type
330
+
331
+ if kind == DtypeKind.DATETIME:
332
+ unit, tz = parse_datetime_format_str(f_string)
333
+ return pa.timestamp(unit, tz=tz)
334
+ else:
335
+ pa_dtype = _PYARROW_DTYPES.get(kind, {}).get(bit_width, None)
336
+
337
+ # Error if dtype is not supported
338
+ if pa_dtype:
339
+ return pa_dtype
340
+ else:
341
+ raise NotImplementedError(
342
+ f"Conversion for {data_type} is not yet supported.")
343
+
344
+
345
+ def buffers_to_array(
346
+ buffers: ColumnBuffers,
347
+ data_type: Tuple[DtypeKind, int, str, str],
348
+ length: int,
349
+ describe_null: ColumnNullType,
350
+ offset: int = 0,
351
+ allow_copy: bool = True,
352
+ ) -> pa.Array:
353
+ """
354
+ Build a PyArrow array from the passed buffer.
355
+
356
+ Parameters
357
+ ----------
358
+ buffer : ColumnBuffers
359
+ Dictionary containing tuples of underlying buffers and
360
+ their associated dtype.
361
+ data_type : Tuple[DtypeKind, int, str, str],
362
+ Dtype description of the column as a tuple ``(kind, bit-width, format string,
363
+ endianness)``.
364
+ length : int
365
+ The number of values in the array.
366
+ describe_null: ColumnNullType
367
+ Null representation the column dtype uses,
368
+ as a tuple ``(kind, value)``
369
+ offset : int, default: 0
370
+ Number of elements to offset from the start of the buffer.
371
+ allow_copy : bool, default: True
372
+ Whether to allow copying the memory to perform the conversion
373
+ (if false then zero-copy approach is requested).
374
+
375
+ Returns
376
+ -------
377
+ pa.Array
378
+
379
+ Notes
380
+ -----
381
+ The returned array doesn't own the memory. The caller of this function
382
+ is responsible for keeping the memory owner object alive as long as
383
+ the returned PyArrow array is being used.
384
+ """
385
+ data_buff, _ = buffers["data"]
386
+ try:
387
+ validity_buff, validity_dtype = buffers["validity"]
388
+ except TypeError:
389
+ validity_buff = None
390
+ try:
391
+ offset_buff, offset_dtype = buffers["offsets"]
392
+ except TypeError:
393
+ offset_buff = None
394
+
395
+ # Construct a pyarrow Buffer
396
+ data_pa_buffer = pa.foreign_buffer(data_buff.ptr, data_buff.bufsize,
397
+ base=data_buff)
398
+
399
+ # Construct a validity pyarrow Buffer, if applicable
400
+ if validity_buff:
401
+ validity_pa_buff = validity_buffer_from_mask(validity_buff,
402
+ validity_dtype,
403
+ describe_null,
404
+ length,
405
+ offset,
406
+ allow_copy)
407
+ else:
408
+ validity_pa_buff = validity_buffer_nan_sentinel(data_pa_buffer,
409
+ data_type,
410
+ describe_null,
411
+ length,
412
+ offset,
413
+ allow_copy)
414
+
415
+ # Construct a pyarrow Array from buffers
416
+ data_dtype = map_date_type(data_type)
417
+
418
+ if offset_buff:
419
+ _, offset_bit_width, _, _ = offset_dtype
420
+ # If an offset buffer exists, construct an offset pyarrow Buffer
421
+ # and add it to the construction of an array
422
+ offset_pa_buffer = pa.foreign_buffer(offset_buff.ptr,
423
+ offset_buff.bufsize,
424
+ base=offset_buff)
425
+
426
+ if data_type[2] == 'U':
427
+ string_type = pa.large_string()
428
+ else:
429
+ if offset_bit_width == 64:
430
+ string_type = pa.large_string()
431
+ else:
432
+ string_type = pa.string()
433
+ array = pa.Array.from_buffers(
434
+ string_type,
435
+ length,
436
+ [validity_pa_buff, offset_pa_buffer, data_pa_buffer],
437
+ offset=offset,
438
+ )
439
+ else:
440
+ array = pa.Array.from_buffers(
441
+ data_dtype,
442
+ length,
443
+ [validity_pa_buff, data_pa_buffer],
444
+ offset=offset,
445
+ )
446
+
447
+ return array
448
+
449
+
450
+ def validity_buffer_from_mask(
451
+ validity_buff: BufferObject,
452
+ validity_dtype: Dtype,
453
+ describe_null: ColumnNullType,
454
+ length: int,
455
+ offset: int = 0,
456
+ allow_copy: bool = True,
457
+ ) -> pa.Buffer:
458
+ """
459
+ Build a PyArrow buffer from the passed mask buffer.
460
+
461
+ Parameters
462
+ ----------
463
+ validity_buff : BufferObject
464
+ Tuple of underlying validity buffer and associated dtype.
465
+ validity_dtype : Dtype
466
+ Dtype description as a tuple ``(kind, bit-width, format string,
467
+ endianness)``.
468
+ describe_null : ColumnNullType
469
+ Null representation the column dtype uses,
470
+ as a tuple ``(kind, value)``
471
+ length : int
472
+ The number of values in the array.
473
+ offset : int, default: 0
474
+ Number of elements to offset from the start of the buffer.
475
+ allow_copy : bool, default: True
476
+ Whether to allow copying the memory to perform the conversion
477
+ (if false then zero-copy approach is requested).
478
+
479
+ Returns
480
+ -------
481
+ pa.Buffer
482
+ """
483
+ null_kind, sentinel_val = describe_null
484
+ validity_kind, _, _, _ = validity_dtype
485
+ assert validity_kind == DtypeKind.BOOL
486
+
487
+ if null_kind == ColumnNullType.NON_NULLABLE:
488
+ # Sliced array can have a NON_NULLABLE ColumnNullType due
489
+ # to no missing values in that slice of an array though the bitmask
490
+ # exists and validity_buff must be set to None in this case
491
+ return None
492
+
493
+ elif null_kind == ColumnNullType.USE_BYTEMASK or (
494
+ null_kind == ColumnNullType.USE_BITMASK and sentinel_val == 1
495
+ ):
496
+ buff = pa.foreign_buffer(validity_buff.ptr,
497
+ validity_buff.bufsize,
498
+ base=validity_buff)
499
+
500
+ if null_kind == ColumnNullType.USE_BYTEMASK:
501
+ if not allow_copy:
502
+ raise RuntimeError(
503
+ "To create a bitmask a copy of the data is "
504
+ "required which is forbidden by allow_copy=False"
505
+ )
506
+ mask = pa.Array.from_buffers(pa.int8(), length,
507
+ [None, buff],
508
+ offset=offset)
509
+ mask_bool = pc.cast(mask, pa.bool_())
510
+ else:
511
+ mask_bool = pa.Array.from_buffers(pa.bool_(), length,
512
+ [None, buff],
513
+ offset=offset)
514
+
515
+ if sentinel_val == 1:
516
+ mask_bool = pc.invert(mask_bool)
517
+
518
+ return mask_bool.buffers()[1]
519
+
520
+ elif null_kind == ColumnNullType.USE_BITMASK and sentinel_val == 0:
521
+ return pa.foreign_buffer(validity_buff.ptr,
522
+ validity_buff.bufsize,
523
+ base=validity_buff)
524
+ else:
525
+ raise NotImplementedError(
526
+ f"{describe_null} null representation is not yet supported.")
527
+
528
+
529
+ def validity_buffer_nan_sentinel(
530
+ data_pa_buffer: BufferObject,
531
+ data_type: Dtype,
532
+ describe_null: ColumnNullType,
533
+ length: int,
534
+ offset: int = 0,
535
+ allow_copy: bool = True,
536
+ ) -> pa.Buffer:
537
+ """
538
+ Build a PyArrow buffer from NaN or sentinel values.
539
+
540
+ Parameters
541
+ ----------
542
+ data_pa_buffer : pa.Buffer
543
+ PyArrow buffer for the column data.
544
+ data_type : Dtype
545
+ Dtype description as a tuple ``(kind, bit-width, format string,
546
+ endianness)``.
547
+ describe_null : ColumnNullType
548
+ Null representation the column dtype uses,
549
+ as a tuple ``(kind, value)``
550
+ length : int
551
+ The number of values in the array.
552
+ offset : int, default: 0
553
+ Number of elements to offset from the start of the buffer.
554
+ allow_copy : bool, default: True
555
+ Whether to allow copying the memory to perform the conversion
556
+ (if false then zero-copy approach is requested).
557
+
558
+ Returns
559
+ -------
560
+ pa.Buffer
561
+ """
562
+ kind, bit_width, _, _ = data_type
563
+ data_dtype = map_date_type(data_type)
564
+ null_kind, sentinel_val = describe_null
565
+
566
+ # Check for float NaN values
567
+ if null_kind == ColumnNullType.USE_NAN:
568
+ if not allow_copy:
569
+ raise RuntimeError(
570
+ "To create a bitmask a copy of the data is "
571
+ "required which is forbidden by allow_copy=False"
572
+ )
573
+
574
+ if kind == DtypeKind.FLOAT and bit_width == 16:
575
+ # 'pyarrow.compute.is_nan' kernel not yet implemented
576
+ # for float16
577
+ raise NotImplementedError(
578
+ f"{data_type} with {null_kind} is not yet supported.")
579
+ else:
580
+ pyarrow_data = pa.Array.from_buffers(
581
+ data_dtype,
582
+ length,
583
+ [None, data_pa_buffer],
584
+ offset=offset,
585
+ )
586
+ mask = pc.is_nan(pyarrow_data)
587
+ mask = pc.invert(mask)
588
+ return mask.buffers()[1]
589
+
590
+ # Check for sentinel values
591
+ elif null_kind == ColumnNullType.USE_SENTINEL:
592
+ if not allow_copy:
593
+ raise RuntimeError(
594
+ "To create a bitmask a copy of the data is "
595
+ "required which is forbidden by allow_copy=False"
596
+ )
597
+
598
+ if kind == DtypeKind.DATETIME:
599
+ sentinel_dtype = pa.int64()
600
+ else:
601
+ sentinel_dtype = data_dtype
602
+ pyarrow_data = pa.Array.from_buffers(sentinel_dtype,
603
+ length,
604
+ [None, data_pa_buffer],
605
+ offset=offset)
606
+ sentinel_arr = pc.equal(pyarrow_data, sentinel_val)
607
+ mask_bool = pc.invert(sentinel_arr)
608
+ return mask_bool.buffers()[1]
609
+
610
+ elif null_kind == ColumnNullType.NON_NULLABLE:
611
+ pass
612
+ else:
613
+ raise NotImplementedError(
614
+ f"{describe_null} null representation is not yet supported.")
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/parquet/__init__.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # flake8: noqa
19
+
20
+ from .core import *
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/parquet/core.py ADDED
@@ -0,0 +1,2454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
19
+ from collections import defaultdict
20
+ from contextlib import nullcontext
21
+ from functools import reduce
22
+
23
+ import inspect
24
+ import json
25
+ import os
26
+ import re
27
+ import operator
28
+
29
+ import pyarrow as pa
30
+
31
+ try:
32
+ import pyarrow._parquet as _parquet
33
+ except ImportError as exc:
34
+ raise ImportError(
35
+ "The pyarrow installation is not built with support "
36
+ f"for the Parquet file format ({str(exc)})"
37
+ ) from None
38
+
39
+ from pyarrow._parquet import (ParquetReader, Statistics, # noqa
40
+ FileMetaData, RowGroupMetaData,
41
+ ColumnChunkMetaData,
42
+ ParquetSchema, ColumnSchema,
43
+ ParquetLogicalType,
44
+ FileEncryptionProperties,
45
+ FileDecryptionProperties,
46
+ SortingColumn)
47
+ from pyarrow.fs import (LocalFileSystem, FileType, _resolve_filesystem_and_path,
48
+ _ensure_filesystem)
49
+ from pyarrow.util import guid, _is_path_like, _stringify_path, _deprecate_api
50
+
51
+
52
+ def _check_contains_null(val):
53
+ if isinstance(val, bytes):
54
+ for byte in val:
55
+ if isinstance(byte, bytes):
56
+ compare_to = chr(0)
57
+ else:
58
+ compare_to = 0
59
+ if byte == compare_to:
60
+ return True
61
+ elif isinstance(val, str):
62
+ return '\x00' in val
63
+ return False
64
+
65
+
66
+ def _check_filters(filters, check_null_strings=True):
67
+ """
68
+ Check if filters are well-formed.
69
+ """
70
+ if filters is not None:
71
+ if len(filters) == 0 or any(len(f) == 0 for f in filters):
72
+ raise ValueError("Malformed filters")
73
+ if isinstance(filters[0][0], str):
74
+ # We have encountered the situation where we have one nesting level
75
+ # too few:
76
+ # We have [(,,), ..] instead of [[(,,), ..]]
77
+ filters = [filters]
78
+ if check_null_strings:
79
+ for conjunction in filters:
80
+ for col, op, val in conjunction:
81
+ if (
82
+ isinstance(val, list) and
83
+ all(_check_contains_null(v) for v in val) or
84
+ _check_contains_null(val)
85
+ ):
86
+ raise NotImplementedError(
87
+ "Null-terminated binary strings are not supported "
88
+ "as filter values."
89
+ )
90
+ return filters
91
+
92
+
93
+ _DNF_filter_doc = """Predicates are expressed using an ``Expression`` or using
94
+ the disjunctive normal form (DNF), like ``[[('x', '=', 0), ...], ...]``.
95
+ DNF allows arbitrary boolean logical combinations of single column predicates.
96
+ The innermost tuples each describe a single column predicate. The list of inner
97
+ predicates is interpreted as a conjunction (AND), forming a more selective and
98
+ multiple column predicate. Finally, the most outer list combines these filters
99
+ as a disjunction (OR).
100
+
101
+ Predicates may also be passed as List[Tuple]. This form is interpreted
102
+ as a single conjunction. To express OR in predicates, one must
103
+ use the (preferred) List[List[Tuple]] notation.
104
+
105
+ Each tuple has format: (``key``, ``op``, ``value``) and compares the
106
+ ``key`` with the ``value``.
107
+ The supported ``op`` are: ``=`` or ``==``, ``!=``, ``<``, ``>``, ``<=``,
108
+ ``>=``, ``in`` and ``not in``. If the ``op`` is ``in`` or ``not in``, the
109
+ ``value`` must be a collection such as a ``list``, a ``set`` or a
110
+ ``tuple``.
111
+
112
+ Examples:
113
+
114
+ Using the ``Expression`` API:
115
+
116
+ .. code-block:: python
117
+
118
+ import pyarrow.compute as pc
119
+ pc.field('x') = 0
120
+ pc.field('y').isin(['a', 'b', 'c'])
121
+ ~pc.field('y').isin({'a', 'b'})
122
+
123
+ Using the DNF format:
124
+
125
+ .. code-block:: python
126
+
127
+ ('x', '=', 0)
128
+ ('y', 'in', ['a', 'b', 'c'])
129
+ ('z', 'not in', {'a','b'})
130
+
131
+ """
132
+
133
+
134
+ def filters_to_expression(filters):
135
+ """
136
+ Check if filters are well-formed and convert to an ``Expression``.
137
+
138
+ Parameters
139
+ ----------
140
+ filters : List[Tuple] or List[List[Tuple]]
141
+
142
+ Notes
143
+ -----
144
+ See internal ``pyarrow._DNF_filter_doc`` attribute for more details.
145
+
146
+ Examples
147
+ --------
148
+
149
+ >>> filters_to_expression([('foo', '==', 'bar')])
150
+ <pyarrow.compute.Expression (foo == "bar")>
151
+
152
+ Returns
153
+ -------
154
+ pyarrow.compute.Expression
155
+ An Expression representing the filters
156
+ """
157
+ import pyarrow.dataset as ds
158
+
159
+ if isinstance(filters, ds.Expression):
160
+ return filters
161
+
162
+ filters = _check_filters(filters, check_null_strings=False)
163
+
164
+ def convert_single_predicate(col, op, val):
165
+ field = ds.field(col)
166
+
167
+ if op == "=" or op == "==":
168
+ return field == val
169
+ elif op == "!=":
170
+ return field != val
171
+ elif op == '<':
172
+ return field < val
173
+ elif op == '>':
174
+ return field > val
175
+ elif op == '<=':
176
+ return field <= val
177
+ elif op == '>=':
178
+ return field >= val
179
+ elif op == 'in':
180
+ return field.isin(val)
181
+ elif op == 'not in':
182
+ return ~field.isin(val)
183
+ else:
184
+ raise ValueError(f'"{col}" is not a valid operator in predicates.')
185
+
186
+ disjunction_members = []
187
+
188
+ for conjunction in filters:
189
+ conjunction_members = [
190
+ convert_single_predicate(col, op, val)
191
+ for col, op, val in conjunction
192
+ ]
193
+
194
+ disjunction_members.append(reduce(operator.and_, conjunction_members))
195
+
196
+ return reduce(operator.or_, disjunction_members)
197
+
198
+
199
+ _filters_to_expression = _deprecate_api(
200
+ "_filters_to_expression", "filters_to_expression",
201
+ filters_to_expression, "10.0.0", DeprecationWarning)
202
+
203
+
204
+ # ----------------------------------------------------------------------
205
+ # Reading a single Parquet file
206
+
207
+
208
+ class ParquetFile:
209
+ """
210
+ Reader interface for a single Parquet file.
211
+
212
+ Parameters
213
+ ----------
214
+ source : str, pathlib.Path, pyarrow.NativeFile, or file-like object
215
+ Readable source. For passing bytes or buffer-like file containing a
216
+ Parquet file, use pyarrow.BufferReader.
217
+ metadata : FileMetaData, default None
218
+ Use existing metadata object, rather than reading from file.
219
+ common_metadata : FileMetaData, default None
220
+ Will be used in reads for pandas schema metadata if not found in the
221
+ main file's metadata, no other uses at the moment.
222
+ read_dictionary : list
223
+ List of column names to read directly as DictionaryArray.
224
+ binary_type : pyarrow.DataType, default None
225
+ If given, Parquet binary columns will be read as this datatype.
226
+ This setting is ignored if a serialized Arrow schema is found in
227
+ the Parquet metadata.
228
+ list_type : subclass of pyarrow.DataType, default None
229
+ If given, non-MAP repeated columns will be read as an instance of
230
+ this datatype (either pyarrow.ListType or pyarrow.LargeListType).
231
+ This setting is ignored if a serialized Arrow schema is found in
232
+ the Parquet metadata.
233
+ memory_map : bool, default False
234
+ If the source is a file path, use a memory map to read file, which can
235
+ improve performance in some environments.
236
+ buffer_size : int, default 0
237
+ If positive, perform read buffering when deserializing individual
238
+ column chunks. Otherwise IO calls are unbuffered.
239
+ pre_buffer : bool, default False
240
+ Coalesce and issue file reads in parallel to improve performance on
241
+ high-latency filesystems (e.g. S3). If True, Arrow will use a
242
+ background I/O thread pool.
243
+ coerce_int96_timestamp_unit : str, default None
244
+ Cast timestamps that are stored in INT96 format to a particular
245
+ resolution (e.g. 'ms'). Setting to None is equivalent to 'ns'
246
+ and therefore INT96 timestamps will be inferred as timestamps
247
+ in nanoseconds.
248
+ decryption_properties : FileDecryptionProperties, default None
249
+ File decryption properties for Parquet Modular Encryption.
250
+ thrift_string_size_limit : int, default None
251
+ If not None, override the maximum total string size allocated
252
+ when decoding Thrift structures. The default limit should be
253
+ sufficient for most Parquet files.
254
+ thrift_container_size_limit : int, default None
255
+ If not None, override the maximum total size of containers allocated
256
+ when decoding Thrift structures. The default limit should be
257
+ sufficient for most Parquet files.
258
+ filesystem : FileSystem, default None
259
+ If nothing passed, will be inferred based on path.
260
+ Path will try to be found in the local on-disk filesystem otherwise
261
+ it will be parsed as an URI to determine the filesystem.
262
+ page_checksum_verification : bool, default False
263
+ If True, verify the checksum for each page read from the file.
264
+ arrow_extensions_enabled : bool, default True
265
+ If True, read Parquet logical types as Arrow extension types where possible,
266
+ (e.g., read JSON as the canonical `arrow.json` extension type or UUID as
267
+ the canonical `arrow.uuid` extension type).
268
+
269
+ Examples
270
+ --------
271
+
272
+ Generate an example PyArrow Table and write it to Parquet file:
273
+
274
+ >>> import pyarrow as pa
275
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
276
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
277
+ ... "Brittle stars", "Centipede"]})
278
+
279
+ >>> import pyarrow.parquet as pq
280
+ >>> pq.write_table(table, 'example.parquet')
281
+
282
+ Create a ``ParquetFile`` object from the Parquet file:
283
+
284
+ >>> parquet_file = pq.ParquetFile('example.parquet')
285
+
286
+ Read the data:
287
+
288
+ >>> parquet_file.read()
289
+ pyarrow.Table
290
+ n_legs: int64
291
+ animal: string
292
+ ----
293
+ n_legs: [[2,2,4,4,5,100]]
294
+ animal: [["Flamingo","Parrot","Dog","Horse","Brittle stars","Centipede"]]
295
+
296
+ Create a ParquetFile object with "animal" column as DictionaryArray:
297
+
298
+ >>> parquet_file = pq.ParquetFile('example.parquet',
299
+ ... read_dictionary=["animal"])
300
+ >>> parquet_file.read()
301
+ pyarrow.Table
302
+ n_legs: int64
303
+ animal: dictionary<values=string, indices=int32, ordered=0>
304
+ ----
305
+ n_legs: [[2,2,4,4,5,100]]
306
+ animal: [ -- dictionary:
307
+ ["Flamingo","Parrot",...,"Brittle stars","Centipede"] -- indices:
308
+ [0,1,2,3,4,5]]
309
+ """
310
+
311
+ def __init__(self, source, *, metadata=None, common_metadata=None,
312
+ read_dictionary=None, binary_type=None, list_type=None,
313
+ memory_map=False, buffer_size=0, pre_buffer=False,
314
+ coerce_int96_timestamp_unit=None,
315
+ decryption_properties=None, thrift_string_size_limit=None,
316
+ thrift_container_size_limit=None, filesystem=None,
317
+ page_checksum_verification=False, arrow_extensions_enabled=True):
318
+
319
+ self._close_source = getattr(source, 'closed', True)
320
+
321
+ filesystem, source = _resolve_filesystem_and_path(
322
+ source, filesystem, memory_map=memory_map)
323
+ if filesystem is not None:
324
+ source = filesystem.open_input_file(source)
325
+ self._close_source = True # We opened it here, ensure we close it.
326
+
327
+ self.reader = ParquetReader()
328
+ self.reader.open(
329
+ source, use_memory_map=memory_map,
330
+ buffer_size=buffer_size, pre_buffer=pre_buffer,
331
+ read_dictionary=read_dictionary, metadata=metadata,
332
+ binary_type=binary_type, list_type=list_type,
333
+ coerce_int96_timestamp_unit=coerce_int96_timestamp_unit,
334
+ decryption_properties=decryption_properties,
335
+ thrift_string_size_limit=thrift_string_size_limit,
336
+ thrift_container_size_limit=thrift_container_size_limit,
337
+ page_checksum_verification=page_checksum_verification,
338
+ arrow_extensions_enabled=arrow_extensions_enabled,
339
+ )
340
+ self.common_metadata = common_metadata
341
+ self._nested_paths_by_prefix = self._build_nested_paths()
342
+
343
+ def __enter__(self):
344
+ return self
345
+
346
+ def __exit__(self, *args, **kwargs):
347
+ self.close()
348
+
349
+ def _build_nested_paths(self):
350
+ paths = self.reader.column_paths
351
+
352
+ result = defaultdict(list)
353
+
354
+ for i, path in enumerate(paths):
355
+ key = path[0]
356
+ rest = path[1:]
357
+ while True:
358
+ result[key].append(i)
359
+
360
+ if not rest:
361
+ break
362
+
363
+ key = '.'.join((key, rest[0]))
364
+ rest = rest[1:]
365
+
366
+ return result
367
+
368
+ @property
369
+ def metadata(self):
370
+ """
371
+ Return the Parquet metadata.
372
+ """
373
+ return self.reader.metadata
374
+
375
+ @property
376
+ def schema(self):
377
+ """
378
+ Return the Parquet schema, unconverted to Arrow types
379
+ """
380
+ return self.metadata.schema
381
+
382
+ @property
383
+ def schema_arrow(self):
384
+ """
385
+ Return the inferred Arrow schema, converted from the whole Parquet
386
+ file's schema
387
+
388
+ Examples
389
+ --------
390
+ Generate an example Parquet file:
391
+
392
+ >>> import pyarrow as pa
393
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
394
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
395
+ ... "Brittle stars", "Centipede"]})
396
+ >>> import pyarrow.parquet as pq
397
+ >>> pq.write_table(table, 'example.parquet')
398
+ >>> parquet_file = pq.ParquetFile('example.parquet')
399
+
400
+ Read the Arrow schema:
401
+
402
+ >>> parquet_file.schema_arrow
403
+ n_legs: int64
404
+ animal: string
405
+ """
406
+ return self.reader.schema_arrow
407
+
408
+ @property
409
+ def num_row_groups(self):
410
+ """
411
+ Return the number of row groups of the Parquet file.
412
+
413
+ Examples
414
+ --------
415
+ >>> import pyarrow as pa
416
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
417
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
418
+ ... "Brittle stars", "Centipede"]})
419
+ >>> import pyarrow.parquet as pq
420
+ >>> pq.write_table(table, 'example.parquet')
421
+ >>> parquet_file = pq.ParquetFile('example.parquet')
422
+
423
+ >>> parquet_file.num_row_groups
424
+ 1
425
+ """
426
+ return self.reader.num_row_groups
427
+
428
+ def close(self, force: bool = False):
429
+ if self._close_source or force:
430
+ self.reader.close()
431
+
432
+ @property
433
+ def closed(self) -> bool:
434
+ return self.reader.closed
435
+
436
+ def read_row_group(self, i, columns=None, use_threads=True,
437
+ use_pandas_metadata=False):
438
+ """
439
+ Read a single row group from a Parquet file.
440
+
441
+ Parameters
442
+ ----------
443
+ i : int
444
+ Index of the individual row group that we want to read.
445
+ columns : list
446
+ If not None, only these columns will be read from the row group. A
447
+ column name may be a prefix of a nested field, e.g. 'a' will select
448
+ 'a.b', 'a.c', and 'a.d.e'.
449
+ use_threads : bool, default True
450
+ Perform multi-threaded column reads.
451
+ use_pandas_metadata : bool, default False
452
+ If True and file has custom pandas schema metadata, ensure that
453
+ index columns are also loaded.
454
+
455
+ Returns
456
+ -------
457
+ pyarrow.table.Table
458
+ Content of the row group as a table (of columns)
459
+
460
+ Examples
461
+ --------
462
+ >>> import pyarrow as pa
463
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
464
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
465
+ ... "Brittle stars", "Centipede"]})
466
+ >>> import pyarrow.parquet as pq
467
+ >>> pq.write_table(table, 'example.parquet')
468
+ >>> parquet_file = pq.ParquetFile('example.parquet')
469
+
470
+ >>> parquet_file.read_row_group(0)
471
+ pyarrow.Table
472
+ n_legs: int64
473
+ animal: string
474
+ ----
475
+ n_legs: [[2,2,4,4,5,100]]
476
+ animal: [["Flamingo","Parrot",...,"Brittle stars","Centipede"]]
477
+ """
478
+ column_indices = self._get_column_indices(
479
+ columns, use_pandas_metadata=use_pandas_metadata)
480
+ return self.reader.read_row_group(i, column_indices=column_indices,
481
+ use_threads=use_threads)
482
+
483
+ def read_row_groups(self, row_groups, columns=None, use_threads=True,
484
+ use_pandas_metadata=False):
485
+ """
486
+ Read a multiple row groups from a Parquet file.
487
+
488
+ Parameters
489
+ ----------
490
+ row_groups : list
491
+ Only these row groups will be read from the file.
492
+ columns : list
493
+ If not None, only these columns will be read from the row group. A
494
+ column name may be a prefix of a nested field, e.g. 'a' will select
495
+ 'a.b', 'a.c', and 'a.d.e'.
496
+ use_threads : bool, default True
497
+ Perform multi-threaded column reads.
498
+ use_pandas_metadata : bool, default False
499
+ If True and file has custom pandas schema metadata, ensure that
500
+ index columns are also loaded.
501
+
502
+ Returns
503
+ -------
504
+ pyarrow.table.Table
505
+ Content of the row groups as a table (of columns).
506
+
507
+ Examples
508
+ --------
509
+ >>> import pyarrow as pa
510
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
511
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
512
+ ... "Brittle stars", "Centipede"]})
513
+ >>> import pyarrow.parquet as pq
514
+ >>> pq.write_table(table, 'example.parquet')
515
+ >>> parquet_file = pq.ParquetFile('example.parquet')
516
+
517
+ >>> parquet_file.read_row_groups([0,0])
518
+ pyarrow.Table
519
+ n_legs: int64
520
+ animal: string
521
+ ----
522
+ n_legs: [[2,2,4,4,5,...,2,4,4,5,100]]
523
+ animal: [["Flamingo","Parrot","Dog",...,"Brittle stars","Centipede"]]
524
+ """
525
+ column_indices = self._get_column_indices(
526
+ columns, use_pandas_metadata=use_pandas_metadata)
527
+ return self.reader.read_row_groups(row_groups,
528
+ column_indices=column_indices,
529
+ use_threads=use_threads)
530
+
531
+ def iter_batches(self, batch_size=65536, row_groups=None, columns=None,
532
+ use_threads=True, use_pandas_metadata=False):
533
+ """
534
+ Read streaming batches from a Parquet file.
535
+
536
+ Parameters
537
+ ----------
538
+ batch_size : int, default 64K
539
+ Maximum number of records to yield per batch. Batches may be
540
+ smaller if there aren't enough rows in the file.
541
+ row_groups : list
542
+ Only these row groups will be read from the file.
543
+ columns : list
544
+ If not None, only these columns will be read from the file. A
545
+ column name may be a prefix of a nested field, e.g. 'a' will select
546
+ 'a.b', 'a.c', and 'a.d.e'.
547
+ use_threads : boolean, default True
548
+ Perform multi-threaded column reads.
549
+ use_pandas_metadata : boolean, default False
550
+ If True and file has custom pandas schema metadata, ensure that
551
+ index columns are also loaded.
552
+
553
+ Yields
554
+ ------
555
+ pyarrow.RecordBatch
556
+ Contents of each batch as a record batch
557
+
558
+ Examples
559
+ --------
560
+ Generate an example Parquet file:
561
+
562
+ >>> import pyarrow as pa
563
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
564
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
565
+ ... "Brittle stars", "Centipede"]})
566
+ >>> import pyarrow.parquet as pq
567
+ >>> pq.write_table(table, 'example.parquet')
568
+ >>> parquet_file = pq.ParquetFile('example.parquet')
569
+ >>> for i in parquet_file.iter_batches():
570
+ ... print("RecordBatch")
571
+ ... print(i.to_pandas())
572
+ ...
573
+ RecordBatch
574
+ n_legs animal
575
+ 0 2 Flamingo
576
+ 1 2 Parrot
577
+ 2 4 Dog
578
+ 3 4 Horse
579
+ 4 5 Brittle stars
580
+ 5 100 Centipede
581
+ """
582
+ if batch_size <= 0:
583
+ raise ValueError("batch_size must be greater than zero")
584
+
585
+ if row_groups is None:
586
+ row_groups = range(0, self.metadata.num_row_groups)
587
+ column_indices = self._get_column_indices(
588
+ columns, use_pandas_metadata=use_pandas_metadata)
589
+
590
+ batches = self.reader.iter_batches(batch_size,
591
+ row_groups=row_groups,
592
+ column_indices=column_indices,
593
+ use_threads=use_threads)
594
+ return batches
595
+
596
+ def read(self, columns=None, use_threads=True, use_pandas_metadata=False):
597
+ """
598
+ Read a Table from Parquet format.
599
+
600
+ Parameters
601
+ ----------
602
+ columns : list
603
+ If not None, only these columns will be read from the file. A
604
+ column name may be a prefix of a nested field, e.g. 'a' will select
605
+ 'a.b', 'a.c', and 'a.d.e'.
606
+ use_threads : bool, default True
607
+ Perform multi-threaded column reads.
608
+ use_pandas_metadata : bool, default False
609
+ If True and file has custom pandas schema metadata, ensure that
610
+ index columns are also loaded.
611
+
612
+ Returns
613
+ -------
614
+ pyarrow.table.Table
615
+ Content of the file as a table (of columns).
616
+
617
+ Examples
618
+ --------
619
+ Generate an example Parquet file:
620
+
621
+ >>> import pyarrow as pa
622
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
623
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
624
+ ... "Brittle stars", "Centipede"]})
625
+ >>> import pyarrow.parquet as pq
626
+ >>> pq.write_table(table, 'example.parquet')
627
+ >>> parquet_file = pq.ParquetFile('example.parquet')
628
+
629
+ Read a Table:
630
+
631
+ >>> parquet_file.read(columns=["animal"])
632
+ pyarrow.Table
633
+ animal: string
634
+ ----
635
+ animal: [["Flamingo","Parrot",...,"Brittle stars","Centipede"]]
636
+ """
637
+ column_indices = self._get_column_indices(
638
+ columns, use_pandas_metadata=use_pandas_metadata)
639
+ return self.reader.read_all(column_indices=column_indices,
640
+ use_threads=use_threads)
641
+
642
+ def scan_contents(self, columns=None, batch_size=65536):
643
+ """
644
+ Read contents of file for the given columns and batch size.
645
+
646
+ Notes
647
+ -----
648
+ This function's primary purpose is benchmarking.
649
+ The scan is executed on a single thread.
650
+
651
+ Parameters
652
+ ----------
653
+ columns : list of integers, default None
654
+ Select columns to read, if None scan all columns.
655
+ batch_size : int, default 64K
656
+ Number of rows to read at a time internally.
657
+
658
+ Returns
659
+ -------
660
+ num_rows : int
661
+ Number of rows in file
662
+
663
+ Examples
664
+ --------
665
+ >>> import pyarrow as pa
666
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
667
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
668
+ ... "Brittle stars", "Centipede"]})
669
+ >>> import pyarrow.parquet as pq
670
+ >>> pq.write_table(table, 'example.parquet')
671
+ >>> parquet_file = pq.ParquetFile('example.parquet')
672
+
673
+ >>> parquet_file.scan_contents()
674
+ 6
675
+ """
676
+ column_indices = self._get_column_indices(columns)
677
+ return self.reader.scan_contents(column_indices,
678
+ batch_size=batch_size)
679
+
680
+ def _get_column_indices(self, column_names, use_pandas_metadata=False):
681
+ if column_names is None:
682
+ return None
683
+
684
+ indices = []
685
+
686
+ for name in column_names:
687
+ if name in self._nested_paths_by_prefix:
688
+ indices.extend(self._nested_paths_by_prefix[name])
689
+
690
+ if use_pandas_metadata:
691
+ file_keyvalues = self.metadata.metadata
692
+ common_keyvalues = (self.common_metadata.metadata
693
+ if self.common_metadata is not None
694
+ else None)
695
+
696
+ if file_keyvalues and b'pandas' in file_keyvalues:
697
+ index_columns = _get_pandas_index_columns(file_keyvalues)
698
+ elif common_keyvalues and b'pandas' in common_keyvalues:
699
+ index_columns = _get_pandas_index_columns(common_keyvalues)
700
+ else:
701
+ index_columns = []
702
+
703
+ if indices is not None and index_columns:
704
+ indices += [self.reader.column_name_idx(descr)
705
+ for descr in index_columns
706
+ if not isinstance(descr, dict)]
707
+
708
+ return indices
709
+
710
+
711
+ _SPARK_DISALLOWED_CHARS = re.compile('[ ,;{}()\n\t=]')
712
+
713
+
714
+ def _sanitized_spark_field_name(name):
715
+ return _SPARK_DISALLOWED_CHARS.sub('_', name)
716
+
717
+
718
+ def _sanitize_schema(schema, flavor):
719
+ if 'spark' in flavor:
720
+ sanitized_fields = []
721
+
722
+ schema_changed = False
723
+
724
+ for field in schema:
725
+ name = field.name
726
+ sanitized_name = _sanitized_spark_field_name(name)
727
+
728
+ if sanitized_name != name:
729
+ schema_changed = True
730
+ sanitized_field = pa.field(sanitized_name, field.type,
731
+ field.nullable, field.metadata)
732
+ sanitized_fields.append(sanitized_field)
733
+ else:
734
+ sanitized_fields.append(field)
735
+
736
+ new_schema = pa.schema(sanitized_fields, metadata=schema.metadata)
737
+ return new_schema, schema_changed
738
+ else:
739
+ return schema, False
740
+
741
+
742
+ def _sanitize_table(table, new_schema, flavor):
743
+ # TODO: This will not handle prohibited characters in nested field names
744
+ if 'spark' in flavor:
745
+ column_data = [table[i] for i in range(table.num_columns)]
746
+ return pa.Table.from_arrays(column_data, schema=new_schema)
747
+ else:
748
+ return table
749
+
750
+
751
+ _parquet_writer_arg_docs = """version : {"1.0", "2.4", "2.6"}, default "2.6"
752
+ Determine which Parquet logical types are available for use, whether the
753
+ reduced set from the Parquet 1.x.x format or the expanded logical types
754
+ added in later format versions.
755
+ Files written with version='2.4' or '2.6' may not be readable in all
756
+ Parquet implementations, so version='1.0' is likely the choice that
757
+ maximizes file compatibility.
758
+ UINT32 and some logical types are only available with version '2.4'.
759
+ Nanosecond timestamps are only available with version '2.6'.
760
+ Other features such as compression algorithms or the new serialized
761
+ data page format must be enabled separately (see 'compression' and
762
+ 'data_page_version').
763
+ use_dictionary : bool or list, default True
764
+ Specify if we should use dictionary encoding in general or only for
765
+ some columns.
766
+ When encoding the column, if the dictionary size is too large, the
767
+ column will fallback to ``PLAIN`` encoding. Specially, ``BOOLEAN`` type
768
+ doesn't support dictionary encoding.
769
+ compression : str or dict, default 'snappy'
770
+ Specify the compression codec, either on a general basis or per-column.
771
+ Valid values: {'NONE', 'SNAPPY', 'GZIP', 'BROTLI', 'LZ4', 'ZSTD'}.
772
+ write_statistics : bool or list, default True
773
+ Specify if we should write statistics in general (default is True) or only
774
+ for some columns.
775
+ use_deprecated_int96_timestamps : bool, default None
776
+ Write timestamps to INT96 Parquet format. Defaults to False unless enabled
777
+ by flavor argument. This take priority over the coerce_timestamps option.
778
+ coerce_timestamps : str, default None
779
+ Cast timestamps to a particular resolution. If omitted, defaults are chosen
780
+ depending on `version`. For ``version='1.0'`` and ``version='2.4'``,
781
+ nanoseconds are cast to microseconds ('us'), while for
782
+ ``version='2.6'`` (the default), they are written natively without loss
783
+ of resolution. Seconds are always cast to milliseconds ('ms') by default,
784
+ as Parquet does not have any temporal type with seconds resolution.
785
+ If the casting results in loss of data, it will raise an exception
786
+ unless ``allow_truncated_timestamps=True`` is given.
787
+ Valid values: {None, 'ms', 'us'}
788
+ allow_truncated_timestamps : bool, default False
789
+ Allow loss of data when coercing timestamps to a particular
790
+ resolution. E.g. if microsecond or nanosecond data is lost when coercing to
791
+ 'ms', do not raise an exception. Passing ``allow_truncated_timestamp=True``
792
+ will NOT result in the truncation exception being ignored unless
793
+ ``coerce_timestamps`` is not None.
794
+ data_page_size : int, default None
795
+ Set a target threshold for the approximate encoded size of data
796
+ pages within a column chunk (in bytes). If None, use the default data page
797
+ size of 1MByte.
798
+ max_rows_per_page : int, default None
799
+ Maximum number of rows per page within a column chunk.
800
+ If None, use the default of 20000.
801
+ Smaller values reduce memory usage during reads but increase metadata overhead.
802
+ flavor : {'spark'}, default None
803
+ Sanitize schema or set other compatibility options to work with
804
+ various target systems.
805
+ filesystem : FileSystem, default None
806
+ If nothing passed, will be inferred from `where` if path-like, else
807
+ `where` is already a file-like object so no filesystem is needed.
808
+ compression_level : int or dict, default None
809
+ Specify the compression level for a codec, either on a general basis or
810
+ per-column. If None is passed, arrow selects the compression level for
811
+ the compression codec in use. The compression level has a different
812
+ meaning for each codec, so you have to read the documentation of the
813
+ codec you are using.
814
+ An exception is thrown if the compression codec does not allow specifying
815
+ a compression level.
816
+ use_byte_stream_split : bool or list, default False
817
+ Specify if the byte_stream_split encoding should be used in general or
818
+ only for some columns. If both dictionary and byte_stream_stream are
819
+ enabled, then dictionary is preferred.
820
+ The byte_stream_split encoding is valid for integer, floating-point
821
+ and fixed-size binary data types (including decimals); it should be
822
+ combined with a compression codec so as to achieve size reduction.
823
+ column_encoding : string or dict, default None
824
+ Specify the encoding scheme on a per column basis.
825
+ Can only be used when ``use_dictionary`` is set to False, and
826
+ cannot be used in combination with ``use_byte_stream_split``.
827
+ Currently supported values: {'PLAIN', 'BYTE_STREAM_SPLIT',
828
+ 'DELTA_BINARY_PACKED', 'DELTA_LENGTH_BYTE_ARRAY', 'DELTA_BYTE_ARRAY'}.
829
+ Certain encodings are only compatible with certain data types.
830
+ Please refer to the encodings section of `Reading and writing Parquet
831
+ files <https://arrow.apache.org/docs/cpp/parquet.html#encodings>`_.
832
+ data_page_version : {"1.0", "2.0"}, default "1.0"
833
+ The serialized Parquet data page format version to write, defaults to
834
+ 1.0. This does not impact the file schema logical types and Arrow to
835
+ Parquet type casting behavior; for that use the "version" option.
836
+ use_compliant_nested_type : bool, default True
837
+ Whether to write compliant Parquet nested type (lists) as defined
838
+ `here <https://github.com/apache/parquet-format/blob/master/
839
+ LogicalTypes.md#nested-types>`_, defaults to ``True``.
840
+ For ``use_compliant_nested_type=True``, this will write into a list
841
+ with 3-level structure where the middle level, named ``list``,
842
+ is a repeated group with a single field named ``element``::
843
+
844
+ <list-repetition> group <name> (LIST) {
845
+ repeated group list {
846
+ <element-repetition> <element-type> element;
847
+ }
848
+ }
849
+
850
+ For ``use_compliant_nested_type=False``, this will also write into a list
851
+ with 3-level structure, where the name of the single field of the middle
852
+ level ``list`` is taken from the element name for nested columns in Arrow,
853
+ which defaults to ``item``::
854
+
855
+ <list-repetition> group <name> (LIST) {
856
+ repeated group list {
857
+ <element-repetition> <element-type> item;
858
+ }
859
+ }
860
+ encryption_properties : FileEncryptionProperties, default None
861
+ File encryption properties for Parquet Modular Encryption.
862
+ If None, no encryption will be done.
863
+ The encryption properties can be created using:
864
+ ``CryptoFactory.file_encryption_properties()``.
865
+ write_batch_size : int, default None
866
+ Number of values to write to a page at a time. If None, use the default of
867
+ 1024. ``write_batch_size`` is complementary to ``data_page_size``. If pages
868
+ are exceeding the ``data_page_size`` due to large column values, lowering
869
+ the batch size can help keep page sizes closer to the intended size.
870
+ dictionary_pagesize_limit : int, default None
871
+ Specify the dictionary page size limit per row group. If None, use the
872
+ default 1MB.
873
+ store_schema : bool, default True
874
+ By default, the Arrow schema is serialized and stored in the Parquet
875
+ file metadata (in the "ARROW:schema" key). When reading the file,
876
+ if this key is available, it will be used to more faithfully recreate
877
+ the original Arrow data. For example, for tz-aware timestamp columns
878
+ it will restore the timezone (Parquet only stores the UTC values without
879
+ timezone), or columns with duration type will be restored from the int64
880
+ Parquet column.
881
+ write_page_index : bool, default False
882
+ Whether to write a page index in general for all columns.
883
+ Writing statistics to the page index disables the old method of writing
884
+ statistics to each data page header. The page index makes statistics-based
885
+ filtering more efficient than the page header, as it gathers all the
886
+ statistics for a Parquet file in a single place, avoiding scattered I/O.
887
+ Note that the page index is not yet used on the read size by PyArrow.
888
+ write_page_checksum : bool, default False
889
+ Whether to write page checksums in general for all columns.
890
+ Page checksums enable detection of data corruption, which might occur during
891
+ transmission or in the storage.
892
+ sorting_columns : Sequence of SortingColumn, default None
893
+ Specify the sort order of the data being written. The writer does not sort
894
+ the data nor does it verify that the data is sorted. The sort order is
895
+ written to the row group metadata, which can then be used by readers.
896
+ store_decimal_as_integer : bool, default False
897
+ Allow decimals with 1 <= precision <= 18 to be stored as integers.
898
+ In Parquet, DECIMAL can be stored in any of the following physical types:
899
+ - int32: for 1 <= precision <= 9.
900
+ - int64: for 10 <= precision <= 18.
901
+ - fixed_len_byte_array: precision is limited by the array size.
902
+ Length n can store <= floor(log_10(2^(8*n - 1) - 1)) base-10 digits.
903
+ - binary: precision is unlimited. The minimum number of bytes to store the
904
+ unscaled value is used.
905
+
906
+ By default, this is DISABLED and all decimal types annotate fixed_len_byte_array.
907
+ When enabled, the writer will use the following physical types to store decimals:
908
+ - int32: for 1 <= precision <= 9.
909
+ - int64: for 10 <= precision <= 18.
910
+ - fixed_len_byte_array: for precision > 18.
911
+
912
+ As a consequence, decimal columns stored in integer types are more compact.
913
+ use_content_defined_chunking : bool or dict, default False
914
+ Optimize parquet files for content addressable storage (CAS) systems by writing
915
+ data pages according to content-defined chunk boundaries. This allows for more
916
+ efficient deduplication of data across files, hence more efficient network
917
+ transfers and storage. The chunking is based on a rolling hash algorithm that
918
+ identifies chunk boundaries based on the actual content of the data.
919
+
920
+ Note that it is an experimental feature and the API may change in the future.
921
+
922
+ If set to ``True``, a default configuration is used with `min_chunk_size=256 KiB`
923
+ and `max_chunk_size=1024 KiB`. The chunk size distribution approximates a normal
924
+ distribution between `min_chunk_size` and `max_chunk_size` (sizes are accounted
925
+ before any Parquet encodings).
926
+
927
+ A `dict` can be passed to adjust the chunker parameters with the following keys:
928
+ - `min_chunk_size`: minimum chunk size in bytes, default 256 KiB
929
+ The rolling hash will not be updated until this size is reached for each chunk.
930
+ Note that all data sent through the hash function is counted towards the chunk
931
+ size, including definition and repetition levels if present.
932
+ - `max_chunk_size`: maximum chunk size in bytes, default is 1024 KiB
933
+ The chunker will create a new chunk whenever the chunk size exceeds this value.
934
+ Note that the parquet writer has a related `data_pagesize` property that controls
935
+ the maximum size of a parquet data page after encoding. While setting
936
+ `data_page_size` to a smaller value than `max_chunk_size` doesn't affect the
937
+ chunking effectiveness, it results in more small parquet data pages.
938
+ - `norm_level`: normalization level to center the chunk size around the average
939
+ size more aggressively, default 0
940
+ Increasing the normalization level increases the probability of finding a chunk,
941
+ improving the deduplication ratio, but also increasing the number of small chunks
942
+ resulting in many small parquet data pages. The default value provides a good
943
+ balance between deduplication ratio and fragmentation. Use norm_level=1 or
944
+ norm_level=2 to reach a higher deduplication ratio at the expense of
945
+ fragmentation.
946
+ write_time_adjusted_to_utc : bool, default False
947
+ Set the value of isAdjustedTOUTC when writing a TIME column.
948
+ If True, this tells the Parquet reader that the TIME columns
949
+ are expressed in reference to midnight in the UTC timezone.
950
+ If False (the default), the TIME columns are assumed to be expressed
951
+ in reference to midnight in an unknown, presumably local, timezone.
952
+ """
953
+
954
+ _parquet_writer_example_doc = """\
955
+ Generate an example PyArrow Table and RecordBatch:
956
+
957
+ >>> import pyarrow as pa
958
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
959
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
960
+ ... "Brittle stars", "Centipede"]})
961
+ >>> batch = pa.record_batch([[2, 2, 4, 4, 5, 100],
962
+ ... ["Flamingo", "Parrot", "Dog", "Horse",
963
+ ... "Brittle stars", "Centipede"]],
964
+ ... names=['n_legs', 'animal'])
965
+
966
+ create a ParquetWriter object:
967
+
968
+ >>> import pyarrow.parquet as pq
969
+ >>> writer = pq.ParquetWriter('example.parquet', table.schema)
970
+
971
+ and write the Table into the Parquet file:
972
+
973
+ >>> writer.write_table(table)
974
+ >>> writer.close()
975
+
976
+ >>> pq.read_table('example.parquet').to_pandas()
977
+ n_legs animal
978
+ 0 2 Flamingo
979
+ 1 2 Parrot
980
+ 2 4 Dog
981
+ 3 4 Horse
982
+ 4 5 Brittle stars
983
+ 5 100 Centipede
984
+
985
+ create a ParquetWriter object for the RecordBatch:
986
+
987
+ >>> writer2 = pq.ParquetWriter('example2.parquet', batch.schema)
988
+
989
+ and write the RecordBatch into the Parquet file:
990
+
991
+ >>> writer2.write_batch(batch)
992
+ >>> writer2.close()
993
+
994
+ >>> pq.read_table('example2.parquet').to_pandas()
995
+ n_legs animal
996
+ 0 2 Flamingo
997
+ 1 2 Parrot
998
+ 2 4 Dog
999
+ 3 4 Horse
1000
+ 4 5 Brittle stars
1001
+ 5 100 Centipede
1002
+ """
1003
+
1004
+
1005
+ class ParquetWriter:
1006
+
1007
+ __doc__ = f"""
1008
+ Class for incrementally building a Parquet file for Arrow tables.
1009
+
1010
+ Parameters
1011
+ ----------
1012
+ where : path or file-like object
1013
+ schema : pyarrow.Schema
1014
+ {_parquet_writer_arg_docs}
1015
+ writer_engine_version : unused
1016
+ **options : dict
1017
+ If options contains a key `metadata_collector` then the
1018
+ corresponding value is assumed to be a list (or any object with
1019
+ `.append` method) that will be filled with the file metadata instance
1020
+ of the written file.
1021
+
1022
+ Examples
1023
+ --------
1024
+ {_parquet_writer_example_doc}
1025
+ """
1026
+
1027
+ def __init__(self, where, schema, filesystem=None,
1028
+ flavor=None,
1029
+ version='2.6',
1030
+ use_dictionary=True,
1031
+ compression='snappy',
1032
+ write_statistics=True,
1033
+ use_deprecated_int96_timestamps=None,
1034
+ compression_level=None,
1035
+ use_byte_stream_split=False,
1036
+ column_encoding=None,
1037
+ writer_engine_version=None,
1038
+ data_page_version='1.0',
1039
+ use_compliant_nested_type=True,
1040
+ encryption_properties=None,
1041
+ write_batch_size=None,
1042
+ dictionary_pagesize_limit=None,
1043
+ store_schema=True,
1044
+ write_page_index=False,
1045
+ write_page_checksum=False,
1046
+ sorting_columns=None,
1047
+ store_decimal_as_integer=False,
1048
+ write_time_adjusted_to_utc=False,
1049
+ max_rows_per_page=None,
1050
+ **options):
1051
+ if use_deprecated_int96_timestamps is None:
1052
+ # Use int96 timestamps for Spark
1053
+ if flavor is not None and 'spark' in flavor:
1054
+ use_deprecated_int96_timestamps = True
1055
+ else:
1056
+ use_deprecated_int96_timestamps = False
1057
+
1058
+ self.flavor = flavor
1059
+ if flavor is not None:
1060
+ schema, self.schema_changed = _sanitize_schema(schema, flavor)
1061
+ else:
1062
+ self.schema_changed = False
1063
+
1064
+ self.schema = schema
1065
+ self.where = where
1066
+
1067
+ # If we open a file using a filesystem, store file handle so we can be
1068
+ # sure to close it when `self.close` is called.
1069
+ self.file_handle = None
1070
+
1071
+ filesystem, path = _resolve_filesystem_and_path(where, filesystem)
1072
+ if filesystem is not None:
1073
+ # ARROW-10480: do not auto-detect compression. While
1074
+ # a filename like foo.parquet.gz is nonconforming, it
1075
+ # shouldn't implicitly apply compression.
1076
+ sink = self.file_handle = filesystem.open_output_stream(
1077
+ path, compression=None)
1078
+ else:
1079
+ sink = where
1080
+ self._metadata_collector = options.pop('metadata_collector', None)
1081
+ engine_version = 'V2'
1082
+ self.writer = _parquet.ParquetWriter(
1083
+ sink, schema,
1084
+ version=version,
1085
+ compression=compression,
1086
+ use_dictionary=use_dictionary,
1087
+ write_statistics=write_statistics,
1088
+ use_deprecated_int96_timestamps=use_deprecated_int96_timestamps,
1089
+ compression_level=compression_level,
1090
+ use_byte_stream_split=use_byte_stream_split,
1091
+ column_encoding=column_encoding,
1092
+ writer_engine_version=engine_version,
1093
+ data_page_version=data_page_version,
1094
+ use_compliant_nested_type=use_compliant_nested_type,
1095
+ encryption_properties=encryption_properties,
1096
+ write_batch_size=write_batch_size,
1097
+ dictionary_pagesize_limit=dictionary_pagesize_limit,
1098
+ store_schema=store_schema,
1099
+ write_page_index=write_page_index,
1100
+ write_page_checksum=write_page_checksum,
1101
+ sorting_columns=sorting_columns,
1102
+ store_decimal_as_integer=store_decimal_as_integer,
1103
+ write_time_adjusted_to_utc=write_time_adjusted_to_utc,
1104
+ max_rows_per_page=max_rows_per_page,
1105
+ **options)
1106
+ self.is_open = True
1107
+
1108
+ def __del__(self):
1109
+ if getattr(self, 'is_open', False):
1110
+ self.close()
1111
+
1112
+ def __enter__(self):
1113
+ return self
1114
+
1115
+ def __exit__(self, *args, **kwargs):
1116
+ self.close()
1117
+ # return false since we want to propagate exceptions
1118
+ return False
1119
+
1120
+ def write(self, table_or_batch, row_group_size=None):
1121
+ """
1122
+ Write RecordBatch or Table to the Parquet file.
1123
+
1124
+ Parameters
1125
+ ----------
1126
+ table_or_batch : {RecordBatch, Table}
1127
+ row_group_size : int, default None
1128
+ Maximum number of rows in each written row group. If None, the row
1129
+ group size will be the minimum of the number of rows in the
1130
+ Table/RecordBatch and 1024 * 1024.
1131
+ """
1132
+ if isinstance(table_or_batch, pa.RecordBatch):
1133
+ self.write_batch(table_or_batch, row_group_size)
1134
+ elif isinstance(table_or_batch, pa.Table):
1135
+ self.write_table(table_or_batch, row_group_size)
1136
+ else:
1137
+ raise TypeError(type(table_or_batch))
1138
+
1139
+ def write_batch(self, batch, row_group_size=None):
1140
+ """
1141
+ Write RecordBatch to the Parquet file.
1142
+
1143
+ Parameters
1144
+ ----------
1145
+ batch : RecordBatch
1146
+ row_group_size : int, default None
1147
+ Maximum number of rows in written row group. If None, the
1148
+ row group size will be the minimum of the RecordBatch
1149
+ size (in rows) and 1024 * 1024. If set larger than 64 * 1024 * 1024
1150
+ then 64 * 1024 * 1024 will be used instead.
1151
+ """
1152
+ table = pa.Table.from_batches([batch], batch.schema)
1153
+ self.write_table(table, row_group_size)
1154
+
1155
+ def write_table(self, table, row_group_size=None):
1156
+ """
1157
+ Write Table to the Parquet file.
1158
+
1159
+ Parameters
1160
+ ----------
1161
+ table : Table
1162
+ row_group_size : int, default None
1163
+ Maximum number of rows in each written row group. If None,
1164
+ the row group size will be the minimum of the Table size (in rows)
1165
+ and 1024 * 1024. If set larger than 64 * 1024 * 1024 then
1166
+ 64 * 1024 * 1024 will be used instead.
1167
+
1168
+ """
1169
+ if self.schema_changed:
1170
+ table = _sanitize_table(table, self.schema, self.flavor)
1171
+ assert self.is_open
1172
+
1173
+ if not table.schema.equals(self.schema, check_metadata=False):
1174
+ msg = (
1175
+ "Table schema does not match schema used to create file: \n"
1176
+ f"table:\n{table.schema!s} vs. \nfile:\n{self.schema!s}"
1177
+ )
1178
+ raise ValueError(msg)
1179
+
1180
+ self.writer.write_table(table, row_group_size=row_group_size)
1181
+
1182
+ def close(self):
1183
+ """
1184
+ Close the connection to the Parquet file.
1185
+ """
1186
+ if self.is_open:
1187
+ self.writer.close()
1188
+ self.is_open = False
1189
+ if self._metadata_collector is not None:
1190
+ self._metadata_collector.append(self.writer.metadata)
1191
+ if self.file_handle is not None:
1192
+ self.file_handle.close()
1193
+
1194
+ def add_key_value_metadata(self, key_value_metadata):
1195
+ """
1196
+ Add key-value metadata to the file.
1197
+ This will overwrite any existing metadata with the same key.
1198
+
1199
+ Parameters
1200
+ ----------
1201
+ key_value_metadata : dict
1202
+ Keys and values must be string-like / coercible to bytes.
1203
+ """
1204
+ assert self.is_open
1205
+ self.writer.add_key_value_metadata(key_value_metadata)
1206
+
1207
+
1208
+ def _get_pandas_index_columns(keyvalues):
1209
+ return (json.loads(keyvalues[b'pandas'].decode('utf8'))
1210
+ ['index_columns'])
1211
+
1212
+
1213
+ EXCLUDED_PARQUET_PATHS = {'_SUCCESS'}
1214
+
1215
+
1216
+ _read_docstring_common = """\
1217
+ read_dictionary : list, default None
1218
+ List of names or column paths (for nested types) to read directly
1219
+ as DictionaryArray. Only supported for BYTE_ARRAY storage. To read
1220
+ a flat column as dictionary-encoded pass the column name. For
1221
+ nested types, you must pass the full column "path", which could be
1222
+ something like level1.level2.list.item. Refer to the Parquet
1223
+ file's schema to obtain the paths.
1224
+ binary_type : pyarrow.DataType, default None
1225
+ If given, Parquet binary columns will be read as this datatype.
1226
+ This setting is ignored if a serialized Arrow schema is found in
1227
+ the Parquet metadata.
1228
+ list_type : subclass of pyarrow.DataType, default None
1229
+ If given, non-MAP repeated columns will be read as an instance of
1230
+ this datatype (either pyarrow.ListType or pyarrow.LargeListType).
1231
+ This setting is ignored if a serialized Arrow schema is found in
1232
+ the Parquet metadata.
1233
+ memory_map : bool, default False
1234
+ If the source is a file path, use a memory map to read file, which can
1235
+ improve performance in some environments.
1236
+ buffer_size : int, default 0
1237
+ If positive, perform read buffering when deserializing individual
1238
+ column chunks. Otherwise IO calls are unbuffered.
1239
+ partitioning : pyarrow.dataset.Partitioning or str or list of str, \
1240
+ default "hive"
1241
+ The partitioning scheme for a partitioned dataset. The default of "hive"
1242
+ assumes directory names with key=value pairs like "/year=2009/month=11".
1243
+ In addition, a scheme like "/2009/11" is also supported, in which case
1244
+ you need to specify the field names or a full schema. See the
1245
+ ``pyarrow.dataset.partitioning()`` function for more details."""
1246
+
1247
+
1248
+ _parquet_dataset_example = """\
1249
+ Generate an example PyArrow Table and write it to a partitioned dataset:
1250
+
1251
+ >>> import pyarrow as pa
1252
+ >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
1253
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
1254
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
1255
+ ... "Brittle stars", "Centipede"]})
1256
+ >>> import pyarrow.parquet as pq
1257
+ >>> pq.write_to_dataset(table, root_path='dataset_v2',
1258
+ ... partition_cols=['year'])
1259
+
1260
+ create a ParquetDataset object from the dataset source:
1261
+
1262
+ >>> dataset = pq.ParquetDataset('dataset_v2/')
1263
+
1264
+ and read the data:
1265
+
1266
+ >>> dataset.read().to_pandas()
1267
+ n_legs animal year
1268
+ 0 5 Brittle stars 2019
1269
+ 1 2 Flamingo 2020
1270
+ 2 4 Dog 2021
1271
+ 3 100 Centipede 2021
1272
+ 4 2 Parrot 2022
1273
+ 5 4 Horse 2022
1274
+
1275
+ create a ParquetDataset object with filter:
1276
+
1277
+ >>> dataset = pq.ParquetDataset('dataset_v2/',
1278
+ ... filters=[('n_legs','=',4)])
1279
+ >>> dataset.read().to_pandas()
1280
+ n_legs animal year
1281
+ 0 4 Dog 2021
1282
+ 1 4 Horse 2022
1283
+ """
1284
+
1285
+
1286
+ class ParquetDataset:
1287
+ __doc__ = f"""
1288
+ Encapsulates details of reading a complete Parquet dataset possibly
1289
+ consisting of multiple files and partitions in subdirectories.
1290
+
1291
+ Parameters
1292
+ ----------
1293
+ path_or_paths : str or List[str]
1294
+ A directory name, single file name, or list of file names.
1295
+ filesystem : FileSystem, default None
1296
+ If nothing passed, will be inferred based on path.
1297
+ Path will try to be found in the local on-disk filesystem otherwise
1298
+ it will be parsed as an URI to determine the filesystem.
1299
+ schema : pyarrow.parquet.Schema
1300
+ Optionally provide the Schema for the Dataset, in which case it will
1301
+ not be inferred from the source.
1302
+ filters : pyarrow.compute.Expression or List[Tuple] or List[List[Tuple]], default None
1303
+ Rows which do not match the filter predicate will be removed from scanned
1304
+ data. Partition keys embedded in a nested directory structure will be
1305
+ exploited to avoid loading files at all if they contain no matching rows.
1306
+ Within-file level filtering and different partitioning schemes are supported.
1307
+
1308
+ {_DNF_filter_doc}
1309
+ {_read_docstring_common}
1310
+ ignore_prefixes : list, optional
1311
+ Files matching any of these prefixes will be ignored by the
1312
+ discovery process.
1313
+ This is matched to the basename of a path.
1314
+ By default this is ['.', '_'].
1315
+ Note that discovery happens only if a directory is passed as source.
1316
+ pre_buffer : bool, default True
1317
+ Coalesce and issue file reads in parallel to improve performance on
1318
+ high-latency filesystems (e.g. S3, GCS). If True, Arrow will use a
1319
+ background I/O thread pool. If using a filesystem layer that itself
1320
+ performs readahead (e.g. fsspec's S3FS), disable readahead for best
1321
+ results. Set to False if you want to prioritize minimal memory usage
1322
+ over maximum speed.
1323
+ coerce_int96_timestamp_unit : str, default None
1324
+ Cast timestamps that are stored in INT96 format to a particular resolution
1325
+ (e.g. 'ms'). Setting to None is equivalent to 'ns' and therefore INT96
1326
+ timestamps will be inferred as timestamps in nanoseconds.
1327
+ decryption_properties : FileDecryptionProperties or None
1328
+ File-level decryption properties.
1329
+ The decryption properties can be created using
1330
+ ``CryptoFactory.file_decryption_properties()``.
1331
+ thrift_string_size_limit : int, default None
1332
+ If not None, override the maximum total string size allocated
1333
+ when decoding Thrift structures. The default limit should be
1334
+ sufficient for most Parquet files.
1335
+ thrift_container_size_limit : int, default None
1336
+ If not None, override the maximum total size of containers allocated
1337
+ when decoding Thrift structures. The default limit should be
1338
+ sufficient for most Parquet files.
1339
+ page_checksum_verification : bool, default False
1340
+ If True, verify the page checksum for each page read from the file.
1341
+ arrow_extensions_enabled : bool, default True
1342
+ If True, read Parquet logical types as Arrow extension types where possible,
1343
+ (e.g., read JSON as the canonical `arrow.json` extension type or UUID as
1344
+ the canonical `arrow.uuid` extension type).
1345
+
1346
+ Examples
1347
+ --------
1348
+ {_parquet_dataset_example}
1349
+ """
1350
+
1351
+ def __init__(self, path_or_paths, filesystem=None, schema=None, *, filters=None,
1352
+ read_dictionary=None, binary_type=None, list_type=None,
1353
+ memory_map=False, buffer_size=None, partitioning="hive",
1354
+ ignore_prefixes=None,
1355
+ pre_buffer=True, coerce_int96_timestamp_unit=None,
1356
+ decryption_properties=None, thrift_string_size_limit=None,
1357
+ thrift_container_size_limit=None,
1358
+ page_checksum_verification=False,
1359
+ arrow_extensions_enabled=True):
1360
+ import pyarrow.dataset as ds
1361
+
1362
+ # map format arguments
1363
+ read_options = {
1364
+ "pre_buffer": pre_buffer,
1365
+ "coerce_int96_timestamp_unit": coerce_int96_timestamp_unit,
1366
+ "thrift_string_size_limit": thrift_string_size_limit,
1367
+ "thrift_container_size_limit": thrift_container_size_limit,
1368
+ "page_checksum_verification": page_checksum_verification,
1369
+ "arrow_extensions_enabled": arrow_extensions_enabled,
1370
+ "binary_type": binary_type,
1371
+ "list_type": list_type,
1372
+ }
1373
+ if buffer_size:
1374
+ read_options.update(use_buffered_stream=True,
1375
+ buffer_size=buffer_size)
1376
+ if read_dictionary is not None:
1377
+ read_options.update(dictionary_columns=read_dictionary)
1378
+
1379
+ if decryption_properties is not None:
1380
+ read_options.update(decryption_properties=decryption_properties)
1381
+
1382
+ self._filter_expression = None
1383
+ if filters is not None:
1384
+ self._filter_expression = filters_to_expression(filters)
1385
+
1386
+ # map old filesystems to new one
1387
+ if filesystem is not None:
1388
+ filesystem = _ensure_filesystem(
1389
+ filesystem, use_mmap=memory_map)
1390
+ elif filesystem is None and memory_map:
1391
+ # if memory_map is specified, assume local file system (string
1392
+ # path can in principle be URI for any filesystem)
1393
+ filesystem = LocalFileSystem(use_mmap=memory_map)
1394
+
1395
+ # This needs to be checked after _ensure_filesystem, because that
1396
+ # handles the case of an fsspec LocalFileSystem
1397
+ if (
1398
+ hasattr(path_or_paths, "__fspath__") and
1399
+ filesystem is not None and
1400
+ not isinstance(filesystem, LocalFileSystem)
1401
+ ):
1402
+ raise TypeError(
1403
+ "Path-like objects with __fspath__ must only be used with "
1404
+ f"local file systems, not {type(filesystem)}"
1405
+ )
1406
+
1407
+ # check for single fragment dataset or dataset directory
1408
+ single_file = None
1409
+ self._base_dir = None
1410
+ if not isinstance(path_or_paths, list):
1411
+ if _is_path_like(path_or_paths):
1412
+ filesystem, path_or_paths = _resolve_filesystem_and_path(
1413
+ path_or_paths, filesystem, memory_map=memory_map
1414
+ )
1415
+ finfo = filesystem.get_file_info(path_or_paths)
1416
+ if finfo.type == FileType.Directory:
1417
+ self._base_dir = path_or_paths
1418
+ else:
1419
+ single_file = path_or_paths
1420
+
1421
+ parquet_format = ds.ParquetFileFormat(**read_options)
1422
+
1423
+ if single_file is not None:
1424
+ fragment = parquet_format.make_fragment(single_file, filesystem)
1425
+
1426
+ self._dataset = ds.FileSystemDataset(
1427
+ [fragment], schema=schema or fragment.physical_schema,
1428
+ format=parquet_format,
1429
+ filesystem=fragment.filesystem
1430
+ )
1431
+ return
1432
+
1433
+ # check partitioning to enable dictionary encoding
1434
+ if partitioning == "hive":
1435
+ partitioning = ds.HivePartitioning.discover(
1436
+ infer_dictionary=True)
1437
+
1438
+ self._dataset = ds.dataset(path_or_paths, filesystem=filesystem,
1439
+ schema=schema, format=parquet_format,
1440
+ partitioning=partitioning,
1441
+ ignore_prefixes=ignore_prefixes)
1442
+
1443
+ def equals(self, other):
1444
+ if not isinstance(other, ParquetDataset):
1445
+ raise TypeError('`other` must be an instance of ParquetDataset')
1446
+
1447
+ return (self.schema == other.schema and
1448
+ self._dataset.format == other._dataset.format and
1449
+ self.filesystem == other.filesystem and
1450
+ # self.fragments == other.fragments and
1451
+ self.files == other.files)
1452
+
1453
+ def __eq__(self, other):
1454
+ try:
1455
+ return self.equals(other)
1456
+ except TypeError:
1457
+ return NotImplemented
1458
+
1459
+ @property
1460
+ def schema(self):
1461
+ """
1462
+ Schema of the Dataset.
1463
+
1464
+ Examples
1465
+ --------
1466
+ Generate an example dataset:
1467
+
1468
+ >>> import pyarrow as pa
1469
+ >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
1470
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
1471
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
1472
+ ... "Brittle stars", "Centipede"]})
1473
+ >>> import pyarrow.parquet as pq
1474
+ >>> pq.write_to_dataset(table, root_path='dataset_v2_schema',
1475
+ ... partition_cols=['year'])
1476
+ >>> dataset = pq.ParquetDataset('dataset_v2_schema/')
1477
+
1478
+ Read the schema:
1479
+
1480
+ >>> dataset.schema
1481
+ n_legs: int64
1482
+ animal: string
1483
+ year: dictionary<values=int32, indices=int32, ordered=0>
1484
+ """
1485
+ return self._dataset.schema
1486
+
1487
+ def read(self, columns=None, use_threads=True, use_pandas_metadata=False):
1488
+ """
1489
+ Read (multiple) Parquet files as a single pyarrow.Table.
1490
+
1491
+ Parameters
1492
+ ----------
1493
+ columns : List[str]
1494
+ Names of columns to read from the dataset. The partition fields
1495
+ are not automatically included.
1496
+ use_threads : bool, default True
1497
+ Perform multi-threaded column reads.
1498
+ use_pandas_metadata : bool, default False
1499
+ If True and file has custom pandas schema metadata, ensure that
1500
+ index columns are also loaded.
1501
+
1502
+ Returns
1503
+ -------
1504
+ pyarrow.Table
1505
+ Content of the file as a table (of columns).
1506
+
1507
+ Examples
1508
+ --------
1509
+ Generate an example dataset:
1510
+
1511
+ >>> import pyarrow as pa
1512
+ >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
1513
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
1514
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
1515
+ ... "Brittle stars", "Centipede"]})
1516
+ >>> import pyarrow.parquet as pq
1517
+ >>> pq.write_to_dataset(table, root_path='dataset_v2_read',
1518
+ ... partition_cols=['year'])
1519
+ >>> dataset = pq.ParquetDataset('dataset_v2_read/')
1520
+
1521
+ Read the dataset:
1522
+
1523
+ >>> dataset.read(columns=["n_legs"])
1524
+ pyarrow.Table
1525
+ n_legs: int64
1526
+ ----
1527
+ n_legs: [[5],[2],[4,100],[2,4]]
1528
+ """
1529
+ # if use_pandas_metadata, we need to include index columns in the
1530
+ # column selection, to be able to restore those in the pandas DataFrame
1531
+ metadata = self.schema.metadata or {}
1532
+
1533
+ if use_pandas_metadata:
1534
+ # if the dataset schema metadata itself doesn't have pandas
1535
+ # then try to get this from common file (for backwards compat)
1536
+ if b"pandas" not in metadata:
1537
+ common_metadata = self._get_common_pandas_metadata()
1538
+ if common_metadata:
1539
+ metadata = common_metadata
1540
+
1541
+ if columns is not None and use_pandas_metadata:
1542
+ if metadata and b'pandas' in metadata:
1543
+ # RangeIndex can be represented as dict instead of column name
1544
+ index_columns = [
1545
+ col for col in _get_pandas_index_columns(metadata)
1546
+ if not isinstance(col, dict)
1547
+ ]
1548
+ columns = (
1549
+ list(columns) + list(set(index_columns) - set(columns))
1550
+ )
1551
+
1552
+ table = self._dataset.to_table(
1553
+ columns=columns, filter=self._filter_expression,
1554
+ use_threads=use_threads
1555
+ )
1556
+
1557
+ # if use_pandas_metadata, restore the pandas metadata (which gets
1558
+ # lost if doing a specific `columns` selection in to_table)
1559
+ if use_pandas_metadata:
1560
+ if metadata and b"pandas" in metadata:
1561
+ new_metadata = table.schema.metadata or {}
1562
+ new_metadata.update({b"pandas": metadata[b"pandas"]})
1563
+ table = table.replace_schema_metadata(new_metadata)
1564
+
1565
+ return table
1566
+
1567
+ def _get_common_pandas_metadata(self):
1568
+
1569
+ if not self._base_dir:
1570
+ return None
1571
+
1572
+ metadata = None
1573
+ for name in ["_common_metadata", "_metadata"]:
1574
+ metadata_path = os.path.join(str(self._base_dir), name)
1575
+ finfo = self.filesystem.get_file_info(metadata_path)
1576
+ if finfo.is_file:
1577
+ pq_meta = read_metadata(
1578
+ metadata_path, filesystem=self.filesystem)
1579
+ metadata = pq_meta.metadata
1580
+ if metadata and b'pandas' in metadata:
1581
+ break
1582
+
1583
+ return metadata
1584
+
1585
+ def read_pandas(self, **kwargs):
1586
+ """
1587
+ Read dataset including pandas metadata, if any. Other arguments passed
1588
+ through to :func:`read`, see docstring for further details.
1589
+
1590
+ Parameters
1591
+ ----------
1592
+ **kwargs : optional
1593
+ Additional options for :func:`read`
1594
+
1595
+ Examples
1596
+ --------
1597
+ Generate an example parquet file:
1598
+
1599
+ >>> import pyarrow as pa
1600
+ >>> import pandas as pd
1601
+ >>> df = pd.DataFrame({'year': [2020, 2022, 2021, 2022, 2019, 2021],
1602
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
1603
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
1604
+ ... "Brittle stars", "Centipede"]})
1605
+ >>> table = pa.Table.from_pandas(df)
1606
+ >>> import pyarrow.parquet as pq
1607
+ >>> pq.write_table(table, 'table_V2.parquet')
1608
+ >>> dataset = pq.ParquetDataset('table_V2.parquet')
1609
+
1610
+ Read the dataset with pandas metadata:
1611
+
1612
+ >>> dataset.read_pandas(columns=["n_legs"])
1613
+ pyarrow.Table
1614
+ n_legs: int64
1615
+ ----
1616
+ n_legs: [[2,2,4,4,5,100]]
1617
+
1618
+ >>> dataset.read_pandas(columns=["n_legs"]).schema.pandas_metadata
1619
+ {'index_columns': [{'kind': 'range', 'name': None, 'start': 0, ...}
1620
+ """
1621
+ return self.read(use_pandas_metadata=True, **kwargs)
1622
+
1623
+ @property
1624
+ def fragments(self):
1625
+ """
1626
+ A list of the Dataset source fragments or pieces with absolute
1627
+ file paths.
1628
+
1629
+ Examples
1630
+ --------
1631
+ Generate an example dataset:
1632
+
1633
+ >>> import pyarrow as pa
1634
+ >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
1635
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
1636
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
1637
+ ... "Brittle stars", "Centipede"]})
1638
+ >>> import pyarrow.parquet as pq
1639
+ >>> pq.write_to_dataset(table, root_path='dataset_v2_fragments',
1640
+ ... partition_cols=['year'])
1641
+ >>> dataset = pq.ParquetDataset('dataset_v2_fragments/')
1642
+
1643
+ List the fragments:
1644
+
1645
+ >>> dataset.fragments
1646
+ [<pyarrow.dataset.ParquetFileFragment path=dataset_v2_fragments/...
1647
+ """
1648
+ return list(self._dataset.get_fragments())
1649
+
1650
+ @property
1651
+ def files(self):
1652
+ """
1653
+ A list of absolute Parquet file paths in the Dataset source.
1654
+
1655
+ Examples
1656
+ --------
1657
+ Generate an example dataset:
1658
+
1659
+ >>> import pyarrow as pa
1660
+ >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
1661
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
1662
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
1663
+ ... "Brittle stars", "Centipede"]})
1664
+ >>> import pyarrow.parquet as pq
1665
+ >>> pq.write_to_dataset(table, root_path='dataset_v2_files',
1666
+ ... partition_cols=['year'])
1667
+ >>> dataset = pq.ParquetDataset('dataset_v2_files/')
1668
+
1669
+ List the files:
1670
+
1671
+ >>> dataset.files
1672
+ ['dataset_v2_files/year=2019/...-0.parquet', ...
1673
+ """
1674
+ return self._dataset.files
1675
+
1676
+ @property
1677
+ def filesystem(self):
1678
+ """
1679
+ The filesystem type of the Dataset source.
1680
+ """
1681
+ return self._dataset.filesystem
1682
+
1683
+ @property
1684
+ def partitioning(self):
1685
+ """
1686
+ The partitioning of the Dataset source, if discovered.
1687
+ """
1688
+ return self._dataset.partitioning
1689
+
1690
+
1691
+ _read_table_docstring = """
1692
+ {0}
1693
+
1694
+ Parameters
1695
+ ----------
1696
+ source : str, list of str, pyarrow.NativeFile, or file-like object
1697
+ If a string is passed, can be a single file name or directory name. If a
1698
+ list of strings is passed, should be file names. For file-like objects,
1699
+ only read a single file. Use pyarrow.BufferReader to read a file contained
1700
+ in a bytes or buffer-like object.
1701
+ columns : list
1702
+ If not None, only these columns will be read from the file. A column
1703
+ name may be a prefix of a nested field, e.g. 'a' will select 'a.b',
1704
+ 'a.c', and 'a.d.e'. If empty, no columns will be read. Note
1705
+ that the table will still have the correct num_rows set despite having
1706
+ no columns.
1707
+ use_threads : bool, default True
1708
+ Perform multi-threaded column reads.
1709
+ schema : Schema, optional
1710
+ Optionally provide the Schema for the parquet dataset, in which case it
1711
+ will not be inferred from the source.
1712
+ {1}
1713
+ filesystem : FileSystem, default None
1714
+ If nothing passed, will be inferred based on path.
1715
+ Path will try to be found in the local on-disk filesystem otherwise
1716
+ it will be parsed as an URI to determine the filesystem.
1717
+ filters : pyarrow.compute.Expression or List[Tuple] or List[List[Tuple]], default None
1718
+ Rows which do not match the filter predicate will be removed from scanned
1719
+ data. Partition keys embedded in a nested directory structure will be
1720
+ exploited to avoid loading files at all if they contain no matching rows.
1721
+ Within-file level filtering and different partitioning schemes are supported.
1722
+
1723
+ {3}
1724
+ ignore_prefixes : list, optional
1725
+ Files matching any of these prefixes will be ignored by the
1726
+ discovery process.
1727
+ This is matched to the basename of a path.
1728
+ By default this is ['.', '_'].
1729
+ Note that discovery happens only if a directory is passed as source.
1730
+ pre_buffer : bool, default True
1731
+ Coalesce and issue file reads in parallel to improve performance on
1732
+ high-latency filesystems (e.g. S3). If True, Arrow will use a
1733
+ background I/O thread pool. If using a filesystem layer that itself
1734
+ performs readahead (e.g. fsspec's S3FS), disable readahead for best
1735
+ results.
1736
+ coerce_int96_timestamp_unit : str, default None
1737
+ Cast timestamps that are stored in INT96 format to a particular
1738
+ resolution (e.g. 'ms'). Setting to None is equivalent to 'ns'
1739
+ and therefore INT96 timestamps will be inferred as timestamps
1740
+ in nanoseconds.
1741
+ decryption_properties : FileDecryptionProperties or None
1742
+ File-level decryption properties.
1743
+ The decryption properties can be created using
1744
+ ``CryptoFactory.file_decryption_properties()``.
1745
+ thrift_string_size_limit : int, default None
1746
+ If not None, override the maximum total string size allocated
1747
+ when decoding Thrift structures. The default limit should be
1748
+ sufficient for most Parquet files.
1749
+ thrift_container_size_limit : int, default None
1750
+ If not None, override the maximum total size of containers allocated
1751
+ when decoding Thrift structures. The default limit should be
1752
+ sufficient for most Parquet files.
1753
+ page_checksum_verification : bool, default False
1754
+ If True, verify the checksum for each page read from the file.
1755
+ arrow_extensions_enabled : bool, default True
1756
+ If True, read Parquet logical types as Arrow extension types where possible,
1757
+ (e.g., read JSON as the canonical `arrow.json` extension type or UUID as
1758
+ the canonical `arrow.uuid` extension type).
1759
+
1760
+ Returns
1761
+ -------
1762
+ {2}
1763
+
1764
+ {4}
1765
+ """
1766
+
1767
+ _read_table_example = """\
1768
+
1769
+ Examples
1770
+ --------
1771
+
1772
+ Generate an example PyArrow Table and write it to a partitioned dataset:
1773
+
1774
+ >>> import pyarrow as pa
1775
+ >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
1776
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
1777
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
1778
+ ... "Brittle stars", "Centipede"]})
1779
+ >>> import pyarrow.parquet as pq
1780
+ >>> pq.write_to_dataset(table, root_path='dataset_name_2',
1781
+ ... partition_cols=['year'])
1782
+
1783
+ Read the data:
1784
+
1785
+ >>> pq.read_table('dataset_name_2').to_pandas()
1786
+ n_legs animal year
1787
+ 0 5 Brittle stars 2019
1788
+ 1 2 Flamingo 2020
1789
+ 2 4 Dog 2021
1790
+ 3 100 Centipede 2021
1791
+ 4 2 Parrot 2022
1792
+ 5 4 Horse 2022
1793
+
1794
+
1795
+ Read only a subset of columns:
1796
+
1797
+ >>> pq.read_table('dataset_name_2', columns=["n_legs", "animal"])
1798
+ pyarrow.Table
1799
+ n_legs: int64
1800
+ animal: string
1801
+ ----
1802
+ n_legs: [[5],[2],[4,100],[2,4]]
1803
+ animal: [["Brittle stars"],["Flamingo"],["Dog","Centipede"],["Parrot","Horse"]]
1804
+
1805
+ Read a subset of columns and read one column as DictionaryArray:
1806
+
1807
+ >>> pq.read_table('dataset_name_2', columns=["n_legs", "animal"],
1808
+ ... read_dictionary=["animal"])
1809
+ pyarrow.Table
1810
+ n_legs: int64
1811
+ animal: dictionary<values=string, indices=int32, ordered=0>
1812
+ ----
1813
+ n_legs: [[5],[2],[4,100],[2,4]]
1814
+ animal: [ -- dictionary:
1815
+ ["Brittle stars"] -- indices:
1816
+ [0], -- dictionary:
1817
+ ["Flamingo"] -- indices:
1818
+ [0], -- dictionary:
1819
+ ["Dog","Centipede"] -- indices:
1820
+ [0,1], -- dictionary:
1821
+ ["Parrot","Horse"] -- indices:
1822
+ [0,1]]
1823
+
1824
+ Read the table with filter:
1825
+
1826
+ >>> pq.read_table('dataset_name_2', columns=["n_legs", "animal"],
1827
+ ... filters=[('n_legs','<',4)]).to_pandas()
1828
+ n_legs animal
1829
+ 0 2 Flamingo
1830
+ 1 2 Parrot
1831
+
1832
+ Read data from a single Parquet file:
1833
+
1834
+ >>> pq.write_table(table, 'example.parquet')
1835
+ >>> pq.read_table('dataset_name_2').to_pandas()
1836
+ n_legs animal year
1837
+ 0 5 Brittle stars 2019
1838
+ 1 2 Flamingo 2020
1839
+ 2 4 Dog 2021
1840
+ 3 100 Centipede 2021
1841
+ 4 2 Parrot 2022
1842
+ 5 4 Horse 2022
1843
+ """
1844
+
1845
+
1846
+ def read_table(source, *, columns=None, use_threads=True,
1847
+ schema=None, use_pandas_metadata=False, read_dictionary=None,
1848
+ binary_type=None, list_type=None, memory_map=False, buffer_size=0,
1849
+ partitioning="hive", filesystem=None, filters=None,
1850
+ ignore_prefixes=None, pre_buffer=True,
1851
+ coerce_int96_timestamp_unit=None,
1852
+ decryption_properties=None, thrift_string_size_limit=None,
1853
+ thrift_container_size_limit=None,
1854
+ page_checksum_verification=False,
1855
+ arrow_extensions_enabled=True):
1856
+
1857
+ try:
1858
+ dataset = ParquetDataset(
1859
+ source,
1860
+ schema=schema,
1861
+ filesystem=filesystem,
1862
+ partitioning=partitioning,
1863
+ memory_map=memory_map,
1864
+ read_dictionary=read_dictionary,
1865
+ binary_type=binary_type,
1866
+ list_type=list_type,
1867
+ buffer_size=buffer_size,
1868
+ filters=filters,
1869
+ ignore_prefixes=ignore_prefixes,
1870
+ pre_buffer=pre_buffer,
1871
+ coerce_int96_timestamp_unit=coerce_int96_timestamp_unit,
1872
+ decryption_properties=decryption_properties,
1873
+ thrift_string_size_limit=thrift_string_size_limit,
1874
+ thrift_container_size_limit=thrift_container_size_limit,
1875
+ page_checksum_verification=page_checksum_verification,
1876
+ arrow_extensions_enabled=arrow_extensions_enabled,
1877
+ )
1878
+ except ImportError:
1879
+ # fall back on ParquetFile for simple cases when pyarrow.dataset
1880
+ # module is not available
1881
+ if filters is not None:
1882
+ raise ValueError(
1883
+ "the 'filters' keyword is not supported when the "
1884
+ "pyarrow.dataset module is not available"
1885
+ )
1886
+ if partitioning != "hive":
1887
+ raise ValueError(
1888
+ "the 'partitioning' keyword is not supported when the "
1889
+ "pyarrow.dataset module is not available"
1890
+ )
1891
+ if schema is not None:
1892
+ raise ValueError(
1893
+ "the 'schema' argument is not supported when the "
1894
+ "pyarrow.dataset module is not available"
1895
+ )
1896
+ if isinstance(source, list):
1897
+ raise ValueError(
1898
+ "the 'source' argument cannot be a list of files "
1899
+ "when the pyarrow.dataset module is not available"
1900
+ )
1901
+
1902
+ filesystem, path = _resolve_filesystem_and_path(source, filesystem)
1903
+ if filesystem is not None:
1904
+ if not filesystem.get_file_info(path).is_file:
1905
+ raise ValueError(
1906
+ "the 'source' argument should be "
1907
+ "an existing parquet file and not a directory "
1908
+ "when the pyarrow.dataset module is not available"
1909
+ )
1910
+
1911
+ source = filesystem.open_input_file(path)
1912
+
1913
+ dataset = ParquetFile(
1914
+ source, read_dictionary=read_dictionary,
1915
+ binary_type=binary_type,
1916
+ list_type=list_type,
1917
+ memory_map=memory_map, buffer_size=buffer_size,
1918
+ pre_buffer=pre_buffer,
1919
+ coerce_int96_timestamp_unit=coerce_int96_timestamp_unit,
1920
+ decryption_properties=decryption_properties,
1921
+ thrift_string_size_limit=thrift_string_size_limit,
1922
+ thrift_container_size_limit=thrift_container_size_limit,
1923
+ page_checksum_verification=page_checksum_verification,
1924
+ )
1925
+
1926
+ return dataset.read(columns=columns, use_threads=use_threads,
1927
+ use_pandas_metadata=use_pandas_metadata)
1928
+
1929
+
1930
+ read_table.__doc__ = _read_table_docstring.format(
1931
+ """Read a Table from Parquet format""",
1932
+ "\n".join(("""use_pandas_metadata : bool, default False
1933
+ If True and file has custom pandas schema metadata, ensure that
1934
+ index columns are also loaded.""", _read_docstring_common)),
1935
+ """pyarrow.Table
1936
+ Content of the file as a table (of columns)""",
1937
+ _DNF_filter_doc, _read_table_example)
1938
+
1939
+
1940
+ def read_pandas(source, columns=None, **kwargs):
1941
+ return read_table(
1942
+ source, columns=columns, use_pandas_metadata=True, **kwargs
1943
+ )
1944
+
1945
+
1946
+ read_pandas.__doc__ = _read_table_docstring.format(
1947
+ 'Read a Table from Parquet format, also reading DataFrame\n'
1948
+ 'index values if known in the file metadata',
1949
+ "\n".join((_read_docstring_common,
1950
+ """**kwargs
1951
+ additional options for :func:`read_table`""")),
1952
+ """pyarrow.Table
1953
+ Content of the file as a Table of Columns, including DataFrame
1954
+ indexes as columns""",
1955
+ _DNF_filter_doc, "")
1956
+
1957
+
1958
+ def write_table(table, where, row_group_size=None, version='2.6',
1959
+ use_dictionary=True, compression='snappy',
1960
+ write_statistics=True,
1961
+ use_deprecated_int96_timestamps=None,
1962
+ coerce_timestamps=None,
1963
+ allow_truncated_timestamps=False,
1964
+ data_page_size=None, flavor=None,
1965
+ filesystem=None,
1966
+ compression_level=None,
1967
+ use_byte_stream_split=False,
1968
+ column_encoding=None,
1969
+ data_page_version='1.0',
1970
+ use_compliant_nested_type=True,
1971
+ encryption_properties=None,
1972
+ write_batch_size=None,
1973
+ dictionary_pagesize_limit=None,
1974
+ store_schema=True,
1975
+ write_page_index=False,
1976
+ write_page_checksum=False,
1977
+ sorting_columns=None,
1978
+ store_decimal_as_integer=False,
1979
+ write_time_adjusted_to_utc=False,
1980
+ max_rows_per_page=None,
1981
+ **kwargs):
1982
+ # Implementor's note: when adding keywords here / updating defaults, also
1983
+ # update it in write_to_dataset and _dataset_parquet.pyx ParquetFileWriteOptions
1984
+ row_group_size = kwargs.pop('chunk_size', row_group_size)
1985
+ use_int96 = use_deprecated_int96_timestamps
1986
+ try:
1987
+ with ParquetWriter(
1988
+ where, table.schema,
1989
+ filesystem=filesystem,
1990
+ version=version,
1991
+ flavor=flavor,
1992
+ use_dictionary=use_dictionary,
1993
+ write_statistics=write_statistics,
1994
+ coerce_timestamps=coerce_timestamps,
1995
+ data_page_size=data_page_size,
1996
+ allow_truncated_timestamps=allow_truncated_timestamps,
1997
+ compression=compression,
1998
+ use_deprecated_int96_timestamps=use_int96,
1999
+ compression_level=compression_level,
2000
+ use_byte_stream_split=use_byte_stream_split,
2001
+ column_encoding=column_encoding,
2002
+ data_page_version=data_page_version,
2003
+ use_compliant_nested_type=use_compliant_nested_type,
2004
+ encryption_properties=encryption_properties,
2005
+ write_batch_size=write_batch_size,
2006
+ dictionary_pagesize_limit=dictionary_pagesize_limit,
2007
+ store_schema=store_schema,
2008
+ write_page_index=write_page_index,
2009
+ write_page_checksum=write_page_checksum,
2010
+ sorting_columns=sorting_columns,
2011
+ store_decimal_as_integer=store_decimal_as_integer,
2012
+ write_time_adjusted_to_utc=write_time_adjusted_to_utc,
2013
+ max_rows_per_page=max_rows_per_page,
2014
+ **kwargs) as writer:
2015
+ writer.write_table(table, row_group_size=row_group_size)
2016
+ except Exception:
2017
+ if _is_path_like(where):
2018
+ try:
2019
+ os.remove(_stringify_path(where))
2020
+ except os.error:
2021
+ pass
2022
+ raise
2023
+
2024
+
2025
+ _write_table_example = """\
2026
+ Generate an example PyArrow Table:
2027
+
2028
+ >>> import pyarrow as pa
2029
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
2030
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
2031
+ ... "Brittle stars", "Centipede"]})
2032
+
2033
+ and write the Table into Parquet file:
2034
+
2035
+ >>> import pyarrow.parquet as pq
2036
+ >>> pq.write_table(table, 'example.parquet')
2037
+
2038
+ Defining row group size for the Parquet file:
2039
+
2040
+ >>> pq.write_table(table, 'example.parquet', row_group_size=3)
2041
+
2042
+ Defining row group compression (default is Snappy):
2043
+
2044
+ >>> pq.write_table(table, 'example.parquet', compression='none')
2045
+
2046
+ Defining row group compression and encoding per-column:
2047
+
2048
+ >>> pq.write_table(table, 'example.parquet',
2049
+ ... compression={'n_legs': 'snappy', 'animal': 'gzip'},
2050
+ ... use_dictionary=['n_legs', 'animal'])
2051
+
2052
+ Defining column encoding per-column:
2053
+
2054
+ >>> pq.write_table(table, 'example.parquet',
2055
+ ... column_encoding={'animal':'PLAIN'},
2056
+ ... use_dictionary=False)
2057
+ """
2058
+
2059
+ write_table.__doc__ = f"""
2060
+ Write a Table to Parquet format.
2061
+
2062
+ Parameters
2063
+ ----------
2064
+ table : pyarrow.Table
2065
+ where : string or pyarrow.NativeFile
2066
+ row_group_size : int, default None
2067
+ Maximum number of rows in each written row group. If None, the
2068
+ row group size will be the minimum of the Table size (in rows)
2069
+ and 1024 * 1024. If set larger than 64 * 1024 * 1024 then
2070
+ 64 * 1024 * 1024 will be used instead.
2071
+ {_parquet_writer_arg_docs}
2072
+ **kwargs : optional
2073
+ Additional options for ParquetWriter
2074
+
2075
+ Examples
2076
+ --------
2077
+ {_write_table_example}
2078
+ """
2079
+
2080
+
2081
+ def write_to_dataset(table, root_path, partition_cols=None,
2082
+ filesystem=None, schema=None, partitioning=None,
2083
+ basename_template=None, use_threads=None,
2084
+ file_visitor=None, existing_data_behavior=None,
2085
+ **kwargs):
2086
+ """Wrapper around dataset.write_dataset for writing a Table to
2087
+ Parquet format by partitions.
2088
+ For each combination of partition columns and values,
2089
+ a subdirectories are created in the following
2090
+ manner:
2091
+
2092
+ root_dir/
2093
+ group1=value1
2094
+ group2=value1
2095
+ <uuid>.parquet
2096
+ group2=value2
2097
+ <uuid>.parquet
2098
+ group1=valueN
2099
+ group2=value1
2100
+ <uuid>.parquet
2101
+ group2=valueN
2102
+ <uuid>.parquet
2103
+
2104
+ Parameters
2105
+ ----------
2106
+ table : pyarrow.Table
2107
+ root_path : str, pathlib.Path
2108
+ The root directory of the dataset.
2109
+ partition_cols : list,
2110
+ Column names by which to partition the dataset.
2111
+ Columns are partitioned in the order they are given.
2112
+ filesystem : FileSystem, default None
2113
+ If nothing passed, will be inferred based on path.
2114
+ Path will try to be found in the local on-disk filesystem otherwise
2115
+ it will be parsed as an URI to determine the filesystem.
2116
+ schema : Schema, optional
2117
+ This Schema of the dataset.
2118
+ partitioning : Partitioning or list[str], optional
2119
+ The partitioning scheme specified with the
2120
+ ``pyarrow.dataset.partitioning()`` function or a list of field names.
2121
+ When providing a list of field names, you can use
2122
+ ``partitioning_flavor`` to drive which partitioning type should be
2123
+ used.
2124
+ basename_template : str, optional
2125
+ A template string used to generate basenames of written data files.
2126
+ The token '{i}' will be replaced with an automatically incremented
2127
+ integer. If not specified, it defaults to "guid-{i}.parquet".
2128
+ use_threads : bool, default True
2129
+ Write files in parallel. If enabled, then maximum parallelism will be
2130
+ used determined by the number of available CPU cores.
2131
+ file_visitor : function
2132
+ If set, this function will be called with a WrittenFile instance
2133
+ for each file created during the call. This object will have both
2134
+ a path attribute and a metadata attribute.
2135
+
2136
+ The path attribute will be a string containing the path to
2137
+ the created file.
2138
+
2139
+ The metadata attribute will be the parquet metadata of the file.
2140
+ This metadata will have the file path attribute set and can be used
2141
+ to build a _metadata file. The metadata attribute will be None if
2142
+ the format is not parquet.
2143
+
2144
+ Example visitor which simple collects the filenames created::
2145
+
2146
+ visited_paths = []
2147
+
2148
+ def file_visitor(written_file):
2149
+ visited_paths.append(written_file.path)
2150
+
2151
+ existing_data_behavior : 'overwrite_or_ignore' | 'error' | \
2152
+ 'delete_matching'
2153
+ Controls how the dataset will handle data that already exists in
2154
+ the destination. The default behaviour is 'overwrite_or_ignore'.
2155
+
2156
+ 'overwrite_or_ignore' will ignore any existing data and will
2157
+ overwrite files with the same name as an output file. Other
2158
+ existing files will be ignored. This behavior, in combination
2159
+ with a unique basename_template for each write, will allow for
2160
+ an append workflow.
2161
+
2162
+ 'error' will raise an error if any data exists in the destination.
2163
+
2164
+ 'delete_matching' is useful when you are writing a partitioned
2165
+ dataset. The first time each partition directory is encountered
2166
+ the entire directory will be deleted. This allows you to overwrite
2167
+ old partitions completely.
2168
+ **kwargs : dict,
2169
+ Used as additional kwargs for :func:`pyarrow.dataset.write_dataset`
2170
+ function for matching kwargs, and remainder to
2171
+ :func:`pyarrow.dataset.ParquetFileFormat.make_write_options`.
2172
+ See the docstring of :func:`write_table` and
2173
+ :func:`pyarrow.dataset.write_dataset` for the available options.
2174
+ Using `metadata_collector` in kwargs allows one to collect the
2175
+ file metadata instances of dataset pieces. The file paths in the
2176
+ ColumnChunkMetaData will be set relative to `root_path`.
2177
+
2178
+ Examples
2179
+ --------
2180
+ Generate an example PyArrow Table:
2181
+
2182
+ >>> import pyarrow as pa
2183
+ >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
2184
+ ... 'n_legs': [2, 2, 4, 4, 5, 100],
2185
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
2186
+ ... "Brittle stars", "Centipede"]})
2187
+
2188
+ and write it to a partitioned dataset:
2189
+
2190
+ >>> import pyarrow.parquet as pq
2191
+ >>> pq.write_to_dataset(table, root_path='dataset_name_3',
2192
+ ... partition_cols=['year'])
2193
+ >>> pq.ParquetDataset('dataset_name_3').files
2194
+ ['dataset_name_3/year=2019/...-0.parquet', ...
2195
+
2196
+ Write a single Parquet file into the root folder:
2197
+
2198
+ >>> pq.write_to_dataset(table, root_path='dataset_name_4')
2199
+ >>> pq.ParquetDataset('dataset_name_4/').files
2200
+ ['dataset_name_4/...-0.parquet']
2201
+ """
2202
+ metadata_collector = kwargs.pop('metadata_collector', None)
2203
+
2204
+ # Check for conflicting keywords
2205
+ msg_confl = (
2206
+ "The '{1}' argument is not supported. "
2207
+ "Use only '{0}' instead."
2208
+ )
2209
+ if partition_cols is not None and partitioning is not None:
2210
+ raise ValueError(msg_confl.format("partitioning",
2211
+ "partition_cols"))
2212
+
2213
+ if metadata_collector is not None and file_visitor is not None:
2214
+ raise ValueError(msg_confl.format("file_visitor",
2215
+ "metadata_collector"))
2216
+
2217
+ import pyarrow.dataset as ds
2218
+
2219
+ # extract write_dataset specific options
2220
+ # reset assumed to go to make_write_options
2221
+ write_dataset_kwargs = dict()
2222
+ for key in inspect.signature(ds.write_dataset).parameters:
2223
+ if key in kwargs:
2224
+ write_dataset_kwargs[key] = kwargs.pop(key)
2225
+ write_dataset_kwargs['max_rows_per_group'] = kwargs.pop(
2226
+ 'row_group_size', kwargs.pop("chunk_size", None)
2227
+ )
2228
+
2229
+ if metadata_collector is not None:
2230
+ def file_visitor(written_file):
2231
+ metadata_collector.append(written_file.metadata)
2232
+
2233
+ # map format arguments
2234
+ parquet_format = ds.ParquetFileFormat()
2235
+ write_options = parquet_format.make_write_options(**kwargs)
2236
+
2237
+ # map old filesystems to new one
2238
+ if filesystem is not None:
2239
+ filesystem = _ensure_filesystem(filesystem)
2240
+
2241
+ if partition_cols:
2242
+ part_schema = table.select(partition_cols).schema
2243
+ partitioning = ds.partitioning(part_schema, flavor="hive")
2244
+
2245
+ if basename_template is None:
2246
+ basename_template = guid() + '-{i}.parquet'
2247
+
2248
+ if existing_data_behavior is None:
2249
+ existing_data_behavior = 'overwrite_or_ignore'
2250
+
2251
+ ds.write_dataset(
2252
+ table, root_path, filesystem=filesystem,
2253
+ format=parquet_format, file_options=write_options, schema=schema,
2254
+ partitioning=partitioning, use_threads=use_threads,
2255
+ file_visitor=file_visitor,
2256
+ basename_template=basename_template,
2257
+ existing_data_behavior=existing_data_behavior,
2258
+ **write_dataset_kwargs)
2259
+ return
2260
+
2261
+
2262
+ def write_metadata(schema, where, metadata_collector=None, filesystem=None,
2263
+ **kwargs):
2264
+ """
2265
+ Write metadata-only Parquet file from schema. This can be used with
2266
+ `write_to_dataset` to generate `_common_metadata` and `_metadata` sidecar
2267
+ files.
2268
+
2269
+ Parameters
2270
+ ----------
2271
+ schema : pyarrow.Schema
2272
+ where : string or pyarrow.NativeFile
2273
+ metadata_collector : list
2274
+ where to collect metadata information.
2275
+ filesystem : FileSystem, default None
2276
+ If nothing passed, will be inferred from `where` if path-like, else
2277
+ `where` is already a file-like object so no filesystem is needed.
2278
+ **kwargs : dict,
2279
+ Additional kwargs for ParquetWriter class. See docstring for
2280
+ `ParquetWriter` for more information.
2281
+
2282
+ Examples
2283
+ --------
2284
+ Generate example data:
2285
+
2286
+ >>> import pyarrow as pa
2287
+ >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
2288
+ ... 'animal': ["Flamingo", "Parrot", "Dog", "Horse",
2289
+ ... "Brittle stars", "Centipede"]})
2290
+
2291
+ Write a dataset and collect metadata information.
2292
+
2293
+ >>> metadata_collector = []
2294
+ >>> import pyarrow.parquet as pq
2295
+ >>> pq.write_to_dataset(
2296
+ ... table, 'dataset_metadata',
2297
+ ... metadata_collector=metadata_collector)
2298
+
2299
+ Write the `_common_metadata` parquet file without row groups statistics.
2300
+
2301
+ >>> pq.write_metadata(
2302
+ ... table.schema, 'dataset_metadata/_common_metadata')
2303
+
2304
+ Write the `_metadata` parquet file with row groups statistics.
2305
+
2306
+ >>> pq.write_metadata(
2307
+ ... table.schema, 'dataset_metadata/_metadata',
2308
+ ... metadata_collector=metadata_collector)
2309
+ """
2310
+ filesystem, where = _resolve_filesystem_and_path(where, filesystem)
2311
+
2312
+ if hasattr(where, "seek"): # file-like
2313
+ cursor_position = where.tell()
2314
+
2315
+ writer = ParquetWriter(where, schema, filesystem, **kwargs)
2316
+ writer.close()
2317
+
2318
+ if metadata_collector is not None:
2319
+ # ParquetWriter doesn't expose the metadata until it's written. Write
2320
+ # it and read it again.
2321
+ metadata = read_metadata(where, filesystem=filesystem)
2322
+ if hasattr(where, "seek"):
2323
+ where.seek(cursor_position) # file-like, set cursor back.
2324
+
2325
+ for m in metadata_collector:
2326
+ metadata.append_row_groups(m)
2327
+ if filesystem is not None:
2328
+ with filesystem.open_output_stream(where) as f:
2329
+ metadata.write_metadata_file(f)
2330
+ else:
2331
+ metadata.write_metadata_file(where)
2332
+
2333
+
2334
+ def read_metadata(where, memory_map=False, decryption_properties=None,
2335
+ filesystem=None):
2336
+ """
2337
+ Read FileMetaData from footer of a single Parquet file.
2338
+
2339
+ Parameters
2340
+ ----------
2341
+ where : str (file path) or file-like object
2342
+ memory_map : bool, default False
2343
+ Create memory map when the source is a file path.
2344
+ decryption_properties : FileDecryptionProperties, default None
2345
+ Decryption properties for reading encrypted Parquet files.
2346
+ filesystem : FileSystem, default None
2347
+ If nothing passed, will be inferred based on path.
2348
+ Path will try to be found in the local on-disk filesystem otherwise
2349
+ it will be parsed as an URI to determine the filesystem.
2350
+
2351
+ Returns
2352
+ -------
2353
+ metadata : FileMetaData
2354
+ The metadata of the Parquet file
2355
+
2356
+ Examples
2357
+ --------
2358
+ >>> import pyarrow as pa
2359
+ >>> import pyarrow.parquet as pq
2360
+ >>> table = pa.table({'n_legs': [4, 5, 100],
2361
+ ... 'animal': ["Dog", "Brittle stars", "Centipede"]})
2362
+ >>> pq.write_table(table, 'example.parquet')
2363
+
2364
+ >>> pq.read_metadata('example.parquet')
2365
+ <pyarrow._parquet.FileMetaData object at ...>
2366
+ created_by: parquet-cpp-arrow version ...
2367
+ num_columns: 2
2368
+ num_rows: 3
2369
+ num_row_groups: 1
2370
+ format_version: 2.6
2371
+ serialized_size: ...
2372
+ """
2373
+ filesystem, where = _resolve_filesystem_and_path(where, filesystem)
2374
+ file_ctx = nullcontext()
2375
+ if filesystem is not None:
2376
+ file_ctx = where = filesystem.open_input_file(where)
2377
+
2378
+ with file_ctx:
2379
+ file = ParquetFile(where, memory_map=memory_map,
2380
+ decryption_properties=decryption_properties)
2381
+ return file.metadata
2382
+
2383
+
2384
+ def read_schema(where, memory_map=False, decryption_properties=None,
2385
+ filesystem=None):
2386
+ """
2387
+ Read effective Arrow schema from Parquet file metadata.
2388
+
2389
+ Parameters
2390
+ ----------
2391
+ where : str (file path) or file-like object
2392
+ memory_map : bool, default False
2393
+ Create memory map when the source is a file path.
2394
+ decryption_properties : FileDecryptionProperties, default None
2395
+ Decryption properties for reading encrypted Parquet files.
2396
+ filesystem : FileSystem, default None
2397
+ If nothing passed, will be inferred based on path.
2398
+ Path will try to be found in the local on-disk filesystem otherwise
2399
+ it will be parsed as an URI to determine the filesystem.
2400
+
2401
+ Returns
2402
+ -------
2403
+ schema : pyarrow.Schema
2404
+ The schema of the Parquet file
2405
+
2406
+ Examples
2407
+ --------
2408
+ >>> import pyarrow as pa
2409
+ >>> import pyarrow.parquet as pq
2410
+ >>> table = pa.table({'n_legs': [4, 5, 100],
2411
+ ... 'animal': ["Dog", "Brittle stars", "Centipede"]})
2412
+ >>> pq.write_table(table, 'example.parquet')
2413
+
2414
+ >>> pq.read_schema('example.parquet')
2415
+ n_legs: int64
2416
+ animal: string
2417
+ """
2418
+ filesystem, where = _resolve_filesystem_and_path(where, filesystem)
2419
+ file_ctx = nullcontext()
2420
+ if filesystem is not None:
2421
+ file_ctx = where = filesystem.open_input_file(where)
2422
+
2423
+ with file_ctx:
2424
+ file = ParquetFile(
2425
+ where, memory_map=memory_map,
2426
+ decryption_properties=decryption_properties)
2427
+ return file.schema.to_arrow_schema()
2428
+
2429
+
2430
+ __all__ = (
2431
+ "ColumnChunkMetaData",
2432
+ "ColumnSchema",
2433
+ "FileDecryptionProperties",
2434
+ "FileEncryptionProperties",
2435
+ "FileMetaData",
2436
+ "ParquetDataset",
2437
+ "ParquetFile",
2438
+ "ParquetLogicalType",
2439
+ "ParquetReader",
2440
+ "ParquetSchema",
2441
+ "ParquetWriter",
2442
+ "RowGroupMetaData",
2443
+ "SortingColumn",
2444
+ "Statistics",
2445
+ "read_metadata",
2446
+ "read_pandas",
2447
+ "read_schema",
2448
+ "read_table",
2449
+ "write_metadata",
2450
+ "write_table",
2451
+ "write_to_dataset",
2452
+ "_filters_to_expression",
2453
+ "filters_to_expression",
2454
+ )
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/parquet/encryption.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pylint: disable=unused-wildcard-import, unused-import
2
+
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ from pyarrow._parquet_encryption import (CryptoFactory, # noqa
20
+ EncryptionConfiguration,
21
+ DecryptionConfiguration,
22
+ KmsConnectionConfig,
23
+ KmsClient)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/CMakeLists.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ arrow_install_all_headers("arrow/python")
19
+ add_subdirectory(vendored)
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/api.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include "arrow/python/arrow_to_pandas.h"
21
+ #include "arrow/python/common.h"
22
+ #include "arrow/python/datetime.h"
23
+ #include "arrow/python/helpers.h"
24
+ #include "arrow/python/inference.h"
25
+ #include "arrow/python/io.h"
26
+ #include "arrow/python/numpy_convert.h"
27
+ #include "arrow/python/numpy_to_arrow.h"
28
+ #include "arrow/python/python_to_arrow.h"
29
+ #include "arrow/python/util.h"
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/arrow_to_pandas.cc ADDED
@@ -0,0 +1,2659 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 pandas conversion via NumPy
19
+
20
+ #include "arrow/python/arrow_to_pandas.h"
21
+ #include "arrow/python/numpy_interop.h" // IWYU pragma: expand
22
+
23
+ #include <cmath>
24
+ #include <cstdint>
25
+ #include <iostream>
26
+ #include <memory>
27
+ #include <mutex>
28
+ #include <string>
29
+ #include <string_view>
30
+ #include <unordered_map>
31
+ #include <utility>
32
+ #include <vector>
33
+
34
+ #include "arrow/array.h"
35
+ #include "arrow/buffer.h"
36
+ #include "arrow/datum.h"
37
+ #include "arrow/status.h"
38
+ #include "arrow/table.h"
39
+ #include "arrow/type.h"
40
+ #include "arrow/type_traits.h"
41
+ #include "arrow/util/checked_cast.h"
42
+ #include "arrow/util/hashing.h"
43
+ #include "arrow/util/int_util.h"
44
+ #include "arrow/util/logging.h"
45
+ #include "arrow/util/macros.h"
46
+ #include "arrow/util/parallel.h"
47
+ #include "arrow/visit_type_inline.h"
48
+
49
+ #include "arrow/compute/api.h"
50
+
51
+ #include "arrow/python/arrow_to_python_internal.h"
52
+ #include "arrow/python/common.h"
53
+ #include "arrow/python/datetime.h"
54
+ #include "arrow/python/decimal.h"
55
+ #include "arrow/python/helpers.h"
56
+ #include "arrow/python/numpy_convert.h"
57
+ #include "arrow/python/numpy_internal.h"
58
+ #include "arrow/python/pyarrow.h"
59
+ #include "arrow/python/python_to_arrow.h"
60
+ #include "arrow/python/type_traits.h"
61
+
62
+ namespace arrow {
63
+
64
+ class MemoryPool;
65
+
66
+ using internal::checked_cast;
67
+ using internal::CheckIndexBounds;
68
+ using internal::OptionalParallelFor;
69
+
70
+ namespace py {
71
+ namespace {
72
+
73
+ // Fix options for conversion of an inner (child) array.
74
+ PandasOptions MakeInnerOptions(PandasOptions options) {
75
+ // Make sure conversion of inner dictionary arrays always returns an array,
76
+ // not a dict {'indices': array, 'dictionary': array, 'ordered': bool}
77
+ options.decode_dictionaries = true;
78
+ options.categorical_columns.reset();
79
+ options.strings_to_categorical = false;
80
+
81
+ // In ARROW-7723, we found as a result of ARROW-3789 that second
82
+ // through microsecond resolution tz-aware timestamps were being promoted to
83
+ // use the DATETIME_NANO_TZ conversion path, yielding a datetime64[ns] NumPy
84
+ // array in this function. PyArray_GETITEM returns datetime.datetime for
85
+ // units second through microsecond but PyLong for nanosecond (because
86
+ // datetime.datetime does not support nanoseconds).
87
+ // We force the object conversion to preserve the value of the timezone.
88
+ // Nanoseconds are returned as integers.
89
+ options.coerce_temporal_nanoseconds = false;
90
+
91
+ return options;
92
+ }
93
+
94
+ // ----------------------------------------------------------------------
95
+ // PyCapsule code for setting ndarray base to reference C++ object
96
+
97
+ struct ArrayCapsule {
98
+ std::shared_ptr<Array> array;
99
+ };
100
+
101
+ struct BufferCapsule {
102
+ std::shared_ptr<Buffer> buffer;
103
+ };
104
+
105
+ void ArrayCapsule_Destructor(PyObject* capsule) {
106
+ delete reinterpret_cast<ArrayCapsule*>(PyCapsule_GetPointer(capsule, "arrow::Array"));
107
+ }
108
+
109
+ void BufferCapsule_Destructor(PyObject* capsule) {
110
+ delete reinterpret_cast<BufferCapsule*>(PyCapsule_GetPointer(capsule, "arrow::Buffer"));
111
+ }
112
+
113
+ // ----------------------------------------------------------------------
114
+ // pandas 0.x DataFrame conversion internals
115
+
116
+ using internal::arrow_traits;
117
+ using internal::npy_traits;
118
+
119
+ template <typename T>
120
+ struct WrapBytes {};
121
+
122
+ template <>
123
+ struct WrapBytes<StringType> {
124
+ static inline PyObject* Wrap(const char* data, int64_t length) {
125
+ return PyUnicode_FromStringAndSize(data, length);
126
+ }
127
+ };
128
+
129
+ template <>
130
+ struct WrapBytes<LargeStringType> {
131
+ static inline PyObject* Wrap(const char* data, int64_t length) {
132
+ return PyUnicode_FromStringAndSize(data, length);
133
+ }
134
+ };
135
+
136
+ template <>
137
+ struct WrapBytes<StringViewType> {
138
+ static inline PyObject* Wrap(const char* data, int64_t length) {
139
+ return PyUnicode_FromStringAndSize(data, length);
140
+ }
141
+ };
142
+
143
+ template <>
144
+ struct WrapBytes<BinaryType> {
145
+ static inline PyObject* Wrap(const char* data, int64_t length) {
146
+ return PyBytes_FromStringAndSize(data, length);
147
+ }
148
+ };
149
+
150
+ template <>
151
+ struct WrapBytes<LargeBinaryType> {
152
+ static inline PyObject* Wrap(const char* data, int64_t length) {
153
+ return PyBytes_FromStringAndSize(data, length);
154
+ }
155
+ };
156
+
157
+ template <>
158
+ struct WrapBytes<BinaryViewType> {
159
+ static inline PyObject* Wrap(const char* data, int64_t length) {
160
+ return PyBytes_FromStringAndSize(data, length);
161
+ }
162
+ };
163
+
164
+ template <>
165
+ struct WrapBytes<FixedSizeBinaryType> {
166
+ static inline PyObject* Wrap(const char* data, int64_t length) {
167
+ return PyBytes_FromStringAndSize(data, length);
168
+ }
169
+ };
170
+
171
+ static inline bool ListTypeSupported(const DataType& type) {
172
+ switch (type.id()) {
173
+ case Type::BOOL:
174
+ case Type::UINT8:
175
+ case Type::INT8:
176
+ case Type::UINT16:
177
+ case Type::INT16:
178
+ case Type::UINT32:
179
+ case Type::INT32:
180
+ case Type::INT64:
181
+ case Type::UINT64:
182
+ case Type::HALF_FLOAT:
183
+ case Type::FLOAT:
184
+ case Type::DOUBLE:
185
+ case Type::DECIMAL128:
186
+ case Type::DECIMAL256:
187
+ case Type::BINARY:
188
+ case Type::LARGE_BINARY:
189
+ case Type::STRING:
190
+ case Type::LARGE_STRING:
191
+ case Type::DATE32:
192
+ case Type::DATE64:
193
+ case Type::STRUCT:
194
+ case Type::MAP:
195
+ case Type::TIME32:
196
+ case Type::TIME64:
197
+ case Type::TIMESTAMP:
198
+ case Type::DURATION:
199
+ case Type::DICTIONARY:
200
+ case Type::INTERVAL_MONTH_DAY_NANO:
201
+ case Type::NA: // empty list
202
+ // The above types are all supported.
203
+ return true;
204
+ case Type::FIXED_SIZE_LIST:
205
+ case Type::LIST:
206
+ case Type::LARGE_LIST:
207
+ case Type::LIST_VIEW:
208
+ case Type::LARGE_LIST_VIEW: {
209
+ const auto& list_type = checked_cast<const BaseListType&>(type);
210
+ return ListTypeSupported(*list_type.value_type());
211
+ }
212
+ case Type::EXTENSION: {
213
+ const auto& ext = checked_cast<const ExtensionType&>(*type.GetSharedPtr());
214
+ return ListTypeSupported(*(ext.storage_type()));
215
+ }
216
+ default:
217
+ break;
218
+ }
219
+ return false;
220
+ }
221
+
222
+ Status CapsulizeArray(const std::shared_ptr<Array>& arr, PyObject** out) {
223
+ auto capsule = new ArrayCapsule{{arr}};
224
+ *out = PyCapsule_New(reinterpret_cast<void*>(capsule), "arrow::Array",
225
+ &ArrayCapsule_Destructor);
226
+ if (*out == nullptr) {
227
+ delete capsule;
228
+ RETURN_IF_PYERROR();
229
+ }
230
+ return Status::OK();
231
+ }
232
+
233
+ Status CapsulizeBuffer(const std::shared_ptr<Buffer>& buffer, PyObject** out) {
234
+ auto capsule = new BufferCapsule{{buffer}};
235
+ *out = PyCapsule_New(reinterpret_cast<void*>(capsule), "arrow::Buffer",
236
+ &BufferCapsule_Destructor);
237
+ if (*out == nullptr) {
238
+ delete capsule;
239
+ RETURN_IF_PYERROR();
240
+ }
241
+ return Status::OK();
242
+ }
243
+
244
+ Status SetNdarrayBase(PyArrayObject* arr, PyObject* base) {
245
+ if (PyArray_SetBaseObject(arr, base) == -1) {
246
+ // Error occurred, trust that SetBaseObject sets the error state
247
+ Py_XDECREF(base);
248
+ RETURN_IF_PYERROR();
249
+ }
250
+ return Status::OK();
251
+ }
252
+
253
+ Status SetBufferBase(PyArrayObject* arr, const std::shared_ptr<Buffer>& buffer) {
254
+ PyObject* base;
255
+ RETURN_NOT_OK(CapsulizeBuffer(buffer, &base));
256
+ return SetNdarrayBase(arr, base);
257
+ }
258
+
259
+ inline void set_numpy_metadata(int type, const DataType* datatype, PyArray_Descr* out) {
260
+ auto metadata =
261
+ reinterpret_cast<PyArray_DatetimeDTypeMetaData*>(PyDataType_C_METADATA(out));
262
+ if (type == NPY_DATETIME) {
263
+ if (datatype->id() == Type::TIMESTAMP) {
264
+ const auto& timestamp_type = checked_cast<const TimestampType&>(*datatype);
265
+ metadata->meta.base = internal::NumPyFrequency(timestamp_type.unit());
266
+ } else {
267
+ ARROW_DCHECK(false)
268
+ << "NPY_DATETIME views only supported for Arrow TIMESTAMP types";
269
+ }
270
+ } else if (type == NPY_TIMEDELTA) {
271
+ ARROW_DCHECK_EQ(datatype->id(), Type::DURATION);
272
+ const auto& duration_type = checked_cast<const DurationType&>(*datatype);
273
+ metadata->meta.base = internal::NumPyFrequency(duration_type.unit());
274
+ }
275
+ }
276
+
277
+ Status PyArray_NewFromPool(int nd, npy_intp* dims, PyArray_Descr* descr, MemoryPool* pool,
278
+ PyObject** out) {
279
+ // ARROW-6570: Allocate memory from MemoryPool for a couple reasons
280
+ //
281
+ // * Track allocations
282
+ // * Get better performance through custom allocators
283
+ int64_t total_size = PyDataType_ELSIZE(descr);
284
+ for (int i = 0; i < nd; ++i) {
285
+ total_size *= dims[i];
286
+ }
287
+
288
+ ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(total_size, pool));
289
+ *out = PyArray_NewFromDescr(&PyArray_Type, descr, nd, dims,
290
+ /*strides=*/nullptr,
291
+ /*data=*/buffer->mutable_data(),
292
+ /*flags=*/NPY_ARRAY_CARRAY | NPY_ARRAY_WRITEABLE,
293
+ /*obj=*/nullptr);
294
+ if (*out == nullptr) {
295
+ RETURN_IF_PYERROR();
296
+ // Trust that error set if NULL returned
297
+ }
298
+ return SetBufferBase(reinterpret_cast<PyArrayObject*>(*out), std::move(buffer));
299
+ }
300
+
301
+ template <typename T = void>
302
+ inline const T* GetPrimitiveValues(const Array& arr) {
303
+ if (arr.length() == 0) {
304
+ return nullptr;
305
+ }
306
+ const int elsize = arr.type()->byte_width();
307
+ const auto& prim_arr = checked_cast<const PrimitiveArray&>(arr);
308
+ return reinterpret_cast<const T*>(prim_arr.values()->data() + arr.offset() * elsize);
309
+ }
310
+
311
+ Status MakeNumPyView(std::shared_ptr<Array> arr, PyObject* py_ref, int npy_type, int ndim,
312
+ npy_intp* dims, PyObject** out) {
313
+ PyAcquireGIL lock;
314
+
315
+ PyArray_Descr* descr = internal::GetSafeNumPyDtype(npy_type);
316
+ set_numpy_metadata(npy_type, arr->type().get(), descr);
317
+ PyObject* result = PyArray_NewFromDescr(
318
+ &PyArray_Type, descr, ndim, dims, /*strides=*/nullptr,
319
+ const_cast<void*>(GetPrimitiveValues(*arr)), /*flags=*/0, nullptr);
320
+ PyArrayObject* np_arr = reinterpret_cast<PyArrayObject*>(result);
321
+ if (np_arr == nullptr) {
322
+ // Error occurred, trust that error set
323
+ return Status::OK();
324
+ }
325
+
326
+ PyObject* base;
327
+ if (py_ref == nullptr) {
328
+ // Capsule will be owned by the ndarray, no incref necessary. See
329
+ // ARROW-1973
330
+ RETURN_NOT_OK(CapsulizeArray(arr, &base));
331
+ } else {
332
+ Py_INCREF(py_ref);
333
+ base = py_ref;
334
+ }
335
+ RETURN_NOT_OK(SetNdarrayBase(np_arr, base));
336
+
337
+ // Do not allow Arrow data to be mutated
338
+ PyArray_CLEARFLAGS(np_arr, NPY_ARRAY_WRITEABLE);
339
+ *out = result;
340
+ return Status::OK();
341
+ }
342
+
343
+ class PandasWriter {
344
+ public:
345
+ enum type {
346
+ OBJECT,
347
+ UINT8,
348
+ INT8,
349
+ UINT16,
350
+ INT16,
351
+ UINT32,
352
+ INT32,
353
+ UINT64,
354
+ INT64,
355
+ HALF_FLOAT,
356
+ FLOAT,
357
+ DOUBLE,
358
+ BOOL,
359
+ DATETIME_DAY,
360
+ DATETIME_SECOND,
361
+ DATETIME_MILLI,
362
+ DATETIME_MICRO,
363
+ DATETIME_NANO,
364
+ DATETIME_SECOND_TZ,
365
+ DATETIME_MILLI_TZ,
366
+ DATETIME_MICRO_TZ,
367
+ DATETIME_NANO_TZ,
368
+ TIMEDELTA_SECOND,
369
+ TIMEDELTA_MILLI,
370
+ TIMEDELTA_MICRO,
371
+ TIMEDELTA_NANO,
372
+ CATEGORICAL,
373
+ EXTENSION
374
+ };
375
+
376
+ PandasWriter(const PandasOptions& options, int64_t num_rows, int num_columns)
377
+ : options_(options), num_rows_(num_rows), num_columns_(num_columns) {
378
+ PyAcquireGIL lock;
379
+ internal::InitPandasStaticData();
380
+ }
381
+ virtual ~PandasWriter() {}
382
+
383
+ void SetBlockData(PyObject* arr) {
384
+ block_arr_.reset(arr);
385
+ block_data_ =
386
+ reinterpret_cast<uint8_t*>(PyArray_DATA(reinterpret_cast<PyArrayObject*>(arr)));
387
+ }
388
+
389
+ /// \brief Either copy or wrap single array to create pandas-compatible array
390
+ /// for Series or DataFrame. num_columns_ can only be 1. Will try to zero
391
+ /// copy if possible (or error if not possible and zero_copy_only=True)
392
+ virtual Status TransferSingle(std::shared_ptr<ChunkedArray> data, PyObject* py_ref) = 0;
393
+
394
+ /// \brief Copy ChunkedArray into a multi-column block
395
+ virtual Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) = 0;
396
+
397
+ Status EnsurePlacementAllocated() {
398
+ std::lock_guard<std::mutex> guard(allocation_lock_);
399
+ if (placement_data_ != nullptr) {
400
+ return Status::OK();
401
+ }
402
+ PyAcquireGIL lock;
403
+ npy_intp placement_dims[1] = {num_columns_};
404
+ PyObject* placement_arr = PyArray_SimpleNew(1, placement_dims, NPY_INT64);
405
+ RETURN_IF_PYERROR();
406
+ placement_arr_.reset(placement_arr);
407
+ placement_data_ = reinterpret_cast<int64_t*>(
408
+ PyArray_DATA(reinterpret_cast<PyArrayObject*>(placement_arr)));
409
+ return Status::OK();
410
+ }
411
+
412
+ Status EnsureAllocated() {
413
+ std::lock_guard<std::mutex> guard(allocation_lock_);
414
+ if (block_data_ != nullptr) {
415
+ return Status::OK();
416
+ }
417
+ RETURN_NOT_OK(Allocate());
418
+ return Status::OK();
419
+ }
420
+
421
+ virtual bool CanZeroCopy(const ChunkedArray& data) const { return false; }
422
+
423
+ virtual Status Write(std::shared_ptr<ChunkedArray> data, int64_t abs_placement,
424
+ int64_t rel_placement) {
425
+ RETURN_NOT_OK(EnsurePlacementAllocated());
426
+ if (num_columns_ == 1 && options_.allow_zero_copy_blocks) {
427
+ RETURN_NOT_OK(TransferSingle(data, /*py_ref=*/nullptr));
428
+ } else {
429
+ RETURN_NOT_OK(
430
+ CheckNoZeroCopy("Cannot do zero copy conversion into "
431
+ "multi-column DataFrame block"));
432
+ RETURN_NOT_OK(EnsureAllocated());
433
+ RETURN_NOT_OK(CopyInto(data, rel_placement));
434
+ }
435
+ placement_data_[rel_placement] = abs_placement;
436
+ return Status::OK();
437
+ }
438
+
439
+ virtual Status GetDataFrameResult(PyObject** out) {
440
+ PyObject* result = PyDict_New();
441
+ RETURN_IF_PYERROR();
442
+
443
+ PyObject* block;
444
+ RETURN_NOT_OK(GetResultBlock(&block));
445
+
446
+ PyDict_SetItemString(result, "block", block);
447
+ PyDict_SetItemString(result, "placement", placement_arr_.obj());
448
+
449
+ RETURN_NOT_OK(AddResultMetadata(result));
450
+ *out = result;
451
+ return Status::OK();
452
+ }
453
+
454
+ // Caller steals the reference to this object
455
+ virtual Status GetSeriesResult(PyObject** out) {
456
+ RETURN_NOT_OK(MakeBlock1D());
457
+ // Caller owns the object now
458
+ *out = block_arr_.detach();
459
+ return Status::OK();
460
+ }
461
+
462
+ protected:
463
+ virtual Status AddResultMetadata(PyObject* result) { return Status::OK(); }
464
+
465
+ Status MakeBlock1D() {
466
+ // For Series or for certain DataFrame block types, we need to shape to a
467
+ // 1D array when there is only one column
468
+ PyAcquireGIL lock;
469
+
470
+ ARROW_DCHECK_EQ(1, num_columns_);
471
+
472
+ npy_intp new_dims[1] = {static_cast<npy_intp>(num_rows_)};
473
+ PyArray_Dims dims;
474
+ dims.ptr = new_dims;
475
+ dims.len = 1;
476
+
477
+ PyObject* reshaped = PyArray_Newshape(
478
+ reinterpret_cast<PyArrayObject*>(block_arr_.obj()), &dims, NPY_ANYORDER);
479
+ RETURN_IF_PYERROR();
480
+
481
+ // ARROW-8801: Here a PyArrayObject is created that is not being managed by
482
+ // any OwnedRef object. This object is then put in the resulting object
483
+ // with PyDict_SetItemString, which increments the reference count, so a
484
+ // memory leak ensues. There are several ways to fix the memory leak but a
485
+ // simple one is to put the reshaped 1D block array in this OwnedRefNoGIL
486
+ // so it will be correctly decref'd when this class is destructed.
487
+ block_arr_.reset(reshaped);
488
+ return Status::OK();
489
+ }
490
+
491
+ virtual Status GetResultBlock(PyObject** out) {
492
+ *out = block_arr_.obj();
493
+ return Status::OK();
494
+ }
495
+
496
+ Status CheckNoZeroCopy(const std::string& message) {
497
+ if (options_.zero_copy_only) {
498
+ return Status::Invalid(message);
499
+ }
500
+ return Status::OK();
501
+ }
502
+
503
+ Status CheckNotZeroCopyOnly(const ChunkedArray& data) {
504
+ if (options_.zero_copy_only) {
505
+ return Status::Invalid("Needed to copy ", data.num_chunks(), " chunks with ",
506
+ data.null_count(), " nulls, but zero_copy_only was True");
507
+ }
508
+ return Status::OK();
509
+ }
510
+
511
+ virtual Status Allocate() {
512
+ return Status::NotImplemented("Override Allocate in subclasses");
513
+ }
514
+
515
+ Status AllocateNDArray(int npy_type, int ndim = 2) {
516
+ PyAcquireGIL lock;
517
+
518
+ PyObject* block_arr = nullptr;
519
+ npy_intp block_dims[2] = {0, 0};
520
+
521
+ if (ndim == 2) {
522
+ block_dims[0] = num_columns_;
523
+ block_dims[1] = num_rows_;
524
+ } else {
525
+ block_dims[0] = num_rows_;
526
+ }
527
+ PyArray_Descr* descr = internal::GetSafeNumPyDtype(npy_type);
528
+ if (PyDataType_REFCHK(descr)) {
529
+ // ARROW-6876: if the array has refcounted items, let Numpy
530
+ // own the array memory so as to decref elements on array destruction
531
+ block_arr = PyArray_SimpleNewFromDescr(ndim, block_dims, descr);
532
+ RETURN_IF_PYERROR();
533
+ } else {
534
+ RETURN_NOT_OK(
535
+ PyArray_NewFromPool(ndim, block_dims, descr, options_.pool, &block_arr));
536
+ }
537
+
538
+ SetBlockData(block_arr);
539
+ return Status::OK();
540
+ }
541
+
542
+ void SetDatetimeUnit(NPY_DATETIMEUNIT unit) {
543
+ PyAcquireGIL lock;
544
+ auto date_dtype =
545
+ reinterpret_cast<PyArray_DatetimeDTypeMetaData*>(PyDataType_C_METADATA(
546
+ PyArray_DESCR(reinterpret_cast<PyArrayObject*>(block_arr_.obj()))));
547
+ date_dtype->meta.base = unit;
548
+ }
549
+
550
+ PandasOptions options_;
551
+
552
+ std::mutex allocation_lock_;
553
+
554
+ int64_t num_rows_;
555
+ int num_columns_;
556
+
557
+ OwnedRefNoGIL block_arr_;
558
+ uint8_t* block_data_ = nullptr;
559
+
560
+ // ndarray<int32>
561
+ OwnedRefNoGIL placement_arr_;
562
+ int64_t* placement_data_ = nullptr;
563
+
564
+ private:
565
+ ARROW_DISALLOW_COPY_AND_ASSIGN(PandasWriter);
566
+ };
567
+
568
+ template <typename InType, typename OutType>
569
+ inline void ConvertIntegerWithNulls(const PandasOptions& options,
570
+ const ChunkedArray& data, OutType* out_values) {
571
+ for (int c = 0; c < data.num_chunks(); c++) {
572
+ const auto& arr = *data.chunk(c);
573
+ const InType* in_values = GetPrimitiveValues<InType>(arr);
574
+ // Upcast to double, set NaN as appropriate
575
+
576
+ for (int i = 0; i < arr.length(); ++i) {
577
+ *out_values++ =
578
+ arr.IsNull(i) ? static_cast<OutType>(NAN) : static_cast<OutType>(in_values[i]);
579
+ }
580
+ }
581
+ }
582
+
583
+ template <typename T>
584
+ inline void ConvertIntegerNoNullsSameType(const PandasOptions& options,
585
+ const ChunkedArray& data, T* out_values) {
586
+ for (int c = 0; c < data.num_chunks(); c++) {
587
+ const auto& arr = *data.chunk(c);
588
+ if (arr.length() > 0) {
589
+ const T* in_values = GetPrimitiveValues<T>(arr);
590
+ memcpy(out_values, in_values, sizeof(T) * arr.length());
591
+ out_values += arr.length();
592
+ }
593
+ }
594
+ }
595
+
596
+ template <typename InType, typename OutType>
597
+ inline void ConvertIntegerNoNullsCast(const PandasOptions& options,
598
+ const ChunkedArray& data, OutType* out_values) {
599
+ for (int c = 0; c < data.num_chunks(); c++) {
600
+ const auto& arr = *data.chunk(c);
601
+ const InType* in_values = GetPrimitiveValues<InType>(arr);
602
+ for (int64_t i = 0; i < arr.length(); ++i) {
603
+ *out_values = in_values[i];
604
+ }
605
+ }
606
+ }
607
+
608
+ template <typename T, typename Enable = void>
609
+ struct MemoizationTraits {
610
+ using Scalar = typename T::c_type;
611
+ };
612
+
613
+ template <typename T>
614
+ struct MemoizationTraits<T, enable_if_has_string_view<T>> {
615
+ // For binary, we memoize string_view as a scalar value to avoid having to
616
+ // unnecessarily copy the memory into the memo table data structure
617
+ using Scalar = std::string_view;
618
+ };
619
+
620
+ // Generic Array -> PyObject** converter that handles object deduplication, if
621
+ // requested
622
+ template <typename Type, typename WrapFunction>
623
+ inline Status ConvertAsPyObjects(const PandasOptions& options, const ChunkedArray& data,
624
+ WrapFunction&& wrap_func, PyObject** out_values) {
625
+ using ArrayType = typename TypeTraits<Type>::ArrayType;
626
+ using Scalar = typename MemoizationTraits<Type>::Scalar;
627
+
628
+ auto convert_chunks = [&](auto&& wrap_func) -> Status {
629
+ for (int c = 0; c < data.num_chunks(); c++) {
630
+ const auto& arr = arrow::internal::checked_cast<const ArrayType&>(*data.chunk(c));
631
+ RETURN_NOT_OK(internal::WriteArrayObjects(arr, wrap_func, out_values));
632
+ out_values += arr.length();
633
+ }
634
+ return Status::OK();
635
+ };
636
+
637
+ if (options.deduplicate_objects) {
638
+ // GH-40316: only allocate a memo table if deduplication is enabled.
639
+ ::arrow::internal::ScalarMemoTable<Scalar> memo_table(options.pool);
640
+ std::vector<PyObject*> unique_values;
641
+ int32_t memo_size = 0;
642
+
643
+ auto WrapMemoized = [&](const Scalar& value, PyObject** out_values) {
644
+ int32_t memo_index;
645
+ RETURN_NOT_OK(memo_table.GetOrInsert(value, &memo_index));
646
+ if (memo_index == memo_size) {
647
+ // New entry
648
+ RETURN_NOT_OK(wrap_func(value, out_values));
649
+ unique_values.push_back(*out_values);
650
+ ++memo_size;
651
+ } else {
652
+ // Duplicate entry
653
+ Py_INCREF(unique_values[memo_index]);
654
+ *out_values = unique_values[memo_index];
655
+ }
656
+ return Status::OK();
657
+ };
658
+ return convert_chunks(std::move(WrapMemoized));
659
+ } else {
660
+ return convert_chunks(std::forward<WrapFunction>(wrap_func));
661
+ }
662
+ }
663
+
664
+ Status ConvertStruct(PandasOptions options, const ChunkedArray& data,
665
+ PyObject** out_values) {
666
+ if (data.num_chunks() == 0) {
667
+ return Status::OK();
668
+ }
669
+ // ChunkedArray has at least one chunk
670
+ auto arr = checked_cast<const StructArray*>(data.chunk(0).get());
671
+ // Use it to cache the struct type and number of fields for all chunks
672
+ int32_t num_fields = arr->num_fields();
673
+ auto array_type = arr->type();
674
+ std::vector<OwnedRef> fields_data(num_fields * data.num_chunks());
675
+ OwnedRef dict_item;
676
+
677
+ // See notes in MakeInnerOptions.
678
+ options = MakeInnerOptions(std::move(options));
679
+ // Don't blindly convert because timestamps in lists are handled differently.
680
+ options.timestamp_as_object = true;
681
+
682
+ for (int c = 0; c < data.num_chunks(); c++) {
683
+ auto fields_data_offset = c * num_fields;
684
+ auto arr = checked_cast<const StructArray*>(data.chunk(c).get());
685
+ // Convert the struct arrays first
686
+ for (int32_t i = 0; i < num_fields; i++) {
687
+ auto field = arr->field(static_cast<int>(i));
688
+ // In case the field is an extension array, use .storage() to convert to Pandas
689
+ if (field->type()->id() == Type::EXTENSION) {
690
+ const ExtensionArray& arr_ext = checked_cast<const ExtensionArray&>(*field);
691
+ field = arr_ext.storage();
692
+ }
693
+ RETURN_NOT_OK(ConvertArrayToPandas(options, field, nullptr,
694
+ fields_data[i + fields_data_offset].ref()));
695
+ ARROW_DCHECK(PyArray_Check(fields_data[i + fields_data_offset].obj()));
696
+ }
697
+
698
+ // Construct a dictionary for each row
699
+ const bool has_nulls = data.null_count() > 0;
700
+ for (int64_t i = 0; i < arr->length(); ++i) {
701
+ if (has_nulls && arr->IsNull(i)) {
702
+ Py_INCREF(Py_None);
703
+ *out_values = Py_None;
704
+ } else {
705
+ // Build the new dict object for the row
706
+ dict_item.reset(PyDict_New());
707
+ RETURN_IF_PYERROR();
708
+ for (int32_t field_idx = 0; field_idx < num_fields; ++field_idx) {
709
+ OwnedRef field_value;
710
+ auto name = array_type->field(static_cast<int>(field_idx))->name();
711
+ if (!arr->field(static_cast<int>(field_idx))->IsNull(i)) {
712
+ // Value exists in child array, obtain it
713
+ auto array = reinterpret_cast<PyArrayObject*>(
714
+ fields_data[field_idx + fields_data_offset].obj());
715
+ auto ptr = reinterpret_cast<const char*>(PyArray_GETPTR1(array, i));
716
+ field_value.reset(PyArray_GETITEM(array, ptr));
717
+ RETURN_IF_PYERROR();
718
+ } else {
719
+ // Translate the Null to a None
720
+ Py_INCREF(Py_None);
721
+ field_value.reset(Py_None);
722
+ }
723
+ // PyDict_SetItemString increments reference count
724
+ auto setitem_result =
725
+ PyDict_SetItemString(dict_item.obj(), name.c_str(), field_value.obj());
726
+ RETURN_IF_PYERROR();
727
+ ARROW_DCHECK_EQ(setitem_result, 0);
728
+ }
729
+ *out_values = dict_item.obj();
730
+ // Grant ownership to the resulting array
731
+ Py_INCREF(*out_values);
732
+ }
733
+ ++out_values;
734
+ }
735
+ }
736
+ return Status::OK();
737
+ }
738
+
739
+ Status DecodeDictionaries(MemoryPool* pool, const std::shared_ptr<DataType>& dense_type,
740
+ ArrayVector* arrays) {
741
+ compute::ExecContext ctx(pool);
742
+ compute::CastOptions options;
743
+ for (size_t i = 0; i < arrays->size(); ++i) {
744
+ ARROW_ASSIGN_OR_RAISE((*arrays)[i],
745
+ compute::Cast(*(*arrays)[i], dense_type, options, &ctx));
746
+ }
747
+ return Status::OK();
748
+ }
749
+
750
+ Status DecodeDictionaries(MemoryPool* pool, const std::shared_ptr<DataType>& dense_type,
751
+ std::shared_ptr<ChunkedArray>* array) {
752
+ auto chunks = (*array)->chunks();
753
+ RETURN_NOT_OK(DecodeDictionaries(pool, dense_type, &chunks));
754
+ *array = std::make_shared<ChunkedArray>(std::move(chunks), dense_type);
755
+ return Status::OK();
756
+ }
757
+
758
+ template <typename T>
759
+ enable_if_list_like<T, Status> ConvertListsLike(PandasOptions options,
760
+ const ChunkedArray& data,
761
+ PyObject** out_values) {
762
+ using ListArrayT = typename TypeTraits<T>::ArrayType;
763
+ // Get column of underlying value arrays
764
+ ArrayVector value_arrays;
765
+ for (int c = 0; c < data.num_chunks(); c++) {
766
+ const auto& arr = checked_cast<const ListArrayT&>(*data.chunk(c));
767
+ // values() does not account for offsets, so we need to slice into it.
768
+ // We can't use Flatten(), because it removes the values behind a null list
769
+ // value, and that makes the offsets into original list values and our
770
+ // flattened_values array different.
771
+ std::shared_ptr<Array> flattened_values = arr.values()->Slice(
772
+ arr.value_offset(0), arr.value_offset(arr.length()) - arr.value_offset(0));
773
+ if (arr.value_type()->id() == Type::EXTENSION) {
774
+ const auto& arr_ext = checked_cast<const ExtensionArray&>(*flattened_values);
775
+ value_arrays.emplace_back(arr_ext.storage());
776
+ } else {
777
+ value_arrays.emplace_back(flattened_values);
778
+ }
779
+ }
780
+
781
+ using ListArrayType = typename ListArrayT::TypeClass;
782
+ const auto& list_type = checked_cast<const ListArrayType&>(*data.type());
783
+ auto value_type = list_type.value_type();
784
+ if (value_type->id() == Type::EXTENSION) {
785
+ value_type = checked_cast<const ExtensionType&>(*value_type).storage_type();
786
+ }
787
+
788
+ auto flat_column = std::make_shared<ChunkedArray>(value_arrays, value_type);
789
+
790
+ options = MakeInnerOptions(std::move(options));
791
+
792
+ OwnedRefNoGIL owned_numpy_array;
793
+ RETURN_NOT_OK(ConvertChunkedArrayToPandas(options, flat_column, nullptr,
794
+ owned_numpy_array.ref()));
795
+ PyObject* numpy_array = owned_numpy_array.obj();
796
+ ARROW_DCHECK(PyArray_Check(numpy_array));
797
+
798
+ int64_t chunk_offset = 0;
799
+ for (int c = 0; c < data.num_chunks(); c++) {
800
+ const auto& arr = checked_cast<const ListArrayT&>(*data.chunk(c));
801
+ const bool has_nulls = data.null_count() > 0;
802
+ for (int64_t i = 0; i < arr.length(); ++i) {
803
+ if (has_nulls && arr.IsNull(i)) {
804
+ Py_INCREF(Py_None);
805
+ *out_values = Py_None;
806
+ } else {
807
+ // Need to subtract value_offset(0) since the original chunk might be a slice
808
+ // into another array.
809
+ OwnedRef start(PyLong_FromLongLong(arr.value_offset(i) + chunk_offset -
810
+ arr.value_offset(0)));
811
+ OwnedRef end(PyLong_FromLongLong(arr.value_offset(i + 1) + chunk_offset -
812
+ arr.value_offset(0)));
813
+ OwnedRef slice(PySlice_New(start.obj(), end.obj(), nullptr));
814
+
815
+ if (ARROW_PREDICT_FALSE(slice.obj() == nullptr)) {
816
+ // Fall out of loop, will return from RETURN_IF_PYERROR
817
+ break;
818
+ }
819
+ *out_values = PyObject_GetItem(numpy_array, slice.obj());
820
+
821
+ if (*out_values == nullptr) {
822
+ // Fall out of loop, will return from RETURN_IF_PYERROR
823
+ break;
824
+ }
825
+ }
826
+ ++out_values;
827
+ }
828
+ RETURN_IF_PYERROR();
829
+
830
+ chunk_offset += arr.value_offset(arr.length()) - arr.value_offset(0);
831
+ }
832
+
833
+ return Status::OK();
834
+ }
835
+
836
+ // TODO GH-40579: optimize ListView conversion to avoid unnecessary copies
837
+ template <typename T>
838
+ enable_if_list_view<T, Status> ConvertListsLike(PandasOptions options,
839
+ const ChunkedArray& data,
840
+ PyObject** out_values) {
841
+ using ListViewArrayType = typename TypeTraits<T>::ArrayType;
842
+ using NonViewType =
843
+ std::conditional_t<T::type_id == Type::LIST_VIEW, ListType, LargeListType>;
844
+ using NonViewClass = typename TypeTraits<NonViewType>::ArrayType;
845
+ ArrayVector list_arrays;
846
+ for (int c = 0; c < data.num_chunks(); c++) {
847
+ const auto& arr = checked_cast<const ListViewArrayType&>(*data.chunk(c));
848
+ ARROW_ASSIGN_OR_RAISE(auto non_view_array,
849
+ NonViewClass::FromListView(arr, options.pool));
850
+ list_arrays.emplace_back(non_view_array);
851
+ }
852
+ auto chunked_array = std::make_shared<ChunkedArray>(list_arrays);
853
+ return ConvertListsLike<NonViewType>(options, *chunked_array, out_values);
854
+ }
855
+
856
+ template <typename F1, typename F2, typename F3>
857
+ Status ConvertMapHelper(F1 resetRow, F2 addPairToRow, F3 stealRow,
858
+ const ChunkedArray& data, PyArrayObject* py_keys,
859
+ PyArrayObject* py_items,
860
+ // needed for null checks in items
861
+ const std::vector<std::shared_ptr<Array>> item_arrays,
862
+ PyObject** out_values) {
863
+ OwnedRef key_value;
864
+ OwnedRef item_value;
865
+
866
+ int64_t chunk_offset = 0;
867
+ for (int c = 0; c < data.num_chunks(); ++c) {
868
+ const auto& arr = checked_cast<const MapArray&>(*data.chunk(c));
869
+ const bool has_nulls = data.null_count() > 0;
870
+
871
+ // Make a list of key/item pairs for each row in array
872
+ for (int64_t i = 0; i < arr.length(); ++i) {
873
+ if (has_nulls && arr.IsNull(i)) {
874
+ Py_INCREF(Py_None);
875
+ *out_values = Py_None;
876
+ } else {
877
+ int64_t entry_offset = arr.value_offset(i);
878
+ int64_t num_pairs = arr.value_offset(i + 1) - entry_offset;
879
+
880
+ // Build the new list object for the row of Python pairs
881
+ RETURN_NOT_OK(resetRow(num_pairs));
882
+
883
+ // Add each key/item pair in the row
884
+ for (int64_t j = 0; j < num_pairs; ++j) {
885
+ // Get key value, key is non-nullable for a valid row
886
+ auto ptr_key = reinterpret_cast<const char*>(
887
+ PyArray_GETPTR1(py_keys, chunk_offset + entry_offset + j));
888
+ key_value.reset(PyArray_GETITEM(py_keys, ptr_key));
889
+ RETURN_IF_PYERROR();
890
+
891
+ if (item_arrays[c]->IsNull(entry_offset + j)) {
892
+ // Translate the Null to a None
893
+ Py_INCREF(Py_None);
894
+ item_value.reset(Py_None);
895
+ } else {
896
+ // Get valid value from item array
897
+ auto ptr_item = reinterpret_cast<const char*>(
898
+ PyArray_GETPTR1(py_items, chunk_offset + entry_offset + j));
899
+ item_value.reset(PyArray_GETITEM(py_items, ptr_item));
900
+ RETURN_IF_PYERROR();
901
+ }
902
+
903
+ // Add the key/item pair to the row
904
+ RETURN_NOT_OK(addPairToRow(j, key_value, item_value));
905
+ }
906
+
907
+ // Pass ownership to the resulting array
908
+ *out_values = stealRow();
909
+ }
910
+ ++out_values;
911
+ }
912
+ RETURN_IF_PYERROR();
913
+
914
+ chunk_offset += arr.values()->length();
915
+ }
916
+
917
+ return Status::OK();
918
+ }
919
+
920
+ // A more helpful error message around TypeErrors that may stem from unhashable keys
921
+ Status CheckMapAsPydictsTypeError() {
922
+ if (ARROW_PREDICT_TRUE(!PyErr_Occurred())) {
923
+ return Status::OK();
924
+ }
925
+ if (PyErr_ExceptionMatches(PyExc_TypeError)) {
926
+ // Modify the error string directly, so it is re-raised
927
+ // with our additional info.
928
+ //
929
+ // There are not many interesting things happening when this
930
+ // is hit. This is intended to only be called directly after
931
+ // PyDict_SetItem, where a finite set of errors could occur.
932
+ PyObject *type, *value, *traceback;
933
+ PyErr_Fetch(&type, &value, &traceback);
934
+ std::string message;
935
+ RETURN_NOT_OK(internal::PyObject_StdStringStr(value, &message));
936
+ message +=
937
+ ". If keys are not hashable, then you must use the option "
938
+ "[maps_as_pydicts=None (default)]";
939
+
940
+ // resets the error
941
+ PyErr_SetString(PyExc_TypeError, message.c_str());
942
+ }
943
+ return ConvertPyError();
944
+ }
945
+
946
+ Status CheckForDuplicateKeys(bool error_on_duplicate_keys, Py_ssize_t total_dict_len,
947
+ Py_ssize_t total_raw_len) {
948
+ if (total_dict_len < total_raw_len) {
949
+ const char* message =
950
+ "[maps_as_pydicts] "
951
+ "After conversion of Arrow maps to pydicts, "
952
+ "detected data loss due to duplicate keys. "
953
+ "Original input length is [%lld], total converted pydict length is [%lld].";
954
+ std::array<char, 256> buf;
955
+ std::snprintf(buf.data(), buf.size(), message, total_raw_len, total_dict_len);
956
+
957
+ if (error_on_duplicate_keys) {
958
+ return Status::UnknownError(buf.data());
959
+ } else {
960
+ ARROW_LOG(WARNING) << buf.data();
961
+ }
962
+ }
963
+ return Status::OK();
964
+ }
965
+
966
+ Status ConvertMap(PandasOptions options, const ChunkedArray& data,
967
+ PyObject** out_values) {
968
+ // Get columns of underlying key/item arrays
969
+ std::vector<std::shared_ptr<Array>> key_arrays;
970
+ std::vector<std::shared_ptr<Array>> item_arrays;
971
+ for (int c = 0; c < data.num_chunks(); ++c) {
972
+ const auto& map_arr = checked_cast<const MapArray&>(*data.chunk(c));
973
+ key_arrays.emplace_back(map_arr.keys());
974
+ item_arrays.emplace_back(map_arr.items());
975
+ }
976
+
977
+ const auto& map_type = checked_cast<const MapType&>(*data.type());
978
+ auto key_type = map_type.key_type();
979
+ auto item_type = map_type.item_type();
980
+
981
+ // ARROW-6899: Convert dictionary-encoded children to dense instead of
982
+ // failing below. A more efficient conversion than this could be done later
983
+ if (key_type->id() == Type::DICTIONARY) {
984
+ auto dense_type = checked_cast<const DictionaryType&>(*key_type).value_type();
985
+ RETURN_NOT_OK(DecodeDictionaries(options.pool, dense_type, &key_arrays));
986
+ key_type = dense_type;
987
+ }
988
+ if (item_type->id() == Type::DICTIONARY) {
989
+ auto dense_type = checked_cast<const DictionaryType&>(*item_type).value_type();
990
+ RETURN_NOT_OK(DecodeDictionaries(options.pool, dense_type, &item_arrays));
991
+ item_type = dense_type;
992
+ }
993
+
994
+ // See notes in MakeInnerOptions.
995
+ options = MakeInnerOptions(std::move(options));
996
+ // Don't blindly convert because timestamps in lists are handled differently.
997
+ options.timestamp_as_object = true;
998
+
999
+ auto flat_keys = std::make_shared<ChunkedArray>(key_arrays, key_type);
1000
+ auto flat_items = std::make_shared<ChunkedArray>(item_arrays, item_type);
1001
+ OwnedRefNoGIL owned_numpy_keys;
1002
+ RETURN_NOT_OK(
1003
+ ConvertChunkedArrayToPandas(options, flat_keys, nullptr, owned_numpy_keys.ref()));
1004
+ OwnedRefNoGIL owned_numpy_items;
1005
+ RETURN_NOT_OK(
1006
+ ConvertChunkedArrayToPandas(options, flat_items, nullptr, owned_numpy_items.ref()));
1007
+ PyArrayObject* py_keys = reinterpret_cast<PyArrayObject*>(owned_numpy_keys.obj());
1008
+ PyArrayObject* py_items = reinterpret_cast<PyArrayObject*>(owned_numpy_items.obj());
1009
+
1010
+ if (options.maps_as_pydicts == MapConversionType::DEFAULT) {
1011
+ // The default behavior to express an Arrow MAP as a list of [(key, value), ...] pairs
1012
+ OwnedRef list_item;
1013
+ return ConvertMapHelper(
1014
+ [&list_item](int64_t num_pairs) {
1015
+ list_item.reset(PyList_New(num_pairs));
1016
+ return CheckPyError();
1017
+ },
1018
+ [&list_item](int64_t idx, OwnedRef& key_value, OwnedRef& item_value) {
1019
+ PyList_SET_ITEM(list_item.obj(), idx,
1020
+ PyTuple_Pack(2, key_value.obj(), item_value.obj()));
1021
+ return CheckPyError();
1022
+ },
1023
+ [&list_item] { return list_item.detach(); }, data, py_keys, py_items, item_arrays,
1024
+ out_values);
1025
+ } else {
1026
+ // Use a native pydict
1027
+ OwnedRef dict_item;
1028
+ Py_ssize_t total_dict_len{0};
1029
+ Py_ssize_t total_raw_len{0};
1030
+
1031
+ bool error_on_duplicate_keys;
1032
+ if (options.maps_as_pydicts == MapConversionType::LOSSY) {
1033
+ error_on_duplicate_keys = false;
1034
+ } else if (options.maps_as_pydicts == MapConversionType::STRICT_) {
1035
+ error_on_duplicate_keys = true;
1036
+ } else {
1037
+ auto val = std::underlying_type_t<MapConversionType>(options.maps_as_pydicts);
1038
+ return Status::UnknownError("Received unknown option for maps_as_pydicts: " +
1039
+ std::to_string(val));
1040
+ }
1041
+
1042
+ auto status = ConvertMapHelper(
1043
+ [&dict_item, &total_raw_len](int64_t num_pairs) {
1044
+ total_raw_len += num_pairs;
1045
+ dict_item.reset(PyDict_New());
1046
+ return CheckPyError();
1047
+ },
1048
+ [&dict_item]([[maybe_unused]] int64_t idx, OwnedRef& key_value,
1049
+ OwnedRef& item_value) {
1050
+ auto setitem_result =
1051
+ PyDict_SetItem(dict_item.obj(), key_value.obj(), item_value.obj());
1052
+ ARROW_RETURN_NOT_OK(CheckMapAsPydictsTypeError());
1053
+ // returns -1 if there are internal errors around hashing/resizing
1054
+ return setitem_result == 0 ? Status::OK()
1055
+ : Status::UnknownError(
1056
+ "[maps_as_pydicts] "
1057
+ "Unexpected failure inserting Arrow (key, "
1058
+ "value) pair into Python dict");
1059
+ },
1060
+ [&dict_item, &total_dict_len] {
1061
+ total_dict_len += PyDict_Size(dict_item.obj());
1062
+ return dict_item.detach();
1063
+ },
1064
+ data, py_keys, py_items, item_arrays, out_values);
1065
+
1066
+ ARROW_RETURN_NOT_OK(status);
1067
+ // If there were no errors generating the pydicts,
1068
+ // then check if we detected any data loss from duplicate keys.
1069
+ return CheckForDuplicateKeys(error_on_duplicate_keys, total_dict_len, total_raw_len);
1070
+ }
1071
+ }
1072
+
1073
+ template <typename InType, typename OutType>
1074
+ inline void ConvertNumericNullable(const ChunkedArray& data, InType na_value,
1075
+ OutType* out_values) {
1076
+ for (int c = 0; c < data.num_chunks(); c++) {
1077
+ const auto& arr = *data.chunk(c);
1078
+ const InType* in_values = GetPrimitiveValues<InType>(arr);
1079
+
1080
+ if (arr.null_count() > 0) {
1081
+ for (int64_t i = 0; i < arr.length(); ++i) {
1082
+ *out_values++ = arr.IsNull(i) ? na_value : in_values[i];
1083
+ }
1084
+ } else {
1085
+ memcpy(out_values, in_values, sizeof(InType) * arr.length());
1086
+ out_values += arr.length();
1087
+ }
1088
+ }
1089
+ }
1090
+
1091
+ template <typename InType, typename OutType>
1092
+ inline void ConvertNumericNullableCast(const ChunkedArray& data, InType na_value,
1093
+ OutType* out_values) {
1094
+ for (int c = 0; c < data.num_chunks(); c++) {
1095
+ const auto& arr = *data.chunk(c);
1096
+ const InType* in_values = GetPrimitiveValues<InType>(arr);
1097
+
1098
+ for (int64_t i = 0; i < arr.length(); ++i) {
1099
+ *out_values++ = arr.IsNull(i) ? static_cast<OutType>(na_value)
1100
+ : static_cast<OutType>(in_values[i]);
1101
+ }
1102
+ }
1103
+ }
1104
+
1105
+ template <int NPY_TYPE>
1106
+ class TypedPandasWriter : public PandasWriter {
1107
+ public:
1108
+ using T = typename npy_traits<NPY_TYPE>::value_type;
1109
+
1110
+ using PandasWriter::PandasWriter;
1111
+
1112
+ Status TransferSingle(std::shared_ptr<ChunkedArray> data, PyObject* py_ref) override {
1113
+ if (CanZeroCopy(*data)) {
1114
+ PyObject* wrapped;
1115
+ npy_intp dims[2] = {static_cast<npy_intp>(num_columns_),
1116
+ static_cast<npy_intp>(num_rows_)};
1117
+ RETURN_NOT_OK(
1118
+ MakeNumPyView(data->chunk(0), py_ref, NPY_TYPE, /*ndim=*/2, dims, &wrapped));
1119
+ SetBlockData(wrapped);
1120
+ return Status::OK();
1121
+ } else {
1122
+ RETURN_NOT_OK(CheckNotZeroCopyOnly(*data));
1123
+ RETURN_NOT_OK(EnsureAllocated());
1124
+ return CopyInto(data, /*rel_placement=*/0);
1125
+ }
1126
+ }
1127
+
1128
+ Status CheckTypeExact(const DataType& type, Type::type expected) {
1129
+ if (type.id() != expected) {
1130
+ return Status::NotImplemented("Cannot write Arrow data of type ", type.ToString(),
1131
+ " to pandas block with NumPy type ",
1132
+ GetNumPyTypeName(NPY_TYPE));
1133
+ }
1134
+ return Status::OK();
1135
+ }
1136
+
1137
+ T* GetBlockColumnStart(int64_t rel_placement) {
1138
+ return reinterpret_cast<T*>(block_data_) + rel_placement * num_rows_;
1139
+ }
1140
+
1141
+ protected:
1142
+ Status Allocate() override { return AllocateNDArray(NPY_TYPE); }
1143
+ };
1144
+
1145
+ struct ObjectWriterVisitor {
1146
+ const PandasOptions& options;
1147
+ const ChunkedArray& data;
1148
+ PyObject** out_values;
1149
+
1150
+ Status Visit(const NullType& type) {
1151
+ for (int c = 0; c < data.num_chunks(); c++) {
1152
+ std::shared_ptr<Array> arr = data.chunk(c);
1153
+
1154
+ for (int64_t i = 0; i < arr->length(); ++i) {
1155
+ // All values are null
1156
+ Py_INCREF(Py_None);
1157
+ *out_values = Py_None;
1158
+ ++out_values;
1159
+ }
1160
+ }
1161
+ return Status::OK();
1162
+ }
1163
+
1164
+ Status Visit(const BooleanType& type) {
1165
+ for (int c = 0; c < data.num_chunks(); c++) {
1166
+ const auto& arr = checked_cast<const BooleanArray&>(*data.chunk(c));
1167
+
1168
+ for (int64_t i = 0; i < arr.length(); ++i) {
1169
+ if (arr.IsNull(i)) {
1170
+ Py_INCREF(Py_None);
1171
+ *out_values++ = Py_None;
1172
+ } else if (arr.Value(i)) {
1173
+ // True
1174
+ Py_INCREF(Py_True);
1175
+ *out_values++ = Py_True;
1176
+ } else {
1177
+ // False
1178
+ Py_INCREF(Py_False);
1179
+ *out_values++ = Py_False;
1180
+ }
1181
+ }
1182
+ }
1183
+ return Status::OK();
1184
+ }
1185
+
1186
+ template <typename Type>
1187
+ enable_if_integer<Type, Status> Visit(const Type& type) {
1188
+ using T = typename Type::c_type;
1189
+ auto WrapValue = [](T value, PyObject** out) {
1190
+ *out = std::is_signed<T>::value ? PyLong_FromLongLong(value)
1191
+ : PyLong_FromUnsignedLongLong(value);
1192
+ RETURN_IF_PYERROR();
1193
+ return Status::OK();
1194
+ };
1195
+ return ConvertAsPyObjects<Type>(options, data, WrapValue, out_values);
1196
+ }
1197
+
1198
+ template <typename Type>
1199
+ enable_if_t<is_base_binary_type<Type>::value || is_binary_view_like_type<Type>::value ||
1200
+ is_fixed_size_binary_type<Type>::value,
1201
+ Status>
1202
+ Visit(const Type& type) {
1203
+ auto WrapValue = [](const std::string_view& view, PyObject** out) {
1204
+ *out = WrapBytes<Type>::Wrap(view.data(), view.length());
1205
+ if (*out == nullptr) {
1206
+ PyErr_Clear();
1207
+ return Status::UnknownError("Wrapping ", view, " failed");
1208
+ }
1209
+ return Status::OK();
1210
+ };
1211
+ return ConvertAsPyObjects<Type>(options, data, WrapValue, out_values);
1212
+ }
1213
+
1214
+ template <typename Type>
1215
+ enable_if_date<Type, Status> Visit(const Type& type) {
1216
+ auto WrapValue = [](typename Type::c_type value, PyObject** out) {
1217
+ RETURN_NOT_OK(internal::PyDate_from_int(value, Type::UNIT, out));
1218
+ RETURN_IF_PYERROR();
1219
+ return Status::OK();
1220
+ };
1221
+ return ConvertAsPyObjects<Type>(options, data, WrapValue, out_values);
1222
+ }
1223
+
1224
+ template <typename Type>
1225
+ enable_if_time<Type, Status> Visit(const Type& type) {
1226
+ const TimeUnit::type unit = type.unit();
1227
+ auto WrapValue = [unit](typename Type::c_type value, PyObject** out) {
1228
+ RETURN_NOT_OK(internal::PyTime_from_int(value, unit, out));
1229
+ RETURN_IF_PYERROR();
1230
+ return Status::OK();
1231
+ };
1232
+ return ConvertAsPyObjects<Type>(options, data, WrapValue, out_values);
1233
+ }
1234
+
1235
+ template <typename Type>
1236
+ enable_if_timestamp<Type, Status> Visit(const Type& type) {
1237
+ const TimeUnit::type unit = type.unit();
1238
+ OwnedRef tzinfo;
1239
+
1240
+ auto ConvertTimezoneNaive = [&](typename Type::c_type value, PyObject** out) {
1241
+ RETURN_NOT_OK(internal::PyDateTime_from_int(value, unit, out));
1242
+ RETURN_IF_PYERROR();
1243
+ return Status::OK();
1244
+ };
1245
+ auto ConvertTimezoneAware = [&](typename Type::c_type value, PyObject** out) {
1246
+ PyObject* naive_datetime;
1247
+ RETURN_NOT_OK(ConvertTimezoneNaive(value, &naive_datetime));
1248
+
1249
+ // convert the timezone naive datetime object to timezone aware
1250
+ // two step conversion of the datetime mimics Python's code:
1251
+ // dt.replace(tzinfo=datetime.timezone.utc).astimezone(tzinfo)
1252
+ // first step: replacing timezone with timezone.utc (replace method)
1253
+ OwnedRef args(PyTuple_New(0));
1254
+ OwnedRef keywords(PyDict_New());
1255
+ PyDict_SetItemString(keywords.obj(), "tzinfo", PyDateTime_TimeZone_UTC);
1256
+ OwnedRef naive_datetime_replace(PyObject_GetAttrString(naive_datetime, "replace"));
1257
+ OwnedRef datetime_utc(
1258
+ PyObject_Call(naive_datetime_replace.obj(), args.obj(), keywords.obj()));
1259
+ // second step: adjust the datetime to tzinfo timezone (astimezone method)
1260
+ *out = PyObject_CallMethod(datetime_utc.obj(), "astimezone", "O", tzinfo.obj());
1261
+
1262
+ // the timezone naive object is no longer required
1263
+ Py_DECREF(naive_datetime);
1264
+ RETURN_IF_PYERROR();
1265
+
1266
+ return Status::OK();
1267
+ };
1268
+
1269
+ if (!type.timezone().empty() && !options.ignore_timezone) {
1270
+ // convert timezone aware
1271
+ PyObject* tzobj;
1272
+ ARROW_ASSIGN_OR_RAISE(tzobj, internal::StringToTzinfo(type.timezone()));
1273
+ tzinfo.reset(tzobj);
1274
+ RETURN_IF_PYERROR();
1275
+ RETURN_NOT_OK(
1276
+ ConvertAsPyObjects<Type>(options, data, ConvertTimezoneAware, out_values));
1277
+ } else {
1278
+ // convert timezone naive
1279
+ RETURN_NOT_OK(
1280
+ ConvertAsPyObjects<Type>(options, data, ConvertTimezoneNaive, out_values));
1281
+ }
1282
+
1283
+ return Status::OK();
1284
+ }
1285
+
1286
+ template <typename Type>
1287
+ enable_if_t<std::is_same<Type, MonthDayNanoIntervalType>::value, Status> Visit(
1288
+ const Type& type) {
1289
+ OwnedRef args(PyTuple_New(0));
1290
+ OwnedRef kwargs(PyDict_New());
1291
+ RETURN_IF_PYERROR();
1292
+ auto to_date_offset = [&](const MonthDayNanoIntervalType::MonthDayNanos& interval,
1293
+ PyObject** out) {
1294
+ ARROW_DCHECK(internal::BorrowPandasDataOffsetType() != nullptr);
1295
+ // DateOffset objects do not add nanoseconds component to pd.Timestamp.
1296
+ // as of Pandas 1.3.3
1297
+ // (https://github.com/pandas-dev/pandas/issues/43892).
1298
+ // So convert microseconds and remainder to preserve data
1299
+ // but give users more expected results.
1300
+ int64_t microseconds = interval.nanoseconds / 1000;
1301
+ int64_t nanoseconds;
1302
+ if (interval.nanoseconds >= 0) {
1303
+ nanoseconds = interval.nanoseconds % 1000;
1304
+ } else {
1305
+ nanoseconds = -((-interval.nanoseconds) % 1000);
1306
+ }
1307
+
1308
+ PyDict_SetItemString(kwargs.obj(), "months", PyLong_FromLong(interval.months));
1309
+ PyDict_SetItemString(kwargs.obj(), "days", PyLong_FromLong(interval.days));
1310
+ PyDict_SetItemString(kwargs.obj(), "microseconds",
1311
+ PyLong_FromLongLong(microseconds));
1312
+ PyDict_SetItemString(kwargs.obj(), "nanoseconds", PyLong_FromLongLong(nanoseconds));
1313
+ *out =
1314
+ PyObject_Call(internal::BorrowPandasDataOffsetType(), args.obj(), kwargs.obj());
1315
+ RETURN_IF_PYERROR();
1316
+ return Status::OK();
1317
+ };
1318
+ return ConvertAsPyObjects<MonthDayNanoIntervalType>(options, data, to_date_offset,
1319
+ out_values);
1320
+ }
1321
+
1322
+ template <typename DecimalT, typename DecimalArrayT>
1323
+ Status VisitDecimal(const DecimalT& type) {
1324
+ OwnedRef decimal;
1325
+ OwnedRef Decimal;
1326
+ RETURN_NOT_OK(internal::ImportModule("decimal", &decimal));
1327
+ RETURN_NOT_OK(internal::ImportFromModule(decimal.obj(), "Decimal", &Decimal));
1328
+ PyObject* decimal_constructor = Decimal.obj();
1329
+
1330
+ for (int c = 0; c < data.num_chunks(); c++) {
1331
+ const auto& arr = checked_cast<const DecimalArrayT&>(*data.chunk(c));
1332
+
1333
+ for (int64_t i = 0; i < arr.length(); ++i) {
1334
+ if (arr.IsNull(i)) {
1335
+ Py_INCREF(Py_None);
1336
+ *out_values++ = Py_None;
1337
+ } else {
1338
+ *out_values++ =
1339
+ internal::DecimalFromString(decimal_constructor, arr.FormatValue(i));
1340
+ RETURN_IF_PYERROR();
1341
+ }
1342
+ }
1343
+ }
1344
+
1345
+ return Status::OK();
1346
+ }
1347
+
1348
+ Status Visit(const Decimal32Type& type) {
1349
+ return VisitDecimal<Decimal32Type, Decimal32Array>(type);
1350
+ }
1351
+
1352
+ Status Visit(const Decimal64Type& type) {
1353
+ return VisitDecimal<Decimal64Type, Decimal64Array>(type);
1354
+ }
1355
+
1356
+ Status Visit(const Decimal128Type& type) {
1357
+ return VisitDecimal<Decimal128Type, Decimal128Array>(type);
1358
+ }
1359
+
1360
+ Status Visit(const Decimal256Type& type) {
1361
+ return VisitDecimal<Decimal256Type, Decimal256Array>(type);
1362
+ }
1363
+
1364
+ template <typename T>
1365
+ enable_if_t<is_list_like_type<T>::value || is_list_view_type<T>::value, Status> Visit(
1366
+ const T& type) {
1367
+ if (!ListTypeSupported(*type.value_type())) {
1368
+ return Status::NotImplemented(
1369
+ "Not implemented type for conversion from List to Pandas: ",
1370
+ type.value_type()->ToString());
1371
+ }
1372
+ return ConvertListsLike<T>(options, data, out_values);
1373
+ }
1374
+
1375
+ Status Visit(const MapType& type) { return ConvertMap(options, data, out_values); }
1376
+
1377
+ Status Visit(const StructType& type) {
1378
+ return ConvertStruct(options, data, out_values);
1379
+ }
1380
+
1381
+ template <typename Type>
1382
+ enable_if_t<is_floating_type<Type>::value ||
1383
+ std::is_same<DictionaryType, Type>::value ||
1384
+ std::is_same<DurationType, Type>::value ||
1385
+ std::is_same<RunEndEncodedType, Type>::value ||
1386
+ std::is_same<ExtensionType, Type>::value ||
1387
+ (std::is_base_of<IntervalType, Type>::value &&
1388
+ !std::is_same<MonthDayNanoIntervalType, Type>::value) ||
1389
+ std::is_base_of<UnionType, Type>::value,
1390
+ Status>
1391
+ Visit(const Type& type) {
1392
+ return Status::NotImplemented("No implemented conversion to object dtype: ",
1393
+ type.ToString());
1394
+ }
1395
+ };
1396
+
1397
+ class ObjectWriter : public TypedPandasWriter<NPY_OBJECT> {
1398
+ public:
1399
+ using TypedPandasWriter<NPY_OBJECT>::TypedPandasWriter;
1400
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1401
+ PyAcquireGIL lock;
1402
+ ObjectWriterVisitor visitor{this->options_, *data,
1403
+ this->GetBlockColumnStart(rel_placement)};
1404
+ return VisitTypeInline(*data->type(), &visitor);
1405
+ }
1406
+ };
1407
+
1408
+ static inline bool IsNonNullContiguous(const ChunkedArray& data) {
1409
+ return data.num_chunks() == 1 && data.null_count() == 0;
1410
+ }
1411
+
1412
+ template <int NPY_TYPE>
1413
+ class IntWriter : public TypedPandasWriter<NPY_TYPE> {
1414
+ public:
1415
+ using ArrowType = typename npy_traits<NPY_TYPE>::TypeClass;
1416
+ using TypedPandasWriter<NPY_TYPE>::TypedPandasWriter;
1417
+
1418
+ bool CanZeroCopy(const ChunkedArray& data) const override {
1419
+ return IsNonNullContiguous(data);
1420
+ }
1421
+
1422
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1423
+ RETURN_NOT_OK(this->CheckTypeExact(*data->type(), ArrowType::type_id));
1424
+ ConvertIntegerNoNullsSameType<typename ArrowType::c_type>(
1425
+ this->options_, *data, this->GetBlockColumnStart(rel_placement));
1426
+ return Status::OK();
1427
+ }
1428
+ };
1429
+
1430
+ template <int NPY_TYPE>
1431
+ class FloatWriter : public TypedPandasWriter<NPY_TYPE> {
1432
+ public:
1433
+ using ArrowType = typename npy_traits<NPY_TYPE>::TypeClass;
1434
+ using TypedPandasWriter<NPY_TYPE>::TypedPandasWriter;
1435
+ using T = typename ArrowType::c_type;
1436
+
1437
+ bool CanZeroCopy(const ChunkedArray& data) const override {
1438
+ return IsNonNullContiguous(data) && data.type()->id() == ArrowType::type_id;
1439
+ }
1440
+
1441
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1442
+ Type::type in_type = data->type()->id();
1443
+ auto out_values = this->GetBlockColumnStart(rel_placement);
1444
+
1445
+ #define INTEGER_CASE(IN_TYPE) \
1446
+ ConvertIntegerWithNulls<IN_TYPE, T>(this->options_, *data, out_values); \
1447
+ break;
1448
+
1449
+ switch (in_type) {
1450
+ case Type::UINT8:
1451
+ INTEGER_CASE(uint8_t);
1452
+ case Type::INT8:
1453
+ INTEGER_CASE(int8_t);
1454
+ case Type::UINT16:
1455
+ INTEGER_CASE(uint16_t);
1456
+ case Type::INT16:
1457
+ INTEGER_CASE(int16_t);
1458
+ case Type::UINT32:
1459
+ INTEGER_CASE(uint32_t);
1460
+ case Type::INT32:
1461
+ INTEGER_CASE(int32_t);
1462
+ case Type::UINT64:
1463
+ INTEGER_CASE(uint64_t);
1464
+ case Type::INT64:
1465
+ INTEGER_CASE(int64_t);
1466
+ case Type::HALF_FLOAT:
1467
+ ConvertNumericNullableCast(*data, npy_traits<NPY_TYPE>::na_sentinel, out_values);
1468
+ case Type::FLOAT:
1469
+ ConvertNumericNullableCast(*data, npy_traits<NPY_TYPE>::na_sentinel, out_values);
1470
+ break;
1471
+ case Type::DOUBLE:
1472
+ ConvertNumericNullableCast(*data, npy_traits<NPY_TYPE>::na_sentinel, out_values);
1473
+ break;
1474
+ default:
1475
+ return Status::NotImplemented("Cannot write Arrow data of type ",
1476
+ data->type()->ToString(),
1477
+ " to a Pandas floating point block");
1478
+ }
1479
+
1480
+ #undef INTEGER_CASE
1481
+
1482
+ return Status::OK();
1483
+ }
1484
+ };
1485
+
1486
+ using UInt8Writer = IntWriter<NPY_UINT8>;
1487
+ using Int8Writer = IntWriter<NPY_INT8>;
1488
+ using UInt16Writer = IntWriter<NPY_UINT16>;
1489
+ using Int16Writer = IntWriter<NPY_INT16>;
1490
+ using UInt32Writer = IntWriter<NPY_UINT32>;
1491
+ using Int32Writer = IntWriter<NPY_INT32>;
1492
+ using UInt64Writer = IntWriter<NPY_UINT64>;
1493
+ using Int64Writer = IntWriter<NPY_INT64>;
1494
+ using Float16Writer = FloatWriter<NPY_FLOAT16>;
1495
+ using Float32Writer = FloatWriter<NPY_FLOAT32>;
1496
+ using Float64Writer = FloatWriter<NPY_FLOAT64>;
1497
+
1498
+ class BoolWriter : public TypedPandasWriter<NPY_BOOL> {
1499
+ public:
1500
+ using TypedPandasWriter<NPY_BOOL>::TypedPandasWriter;
1501
+
1502
+ Status TransferSingle(std::shared_ptr<ChunkedArray> data, PyObject* py_ref) override {
1503
+ RETURN_NOT_OK(
1504
+ CheckNoZeroCopy("Zero copy conversions not possible with "
1505
+ "boolean types"));
1506
+ RETURN_NOT_OK(EnsureAllocated());
1507
+ return CopyInto(data, /*rel_placement=*/0);
1508
+ }
1509
+
1510
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1511
+ RETURN_NOT_OK(this->CheckTypeExact(*data->type(), Type::BOOL));
1512
+ auto out_values = this->GetBlockColumnStart(rel_placement);
1513
+ for (int c = 0; c < data->num_chunks(); c++) {
1514
+ const auto& arr = checked_cast<const BooleanArray&>(*data->chunk(c));
1515
+ for (int64_t i = 0; i < arr.length(); ++i) {
1516
+ *out_values++ = static_cast<uint8_t>(arr.Value(i));
1517
+ }
1518
+ }
1519
+ return Status::OK();
1520
+ }
1521
+ };
1522
+
1523
+ // ----------------------------------------------------------------------
1524
+ // Date / timestamp types
1525
+
1526
+ template <typename T, int64_t SHIFT>
1527
+ inline void ConvertDatetime(const ChunkedArray& data, int64_t* out_values) {
1528
+ for (int c = 0; c < data.num_chunks(); c++) {
1529
+ const auto& arr = *data.chunk(c);
1530
+ const T* in_values = GetPrimitiveValues<T>(arr);
1531
+
1532
+ for (int64_t i = 0; i < arr.length(); ++i) {
1533
+ *out_values++ = arr.IsNull(i) ? kPandasTimestampNull
1534
+ : (static_cast<int64_t>(in_values[i]) * SHIFT);
1535
+ }
1536
+ }
1537
+ }
1538
+
1539
+ template <typename T, int SHIFT>
1540
+ void ConvertDatesShift(const ChunkedArray& data, int64_t* out_values) {
1541
+ for (int c = 0; c < data.num_chunks(); c++) {
1542
+ const auto& arr = *data.chunk(c);
1543
+ const T* in_values = GetPrimitiveValues<T>(arr);
1544
+ for (int64_t i = 0; i < arr.length(); ++i) {
1545
+ *out_values++ = arr.IsNull(i) ? kPandasTimestampNull
1546
+ : static_cast<int64_t>(in_values[i]) / SHIFT;
1547
+ }
1548
+ }
1549
+ }
1550
+
1551
+ class DatetimeDayWriter : public TypedPandasWriter<NPY_DATETIME> {
1552
+ public:
1553
+ using TypedPandasWriter<NPY_DATETIME>::TypedPandasWriter;
1554
+
1555
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1556
+ int64_t* out_values = this->GetBlockColumnStart(rel_placement);
1557
+ const auto& type = checked_cast<const DateType&>(*data->type());
1558
+ switch (type.unit()) {
1559
+ case DateUnit::DAY:
1560
+ ConvertDatesShift<int32_t, 1LL>(*data, out_values);
1561
+ break;
1562
+ case DateUnit::MILLI:
1563
+ ConvertDatesShift<int64_t, 86400000LL>(*data, out_values);
1564
+ break;
1565
+ }
1566
+ return Status::OK();
1567
+ }
1568
+
1569
+ protected:
1570
+ Status Allocate() override {
1571
+ RETURN_NOT_OK(this->AllocateNDArray(NPY_DATETIME));
1572
+ SetDatetimeUnit(NPY_FR_D);
1573
+ return Status::OK();
1574
+ }
1575
+ };
1576
+
1577
+ template <TimeUnit::type UNIT>
1578
+ class DatetimeWriter : public TypedPandasWriter<NPY_DATETIME> {
1579
+ public:
1580
+ using TypedPandasWriter<NPY_DATETIME>::TypedPandasWriter;
1581
+
1582
+ bool CanZeroCopy(const ChunkedArray& data) const override {
1583
+ if (data.type()->id() == Type::TIMESTAMP) {
1584
+ const auto& type = checked_cast<const TimestampType&>(*data.type());
1585
+ return IsNonNullContiguous(data) && type.unit() == UNIT;
1586
+ } else {
1587
+ return false;
1588
+ }
1589
+ }
1590
+
1591
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1592
+ const auto& ts_type = checked_cast<const TimestampType&>(*data->type());
1593
+ ARROW_DCHECK_EQ(UNIT, ts_type.unit()) << "Should only call instances of this writer "
1594
+ << "with arrays of the correct unit";
1595
+ ConvertNumericNullable<int64_t>(*data, kPandasTimestampNull,
1596
+ this->GetBlockColumnStart(rel_placement));
1597
+ return Status::OK();
1598
+ }
1599
+
1600
+ protected:
1601
+ Status Allocate() override {
1602
+ RETURN_NOT_OK(this->AllocateNDArray(NPY_DATETIME));
1603
+ SetDatetimeUnit(internal::NumPyFrequency(UNIT));
1604
+ return Status::OK();
1605
+ }
1606
+ };
1607
+
1608
+ using DatetimeSecondWriter = DatetimeWriter<TimeUnit::SECOND>;
1609
+
1610
+ class DatetimeMilliWriter : public DatetimeWriter<TimeUnit::MILLI> {
1611
+ public:
1612
+ using DatetimeWriter<TimeUnit::MILLI>::DatetimeWriter;
1613
+
1614
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1615
+ Type::type type = data->type()->id();
1616
+ int64_t* out_values = this->GetBlockColumnStart(rel_placement);
1617
+ if (type == Type::DATE32) {
1618
+ // Convert from days since epoch to datetime64[ms]
1619
+ ConvertDatetime<int32_t, 86400000L>(*data, out_values);
1620
+ } else if (type == Type::DATE64) {
1621
+ ConvertNumericNullable<int64_t>(*data, kPandasTimestampNull, out_values);
1622
+ } else {
1623
+ const auto& ts_type = checked_cast<const TimestampType&>(*data->type());
1624
+ ARROW_DCHECK_EQ(TimeUnit::MILLI, ts_type.unit())
1625
+ << "Should only call instances of this writer "
1626
+ << "with arrays of the correct unit";
1627
+ ConvertNumericNullable<int64_t>(*data, kPandasTimestampNull, out_values);
1628
+ }
1629
+ return Status::OK();
1630
+ }
1631
+ };
1632
+
1633
+ using DatetimeMicroWriter = DatetimeWriter<TimeUnit::MICRO>;
1634
+
1635
+ class DatetimeNanoWriter : public DatetimeWriter<TimeUnit::NANO> {
1636
+ public:
1637
+ using DatetimeWriter<TimeUnit::NANO>::DatetimeWriter;
1638
+
1639
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1640
+ Type::type type = data->type()->id();
1641
+ int64_t* out_values = this->GetBlockColumnStart(rel_placement);
1642
+ compute::ExecContext ctx(options_.pool);
1643
+ compute::CastOptions options;
1644
+ if (options_.safe_cast) {
1645
+ options = compute::CastOptions::Safe();
1646
+ } else {
1647
+ options = compute::CastOptions::Unsafe();
1648
+ }
1649
+ Datum out;
1650
+ auto target_type = timestamp(TimeUnit::NANO);
1651
+
1652
+ if (type == Type::DATE32) {
1653
+ // Convert from days since epoch to datetime64[ns]
1654
+ ConvertDatetime<int32_t, kNanosecondsInDay>(*data, out_values);
1655
+ } else if (type == Type::DATE64) {
1656
+ // Date64Type is millisecond timestamp stored as int64_t
1657
+ // TODO(wesm): Do we want to make sure to zero out the milliseconds?
1658
+ ConvertDatetime<int64_t, 1000000L>(*data, out_values);
1659
+ } else if (type == Type::TIMESTAMP) {
1660
+ const auto& ts_type = checked_cast<const TimestampType&>(*data->type());
1661
+
1662
+ if (ts_type.unit() == TimeUnit::NANO) {
1663
+ ConvertNumericNullable<int64_t>(*data, kPandasTimestampNull, out_values);
1664
+ } else if (ts_type.unit() == TimeUnit::MICRO || ts_type.unit() == TimeUnit::MILLI ||
1665
+ ts_type.unit() == TimeUnit::SECOND) {
1666
+ ARROW_ASSIGN_OR_RAISE(out, compute::Cast(data, target_type, options, &ctx));
1667
+ ConvertNumericNullable<int64_t>(*out.chunked_array(), kPandasTimestampNull,
1668
+ out_values);
1669
+ } else {
1670
+ return Status::NotImplemented("Unsupported time unit");
1671
+ }
1672
+ } else {
1673
+ return Status::NotImplemented("Cannot write Arrow data of type ",
1674
+ data->type()->ToString(),
1675
+ " to a Pandas datetime block.");
1676
+ }
1677
+ return Status::OK();
1678
+ }
1679
+ };
1680
+
1681
+ template <typename BASE>
1682
+ class DatetimeTZWriter : public BASE {
1683
+ public:
1684
+ DatetimeTZWriter(const PandasOptions& options, const std::string& timezone,
1685
+ int64_t num_rows)
1686
+ : BASE(options, num_rows, 1), timezone_(timezone) {}
1687
+
1688
+ protected:
1689
+ Status GetResultBlock(PyObject** out) override {
1690
+ RETURN_NOT_OK(this->MakeBlock1D());
1691
+ *out = this->block_arr_.obj();
1692
+ return Status::OK();
1693
+ }
1694
+
1695
+ Status AddResultMetadata(PyObject* result) override {
1696
+ PyObject* py_tz = PyUnicode_FromStringAndSize(
1697
+ timezone_.c_str(), static_cast<Py_ssize_t>(timezone_.size()));
1698
+ RETURN_IF_PYERROR();
1699
+ PyDict_SetItemString(result, "timezone", py_tz);
1700
+ Py_DECREF(py_tz);
1701
+ return Status::OK();
1702
+ }
1703
+
1704
+ private:
1705
+ std::string timezone_;
1706
+ };
1707
+
1708
+ using DatetimeSecondTZWriter = DatetimeTZWriter<DatetimeSecondWriter>;
1709
+ using DatetimeMilliTZWriter = DatetimeTZWriter<DatetimeMilliWriter>;
1710
+ using DatetimeMicroTZWriter = DatetimeTZWriter<DatetimeMicroWriter>;
1711
+ using DatetimeNanoTZWriter = DatetimeTZWriter<DatetimeNanoWriter>;
1712
+
1713
+ template <TimeUnit::type UNIT>
1714
+ class TimedeltaWriter : public TypedPandasWriter<NPY_TIMEDELTA> {
1715
+ public:
1716
+ using TypedPandasWriter<NPY_TIMEDELTA>::TypedPandasWriter;
1717
+
1718
+ Status AllocateTimedelta(int ndim) {
1719
+ RETURN_NOT_OK(this->AllocateNDArray(NPY_TIMEDELTA, ndim));
1720
+ SetDatetimeUnit(internal::NumPyFrequency(UNIT));
1721
+ return Status::OK();
1722
+ }
1723
+
1724
+ bool CanZeroCopy(const ChunkedArray& data) const override {
1725
+ const auto& type = checked_cast<const DurationType&>(*data.type());
1726
+ return IsNonNullContiguous(data) && type.unit() == UNIT;
1727
+ }
1728
+
1729
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1730
+ const auto& type = checked_cast<const DurationType&>(*data->type());
1731
+ ARROW_DCHECK_EQ(UNIT, type.unit()) << "Should only call instances of this writer "
1732
+ << "with arrays of the correct unit";
1733
+ ConvertNumericNullable<int64_t>(*data, kPandasTimestampNull,
1734
+ this->GetBlockColumnStart(rel_placement));
1735
+ return Status::OK();
1736
+ }
1737
+
1738
+ protected:
1739
+ Status Allocate() override { return AllocateTimedelta(2); }
1740
+ };
1741
+
1742
+ using TimedeltaSecondWriter = TimedeltaWriter<TimeUnit::SECOND>;
1743
+ using TimedeltaMilliWriter = TimedeltaWriter<TimeUnit::MILLI>;
1744
+ using TimedeltaMicroWriter = TimedeltaWriter<TimeUnit::MICRO>;
1745
+
1746
+ class TimedeltaNanoWriter : public TimedeltaWriter<TimeUnit::NANO> {
1747
+ public:
1748
+ using TimedeltaWriter<TimeUnit::NANO>::TimedeltaWriter;
1749
+
1750
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1751
+ Type::type type = data->type()->id();
1752
+ int64_t* out_values = this->GetBlockColumnStart(rel_placement);
1753
+ if (type == Type::DURATION) {
1754
+ const auto& ts_type = checked_cast<const DurationType&>(*data->type());
1755
+ if (ts_type.unit() == TimeUnit::NANO) {
1756
+ ConvertNumericNullable<int64_t>(*data, kPandasTimestampNull, out_values);
1757
+ } else if (ts_type.unit() == TimeUnit::MICRO) {
1758
+ ConvertDatetime<int64_t, 1000L>(*data, out_values);
1759
+ } else if (ts_type.unit() == TimeUnit::MILLI) {
1760
+ ConvertDatetime<int64_t, 1000000L>(*data, out_values);
1761
+ } else if (ts_type.unit() == TimeUnit::SECOND) {
1762
+ ConvertDatetime<int64_t, 1000000000L>(*data, out_values);
1763
+ } else {
1764
+ return Status::NotImplemented("Unsupported time unit");
1765
+ }
1766
+ } else {
1767
+ return Status::NotImplemented("Cannot write Arrow data of type ",
1768
+ data->type()->ToString(),
1769
+ " to a Pandas timedelta block.");
1770
+ }
1771
+ return Status::OK();
1772
+ }
1773
+ };
1774
+
1775
+ Status MakeZeroLengthArray(const std::shared_ptr<DataType>& type,
1776
+ std::shared_ptr<Array>* out) {
1777
+ std::unique_ptr<ArrayBuilder> builder;
1778
+ RETURN_NOT_OK(MakeBuilder(default_memory_pool(), type, &builder));
1779
+ RETURN_NOT_OK(builder->Resize(0));
1780
+ return builder->Finish(out);
1781
+ }
1782
+
1783
+ bool NeedDictionaryUnification(const ChunkedArray& data) {
1784
+ if (data.num_chunks() < 2) {
1785
+ return false;
1786
+ }
1787
+ const auto& arr_first = checked_cast<const DictionaryArray&>(*data.chunk(0));
1788
+ for (int c = 1; c < data.num_chunks(); c++) {
1789
+ const auto& arr = checked_cast<const DictionaryArray&>(*data.chunk(c));
1790
+ if (!(arr_first.dictionary()->Equals(arr.dictionary()))) {
1791
+ return true;
1792
+ }
1793
+ }
1794
+ return false;
1795
+ }
1796
+
1797
+ template <typename IndexType>
1798
+ class CategoricalWriter
1799
+ : public TypedPandasWriter<arrow_traits<IndexType::type_id>::npy_type> {
1800
+ public:
1801
+ using TRAITS = arrow_traits<IndexType::type_id>;
1802
+ using ArrayType = typename TypeTraits<IndexType>::ArrayType;
1803
+ using T = typename TRAITS::T;
1804
+
1805
+ explicit CategoricalWriter(const PandasOptions& options, int64_t num_rows)
1806
+ : TypedPandasWriter<TRAITS::npy_type>(options, num_rows, 1),
1807
+ ordered_(false),
1808
+ needs_copy_(false) {}
1809
+
1810
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1811
+ return Status::NotImplemented("categorical type");
1812
+ }
1813
+
1814
+ Status TransferSingle(std::shared_ptr<ChunkedArray> data, PyObject* py_ref) override {
1815
+ const auto& dict_type = checked_cast<const DictionaryType&>(*data->type());
1816
+ std::shared_ptr<Array> dict;
1817
+ if (data->num_chunks() == 0) {
1818
+ // no dictionary values => create empty array
1819
+ RETURN_NOT_OK(this->AllocateNDArray(TRAITS::npy_type, 1));
1820
+ RETURN_NOT_OK(MakeZeroLengthArray(dict_type.value_type(), &dict));
1821
+ } else {
1822
+ ARROW_DCHECK_EQ(IndexType::type_id, dict_type.index_type()->id());
1823
+ RETURN_NOT_OK(WriteIndices(*data, &dict));
1824
+ }
1825
+
1826
+ PyObject* pydict;
1827
+ RETURN_NOT_OK(ConvertArrayToPandas(this->options_, dict, nullptr, &pydict));
1828
+ dictionary_.reset(pydict);
1829
+ ordered_ = dict_type.ordered();
1830
+ return Status::OK();
1831
+ }
1832
+
1833
+ Status Write(std::shared_ptr<ChunkedArray> data, int64_t abs_placement,
1834
+ int64_t rel_placement) override {
1835
+ RETURN_NOT_OK(this->EnsurePlacementAllocated());
1836
+ RETURN_NOT_OK(TransferSingle(data, /*py_ref=*/nullptr));
1837
+ this->placement_data_[rel_placement] = abs_placement;
1838
+ return Status::OK();
1839
+ }
1840
+
1841
+ Status GetSeriesResult(PyObject** out) override {
1842
+ PyAcquireGIL lock;
1843
+
1844
+ PyObject* result = PyDict_New();
1845
+ RETURN_IF_PYERROR();
1846
+
1847
+ // Expected single array dictionary layout
1848
+ PyDict_SetItemString(result, "indices", this->block_arr_.obj());
1849
+ RETURN_IF_PYERROR();
1850
+ RETURN_NOT_OK(AddResultMetadata(result));
1851
+
1852
+ *out = result;
1853
+ return Status::OK();
1854
+ }
1855
+
1856
+ protected:
1857
+ Status AddResultMetadata(PyObject* result) override {
1858
+ PyDict_SetItemString(result, "dictionary", dictionary_.obj());
1859
+ PyObject* py_ordered = ordered_ ? Py_True : Py_False;
1860
+ Py_INCREF(py_ordered);
1861
+ PyDict_SetItemString(result, "ordered", py_ordered);
1862
+ return Status::OK();
1863
+ }
1864
+
1865
+ Status WriteIndicesUniform(const ChunkedArray& data) {
1866
+ // For unsigned types, upcast to signed since pandas uses -1 for nulls
1867
+ // uint8 to int16, uint16 to int32, uint32 to int64, signed types unchanged
1868
+ using OutputType = std::conditional_t<
1869
+ std::is_same<T, uint8_t>::value, int16_t,
1870
+ std::conditional_t<
1871
+ std::is_same<T, uint16_t>::value, int32_t,
1872
+ std::conditional_t<std::is_same<T, uint32_t>::value, int64_t, T>>>;
1873
+ const int npy_output_type = std::is_same<OutputType, int16_t>::value ? NPY_INT16
1874
+ : std::is_same<OutputType, int32_t>::value ? NPY_INT32
1875
+ : std::is_same<OutputType, int64_t>::value
1876
+ ? NPY_INT64
1877
+ : TRAITS::npy_type;
1878
+
1879
+ RETURN_NOT_OK(this->AllocateNDArray(npy_output_type, 1));
1880
+ auto out_values = reinterpret_cast<OutputType*>(this->block_data_);
1881
+
1882
+ for (int c = 0; c < data.num_chunks(); c++) {
1883
+ const auto& arr = checked_cast<const DictionaryArray&>(*data.chunk(c));
1884
+ const auto& indices = checked_cast<const ArrayType&>(*arr.indices());
1885
+ auto values = reinterpret_cast<const T*>(indices.raw_values());
1886
+
1887
+ RETURN_NOT_OK(CheckIndexBounds(*indices.data(), arr.dictionary()->length()));
1888
+ // Null is -1 in CategoricalBlock
1889
+ for (int i = 0; i < arr.length(); ++i) {
1890
+ if (indices.IsValid(i)) {
1891
+ *out_values++ = static_cast<OutputType>(values[i]);
1892
+ } else {
1893
+ *out_values++ = -1;
1894
+ }
1895
+ }
1896
+ }
1897
+ return Status::OK();
1898
+ }
1899
+
1900
+ Status WriteIndicesVarying(const ChunkedArray& data, std::shared_ptr<Array>* out_dict) {
1901
+ // Yield int32 indices to allow for dictionary outgrowing the current index
1902
+ // type
1903
+ RETURN_NOT_OK(this->AllocateNDArray(NPY_INT32, 1));
1904
+ auto out_values = reinterpret_cast<int32_t*>(this->block_data_);
1905
+
1906
+ const auto& dict_type = checked_cast<const DictionaryType&>(*data.type());
1907
+
1908
+ ARROW_ASSIGN_OR_RAISE(auto unifier, DictionaryUnifier::Make(dict_type.value_type(),
1909
+ this->options_.pool));
1910
+ for (int c = 0; c < data.num_chunks(); c++) {
1911
+ const auto& arr = checked_cast<const DictionaryArray&>(*data.chunk(c));
1912
+ const auto& indices = checked_cast<const ArrayType&>(*arr.indices());
1913
+ auto values = reinterpret_cast<const T*>(indices.raw_values());
1914
+
1915
+ std::shared_ptr<Buffer> transpose_buffer;
1916
+ RETURN_NOT_OK(unifier->Unify(*arr.dictionary(), &transpose_buffer));
1917
+
1918
+ auto transpose = reinterpret_cast<const int32_t*>(transpose_buffer->data());
1919
+ int64_t dict_length = arr.dictionary()->length();
1920
+
1921
+ RETURN_NOT_OK(CheckIndexBounds(*indices.data(), dict_length));
1922
+
1923
+ // Null is -1 in CategoricalBlock
1924
+ for (int i = 0; i < arr.length(); ++i) {
1925
+ if (indices.IsValid(i)) {
1926
+ *out_values++ = transpose[values[i]];
1927
+ } else {
1928
+ *out_values++ = -1;
1929
+ }
1930
+ }
1931
+ }
1932
+
1933
+ std::shared_ptr<DataType> unused_type;
1934
+ return unifier->GetResult(&unused_type, out_dict);
1935
+ }
1936
+
1937
+ Status WriteIndices(const ChunkedArray& data, std::shared_ptr<Array>* out_dict) {
1938
+ ARROW_DCHECK_GT(data.num_chunks(), 0);
1939
+
1940
+ // Sniff the first chunk
1941
+ const auto& arr_first = checked_cast<const DictionaryArray&>(*data.chunk(0));
1942
+ const auto indices_first = std::static_pointer_cast<ArrayType>(arr_first.indices());
1943
+
1944
+ // For unsigned types, we need to convert to signed for pandas compatibility
1945
+ // even when there are no nulls, so we skip the fast path
1946
+ const bool is_unsigned = std::is_unsigned<T>::value;
1947
+
1948
+ if (data.num_chunks() == 1 && indices_first->null_count() == 0 && !is_unsigned) {
1949
+ RETURN_NOT_OK(
1950
+ CheckIndexBounds(*indices_first->data(), arr_first.dictionary()->length()));
1951
+
1952
+ PyObject* wrapped;
1953
+ npy_intp dims[1] = {static_cast<npy_intp>(this->num_rows_)};
1954
+ RETURN_NOT_OK(MakeNumPyView(indices_first, /*py_ref=*/nullptr, TRAITS::npy_type,
1955
+ /*ndim=*/1, dims, &wrapped));
1956
+ this->SetBlockData(wrapped);
1957
+ *out_dict = arr_first.dictionary();
1958
+ } else {
1959
+ RETURN_NOT_OK(this->CheckNotZeroCopyOnly(data));
1960
+ if (NeedDictionaryUnification(data)) {
1961
+ RETURN_NOT_OK(WriteIndicesVarying(data, out_dict));
1962
+ } else {
1963
+ RETURN_NOT_OK(WriteIndicesUniform(data));
1964
+ *out_dict = arr_first.dictionary();
1965
+ }
1966
+ }
1967
+ return Status::OK();
1968
+ }
1969
+
1970
+ OwnedRefNoGIL dictionary_;
1971
+ bool ordered_;
1972
+ bool needs_copy_;
1973
+ };
1974
+
1975
+ class ExtensionWriter : public PandasWriter {
1976
+ public:
1977
+ using PandasWriter::PandasWriter;
1978
+
1979
+ Status Allocate() override {
1980
+ // no-op
1981
+ return Status::OK();
1982
+ }
1983
+
1984
+ Status TransferSingle(std::shared_ptr<ChunkedArray> data, PyObject* py_ref) override {
1985
+ PyAcquireGIL lock;
1986
+ PyObject* py_array;
1987
+ py_array = wrap_chunked_array(data);
1988
+ py_array_.reset(py_array);
1989
+
1990
+ return Status::OK();
1991
+ }
1992
+
1993
+ Status CopyInto(std::shared_ptr<ChunkedArray> data, int64_t rel_placement) override {
1994
+ return TransferSingle(data, nullptr);
1995
+ }
1996
+
1997
+ Status GetDataFrameResult(PyObject** out) override {
1998
+ PyAcquireGIL lock;
1999
+ PyObject* result = PyDict_New();
2000
+ RETURN_IF_PYERROR();
2001
+
2002
+ PyDict_SetItemString(result, "py_array", py_array_.obj());
2003
+ PyDict_SetItemString(result, "placement", placement_arr_.obj());
2004
+ *out = result;
2005
+ return Status::OK();
2006
+ }
2007
+
2008
+ Status GetSeriesResult(PyObject** out) override {
2009
+ *out = py_array_.detach();
2010
+ return Status::OK();
2011
+ }
2012
+
2013
+ protected:
2014
+ OwnedRefNoGIL py_array_;
2015
+ };
2016
+
2017
+ Status MakeWriter(const PandasOptions& options, PandasWriter::type writer_type,
2018
+ const DataType& type, int64_t num_rows, int num_columns,
2019
+ std::shared_ptr<PandasWriter>* writer) {
2020
+ #define BLOCK_CASE(NAME, TYPE) \
2021
+ case PandasWriter::NAME: \
2022
+ *writer = std::make_shared<TYPE>(options, num_rows, num_columns); \
2023
+ break;
2024
+
2025
+ #define CATEGORICAL_CASE(TYPE) \
2026
+ case TYPE::type_id: \
2027
+ *writer = std::make_shared<CategoricalWriter<TYPE>>(options, num_rows); \
2028
+ break;
2029
+
2030
+ #define TZ_CASE(NAME, TYPE) \
2031
+ case PandasWriter::NAME: { \
2032
+ const auto& ts_type = checked_cast<const TimestampType&>(type); \
2033
+ *writer = std::make_shared<TYPE>(options, ts_type.timezone(), num_rows); \
2034
+ } break;
2035
+
2036
+ switch (writer_type) {
2037
+ case PandasWriter::CATEGORICAL: {
2038
+ const auto& index_type = *checked_cast<const DictionaryType&>(type).index_type();
2039
+ switch (index_type.id()) {
2040
+ CATEGORICAL_CASE(Int8Type);
2041
+ CATEGORICAL_CASE(Int16Type);
2042
+ CATEGORICAL_CASE(Int32Type);
2043
+ CATEGORICAL_CASE(Int64Type);
2044
+ CATEGORICAL_CASE(UInt8Type);
2045
+ CATEGORICAL_CASE(UInt16Type);
2046
+ CATEGORICAL_CASE(UInt32Type);
2047
+ case Type::UINT64:
2048
+ return Status::TypeError(
2049
+ "Converting UInt64 dictionary indices to pandas is not supported.");
2050
+ default:
2051
+ // Unreachable
2052
+ ARROW_DCHECK(false);
2053
+ break;
2054
+ }
2055
+ } break;
2056
+ case PandasWriter::EXTENSION:
2057
+ *writer = std::make_shared<ExtensionWriter>(options, num_rows, num_columns);
2058
+ break;
2059
+ BLOCK_CASE(OBJECT, ObjectWriter);
2060
+ BLOCK_CASE(UINT8, UInt8Writer);
2061
+ BLOCK_CASE(INT8, Int8Writer);
2062
+ BLOCK_CASE(UINT16, UInt16Writer);
2063
+ BLOCK_CASE(INT16, Int16Writer);
2064
+ BLOCK_CASE(UINT32, UInt32Writer);
2065
+ BLOCK_CASE(INT32, Int32Writer);
2066
+ BLOCK_CASE(UINT64, UInt64Writer);
2067
+ BLOCK_CASE(INT64, Int64Writer);
2068
+ BLOCK_CASE(HALF_FLOAT, Float16Writer);
2069
+ BLOCK_CASE(FLOAT, Float32Writer);
2070
+ BLOCK_CASE(DOUBLE, Float64Writer);
2071
+ BLOCK_CASE(BOOL, BoolWriter);
2072
+ BLOCK_CASE(DATETIME_DAY, DatetimeDayWriter);
2073
+ BLOCK_CASE(DATETIME_SECOND, DatetimeSecondWriter);
2074
+ BLOCK_CASE(DATETIME_MILLI, DatetimeMilliWriter);
2075
+ BLOCK_CASE(DATETIME_MICRO, DatetimeMicroWriter);
2076
+ BLOCK_CASE(DATETIME_NANO, DatetimeNanoWriter);
2077
+ BLOCK_CASE(TIMEDELTA_SECOND, TimedeltaSecondWriter);
2078
+ BLOCK_CASE(TIMEDELTA_MILLI, TimedeltaMilliWriter);
2079
+ BLOCK_CASE(TIMEDELTA_MICRO, TimedeltaMicroWriter);
2080
+ BLOCK_CASE(TIMEDELTA_NANO, TimedeltaNanoWriter);
2081
+ TZ_CASE(DATETIME_SECOND_TZ, DatetimeSecondTZWriter);
2082
+ TZ_CASE(DATETIME_MILLI_TZ, DatetimeMilliTZWriter);
2083
+ TZ_CASE(DATETIME_MICRO_TZ, DatetimeMicroTZWriter);
2084
+ TZ_CASE(DATETIME_NANO_TZ, DatetimeNanoTZWriter);
2085
+ default:
2086
+ return Status::NotImplemented("Unsupported block type");
2087
+ }
2088
+
2089
+ #undef BLOCK_CASE
2090
+ #undef CATEGORICAL_CASE
2091
+
2092
+ return Status::OK();
2093
+ }
2094
+
2095
+ static Status GetPandasWriterType(const ChunkedArray& data, const PandasOptions& options,
2096
+ PandasWriter::type* output_type) {
2097
+ #define INTEGER_CASE(NAME) \
2098
+ *output_type = \
2099
+ data.null_count() > 0 \
2100
+ ? options.integer_object_nulls ? PandasWriter::OBJECT : PandasWriter::DOUBLE \
2101
+ : PandasWriter::NAME; \
2102
+ break;
2103
+
2104
+ switch (data.type()->id()) {
2105
+ case Type::BOOL:
2106
+ *output_type = data.null_count() > 0 ? PandasWriter::OBJECT : PandasWriter::BOOL;
2107
+ break;
2108
+ case Type::UINT8:
2109
+ INTEGER_CASE(UINT8);
2110
+ case Type::INT8:
2111
+ INTEGER_CASE(INT8);
2112
+ case Type::UINT16:
2113
+ INTEGER_CASE(UINT16);
2114
+ case Type::INT16:
2115
+ INTEGER_CASE(INT16);
2116
+ case Type::UINT32:
2117
+ INTEGER_CASE(UINT32);
2118
+ case Type::INT32:
2119
+ INTEGER_CASE(INT32);
2120
+ case Type::UINT64:
2121
+ INTEGER_CASE(UINT64);
2122
+ case Type::INT64:
2123
+ INTEGER_CASE(INT64);
2124
+ case Type::HALF_FLOAT:
2125
+ *output_type = PandasWriter::HALF_FLOAT;
2126
+ break;
2127
+ case Type::FLOAT:
2128
+ *output_type = PandasWriter::FLOAT;
2129
+ break;
2130
+ case Type::DOUBLE:
2131
+ *output_type = PandasWriter::DOUBLE;
2132
+ break;
2133
+ case Type::STRING: // fall through
2134
+ case Type::LARGE_STRING: // fall through
2135
+ case Type::STRING_VIEW: // fall through
2136
+ case Type::BINARY: // fall through
2137
+ case Type::LARGE_BINARY:
2138
+ case Type::BINARY_VIEW:
2139
+ case Type::NA: // fall through
2140
+ case Type::FIXED_SIZE_BINARY: // fall through
2141
+ case Type::STRUCT: // fall through
2142
+ case Type::TIME32: // fall through
2143
+ case Type::TIME64: // fall through
2144
+ case Type::DECIMAL32: // fall through
2145
+ case Type::DECIMAL64: // fall through
2146
+ case Type::DECIMAL128: // fall through
2147
+ case Type::DECIMAL256: // fall through
2148
+ case Type::INTERVAL_MONTH_DAY_NANO: // fall through
2149
+ *output_type = PandasWriter::OBJECT;
2150
+ break;
2151
+ case Type::DATE32:
2152
+ if (options.date_as_object) {
2153
+ *output_type = PandasWriter::OBJECT;
2154
+ } else if (options.coerce_temporal_nanoseconds) {
2155
+ *output_type = PandasWriter::DATETIME_NANO;
2156
+ } else if (options.to_numpy) {
2157
+ // Numpy supports Day, but Pandas does not
2158
+ *output_type = PandasWriter::DATETIME_DAY;
2159
+ } else {
2160
+ *output_type = PandasWriter::DATETIME_MILLI;
2161
+ }
2162
+ break;
2163
+ case Type::DATE64:
2164
+ if (options.date_as_object) {
2165
+ *output_type = PandasWriter::OBJECT;
2166
+ } else if (options.coerce_temporal_nanoseconds) {
2167
+ *output_type = PandasWriter::DATETIME_NANO;
2168
+ } else {
2169
+ *output_type = PandasWriter::DATETIME_MILLI;
2170
+ }
2171
+ break;
2172
+ case Type::TIMESTAMP: {
2173
+ const auto& ts_type = checked_cast<const TimestampType&>(*data.type());
2174
+ if (options.timestamp_as_object && ts_type.unit() != TimeUnit::NANO) {
2175
+ // Nanoseconds are never out of bounds for pandas, so in that case
2176
+ // we don't convert to object
2177
+ *output_type = PandasWriter::OBJECT;
2178
+ } else if (options.coerce_temporal_nanoseconds) {
2179
+ if (!ts_type.timezone().empty()) {
2180
+ *output_type = PandasWriter::DATETIME_NANO_TZ;
2181
+ } else {
2182
+ *output_type = PandasWriter::DATETIME_NANO;
2183
+ }
2184
+ } else {
2185
+ if (!ts_type.timezone().empty()) {
2186
+ switch (ts_type.unit()) {
2187
+ case TimeUnit::SECOND:
2188
+ *output_type = PandasWriter::DATETIME_SECOND_TZ;
2189
+ break;
2190
+ case TimeUnit::MILLI:
2191
+ *output_type = PandasWriter::DATETIME_MILLI_TZ;
2192
+ break;
2193
+ case TimeUnit::MICRO:
2194
+ *output_type = PandasWriter::DATETIME_MICRO_TZ;
2195
+ break;
2196
+ case TimeUnit::NANO:
2197
+ *output_type = PandasWriter::DATETIME_NANO_TZ;
2198
+ break;
2199
+ }
2200
+ } else {
2201
+ switch (ts_type.unit()) {
2202
+ case TimeUnit::SECOND:
2203
+ *output_type = PandasWriter::DATETIME_SECOND;
2204
+ break;
2205
+ case TimeUnit::MILLI:
2206
+ *output_type = PandasWriter::DATETIME_MILLI;
2207
+ break;
2208
+ case TimeUnit::MICRO:
2209
+ *output_type = PandasWriter::DATETIME_MICRO;
2210
+ break;
2211
+ case TimeUnit::NANO:
2212
+ *output_type = PandasWriter::DATETIME_NANO;
2213
+ break;
2214
+ }
2215
+ }
2216
+ }
2217
+ } break;
2218
+ case Type::DURATION: {
2219
+ const auto& dur_type = checked_cast<const DurationType&>(*data.type());
2220
+ if (options.coerce_temporal_nanoseconds) {
2221
+ *output_type = PandasWriter::TIMEDELTA_NANO;
2222
+ } else {
2223
+ switch (dur_type.unit()) {
2224
+ case TimeUnit::SECOND:
2225
+ *output_type = PandasWriter::TIMEDELTA_SECOND;
2226
+ break;
2227
+ case TimeUnit::MILLI:
2228
+ *output_type = PandasWriter::TIMEDELTA_MILLI;
2229
+ break;
2230
+ case TimeUnit::MICRO:
2231
+ *output_type = PandasWriter::TIMEDELTA_MICRO;
2232
+ break;
2233
+ case TimeUnit::NANO:
2234
+ *output_type = PandasWriter::TIMEDELTA_NANO;
2235
+ break;
2236
+ }
2237
+ }
2238
+ } break;
2239
+ case Type::FIXED_SIZE_LIST:
2240
+ case Type::LIST:
2241
+ case Type::LARGE_LIST:
2242
+ case Type::LIST_VIEW:
2243
+ case Type::LARGE_LIST_VIEW:
2244
+ case Type::MAP: {
2245
+ auto list_type = std::static_pointer_cast<BaseListType>(data.type());
2246
+ if (!ListTypeSupported(*list_type->value_type())) {
2247
+ return Status::NotImplemented("Not implemented type for Arrow list to pandas: ",
2248
+ list_type->value_type()->ToString());
2249
+ }
2250
+ *output_type = PandasWriter::OBJECT;
2251
+ } break;
2252
+ case Type::DICTIONARY:
2253
+ *output_type = PandasWriter::CATEGORICAL;
2254
+ break;
2255
+ case Type::EXTENSION:
2256
+ *output_type = PandasWriter::EXTENSION;
2257
+ break;
2258
+ default:
2259
+ return Status::NotImplemented(
2260
+ "No known equivalent Pandas block for Arrow data of type ",
2261
+ data.type()->ToString(), " is known.");
2262
+ }
2263
+ return Status::OK();
2264
+ }
2265
+
2266
+ // Construct the exact pandas "BlockManager" memory layout
2267
+ //
2268
+ // * For each column determine the correct output pandas type
2269
+ // * Allocate 2D blocks (ncols x nrows) for each distinct data type in output
2270
+ // * Allocate block placement arrays
2271
+ // * Write Arrow columns out into each slice of memory; populate block
2272
+ // * placement arrays as we go
2273
+ class PandasBlockCreator {
2274
+ public:
2275
+ using WriterMap = std::unordered_map<int, std::shared_ptr<PandasWriter>>;
2276
+
2277
+ explicit PandasBlockCreator(const PandasOptions& options, FieldVector fields,
2278
+ ChunkedArrayVector arrays)
2279
+ : options_(options), fields_(std::move(fields)), arrays_(std::move(arrays)) {
2280
+ num_columns_ = static_cast<int>(arrays_.size());
2281
+ if (num_columns_ > 0) {
2282
+ num_rows_ = arrays_[0]->length();
2283
+ }
2284
+ column_block_placement_.resize(num_columns_);
2285
+ }
2286
+ virtual ~PandasBlockCreator() = default;
2287
+
2288
+ virtual Status Convert(PyObject** out) = 0;
2289
+
2290
+ Status AppendBlocks(const WriterMap& blocks, PyObject* list) {
2291
+ for (const auto& it : blocks) {
2292
+ PyObject* item;
2293
+ RETURN_NOT_OK(it.second->GetDataFrameResult(&item));
2294
+ if (PyList_Append(list, item) < 0) {
2295
+ RETURN_IF_PYERROR();
2296
+ }
2297
+
2298
+ // ARROW-1017; PyList_Append increments object refcount
2299
+ Py_DECREF(item);
2300
+ }
2301
+ return Status::OK();
2302
+ }
2303
+
2304
+ protected:
2305
+ PandasOptions options_;
2306
+
2307
+ FieldVector fields_;
2308
+ ChunkedArrayVector arrays_;
2309
+ int num_columns_;
2310
+ int64_t num_rows_;
2311
+
2312
+ // column num -> relative placement within internal block
2313
+ std::vector<int> column_block_placement_;
2314
+ };
2315
+
2316
+ // Helper function for extension chunked arrays
2317
+ // Constructing a storage chunked array of an extension chunked array
2318
+ std::shared_ptr<ChunkedArray> GetStorageChunkedArray(std::shared_ptr<ChunkedArray> arr) {
2319
+ auto value_type = checked_cast<const ExtensionType&>(*arr->type()).storage_type();
2320
+ ArrayVector storage_arrays;
2321
+ for (int c = 0; c < arr->num_chunks(); c++) {
2322
+ const auto& arr_ext = checked_cast<const ExtensionArray&>(*arr->chunk(c));
2323
+ storage_arrays.emplace_back(arr_ext.storage());
2324
+ }
2325
+ return std::make_shared<ChunkedArray>(std::move(storage_arrays), value_type);
2326
+ };
2327
+
2328
+ // Helper function to decode RunEndEncodedArray
2329
+ Result<std::shared_ptr<ChunkedArray>> GetDecodedChunkedArray(
2330
+ std::shared_ptr<ChunkedArray> arr) {
2331
+ ARROW_ASSIGN_OR_RAISE(Datum decoded, compute::RunEndDecode(arr));
2332
+ ARROW_DCHECK(decoded.is_chunked_array());
2333
+ return decoded.chunked_array();
2334
+ };
2335
+
2336
+ class ConsolidatedBlockCreator : public PandasBlockCreator {
2337
+ public:
2338
+ using PandasBlockCreator::PandasBlockCreator;
2339
+
2340
+ Status Convert(PyObject** out) override {
2341
+ column_types_.resize(num_columns_);
2342
+ RETURN_NOT_OK(CreateBlocks());
2343
+ RETURN_NOT_OK(WriteTableToBlocks());
2344
+ PyAcquireGIL lock;
2345
+
2346
+ PyObject* result = PyList_New(0);
2347
+ RETURN_IF_PYERROR();
2348
+
2349
+ RETURN_NOT_OK(AppendBlocks(blocks_, result));
2350
+ RETURN_NOT_OK(AppendBlocks(singleton_blocks_, result));
2351
+
2352
+ *out = result;
2353
+ return Status::OK();
2354
+ }
2355
+
2356
+ Status GetBlockType(int column_index, PandasWriter::type* out) {
2357
+ if (options_.IsExtensionColumn(fields_[column_index]->name())) {
2358
+ *out = PandasWriter::EXTENSION;
2359
+ return Status::OK();
2360
+ } else {
2361
+ // In case of an extension array default to the storage type
2362
+ if (arrays_[column_index]->type()->id() == Type::EXTENSION) {
2363
+ arrays_[column_index] = GetStorageChunkedArray(arrays_[column_index]);
2364
+ }
2365
+ // In case of a RunEndEncodedArray default to the values type
2366
+ else if (arrays_[column_index]->type()->id() == Type::RUN_END_ENCODED) {
2367
+ ARROW_ASSIGN_OR_RAISE(arrays_[column_index],
2368
+ GetDecodedChunkedArray(arrays_[column_index]));
2369
+ }
2370
+ return GetPandasWriterType(*arrays_[column_index], options_, out);
2371
+ }
2372
+ }
2373
+
2374
+ Status CreateBlocks() {
2375
+ for (int i = 0; i < num_columns_; ++i) {
2376
+ const DataType& type = *arrays_[i]->type();
2377
+ PandasWriter::type output_type;
2378
+ RETURN_NOT_OK(GetBlockType(i, &output_type));
2379
+
2380
+ int block_placement = 0;
2381
+ std::shared_ptr<PandasWriter> writer;
2382
+ if (output_type == PandasWriter::CATEGORICAL ||
2383
+ output_type == PandasWriter::DATETIME_SECOND_TZ ||
2384
+ output_type == PandasWriter::DATETIME_MILLI_TZ ||
2385
+ output_type == PandasWriter::DATETIME_MICRO_TZ ||
2386
+ output_type == PandasWriter::DATETIME_NANO_TZ ||
2387
+ output_type == PandasWriter::EXTENSION) {
2388
+ RETURN_NOT_OK(MakeWriter(options_, output_type, type, num_rows_,
2389
+ /*num_columns=*/1, &writer));
2390
+ singleton_blocks_[i] = writer;
2391
+ } else {
2392
+ auto it = block_sizes_.find(output_type);
2393
+ if (it != block_sizes_.end()) {
2394
+ block_placement = it->second;
2395
+ // Increment count
2396
+ ++it->second;
2397
+ } else {
2398
+ // Add key to map
2399
+ block_sizes_[output_type] = 1;
2400
+ }
2401
+ }
2402
+ column_types_[i] = output_type;
2403
+ column_block_placement_[i] = block_placement;
2404
+ }
2405
+
2406
+ // Create normal non-categorical blocks
2407
+ for (const auto& it : this->block_sizes_) {
2408
+ PandasWriter::type output_type = static_cast<PandasWriter::type>(it.first);
2409
+ std::shared_ptr<PandasWriter> block;
2410
+ RETURN_NOT_OK(MakeWriter(this->options_, output_type, /*unused*/ *null(), num_rows_,
2411
+ it.second, &block));
2412
+ this->blocks_[output_type] = block;
2413
+ }
2414
+ return Status::OK();
2415
+ }
2416
+
2417
+ Status GetWriter(int i, std::shared_ptr<PandasWriter>* block) {
2418
+ PandasWriter::type output_type = this->column_types_[i];
2419
+ switch (output_type) {
2420
+ case PandasWriter::CATEGORICAL:
2421
+ case PandasWriter::DATETIME_SECOND_TZ:
2422
+ case PandasWriter::DATETIME_MILLI_TZ:
2423
+ case PandasWriter::DATETIME_MICRO_TZ:
2424
+ case PandasWriter::DATETIME_NANO_TZ:
2425
+ case PandasWriter::EXTENSION: {
2426
+ auto it = this->singleton_blocks_.find(i);
2427
+ if (it == this->singleton_blocks_.end()) {
2428
+ return Status::KeyError("No block allocated");
2429
+ }
2430
+ *block = it->second;
2431
+ } break;
2432
+ default:
2433
+ auto it = this->blocks_.find(output_type);
2434
+ if (it == this->blocks_.end()) {
2435
+ return Status::KeyError("No block allocated");
2436
+ }
2437
+ *block = it->second;
2438
+ break;
2439
+ }
2440
+ return Status::OK();
2441
+ }
2442
+
2443
+ Status WriteTableToBlocks() {
2444
+ auto WriteColumn = [this](int i) {
2445
+ std::shared_ptr<PandasWriter> block;
2446
+ RETURN_NOT_OK(this->GetWriter(i, &block));
2447
+ // ARROW-3789 Use std::move on the array to permit self-destructing
2448
+ return block->Write(std::move(arrays_[i]), i, this->column_block_placement_[i]);
2449
+ };
2450
+
2451
+ return OptionalParallelFor(options_.use_threads, num_columns_, WriteColumn);
2452
+ }
2453
+
2454
+ private:
2455
+ // column num -> block type id
2456
+ std::vector<PandasWriter::type> column_types_;
2457
+
2458
+ // block type -> type count
2459
+ std::unordered_map<int, int> block_sizes_;
2460
+ std::unordered_map<int, const DataType*> block_types_;
2461
+
2462
+ // block type -> block
2463
+ WriterMap blocks_;
2464
+
2465
+ WriterMap singleton_blocks_;
2466
+ };
2467
+
2468
+ /// \brief Create blocks for pandas.DataFrame block manager using one block per
2469
+ /// column strategy. This permits some zero-copy optimizations as well as the
2470
+ /// ability for the table to "self-destruct" if selected by the user.
2471
+ class SplitBlockCreator : public PandasBlockCreator {
2472
+ public:
2473
+ using PandasBlockCreator::PandasBlockCreator;
2474
+
2475
+ Status GetWriter(int i, std::shared_ptr<PandasWriter>* writer) {
2476
+ PandasWriter::type output_type = PandasWriter::OBJECT;
2477
+ const DataType& type = *arrays_[i]->type();
2478
+ if (options_.IsExtensionColumn(fields_[i]->name())) {
2479
+ output_type = PandasWriter::EXTENSION;
2480
+ } else {
2481
+ // Null count needed to determine output type
2482
+ RETURN_NOT_OK(GetPandasWriterType(*arrays_[i], options_, &output_type));
2483
+ }
2484
+ return MakeWriter(this->options_, output_type, type, num_rows_, 1, writer);
2485
+ }
2486
+
2487
+ Status Convert(PyObject** out) override {
2488
+ PyAcquireGIL lock;
2489
+
2490
+ PyObject* result = PyList_New(0);
2491
+ RETURN_IF_PYERROR();
2492
+
2493
+ for (int i = 0; i < num_columns_; ++i) {
2494
+ std::shared_ptr<PandasWriter> writer;
2495
+ RETURN_NOT_OK(GetWriter(i, &writer));
2496
+ // ARROW-3789 Use std::move on the array to permit self-destructing
2497
+ RETURN_NOT_OK(writer->Write(std::move(arrays_[i]), i, /*rel_placement=*/0));
2498
+
2499
+ PyObject* item;
2500
+ RETURN_NOT_OK(writer->GetDataFrameResult(&item));
2501
+ if (PyList_Append(result, item) < 0) {
2502
+ RETURN_IF_PYERROR();
2503
+ }
2504
+ // PyList_Append increments object refcount
2505
+ Py_DECREF(item);
2506
+ }
2507
+
2508
+ *out = result;
2509
+ return Status::OK();
2510
+ }
2511
+
2512
+ private:
2513
+ std::vector<std::shared_ptr<PandasWriter>> writers_;
2514
+ };
2515
+
2516
+ Status ConvertCategoricals(const PandasOptions& options, ChunkedArrayVector* arrays,
2517
+ FieldVector* fields) {
2518
+ std::vector<int> columns_to_encode;
2519
+
2520
+ // For Categorical conversions
2521
+ auto EncodeColumn = [&](int j) {
2522
+ int i = columns_to_encode[j];
2523
+ if (options.zero_copy_only) {
2524
+ return Status::Invalid("Need to dictionary encode a column, but ",
2525
+ "only zero-copy conversions allowed");
2526
+ }
2527
+ compute::ExecContext ctx(options.pool);
2528
+ ARROW_ASSIGN_OR_RAISE(
2529
+ Datum out, DictionaryEncode((*arrays)[i],
2530
+ compute::DictionaryEncodeOptions::Defaults(), &ctx));
2531
+ (*arrays)[i] = out.chunked_array();
2532
+ (*fields)[i] = (*fields)[i]->WithType((*arrays)[i]->type());
2533
+ return Status::OK();
2534
+ };
2535
+
2536
+ if (options.HasCategoricalColumns()) {
2537
+ for (int i = 0; i < static_cast<int>(arrays->size()); i++) {
2538
+ if ((*arrays)[i]->type()->id() != Type::DICTIONARY &&
2539
+ options.IsCategoricalColumn((*fields)[i]->name())) {
2540
+ columns_to_encode.push_back(i);
2541
+ }
2542
+ }
2543
+ }
2544
+ if (options.strings_to_categorical) {
2545
+ for (int i = 0; i < static_cast<int>(arrays->size()); i++) {
2546
+ if (is_base_binary_like((*arrays)[i]->type()->id()) ||
2547
+ is_binary_view_like((*arrays)[i]->type()->id())) {
2548
+ columns_to_encode.push_back(i);
2549
+ }
2550
+ }
2551
+ }
2552
+ return OptionalParallelFor(options.use_threads,
2553
+ static_cast<int>(columns_to_encode.size()), EncodeColumn);
2554
+ }
2555
+
2556
+ } // namespace
2557
+
2558
+ Status ConvertArrayToPandas(const PandasOptions& options, std::shared_ptr<Array> arr,
2559
+ PyObject* py_ref, PyObject** out) {
2560
+ return ConvertChunkedArrayToPandas(
2561
+ options, std::make_shared<ChunkedArray>(std::move(arr)), py_ref, out);
2562
+ }
2563
+
2564
+ Status ConvertChunkedArrayToPandas(const PandasOptions& options,
2565
+ std::shared_ptr<ChunkedArray> arr, PyObject* py_ref,
2566
+ PyObject** out) {
2567
+ if (options.decode_dictionaries && arr->type()->id() == Type::DICTIONARY) {
2568
+ // XXX we should return an error as below if options.zero_copy_only
2569
+ // is true, but that would break compatibility with existing tests.
2570
+ const auto& dense_type =
2571
+ checked_cast<const DictionaryType&>(*arr->type()).value_type();
2572
+ RETURN_NOT_OK(DecodeDictionaries(options.pool, dense_type, &arr));
2573
+ ARROW_DCHECK_NE(arr->type()->id(), Type::DICTIONARY);
2574
+
2575
+ // The original Python DictionaryArray won't own the memory anymore
2576
+ // as we actually built a new array when we decoded the DictionaryArray
2577
+ // thus let the final resulting numpy array own the memory through a Capsule
2578
+ py_ref = nullptr;
2579
+ }
2580
+
2581
+ if (options.strings_to_categorical && (is_base_binary_like(arr->type()->id()) ||
2582
+ is_binary_view_like(arr->type()->id()))) {
2583
+ if (options.zero_copy_only) {
2584
+ return Status::Invalid("Need to dictionary encode a column, but ",
2585
+ "only zero-copy conversions allowed");
2586
+ }
2587
+ compute::ExecContext ctx(options.pool);
2588
+ ARROW_ASSIGN_OR_RAISE(
2589
+ Datum out,
2590
+ DictionaryEncode(arr, compute::DictionaryEncodeOptions::Defaults(), &ctx));
2591
+ arr = out.chunked_array();
2592
+ }
2593
+
2594
+ PandasOptions modified_options = options;
2595
+ modified_options.strings_to_categorical = false;
2596
+
2597
+ // ARROW-7596: We permit the hybrid Series/DataFrame code path to do zero copy
2598
+ // optimizations that we do not allow in the default case when converting
2599
+ // Table->DataFrame
2600
+ modified_options.allow_zero_copy_blocks = true;
2601
+
2602
+ // In case of an extension array default to the storage type
2603
+ if (arr->type()->id() == Type::EXTENSION) {
2604
+ arr = GetStorageChunkedArray(arr);
2605
+ }
2606
+ // In case of a RunEndEncodedArray decode the array
2607
+ else if (arr->type()->id() == Type::RUN_END_ENCODED) {
2608
+ if (options.zero_copy_only) {
2609
+ return Status::Invalid("Need to dencode a RunEndEncodedArray, but ",
2610
+ "only zero-copy conversions allowed");
2611
+ }
2612
+ ARROW_ASSIGN_OR_RAISE(arr, GetDecodedChunkedArray(arr));
2613
+
2614
+ // Because we built a new array when we decoded the RunEndEncodedArray
2615
+ // the final resulting numpy array should own the memory through a Capsule
2616
+ py_ref = nullptr;
2617
+ }
2618
+
2619
+ PandasWriter::type output_type;
2620
+ RETURN_NOT_OK(GetPandasWriterType(*arr, modified_options, &output_type));
2621
+ if (options.decode_dictionaries) {
2622
+ ARROW_DCHECK_NE(output_type, PandasWriter::CATEGORICAL);
2623
+ }
2624
+
2625
+ std::shared_ptr<PandasWriter> writer;
2626
+ RETURN_NOT_OK(MakeWriter(modified_options, output_type, *arr->type(), arr->length(),
2627
+ /*num_columns=*/1, &writer));
2628
+ RETURN_NOT_OK(writer->TransferSingle(std::move(arr), py_ref));
2629
+ return writer->GetSeriesResult(out);
2630
+ }
2631
+
2632
+ Status ConvertTableToPandas(const PandasOptions& options, std::shared_ptr<Table> table,
2633
+ PyObject** out) {
2634
+ ChunkedArrayVector arrays = table->columns();
2635
+ FieldVector fields = table->fields();
2636
+
2637
+ // ARROW-3789: allow "self-destructing" by releasing references to columns as
2638
+ // we convert them to pandas
2639
+ table = nullptr;
2640
+
2641
+ RETURN_NOT_OK(ConvertCategoricals(options, &arrays, &fields));
2642
+
2643
+ PandasOptions modified_options = options;
2644
+ modified_options.strings_to_categorical = false;
2645
+ modified_options.categorical_columns.reset();
2646
+
2647
+ if (options.split_blocks) {
2648
+ modified_options.allow_zero_copy_blocks = true;
2649
+ SplitBlockCreator helper(modified_options, std::move(fields), std::move(arrays));
2650
+ return helper.Convert(out);
2651
+ } else {
2652
+ ConsolidatedBlockCreator helper(modified_options, std::move(fields),
2653
+ std::move(arrays));
2654
+ return helper.Convert(out);
2655
+ }
2656
+ }
2657
+
2658
+ } // namespace py
2659
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/arrow_to_pandas.h ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 pandas's NumPy-based data representation
19
+ // and Arrow data structures
20
+
21
+ #pragma once
22
+
23
+ #include "arrow/python/platform.h"
24
+
25
+ #include <memory>
26
+ #include <string>
27
+ #include <unordered_set>
28
+
29
+ #include "arrow/memory_pool.h"
30
+ #include "arrow/python/visibility.h"
31
+
32
+ namespace arrow {
33
+
34
+ class Array;
35
+ class ChunkedArray;
36
+ class Column;
37
+ class DataType;
38
+ class MemoryPool;
39
+ class Status;
40
+ class Table;
41
+
42
+ namespace py {
43
+
44
+ enum class MapConversionType {
45
+ DEFAULT, // convert arrow maps to assoc lists (list of kev-value tuples) in Pandas
46
+ LOSSY, // report warnings when lossiness is encountered due to duplicate keys
47
+ STRICT_, // raise a Python exception when lossiness is encountered due to duplicate
48
+ // keys
49
+ };
50
+
51
+ struct PandasOptions {
52
+ bool HasCategoricalColumns() const {
53
+ return categorical_columns && !categorical_columns->empty();
54
+ }
55
+
56
+ bool IsCategoricalColumn(const std::string& name) const {
57
+ return categorical_columns && categorical_columns->count(name);
58
+ }
59
+
60
+ bool HasExtensionColumns() const {
61
+ return extension_columns && !extension_columns->empty();
62
+ }
63
+
64
+ bool IsExtensionColumn(const std::string& name) const {
65
+ return extension_columns && extension_columns->count(name);
66
+ }
67
+
68
+ /// arrow::MemoryPool to use for memory allocations
69
+ MemoryPool* pool = default_memory_pool();
70
+
71
+ /// If true, we will convert all string columns to categoricals
72
+ bool strings_to_categorical = false;
73
+ bool zero_copy_only = false;
74
+ bool integer_object_nulls = false;
75
+ bool date_as_object = false;
76
+ bool timestamp_as_object = false;
77
+ bool use_threads = false;
78
+
79
+ /// Coerce all date and timestamp to datetime64[ns]
80
+ bool coerce_temporal_nanoseconds = false;
81
+
82
+ /// Used to maintain backwards compatibility for
83
+ /// timezone bugs (see ARROW-9528). Should be removed
84
+ /// after Arrow 2.0 release.
85
+ bool ignore_timezone = false;
86
+
87
+ /// \brief If true, do not create duplicate PyObject versions of equal
88
+ /// objects. This only applies to immutable objects like strings or datetime
89
+ /// objects
90
+ bool deduplicate_objects = false;
91
+
92
+ /// \brief For certain data types, a cast is needed in order to store the
93
+ /// data in a pandas DataFrame or Series (e.g. timestamps are always stored
94
+ /// as nanoseconds in pandas). This option controls whether it is a safe
95
+ /// cast or not.
96
+ bool safe_cast = true;
97
+
98
+ /// \brief If true, create one block per column rather than consolidated
99
+ /// blocks (1 per data type). Do zero-copy wrapping when there are no
100
+ /// nulls. pandas currently will consolidate the blocks on its own, causing
101
+ /// increased memory use, so keep this in mind if you are working on a
102
+ /// memory-constrained situation.
103
+ bool split_blocks = false;
104
+
105
+ /// \brief If true, allow non-writable zero-copy views to be created for
106
+ /// single column blocks. This option is also used to provide zero copy for
107
+ /// Series data
108
+ bool allow_zero_copy_blocks = false;
109
+
110
+ /// \brief If true, attempt to deallocate buffers in passed Arrow object if
111
+ /// it is the only remaining shared_ptr copy of it. See ARROW-3789 for
112
+ /// original context for this feature. Only currently implemented for Table
113
+ /// conversions
114
+ bool self_destruct = false;
115
+
116
+ /// \brief The default behavior (DEFAULT), is to convert Arrow Map arrays to
117
+ /// Python association lists (list-of-tuples) in the same order as the Arrow
118
+ /// Map, as in [(key1, value1), (key2, value2), ...]
119
+ /// If LOSSY or STRICT, convert Arrow Map arrays to native Python dicts.
120
+ /// This can change the ordering of (key, value) pairs, and will deduplicate
121
+ /// multiple keys, resulting in a possible loss of data.
122
+ /// If 'lossy', this key deduplication results in a warning printed
123
+ /// when detected. If 'strict', this instead results in an exception
124
+ /// being raised when detected.
125
+ MapConversionType maps_as_pydicts = MapConversionType::DEFAULT;
126
+
127
+ // Used internally for nested arrays.
128
+ bool decode_dictionaries = false;
129
+
130
+ // Columns that should be casted to categorical
131
+ //
132
+ // This is wrapped in a shared_ptr because this struct is copied internally for
133
+ // each column or nested field (see GH-47861).
134
+ std::shared_ptr<const std::unordered_set<std::string>> categorical_columns;
135
+
136
+ // Columns that should be passed through to be converted to
137
+ // ExtensionArray/Block
138
+ std::shared_ptr<const std::unordered_set<std::string>> extension_columns;
139
+
140
+ // Used internally to decipher between to_numpy() and to_pandas() when
141
+ // the expected output differs
142
+ bool to_numpy = false;
143
+ };
144
+
145
+ ARROW_PYTHON_EXPORT
146
+ Status ConvertArrayToPandas(const PandasOptions& options, std::shared_ptr<Array> arr,
147
+ PyObject* py_ref, PyObject** out);
148
+
149
+ ARROW_PYTHON_EXPORT
150
+ Status ConvertChunkedArrayToPandas(const PandasOptions& options,
151
+ std::shared_ptr<ChunkedArray> col, PyObject* py_ref,
152
+ PyObject** out);
153
+
154
+ // Convert a whole table as efficiently as possible to a pandas.DataFrame.
155
+ //
156
+ // The returned Python object is a list of tuples consisting of the exact 2D
157
+ // BlockManager structure of the pandas.DataFrame used as of pandas 0.19.x.
158
+ //
159
+ // tuple item: (indices: ndarray[int32], block: ndarray[TYPE, ndim=2])
160
+ ARROW_PYTHON_EXPORT
161
+ Status ConvertTableToPandas(const PandasOptions& options, std::shared_ptr<Table> table,
162
+ PyObject** out);
163
+
164
+ } // namespace py
165
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/arrow_to_python_internal.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include "arrow/array.h"
21
+ #include "arrow/python/platform.h"
22
+
23
+ namespace arrow {
24
+ namespace py {
25
+ namespace internal {
26
+ // TODO(ARROW-12976): See if we can refactor Pandas ObjectWriter logic
27
+ // to the .cc file and move this there as well if we can.
28
+
29
+ // Converts array to a sequency of python objects.
30
+ template <typename ArrayType, typename WriteValue, typename Assigner>
31
+ inline Status WriteArrayObjects(const ArrayType& arr, WriteValue&& write_func,
32
+ Assigner out_values) {
33
+ // TODO(ARROW-12976): Use visitor here?
34
+ const bool has_nulls = arr.null_count() > 0;
35
+ for (int64_t i = 0; i < arr.length(); ++i) {
36
+ if (has_nulls && arr.IsNull(i)) {
37
+ Py_INCREF(Py_None);
38
+ *out_values = Py_None;
39
+ } else {
40
+ RETURN_NOT_OK(write_func(arr.GetView(i), out_values));
41
+ }
42
+ ++out_values;
43
+ }
44
+ return Status::OK();
45
+ }
46
+
47
+ } // namespace internal
48
+ } // namespace py
49
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/async.h ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <utility>
21
+
22
+ #include "arrow/python/common.h"
23
+ #include "arrow/status.h"
24
+ #include "arrow/util/future.h"
25
+
26
+ namespace arrow::py {
27
+
28
+ /// \brief Bind a Python callback to an arrow::Future.
29
+ ///
30
+ /// If the Future finishes successfully, py_wrapper is called with its
31
+ /// result value and should return a PyObject*. If py_wrapper is successful,
32
+ /// py_cb is called with its return value.
33
+ ///
34
+ /// If either the Future or py_wrapper fails, py_cb is called with the
35
+ /// associated Python exception.
36
+ ///
37
+ /// \param future The future to bind to.
38
+ /// \param py_cb The Python callback function. Will be passed the result of
39
+ /// py_wrapper, or a Python exception if the future failed or one was
40
+ /// raised by py_wrapper.
41
+ /// \param py_wrapper A function (likely defined in Cython) to convert the C++
42
+ /// result of the future to a Python object.
43
+ template <typename T, typename PyWrapper = PyObject* (*)(T)>
44
+ void BindFuture(Future<T> future, PyObject* py_cb, PyWrapper py_wrapper) {
45
+ Py_INCREF(py_cb);
46
+ OwnedRefNoGIL cb_ref(py_cb);
47
+
48
+ auto future_cb = [cb_ref = std::move(cb_ref),
49
+ py_wrapper = std::move(py_wrapper)](Result<T> result) {
50
+ SafeCallIntoPythonVoid([&]() {
51
+ OwnedRef py_value_or_exc{WrapResult(std::move(result), std::move(py_wrapper))};
52
+ Py_XDECREF(
53
+ PyObject_CallFunctionObjArgs(cb_ref.obj(), py_value_or_exc.obj(), NULLPTR));
54
+ ARROW_WARN_NOT_OK(CheckPyError(), "Internal error in async call");
55
+ });
56
+ };
57
+ future.AddCallback(std::move(future_cb));
58
+ }
59
+
60
+ } // namespace arrow::py
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/benchmark.cc ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include "arrow/python/benchmark.h"
19
+ #include "arrow/python/helpers.h"
20
+
21
+ namespace arrow {
22
+ namespace py {
23
+ namespace benchmark {
24
+
25
+ void Benchmark_PandasObjectIsNull(PyObject* list) {
26
+ if (!PyList_CheckExact(list)) {
27
+ PyErr_SetString(PyExc_TypeError, "expected a list");
28
+ return;
29
+ }
30
+ Py_ssize_t i, n = PyList_GET_SIZE(list);
31
+ for (i = 0; i < n; i++) {
32
+ internal::PandasObjectIsNull(PyList_GET_ITEM(list, i));
33
+ }
34
+ }
35
+
36
+ } // namespace benchmark
37
+ } // namespace py
38
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/benchmark.h ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include "arrow/python/platform.h"
21
+
22
+ #include "arrow/python/visibility.h"
23
+
24
+ namespace arrow {
25
+ namespace py {
26
+ namespace benchmark {
27
+
28
+ // Micro-benchmark routines for use from ASV
29
+
30
+ // Run PandasObjectIsNull() once over every object in *list*
31
+ ARROW_PYTHON_EXPORT
32
+ void Benchmark_PandasObjectIsNull(PyObject* list);
33
+
34
+ } // namespace benchmark
35
+ } // namespace py
36
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/common.cc ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include "arrow/python/common.h"
19
+
20
+ #include <cstdlib>
21
+ #include <mutex>
22
+ #include <sstream>
23
+ #include <string>
24
+
25
+ #include "arrow/memory_pool.h"
26
+ #include "arrow/status.h"
27
+ #include "arrow/util/checked_cast.h"
28
+ #include "arrow/util/logging.h"
29
+
30
+ #include "arrow/python/helpers.h"
31
+
32
+ namespace arrow {
33
+
34
+ using internal::checked_cast;
35
+
36
+ namespace py {
37
+
38
+ static std::mutex memory_pool_mutex;
39
+ static MemoryPool* default_python_pool = nullptr;
40
+
41
+ void set_default_memory_pool(MemoryPool* pool) {
42
+ std::lock_guard<std::mutex> guard(memory_pool_mutex);
43
+ default_python_pool = pool;
44
+ }
45
+
46
+ MemoryPool* get_memory_pool() {
47
+ std::lock_guard<std::mutex> guard(memory_pool_mutex);
48
+ if (default_python_pool) {
49
+ return default_python_pool;
50
+ } else {
51
+ return default_memory_pool();
52
+ }
53
+ }
54
+
55
+ // ----------------------------------------------------------------------
56
+ // PythonErrorDetail
57
+
58
+ namespace {
59
+
60
+ const char kErrorDetailTypeId[] = "arrow::py::PythonErrorDetail";
61
+
62
+ // Try to match the Python exception type with an appropriate Status code
63
+ StatusCode MapPyError(PyObject* exc_type) {
64
+ StatusCode code;
65
+
66
+ if (PyErr_GivenExceptionMatches(exc_type, PyExc_MemoryError)) {
67
+ code = StatusCode::OutOfMemory;
68
+ } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_IndexError)) {
69
+ code = StatusCode::IndexError;
70
+ } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_KeyError)) {
71
+ code = StatusCode::KeyError;
72
+ } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_TypeError)) {
73
+ code = StatusCode::TypeError;
74
+ } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_ValueError) ||
75
+ PyErr_GivenExceptionMatches(exc_type, PyExc_OverflowError)) {
76
+ code = StatusCode::Invalid;
77
+ } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_EnvironmentError)) {
78
+ code = StatusCode::IOError;
79
+ } else if (PyErr_GivenExceptionMatches(exc_type, PyExc_NotImplementedError)) {
80
+ code = StatusCode::NotImplemented;
81
+ } else {
82
+ code = StatusCode::UnknownError;
83
+ }
84
+ return code;
85
+ }
86
+
87
+ // PythonErrorDetail indicates a Python exception was raised.
88
+ class PythonErrorDetail : public StatusDetail {
89
+ public:
90
+ const char* type_id() const override { return kErrorDetailTypeId; }
91
+
92
+ std::string ToString() const override {
93
+ // This is simple enough not to need the GIL
94
+ Result<std::string> result = FormatImpl();
95
+
96
+ if (result.ok()) {
97
+ return result.ValueOrDie();
98
+ } else {
99
+ // Fallback to just the exception type
100
+ const auto ty = reinterpret_cast<const PyTypeObject*>(exc_type_.obj());
101
+ return std::string("Python exception: ") + ty->tp_name;
102
+ }
103
+ }
104
+
105
+ void RestorePyError() const {
106
+ Py_INCREF(exc_type_.obj());
107
+ Py_INCREF(exc_value_.obj());
108
+ Py_INCREF(exc_traceback_.obj());
109
+ PyErr_Restore(exc_type_.obj(), exc_value_.obj(), exc_traceback_.obj());
110
+ }
111
+
112
+ PyObject* exc_type() const { return exc_type_.obj(); }
113
+
114
+ PyObject* exc_value() const { return exc_value_.obj(); }
115
+
116
+ static std::shared_ptr<PythonErrorDetail> FromPyError() {
117
+ PyObject* exc_type = nullptr;
118
+ PyObject* exc_value = nullptr;
119
+ PyObject* exc_traceback = nullptr;
120
+
121
+ PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
122
+ PyErr_NormalizeException(&exc_type, &exc_value, &exc_traceback);
123
+ ARROW_CHECK(exc_type)
124
+ << "PythonErrorDetail::FromPyError called without a Python error set";
125
+ ARROW_DCHECK(PyType_Check(exc_type));
126
+ ARROW_DCHECK(exc_value); // Ensured by PyErr_NormalizeException, double-check
127
+ if (exc_traceback == nullptr) {
128
+ // Needed by PyErr_Restore()
129
+ Py_INCREF(Py_None);
130
+ exc_traceback = Py_None;
131
+ }
132
+
133
+ std::shared_ptr<PythonErrorDetail> detail(new PythonErrorDetail);
134
+ detail->exc_type_.reset(exc_type);
135
+ detail->exc_value_.reset(exc_value);
136
+ detail->exc_traceback_.reset(exc_traceback);
137
+ return detail;
138
+ }
139
+
140
+ protected:
141
+ Result<std::string> FormatImpl() const {
142
+ PyAcquireGIL lock;
143
+
144
+ // Use traceback.format_exception()
145
+ OwnedRef traceback_module;
146
+ RETURN_NOT_OK(internal::ImportModule("traceback", &traceback_module));
147
+
148
+ OwnedRef fmt_exception;
149
+ RETURN_NOT_OK(internal::ImportFromModule(traceback_module.obj(), "format_exception",
150
+ &fmt_exception));
151
+
152
+ OwnedRef formatted;
153
+ formatted.reset(PyObject_CallFunctionObjArgs(fmt_exception.obj(), exc_type_.obj(),
154
+ exc_value_.obj(), exc_traceback_.obj(),
155
+ NULL));
156
+ RETURN_IF_PYERROR();
157
+
158
+ std::stringstream ss;
159
+ ss << "Python exception: ";
160
+ Py_ssize_t num_lines = PySequence_Length(formatted.obj());
161
+ RETURN_IF_PYERROR();
162
+
163
+ for (Py_ssize_t i = 0; i < num_lines; ++i) {
164
+ Py_ssize_t line_size;
165
+
166
+ PyObject* line = PySequence_GetItem(formatted.obj(), i);
167
+ RETURN_IF_PYERROR();
168
+
169
+ const char* data = PyUnicode_AsUTF8AndSize(line, &line_size);
170
+ RETURN_IF_PYERROR();
171
+
172
+ ss << std::string_view(data, line_size);
173
+ }
174
+ return ss.str();
175
+ }
176
+
177
+ PythonErrorDetail() = default;
178
+
179
+ OwnedRefNoGIL exc_type_, exc_value_, exc_traceback_;
180
+ };
181
+
182
+ } // namespace
183
+
184
+ // ----------------------------------------------------------------------
185
+ // Python exception <-> Status
186
+
187
+ Status ConvertPyError(StatusCode code) {
188
+ auto detail = PythonErrorDetail::FromPyError();
189
+ if (code == StatusCode::UnknownError) {
190
+ code = MapPyError(detail->exc_type());
191
+ }
192
+
193
+ std::string message;
194
+ RETURN_NOT_OK(internal::PyObject_StdStringStr(detail->exc_value(), &message));
195
+ return Status(code, message, detail);
196
+ }
197
+
198
+ bool IsPyError(const Status& status) {
199
+ if (status.ok()) {
200
+ return false;
201
+ }
202
+ auto detail = status.detail();
203
+ bool result = detail != nullptr && detail->type_id() == kErrorDetailTypeId;
204
+ return result;
205
+ }
206
+
207
+ void RestorePyError(const Status& status) {
208
+ ARROW_CHECK(IsPyError(status));
209
+ const auto& detail = checked_cast<const PythonErrorDetail&>(*status.detail());
210
+ detail.RestorePyError();
211
+ }
212
+
213
+ // ----------------------------------------------------------------------
214
+ // PyBuffer
215
+
216
+ PyBuffer::PyBuffer() : Buffer(nullptr, 0) {}
217
+
218
+ Status PyBuffer::Init(PyObject* obj) {
219
+ if (!PyObject_GetBuffer(obj, &py_buf_, PyBUF_ANY_CONTIGUOUS)) {
220
+ data_ = reinterpret_cast<const uint8_t*>(py_buf_.buf);
221
+ ARROW_CHECK_NE(data_, nullptr) << "Null pointer in Py_buffer";
222
+ size_ = py_buf_.len;
223
+ capacity_ = py_buf_.len;
224
+ is_mutable_ = !py_buf_.readonly;
225
+ return Status::OK();
226
+ } else {
227
+ return ConvertPyError(StatusCode::Invalid);
228
+ }
229
+ }
230
+
231
+ Result<std::shared_ptr<Buffer>> PyBuffer::FromPyObject(PyObject* obj) {
232
+ PyBuffer* buf = new PyBuffer();
233
+ std::shared_ptr<Buffer> res(buf);
234
+ RETURN_NOT_OK(buf->Init(obj));
235
+ return res;
236
+ }
237
+
238
+ PyBuffer::~PyBuffer() {
239
+ if (data_ != nullptr) {
240
+ PyAcquireGIL lock;
241
+ PyBuffer_Release(&py_buf_);
242
+ }
243
+ }
244
+
245
+ } // namespace py
246
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/common.h ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <functional>
21
+ #include <memory>
22
+ #include <optional>
23
+ #include <utility>
24
+
25
+ #include "arrow/buffer.h"
26
+ #include "arrow/python/pyarrow.h"
27
+ #include "arrow/python/visibility.h"
28
+ #include "arrow/result.h"
29
+ #include "arrow/util/macros.h"
30
+
31
+ namespace arrow {
32
+
33
+ class MemoryPool;
34
+ template <class T>
35
+ class Result;
36
+
37
+ namespace py {
38
+
39
+ // Convert current Python error to a Status. The Python error state is cleared
40
+ // and can be restored with RestorePyError().
41
+ ARROW_PYTHON_EXPORT Status ConvertPyError(StatusCode code = StatusCode::UnknownError);
42
+ // Query whether the given Status is a Python error (as wrapped by ConvertPyError()).
43
+ ARROW_PYTHON_EXPORT bool IsPyError(const Status& status);
44
+ // Restore a Python error wrapped in a Status.
45
+ ARROW_PYTHON_EXPORT void RestorePyError(const Status& status);
46
+
47
+ // Catch a pending Python exception and return the corresponding Status.
48
+ // If no exception is pending, Status::OK() is returned.
49
+ inline Status CheckPyError(StatusCode code = StatusCode::UnknownError) {
50
+ if (ARROW_PREDICT_TRUE(!PyErr_Occurred())) {
51
+ return Status::OK();
52
+ } else {
53
+ return ConvertPyError(code);
54
+ }
55
+ }
56
+
57
+ #define RETURN_IF_PYERROR() ARROW_RETURN_NOT_OK(CheckPyError())
58
+
59
+ #define PY_RETURN_IF_ERROR(CODE) ARROW_RETURN_NOT_OK(CheckPyError(CODE))
60
+
61
+ // For Cython, as you can't define template C++ functions in Cython, only use them.
62
+ // This function can set a Python exception. It assumes that T has a (cheap)
63
+ // default constructor.
64
+ template <class T>
65
+ T GetResultValue(Result<T> result) {
66
+ if (ARROW_PREDICT_TRUE(result.ok())) {
67
+ return *std::move(result);
68
+ } else {
69
+ int r = internal::check_status(result.status()); // takes the GIL
70
+ assert(r == -1); // should have errored out
71
+ ARROW_UNUSED(r);
72
+ return {};
73
+ }
74
+ }
75
+
76
+ /// \brief Wrap a Result and return the corresponding Python object.
77
+ ///
78
+ /// If the Result is successful, py_wrapper is called with its result value
79
+ /// and should return a PyObject*. If py_wrapper is successful (returns
80
+ /// a non-NULL value), its return value is returned.
81
+ ///
82
+ /// If either the Result or py_wrapper fails, the associated Python exception
83
+ /// is raised and NULL is returned.
84
+ //
85
+ /// \param result The Result whose value to wrap in a Python object.
86
+ /// \param py_wrapper A function (likely defined in Cython) to convert the C++
87
+ /// value of the Result to a Python object.
88
+ /// \return A new Python reference, or NULL if an exception occurred
89
+ template <typename T, typename PyWrapper = PyObject* (*)(T)>
90
+ PyObject* WrapResult(Result<T> result, PyWrapper&& py_wrapper) {
91
+ static_assert(std::is_same_v<PyObject*, decltype(py_wrapper(std::declval<T>()))>,
92
+ "PyWrapper argument to WrapResult should return a PyObject* "
93
+ "when called with a T*");
94
+ Status st = result.status();
95
+ if (st.ok()) {
96
+ PyObject* py_value = py_wrapper(result.MoveValueUnsafe());
97
+ st = CheckPyError();
98
+ if (st.ok()) {
99
+ return py_value;
100
+ }
101
+ Py_XDECREF(py_value); // should be null, but who knows
102
+ }
103
+ // Status is an error, convert it to an exception.
104
+ return internal::convert_status(st);
105
+ }
106
+
107
+ // A RAII-style helper that ensures the GIL is acquired inside a lexical block.
108
+ class ARROW_PYTHON_EXPORT PyAcquireGIL {
109
+ public:
110
+ PyAcquireGIL() : acquired_gil_(false) { acquire(); }
111
+
112
+ ~PyAcquireGIL() { release(); }
113
+
114
+ void acquire() {
115
+ if (!acquired_gil_) {
116
+ state_ = PyGILState_Ensure();
117
+ acquired_gil_ = true;
118
+ }
119
+ }
120
+
121
+ // idempotent
122
+ void release() {
123
+ if (acquired_gil_) {
124
+ PyGILState_Release(state_);
125
+ acquired_gil_ = false;
126
+ }
127
+ }
128
+
129
+ private:
130
+ bool acquired_gil_;
131
+ PyGILState_STATE state_;
132
+ ARROW_DISALLOW_COPY_AND_ASSIGN(PyAcquireGIL);
133
+ };
134
+
135
+ // A RAII-style helper that releases the GIL until the end of a lexical block
136
+ class ARROW_PYTHON_EXPORT PyReleaseGIL {
137
+ public:
138
+ PyReleaseGIL() : ptr_(PyEval_SaveThread(), &unique_ptr_deleter) {}
139
+
140
+ private:
141
+ static void unique_ptr_deleter(PyThreadState* state) {
142
+ if (state) {
143
+ PyEval_RestoreThread(state);
144
+ }
145
+ }
146
+ std::unique_ptr<PyThreadState, decltype(&unique_ptr_deleter)> ptr_;
147
+ };
148
+
149
+ // A helper to call safely into the Python interpreter from arbitrary C++ code.
150
+ // The GIL is acquired, and the current thread's error status is preserved.
151
+ template <typename Function>
152
+ auto SafeCallIntoPython(Function&& func) -> decltype(func()) {
153
+ PyAcquireGIL lock;
154
+ PyObject* exc_type;
155
+ PyObject* exc_value;
156
+ PyObject* exc_traceback;
157
+ PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
158
+ auto maybe_status = std::forward<Function>(func)();
159
+ // If the return Status is a "Python error", the current Python error status
160
+ // describes the error and shouldn't be clobbered.
161
+ if (!IsPyError(::arrow::ToStatus(maybe_status)) && exc_type != NULLPTR) {
162
+ PyErr_Restore(exc_type, exc_value, exc_traceback);
163
+ }
164
+ return maybe_status;
165
+ }
166
+
167
+ template <typename Function>
168
+ auto SafeCallIntoPythonVoid(Function&& func) -> decltype(func()) {
169
+ PyAcquireGIL lock;
170
+ PyObject* exc_type;
171
+ PyObject* exc_value;
172
+ PyObject* exc_traceback;
173
+ PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
174
+ func();
175
+ if (exc_type != NULLPTR) {
176
+ PyErr_Restore(exc_type, exc_value, exc_traceback);
177
+ }
178
+ }
179
+
180
+ // A RAII primitive that DECREFs the underlying PyObject* when it
181
+ // goes out of scope.
182
+ class ARROW_PYTHON_EXPORT OwnedRef {
183
+ public:
184
+ OwnedRef() : obj_(NULLPTR) {}
185
+ OwnedRef(OwnedRef&& other) : OwnedRef(other.detach()) {}
186
+ explicit OwnedRef(PyObject* obj) : obj_(obj) {}
187
+
188
+ OwnedRef& operator=(OwnedRef&& other) {
189
+ obj_ = other.detach();
190
+ return *this;
191
+ }
192
+
193
+ ~OwnedRef() {
194
+ // GH-38626: destructor may be called after the Python interpreter is finalized.
195
+ if (Py_IsInitialized()) {
196
+ reset();
197
+ }
198
+ }
199
+
200
+ void reset(PyObject* obj) {
201
+ Py_XDECREF(obj_);
202
+ obj_ = obj;
203
+ }
204
+
205
+ void reset() { reset(NULLPTR); }
206
+
207
+ PyObject* detach() {
208
+ PyObject* result = obj_;
209
+ obj_ = NULLPTR;
210
+ return result;
211
+ }
212
+
213
+ PyObject* obj() const { return obj_; }
214
+
215
+ PyObject** ref() { return &obj_; }
216
+
217
+ operator bool() const { return obj_ != NULLPTR; }
218
+
219
+ private:
220
+ ARROW_DISALLOW_COPY_AND_ASSIGN(OwnedRef);
221
+
222
+ PyObject* obj_;
223
+ };
224
+
225
+ // Same as OwnedRef, but ensures the GIL is taken when it goes out of scope.
226
+ // This is for situations where the GIL is not always known to be held
227
+ // (e.g. if it is released in the middle of a function for performance reasons)
228
+ class ARROW_PYTHON_EXPORT OwnedRefNoGIL : public OwnedRef {
229
+ public:
230
+ OwnedRefNoGIL() : OwnedRef() {}
231
+ OwnedRefNoGIL(OwnedRefNoGIL&& other) : OwnedRef(other.detach()) {}
232
+ explicit OwnedRefNoGIL(PyObject* obj) : OwnedRef(obj) {}
233
+
234
+ ~OwnedRefNoGIL() {
235
+ // GH-38626: destructor may be called after the Python interpreter is finalized.
236
+ if (Py_IsInitialized() && obj() != NULLPTR) {
237
+ PyAcquireGIL lock;
238
+ reset();
239
+ }
240
+ }
241
+ };
242
+
243
+ template <template <typename...> typename SmartPtr, typename... Ts>
244
+ class SmartPtrNoGIL : public SmartPtr<Ts...> {
245
+ using Base = SmartPtr<Ts...>;
246
+
247
+ public:
248
+ template <typename... Args>
249
+ SmartPtrNoGIL(Args&&... args) : Base(std::forward<Args>(args)...) {}
250
+
251
+ ~SmartPtrNoGIL() { reset(); }
252
+
253
+ template <typename... Args>
254
+ void reset(Args&&... args) {
255
+ auto release_guard = optional_gil_release();
256
+ Base::reset(std::forward<Args>(args)...);
257
+ }
258
+
259
+ template <typename V>
260
+ SmartPtrNoGIL& operator=(V&& v) {
261
+ auto release_guard = optional_gil_release();
262
+ Base::operator=(std::forward<V>(v));
263
+ return *this;
264
+ }
265
+
266
+ private:
267
+ // Only release the GIL if we own an object *and* the Python runtime is
268
+ // valid *and* the GIL is held.
269
+ std::optional<PyReleaseGIL> optional_gil_release() const {
270
+ if (this->get() != nullptr && Py_IsInitialized() && PyGILState_Check()) {
271
+ return PyReleaseGIL();
272
+ }
273
+ return {};
274
+ }
275
+ };
276
+
277
+ /// \brief A std::shared_ptr<T, ...> subclass that releases the GIL when destroying T
278
+ template <typename... Ts>
279
+ using SharedPtrNoGIL = SmartPtrNoGIL<std::shared_ptr, Ts...>;
280
+
281
+ /// \brief A std::unique_ptr<T, ...> subclass that releases the GIL when destroying T
282
+ template <typename... Ts>
283
+ using UniquePtrNoGIL = SmartPtrNoGIL<std::unique_ptr, Ts...>;
284
+
285
+ template <typename Fn>
286
+ struct BoundFunction;
287
+
288
+ template <typename... Args>
289
+ struct BoundFunction<void(PyObject*, Args...)> {
290
+ // We bind `cdef void fn(object, ...)` to get a `Status(...)`
291
+ // where the Status contains any Python error raised by `fn`
292
+ using Unbound = void(PyObject*, Args...);
293
+ using Bound = Status(Args...);
294
+
295
+ BoundFunction(Unbound* unbound, PyObject* bound_arg)
296
+ : unbound_(unbound), bound_arg_(bound_arg) {}
297
+
298
+ Status Invoke(Args... args) const {
299
+ PyAcquireGIL lock;
300
+ unbound_(bound_arg_.obj(), std::forward<Args>(args)...);
301
+ RETURN_IF_PYERROR();
302
+ return Status::OK();
303
+ }
304
+
305
+ Unbound* unbound_;
306
+ OwnedRefNoGIL bound_arg_;
307
+ };
308
+
309
+ template <typename Return, typename... Args>
310
+ struct BoundFunction<Return(PyObject*, Args...)> {
311
+ // We bind `cdef Return fn(object, ...)` to get a `Result<Return>(...)`
312
+ // where the Result contains any Python error raised by `fn` or the
313
+ // return value from `fn`.
314
+ using Unbound = Return(PyObject*, Args...);
315
+ using Bound = Result<Return>(Args...);
316
+
317
+ BoundFunction(Unbound* unbound, PyObject* bound_arg)
318
+ : unbound_(unbound), bound_arg_(bound_arg) {}
319
+
320
+ Result<Return> Invoke(Args... args) const {
321
+ PyAcquireGIL lock;
322
+ Return ret = unbound_(bound_arg_.obj(), std::forward<Args>(args)...);
323
+ RETURN_IF_PYERROR();
324
+ return ret;
325
+ }
326
+
327
+ Unbound* unbound_;
328
+ OwnedRefNoGIL bound_arg_;
329
+ };
330
+
331
+ template <typename OutFn, typename Return, typename... Args>
332
+ std::function<OutFn> BindFunction(Return (*unbound)(PyObject*, Args...),
333
+ PyObject* bound_arg) {
334
+ using Fn = BoundFunction<Return(PyObject*, Args...)>;
335
+
336
+ static_assert(std::is_same<typename Fn::Bound, OutFn>::value,
337
+ "requested bound function of unsupported type");
338
+
339
+ Py_XINCREF(bound_arg);
340
+ auto bound_fn = std::make_shared<Fn>(unbound, bound_arg);
341
+ return
342
+ [bound_fn](Args... args) { return bound_fn->Invoke(std::forward<Args>(args)...); };
343
+ }
344
+
345
+ // A temporary conversion of a Python object to a bytes area.
346
+ struct PyBytesView {
347
+ const char* bytes;
348
+ Py_ssize_t size;
349
+ bool is_utf8;
350
+
351
+ static Result<PyBytesView> FromString(PyObject* obj, bool check_utf8 = false) {
352
+ PyBytesView self;
353
+ ARROW_RETURN_NOT_OK(self.ParseString(obj, check_utf8));
354
+ return std::move(self);
355
+ }
356
+
357
+ static Result<PyBytesView> FromUnicode(PyObject* obj) {
358
+ PyBytesView self;
359
+ ARROW_RETURN_NOT_OK(self.ParseUnicode(obj));
360
+ return std::move(self);
361
+ }
362
+
363
+ static Result<PyBytesView> FromBinary(PyObject* obj) {
364
+ PyBytesView self;
365
+ ARROW_RETURN_NOT_OK(self.ParseBinary(obj));
366
+ return std::move(self);
367
+ }
368
+
369
+ // View the given Python object as string-like, i.e. str or (utf8) bytes
370
+ Status ParseString(PyObject* obj, bool check_utf8 = false) {
371
+ if (PyUnicode_Check(obj)) {
372
+ return ParseUnicode(obj);
373
+ } else {
374
+ ARROW_RETURN_NOT_OK(ParseBinary(obj));
375
+ if (check_utf8) {
376
+ // Check the bytes are utf8 utf-8
377
+ OwnedRef decoded(PyUnicode_FromStringAndSize(bytes, size));
378
+ if (ARROW_PREDICT_TRUE(!PyErr_Occurred())) {
379
+ is_utf8 = true;
380
+ } else {
381
+ PyErr_Clear();
382
+ is_utf8 = false;
383
+ }
384
+ }
385
+ return Status::OK();
386
+ }
387
+ }
388
+
389
+ // View the given Python object as unicode string
390
+ Status ParseUnicode(PyObject* obj) {
391
+ // The utf-8 representation is cached on the unicode object
392
+ bytes = PyUnicode_AsUTF8AndSize(obj, &size);
393
+ RETURN_IF_PYERROR();
394
+ is_utf8 = true;
395
+ return Status::OK();
396
+ }
397
+
398
+ // View the given Python object as binary-like, i.e. bytes
399
+ Status ParseBinary(PyObject* obj) {
400
+ if (PyBytes_Check(obj)) {
401
+ bytes = PyBytes_AS_STRING(obj);
402
+ size = PyBytes_GET_SIZE(obj);
403
+ is_utf8 = false;
404
+ } else if (PyByteArray_Check(obj)) {
405
+ bytes = PyByteArray_AS_STRING(obj);
406
+ size = PyByteArray_GET_SIZE(obj);
407
+ is_utf8 = false;
408
+ } else if (PyMemoryView_Check(obj)) {
409
+ PyObject* ref = PyMemoryView_GetContiguous(obj, PyBUF_READ, 'C');
410
+ RETURN_IF_PYERROR();
411
+ Py_buffer* buffer = PyMemoryView_GET_BUFFER(ref);
412
+ bytes = reinterpret_cast<const char*>(buffer->buf);
413
+ size = buffer->len;
414
+ is_utf8 = false;
415
+ } else {
416
+ return Status::TypeError("Expected bytes, got a '", Py_TYPE(obj)->tp_name,
417
+ "' object");
418
+ }
419
+ return Status::OK();
420
+ }
421
+
422
+ protected:
423
+ OwnedRef ref;
424
+ };
425
+
426
+ class ARROW_PYTHON_EXPORT PyBuffer : public Buffer {
427
+ public:
428
+ /// While memoryview objects support multi-dimensional buffers, PyBuffer only supports
429
+ /// one-dimensional byte buffers.
430
+ ~PyBuffer();
431
+
432
+ static Result<std::shared_ptr<Buffer>> FromPyObject(PyObject* obj);
433
+
434
+ private:
435
+ PyBuffer();
436
+ Status Init(PyObject*);
437
+
438
+ Py_buffer py_buf_;
439
+ };
440
+
441
+ // Return the common PyArrow memory pool
442
+ ARROW_PYTHON_EXPORT void set_default_memory_pool(MemoryPool* pool);
443
+ ARROW_PYTHON_EXPORT MemoryPool* get_memory_pool();
444
+
445
+ // This is annoying: because C++11 does not allow implicit conversion of string
446
+ // literals to non-const char*, we need to go through some gymnastics to use
447
+ // PyObject_CallMethod without a lot of pain (its arguments are non-const
448
+ // char*)
449
+ template <typename... ArgTypes>
450
+ static inline PyObject* cpp_PyObject_CallMethod(PyObject* obj, const char* method_name,
451
+ const char* argspec, ArgTypes... args) {
452
+ return PyObject_CallMethod(obj, const_cast<char*>(method_name),
453
+ const_cast<char*>(argspec), args...);
454
+ }
455
+
456
+ } // namespace py
457
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/config.cc ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include "arrow/python/config.h"
19
+ #include "arrow/python/config_internal.h"
20
+
21
+ namespace arrow {
22
+ namespace py {
23
+
24
+ namespace {
25
+
26
+ const BuildInfo kBuildInfo = {
27
+ PYARROW_BUILD_TYPE,
28
+ };
29
+
30
+ } // namespace
31
+
32
+ const BuildInfo& GetBuildInfo() { return kBuildInfo; }
33
+
34
+ } // namespace py
35
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/config.h ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <string>
21
+
22
+ #include "arrow/python/visibility.h"
23
+
24
+ namespace arrow {
25
+ namespace py {
26
+
27
+ struct BuildInfo {
28
+ // The uppercase build type, e.g. "DEBUG" or "RELEASE"
29
+ std::string build_type;
30
+ };
31
+
32
+ /// \brief Get build info for PyArrow.
33
+ ///
34
+ ARROW_PYTHON_EXPORT
35
+ const BuildInfo& GetBuildInfo();
36
+
37
+ } // namespace py
38
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/config_internal.h.cmake ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #define PYARROW_BUILD_TYPE "@UPPERCASE_PYBUILD_TYPE@"
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/csv.cc ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include "csv.h"
19
+
20
+ #include <memory>
21
+
22
+ #include "arrow/python/common.h"
23
+
24
+ namespace arrow {
25
+
26
+ using csv::InvalidRow;
27
+ using csv::InvalidRowHandler;
28
+ using csv::InvalidRowResult;
29
+
30
+ namespace py {
31
+ namespace csv {
32
+
33
+ InvalidRowHandler MakeInvalidRowHandler(PyInvalidRowCallback cb, PyObject* py_handler) {
34
+ if (cb == nullptr) {
35
+ return InvalidRowHandler{};
36
+ }
37
+
38
+ struct Handler {
39
+ PyInvalidRowCallback cb;
40
+ std::shared_ptr<OwnedRefNoGIL> handler_ref;
41
+
42
+ InvalidRowResult operator()(const InvalidRow& invalid_row) {
43
+ InvalidRowResult result;
44
+ auto st = SafeCallIntoPython([&]() -> Status {
45
+ result = cb(handler_ref->obj(), invalid_row);
46
+ if (PyErr_Occurred()) {
47
+ PyErr_WriteUnraisable(handler_ref->obj());
48
+ }
49
+ return Status::OK();
50
+ });
51
+ ARROW_UNUSED(st);
52
+ return result;
53
+ }
54
+ };
55
+
56
+ Py_INCREF(py_handler);
57
+ return Handler{cb, std::make_shared<OwnedRefNoGIL>(py_handler)};
58
+ }
59
+
60
+ } // namespace csv
61
+ } // namespace py
62
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/csv.h ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <functional>
21
+ #include <memory>
22
+ #include <string>
23
+ #include <vector>
24
+
25
+ #include "arrow/csv/options.h"
26
+ #include "arrow/python/common.h"
27
+ #include "arrow/util/macros.h"
28
+
29
+ namespace arrow {
30
+ namespace py {
31
+ namespace csv {
32
+
33
+ using PyInvalidRowCallback = std::function<::arrow::csv::InvalidRowResult(
34
+ PyObject*, const ::arrow::csv::InvalidRow&)>;
35
+
36
+ ARROW_PYTHON_EXPORT
37
+ ::arrow::csv::InvalidRowHandler MakeInvalidRowHandler(PyInvalidRowCallback,
38
+ PyObject* handler);
39
+
40
+ } // namespace csv
41
+ } // namespace py
42
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/datetime.cc ADDED
@@ -0,0 +1,665 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include "datetime.h"
18
+
19
+ #include <algorithm>
20
+ #include <chrono>
21
+ #include <iomanip>
22
+ #include <regex>
23
+ #include <string_view>
24
+
25
+ #include "arrow/array.h"
26
+ #include "arrow/python/arrow_to_python_internal.h"
27
+ #include "arrow/python/common.h"
28
+ #include "arrow/python/helpers.h"
29
+ #include "arrow/python/platform.h"
30
+ #include "arrow/scalar.h"
31
+ #include "arrow/status.h"
32
+ #include "arrow/type.h"
33
+ #include "arrow/util/logging.h"
34
+ #include "arrow/util/regex.h"
35
+ #include "arrow/util/value_parsing.h"
36
+
37
+ namespace arrow {
38
+
39
+ using internal::RegexMatch;
40
+
41
+ namespace py {
42
+ namespace internal {
43
+
44
+ namespace {
45
+
46
+ bool MatchFixedOffset(const std::string& tz, std::string_view* sign,
47
+ std::string_view* hour, std::string_view* minute) {
48
+ static const std::regex regex("^([+-])(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$");
49
+ if (tz.size() < 5) {
50
+ return false;
51
+ }
52
+ return RegexMatch(regex, tz, {sign, hour, minute});
53
+ }
54
+
55
+ constexpr char* NonConst(const char* st) {
56
+ // Hack for python versions < 3.7 where members of PyStruct members
57
+ // where non-const (C++ doesn't like assigning string literals to these types)
58
+ return const_cast<char*>(st);
59
+ }
60
+
61
+ static PyTypeObject MonthDayNanoTupleType = {};
62
+
63
+ static PyStructSequence_Field MonthDayNanoField[] = {
64
+ {NonConst("months"), NonConst("The number of months in the interval")},
65
+ {NonConst("days"), NonConst("The number days in the interval")},
66
+ {NonConst("nanoseconds"), NonConst("The number of nanoseconds in the interval")},
67
+ {nullptr, nullptr}};
68
+
69
+ static PyStructSequence_Desc MonthDayNanoTupleDesc = {
70
+ NonConst("MonthDayNano"),
71
+ NonConst("A calendar interval consisting of months, days and nanoseconds."),
72
+ MonthDayNanoField,
73
+ /*n_in_sequence=*/3};
74
+
75
+ } // namespace
76
+
77
+ #ifndef PYPY_VERSION
78
+ PyDateTime_CAPI* datetime_api = nullptr;
79
+
80
+ void InitDatetime() {
81
+ PyAcquireGIL lock;
82
+ datetime_api =
83
+ reinterpret_cast<PyDateTime_CAPI*>(PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0));
84
+ if (datetime_api == nullptr) {
85
+ Py_FatalError("Could not import datetime C API");
86
+ }
87
+ }
88
+ #endif
89
+
90
+ // The following code is adapted from
91
+ // https://github.com/numpy/numpy/blob/main/numpy/core/src/multiarray/datetime.c
92
+
93
+ // Days per month, regular year and leap year
94
+ static int64_t _days_per_month_table[2][12] = {
95
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
96
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
97
+
98
+ static bool is_leapyear(int64_t year) {
99
+ return (year & 0x3) == 0 && // year % 4 == 0
100
+ ((year % 100) != 0 || (year % 400) == 0);
101
+ }
102
+
103
+ // Calculates the days offset from the 1970 epoch.
104
+ static int64_t get_days_from_date(int64_t date_year, int64_t date_month,
105
+ int64_t date_day) {
106
+ int64_t i, month;
107
+ int64_t year, days = 0;
108
+ int64_t* month_lengths;
109
+
110
+ year = date_year - 1970;
111
+ days = year * 365;
112
+
113
+ // Adjust for leap years
114
+ if (days >= 0) {
115
+ // 1968 is the closest leap year before 1970.
116
+ // Exclude the current year, so add 1.
117
+ year += 1;
118
+ // Add one day for each 4 years
119
+ days += year / 4;
120
+ // 1900 is the closest previous year divisible by 100
121
+ year += 68;
122
+ // Subtract one day for each 100 years
123
+ days -= year / 100;
124
+ // 1600 is the closest previous year divisible by 400
125
+ year += 300;
126
+ // Add one day for each 400 years
127
+ days += year / 400;
128
+ } else {
129
+ // 1972 is the closest later year after 1970.
130
+ // Include the current year, so subtract 2.
131
+ year -= 2;
132
+ // Subtract one day for each 4 years
133
+ days += year / 4;
134
+ // 2000 is the closest later year divisible by 100
135
+ year -= 28;
136
+ // Add one day for each 100 years
137
+ days -= year / 100;
138
+ // 2000 is also the closest later year divisible by 400
139
+ // Subtract one day for each 400 years
140
+ days += year / 400;
141
+ }
142
+
143
+ month_lengths = _days_per_month_table[is_leapyear(date_year)];
144
+ month = date_month - 1;
145
+
146
+ // Add the months
147
+ for (i = 0; i < month; ++i) {
148
+ days += month_lengths[i];
149
+ }
150
+
151
+ // Add the days
152
+ days += date_day - 1;
153
+
154
+ return days;
155
+ }
156
+
157
+ // Modifies '*days_' to be the day offset within the year,
158
+ // and returns the year.
159
+ static int64_t days_to_yearsdays(int64_t* days_) {
160
+ const int64_t days_per_400years = (400 * 365 + 100 - 4 + 1);
161
+ // Adjust so it's relative to the year 2000 (divisible by 400)
162
+ int64_t days = (*days_) - (365 * 30 + 7);
163
+ int64_t year;
164
+
165
+ // Break down the 400 year cycle to get the year and day within the year
166
+ if (days >= 0) {
167
+ year = 400 * (days / days_per_400years);
168
+ days = days % days_per_400years;
169
+ } else {
170
+ year = 400 * ((days - (days_per_400years - 1)) / days_per_400years);
171
+ days = days % days_per_400years;
172
+ if (days < 0) {
173
+ days += days_per_400years;
174
+ }
175
+ }
176
+
177
+ // Work out the year/day within the 400 year cycle
178
+ if (days >= 366) {
179
+ year += 100 * ((days - 1) / (100 * 365 + 25 - 1));
180
+ days = (days - 1) % (100 * 365 + 25 - 1);
181
+ if (days >= 365) {
182
+ year += 4 * ((days + 1) / (4 * 365 + 1));
183
+ days = (days + 1) % (4 * 365 + 1);
184
+ if (days >= 366) {
185
+ year += (days - 1) / 365;
186
+ days = (days - 1) % 365;
187
+ }
188
+ }
189
+ }
190
+
191
+ *days_ = days;
192
+ return year + 2000;
193
+ }
194
+
195
+ // Extracts the month and year and day number from a number of days
196
+ static void get_date_from_days(int64_t days, int64_t* date_year, int64_t* date_month,
197
+ int64_t* date_day) {
198
+ int64_t *month_lengths, i;
199
+
200
+ *date_year = days_to_yearsdays(&days);
201
+ month_lengths = _days_per_month_table[is_leapyear(*date_year)];
202
+
203
+ for (i = 0; i < 12; ++i) {
204
+ if (days < month_lengths[i]) {
205
+ *date_month = i + 1;
206
+ *date_day = days + 1;
207
+ return;
208
+ } else {
209
+ days -= month_lengths[i];
210
+ }
211
+ }
212
+
213
+ // Should never get here
214
+ return;
215
+ }
216
+
217
+ // Splitting time quantities, for example splitting total seconds into
218
+ // minutes and remaining seconds. After we run
219
+ // int64_t remaining = split_time(total, quotient, &next)
220
+ // we have
221
+ // total = next * quotient + remaining. Handles negative values by propagating
222
+ // them: If total is negative, next will be negative and remaining will
223
+ // always be non-negative.
224
+ static inline int64_t split_time(int64_t total, int64_t quotient, int64_t* next) {
225
+ int64_t r = total % quotient;
226
+ if (r < 0) {
227
+ *next = total / quotient - 1;
228
+ return r + quotient;
229
+ } else {
230
+ *next = total / quotient;
231
+ return r;
232
+ }
233
+ }
234
+
235
+ static inline Status PyTime_convert_int(int64_t val, const TimeUnit::type unit,
236
+ int64_t* hour, int64_t* minute, int64_t* second,
237
+ int64_t* microsecond) {
238
+ switch (unit) {
239
+ case TimeUnit::NANO:
240
+ if (val % 1000 != 0) {
241
+ return Status::Invalid("Value ", val, " has non-zero nanoseconds");
242
+ }
243
+ val /= 1000;
244
+ // fall through
245
+ case TimeUnit::MICRO:
246
+ *microsecond = split_time(val, 1000000LL, &val);
247
+ *second = split_time(val, 60, &val);
248
+ *minute = split_time(val, 60, hour);
249
+ break;
250
+ case TimeUnit::MILLI:
251
+ *microsecond = split_time(val, 1000, &val) * 1000;
252
+ // fall through
253
+ case TimeUnit::SECOND:
254
+ *second = split_time(val, 60, &val);
255
+ *minute = split_time(val, 60, hour);
256
+ break;
257
+ default:
258
+ break;
259
+ }
260
+ return Status::OK();
261
+ }
262
+
263
+ static inline Status PyDate_convert_int(int64_t val, const DateUnit unit, int64_t* year,
264
+ int64_t* month, int64_t* day) {
265
+ switch (unit) {
266
+ case DateUnit::MILLI:
267
+ val /= 86400000LL; // fall through
268
+ case DateUnit::DAY:
269
+ get_date_from_days(val, year, month, day);
270
+ default:
271
+ break;
272
+ }
273
+ return Status::OK();
274
+ }
275
+
276
+ PyObject* NewMonthDayNanoTupleType() {
277
+ if (MonthDayNanoTupleType.tp_name == nullptr) {
278
+ if (PyStructSequence_InitType2(&MonthDayNanoTupleType, &MonthDayNanoTupleDesc) != 0) {
279
+ Py_FatalError("Could not initialize MonthDayNanoTuple");
280
+ }
281
+ }
282
+ Py_INCREF(&MonthDayNanoTupleType);
283
+ return (PyObject*)&MonthDayNanoTupleType;
284
+ }
285
+
286
+ Status PyTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out) {
287
+ int64_t hour = 0, minute = 0, second = 0, microsecond = 0;
288
+ RETURN_NOT_OK(PyTime_convert_int(val, unit, &hour, &minute, &second, &microsecond));
289
+ *out = PyTime_FromTime(static_cast<int32_t>(hour), static_cast<int32_t>(minute),
290
+ static_cast<int32_t>(second), static_cast<int32_t>(microsecond));
291
+ return Status::OK();
292
+ }
293
+
294
+ Status PyDate_from_int(int64_t val, const DateUnit unit, PyObject** out) {
295
+ int64_t year = 0, month = 0, day = 0;
296
+ RETURN_NOT_OK(PyDate_convert_int(val, unit, &year, &month, &day));
297
+ *out = PyDate_FromDate(static_cast<int32_t>(year), static_cast<int32_t>(month),
298
+ static_cast<int32_t>(day));
299
+ return Status::OK();
300
+ }
301
+
302
+ Status PyDateTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out) {
303
+ int64_t hour = 0, minute = 0, second = 0, microsecond = 0;
304
+ RETURN_NOT_OK(PyTime_convert_int(val, unit, &hour, &minute, &second, &microsecond));
305
+ int64_t total_days = 0;
306
+ hour = split_time(hour, 24, &total_days);
307
+ int64_t year = 0, month = 0, day = 0;
308
+ get_date_from_days(total_days, &year, &month, &day);
309
+ *out = PyDateTime_FromDateAndTime(
310
+ static_cast<int32_t>(year), static_cast<int32_t>(month), static_cast<int32_t>(day),
311
+ static_cast<int32_t>(hour), static_cast<int32_t>(minute),
312
+ static_cast<int32_t>(second), static_cast<int32_t>(microsecond));
313
+ return Status::OK();
314
+ }
315
+
316
+ int64_t PyDate_to_days(PyDateTime_Date* pydate) {
317
+ return get_days_from_date(PyDateTime_GET_YEAR(pydate), PyDateTime_GET_MONTH(pydate),
318
+ PyDateTime_GET_DAY(pydate));
319
+ }
320
+
321
+ Result<int64_t> PyDateTime_utcoffset_s(PyObject* obj) {
322
+ // calculate offset from UTC timezone in seconds
323
+ // supports only PyDateTime_DateTime and PyDateTime_Time objects
324
+ OwnedRef pyoffset(PyObject_CallMethod(obj, "utcoffset", NULL));
325
+ RETURN_IF_PYERROR();
326
+ if (pyoffset.obj() != nullptr && pyoffset.obj() != Py_None) {
327
+ auto delta = reinterpret_cast<PyDateTime_Delta*>(pyoffset.obj());
328
+ return internal::PyDelta_to_s(delta);
329
+ } else {
330
+ return 0;
331
+ }
332
+ }
333
+
334
+ Result<std::string> PyTZInfo_utcoffset_hhmm(PyObject* pytzinfo) {
335
+ // attempt to convert timezone offset objects to "+/-{hh}:{mm}" format
336
+ OwnedRef pydelta_object(PyObject_CallMethod(pytzinfo, "utcoffset", "O", Py_None));
337
+ RETURN_IF_PYERROR();
338
+
339
+ if (!PyDelta_Check(pydelta_object.obj())) {
340
+ return Status::Invalid(
341
+ "Object returned by tzinfo.utcoffset(None) is not an instance of "
342
+ "datetime.timedelta");
343
+ }
344
+ auto pydelta = reinterpret_cast<PyDateTime_Delta*>(pydelta_object.obj());
345
+
346
+ // retrieve the offset as seconds
347
+ auto total_seconds = internal::PyDelta_to_s(pydelta);
348
+
349
+ // determine whether the offset is positive or negative
350
+ auto sign = (total_seconds < 0) ? "-" : "+";
351
+ total_seconds = abs(total_seconds);
352
+
353
+ // calculate offset components
354
+ int64_t hours, minutes, seconds;
355
+ seconds = split_time(total_seconds, 60, &minutes);
356
+ minutes = split_time(minutes, 60, &hours);
357
+ if (seconds > 0) {
358
+ // check there are no remaining seconds
359
+ return Status::Invalid("Offset must represent whole number of minutes");
360
+ }
361
+
362
+ // construct the timezone string
363
+ std::stringstream stream;
364
+ stream << sign << std::setfill('0') << std::setw(2) << hours << ":" << std::setfill('0')
365
+ << std::setw(2) << minutes;
366
+ return stream.str();
367
+ }
368
+
369
+ // Converted from python. See https://github.com/apache/arrow/pull/7604
370
+ // for details.
371
+ Result<PyObject*> StringToTzinfo(const std::string& tz) {
372
+ std::string_view sign_str, hour_str, minute_str;
373
+ OwnedRef pytz;
374
+ OwnedRef zoneinfo;
375
+ OwnedRef datetime;
376
+
377
+ if (internal::ImportModule("pytz", &pytz).ok()) {
378
+ if (MatchFixedOffset(tz, &sign_str, &hour_str, &minute_str)) {
379
+ int sign = -1;
380
+ if (sign_str == "+") {
381
+ sign = 1;
382
+ }
383
+ OwnedRef fixed_offset;
384
+ RETURN_NOT_OK(internal::ImportFromModule(pytz.obj(), "FixedOffset", &fixed_offset));
385
+ uint32_t minutes, hours;
386
+ if (!::arrow::internal::ParseUnsigned(hour_str.data(), hour_str.size(), &hours) ||
387
+ !::arrow::internal::ParseUnsigned(minute_str.data(), minute_str.size(),
388
+ &minutes)) {
389
+ return Status::Invalid("Invalid timezone: ", tz);
390
+ }
391
+ OwnedRef total_minutes(PyLong_FromLong(
392
+ sign * ((static_cast<int>(hours) * 60) + static_cast<int>(minutes))));
393
+ RETURN_IF_PYERROR();
394
+ auto tzinfo =
395
+ PyObject_CallFunctionObjArgs(fixed_offset.obj(), total_minutes.obj(), NULL);
396
+ RETURN_IF_PYERROR();
397
+ return tzinfo;
398
+ }
399
+
400
+ OwnedRef timezone;
401
+ RETURN_NOT_OK(internal::ImportFromModule(pytz.obj(), "timezone", &timezone));
402
+ OwnedRef py_tz_string(
403
+ PyUnicode_FromStringAndSize(tz.c_str(), static_cast<Py_ssize_t>(tz.size())));
404
+ auto tzinfo = PyObject_CallFunctionObjArgs(timezone.obj(), py_tz_string.obj(), NULL);
405
+ RETURN_IF_PYERROR();
406
+ return tzinfo;
407
+ }
408
+
409
+ // catch fixed offset if pytz is not present
410
+ if (MatchFixedOffset(tz, &sign_str, &hour_str, &minute_str)) {
411
+ RETURN_NOT_OK(internal::ImportModule("datetime", &datetime));
412
+ int sign = -1;
413
+ if (sign_str == "+") {
414
+ sign = 1;
415
+ }
416
+
417
+ // import timezone and timedelta module to create a tzinfo object
418
+ OwnedRef class_timezone;
419
+ OwnedRef class_timedelta;
420
+ RETURN_NOT_OK(
421
+ internal::ImportFromModule(datetime.obj(), "timezone", &class_timezone));
422
+ RETURN_NOT_OK(
423
+ internal::ImportFromModule(datetime.obj(), "timedelta", &class_timedelta));
424
+
425
+ // check input
426
+ uint32_t minutes, hours;
427
+ if (!::arrow::internal::ParseUnsigned(hour_str.data(), hour_str.size(), &hours) ||
428
+ !::arrow::internal::ParseUnsigned(minute_str.data(), minute_str.size(),
429
+ &minutes)) {
430
+ return Status::Invalid("Invalid timezone: ", tz);
431
+ }
432
+
433
+ // save offset as a signed integer
434
+ OwnedRef total_minutes(PyLong_FromLong(
435
+ sign * ((static_cast<int>(hours) * 60) + static_cast<int>(minutes))));
436
+ // create zero integers for empty arguments in datetime.timedelta
437
+ OwnedRef zero(PyLong_FromLong(static_cast<int>(0)));
438
+
439
+ // call datetime.timedelta to get correct offset object for datetime.timezone
440
+ auto offset =
441
+ PyObject_CallFunctionObjArgs(class_timedelta.obj(), zero.obj(), zero.obj(),
442
+ zero.obj(), zero.obj(), total_minutes.obj(), NULL);
443
+ RETURN_IF_PYERROR();
444
+ // call datetime.timezone
445
+ auto tzinfo = PyObject_CallFunctionObjArgs(class_timezone.obj(), offset, NULL);
446
+ RETURN_IF_PYERROR();
447
+ return tzinfo;
448
+ }
449
+
450
+ // fallback on zoneinfo if tz is string and pytz is not present
451
+ if (internal::ImportModule("zoneinfo", &zoneinfo).ok()) {
452
+ OwnedRef class_zoneinfo;
453
+ RETURN_NOT_OK(
454
+ internal::ImportFromModule(zoneinfo.obj(), "ZoneInfo", &class_zoneinfo));
455
+ OwnedRef py_tz_string(
456
+ PyUnicode_FromStringAndSize(tz.c_str(), static_cast<Py_ssize_t>(tz.size())));
457
+ auto tzinfo =
458
+ PyObject_CallFunctionObjArgs(class_zoneinfo.obj(), py_tz_string.obj(), NULL);
459
+ RETURN_IF_PYERROR();
460
+ return tzinfo;
461
+ }
462
+
463
+ return Status::Invalid(
464
+ "Pytz package or Python>=3.8 for zoneinfo module must be installed.");
465
+ }
466
+
467
+ Result<std::string> TzinfoToString(PyObject* tzinfo) {
468
+ OwnedRef module_pytz; // import pytz
469
+ OwnedRef module_datetime; // import datetime
470
+ OwnedRef module_zoneinfo; // import zoneinfo
471
+ OwnedRef module_dateutil; // import dateutil
472
+ OwnedRef class_timezone; // from datetime import timezone
473
+ OwnedRef class_fixedoffset; // from pytz import _FixedOffset
474
+ OwnedRef class_basetzinfo; // from pytz import BaseTzInfo
475
+ OwnedRef class_zoneinfo; // from zoneinfo import ZoneInfo
476
+ OwnedRef class_tzfile; // from zoneinfo import tzfile
477
+
478
+ // import necessary modules
479
+ RETURN_NOT_OK(internal::ImportModule("datetime", &module_datetime));
480
+ // import necessary classes
481
+ RETURN_NOT_OK(
482
+ internal::ImportFromModule(module_datetime.obj(), "timezone", &class_timezone));
483
+
484
+ // check that it's a valid tzinfo object
485
+ if (!PyTZInfo_Check(tzinfo)) {
486
+ return Status::TypeError("Not an instance of datetime.tzinfo");
487
+ }
488
+
489
+ // if tzinfo is an instance of datetime.timezone return the
490
+ // HH:MM offset string representation
491
+ if (PyObject_IsInstance(tzinfo, class_timezone.obj())) {
492
+ // still recognize datetime.timezone.utc as UTC (instead of +00:00)
493
+ OwnedRef tzname_object(PyObject_CallMethod(tzinfo, "tzname", "O", Py_None));
494
+ RETURN_IF_PYERROR();
495
+ if (PyUnicode_Check(tzname_object.obj())) {
496
+ std::string result;
497
+ RETURN_NOT_OK(internal::PyUnicode_AsStdString(tzname_object.obj(), &result));
498
+ if (result == "UTC") {
499
+ return result;
500
+ }
501
+ }
502
+ return PyTZInfo_utcoffset_hhmm(tzinfo);
503
+ }
504
+
505
+ // Try to import pytz if it is available
506
+ if (internal::ImportModule("pytz", &module_pytz).ok()) {
507
+ RETURN_NOT_OK(internal::ImportFromModule(module_pytz.obj(), "_FixedOffset",
508
+ &class_fixedoffset));
509
+ RETURN_NOT_OK(
510
+ internal::ImportFromModule(module_pytz.obj(), "BaseTzInfo", &class_basetzinfo));
511
+ }
512
+
513
+ // if tzinfo is an instance of pytz._FixedOffset return the
514
+ // HH:MM offset string representation
515
+ if (module_pytz.obj() != nullptr &&
516
+ PyObject_IsInstance(tzinfo, class_fixedoffset.obj())) {
517
+ OwnedRef tzname_object(PyObject_CallMethod(tzinfo, "tzname", "O", Py_None));
518
+ RETURN_IF_PYERROR();
519
+ return PyTZInfo_utcoffset_hhmm(tzinfo);
520
+ }
521
+
522
+ // if pytz is installed and tzinfo is and instance of pytz.BaseTzInfo
523
+ if (module_pytz.obj() != nullptr &&
524
+ PyObject_IsInstance(tzinfo, class_basetzinfo.obj())) {
525
+ OwnedRef zone(PyObject_GetAttrString(tzinfo, "zone"));
526
+ RETURN_IF_PYERROR();
527
+ std::string result;
528
+ RETURN_NOT_OK(internal::PyUnicode_AsStdString(zone.obj(), &result));
529
+ return result;
530
+ }
531
+
532
+ // Try to import zoneinfo if it is available
533
+ if (internal::ImportModule("zoneinfo", &module_zoneinfo).ok()) {
534
+ RETURN_NOT_OK(
535
+ internal::ImportFromModule(module_zoneinfo.obj(), "ZoneInfo", &class_zoneinfo));
536
+ }
537
+
538
+ // if zoneinfo is installed and tzinfo is an instance of zoneinfo.ZoneInfo
539
+ if (module_zoneinfo.obj() != nullptr &&
540
+ PyObject_IsInstance(tzinfo, class_zoneinfo.obj())) {
541
+ OwnedRef key(PyObject_GetAttrString(tzinfo, "key"));
542
+ RETURN_IF_PYERROR();
543
+ std::string result;
544
+ RETURN_NOT_OK(internal::PyUnicode_AsStdString(key.obj(), &result));
545
+ return result;
546
+ }
547
+
548
+ // Try to import dateutil if it is available
549
+ if (internal::ImportModule("dateutil.tz", &module_dateutil).ok()) {
550
+ RETURN_NOT_OK(
551
+ internal::ImportFromModule(module_dateutil.obj(), "tzfile", &class_tzfile));
552
+ }
553
+
554
+ // if dateutil is installed and tzinfo is an instance of dateutil.tz.tzfile
555
+ if (module_dateutil.obj() != nullptr &&
556
+ PyObject_IsInstance(tzinfo, class_tzfile.obj())) {
557
+ OwnedRef _filename(PyObject_GetAttrString(tzinfo, "_filename"));
558
+ RETURN_IF_PYERROR();
559
+ std::string result;
560
+ RETURN_NOT_OK(internal::PyUnicode_AsStdString(_filename.obj(), &result));
561
+ // _filename returns a full path in general ('/usr/share/zoneinfo/Europe/Paris')
562
+ // or POSIX name on Windows ('Europe/Paris') - we need a substring in first case
563
+ std::size_t pos = result.find("zoneinfo/");
564
+ if (pos != std::string::npos) {
565
+ return result.substr(pos + 9);
566
+ }
567
+ return result;
568
+ }
569
+
570
+ // attempt to call tzinfo.tzname(None)
571
+ OwnedRef tzname_object(PyObject_CallMethod(tzinfo, "tzname", "O", Py_None));
572
+ RETURN_IF_PYERROR();
573
+ if (PyUnicode_Check(tzname_object.obj())) {
574
+ std::string result;
575
+ RETURN_NOT_OK(internal::PyUnicode_AsStdString(tzname_object.obj(), &result));
576
+ return result;
577
+ }
578
+
579
+ // fall back to HH:MM offset string representation based on tzinfo.utcoffset(None)
580
+ return PyTZInfo_utcoffset_hhmm(tzinfo);
581
+ }
582
+
583
+ PyObject* MonthDayNanoIntervalToNamedTuple(
584
+ const MonthDayNanoIntervalType::MonthDayNanos& interval) {
585
+ OwnedRef tuple(PyStructSequence_New(&MonthDayNanoTupleType));
586
+ if (ARROW_PREDICT_FALSE(tuple.obj() == nullptr)) {
587
+ return nullptr;
588
+ }
589
+ PyStructSequence_SetItem(tuple.obj(), /*pos=*/0, PyLong_FromLong(interval.months));
590
+ PyStructSequence_SetItem(tuple.obj(), /*pos=*/1, PyLong_FromLong(interval.days));
591
+ PyStructSequence_SetItem(tuple.obj(), /*pos=*/2,
592
+ PyLong_FromLongLong(interval.nanoseconds));
593
+ return tuple.detach();
594
+ }
595
+
596
+ namespace {
597
+
598
+ // Wrapper around a Python list object that mimics dereference and assignment
599
+ // operations.
600
+ struct PyListAssigner {
601
+ public:
602
+ explicit PyListAssigner(PyObject* list) : list_(list) {
603
+ ARROW_DCHECK(PyList_Check(list_));
604
+ }
605
+
606
+ PyListAssigner& operator*() { return *this; }
607
+
608
+ void operator=(PyObject* obj) {
609
+ if (ARROW_PREDICT_FALSE(PyList_SetItem(list_, current_index_, obj) == -1)) {
610
+ Py_FatalError("list did not have the correct preallocated size.");
611
+ }
612
+ }
613
+
614
+ PyListAssigner& operator++() {
615
+ current_index_++;
616
+ return *this;
617
+ }
618
+
619
+ PyListAssigner& operator+=(int64_t offset) {
620
+ current_index_ += offset;
621
+ return *this;
622
+ }
623
+
624
+ private:
625
+ PyObject* list_;
626
+ int64_t current_index_ = 0;
627
+ };
628
+
629
+ } // namespace
630
+
631
+ Result<PyObject*> MonthDayNanoIntervalArrayToPyList(
632
+ const MonthDayNanoIntervalArray& array) {
633
+ OwnedRef out_list(PyList_New(array.length()));
634
+ RETURN_IF_PYERROR();
635
+ PyListAssigner out_objects(out_list.obj());
636
+ auto& interval_array =
637
+ arrow::internal::checked_cast<const MonthDayNanoIntervalArray&>(array);
638
+ RETURN_NOT_OK(internal::WriteArrayObjects(
639
+ interval_array,
640
+ [&](const MonthDayNanoIntervalType::MonthDayNanos& interval, PyListAssigner& out) {
641
+ PyObject* tuple = internal::MonthDayNanoIntervalToNamedTuple(interval);
642
+ if (ARROW_PREDICT_FALSE(tuple == nullptr)) {
643
+ RETURN_IF_PYERROR();
644
+ }
645
+
646
+ *out = tuple;
647
+ return Status::OK();
648
+ },
649
+ out_objects));
650
+ return out_list.detach();
651
+ }
652
+
653
+ Result<PyObject*> MonthDayNanoIntervalScalarToPyObject(
654
+ const MonthDayNanoIntervalScalar& scalar) {
655
+ if (scalar.is_valid) {
656
+ return internal::MonthDayNanoIntervalToNamedTuple(scalar.value);
657
+ } else {
658
+ Py_INCREF(Py_None);
659
+ return Py_None;
660
+ }
661
+ }
662
+
663
+ } // namespace internal
664
+ } // namespace py
665
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/datetime.h ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <algorithm>
21
+ #include <chrono>
22
+
23
+ #include "arrow/python/platform.h"
24
+ #include "arrow/python/visibility.h"
25
+ #include "arrow/result.h"
26
+ #include "arrow/status.h"
27
+ #include "arrow/type.h"
28
+ #include "arrow/type_fwd.h"
29
+ #include "arrow/util/int_util_overflow.h"
30
+ #include "arrow/util/logging.h"
31
+
32
+ // By default, PyDateTimeAPI is a *static* variable. This forces
33
+ // PyDateTime_IMPORT to be called in every C/C++ module using the
34
+ // C datetime API. This is error-prone and potentially costly.
35
+ // Instead, we redefine PyDateTimeAPI to point to a global variable,
36
+ // which is initialized once by calling InitDatetime().
37
+ #ifdef PYPY_VERSION
38
+ # include "datetime.h"
39
+ #else
40
+ # define PyDateTimeAPI ::arrow::py::internal::datetime_api
41
+ #endif
42
+
43
+ namespace arrow {
44
+ using internal::AddWithOverflow;
45
+ using internal::MultiplyWithOverflow;
46
+ namespace py {
47
+ namespace internal {
48
+
49
+ #ifndef PYPY_VERSION
50
+ extern PyDateTime_CAPI* datetime_api;
51
+
52
+ ARROW_PYTHON_EXPORT
53
+ void InitDatetime();
54
+ #endif
55
+
56
+ // Returns the MonthDayNano namedtuple type (increments the reference count).
57
+ ARROW_PYTHON_EXPORT
58
+ PyObject* NewMonthDayNanoTupleType();
59
+
60
+ ARROW_PYTHON_EXPORT
61
+ inline int64_t PyTime_to_us(PyObject* pytime) {
62
+ return (PyDateTime_TIME_GET_HOUR(pytime) * 3600000000LL +
63
+ PyDateTime_TIME_GET_MINUTE(pytime) * 60000000LL +
64
+ PyDateTime_TIME_GET_SECOND(pytime) * 1000000LL +
65
+ PyDateTime_TIME_GET_MICROSECOND(pytime));
66
+ }
67
+
68
+ ARROW_PYTHON_EXPORT
69
+ inline int64_t PyTime_to_s(PyObject* pytime) { return PyTime_to_us(pytime) / 1000000; }
70
+
71
+ ARROW_PYTHON_EXPORT
72
+ inline int64_t PyTime_to_ms(PyObject* pytime) { return PyTime_to_us(pytime) / 1000; }
73
+
74
+ ARROW_PYTHON_EXPORT
75
+ inline int64_t PyTime_to_ns(PyObject* pytime) { return PyTime_to_us(pytime) * 1000; }
76
+
77
+ ARROW_PYTHON_EXPORT
78
+ Status PyTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out);
79
+
80
+ ARROW_PYTHON_EXPORT
81
+ Status PyDate_from_int(int64_t val, const DateUnit unit, PyObject** out);
82
+
83
+ // WARNING: This function returns a naive datetime.
84
+ ARROW_PYTHON_EXPORT
85
+ Status PyDateTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out);
86
+
87
+ // This declaration must be the same as in filesystem/filesystem.h
88
+ using TimePoint =
89
+ std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>;
90
+
91
+ ARROW_PYTHON_EXPORT
92
+ int64_t PyDate_to_days(PyDateTime_Date* pydate);
93
+
94
+ ARROW_PYTHON_EXPORT
95
+ inline int64_t PyDate_to_s(PyDateTime_Date* pydate) {
96
+ return PyDate_to_days(pydate) * 86400LL;
97
+ }
98
+
99
+ ARROW_PYTHON_EXPORT
100
+ inline int64_t PyDate_to_ms(PyDateTime_Date* pydate) {
101
+ return PyDate_to_days(pydate) * 86400000LL;
102
+ }
103
+
104
+ ARROW_PYTHON_EXPORT
105
+ inline int64_t PyDateTime_to_s(PyDateTime_DateTime* pydatetime) {
106
+ return (PyDate_to_s(reinterpret_cast<PyDateTime_Date*>(pydatetime)) +
107
+ PyDateTime_DATE_GET_HOUR(pydatetime) * 3600LL +
108
+ PyDateTime_DATE_GET_MINUTE(pydatetime) * 60LL +
109
+ PyDateTime_DATE_GET_SECOND(pydatetime));
110
+ }
111
+
112
+ ARROW_PYTHON_EXPORT
113
+ inline int64_t PyDateTime_to_ms(PyDateTime_DateTime* pydatetime) {
114
+ return (PyDateTime_to_s(pydatetime) * 1000LL +
115
+ PyDateTime_DATE_GET_MICROSECOND(pydatetime) / 1000);
116
+ }
117
+
118
+ ARROW_PYTHON_EXPORT
119
+ inline int64_t PyDateTime_to_us(PyDateTime_DateTime* pydatetime) {
120
+ return (PyDateTime_to_s(pydatetime) * 1000000LL +
121
+ PyDateTime_DATE_GET_MICROSECOND(pydatetime));
122
+ }
123
+
124
+ ARROW_PYTHON_EXPORT
125
+ inline int64_t PyDateTime_to_ns(PyDateTime_DateTime* pydatetime) {
126
+ return PyDateTime_to_us(pydatetime) * 1000LL;
127
+ }
128
+
129
+ ARROW_PYTHON_EXPORT
130
+ inline TimePoint PyDateTime_to_TimePoint(PyDateTime_DateTime* pydatetime) {
131
+ return TimePoint(TimePoint::duration(PyDateTime_to_ns(pydatetime)));
132
+ }
133
+
134
+ ARROW_PYTHON_EXPORT
135
+ inline int64_t TimePoint_to_ns(TimePoint val) { return val.time_since_epoch().count(); }
136
+
137
+ ARROW_PYTHON_EXPORT
138
+ inline TimePoint TimePoint_from_s(double val) {
139
+ return TimePoint(TimePoint::duration(static_cast<int64_t>(1e9 * val)));
140
+ }
141
+
142
+ ARROW_PYTHON_EXPORT
143
+ inline TimePoint TimePoint_from_ns(int64_t val) {
144
+ return TimePoint(TimePoint::duration(val));
145
+ }
146
+
147
+ ARROW_PYTHON_EXPORT
148
+ inline int64_t PyDelta_to_s(PyDateTime_Delta* pytimedelta) {
149
+ return (PyDateTime_DELTA_GET_DAYS(pytimedelta) * 86400LL +
150
+ PyDateTime_DELTA_GET_SECONDS(pytimedelta));
151
+ }
152
+
153
+ ARROW_PYTHON_EXPORT
154
+ inline int64_t PyDelta_to_ms(PyDateTime_Delta* pytimedelta) {
155
+ return (PyDelta_to_s(pytimedelta) * 1000LL +
156
+ PyDateTime_DELTA_GET_MICROSECONDS(pytimedelta) / 1000);
157
+ }
158
+
159
+ ARROW_PYTHON_EXPORT
160
+ inline Result<int64_t> PyDelta_to_us(PyDateTime_Delta* pytimedelta) {
161
+ int64_t result = PyDelta_to_s(pytimedelta);
162
+ if (MultiplyWithOverflow(result, 1000000LL, &result)) {
163
+ return Status::Invalid("Timedelta too large to fit in 64-bit integer");
164
+ }
165
+ if (AddWithOverflow(result, PyDateTime_DELTA_GET_MICROSECONDS(pytimedelta), &result)) {
166
+ return Status::Invalid("Timedelta too large to fit in 64-bit integer");
167
+ }
168
+ return result;
169
+ }
170
+
171
+ ARROW_PYTHON_EXPORT
172
+ inline Result<int64_t> PyDelta_to_ns(PyDateTime_Delta* pytimedelta) {
173
+ ARROW_ASSIGN_OR_RAISE(int64_t result, PyDelta_to_us(pytimedelta));
174
+ if (MultiplyWithOverflow(result, 1000LL, &result)) {
175
+ return Status::Invalid("Timedelta too large to fit in 64-bit integer");
176
+ }
177
+ return result;
178
+ }
179
+
180
+ ARROW_PYTHON_EXPORT
181
+ Result<int64_t> PyDateTime_utcoffset_s(PyObject* pydatetime);
182
+
183
+ /// \brief Convert a time zone name into a time zone object.
184
+ ///
185
+ /// Supported input strings are:
186
+ /// * As used in the Olson time zone database (the "tz database" or
187
+ /// "tzdata"), such as "America/New_York"
188
+ /// * An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30
189
+ /// GIL must be held when calling this method.
190
+ ARROW_PYTHON_EXPORT
191
+ Result<PyObject*> StringToTzinfo(const std::string& tz);
192
+
193
+ /// \brief Convert a time zone object to a string representation.
194
+ ///
195
+ /// The output strings are:
196
+ /// * An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30
197
+ /// if the input object is either an instance of pytz._FixedOffset or
198
+ /// datetime.timedelta
199
+ /// * The timezone's name if the input object's tzname() method returns with a
200
+ /// non-empty timezone name such as "UTC" or "America/New_York"
201
+ ///
202
+ /// GIL must be held when calling this method.
203
+ ARROW_PYTHON_EXPORT
204
+ Result<std::string> TzinfoToString(PyObject* pytzinfo);
205
+
206
+ /// \brief Convert MonthDayNano to a python namedtuple.
207
+ ///
208
+ /// Return a named tuple (pyarrow.MonthDayNano) containing attributes
209
+ /// "months", "days", "nanoseconds" in the given order
210
+ /// with values extracted from the fields on interval.
211
+ ///
212
+ /// GIL must be held when calling this method.
213
+ ARROW_PYTHON_EXPORT
214
+ PyObject* MonthDayNanoIntervalToNamedTuple(
215
+ const MonthDayNanoIntervalType::MonthDayNanos& interval);
216
+
217
+ /// \brief Convert the given Array to a PyList object containing
218
+ /// pyarrow.MonthDayNano objects.
219
+ ARROW_PYTHON_EXPORT
220
+ Result<PyObject*> MonthDayNanoIntervalArrayToPyList(
221
+ const MonthDayNanoIntervalArray& array);
222
+
223
+ /// \brief Convert the Scalar object to a pyarrow.MonthDayNano (or None if
224
+ /// is isn't valid).
225
+ ARROW_PYTHON_EXPORT
226
+ Result<PyObject*> MonthDayNanoIntervalScalarToPyObject(
227
+ const MonthDayNanoIntervalScalar& scalar);
228
+
229
+ } // namespace internal
230
+ } // namespace py
231
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/decimal.cc ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include <algorithm>
19
+ #include <limits>
20
+
21
+ #include "arrow/python/common.h"
22
+ #include "arrow/python/decimal.h"
23
+ #include "arrow/python/helpers.h"
24
+ #include "arrow/type_fwd.h"
25
+ #include "arrow/util/decimal.h"
26
+ #include "arrow/util/logging.h"
27
+
28
+ namespace arrow {
29
+ namespace py {
30
+ namespace internal {
31
+
32
+ Status ImportDecimalType(OwnedRef* decimal_type) {
33
+ OwnedRef decimal_module;
34
+ RETURN_NOT_OK(ImportModule("decimal", &decimal_module));
35
+ RETURN_NOT_OK(ImportFromModule(decimal_module.obj(), "Decimal", decimal_type));
36
+ return Status::OK();
37
+ }
38
+
39
+ Status PythonDecimalToString(PyObject* python_decimal, std::string* out) {
40
+ // Call Python's str(decimal_object)
41
+ return PyObject_StdStringStr(python_decimal, out);
42
+ }
43
+
44
+ // \brief Infer the precision and scale of a Python decimal.Decimal instance
45
+ // \param python_decimal[in] An instance of decimal.Decimal
46
+ // \param precision[out] The value of the inferred precision
47
+ // \param scale[out] The value of the inferred scale
48
+ // \return The status of the operation
49
+ static Status InferDecimalPrecisionAndScale(PyObject* python_decimal, int32_t* precision,
50
+ int32_t* scale) {
51
+ ARROW_DCHECK_NE(python_decimal, NULLPTR);
52
+ ARROW_DCHECK_NE(precision, NULLPTR);
53
+ ARROW_DCHECK_NE(scale, NULLPTR);
54
+
55
+ // TODO(phillipc): Make sure we perform PyDecimal_Check(python_decimal) as a
56
+ // ARROW_DCHECK
57
+ OwnedRef as_tuple(PyObject_CallMethod(python_decimal, const_cast<char*>("as_tuple"),
58
+ const_cast<char*>("")));
59
+ RETURN_IF_PYERROR();
60
+ ARROW_DCHECK(PyTuple_Check(as_tuple.obj()));
61
+
62
+ OwnedRef digits(PyObject_GetAttrString(as_tuple.obj(), "digits"));
63
+ RETURN_IF_PYERROR();
64
+ ARROW_DCHECK(PyTuple_Check(digits.obj()));
65
+
66
+ const auto num_digits = static_cast<int32_t>(PyTuple_Size(digits.obj()));
67
+ RETURN_IF_PYERROR();
68
+
69
+ OwnedRef py_exponent(PyObject_GetAttrString(as_tuple.obj(), "exponent"));
70
+ RETURN_IF_PYERROR();
71
+ ARROW_DCHECK(IsPyInteger(py_exponent.obj()));
72
+
73
+ const auto exponent = static_cast<int32_t>(PyLong_AsLong(py_exponent.obj()));
74
+ RETURN_IF_PYERROR();
75
+
76
+ if (exponent < 0) {
77
+ // If exponent > num_digits, we have a number with leading zeros
78
+ // such as 0.01234. Ensure we have enough precision for leading zeros
79
+ // (which are not included in num_digits).
80
+ *precision = std::max(num_digits, -exponent);
81
+ *scale = -exponent;
82
+ } else {
83
+ // Trailing zeros are not included in num_digits, need to add to precision.
84
+ // Note we don't generate negative scales as they are poorly supported
85
+ // in non-Arrow systems.
86
+ *precision = num_digits + exponent;
87
+ *scale = 0;
88
+ }
89
+ return Status::OK();
90
+ }
91
+
92
+ PyObject* DecimalFromString(PyObject* decimal_constructor,
93
+ const std::string& decimal_string) {
94
+ ARROW_DCHECK_NE(decimal_constructor, nullptr);
95
+
96
+ auto string_size = decimal_string.size();
97
+ ARROW_DCHECK_GT(string_size, 0);
98
+
99
+ auto string_bytes = decimal_string.c_str();
100
+ ARROW_DCHECK_NE(string_bytes, nullptr);
101
+
102
+ return PyObject_CallFunction(decimal_constructor, const_cast<char*>("s#"), string_bytes,
103
+ static_cast<Py_ssize_t>(string_size));
104
+ }
105
+
106
+ namespace {
107
+
108
+ template <typename ArrowDecimal>
109
+ Status DecimalFromStdString(const std::string& decimal_string,
110
+ const DecimalType& arrow_type, ArrowDecimal* out) {
111
+ int32_t inferred_precision;
112
+ int32_t inferred_scale;
113
+
114
+ RETURN_NOT_OK(ArrowDecimal::FromString(decimal_string, out, &inferred_precision,
115
+ &inferred_scale));
116
+
117
+ const int32_t precision = arrow_type.precision();
118
+ const int32_t scale = arrow_type.scale();
119
+
120
+ if (scale != inferred_scale) {
121
+ ARROW_DCHECK_NE(out, NULLPTR);
122
+ ARROW_ASSIGN_OR_RAISE(*out, out->Rescale(inferred_scale, scale));
123
+ }
124
+
125
+ auto inferred_scale_delta = inferred_scale - scale;
126
+ if (ARROW_PREDICT_FALSE((inferred_precision - inferred_scale_delta) > precision)) {
127
+ return Status::Invalid(
128
+ "Decimal type with precision ", inferred_precision,
129
+ " does not fit into precision inferred from first array element: ", precision);
130
+ }
131
+
132
+ return Status::OK();
133
+ }
134
+
135
+ template <typename ArrowDecimal>
136
+ Status InternalDecimalFromPythonDecimal(PyObject* python_decimal,
137
+ const DecimalType& arrow_type,
138
+ ArrowDecimal* out) {
139
+ ARROW_DCHECK_NE(python_decimal, NULLPTR);
140
+ ARROW_DCHECK_NE(out, NULLPTR);
141
+
142
+ std::string string;
143
+ RETURN_NOT_OK(PythonDecimalToString(python_decimal, &string));
144
+ return DecimalFromStdString(string, arrow_type, out);
145
+ }
146
+
147
+ template <typename ArrowDecimal>
148
+ Status InternalDecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type,
149
+ ArrowDecimal* out) {
150
+ ARROW_DCHECK_NE(obj, NULLPTR);
151
+ ARROW_DCHECK_NE(out, NULLPTR);
152
+
153
+ if (IsPyInteger(obj)) {
154
+ // TODO: add a fast path for small-ish ints
155
+ std::string string;
156
+ RETURN_NOT_OK(PyObject_StdStringStr(obj, &string));
157
+ return DecimalFromStdString(string, arrow_type, out);
158
+ } else if (PyDecimal_Check(obj)) {
159
+ return InternalDecimalFromPythonDecimal<ArrowDecimal>(obj, arrow_type, out);
160
+ } else {
161
+ return Status::TypeError("int or Decimal object expected, got ",
162
+ Py_TYPE(obj)->tp_name);
163
+ }
164
+ }
165
+
166
+ } // namespace
167
+
168
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
169
+ Decimal32* out) {
170
+ return InternalDecimalFromPythonDecimal(python_decimal, arrow_type, out);
171
+ }
172
+
173
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type, Decimal32* out) {
174
+ return InternalDecimalFromPyObject(obj, arrow_type, out);
175
+ }
176
+
177
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
178
+ Decimal64* out) {
179
+ return InternalDecimalFromPythonDecimal(python_decimal, arrow_type, out);
180
+ }
181
+
182
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type, Decimal64* out) {
183
+ return InternalDecimalFromPyObject(obj, arrow_type, out);
184
+ }
185
+
186
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
187
+ Decimal128* out) {
188
+ return InternalDecimalFromPythonDecimal(python_decimal, arrow_type, out);
189
+ }
190
+
191
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type,
192
+ Decimal128* out) {
193
+ return InternalDecimalFromPyObject(obj, arrow_type, out);
194
+ }
195
+
196
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
197
+ Decimal256* out) {
198
+ return InternalDecimalFromPythonDecimal(python_decimal, arrow_type, out);
199
+ }
200
+
201
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type,
202
+ Decimal256* out) {
203
+ return InternalDecimalFromPyObject(obj, arrow_type, out);
204
+ }
205
+
206
+ bool PyDecimal_Check(PyObject* obj) {
207
+ static OwnedRef decimal_type;
208
+ if (!decimal_type.obj()) {
209
+ ARROW_CHECK_OK(ImportDecimalType(&decimal_type));
210
+ ARROW_DCHECK(PyType_Check(decimal_type.obj()));
211
+ }
212
+ // PyObject_IsInstance() is slower as it has to check for virtual subclasses
213
+ const int result =
214
+ PyType_IsSubtype(Py_TYPE(obj), reinterpret_cast<PyTypeObject*>(decimal_type.obj()));
215
+ ARROW_CHECK_NE(result, -1) << " error during PyType_IsSubtype check";
216
+ return result == 1;
217
+ }
218
+
219
+ bool PyDecimal_ISNAN(PyObject* obj) {
220
+ ARROW_DCHECK(PyDecimal_Check(obj)) << "obj is not an instance of decimal.Decimal";
221
+ OwnedRef is_nan(
222
+ PyObject_CallMethod(obj, const_cast<char*>("is_nan"), const_cast<char*>("")));
223
+ return PyObject_IsTrue(is_nan.obj()) == 1;
224
+ }
225
+
226
+ DecimalMetadata::DecimalMetadata()
227
+ : DecimalMetadata(std::numeric_limits<int32_t>::min(),
228
+ std::numeric_limits<int32_t>::min()) {}
229
+
230
+ DecimalMetadata::DecimalMetadata(int32_t precision, int32_t scale)
231
+ : precision_(precision), scale_(scale) {}
232
+
233
+ Status DecimalMetadata::Update(int32_t suggested_precision, int32_t suggested_scale) {
234
+ const int32_t current_scale = scale_;
235
+ scale_ = std::max(current_scale, suggested_scale);
236
+
237
+ const int32_t current_precision = precision_;
238
+
239
+ if (current_precision == std::numeric_limits<int32_t>::min()) {
240
+ precision_ = suggested_precision;
241
+ } else {
242
+ auto num_digits = std::max(current_precision - current_scale,
243
+ suggested_precision - suggested_scale);
244
+ precision_ = std::max(num_digits + scale_, current_precision);
245
+ }
246
+
247
+ return Status::OK();
248
+ }
249
+
250
+ Status DecimalMetadata::Update(PyObject* object) {
251
+ bool is_decimal = PyDecimal_Check(object);
252
+
253
+ if (ARROW_PREDICT_FALSE(!is_decimal || PyDecimal_ISNAN(object))) {
254
+ return Status::OK();
255
+ }
256
+
257
+ int32_t precision = 0;
258
+ int32_t scale = 0;
259
+ RETURN_NOT_OK(InferDecimalPrecisionAndScale(object, &precision, &scale));
260
+ return Update(precision, scale);
261
+ }
262
+
263
+ } // namespace internal
264
+ } // namespace py
265
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/decimal.h ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <string>
21
+
22
+ #include "arrow/python/visibility.h"
23
+ #include "arrow/type.h"
24
+
25
+ namespace arrow {
26
+
27
+ class Decimal128;
28
+ class Decimal256;
29
+
30
+ namespace py {
31
+
32
+ class OwnedRef;
33
+
34
+ //
35
+ // Python Decimal support
36
+ //
37
+
38
+ namespace internal {
39
+
40
+ // \brief Import the Python Decimal type
41
+ ARROW_PYTHON_EXPORT
42
+ Status ImportDecimalType(OwnedRef* decimal_type);
43
+
44
+ // \brief Convert a Python Decimal object to a C++ string
45
+ // \param[in] python_decimal A Python decimal.Decimal instance
46
+ // \param[out] The string representation of the Python Decimal instance
47
+ // \return The status of the operation
48
+ ARROW_PYTHON_EXPORT
49
+ Status PythonDecimalToString(PyObject* python_decimal, std::string* out);
50
+
51
+ // \brief Convert a C++ std::string to a Python Decimal instance
52
+ // \param[in] decimal_constructor The decimal type object
53
+ // \param[in] decimal_string A decimal string
54
+ // \return An instance of decimal.Decimal
55
+ ARROW_PYTHON_EXPORT
56
+ PyObject* DecimalFromString(PyObject* decimal_constructor,
57
+ const std::string& decimal_string);
58
+
59
+ // \brief Convert a Python decimal to an Arrow Decimal128 object
60
+ // \param[in] python_decimal A Python decimal.Decimal instance
61
+ // \param[in] arrow_type An instance of arrow::DecimalType
62
+ // \param[out] out A pointer to a Decimal128
63
+ // \return The status of the operation
64
+ ARROW_PYTHON_EXPORT
65
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
66
+ Decimal32* out);
67
+
68
+ // \brief Convert a Python object to an Arrow Decimal128 object
69
+ // \param[in] python_decimal A Python int or decimal.Decimal instance
70
+ // \param[in] arrow_type An instance of arrow::DecimalType
71
+ // \param[out] out A pointer to a Decimal128
72
+ // \return The status of the operation
73
+ ARROW_PYTHON_EXPORT
74
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type, Decimal32* out);
75
+
76
+ // \brief Convert a Python decimal to an Arrow Decimal128 object
77
+ // \param[in] python_decimal A Python decimal.Decimal instance
78
+ // \param[in] arrow_type An instance of arrow::DecimalType
79
+ // \param[out] out A pointer to a Decimal128
80
+ // \return The status of the operation
81
+ ARROW_PYTHON_EXPORT
82
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
83
+ Decimal64* out);
84
+
85
+ // \brief Convert a Python object to an Arrow Decimal128 object
86
+ // \param[in] python_decimal A Python int or decimal.Decimal instance
87
+ // \param[in] arrow_type An instance of arrow::DecimalType
88
+ // \param[out] out A pointer to a Decimal128
89
+ // \return The status of the operation
90
+ ARROW_PYTHON_EXPORT
91
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type, Decimal64* out);
92
+
93
+ // \brief Convert a Python decimal to an Arrow Decimal128 object
94
+ // \param[in] python_decimal A Python decimal.Decimal instance
95
+ // \param[in] arrow_type An instance of arrow::DecimalType
96
+ // \param[out] out A pointer to a Decimal128
97
+ // \return The status of the operation
98
+ ARROW_PYTHON_EXPORT
99
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
100
+ Decimal128* out);
101
+
102
+ // \brief Convert a Python object to an Arrow Decimal128 object
103
+ // \param[in] python_decimal A Python int or decimal.Decimal instance
104
+ // \param[in] arrow_type An instance of arrow::DecimalType
105
+ // \param[out] out A pointer to a Decimal128
106
+ // \return The status of the operation
107
+ ARROW_PYTHON_EXPORT
108
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type, Decimal128* out);
109
+
110
+ // \brief Convert a Python decimal to an Arrow Decimal256 object
111
+ // \param[in] python_decimal A Python decimal.Decimal instance
112
+ // \param[in] arrow_type An instance of arrow::DecimalType
113
+ // \param[out] out A pointer to a Decimal256
114
+ // \return The status of the operation
115
+ ARROW_PYTHON_EXPORT
116
+ Status DecimalFromPythonDecimal(PyObject* python_decimal, const DecimalType& arrow_type,
117
+ Decimal256* out);
118
+
119
+ // \brief Convert a Python object to an Arrow Decimal256 object
120
+ // \param[in] python_decimal A Python int or decimal.Decimal instance
121
+ // \param[in] arrow_type An instance of arrow::DecimalType
122
+ // \param[out] out A pointer to a Decimal256
123
+ // \return The status of the operation
124
+ ARROW_PYTHON_EXPORT
125
+ Status DecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type, Decimal256* out);
126
+
127
+ // \brief Check whether obj is an instance of Decimal
128
+ ARROW_PYTHON_EXPORT
129
+ bool PyDecimal_Check(PyObject* obj);
130
+
131
+ // \brief Check whether obj is nan. This function will abort the program if the argument
132
+ // is not a Decimal instance
133
+ ARROW_PYTHON_EXPORT
134
+ bool PyDecimal_ISNAN(PyObject* obj);
135
+
136
+ // \brief Helper class to track and update the precision and scale of a decimal
137
+ class ARROW_PYTHON_EXPORT DecimalMetadata {
138
+ public:
139
+ DecimalMetadata();
140
+ DecimalMetadata(int32_t precision, int32_t scale);
141
+
142
+ // \brief Adjust the precision and scale of a decimal type given a new precision and a
143
+ // new scale \param[in] suggested_precision A candidate precision \param[in]
144
+ // suggested_scale A candidate scale \return The status of the operation
145
+ Status Update(int32_t suggested_precision, int32_t suggested_scale);
146
+
147
+ // \brief A convenient interface for updating the precision and scale based on a Python
148
+ // Decimal object \param object A Python Decimal object \return The status of the
149
+ // operation
150
+ Status Update(PyObject* object);
151
+
152
+ int32_t precision() const { return precision_; }
153
+ int32_t scale() const { return scale_; }
154
+
155
+ private:
156
+ int32_t precision_;
157
+ int32_t scale_;
158
+ };
159
+
160
+ } // namespace internal
161
+ } // namespace py
162
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/extension_type.cc ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include <memory>
19
+ #include <sstream>
20
+ #include <utility>
21
+
22
+ #include "arrow/python/extension_type.h"
23
+ #include "arrow/python/helpers.h"
24
+ #include "arrow/python/pyarrow.h"
25
+ #include "arrow/python/vendored/pythoncapi_compat.h"
26
+ #include "arrow/util/checked_cast.h"
27
+ #include "arrow/util/logging.h"
28
+
29
+ namespace arrow {
30
+
31
+ using internal::checked_cast;
32
+
33
+ namespace py {
34
+
35
+ namespace {
36
+
37
+ // Serialize a Python ExtensionType instance
38
+ Status SerializeExtInstance(PyObject* type_instance, std::string* out) {
39
+ OwnedRef res(
40
+ cpp_PyObject_CallMethod(type_instance, "__arrow_ext_serialize__", nullptr));
41
+ if (!res) {
42
+ return ConvertPyError();
43
+ }
44
+ if (!PyBytes_Check(res.obj())) {
45
+ return Status::TypeError(
46
+ "__arrow_ext_serialize__ should return bytes object, "
47
+ "got ",
48
+ internal::PyObject_StdStringRepr(res.obj()));
49
+ }
50
+ *out = internal::PyBytes_AsStdString(res.obj());
51
+ return Status::OK();
52
+ }
53
+
54
+ // Deserialize a Python ExtensionType instance
55
+ PyObject* DeserializeExtInstance(PyObject* type_class,
56
+ std::shared_ptr<DataType> storage_type,
57
+ const std::string& serialized_data) {
58
+ OwnedRef storage_ref(wrap_data_type(storage_type));
59
+ if (!storage_ref) {
60
+ return nullptr;
61
+ }
62
+ OwnedRef data_ref(PyBytes_FromStringAndSize(
63
+ serialized_data.data(), static_cast<Py_ssize_t>(serialized_data.size())));
64
+ if (!data_ref) {
65
+ return nullptr;
66
+ }
67
+
68
+ return cpp_PyObject_CallMethod(type_class, "__arrow_ext_deserialize__", "OO",
69
+ storage_ref.obj(), data_ref.obj());
70
+ }
71
+
72
+ } // namespace
73
+
74
+ static const char* kExtensionName = "arrow.py_extension_type";
75
+
76
+ std::string PyExtensionType::ToString(bool show_metadata) const {
77
+ PyAcquireGIL lock;
78
+
79
+ std::stringstream ss;
80
+ OwnedRef instance(GetInstance());
81
+ ss << "extension<" << this->extension_name() << "<" << Py_TYPE(instance.obj())->tp_name
82
+ << ">>";
83
+ return ss.str();
84
+ }
85
+
86
+ PyExtensionType::PyExtensionType(std::shared_ptr<DataType> storage_type, PyObject* typ,
87
+ PyObject* inst)
88
+ : ExtensionType(storage_type),
89
+ extension_name_(kExtensionName),
90
+ type_class_(typ),
91
+ type_instance_(inst) {}
92
+
93
+ PyExtensionType::PyExtensionType(std::shared_ptr<DataType> storage_type,
94
+ std::string extension_name, PyObject* typ,
95
+ PyObject* inst)
96
+ : ExtensionType(storage_type),
97
+ extension_name_(std::move(extension_name)),
98
+ type_class_(typ),
99
+ type_instance_(inst) {}
100
+
101
+ bool PyExtensionType::ExtensionEquals(const ExtensionType& other) const {
102
+ PyAcquireGIL lock;
103
+
104
+ if (other.extension_name() != extension_name()) {
105
+ return false;
106
+ }
107
+ const auto& other_ext = checked_cast<const PyExtensionType&>(other);
108
+ int res = -1;
109
+ if (!type_instance_) {
110
+ if (other_ext.type_instance_) {
111
+ return false;
112
+ }
113
+ // Compare Python types
114
+ res = PyObject_RichCompareBool(type_class_.obj(), other_ext.type_class_.obj(), Py_EQ);
115
+ } else {
116
+ if (!other_ext.type_instance_) {
117
+ return false;
118
+ }
119
+ // Compare Python instances
120
+ OwnedRef left(GetInstance());
121
+ OwnedRef right(other_ext.GetInstance());
122
+ if (!left || !right) {
123
+ goto error;
124
+ }
125
+ res = PyObject_RichCompareBool(left.obj(), right.obj(), Py_EQ);
126
+ }
127
+ if (res == -1) {
128
+ goto error;
129
+ }
130
+ return res == 1;
131
+
132
+ error:
133
+ // Cannot propagate error
134
+ PyErr_WriteUnraisable(nullptr);
135
+ return false;
136
+ }
137
+
138
+ std::shared_ptr<Array> PyExtensionType::MakeArray(std::shared_ptr<ArrayData> data) const {
139
+ ARROW_DCHECK_EQ(data->type->id(), Type::EXTENSION);
140
+ return std::make_shared<ExtensionArray>(data);
141
+ }
142
+
143
+ std::string PyExtensionType::Serialize() const {
144
+ ARROW_DCHECK(type_instance_);
145
+ return serialized_;
146
+ }
147
+
148
+ Result<std::shared_ptr<DataType>> PyExtensionType::Deserialize(
149
+ std::shared_ptr<DataType> storage_type, const std::string& serialized_data) const {
150
+ PyAcquireGIL lock;
151
+
152
+ if (import_pyarrow()) {
153
+ return ConvertPyError();
154
+ }
155
+ OwnedRef res(DeserializeExtInstance(type_class_.obj(), storage_type, serialized_data));
156
+ if (!res) {
157
+ return ConvertPyError();
158
+ }
159
+ return unwrap_data_type(res.obj());
160
+ }
161
+
162
+ PyObject* PyExtensionType::GetInstance() const {
163
+ if (!type_instance_) {
164
+ PyErr_SetString(PyExc_TypeError, "Not an instance");
165
+ return nullptr;
166
+ }
167
+ ARROW_DCHECK(PyWeakref_CheckRef(type_instance_.obj()));
168
+ PyObject* inst = NULL;
169
+ int result = PyWeakref_GetRef(type_instance_.obj(), &inst);
170
+ if (result == 1) {
171
+ // Alive: inst is a new strong reference
172
+ return inst;
173
+ } else if (result == 0) {
174
+ // Weakref is dead, must reconstruct from serialized form
175
+ // XXX cache again?
176
+ return DeserializeExtInstance(type_class_.obj(), storage_type_, serialized_);
177
+ } else {
178
+ // -1 = exception
179
+ return nullptr;
180
+ }
181
+ }
182
+
183
+ Status PyExtensionType::SetInstance(PyObject* inst) const {
184
+ // Check we have the right type
185
+ PyObject* typ = reinterpret_cast<PyObject*>(Py_TYPE(inst));
186
+ if (typ != type_class_.obj()) {
187
+ return Status::TypeError("Unexpected Python ExtensionType class ",
188
+ internal::PyObject_StdStringRepr(typ), " expected ",
189
+ internal::PyObject_StdStringRepr(type_class_.obj()));
190
+ }
191
+
192
+ PyObject* wr = PyWeakref_NewRef(inst, nullptr);
193
+ if (wr == NULL) {
194
+ return ConvertPyError();
195
+ }
196
+ type_instance_.reset(wr);
197
+ return SerializeExtInstance(inst, &serialized_);
198
+ }
199
+
200
+ Status PyExtensionType::FromClass(const std::shared_ptr<DataType> storage_type,
201
+ const std::string extension_name, PyObject* typ,
202
+ std::shared_ptr<ExtensionType>* out) {
203
+ Py_INCREF(typ);
204
+ out->reset(new PyExtensionType(storage_type, std::move(extension_name), typ));
205
+ return Status::OK();
206
+ }
207
+
208
+ Status RegisterPyExtensionType(const std::shared_ptr<DataType>& type) {
209
+ ARROW_DCHECK_EQ(type->id(), Type::EXTENSION);
210
+ auto ext_type = std::dynamic_pointer_cast<ExtensionType>(type);
211
+ return RegisterExtensionType(ext_type);
212
+ }
213
+
214
+ Status UnregisterPyExtensionType(const std::string& type_name) {
215
+ return UnregisterExtensionType(type_name);
216
+ }
217
+
218
+ std::string PyExtensionName() { return kExtensionName; }
219
+
220
+ } // namespace py
221
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/extension_type.h ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <memory>
21
+ #include <string>
22
+
23
+ #include "arrow/extension_type.h"
24
+ #include "arrow/python/common.h"
25
+ #include "arrow/python/visibility.h"
26
+ #include "arrow/util/macros.h"
27
+
28
+ namespace arrow {
29
+ namespace py {
30
+
31
+ class ARROW_PYTHON_EXPORT PyExtensionType : public ExtensionType {
32
+ public:
33
+ // Implement extensionType API
34
+ std::string extension_name() const override { return extension_name_; }
35
+
36
+ std::string ToString(bool show_metadata = false) const override;
37
+
38
+ bool ExtensionEquals(const ExtensionType& other) const override;
39
+
40
+ std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
41
+
42
+ Result<std::shared_ptr<DataType>> Deserialize(
43
+ std::shared_ptr<DataType> storage_type,
44
+ const std::string& serialized) const override;
45
+
46
+ std::string Serialize() const override;
47
+
48
+ // For use from Cython
49
+ // Assumes that `typ` is borrowed
50
+ static Status FromClass(const std::shared_ptr<DataType> storage_type,
51
+ const std::string extension_name, PyObject* typ,
52
+ std::shared_ptr<ExtensionType>* out);
53
+
54
+ // Return new ref
55
+ PyObject* GetInstance() const;
56
+ Status SetInstance(PyObject*) const;
57
+
58
+ protected:
59
+ PyExtensionType(std::shared_ptr<DataType> storage_type, PyObject* typ,
60
+ PyObject* inst = NULLPTR);
61
+ PyExtensionType(std::shared_ptr<DataType> storage_type, std::string extension_name,
62
+ PyObject* typ, PyObject* inst = NULLPTR);
63
+
64
+ std::string extension_name_;
65
+
66
+ // These fields are mutable because of two-step initialization.
67
+ mutable OwnedRefNoGIL type_class_;
68
+ // A weakref or null. Storing a strong reference to the Python extension type
69
+ // instance would create an unreclaimable reference cycle between Python and C++
70
+ // (the Python instance has to keep a strong reference to the C++ ExtensionType
71
+ // in other direction). Instead, we store a weakref to the instance.
72
+ // If the weakref is dead, we reconstruct the instance from its serialized form.
73
+ mutable OwnedRefNoGIL type_instance_;
74
+ // Empty if type_instance_ is null
75
+ mutable std::string serialized_;
76
+ };
77
+
78
+ ARROW_PYTHON_EXPORT std::string PyExtensionName();
79
+
80
+ ARROW_PYTHON_EXPORT Status RegisterPyExtensionType(const std::shared_ptr<DataType>&);
81
+
82
+ ARROW_PYTHON_EXPORT Status UnregisterPyExtensionType(const std::string& type_name);
83
+
84
+ } // namespace py
85
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/filesystem.cc ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #include "arrow/python/filesystem.h"
19
+ #include "arrow/util/logging.h"
20
+
21
+ namespace arrow {
22
+
23
+ using fs::FileInfo;
24
+ using fs::FileSelector;
25
+
26
+ namespace py {
27
+ namespace fs {
28
+
29
+ PyFileSystem::PyFileSystem(PyObject* handler, PyFileSystemVtable vtable)
30
+ : handler_(handler), vtable_(std::move(vtable)) {
31
+ Py_INCREF(handler);
32
+ }
33
+
34
+ PyFileSystem::~PyFileSystem() {}
35
+
36
+ std::shared_ptr<PyFileSystem> PyFileSystem::Make(PyObject* handler,
37
+ PyFileSystemVtable vtable) {
38
+ return std::make_shared<PyFileSystem>(handler, std::move(vtable));
39
+ }
40
+
41
+ std::string PyFileSystem::type_name() const {
42
+ std::string result;
43
+ auto st = SafeCallIntoPython([&]() -> Status {
44
+ vtable_.get_type_name(handler_.obj(), &result);
45
+ if (PyErr_Occurred()) {
46
+ PyErr_WriteUnraisable(handler_.obj());
47
+ }
48
+ return Status::OK();
49
+ });
50
+ ARROW_UNUSED(st);
51
+ return result;
52
+ }
53
+
54
+ bool PyFileSystem::Equals(const FileSystem& other) const {
55
+ bool result;
56
+ auto st = SafeCallIntoPython([&]() -> Status {
57
+ result = vtable_.equals(handler_.obj(), other);
58
+ if (PyErr_Occurred()) {
59
+ PyErr_WriteUnraisable(handler_.obj());
60
+ }
61
+ return Status::OK();
62
+ });
63
+ ARROW_UNUSED(st);
64
+ return result;
65
+ }
66
+
67
+ Result<FileInfo> PyFileSystem::GetFileInfo(const std::string& path) {
68
+ FileInfo info;
69
+
70
+ auto st = SafeCallIntoPython([&]() -> Status {
71
+ vtable_.get_file_info(handler_.obj(), path, &info);
72
+ return CheckPyError();
73
+ });
74
+ RETURN_NOT_OK(st);
75
+ return info;
76
+ }
77
+
78
+ Result<std::vector<FileInfo>> PyFileSystem::GetFileInfo(
79
+ const std::vector<std::string>& paths) {
80
+ std::vector<FileInfo> infos;
81
+
82
+ auto st = SafeCallIntoPython([&]() -> Status {
83
+ vtable_.get_file_info_vector(handler_.obj(), paths, &infos);
84
+ return CheckPyError();
85
+ });
86
+ RETURN_NOT_OK(st);
87
+ return infos;
88
+ }
89
+
90
+ Result<std::vector<FileInfo>> PyFileSystem::GetFileInfo(const FileSelector& select) {
91
+ std::vector<FileInfo> infos;
92
+
93
+ auto st = SafeCallIntoPython([&]() -> Status {
94
+ vtable_.get_file_info_selector(handler_.obj(), select, &infos);
95
+ return CheckPyError();
96
+ });
97
+ RETURN_NOT_OK(st);
98
+ return infos;
99
+ }
100
+
101
+ Status PyFileSystem::CreateDir(const std::string& path, bool recursive) {
102
+ return SafeCallIntoPython([&]() -> Status {
103
+ vtable_.create_dir(handler_.obj(), path, recursive);
104
+ return CheckPyError();
105
+ });
106
+ }
107
+
108
+ Status PyFileSystem::DeleteDir(const std::string& path) {
109
+ return SafeCallIntoPython([&]() -> Status {
110
+ vtable_.delete_dir(handler_.obj(), path);
111
+ return CheckPyError();
112
+ });
113
+ }
114
+
115
+ Status PyFileSystem::DeleteDirContents(const std::string& path, bool missing_dir_ok) {
116
+ return SafeCallIntoPython([&]() -> Status {
117
+ vtable_.delete_dir_contents(handler_.obj(), path, missing_dir_ok);
118
+ return CheckPyError();
119
+ });
120
+ }
121
+
122
+ Status PyFileSystem::DeleteRootDirContents() {
123
+ return SafeCallIntoPython([&]() -> Status {
124
+ vtable_.delete_root_dir_contents(handler_.obj());
125
+ return CheckPyError();
126
+ });
127
+ }
128
+
129
+ Status PyFileSystem::DeleteFile(const std::string& path) {
130
+ return SafeCallIntoPython([&]() -> Status {
131
+ vtable_.delete_file(handler_.obj(), path);
132
+ return CheckPyError();
133
+ });
134
+ }
135
+
136
+ Status PyFileSystem::Move(const std::string& src, const std::string& dest) {
137
+ return SafeCallIntoPython([&]() -> Status {
138
+ vtable_.move(handler_.obj(), src, dest);
139
+ return CheckPyError();
140
+ });
141
+ }
142
+
143
+ Status PyFileSystem::CopyFile(const std::string& src, const std::string& dest) {
144
+ return SafeCallIntoPython([&]() -> Status {
145
+ vtable_.copy_file(handler_.obj(), src, dest);
146
+ return CheckPyError();
147
+ });
148
+ }
149
+
150
+ Result<std::shared_ptr<io::InputStream>> PyFileSystem::OpenInputStream(
151
+ const std::string& path) {
152
+ std::shared_ptr<io::InputStream> stream;
153
+ auto st = SafeCallIntoPython([&]() -> Status {
154
+ vtable_.open_input_stream(handler_.obj(), path, &stream);
155
+ return CheckPyError();
156
+ });
157
+ RETURN_NOT_OK(st);
158
+ return stream;
159
+ }
160
+
161
+ Result<std::shared_ptr<io::RandomAccessFile>> PyFileSystem::OpenInputFile(
162
+ const std::string& path) {
163
+ std::shared_ptr<io::RandomAccessFile> stream;
164
+ auto st = SafeCallIntoPython([&]() -> Status {
165
+ vtable_.open_input_file(handler_.obj(), path, &stream);
166
+ return CheckPyError();
167
+ });
168
+ RETURN_NOT_OK(st);
169
+ return stream;
170
+ }
171
+
172
+ Result<std::shared_ptr<io::OutputStream>> PyFileSystem::OpenOutputStream(
173
+ const std::string& path, const std::shared_ptr<const KeyValueMetadata>& metadata) {
174
+ std::shared_ptr<io::OutputStream> stream;
175
+ auto st = SafeCallIntoPython([&]() -> Status {
176
+ vtable_.open_output_stream(handler_.obj(), path, metadata, &stream);
177
+ return CheckPyError();
178
+ });
179
+ RETURN_NOT_OK(st);
180
+ return stream;
181
+ }
182
+
183
+ Result<std::shared_ptr<io::OutputStream>> PyFileSystem::OpenAppendStream(
184
+ const std::string& path, const std::shared_ptr<const KeyValueMetadata>& metadata) {
185
+ std::shared_ptr<io::OutputStream> stream;
186
+ auto st = SafeCallIntoPython([&]() -> Status {
187
+ vtable_.open_append_stream(handler_.obj(), path, metadata, &stream);
188
+ return CheckPyError();
189
+ });
190
+ RETURN_NOT_OK(st);
191
+ return stream;
192
+ }
193
+
194
+ Result<std::string> PyFileSystem::NormalizePath(std::string path) {
195
+ std::string normalized;
196
+ auto st = SafeCallIntoPython([&]() -> Status {
197
+ vtable_.normalize_path(handler_.obj(), path, &normalized);
198
+ return CheckPyError();
199
+ });
200
+ RETURN_NOT_OK(st);
201
+ return normalized;
202
+ }
203
+
204
+ } // namespace fs
205
+ } // namespace py
206
+ } // namespace arrow
miniconda3/envs/ladir/lib/python3.10/site-packages/pyarrow/src/arrow/python/filesystem.h ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #pragma once
19
+
20
+ #include <memory>
21
+ #include <string>
22
+ #include <vector>
23
+
24
+ #include "arrow/filesystem/filesystem.h"
25
+ #include "arrow/python/common.h"
26
+ #include "arrow/python/visibility.h"
27
+ #include "arrow/util/macros.h"
28
+
29
+ namespace arrow::py::fs {
30
+
31
+ class ARROW_PYTHON_EXPORT PyFileSystemVtable {
32
+ public:
33
+ std::function<void(PyObject*, std::string* out)> get_type_name;
34
+ std::function<bool(PyObject*, const arrow::fs::FileSystem& other)> equals;
35
+
36
+ std::function<void(PyObject*, const std::string& path, arrow::fs::FileInfo* out)>
37
+ get_file_info;
38
+ std::function<void(PyObject*, const std::vector<std::string>& paths,
39
+ std::vector<arrow::fs::FileInfo>* out)>
40
+ get_file_info_vector;
41
+ std::function<void(PyObject*, const arrow::fs::FileSelector&,
42
+ std::vector<arrow::fs::FileInfo>* out)>
43
+ get_file_info_selector;
44
+
45
+ std::function<void(PyObject*, const std::string& path, bool)> create_dir;
46
+ std::function<void(PyObject*, const std::string& path)> delete_dir;
47
+ std::function<void(PyObject*, const std::string& path, bool)> delete_dir_contents;
48
+ std::function<void(PyObject*)> delete_root_dir_contents;
49
+ std::function<void(PyObject*, const std::string& path)> delete_file;
50
+ std::function<void(PyObject*, const std::string& src, const std::string& dest)> move;
51
+ std::function<void(PyObject*, const std::string& src, const std::string& dest)>
52
+ copy_file;
53
+
54
+ std::function<void(PyObject*, const std::string& path,
55
+ std::shared_ptr<io::InputStream>* out)>
56
+ open_input_stream;
57
+ std::function<void(PyObject*, const std::string& path,
58
+ std::shared_ptr<io::RandomAccessFile>* out)>
59
+ open_input_file;
60
+ std::function<void(PyObject*, const std::string& path,
61
+ const std::shared_ptr<const KeyValueMetadata>&,
62
+ std::shared_ptr<io::OutputStream>* out)>
63
+ open_output_stream;
64
+ std::function<void(PyObject*, const std::string& path,
65
+ const std::shared_ptr<const KeyValueMetadata>&,
66
+ std::shared_ptr<io::OutputStream>* out)>
67
+ open_append_stream;
68
+
69
+ std::function<void(PyObject*, const std::string& path, std::string* out)>
70
+ normalize_path;
71
+ };
72
+
73
+ class ARROW_PYTHON_EXPORT PyFileSystem : public arrow::fs::FileSystem {
74
+ public:
75
+ PyFileSystem(PyObject* handler, PyFileSystemVtable vtable);
76
+ ~PyFileSystem() override;
77
+
78
+ static std::shared_ptr<PyFileSystem> Make(PyObject* handler, PyFileSystemVtable vtable);
79
+
80
+ std::string type_name() const override;
81
+
82
+ bool Equals(const FileSystem& other) const override;
83
+
84
+ /// \cond FALSE
85
+ using FileSystem::CreateDir;
86
+ using FileSystem::DeleteDirContents;
87
+ using FileSystem::GetFileInfo;
88
+ using FileSystem::OpenAppendStream;
89
+ using FileSystem::OpenOutputStream;
90
+ /// \endcond
91
+
92
+ Result<arrow::fs::FileInfo> GetFileInfo(const std::string& path) override;
93
+ Result<std::vector<arrow::fs::FileInfo>> GetFileInfo(
94
+ const std::vector<std::string>& paths) override;
95
+ Result<std::vector<arrow::fs::FileInfo>> GetFileInfo(
96
+ const arrow::fs::FileSelector& select) override;
97
+
98
+ Status CreateDir(const std::string& path, bool recursive) override;
99
+
100
+ Status DeleteDir(const std::string& path) override;
101
+ Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
102
+ Status DeleteRootDirContents() override;
103
+
104
+ Status DeleteFile(const std::string& path) override;
105
+
106
+ Status Move(const std::string& src, const std::string& dest) override;
107
+
108
+ Status CopyFile(const std::string& src, const std::string& dest) override;
109
+
110
+ Result<std::shared_ptr<io::InputStream>> OpenInputStream(
111
+ const std::string& path) override;
112
+ Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
113
+ const std::string& path) override;
114
+ Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
115
+ const std::string& path,
116
+ const std::shared_ptr<const KeyValueMetadata>& metadata) override;
117
+ Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
118
+ const std::string& path,
119
+ const std::shared_ptr<const KeyValueMetadata>& metadata) override;
120
+
121
+ Result<std::string> NormalizePath(std::string path) override;
122
+
123
+ PyObject* handler() const { return handler_.obj(); }
124
+
125
+ private:
126
+ OwnedRefNoGIL handler_;
127
+ PyFileSystemVtable vtable_;
128
+ };
129
+
130
+ } // namespace arrow::py::fs