snowflake-connector-python 4.4.0__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/connector/__init__.py +118 -0
- snowflake/connector/_query_context_cache.py +276 -0
- snowflake/connector/_sql_util.py +48 -0
- snowflake/connector/_utils.py +353 -0
- snowflake/connector/aio/README.md +88 -0
- snowflake/connector/aio/__init__.py +163 -0
- snowflake/connector/aio/_azure_storage_client.py +227 -0
- snowflake/connector/aio/_bind_upload_agent.py +69 -0
- snowflake/connector/aio/_connection.py +1216 -0
- snowflake/connector/aio/_cursor.py +1402 -0
- snowflake/connector/aio/_description.py +5 -0
- snowflake/connector/aio/_direct_file_operation_utils.py +88 -0
- snowflake/connector/aio/_file_transfer_agent.py +316 -0
- snowflake/connector/aio/_gcs_storage_client.py +360 -0
- snowflake/connector/aio/_network.py +860 -0
- snowflake/connector/aio/_ocsp_asn1crypto.py +51 -0
- snowflake/connector/aio/_ocsp_snowflake.py +608 -0
- snowflake/connector/aio/_pandas_tools.py +561 -0
- snowflake/connector/aio/_result_batch.py +442 -0
- snowflake/connector/aio/_result_set.py +309 -0
- snowflake/connector/aio/_s3_storage_client.py +460 -0
- snowflake/connector/aio/_session_manager.py +588 -0
- snowflake/connector/aio/_storage_client.py +331 -0
- snowflake/connector/aio/_telemetry.py +97 -0
- snowflake/connector/aio/_time_util.py +57 -0
- snowflake/connector/aio/_wif_util.py +324 -0
- snowflake/connector/aio/auth/__init__.py +52 -0
- snowflake/connector/aio/auth/_auth.py +406 -0
- snowflake/connector/aio/auth/_by_plugin.py +131 -0
- snowflake/connector/aio/auth/_default.py +28 -0
- snowflake/connector/aio/auth/_idtoken.py +54 -0
- snowflake/connector/aio/auth/_keypair.py +60 -0
- snowflake/connector/aio/auth/_no_auth.py +31 -0
- snowflake/connector/aio/auth/_oauth.py +27 -0
- snowflake/connector/aio/auth/_oauth_code.py +117 -0
- snowflake/connector/aio/auth/_oauth_credentials.py +100 -0
- snowflake/connector/aio/auth/_okta.py +247 -0
- snowflake/connector/aio/auth/_pat.py +27 -0
- snowflake/connector/aio/auth/_usrpwdmfa.py +30 -0
- snowflake/connector/aio/auth/_webbrowser.py +405 -0
- snowflake/connector/aio/auth/_workload_identity.py +60 -0
- snowflake/connector/arrow_context.py +211 -0
- snowflake/connector/auth/__init__.py +53 -0
- snowflake/connector/auth/_auth.py +669 -0
- snowflake/connector/auth/_http_server.py +257 -0
- snowflake/connector/auth/_oauth_base.py +472 -0
- snowflake/connector/auth/by_plugin.py +219 -0
- snowflake/connector/auth/default.py +36 -0
- snowflake/connector/auth/idtoken.py +72 -0
- snowflake/connector/auth/keypair.py +225 -0
- snowflake/connector/auth/no_auth.py +39 -0
- snowflake/connector/auth/oauth.py +49 -0
- snowflake/connector/auth/oauth_code.py +490 -0
- snowflake/connector/auth/oauth_credentials.py +71 -0
- snowflake/connector/auth/okta.py +339 -0
- snowflake/connector/auth/pat.py +40 -0
- snowflake/connector/auth/usrpwdmfa.py +69 -0
- snowflake/connector/auth/webbrowser.py +514 -0
- snowflake/connector/auth/workload_identity.py +110 -0
- snowflake/connector/azure_storage_client.py +278 -0
- snowflake/connector/backoff_policies.py +141 -0
- snowflake/connector/bind_upload_agent.py +89 -0
- snowflake/connector/cache.py +696 -0
- snowflake/connector/compat.py +127 -0
- snowflake/connector/config_manager.py +553 -0
- snowflake/connector/connection.py +2671 -0
- snowflake/connector/connection_diagnostic.py +793 -0
- snowflake/connector/constants.py +460 -0
- snowflake/connector/converter.py +809 -0
- snowflake/connector/converter_issue23517.py +87 -0
- snowflake/connector/converter_null.py +14 -0
- snowflake/connector/converter_snowsql.py +205 -0
- snowflake/connector/crl.py +919 -0
- snowflake/connector/crl_cache.py +734 -0
- snowflake/connector/cursor.py +2099 -0
- snowflake/connector/dbapi.py +53 -0
- snowflake/connector/description.py +21 -0
- snowflake/connector/direct_file_operation_utils.py +88 -0
- snowflake/connector/encryption_util.py +220 -0
- snowflake/connector/errorcode.py +94 -0
- snowflake/connector/errors.py +666 -0
- snowflake/connector/externals_utils/__init__.py +0 -0
- snowflake/connector/externals_utils/externals_setup.py +30 -0
- snowflake/connector/feature.py +4 -0
- snowflake/connector/file_compression_type.py +118 -0
- snowflake/connector/file_lock.py +72 -0
- snowflake/connector/file_transfer_agent.py +1244 -0
- snowflake/connector/file_util.py +153 -0
- snowflake/connector/gcs_storage_client.py +476 -0
- snowflake/connector/gzip_decoder.py +85 -0
- snowflake/connector/interval_util.py +26 -0
- snowflake/connector/local_storage_client.py +90 -0
- snowflake/connector/log_configuration.py +62 -0
- snowflake/connector/logging_utils/__init__.py +0 -0
- snowflake/connector/logging_utils/filters.py +72 -0
- snowflake/connector/minicore/__init__.py +0 -0
- snowflake/connector/minicore/aix_ppc64/libsf_mini_core.a +0 -0
- snowflake/connector/minicore/aix_ppc64/libsf_mini_core_static.a +0 -0
- snowflake/connector/minicore/linux_aarch64_glibc/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/linux_aarch64_musl/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/linux_x86_64_glibc/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/linux_x86_64_musl/libsf_mini_core.so +0 -0
- snowflake/connector/minicore/macos_aarch64/libsf_mini_core.dylib +0 -0
- snowflake/connector/minicore/macos_x86_64/libsf_mini_core.dylib +0 -0
- snowflake/connector/minicore/windows_x86_64/sf_mini_core.dll +0 -0
- snowflake/connector/minicore/windows_x86_64/sf_mini_core_static.lib +0 -0
- snowflake/connector/nanoarrow_arrow_iterator.cp314-win_amd64.pyd +0 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.cpp +60 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ArrayConverter.hpp +29 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.cpp +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BinaryConverter.hpp +26 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.cpp +21 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/BooleanConverter.hpp +23 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.cpp +570 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowChunkIterator.hpp +98 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.cpp +125 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowIterator.hpp +115 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.cpp +1140 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/CArrowTableIterator.hpp +138 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.cpp +47 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DateConverter.hpp +46 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.cpp +83 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecFloatConverter.hpp +35 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.cpp +97 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/DecimalConverter.hpp +72 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.cpp +73 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FixedSizeListConverter.hpp +28 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.cpp +30 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/FloatConverter.hpp +35 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IColumnConverter.hpp +17 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.cpp +23 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntConverter.hpp +45 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.cpp +75 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/IntervalConverter.hpp +57 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/LICENSE.txt +209 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.cpp +75 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/MapConverter.hpp +30 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.cpp +46 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/ObjectConverter.hpp +29 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.cpp +8 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Common.hpp +95 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.cpp +57 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Python/Helpers.hpp +36 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.cpp +34 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/SnowflakeType.hpp +48 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.cpp +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/StringConverter.hpp +26 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.cpp +36 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeConverter.hpp +31 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.cpp +346 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/TimeStampConverter.hpp +145 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/macros.hpp +14 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.cpp +67 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/Util/time.hpp +68 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_accessors.h +101 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_alloc.h +127 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_assert.h +45 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_builder.h +1908 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_emitter.h +215 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_endian.h +125 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_epilogue.h +7 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_flatbuffers.h +55 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_identifier.h +148 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_iov.h +31 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_prologue.h +8 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_refmap.h +144 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_rtconfig.h +162 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_types.h +97 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/flatcc_verifier.h +239 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/flatcc_portable.h +14 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/paligned_alloc.h +210 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pattributes.h +84 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic.h +84 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_pop.h +20 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pdiagnostic_push.h +51 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian.h +206 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pendian_detect.h +118 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinline.h +19 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pinttypes.h +52 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable.h +2 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/portable_basic.h +25 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstatic_assert.h +67 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdalign.h +162 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pstdint.h +898 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/punaligned.h +190 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pversion.h +6 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/portable/pwarnings.h +52 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc.c +3204 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.c +3217 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.h +3618 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow.hpp +379 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.pyx +262 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.c +512 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_device.h +350 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c +33273 -0
- snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.h +397 -0
- snowflake/connector/nanoarrow_cpp/Logging/logging.cpp +100 -0
- snowflake/connector/nanoarrow_cpp/Logging/logging.hpp +49 -0
- snowflake/connector/network.py +1227 -0
- snowflake/connector/ocsp_asn1crypto.py +447 -0
- snowflake/connector/ocsp_snowflake.py +1939 -0
- snowflake/connector/options.py +179 -0
- snowflake/connector/os_details.py +88 -0
- snowflake/connector/pandas_tools.py +734 -0
- snowflake/connector/platform_detection.py +555 -0
- snowflake/connector/proxy.py +28 -0
- snowflake/connector/py.typed +0 -0
- snowflake/connector/result_batch.py +917 -0
- snowflake/connector/result_set.py +340 -0
- snowflake/connector/s3_storage_client.py +614 -0
- snowflake/connector/secret_detector.py +181 -0
- snowflake/connector/session_manager.py +650 -0
- snowflake/connector/sf_dirs.py +64 -0
- snowflake/connector/sfbinaryformat.py +35 -0
- snowflake/connector/sfdatetime.py +345 -0
- snowflake/connector/snow_logging.py +144 -0
- snowflake/connector/sqlstate.py +9 -0
- snowflake/connector/ssd_internal_keys.py +30 -0
- snowflake/connector/ssl_wrap_socket.py +281 -0
- snowflake/connector/storage_client.py +486 -0
- snowflake/connector/telemetry.py +254 -0
- snowflake/connector/telemetry_oob.py +544 -0
- snowflake/connector/test_util.py +30 -0
- snowflake/connector/time_util.py +159 -0
- snowflake/connector/token_cache.py +457 -0
- snowflake/connector/tool/__init__.py +0 -0
- snowflake/connector/tool/dump_certs.py +57 -0
- snowflake/connector/tool/dump_ocsp_response.py +139 -0
- snowflake/connector/tool/dump_ocsp_response_cache.py +194 -0
- snowflake/connector/tool/probe_connection.py +69 -0
- snowflake/connector/url_util.py +55 -0
- snowflake/connector/util_text.py +320 -0
- snowflake/connector/vendored/__init__.py +3 -0
- snowflake/connector/vendored/requests/LICENSE +175 -0
- snowflake/connector/vendored/requests/__init__.py +184 -0
- snowflake/connector/vendored/requests/__version__.py +14 -0
- snowflake/connector/vendored/requests/_internal_utils.py +50 -0
- snowflake/connector/vendored/requests/adapters.py +696 -0
- snowflake/connector/vendored/requests/api.py +157 -0
- snowflake/connector/vendored/requests/auth.py +314 -0
- snowflake/connector/vendored/requests/certs.py +17 -0
- snowflake/connector/vendored/requests/compat.py +106 -0
- snowflake/connector/vendored/requests/cookies.py +561 -0
- snowflake/connector/vendored/requests/exceptions.py +151 -0
- snowflake/connector/vendored/requests/help.py +134 -0
- snowflake/connector/vendored/requests/hooks.py +33 -0
- snowflake/connector/vendored/requests/models.py +1039 -0
- snowflake/connector/vendored/requests/packages.py +23 -0
- snowflake/connector/vendored/requests/sessions.py +831 -0
- snowflake/connector/vendored/requests/status_codes.py +128 -0
- snowflake/connector/vendored/requests/structures.py +99 -0
- snowflake/connector/vendored/requests/utils.py +1086 -0
- snowflake/connector/vendored/urllib3/LICENSE.txt +21 -0
- snowflake/connector/vendored/urllib3/__init__.py +211 -0
- snowflake/connector/vendored/urllib3/_base_connection.py +165 -0
- snowflake/connector/vendored/urllib3/_collections.py +487 -0
- snowflake/connector/vendored/urllib3/_request_methods.py +278 -0
- snowflake/connector/vendored/urllib3/_version.py +34 -0
- snowflake/connector/vendored/urllib3/connection.py +1108 -0
- snowflake/connector/vendored/urllib3/connectionpool.py +1178 -0
- snowflake/connector/vendored/urllib3/contrib/__init__.py +0 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/__init__.py +17 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/connection.py +260 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/emscripten_fetch_worker.js +110 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/fetch.py +726 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/request.py +22 -0
- snowflake/connector/vendored/urllib3/contrib/emscripten/response.py +277 -0
- snowflake/connector/vendored/urllib3/contrib/pyopenssl.py +564 -0
- snowflake/connector/vendored/urllib3/contrib/socks.py +228 -0
- snowflake/connector/vendored/urllib3/exceptions.py +335 -0
- snowflake/connector/vendored/urllib3/fields.py +341 -0
- snowflake/connector/vendored/urllib3/filepost.py +89 -0
- snowflake/connector/vendored/urllib3/http2/__init__.py +53 -0
- snowflake/connector/vendored/urllib3/http2/connection.py +356 -0
- snowflake/connector/vendored/urllib3/http2/probe.py +87 -0
- snowflake/connector/vendored/urllib3/poolmanager.py +651 -0
- snowflake/connector/vendored/urllib3/py.typed +2 -0
- snowflake/connector/vendored/urllib3/response.py +1480 -0
- snowflake/connector/vendored/urllib3/util/__init__.py +42 -0
- snowflake/connector/vendored/urllib3/util/connection.py +137 -0
- snowflake/connector/vendored/urllib3/util/proxy.py +43 -0
- snowflake/connector/vendored/urllib3/util/request.py +263 -0
- snowflake/connector/vendored/urllib3/util/response.py +101 -0
- snowflake/connector/vendored/urllib3/util/retry.py +549 -0
- snowflake/connector/vendored/urllib3/util/ssl_.py +527 -0
- snowflake/connector/vendored/urllib3/util/ssl_match_hostname.py +159 -0
- snowflake/connector/vendored/urllib3/util/ssltransport.py +271 -0
- snowflake/connector/vendored/urllib3/util/timeout.py +275 -0
- snowflake/connector/vendored/urllib3/util/url.py +469 -0
- snowflake/connector/vendored/urllib3/util/util.py +42 -0
- snowflake/connector/vendored/urllib3/util/wait.py +124 -0
- snowflake/connector/version.py +3 -0
- snowflake/connector/wif_util.py +434 -0
- snowflake_connector_python-4.4.0.dist-info/DELVEWHEEL +2 -0
- snowflake_connector_python-4.4.0.dist-info/METADATA +1591 -0
- snowflake_connector_python-4.4.0.dist-info/RECORD +302 -0
- snowflake_connector_python-4.4.0.dist-info/WHEEL +5 -0
- snowflake_connector_python-4.4.0.dist-info/entry_points.txt +4 -0
- snowflake_connector_python-4.4.0.dist-info/licenses/LICENSE.txt +202 -0
- snowflake_connector_python-4.4.0.dist-info/licenses/NOTICE +8 -0
- snowflake_connector_python-4.4.0.dist-info/top_level.txt +1 -0
- snowflake_connector_python.libs/msvcp140-0f885b509a685d2bbfa652fed26b5fb3.dll +0 -0
|
@@ -0,0 +1,512 @@
|
|
|
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 "nanoarrow_device.h"
|
|
19
|
+
|
|
20
|
+
#include <errno.h>
|
|
21
|
+
|
|
22
|
+
#include "nanoarrow.h"
|
|
23
|
+
|
|
24
|
+
ArrowErrorCode ArrowDeviceCheckRuntime(struct ArrowError* error) {
|
|
25
|
+
const char* nanoarrow_runtime_version = ArrowNanoarrowVersion();
|
|
26
|
+
const char* nanoarrow_ipc_build_time_version = NANOARROW_VERSION;
|
|
27
|
+
|
|
28
|
+
if (strcmp(nanoarrow_runtime_version, nanoarrow_ipc_build_time_version) !=
|
|
29
|
+
0) {
|
|
30
|
+
ArrowErrorSet(
|
|
31
|
+
error, "Expected nanoarrow runtime version '%s' but found version '%s'",
|
|
32
|
+
nanoarrow_ipc_build_time_version, nanoarrow_runtime_version);
|
|
33
|
+
return EINVAL;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return NANOARROW_OK;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static void ArrowDeviceArrayInitDefault(struct ArrowDevice* device,
|
|
40
|
+
struct ArrowDeviceArray* device_array,
|
|
41
|
+
struct ArrowArray* array) {
|
|
42
|
+
memset(device_array, 0, sizeof(struct ArrowDeviceArray));
|
|
43
|
+
device_array->device_type = device->device_type;
|
|
44
|
+
device_array->device_id = device->device_id;
|
|
45
|
+
ArrowArrayMove(array, &device_array->array);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static ArrowErrorCode ArrowDeviceCpuBufferInit(struct ArrowDevice* device_src,
|
|
49
|
+
struct ArrowBufferView src,
|
|
50
|
+
struct ArrowDevice* device_dst,
|
|
51
|
+
struct ArrowBuffer* dst) {
|
|
52
|
+
if (device_dst->device_type != ARROW_DEVICE_CPU ||
|
|
53
|
+
device_src->device_type != ARROW_DEVICE_CPU) {
|
|
54
|
+
return ENOTSUP;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ArrowBufferInit(dst);
|
|
58
|
+
dst->allocator = ArrowBufferAllocatorDefault();
|
|
59
|
+
NANOARROW_RETURN_NOT_OK(
|
|
60
|
+
ArrowBufferAppend(dst, src.data.as_uint8, src.size_bytes));
|
|
61
|
+
return NANOARROW_OK;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static ArrowErrorCode ArrowDeviceCpuBufferMove(struct ArrowDevice* device_src,
|
|
65
|
+
struct ArrowBuffer* src,
|
|
66
|
+
struct ArrowDevice* device_dst,
|
|
67
|
+
struct ArrowBuffer* dst) {
|
|
68
|
+
if (device_dst->device_type != ARROW_DEVICE_CPU ||
|
|
69
|
+
device_src->device_type != ARROW_DEVICE_CPU) {
|
|
70
|
+
return ENOTSUP;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ArrowBufferMove(src, dst);
|
|
74
|
+
return NANOARROW_OK;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static ArrowErrorCode ArrowDeviceCpuBufferCopy(struct ArrowDevice* device_src,
|
|
78
|
+
struct ArrowBufferView src,
|
|
79
|
+
struct ArrowDevice* device_dst,
|
|
80
|
+
struct ArrowBufferView dst) {
|
|
81
|
+
if (device_dst->device_type != ARROW_DEVICE_CPU ||
|
|
82
|
+
device_src->device_type != ARROW_DEVICE_CPU) {
|
|
83
|
+
return ENOTSUP;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
memcpy((uint8_t*)dst.data.as_uint8, src.data.as_uint8, dst.size_bytes);
|
|
87
|
+
return NANOARROW_OK;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static ArrowErrorCode ArrowDeviceCpuSynchronize(struct ArrowDevice* device,
|
|
91
|
+
void* sync_event,
|
|
92
|
+
struct ArrowError* error) {
|
|
93
|
+
switch (device->device_type) {
|
|
94
|
+
case ARROW_DEVICE_CPU:
|
|
95
|
+
if (sync_event != NULL) {
|
|
96
|
+
ArrowErrorSet(
|
|
97
|
+
error, "Expected NULL sync_event for ARROW_DEVICE_CPU but got %p",
|
|
98
|
+
sync_event);
|
|
99
|
+
return EINVAL;
|
|
100
|
+
} else {
|
|
101
|
+
return NANOARROW_OK;
|
|
102
|
+
}
|
|
103
|
+
default:
|
|
104
|
+
return device->synchronize_event(device, sync_event, error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static void ArrowDeviceCpuRelease(struct ArrowDevice* device) {
|
|
109
|
+
device->release = NULL;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
struct ArrowDevice* ArrowDeviceCpu(void) {
|
|
113
|
+
static struct ArrowDevice* cpu_device_singleton = NULL;
|
|
114
|
+
if (cpu_device_singleton == NULL) {
|
|
115
|
+
cpu_device_singleton =
|
|
116
|
+
(struct ArrowDevice*)ArrowMalloc(sizeof(struct ArrowDevice));
|
|
117
|
+
ArrowDeviceInitCpu(cpu_device_singleton);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return cpu_device_singleton;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void ArrowDeviceInitCpu(struct ArrowDevice* device) {
|
|
124
|
+
device->device_type = ARROW_DEVICE_CPU;
|
|
125
|
+
device->device_id = 0;
|
|
126
|
+
device->array_init = NULL;
|
|
127
|
+
device->array_move = NULL;
|
|
128
|
+
device->buffer_init = &ArrowDeviceCpuBufferInit;
|
|
129
|
+
device->buffer_move = &ArrowDeviceCpuBufferMove;
|
|
130
|
+
device->buffer_copy = &ArrowDeviceCpuBufferCopy;
|
|
131
|
+
device->synchronize_event = &ArrowDeviceCpuSynchronize;
|
|
132
|
+
device->release = &ArrowDeviceCpuRelease;
|
|
133
|
+
device->private_data = NULL;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
#ifdef NANOARROW_DEVICE_WITH_METAL
|
|
137
|
+
struct ArrowDevice* ArrowDeviceMetalDefaultDevice(void);
|
|
138
|
+
#endif
|
|
139
|
+
|
|
140
|
+
#ifdef NANOARROW_DEVICE_WITH_CUDA
|
|
141
|
+
struct ArrowDevice* ArrowDeviceCuda(ArrowDeviceType device_type,
|
|
142
|
+
int64_t device_id);
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
struct ArrowDevice* ArrowDeviceResolve(ArrowDeviceType device_type,
|
|
146
|
+
int64_t device_id) {
|
|
147
|
+
if (device_type == ARROW_DEVICE_CPU && device_id == 0) {
|
|
148
|
+
return ArrowDeviceCpu();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#ifdef NANOARROW_DEVICE_WITH_METAL
|
|
152
|
+
if (device_type == ARROW_DEVICE_METAL) {
|
|
153
|
+
struct ArrowDevice* default_device = ArrowDeviceMetalDefaultDevice();
|
|
154
|
+
if (device_id == default_device->device_id) {
|
|
155
|
+
return default_device;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
#ifdef NANOARROW_DEVICE_WITH_CUDA
|
|
161
|
+
if (device_type == ARROW_DEVICE_CUDA ||
|
|
162
|
+
device_type == ARROW_DEVICE_CUDA_HOST) {
|
|
163
|
+
return ArrowDeviceCuda(device_type, device_id);
|
|
164
|
+
}
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
return NULL;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
ArrowErrorCode ArrowDeviceArrayInit(struct ArrowDevice* device,
|
|
171
|
+
struct ArrowDeviceArray* device_array,
|
|
172
|
+
struct ArrowArray* array) {
|
|
173
|
+
if (device->array_init != NULL) {
|
|
174
|
+
return device->array_init(device, device_array, array);
|
|
175
|
+
} else {
|
|
176
|
+
ArrowDeviceArrayInitDefault(device, device_array, array);
|
|
177
|
+
return NANOARROW_OK;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
ArrowErrorCode ArrowDeviceBufferInit(struct ArrowDevice* device_src,
|
|
182
|
+
struct ArrowBufferView src,
|
|
183
|
+
struct ArrowDevice* device_dst,
|
|
184
|
+
struct ArrowBuffer* dst) {
|
|
185
|
+
int result = device_dst->buffer_init(device_src, src, device_dst, dst);
|
|
186
|
+
if (result == ENOTSUP) {
|
|
187
|
+
result = device_src->buffer_init(device_src, src, device_dst, dst);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
ArrowErrorCode ArrowDeviceBufferMove(struct ArrowDevice* device_src,
|
|
194
|
+
struct ArrowBuffer* src,
|
|
195
|
+
struct ArrowDevice* device_dst,
|
|
196
|
+
struct ArrowBuffer* dst) {
|
|
197
|
+
int result = device_dst->buffer_move(device_src, src, device_dst, dst);
|
|
198
|
+
if (result == ENOTSUP) {
|
|
199
|
+
result = device_src->buffer_move(device_src, src, device_dst, dst);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
ArrowErrorCode ArrowDeviceBufferCopy(struct ArrowDevice* device_src,
|
|
206
|
+
struct ArrowBufferView src,
|
|
207
|
+
struct ArrowDevice* device_dst,
|
|
208
|
+
struct ArrowBufferView dst) {
|
|
209
|
+
int result = device_dst->buffer_copy(device_src, src, device_dst, dst);
|
|
210
|
+
if (result == ENOTSUP) {
|
|
211
|
+
result = device_src->buffer_copy(device_src, src, device_dst, dst);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
struct ArrowBasicDeviceArrayStreamPrivate {
|
|
218
|
+
struct ArrowDevice* device;
|
|
219
|
+
struct ArrowArrayStream naive_stream;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
static int ArrowDeviceBasicArrayStreamGetSchema(
|
|
223
|
+
struct ArrowDeviceArrayStream* array_stream, struct ArrowSchema* schema) {
|
|
224
|
+
struct ArrowBasicDeviceArrayStreamPrivate* private_data =
|
|
225
|
+
(struct ArrowBasicDeviceArrayStreamPrivate*)array_stream->private_data;
|
|
226
|
+
return private_data->naive_stream.get_schema(&private_data->naive_stream,
|
|
227
|
+
schema);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
static int ArrowDeviceBasicArrayStreamGetNext(
|
|
231
|
+
struct ArrowDeviceArrayStream* array_stream,
|
|
232
|
+
struct ArrowDeviceArray* device_array) {
|
|
233
|
+
struct ArrowBasicDeviceArrayStreamPrivate* private_data =
|
|
234
|
+
(struct ArrowBasicDeviceArrayStreamPrivate*)array_stream->private_data;
|
|
235
|
+
|
|
236
|
+
struct ArrowArray tmp;
|
|
237
|
+
NANOARROW_RETURN_NOT_OK(
|
|
238
|
+
private_data->naive_stream.get_next(&private_data->naive_stream, &tmp));
|
|
239
|
+
int result = ArrowDeviceArrayInit(private_data->device, device_array, &tmp);
|
|
240
|
+
if (result != NANOARROW_OK) {
|
|
241
|
+
tmp.release(&tmp);
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return NANOARROW_OK;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static const char* ArrowDeviceBasicArrayStreamGetLastError(
|
|
249
|
+
struct ArrowDeviceArrayStream* array_stream) {
|
|
250
|
+
struct ArrowBasicDeviceArrayStreamPrivate* private_data =
|
|
251
|
+
(struct ArrowBasicDeviceArrayStreamPrivate*)array_stream->private_data;
|
|
252
|
+
return private_data->naive_stream.get_last_error(&private_data->naive_stream);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
static void ArrowDeviceBasicArrayStreamRelease(
|
|
256
|
+
struct ArrowDeviceArrayStream* array_stream) {
|
|
257
|
+
struct ArrowBasicDeviceArrayStreamPrivate* private_data =
|
|
258
|
+
(struct ArrowBasicDeviceArrayStreamPrivate*)array_stream->private_data;
|
|
259
|
+
private_data->naive_stream.release(&private_data->naive_stream);
|
|
260
|
+
ArrowFree(private_data);
|
|
261
|
+
array_stream->release = NULL;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
ArrowErrorCode ArrowDeviceBasicArrayStreamInit(
|
|
265
|
+
struct ArrowDeviceArrayStream* device_array_stream,
|
|
266
|
+
struct ArrowArrayStream* array_stream, struct ArrowDevice* device) {
|
|
267
|
+
struct ArrowBasicDeviceArrayStreamPrivate* private_data =
|
|
268
|
+
(struct ArrowBasicDeviceArrayStreamPrivate*)ArrowMalloc(
|
|
269
|
+
sizeof(struct ArrowBasicDeviceArrayStreamPrivate));
|
|
270
|
+
if (private_data == NULL) {
|
|
271
|
+
return ENOMEM;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private_data->device = device;
|
|
275
|
+
ArrowArrayStreamMove(array_stream, &private_data->naive_stream);
|
|
276
|
+
|
|
277
|
+
device_array_stream->device_type = device->device_type;
|
|
278
|
+
device_array_stream->get_schema = &ArrowDeviceBasicArrayStreamGetSchema;
|
|
279
|
+
device_array_stream->get_next = &ArrowDeviceBasicArrayStreamGetNext;
|
|
280
|
+
device_array_stream->get_last_error =
|
|
281
|
+
&ArrowDeviceBasicArrayStreamGetLastError;
|
|
282
|
+
device_array_stream->release = &ArrowDeviceBasicArrayStreamRelease;
|
|
283
|
+
device_array_stream->private_data = private_data;
|
|
284
|
+
return NANOARROW_OK;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
void ArrowDeviceArrayViewInit(struct ArrowDeviceArrayView* device_array_view) {
|
|
288
|
+
memset(device_array_view, 0, sizeof(struct ArrowDeviceArrayView));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
void ArrowDeviceArrayViewReset(struct ArrowDeviceArrayView* device_array_view) {
|
|
292
|
+
ArrowArrayViewReset(&device_array_view->array_view);
|
|
293
|
+
device_array_view->device = NULL;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
static ArrowErrorCode ArrowDeviceBufferGetInt32(
|
|
297
|
+
struct ArrowDevice* device, struct ArrowBufferView buffer_view, int64_t i,
|
|
298
|
+
int32_t* out) {
|
|
299
|
+
struct ArrowBufferView out_view;
|
|
300
|
+
out_view.data.as_int32 = out;
|
|
301
|
+
out_view.size_bytes = sizeof(int32_t);
|
|
302
|
+
|
|
303
|
+
struct ArrowBufferView device_buffer_view;
|
|
304
|
+
device_buffer_view.data.as_int32 = buffer_view.data.as_int32 + i;
|
|
305
|
+
device_buffer_view.size_bytes = sizeof(int32_t);
|
|
306
|
+
NANOARROW_RETURN_NOT_OK(ArrowDeviceBufferCopy(device, device_buffer_view,
|
|
307
|
+
ArrowDeviceCpu(), out_view));
|
|
308
|
+
return NANOARROW_OK;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
static ArrowErrorCode ArrowDeviceBufferGetInt64(
|
|
312
|
+
struct ArrowDevice* device, struct ArrowBufferView buffer_view, int64_t i,
|
|
313
|
+
int64_t* out) {
|
|
314
|
+
struct ArrowBufferView out_view;
|
|
315
|
+
out_view.data.as_int64 = out;
|
|
316
|
+
out_view.size_bytes = sizeof(int64_t);
|
|
317
|
+
|
|
318
|
+
struct ArrowBufferView device_buffer_view;
|
|
319
|
+
device_buffer_view.data.as_int64 = buffer_view.data.as_int64 + i;
|
|
320
|
+
device_buffer_view.size_bytes = sizeof(int64_t);
|
|
321
|
+
NANOARROW_RETURN_NOT_OK(ArrowDeviceBufferCopy(device, device_buffer_view,
|
|
322
|
+
ArrowDeviceCpu(), out_view));
|
|
323
|
+
return NANOARROW_OK;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
static ArrowErrorCode ArrowDeviceArrayViewResolveBufferSizes(
|
|
327
|
+
struct ArrowDevice* device, struct ArrowArrayView* array_view) {
|
|
328
|
+
// Calculate buffer sizes that require accessing the offset buffer
|
|
329
|
+
// (at this point all other sizes have been resolved).
|
|
330
|
+
int64_t offset_plus_length = array_view->offset + array_view->length;
|
|
331
|
+
int32_t last_offset32;
|
|
332
|
+
int64_t last_offset64;
|
|
333
|
+
|
|
334
|
+
switch (array_view->storage_type) {
|
|
335
|
+
case NANOARROW_TYPE_STRING:
|
|
336
|
+
case NANOARROW_TYPE_BINARY:
|
|
337
|
+
if (array_view->buffer_views[1].size_bytes == 0) {
|
|
338
|
+
array_view->buffer_views[2].size_bytes = 0;
|
|
339
|
+
} else if (array_view->buffer_views[2].size_bytes == -1) {
|
|
340
|
+
NANOARROW_RETURN_NOT_OK(
|
|
341
|
+
ArrowDeviceBufferGetInt32(device, array_view->buffer_views[1],
|
|
342
|
+
offset_plus_length, &last_offset32));
|
|
343
|
+
array_view->buffer_views[2].size_bytes = last_offset32;
|
|
344
|
+
}
|
|
345
|
+
break;
|
|
346
|
+
|
|
347
|
+
case NANOARROW_TYPE_LARGE_STRING:
|
|
348
|
+
case NANOARROW_TYPE_LARGE_BINARY:
|
|
349
|
+
if (array_view->buffer_views[1].size_bytes == 0) {
|
|
350
|
+
array_view->buffer_views[2].size_bytes = 0;
|
|
351
|
+
} else if (array_view->buffer_views[2].size_bytes == -1) {
|
|
352
|
+
NANOARROW_RETURN_NOT_OK(
|
|
353
|
+
ArrowDeviceBufferGetInt64(device, array_view->buffer_views[1],
|
|
354
|
+
offset_plus_length, &last_offset64));
|
|
355
|
+
array_view->buffer_views[2].size_bytes = last_offset64;
|
|
356
|
+
}
|
|
357
|
+
break;
|
|
358
|
+
default:
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Recurse for children
|
|
363
|
+
for (int64_t i = 0; i < array_view->n_children; i++) {
|
|
364
|
+
NANOARROW_RETURN_NOT_OK(ArrowDeviceArrayViewResolveBufferSizes(
|
|
365
|
+
device, array_view->children[i]));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return NANOARROW_OK;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
ArrowErrorCode ArrowDeviceArrayViewSetArrayMinimal(
|
|
372
|
+
struct ArrowDeviceArrayView* device_array_view,
|
|
373
|
+
struct ArrowDeviceArray* device_array, struct ArrowError* error) {
|
|
374
|
+
// Resolve device
|
|
375
|
+
struct ArrowDevice* device =
|
|
376
|
+
ArrowDeviceResolve(device_array->device_type, device_array->device_id);
|
|
377
|
+
if (device == NULL) {
|
|
378
|
+
ArrowErrorSet(error, "Can't resolve device with type %d and identifier %ld",
|
|
379
|
+
(int)device_array->device_type,
|
|
380
|
+
(long)device_array->device_id);
|
|
381
|
+
return EINVAL;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Set the device array device
|
|
385
|
+
device_array_view->device = device;
|
|
386
|
+
|
|
387
|
+
// Populate the array_view
|
|
388
|
+
NANOARROW_RETURN_NOT_OK(ArrowArrayViewSetArrayMinimal(
|
|
389
|
+
&device_array_view->array_view, &device_array->array, error));
|
|
390
|
+
|
|
391
|
+
return NANOARROW_OK;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
ArrowErrorCode ArrowDeviceArrayViewSetArray(
|
|
395
|
+
struct ArrowDeviceArrayView* device_array_view,
|
|
396
|
+
struct ArrowDeviceArray* device_array, struct ArrowError* error) {
|
|
397
|
+
NANOARROW_RETURN_NOT_OK(ArrowDeviceArrayViewSetArrayMinimal(
|
|
398
|
+
device_array_view, device_array, error));
|
|
399
|
+
|
|
400
|
+
// Wait on device_array to synchronize with the CPU
|
|
401
|
+
// TODO: This is not actually sufficient for CUDA, where the synchronization
|
|
402
|
+
// should happen after the cudaMemcpy, not before it. The ordering of
|
|
403
|
+
// these operations should be explicit and asynchronous (and is probably
|
|
404
|
+
// outside the scope of what can be done with a generic callback).
|
|
405
|
+
NANOARROW_RETURN_NOT_OK(device_array_view->device->synchronize_event(
|
|
406
|
+
device_array_view->device, device_array->sync_event, error));
|
|
407
|
+
|
|
408
|
+
// Resolve unknown buffer sizes (i.e., string, binary, large string, large
|
|
409
|
+
// binary)
|
|
410
|
+
NANOARROW_RETURN_NOT_OK_WITH_ERROR(
|
|
411
|
+
ArrowDeviceArrayViewResolveBufferSizes(device_array_view->device,
|
|
412
|
+
&device_array_view->array_view),
|
|
413
|
+
error);
|
|
414
|
+
|
|
415
|
+
return NANOARROW_OK;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
static ArrowErrorCode ArrowDeviceArrayViewCopyInternal(
|
|
419
|
+
struct ArrowDevice* device_src, struct ArrowArrayView* src,
|
|
420
|
+
struct ArrowDevice* device_dst, struct ArrowArray* dst) {
|
|
421
|
+
// Currently no attempt to minimize the amount of memory copied (i.e.,
|
|
422
|
+
// by applying offset + length and copying potentially fewer bytes)
|
|
423
|
+
dst->length = src->length;
|
|
424
|
+
dst->offset = src->offset;
|
|
425
|
+
dst->null_count = src->null_count;
|
|
426
|
+
|
|
427
|
+
for (int i = 0; i < 3; i++) {
|
|
428
|
+
if (src->layout.buffer_type[i] == NANOARROW_BUFFER_TYPE_NONE) {
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
NANOARROW_RETURN_NOT_OK(
|
|
433
|
+
ArrowDeviceBufferInit(device_src, src->buffer_views[i], device_dst,
|
|
434
|
+
ArrowArrayBuffer(dst, i)));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
for (int64_t i = 0; i < src->n_children; i++) {
|
|
438
|
+
NANOARROW_RETURN_NOT_OK(ArrowDeviceArrayViewCopyInternal(
|
|
439
|
+
device_src, src->children[i], device_dst, dst->children[i]));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (src->dictionary != NULL) {
|
|
443
|
+
NANOARROW_RETURN_NOT_OK(ArrowDeviceArrayViewCopyInternal(
|
|
444
|
+
device_src, src->dictionary, device_dst, dst->dictionary));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return NANOARROW_OK;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
ArrowErrorCode ArrowDeviceArrayViewCopy(struct ArrowDeviceArrayView* src,
|
|
451
|
+
struct ArrowDevice* device_dst,
|
|
452
|
+
struct ArrowDeviceArray* dst) {
|
|
453
|
+
struct ArrowArray tmp;
|
|
454
|
+
NANOARROW_RETURN_NOT_OK(
|
|
455
|
+
ArrowArrayInitFromArrayView(&tmp, &src->array_view, NULL));
|
|
456
|
+
|
|
457
|
+
int result = ArrowDeviceArrayViewCopyInternal(src->device, &src->array_view,
|
|
458
|
+
device_dst, &tmp);
|
|
459
|
+
if (result != NANOARROW_OK) {
|
|
460
|
+
tmp.release(&tmp);
|
|
461
|
+
return result;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
result =
|
|
465
|
+
ArrowArrayFinishBuilding(&tmp, NANOARROW_VALIDATION_LEVEL_MINIMAL, NULL);
|
|
466
|
+
if (result != NANOARROW_OK) {
|
|
467
|
+
tmp.release(&tmp);
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
result = ArrowDeviceArrayInit(device_dst, dst, &tmp);
|
|
472
|
+
if (result != NANOARROW_OK) {
|
|
473
|
+
tmp.release(&tmp);
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return result;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
ArrowErrorCode ArrowDeviceArrayMoveToDevice(struct ArrowDeviceArray* src,
|
|
481
|
+
struct ArrowDevice* device_dst,
|
|
482
|
+
struct ArrowDeviceArray* dst) {
|
|
483
|
+
// Can always move from the same device to the same device
|
|
484
|
+
if (src->device_type == device_dst->device_type &&
|
|
485
|
+
src->device_id == device_dst->device_id) {
|
|
486
|
+
ArrowDeviceArrayMove(src, dst);
|
|
487
|
+
return NANOARROW_OK;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
struct ArrowDevice* device_src =
|
|
491
|
+
ArrowDeviceResolve(src->device_type, src->device_id);
|
|
492
|
+
if (device_src == NULL) {
|
|
493
|
+
return EINVAL;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// See if the source knows how to move
|
|
497
|
+
int result;
|
|
498
|
+
if (device_src->array_move != NULL) {
|
|
499
|
+
result = device_src->array_move(device_src, src, device_dst, dst);
|
|
500
|
+
if (result != ENOTSUP) {
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// See if the destination knows how to move
|
|
506
|
+
if (device_dst->array_move != NULL) {
|
|
507
|
+
NANOARROW_RETURN_NOT_OK(
|
|
508
|
+
device_dst->array_move(device_src, src, device_dst, dst));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return ENOTSUP;
|
|
512
|
+
}
|