From 2a7498a376fc05598c5476d9e05f1c0d3a67779c Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Tue, 11 May 2021 12:52:44 -0400 Subject: [PATCH 01/18] Fix black, flake8 checks, attempt to fix isort --- .pre-commit-config.yaml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f82fa9ef361..765df0305f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,10 +3,30 @@ repos: rev: 5.0.7 hooks: - id: isort + alias: isort-cudf + name: isort-cudf + args: ["--settings-path=python/cudf/setup.cfg"] + files: python/cudf/.* + - id: isort + alias: isort-cudf-kafka + name: isort-cudf-kafka + args: ["--settings-path=python/cudf_kafka/setup.cfg"] + files: python/cudf_kafka/.* + - id: isort + alias: isort-custreamz + name: isort-custreamz + args: ["--settings-path=python/custreamz/setup.cfg"] + files: python/custreamz/.* + - id: isort + alias: isort-dask-cudf + name: isort-dask-cudf + args: ["--settings-path=python/dask_cudf/setup.cfg"] + files: python/dask_cudf/.* - repo: https://github.com/ambv/black rev: 19.10b0 hooks: - id: black + files: python/.* - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.3 hooks: @@ -14,10 +34,7 @@ repos: alias: flake8 name: flake8 args: ["--config=python/.flake8"] - types: [python] - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 - hooks: + files: python/.*\.py$ - id: flake8 alias: flake8-cython name: flake8-cython From 1b1a7e3fba923d61402ddaf18414198f76d2f596 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Tue, 11 May 2021 12:52:58 -0400 Subject: [PATCH 02/18] Fix clang-format checks --- cpp/scripts/run-clang-format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/scripts/run-clang-format.py b/cpp/scripts/run-clang-format.py index 2a7b66d4f77..cb77611fa3c 100755 --- a/cpp/scripts/run-clang-format.py +++ b/cpp/scripts/run-clang-format.py @@ -29,10 +29,10 @@ DEFAULT_DIRS = [ "cpp/benchmarks", "cpp/include", - "cpp/include/cudf", - "cpp/include/nvtext", + "cpp/libcudf_kafka", "cpp/src", "cpp/tests", + "java/src/main/native", ] From 8eab7ab6dd06ffb8ca08f213a01bf7912064a20f Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Tue, 11 May 2021 14:11:10 -0400 Subject: [PATCH 03/18] Add new isort checks to gpuCI script --- ci/checks/style.sh | 62 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/ci/checks/style.sh b/ci/checks/style.sh index 981e886d31c..a6b5ebb22b9 100755 --- a/ci/checks/style.sh +++ b/ci/checks/style.sh @@ -13,28 +13,40 @@ LANG=C.UTF-8 # Activate common conda env source activate gdf -# Run isort and get results/return code -ISORT=`isort --check-only python/**/*.py` -ISORT_RETVAL=$? +# Run isort-cudf and get results/return code +ISORT_CUDF=`isort python/cudf --check-only --settings-path=python/cudf/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_CUDF_RETVAL=$? + +# Run isort-cudf-kafka and get results/return code +ISORT_CUDF_KAFKA=`isort python/cudf_kafka --check-only --settings-path=python/cudf_kafka/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_CUDF_KAFKA_RETVAL=$? + +# Run isort-custreamz and get results/return code +ISORT_CUSTREAMZ=`isort python/custreamz --check-only --settings-path=python/custreamz/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_CUSTREAMZ_RETVAL=$? + +# Run isort-dask-cudf and get results/return code +ISORT_DASK_CUDF=`isort python/dask_cudf --check-only --settings-path=python/dask_cudf/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_DASK_CUDF_RETVAL=$? # Run black and get results/return code -BLACK=`black --check python` +BLACK=`black --check python 2>&1` BLACK_RETVAL=$? # Run flake8 and get results/return code -FLAKE=`flake8 --config=python/.flake8 python` +FLAKE=`flake8 --config=python/.flake8 python 2>&1` FLAKE_RETVAL=$? # Run flake8-cython and get results/return code -FLAKE_CYTHON=`flake8 --config=python/.flake8.cython` +FLAKE_CYTHON=`flake8 --config=python/.flake8.cython 2>&1` FLAKE_CYTHON_RETVAL=$? # Run mypy and get results/return code -MYPY_CUDF=`mypy --config=python/cudf/setup.cfg python/cudf/cudf` +MYPY_CUDF=`mypy --config=python/cudf/setup.cfg python/cudf/cudf 2>&1` MYPY_CUDF_RETVAL=$? # Run pydocstyle and get results/return code -PYDOCSTYLE=`pydocstyle --config=python/.flake8 python` +PYDOCSTYLE=`pydocstyle --config=python/.flake8 python 2>&1` PYDOCSTYLE_RETVAL=$? # Run clang-format and check for a consistent code format @@ -42,12 +54,36 @@ CLANG_FORMAT=`python cpp/scripts/run-clang-format.py 2>&1` CLANG_FORMAT_RETVAL=$? # Output results if failure otherwise show pass -if [ "$ISORT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: isort style check; begin output\n\n" - echo -e "$ISORT" - echo -e "\n\n>>>> FAILED: isort style check; end output\n\n" +if [ "$ISORT_CUDF_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: isort-cudf style check; begin output\n\n" + echo -e "$ISORT_CUDF" + echo -e "\n\n>>>> FAILED: isort-cudf style check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: isort-cudf style check\n\n" +fi + +if [ "$ISORT_CUDF_KAFKA_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: isort-cudf-kafka style check; begin output\n\n" + echo -e "$ISORT_CUDF_KAFKA" + echo -e "\n\n>>>> FAILED: isort-cudf-kafka style check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: isort-cudf-kafka style check\n\n" +fi + +if [ "$ISORT_CUSTREAMZ_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: isort-custreamz style check; begin output\n\n" + echo -e "$ISORT_CUSTREAMZ" + echo -e "\n\n>>>> FAILED: isort-custreamz style check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: isort-custreamz style check\n\n" +fi + +if [ "$ISORT_DASK_CUDF_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: isort-dask-cudf style check; begin output\n\n" + echo -e "$ISORT_DASK_CUDF" + echo -e "\n\n>>>> FAILED: isort-dask-cudf style check; end output\n\n" else - echo -e "\n\n>>>> PASSED: isort style check\n\n" + echo -e "\n\n>>>> PASSED: isort-dask-cudf style check\n\n" fi if [ "$BLACK_RETVAL" != "0" ]; then From 42ecf31fae8c2bf1f3470756d181bf53cbc69d1e Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Thu, 13 May 2021 13:31:33 -0400 Subject: [PATCH 04/18] Add new isort return values to array --- ci/checks/style.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/checks/style.sh b/ci/checks/style.sh index a6b5ebb22b9..76a0303b711 100755 --- a/ci/checks/style.sh +++ b/ci/checks/style.sh @@ -139,7 +139,11 @@ HEADER_META=`ci/checks/headers_test.sh` HEADER_META_RETVAL=$? echo -e "$HEADER_META" -RETVALS=($ISORT_RETVAL $BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $PYDOCSTYLE_RETVAL $CLANG_FORMAT_RETVAL $HEADER_META_RETVAL $MYPY_CUDF_RETVAL) +RETVALS=( + $ISORT_CUDF_RETVAL $ISORT_CUDF_KAFKA_RETVAL $ISORT_CUSTREAMZ_RETVAL $ISORT_DASK_CUDF_RETVAL + $BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $PYDOCSTYLE_RETVAL $CLANG_FORMAT_RETVAL + $HEADER_META_RETVAL $MYPY_CUDF_RETVAL +) IFS=$'\n' RETVAL=`echo "${RETVALS[*]}" | sort -nr | head -n1` From f2ad3b20db70f077498f77a100205cbc0b38c438 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Fri, 4 Jun 2021 17:20:33 -0400 Subject: [PATCH 05/18] Exclude __init__.py files for isort-cudf --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 765df0305f0..f877dc1abb6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,7 @@ repos: name: isort-cudf args: ["--settings-path=python/cudf/setup.cfg"] files: python/cudf/.* + exclude: __init__.py$ - id: isort alias: isort-cudf-kafka name: isort-cudf-kafka From 4cb923b742d5db6c6f102baa978d0e6821b4a13f Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Fri, 4 Jun 2021 18:12:22 -0400 Subject: [PATCH 06/18] Bump isort to 5.6.0, include cython/pyi in checks --- .pre-commit-config.yaml | 8 ++++++-- ci/checks/style.sh | 8 ++++---- python/.flake8.cython | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f877dc1abb6..0a22f409e4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - - repo: https://github.com/timothycrosley/isort - rev: 5.0.7 + - repo: https://github.com/pycqa/isort + rev: 5.6.0 hooks: - id: isort alias: isort-cudf @@ -8,11 +8,15 @@ repos: args: ["--settings-path=python/cudf/setup.cfg"] files: python/cudf/.* exclude: __init__.py$ + types: [text] + types_or: [python, cython, pyi] - id: isort alias: isort-cudf-kafka name: isort-cudf-kafka args: ["--settings-path=python/cudf_kafka/setup.cfg"] files: python/cudf_kafka/.* + types: [text] + types_or: [python, cython] - id: isort alias: isort-custreamz name: isort-custreamz diff --git a/ci/checks/style.sh b/ci/checks/style.sh index 76a0303b711..811343aef0a 100755 --- a/ci/checks/style.sh +++ b/ci/checks/style.sh @@ -14,19 +14,19 @@ LANG=C.UTF-8 source activate gdf # Run isort-cudf and get results/return code -ISORT_CUDF=`isort python/cudf --check-only --settings-path=python/cudf/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_CUDF=`isort python/cudf --check-only --settings-path=python/cudf/setup.cfg 2>&1` ISORT_CUDF_RETVAL=$? # Run isort-cudf-kafka and get results/return code -ISORT_CUDF_KAFKA=`isort python/cudf_kafka --check-only --settings-path=python/cudf_kafka/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_CUDF_KAFKA=`isort python/cudf_kafka --check-only --settings-path=python/cudf_kafka/setup.cfg 2>&1` ISORT_CUDF_KAFKA_RETVAL=$? # Run isort-custreamz and get results/return code -ISORT_CUSTREAMZ=`isort python/custreamz --check-only --settings-path=python/custreamz/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_CUSTREAMZ=`isort python/custreamz --check-only --settings-path=python/custreamz/setup.cfg 2>&1` ISORT_CUSTREAMZ_RETVAL=$? # Run isort-dask-cudf and get results/return code -ISORT_DASK_CUDF=`isort python/dask_cudf --check-only --settings-path=python/dask_cudf/setup.cfg --skip-glob *.pyx --skip-glob *.pyi 2>&1` +ISORT_DASK_CUDF=`isort python/dask_cudf --check-only --settings-path=python/dask_cudf/setup.cfg 2>&1` ISORT_DASK_CUDF_RETVAL=$? # Run black and get results/return code diff --git a/python/.flake8.cython b/python/.flake8.cython index 243147f397f..92d467db159 100644 --- a/python/.flake8.cython +++ b/python/.flake8.cython @@ -17,9 +17,10 @@ [flake8] filename = *.pyx, *.pxd, *.pxi exclude = *.egg, build, docs, .git -ignore = E999, E225, E226, E227, W503, W504, E211 +ignore = E999, E225, E226, E227, W503, W504, E211, E402 # Rules ignored: +# E402: invalid syntax (works for Python, not Cython) # E999: invalid syntax (works for Python, not Cython) # E211: whitespace before '(' (used in multi-line imports) # E225: Missing whitespace around operators (breaks cython casting syntax like ) From 00ecc5129a2200abdedcd0d2a5ba10a63b17d70f Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Mon, 14 Jun 2021 15:27:42 -0400 Subject: [PATCH 07/18] Bump isort to 5.6.4 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a22f409e4a..b0ce5f93b26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.6.0 + rev: 5.6.4 hooks: - id: isort alias: isort-cudf From 220a722b3d584cad6447e6d73b85ca73b038a837 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Mon, 21 Jun 2021 14:29:05 -0400 Subject: [PATCH 08/18] Run updated hooks across codebase --- .../tests/kafka_consumer_tests.cpp | 2 +- java/src/main/native/include/jni_utils.hpp | 25 +- java/src/main/native/src/AggregationJni.cpp | 26 +- java/src/main/native/src/ColumnVectorJni.cpp | 108 +++-- java/src/main/native/src/ColumnViewJni.cpp | 374 ++++++++---------- .../main/native/src/ContiguousTableJni.cpp | 2 +- java/src/main/native/src/CudaJni.cpp | 3 +- .../src/HostMemoryBufferNativeUtilsJni.cpp | 42 +- java/src/main/native/src/NvcompJni.cpp | 366 ++++++++--------- java/src/main/native/src/NvtxRangeJni.cpp | 10 +- java/src/main/native/src/ScalarJni.cpp | 18 +- java/src/main/native/src/TableJni.cpp | 247 ++++++------ java/src/main/native/src/cudf_jni_apis.hpp | 2 +- java/src/main/native/src/dtype_utils.hpp | 12 +- java/src/main/native/src/map_lookup.cu | 6 +- java/src/main/native/src/prefix_sum.cu | 20 +- java/src/main/native/src/prefix_sum.hpp | 3 +- python/cudf/cudf/_lib/aggregation.pxd | 4 +- python/cudf/cudf/_lib/aggregation.pyx | 15 +- python/cudf/cudf/_lib/avro.pyx | 11 +- python/cudf/cudf/_lib/binaryop.pxd | 1 - python/cudf/cudf/_lib/binaryop.pyx | 19 +- python/cudf/cudf/_lib/column.pxd | 7 +- python/cudf/cudf/_lib/column.pyi | 6 +- python/cudf/cudf/_lib/column.pyx | 33 +- python/cudf/cudf/_lib/concat.pyx | 18 +- python/cudf/cudf/_lib/copying.pyx | 24 +- python/cudf/cudf/_lib/cpp/aggregation.pxd | 6 +- python/cudf/cudf/_lib/cpp/binaryop.pxd | 7 +- python/cudf/cudf/_lib/cpp/column/column.pxd | 10 +- .../cudf/_lib/cpp/column/column_factories.pxd | 9 +- .../cudf/cudf/_lib/cpp/column/column_view.pxd | 8 +- python/cudf/cudf/_lib/cpp/concatenate.pxd | 3 +- python/cudf/cudf/_lib/cpp/copying.pxd | 11 +- python/cudf/cudf/_lib/cpp/filling.pxd | 6 +- python/cudf/cudf/_lib/cpp/gpuarrow.pxd | 9 +- python/cudf/cudf/_lib/cpp/groupby.pxd | 12 +- python/cudf/cudf/_lib/cpp/hash.pxd | 2 +- python/cudf/cudf/_lib/cpp/interop.pxd | 10 +- python/cudf/cudf/_lib/cpp/io/avro.pxd | 2 +- python/cudf/cudf/_lib/cpp/io/csv.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/json.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/orc.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd | 2 +- python/cudf/cudf/_lib/cpp/io/parquet.pxd | 9 +- python/cudf/cudf/_lib/cpp/io/types.pxd | 6 +- python/cudf/cudf/_lib/cpp/join.pxd | 10 +- python/cudf/cudf/_lib/cpp/labeling.pxd | 1 + python/cudf/cudf/_lib/cpp/lists/contains.pxd | 4 +- .../cudf/_lib/cpp/lists/count_elements.pxd | 1 + .../_lib/cpp/lists/drop_list_duplicates.pxd | 5 +- python/cudf/cudf/_lib/cpp/lists/explode.pxd | 1 + python/cudf/cudf/_lib/cpp/lists/extract.pxd | 2 +- .../cudf/_lib/cpp/lists/lists_column_view.pxd | 4 +- python/cudf/cudf/_lib/cpp/lists/sorting.pxd | 2 +- python/cudf/cudf/_lib/cpp/merge.pxd | 4 +- python/cudf/cudf/_lib/cpp/null_mask.pxd | 2 +- .../cudf/_lib/cpp/nvtext/edit_distance.pxd | 1 + .../cudf/_lib/cpp/nvtext/generate_ngrams.pxd | 1 + .../cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd | 1 + .../cudf/cudf/_lib/cpp/nvtext/normalize.pxd | 1 + python/cudf/cudf/_lib/cpp/nvtext/replace.pxd | 2 +- python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd | 1 + .../cudf/_lib/cpp/nvtext/subword_tokenize.pxd | 3 +- python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd | 1 + python/cudf/cudf/_lib/cpp/partitioning.pxd | 6 +- python/cudf/cudf/_lib/cpp/quantiles.pxd | 5 +- python/cudf/cudf/_lib/cpp/reduce.pxd | 13 +- python/cudf/cudf/_lib/cpp/replace.pxd | 10 +- python/cudf/cudf/_lib/cpp/reshape.pxd | 3 +- python/cudf/cudf/_lib/cpp/rolling.pxd | 6 +- python/cudf/cudf/_lib/cpp/round.pxd | 1 + python/cudf/cudf/_lib/cpp/scalar/scalar.pxd | 5 +- python/cudf/cudf/_lib/cpp/search.pxd | 4 +- python/cudf/cudf/_lib/cpp/sorting.pxd | 5 +- .../cudf/cudf/_lib/cpp/stream_compaction.pxd | 13 +- .../cudf/cudf/_lib/cpp/strings/attributes.pxd | 1 + .../cudf/cudf/_lib/cpp/strings/capitalize.pxd | 1 + python/cudf/cudf/_lib/cpp/strings/case.pxd | 1 + .../cudf/cudf/_lib/cpp/strings/char_types.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/combine.pxd | 8 +- .../cudf/cudf/_lib/cpp/strings/contains.pxd | 3 +- .../cpp/strings/convert/convert_booleans.pxd | 3 +- .../cpp/strings/convert/convert_datetime.pxd | 5 +- .../cpp/strings/convert/convert_durations.pxd | 5 +- .../strings/convert/convert_fixed_point.pxd | 3 +- .../cpp/strings/convert/convert_floats.pxd | 3 +- .../cpp/strings/convert/convert_integers.pxd | 3 +- .../_lib/cpp/strings/convert/convert_ipv4.pxd | 3 +- .../_lib/cpp/strings/convert/convert_urls.pxd | 3 +- python/cudf/cudf/_lib/cpp/strings/extract.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/find.pxd | 4 +- .../cudf/_lib/cpp/strings/find_multiple.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/findall.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/json.pxd | 5 +- python/cudf/cudf/_lib/cpp/strings/padding.pxd | 9 +- python/cudf/cudf/_lib/cpp/strings/replace.pxd | 8 +- .../cudf/cudf/_lib/cpp/strings/replace_re.pxd | 9 +- .../cudf/_lib/cpp/strings/split/partition.pxd | 8 +- .../cudf/_lib/cpp/strings/split/split.pxd | 10 +- python/cudf/cudf/_lib/cpp/strings/strip.pxd | 6 +- .../cudf/cudf/_lib/cpp/strings/substring.pxd | 6 +- .../cudf/cudf/_lib/cpp/strings/translate.pxd | 7 +- python/cudf/cudf/_lib/cpp/strings/wrap.pxd | 6 +- python/cudf/cudf/_lib/cpp/table/table.pxd | 10 +- .../cudf/cudf/_lib/cpp/table/table_view.pxd | 6 +- python/cudf/cudf/_lib/cpp/transform.pxd | 10 +- python/cudf/cudf/_lib/cpp/unary.pxd | 13 +- .../cudf/_lib/cpp/utilities/host_span.pxd | 1 + .../cudf/cudf/_lib/cpp/wrappers/decimals.pxd | 3 +- python/cudf/cudf/_lib/csv.pyx | 22 +- python/cudf/cudf/_lib/datetime.pyx | 6 +- python/cudf/cudf/_lib/filling.pyx | 9 +- python/cudf/cudf/_lib/gpuarrow.pyx | 14 +- python/cudf/cudf/_lib/groupby.pyx | 28 +- python/cudf/cudf/_lib/hash.pyx | 15 +- python/cudf/cudf/_lib/interop.pyx | 24 +- python/cudf/cudf/_lib/io/datasource.pxd | 2 + python/cudf/cudf/_lib/io/datasource.pyx | 2 + python/cudf/cudf/_lib/io/utils.pxd | 3 +- python/cudf/cudf/_lib/io/utils.pyx | 17 +- python/cudf/cudf/_lib/join.pyx | 18 +- python/cudf/cudf/_lib/json.pyx | 9 +- python/cudf/cudf/_lib/labeling.pyx | 7 +- python/cudf/cudf/_lib/lists.pyx | 37 +- python/cudf/cudf/_lib/merge.pyx | 11 +- python/cudf/cudf/_lib/null_mask.pyx | 11 +- .../cudf/cudf/_lib/nvtext/edit_distance.pyx | 4 +- .../cudf/cudf/_lib/nvtext/generate_ngrams.pyx | 8 +- .../cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx | 8 +- python/cudf/cudf/_lib/nvtext/normalize.pyx | 4 +- python/cudf/cudf/_lib/nvtext/replace.pyx | 8 +- python/cudf/cudf/_lib/nvtext/stemmer.pyx | 12 +- .../cudf/_lib/nvtext/subword_tokenize.pyx | 13 +- python/cudf/cudf/_lib/nvtext/tokenize.pyx | 12 +- python/cudf/cudf/_lib/orc.pyx | 38 +- python/cudf/cudf/_lib/parquet.pyx | 64 ++- python/cudf/cudf/_lib/partitioning.pyx | 14 +- python/cudf/cudf/_lib/quantiles.pyx | 18 +- python/cudf/cudf/_lib/reduce.pyx | 19 +- python/cudf/cudf/_lib/replace.pyx | 16 +- python/cudf/cudf/_lib/reshape.pyx | 13 +- python/cudf/cudf/_lib/rolling.pyx | 13 +- python/cudf/cudf/_lib/round.pyx | 3 +- python/cudf/cudf/_lib/scalar.pyx | 46 ++- python/cudf/cudf/_lib/search.pyx | 9 +- python/cudf/cudf/_lib/sort.pxd | 1 + python/cudf/cudf/_lib/sort.pyx | 19 +- python/cudf/cudf/_lib/stream_compaction.pyx | 26 +- python/cudf/cudf/_lib/string_casting.pyx | 43 +- python/cudf/cudf/_lib/strings/attributes.pyx | 6 +- python/cudf/cudf/_lib/strings/capitalize.pyx | 2 +- python/cudf/cudf/_lib/strings/case.pyx | 4 +- python/cudf/cudf/_lib/strings/char_types.pyx | 7 +- python/cudf/cudf/_lib/strings/combine.pyx | 19 +- python/cudf/cudf/_lib/strings/contains.pyx | 10 +- .../strings/convert/convert_fixed_point.pyx | 21 +- .../_lib/strings/convert/convert_floats.pyx | 3 +- .../_lib/strings/convert/convert_integers.pyx | 3 +- .../_lib/strings/convert/convert_urls.pyx | 6 +- python/cudf/cudf/_lib/strings/extract.pyx | 15 +- python/cudf/cudf/_lib/strings/find.pyx | 12 +- .../cudf/cudf/_lib/strings/find_multiple.pyx | 4 +- python/cudf/cudf/_lib/strings/findall.pyx | 17 +- python/cudf/cudf/_lib/strings/json.pyx | 10 +- python/cudf/cudf/_lib/strings/padding.pyx | 9 +- python/cudf/cudf/_lib/strings/replace.pyx | 20 +- python/cudf/cudf/_lib/strings/replace_re.pyx | 13 +- .../cudf/_lib/strings/split/partition.pyx | 19 +- python/cudf/cudf/_lib/strings/split/split.pyx | 23 +- python/cudf/cudf/_lib/strings/strip.pyx | 14 +- python/cudf/cudf/_lib/strings/substring.pyx | 13 +- python/cudf/cudf/_lib/strings/translate.pyx | 12 +- python/cudf/cudf/_lib/strings/wrap.pyx | 10 +- python/cudf/cudf/_lib/table.pxd | 4 +- python/cudf/cudf/_lib/table.pyi | 2 +- python/cudf/cudf/_lib/table.pyx | 15 +- python/cudf/cudf/_lib/transform.pyx | 23 +- python/cudf/cudf/_lib/transpose.pyx | 13 +- python/cudf/cudf/_lib/types.pxd | 3 +- python/cudf/cudf/_lib/types.pyx | 13 +- python/cudf/cudf/_lib/unary.pyx | 27 +- python/cudf/cudf/_lib/utils.pxd | 2 + python/cudf/cudf/_lib/utils.pyx | 16 +- python/cudf/cudf/api/extensions/accessor.py | 4 +- python/cudf/cudf/benchmarks/bench_cudf_io.py | 6 +- python/cudf/cudf/benchmarks/get_datasets.py | 2 +- python/cudf/cudf/core/frame.py | 2 +- python/cudf/cudf/core/subword_tokenizer.py | 6 +- python/cudf/cudf/core/tools/numeric.py | 11 +- python/cudf/cudf/tests/test_array_ufunc.py | 5 +- python/cudf/cudf/tests/test_compile_udf.py | 3 +- python/cudf/cudf/tests/test_concat.py | 2 +- .../cudf/cudf/tests/test_custom_accessor.py | 2 +- python/cudf/cudf/tests/test_dtypes.py | 2 +- python/cudf/cudf/tests/test_hash_vocab.py | 6 +- python/cudf/cudf/tests/test_replace.py | 2 +- python/cudf/cudf/tests/test_scan.py | 2 +- python/cudf/cudf/tests/test_seriesmap.py | 2 +- .../cudf/cudf/tests/test_subword_tokenizer.py | 5 +- python/cudf/cudf/tests/test_udf_binops.py | 5 +- python/cudf/cudf/utils/applyutils.py | 4 +- python/cudf/cudf/utils/cudautils.py | 4 +- python/cudf/cudf/utils/utils.py | 2 +- python/cudf_kafka/cudf_kafka/_lib/kafka.pxd | 9 +- python/cudf_kafka/cudf_kafka/_lib/kafka.pyx | 9 +- .../custreamz/tests/test_dataframes.py | 7 +- .../dask_cudf/tests/test_accessor.py | 4 +- .../dask_cudf/tests/test_delayed_io.py | 4 +- python/dask_cudf/dask_cudf/tests/test_join.py | 4 +- .../dask_cudf/tests/test_reductions.py | 4 +- python/dask_cudf/dask_cudf/tests/test_sort.py | 4 +- 212 files changed, 1414 insertions(+), 1578 deletions(-) diff --git a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp index 0f88d0b2564..dbfd7a29efd 100644 --- a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp +++ b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp @@ -20,8 +20,8 @@ #include #include "cudf_kafka/kafka_consumer.hpp" -#include #include +#include namespace kafka = cudf::io::external::kafka; diff --git a/java/src/main/native/include/jni_utils.hpp b/java/src/main/native/include/jni_utils.hpp index 3ce136dda19..4b6696e3911 100644 --- a/java/src/main/native/include/jni_utils.hpp +++ b/java/src/main/native/include/jni_utils.hpp @@ -243,21 +243,13 @@ template class nativ return data_ptr; } - const N_TYPE *const begin() const { - return data(); - } + const N_TYPE *const begin() const { return data(); } - N_TYPE *begin() { - return data(); - } + N_TYPE *begin() { return data(); } - const N_TYPE *const end() const { - return data() + size(); - } + const N_TYPE *const end() const { return data() + size(); } - N_TYPE *end() { - return data() + size(); - } + N_TYPE *end() { return data() + size(); } const J_ARRAY_TYPE get_jArray() const { return orig; } @@ -315,7 +307,7 @@ template class native_jpointerArray { int size() const noexcept { return wrapped.size(); } - T *operator[](int index) const { + T *operator[](int index) const { if (data() == NULL) { throw_java_exception(env, NPE_CLASS, "pointer is NULL"); } @@ -754,8 +746,8 @@ inline void jni_cuda_check(JNIEnv *const env, cudaError_t cuda_status) { if (cudaErrorMemoryAllocation == cudaPeekAtLastError()) { \ cudaGetLastError(); \ } \ - auto what = std::string("Could not allocate native memory: ") + \ - (e.what() == nullptr ? "" : e.what()); \ + auto what = \ + std::string("Could not allocate native memory: ") + (e.what() == nullptr ? "" : e.what()); \ JNI_CHECK_THROW_NEW(env, cudf::jni::OOM_CLASS, what.c_str(), ret_val); \ } \ catch (const std::exception &e) { \ @@ -763,5 +755,4 @@ inline void jni_cuda_check(JNIEnv *const env, cudaError_t cuda_status) { JNI_CHECK_THROW_NEW(env, class_name, e.what(), ret_val); \ } -#define CATCH_STD(env, ret_val) \ - CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val) +#define CATCH_STD(env, ret_val) CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val) diff --git a/java/src/main/native/src/AggregationJni.cpp b/java/src/main/native/src/AggregationJni.cpp index 63c2c33202e..b4ea1f9c33f 100644 --- a/java/src/main/native/src/AggregationJni.cpp +++ b/java/src/main/native/src/AggregationJni.cpp @@ -20,8 +20,7 @@ extern "C" { -JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env, - jclass class_object, +JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env, jclass class_object, jlong ptr) { try { cudf::jni::auto_set_device(env); @@ -51,7 +50,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv case 3: // MAX ret = cudf::make_max_aggregation(); break; - //case 4 COUNT + // case 4 COUNT case 5: // ANY ret = cudf::make_any_aggregation(); break; @@ -102,9 +101,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNthAgg(JNIEnv *env try { cudf::jni::auto_set_device(env); - std::unique_ptr ret = - cudf::make_nth_element_aggregation(offset, - include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE); + std::unique_ptr ret = cudf::make_nth_element_aggregation( + offset, include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE); return reinterpret_cast(ret.release()); } CATCH_STD(env, 0); @@ -112,8 +110,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNthAgg(JNIEnv *env JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createDdofAgg(JNIEnv *env, jclass class_object, - jint kind, - jint ddof) { + jint kind, jint ddof) { try { cudf::jni::auto_set_device(env); @@ -179,8 +176,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createQuantAgg(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv *env, jclass class_object, - jint kind, - jint offset) { + jint kind, jint offset) { try { cudf::jni::auto_set_device(env); @@ -200,9 +196,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg(JNIEnv *env, - jclass class_object, - jboolean include_nulls) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg( + JNIEnv *env, jclass class_object, jboolean include_nulls) { try { cudf::jni::auto_set_device(env); cudf::null_policy policy = @@ -226,9 +221,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectSetAgg(JNIE nulls_equal ? cudf::null_equality::EQUAL : cudf::null_equality::UNEQUAL; cudf::nan_equality nan_equality = nans_equal ? cudf::nan_equality::ALL_EQUAL : cudf::nan_equality::UNEQUAL; - std::unique_ptr ret = cudf::make_collect_set_aggregation(null_policy, - null_equality, - nan_equality); + std::unique_ptr ret = + cudf::make_collect_set_aggregation(null_policy, null_equality, nan_equality); return reinterpret_cast(ret.release()); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/ColumnVectorJni.cpp b/java/src/main/native/src/ColumnVectorJni.cpp index 85bbdd41b4a..89592a8a17c 100644 --- a/java/src/main/native/src/ColumnVectorJni.cpp +++ b/java/src/main/native/src/ColumnVectorJni.cpp @@ -17,18 +17,18 @@ #include #include #include +#include #include -#include #include -#include -#include -#include +#include #include #include #include +#include #include #include #include +#include #include "cudf_jni_apis.hpp" #include "dtype_utils.hpp" @@ -54,13 +54,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_sequence(JNIEnv *env, j CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow(JNIEnv *env, jclass, - jint j_type, - jlong j_col_length, - jlong j_null_count, - jobject j_data_obj, - jobject j_validity_obj, - jobject j_offsets_obj) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow( + JNIEnv *env, jclass, jint j_type, jlong j_col_length, jlong j_null_count, jobject j_data_obj, + jobject j_validity_obj, jobject j_offsets_obj) { try { cudf::jni::auto_set_device(env); cudf::type_id n_type = static_cast(j_type); @@ -83,17 +79,22 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow(JNIEnv *env, offsets_address = env->GetDirectBufferAddress(j_offsets_obj); offsets_length = env->GetDirectBufferCapacity(j_offsets_obj); } - auto data_buffer = arrow::Buffer::Wrap(static_cast(data_address), static_cast(data_length)); - auto null_buffer = arrow::Buffer::Wrap(static_cast(validity_address), static_cast(validity_length)); - auto offsets_buffer = arrow::Buffer::Wrap(static_cast(offsets_address), static_cast(offsets_length)); + auto data_buffer = + arrow::Buffer::Wrap(static_cast(data_address), static_cast(data_length)); + auto null_buffer = arrow::Buffer::Wrap(static_cast(validity_address), + static_cast(validity_length)); + auto offsets_buffer = arrow::Buffer::Wrap(static_cast(offsets_address), + static_cast(offsets_length)); std::shared_ptr arrow_array; switch (n_type) { case cudf::type_id::DECIMAL32: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL32 yet", 0); + JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL32 yet", + 0); break; case cudf::type_id::DECIMAL64: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL64 yet", 0); + JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL64 yet", + 0); break; case cudf::type_id::STRUCT: JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting STRUCT yet", 0); @@ -102,19 +103,23 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow(JNIEnv *env, JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting LIST yet", 0); break; case cudf::type_id::DICTIONARY32: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DICTIONARY32 yet", 0); + JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, + "Don't support converting DICTIONARY32 yet", 0); break; case cudf::type_id::STRING: - arrow_array = std::make_shared(j_col_length, offsets_buffer, data_buffer, null_buffer, j_null_count); + arrow_array = std::make_shared(j_col_length, offsets_buffer, + data_buffer, null_buffer, j_null_count); break; default: // this handles the primitive types - arrow_array = cudf::detail::to_arrow_array(n_type, j_col_length, data_buffer, null_buffer, j_null_count); + arrow_array = cudf::detail::to_arrow_array(n_type, j_col_length, data_buffer, null_buffer, + j_null_count); } auto name_and_type = arrow::field("col", arrow_array->type()); std::vector> fields = {name_and_type}; std::shared_ptr schema = std::make_shared(fields); - auto arrow_table = arrow::Table::Make(schema, std::vector>{arrow_array}); + auto arrow_table = + arrow::Table::Make(schema, std::vector>{arrow_array}); std::unique_ptr table_result = cudf::from_arrow(*(arrow_table)); std::vector> retCols = table_result->release(); if (retCols.size() != 1) { @@ -125,28 +130,24 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow(JNIEnv *env, CATCH_STD(env, 0); } - -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_stringConcatenation(JNIEnv *env, jclass, - jlongArray column_handles, - jlong separator, - jlong narep) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_stringConcatenation( + JNIEnv *env, jclass, jlongArray column_handles, jlong separator, jlong narep) { JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); JNI_NULL_CHECK(env, separator, "separator string scalar object is null", 0); JNI_NULL_CHECK(env, narep, "narep string scalar object is null", 0); try { cudf::jni::auto_set_device(env); - const auto& separator_scalar = *reinterpret_cast(separator); - const auto& narep_scalar = *reinterpret_cast(narep); + const auto &separator_scalar = *reinterpret_cast(separator); + const auto &narep_scalar = *reinterpret_cast(narep); cudf::jni::native_jpointerArray n_cudf_columns(env, column_handles); std::vector column_views; - std::transform(n_cudf_columns.data(), - n_cudf_columns.data() + n_cudf_columns.size(), + std::transform(n_cudf_columns.data(), n_cudf_columns.data() + n_cudf_columns.size(), std::back_inserter(column_views), [](auto const &p_column) { return *p_column; }); std::unique_ptr result = - cudf::strings::concatenate(cudf::table_view(column_views), separator_scalar, narep_scalar); + cudf::strings::concatenate(cudf::table_view(column_views), separator_scalar, narep_scalar); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -158,28 +159,25 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_concatListByRow(JNIEnv JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); try { cudf::jni::auto_set_device(env); - auto null_policy = ignore_null ? cudf::lists::concatenate_null_policy::IGNORE - : cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW; + auto null_policy = ignore_null ? cudf::lists::concatenate_null_policy::IGNORE : + cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW; cudf::jni::native_jpointerArray n_cudf_columns(env, column_handles); std::vector column_views; - std::transform(n_cudf_columns.data(), - n_cudf_columns.data() + n_cudf_columns.size(), + std::transform(n_cudf_columns.data(), n_cudf_columns.data() + n_cudf_columns.size(), std::back_inserter(column_views), [](auto const &p_column) { return *p_column; }); std::unique_ptr result = - cudf::lists::concatenate_rows(cudf::table_view(column_views), null_policy); + cudf::lists::concatenate_rows(cudf::table_view(column_views), null_policy); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeList(JNIEnv *env, jobject j_object, - jlongArray handles, - jlong j_type, - jint scale, - jlong row_count) { + jlongArray handles, jlong j_type, + jint scale, jlong row_count) { using ScalarType = cudf::scalar_type_t; JNI_NULL_CHECK(env, handles, "native view handles are null", 0) try { @@ -199,8 +197,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeList(JNIEnv *env, j auto offsets = cudf::make_column_from_scalar(*zero, row_count + 1); cudf::data_type n_data_type = cudf::jni::make_data_type(j_type, scale); auto empty_col = cudf::make_empty_column(n_data_type); - ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(empty_col), - 0, rmm::device_buffer()); + ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(empty_col), 0, + rmm::device_buffer()); } else { auto count = cudf::make_numeric_scalar(cudf::data_type(cudf::type_id::INT32)); count->set_valid(true); @@ -208,8 +206,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeList(JNIEnv *env, j std::unique_ptr offsets = cudf::sequence(row_count + 1, *zero, *count); auto data_col = cudf::interleave_columns(cudf::table_view(children_vector)); - ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(data_col), - 0, rmm::device_buffer()); + ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(data_col), 0, + rmm::device_buffer()); } return reinterpret_cast(ret.release()); @@ -250,9 +248,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromScalar(JNIEnv *env, // type. // (Assumes the `row_count` is not big, otherwise there would be a performance issue.) // Checks the `row_count` because `cudf::concatenate` does not support no rows. - auto data_col = row_count > 0 - ? cudf::concatenate(std::vector(row_count, s_val)) - : cudf::empty_like(s_val); + auto data_col = row_count > 0 ? + cudf::concatenate(std::vector(row_count, s_val)) : + cudf::empty_like(s_val); col = cudf::make_lists_column(row_count, std::move(offsets), std::move(data_col), cudf::state_null_count(mask_state, row_count), cudf::create_null_mask(row_count, mask_state)); @@ -280,7 +278,6 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromScalar(JNIEnv *env, CATCH_STD(env, 0); } - JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_concatenate(JNIEnv *env, jclass clazz, jlongArray column_handles) { JNI_NULL_CHECK(env, column_handles, "input columns are null", 0); @@ -305,12 +302,10 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_concatenate(JNIEnv *env CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, jobject j_object, jlongArray column_handles, jint hash_function_id, - jintArray initial_values, - jint seed) { + jintArray initial_values, jint seed) { JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); JNI_NULL_CHECK(env, initial_values, "array of initial values is null", 0); @@ -322,13 +317,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, [](auto const &p_column) { return *p_column; }); cudf::table_view *input_table = new cudf::table_view(column_views); - cudf::jni::native_jintArray native_iv (env, initial_values); + cudf::jni::native_jintArray native_iv(env, initial_values); std::vector vector_iv; std::transform(native_iv.data(), native_iv.data() + native_iv.size(), - std::back_inserter(vector_iv), - [](auto const &iv) { return iv; }); + std::back_inserter(vector_iv), [](auto const &iv) { return iv; }); - std::unique_ptr result = cudf::hash(*input_table, static_cast(hash_function_id), vector_iv, seed); + std::unique_ptr result = + cudf::hash(*input_table, static_cast(hash_function_id), vector_iv, seed); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -378,8 +373,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_getNativeColumnView(JNI CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeEmptyCudfColumn(JNIEnv *env, - jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeEmptyCudfColumn(JNIEnv *env, jclass, jint j_type, jint scale) { diff --git a/java/src/main/native/src/ColumnViewJni.cpp b/java/src/main/native/src/ColumnViewJni.cpp index 8d2d67b8fd0..e7cfaedbb25 100644 --- a/java/src/main/native/src/ColumnViewJni.cpp +++ b/java/src/main/native/src/ColumnViewJni.cpp @@ -23,9 +23,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -47,27 +49,26 @@ #include #include #include +#include #include #include #include #include #include #include -#include +#include #include #include #include -#include -#include -#include #include + #include "cudf/types.hpp" -#include "prefix_sum.hpp" #include "cudf_jni_apis.hpp" #include "dtype_utils.hpp" #include "jni.h" #include "jni_utils.hpp" +#include "prefix_sum.hpp" namespace { @@ -84,10 +85,9 @@ std::size_t calc_device_memory_size(cudf::column_view const &view) { total += cudf::size_of(dtype) * view.size(); } - return std::accumulate(view.child_begin(), view.child_end(), total, - [](std::size_t t, cudf::column_view const &v) { - return t + calc_device_memory_size(v); - }); + return std::accumulate( + view.child_begin(), view.child_end(), total, + [](std::size_t t, cudf::column_view const &v) { return t + calc_device_memory_size(v); }); } } // anonymous namespace @@ -155,8 +155,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_replaceNullsColumn(JNIEnv } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVV(JNIEnv *env, jclass, - jlong j_pred_vec, - jlong j_true_vec, + jlong j_pred_vec, jlong j_true_vec, jlong j_false_vec) { JNI_NULL_CHECK(env, j_pred_vec, "predicate column is null", 0); JNI_NULL_CHECK(env, j_true_vec, "true column is null", 0); @@ -173,8 +172,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVV(JNIEnv *env, jcl } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVS(JNIEnv *env, jclass, - jlong j_pred_vec, - jlong j_true_vec, + jlong j_pred_vec, jlong j_true_vec, jlong j_false_scalar) { JNI_NULL_CHECK(env, j_pred_vec, "predicate column is null", 0); JNI_NULL_CHECK(env, j_true_vec, "true column is null", 0); @@ -227,10 +225,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseSS(JNIEnv *env, jcl CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_reduce(JNIEnv *env, jclass, - jlong j_col_view, - jlong j_agg, - jint j_dtype, jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_reduce(JNIEnv *env, jclass, jlong j_col_view, + jlong j_agg, jint j_dtype, + jint scale) { JNI_NULL_CHECK(env, j_col_view, "column view is null", 0); JNI_NULL_CHECK(env, j_agg, "aggregation is null", 0); try { @@ -265,9 +262,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_quantile(JNIEnv *env, jcl } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_rollingWindow( - JNIEnv *env, jclass clazz, jlong input_col, jlong default_output_col, - jint min_periods, jlong agg_ptr, jint preceding, - jint following, jlong preceding_col, jlong following_col) { + JNIEnv *env, jclass clazz, jlong input_col, jlong default_output_col, jint min_periods, + jlong agg_ptr, jint preceding, jint following, jlong preceding_col, jlong following_col) { JNI_NULL_CHECK(env, input_col, "native handle is null", 0); JNI_NULL_CHECK(env, agg_ptr, "aggregation handle is null", 0); @@ -278,27 +274,28 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_rollingWindow( reinterpret_cast(default_output_col); cudf::column_view *n_preceding_col = reinterpret_cast(preceding_col); cudf::column_view *n_following_col = reinterpret_cast(following_col); - cudf::rolling_aggregation * agg = dynamic_cast(reinterpret_cast(agg_ptr)); + cudf::rolling_aggregation *agg = + dynamic_cast(reinterpret_cast(agg_ptr)); JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", 0); std::unique_ptr ret; if (n_default_output_col != nullptr) { if (n_preceding_col != nullptr && n_following_col != nullptr) { - CUDF_FAIL("A default output column is not currently supported with variable length preceding and following"); - //ret = cudf::rolling_window(*n_input_col, *n_default_output_col, + CUDF_FAIL("A default output column is not currently supported with variable length " + "preceding and following"); + // ret = cudf::rolling_window(*n_input_col, *n_default_output_col, // *n_preceding_col, *n_following_col, min_periods, agg); } else { - ret = cudf::rolling_window(*n_input_col, *n_default_output_col, - preceding, following, min_periods, *agg); + ret = cudf::rolling_window(*n_input_col, *n_default_output_col, preceding, following, + min_periods, *agg); } } else { if (n_preceding_col != nullptr && n_following_col != nullptr) { - ret = cudf::rolling_window(*n_input_col, *n_preceding_col, *n_following_col, - min_periods, *agg); + ret = cudf::rolling_window(*n_input_col, *n_preceding_col, *n_following_col, min_periods, + *agg); } else { - ret = cudf::rolling_window(*n_input_col, preceding, following, min_periods, - *agg); + ret = cudf::rolling_window(*n_input_col, preceding, following, min_periods, *agg); } } return reinterpret_cast(ret.release()); @@ -370,8 +367,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_listContains(JNIEnv *env, } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_listContainsColumn(JNIEnv *env, jclass, - jlong column_view, - jlong lookup_key_cv) { + jlong column_view, + jlong lookup_key_cv) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, lookup_key_cv, "lookup column is null", 0); try { @@ -491,8 +488,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_byteCount(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_findAndReplaceAll(JNIEnv *env, - jclass clazz, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_findAndReplaceAll(JNIEnv *env, jclass clazz, jlong old_values_handle, jlong new_values_handle, jlong input_handle) { @@ -579,23 +575,21 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_unaryOperation(JNIEnv *en CATCH_STD(env, 0); } - -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_round(JNIEnv *env, jclass, - jlong input_ptr, jint decimal_places, - jint rounding_method) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_round(JNIEnv *env, jclass, jlong input_ptr, + jint decimal_places, + jint rounding_method) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *input = reinterpret_cast(input_ptr); - cudf::rounding_method method = static_cast(rounding_method); - std::unique_ptr ret = cudf::round(*input, decimal_places, method); - return reinterpret_cast(ret.release()); - } - CATCH_STD(env, 0); -} - -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, - jlong input_ptr) { + try { + cudf::jni::auto_set_device(env); + cudf::column_view *input = reinterpret_cast(input_ptr); + cudf::rounding_method method = static_cast(rounding_method); + std::unique_ptr ret = cudf::round(*input, decimal_places, method); + return reinterpret_cast(ret.release()); + } + CATCH_STD(env, 0); +} + +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -606,8 +600,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_month(JNIEnv *env, jclass, - jlong input_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_month(JNIEnv *env, jclass, jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -629,8 +622,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_day(JNIEnv *env, jclass, CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_hour(JNIEnv *env, jclass, - jlong input_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_hour(JNIEnv *env, jclass, jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -701,9 +693,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_dayOfYear(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclass, - jlong handle, jint type, - jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclass, jlong handle, + jint type, jint scale) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { cudf::jni::auto_set_device(env); @@ -716,13 +707,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas } if (n_data_type.id() == cudf::type_id::STRING) { switch (column->type().id()) { - case cudf::type_id::BOOL8: - result = cudf::strings::from_booleans(*column); - break; + case cudf::type_id::BOOL8: result = cudf::strings::from_booleans(*column); break; case cudf::type_id::FLOAT32: - case cudf::type_id::FLOAT64: - result = cudf::strings::from_floats(*column); - break; + case cudf::type_id::FLOAT64: result = cudf::strings::from_floats(*column); break; case cudf::type_id::INT8: case cudf::type_id::UINT8: case cudf::type_id::INT16: @@ -730,24 +717,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas case cudf::type_id::INT32: case cudf::type_id::UINT32: case cudf::type_id::INT64: - case cudf::type_id::UINT64: - result = cudf::strings::from_integers(*column); - break; + case cudf::type_id::UINT64: result = cudf::strings::from_integers(*column); break; case cudf::type_id::DECIMAL32: - case cudf::type_id::DECIMAL64: - result = cudf::strings::from_fixed_point(*column); - break; + case cudf::type_id::DECIMAL64: result = cudf::strings::from_fixed_point(*column); break; default: JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Invalid data type", 0); } } else if (column->type().id() == cudf::type_id::STRING) { switch (n_data_type.id()) { - case cudf::type_id::BOOL8: - result = cudf::strings::to_booleans(*column); - break; + case cudf::type_id::BOOL8: result = cudf::strings::to_booleans(*column); break; case cudf::type_id::FLOAT32: - case cudf::type_id::FLOAT64: - result = cudf::strings::to_floats(*column, n_data_type); - break; + case cudf::type_id::FLOAT64: result = cudf::strings::to_floats(*column, n_data_type); break; case cudf::type_id::INT8: case cudf::type_id::UINT8: case cudf::type_id::INT16: @@ -770,30 +749,26 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas // "reinterpret" casting will be supported via https://github.com/rapidsai/cudf/pull/5358 if (n_data_type.id() == cudf::type_id::TIMESTAMP_DAYS) { if (column->type().id() != cudf::type_id::INT32) { - JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Numeric cast to TIMESTAMP_DAYS requires INT32", 0); + JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", + "Numeric cast to TIMESTAMP_DAYS requires INT32", 0); } } else { if (column->type().id() != cudf::type_id::INT64) { - JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Numeric cast to non-day timestamp requires INT64", 0); + JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", + "Numeric cast to non-day timestamp requires INT64", 0); } } cudf::data_type duration_type = cudf::jni::timestamp_to_duration(n_data_type); - cudf::column_view duration_view = cudf::column_view(duration_type, - column->size(), - column->head(), - column->null_mask(), - column->null_count()); + cudf::column_view duration_view = cudf::column_view( + duration_type, column->size(), column->head(), column->null_mask(), column->null_count()); result = cudf::cast(duration_view, n_data_type); } else if (cudf::is_timestamp(column->type()) && cudf::is_numeric(n_data_type)) { // This is a temporary workaround to allow Java to cast from timestamp types to integral types // without forcing an intermediate duration column to be manifested. Ultimately this style of // "reinterpret" casting will be supported via https://github.com/rapidsai/cudf/pull/5358 cudf::data_type duration_type = cudf::jni::timestamp_to_duration(column->type()); - cudf::column_view duration_view = cudf::column_view(duration_type, - column->size(), - column->head(), - column->null_mask(), - column->null_count()); + cudf::column_view duration_view = cudf::column_view( + duration_type, column->size(), column->head(), column->null_mask(), column->null_count()); result = cudf::cast(duration_view, n_data_type); } else { result = cudf::cast(*column, n_data_type); @@ -803,9 +778,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitCastTo(JNIEnv *env, jclass, - jlong handle, jint type, - jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitCastTo(JNIEnv *env, jclass, jlong handle, + jint type, jint scale) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { cudf::jni::auto_set_device(env); @@ -851,7 +825,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringTimestampToTimestam } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isTimestamp(JNIEnv *env, jclass, - jlong handle, jstring formatObj) { + jlong handle, + jstring formatObj) { JNI_NULL_CHECK(env, handle, "column is null", 0); JNI_NULL_CHECK(env, formatObj, "format is null", 0); @@ -861,8 +836,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isTimestamp(JNIEnv *env, cudf::column_view *column = reinterpret_cast(handle); cudf::strings_column_view strings_column(*column); - std::unique_ptr result = cudf::strings::is_timestamp( - strings_column, format.get()); + std::unique_ptr result = + cudf::strings::is_timestamp(strings_column, format.get()); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -900,8 +875,7 @@ JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_ColumnView_containsScalar(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_containsVector(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_containsVector(JNIEnv *env, jobject j_object, jlong j_haystack_handle, jlong j_needle_handle) { JNI_NULL_CHECK(env, j_haystack_handle, "haystack vector is null", false); @@ -951,8 +925,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringStartWith(JNIEnv *e CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env, jobject j_object, jlong j_view_handle, jlong comp_string) { JNI_NULL_CHECK(env, j_view_handle, "column is null", false); @@ -970,8 +943,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringContains(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringContains(JNIEnv *env, jobject j_object, jlong j_view_handle, jlong comp_string) { JNI_NULL_CHECK(env, j_view_handle, "column is null", false); @@ -1039,8 +1011,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_binaryOpVV(JNIEnv *env, j cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation( - *lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1071,8 +1042,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_binaryOpVS(JNIEnv *env, j cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation( - *lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1117,8 +1087,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringColumn(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringLocate(JNIEnv *env, jclass, jlong column_view, - jlong substring, - jint start, jint end) { + jlong substring, jint start, + jint end) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, substring, "target string scalar is null", 0); try { @@ -1135,8 +1105,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringLocate(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplace(JNIEnv *env, jclass, jlong column_view, - jlong target, - jlong replace) { + jlong target, jlong replace) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, target, "target string scalar is null", 0); JNI_NULL_CHECK(env, replace, "replace string scalar is null", 0); @@ -1169,11 +1138,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_mapLookup(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs(JNIEnv *env, - jclass, - jlong column_view, - jstring patternObj, - jstring replaceObj) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs( + JNIEnv *env, jclass, jlong column_view, jstring patternObj, jstring replaceObj) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, patternObj, "pattern string is null", 0); @@ -1185,8 +1151,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs cudf::jni::native_jstring ss_pattern(env, patternObj); cudf::jni::native_jstring ss_replace(env, replaceObj); - std::unique_ptr result = cudf::strings::replace_with_backrefs( - scv, ss_pattern.get(), ss_replace.get()); + std::unique_ptr result = + cudf::strings::replace_with_backrefs(scv, ss_pattern.get(), ss_replace.get()); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1208,11 +1174,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_zfill(JNIEnv *env, jclass CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_pad(JNIEnv *env, - jclass, - jlong column_view, - jint j_width, - jint j_side, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_pad(JNIEnv *env, jclass, jlong column_view, + jint j_width, jint j_side, jstring fill_char) { JNI_NULL_CHECK(env, column_view, "column is null", 0); @@ -1311,11 +1274,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_normalizeNANsAndZeros(JNI CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidity(JNIEnv *env, - jobject j_object, - jlong base_column, - jlongArray column_handles, - jint bin_op) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidity( + JNIEnv *env, jobject j_object, jlong base_column, jlongArray column_handles, jint bin_op) { JNI_NULL_CHECK(env, base_column, "base column native handle is null", 0); JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); try { @@ -1337,15 +1297,14 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit cudf::table_view *input_table = new cudf::table_view(column_views); cudf::binary_operator op = static_cast(bin_op); - switch(op) { + switch (op) { case cudf::binary_operator::BITWISE_AND: copy->set_null_mask(cudf::bitmask_and(*input_table)); break; case cudf::binary_operator::BITWISE_OR: copy->set_null_mask(cudf::bitmask_or(*input_table)); break; - default: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Unsupported merge operation", 0); + default: JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Unsupported merge operation", 0); } return reinterpret_cast(copy.release()); @@ -1358,11 +1317,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit // should typically only be called from the CudfColumn inner class. //////// -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv *env, - jclass, jint j_type, - jint scale, jlong j_data, - jlong j_data_size, - jlong j_offset, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView( + JNIEnv *env, jclass, jint j_type, jint scale, jlong j_data, jlong j_data_size, jlong j_offset, jlong j_valid, jint j_null_count, jint size, jlongArray j_children) { try { @@ -1380,7 +1336,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv if (n_type == cudf::type_id::STRING) { if (size == 0) { - ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0)); + ret.reset( + new cudf::column_view(cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0)); } else { JNI_NULL_CHECK(env, j_offset, "offset is null", 0); // This must be kept in sync with how string columns are created @@ -1404,20 +1361,21 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv offsets_size = size + 1; offsets = reinterpret_cast(j_offset); } - cudf::column_view offsets_column(cudf::data_type{cudf::type_id::INT32}, offsets_size, offsets); + cudf::column_view offsets_column(cudf::data_type{cudf::type_id::INT32}, offsets_size, + offsets); ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::LIST}, size, nullptr, valid, - j_null_count, 0, {offsets_column, *children[0]})); - } else if (n_type == cudf::type_id::STRUCT) { - JNI_NULL_CHECK(env, j_children, "children of a struct are null", 0); - cudf::jni::native_jpointerArray children(env, j_children); - std::vector children_vector(children.size()); - for (int i = 0; i < children.size(); i++) { - children_vector[i] = *children[i]; - } - ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, size, nullptr, valid, - j_null_count, 0, children_vector)); - } else { - ret.reset(new cudf::column_view(n_data_type, size, data, valid, j_null_count)); + j_null_count, 0, {offsets_column, *children[0]})); + } else if (n_type == cudf::type_id::STRUCT) { + JNI_NULL_CHECK(env, j_children, "children of a struct are null", 0); + cudf::jni::native_jpointerArray children(env, j_children); + std::vector children_vector(children.size()); + for (int i = 0; i < children.size(); i++) { + children_vector[i] = *children[i]; + } + ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, size, nullptr, valid, + j_null_count, 0, children_vector)); + } else { + ret.reset(new cudf::column_view(n_data_type, size, data, valid, j_null_count)); } return reinterpret_cast(ret.release()); @@ -1425,8 +1383,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *env, - jobject j_object, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *env, jobject j_object, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1437,8 +1394,7 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *en CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv *env, - jclass, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1449,8 +1405,7 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeRowCount(JNIEnv *env, - jclass, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeRowCount(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1497,7 +1452,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeDataAddress(JNIE cudf::column_view data_view = view.chars(); result = reinterpret_cast(data_view.data()); } - } else if(column->type().id() != cudf::type_id::LIST && column->type().id() != cudf::type_id::STRUCT) { + } else if (column->type().id() != cudf::type_id::LIST && + column->type().id() != cudf::type_id::STRUCT) { result = reinterpret_cast(column->data()); } return result; @@ -1518,7 +1474,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeDataLength(JNIEn cudf::column_view data_view = view.chars(); result = data_view.size(); } - } else if(column->type().id() != cudf::type_id::LIST && column->type().id() != cudf::type_id::STRUCT) { + } else if (column->type().id() != cudf::type_id::LIST && + column->type().id() != cudf::type_id::STRUCT) { result = cudf::size_of(column->type()) * column->size(); } return result; @@ -1530,45 +1487,49 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeNumChildren(JNIEn jobject j_object, jlong handle) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *column = reinterpret_cast(handle); - // Strings has children(offsets and chars) but not a nested child() we care about here. - if (column->type().id() == cudf::type_id::STRING) { - return 0; - } else if (column->type().id() == cudf::type_id::LIST) { - // first child is always offsets in lists which we do not want to count here - return static_cast(column->num_children() - 1); - } else if (column->type().id() == cudf::type_id::STRUCT) { - return static_cast(column->num_children()); - } else { - return 0; - } + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + cudf::column_view *column = reinterpret_cast(handle); + // Strings has children(offsets and chars) but not a nested child() we care about here. + if (column->type().id() == cudf::type_id::STRING) { + return 0; + } else if (column->type().id() == cudf::type_id::LIST) { + // first child is always offsets in lists which we do not want to count here + return static_cast(column->num_children() - 1); + } else if (column->type().id() == cudf::type_id::STRUCT) { + return static_cast(column->num_children()); + } else { + return 0; } - CATCH_STD(env, 0); - + } + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getChildCvPointer(JNIEnv *env, jobject j_object, - jlong handle, jint child_index) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *column = reinterpret_cast(handle); - if (column->type().id() == cudf::type_id::LIST) { - std::unique_ptr view = std::make_unique(*column); - // first child is always offsets which we do not want to get from this call - std::unique_ptr next_view = std::make_unique(column->child(1 + child_index)); - return reinterpret_cast(next_view.release()); - } else { - std::unique_ptr view = std::make_unique(*column); - std::unique_ptr next_view = std::make_unique(column->child(child_index)); - return reinterpret_cast(next_view.release()); - } + jlong handle, + jint child_index) { + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + cudf::column_view *column = reinterpret_cast(handle); + if (column->type().id() == cudf::type_id::LIST) { + std::unique_ptr view = + std::make_unique(*column); + // first child is always offsets which we do not want to get from this call + std::unique_ptr next_view = + std::make_unique(column->child(1 + child_index)); + return reinterpret_cast(next_view.release()); + } else { + std::unique_ptr view = + std::make_unique(*column); + std::unique_ptr next_view = + std::make_unique(column->child(child_index)); + return reinterpret_cast(next_view.release()); } - CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeOffsetsAddress(JNIEnv *env, jclass, @@ -1621,8 +1582,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeOffsetsLength(JN CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress(JNIEnv *env, - jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1633,8 +1593,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress( CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityLength(JNIEnv *env, - jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityLength(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1661,13 +1620,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidPointerSize JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getDeviceMemorySize(JNIEnv *env, jclass, jlong handle) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - auto view = reinterpret_cast(handle); - return calc_device_memory_size(*view); - } - CATCH_STD(env, 0); + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + auto view = reinterpret_cast(handle); + return calc_device_memory_size(*view); + } + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_clamper(JNIEnv *env, jobject j_object, @@ -1726,7 +1685,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeStructView(JNIEnv *en children_vector[i] = *children[i]; } ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, row_count, nullptr, - nullptr, 0, 0, children_vector)); + nullptr, 0, 0, children_vector)); return reinterpret_cast(ret.release()); } @@ -1771,7 +1730,6 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_nansToNulls(JNIEnv *env, CATCH_STD(env, 0) } - JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isFloat(JNIEnv *env, jobject j_object, jlong handle) { @@ -1801,8 +1759,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isInteger(JNIEnv *env, jo } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isIntegerWithType(JNIEnv *env, jobject, - jlong handle, - jint j_dtype, + jlong handle, jint j_dtype, jint scale) { JNI_NULL_CHECK(env, handle, "native view handle is null", 0) @@ -1817,7 +1774,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isIntegerWithType(JNIEnv CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv *env, jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv *env, + jobject j_object, jlong handle) { JNI_NULL_CHECK(env, handle, "native view handle is null", 0) @@ -1832,15 +1790,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env, jclass, - jlong j_view_handle, jlong j_scalar_handle) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env, jclass, + jlong j_view_handle, + jlong j_scalar_handle) { - JNI_NULL_CHECK(env, j_view_handle, "view cannot be null", 0); - JNI_NULL_CHECK(env, j_scalar_handle, "path cannot be null", 0); + JNI_NULL_CHECK(env, j_view_handle, "view cannot be null", 0); + JNI_NULL_CHECK(env, j_scalar_handle, "path cannot be null", 0); try { cudf::jni::auto_set_device(env); - cudf::column_view* n_column_view = reinterpret_cast(j_view_handle); + cudf::column_view *n_column_view = reinterpret_cast(j_view_handle); cudf::strings_column_view n_strings_col_view(*n_column_view); cudf::string_scalar *n_scalar_path = reinterpret_cast(j_scalar_handle); @@ -1849,6 +1808,5 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env return reinterpret_cast(result.release()); } CATCH_STD(env, 0) - } } // extern "C" diff --git a/java/src/main/native/src/ContiguousTableJni.cpp b/java/src/main/native/src/ContiguousTableJni.cpp index 352256af450..f592d80834c 100644 --- a/java/src/main/native/src/ContiguousTableJni.cpp +++ b/java/src/main/native/src/ContiguousTableJni.cpp @@ -93,7 +93,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ContiguousTable_createPackedMetadata auto data_addr = reinterpret_cast(j_buffer_addr); auto data_size = static_cast(j_buffer_length); auto metadata_ptr = - new cudf::packed_columns::metadata(cudf::pack_metadata(*table, data_addr, data_size)); + new cudf::packed_columns::metadata(cudf::pack_metadata(*table, data_addr, data_size)); return reinterpret_cast(metadata_ptr); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/CudaJni.cpp b/java/src/main/native/src/CudaJni.cpp index f5eb09fa2d4..9b65a335fa7 100644 --- a/java/src/main/native/src/CudaJni.cpp +++ b/java/src/main/native/src/CudaJni.cpp @@ -15,6 +15,7 @@ */ #include + #include "jni_utils.hpp" namespace { @@ -49,7 +50,7 @@ void auto_set_device(JNIEnv *env) { } /** Fills all the bytes in the buffer 'buf' with 'value'. */ -void device_memset_async(JNIEnv *env, rmm::device_buffer& buf, char value) { +void device_memset_async(JNIEnv *env, rmm::device_buffer &buf, char value) { cudaError_t cuda_status = cudaMemsetAsync((void *)buf.data(), value, buf.size()); jni_cuda_check(env, cuda_status); } diff --git a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp index 4a38516db92..16b8630b04a 100644 --- a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp +++ b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp @@ -14,32 +14,26 @@ * limitations under the License. */ -#include - -#include -#include #include #include +#include #include #include +#include +#include + #include "jni_utils.hpp" extern "C" { -JNIEXPORT jobject JNICALL -Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_wrapRangeInBuffer(JNIEnv *env, jclass, - jlong addr, - jlong len) { +JNIEXPORT jobject JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_wrapRangeInBuffer( + JNIEnv *env, jclass, jlong addr, jlong len) { return env->NewDirectByteBuffer(reinterpret_cast(addr), len); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap(JNIEnv* env, jclass, - jstring jpath, - jint mode, - jlong offset, - jlong length) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap( + JNIEnv *env, jclass, jstring jpath, jint mode, jlong offset, jlong length) { JNI_NULL_CHECK(env, jpath, "path is null", 0); JNI_ARG_CHECK(env, (mode == 0 || mode == 1), "bad mode value", 0); try { @@ -50,29 +44,31 @@ Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap(JNIEnv* env, jclass, cudf::jni::throw_java_exception(env, "java/io/IOException", strerror(errno)); } - void* address = mmap(NULL, length, - (mode == 0) ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); + void *address = mmap(NULL, length, (mode == 0) ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, + fd, offset); if (address == MAP_FAILED) { - char const* error_msg = strerror(errno); + char const *error_msg = strerror(errno); close(fd); cudf::jni::throw_java_exception(env, "java/io/IOException", error_msg); } close(fd); return reinterpret_cast(address); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_munmap(JNIEnv* env, jclass, - jlong address, jlong length) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_munmap(JNIEnv *env, jclass, + jlong address, + jlong length) { JNI_NULL_CHECK(env, address, "address is NULL", ); try { - int rc = munmap(reinterpret_cast(address), length); + int rc = munmap(reinterpret_cast(address), length); if (rc == -1) { cudf::jni::throw_java_exception(env, "java/io/IOException", strerror(errno)); } - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } } // extern "C" diff --git a/java/src/main/native/src/NvcompJni.cpp b/java/src/main/native/src/NvcompJni.cpp index 9ef3b1f958a..5ba87221597 100644 --- a/java/src/main/native/src/NvcompJni.cpp +++ b/java/src/main/native/src/NvcompJni.cpp @@ -29,8 +29,7 @@ constexpr char const *UNSUPPORTED_CLASS = "java/lang/UnsupportedOperationExcepti void check_nvcomp_status(JNIEnv *env, nvcompError_t status) { switch (status) { - case nvcompSuccess: - break; + case nvcompSuccess: break; case nvcompErrorInvalidValue: cudf::jni::throw_java_exception(env, ILLEGAL_ARG_CLASS, "nvcomp invalid value"); break; @@ -50,10 +49,8 @@ void check_nvcomp_status(JNIEnv *env, nvcompError_t status) { extern "C" { -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jlong jstream) { try { cudf::jni::auto_set_device(env); void *metadata_ptr; @@ -62,121 +59,114 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata(JNIEnv *env, jclass, &metadata_ptr, stream); check_nvcomp_status(env, status); return reinterpret_cast(metadata_ptr); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressDestroyMetadata(JNIEnv *env, jclass, - jlong metadata_ptr) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressDestroyMetadata( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); nvcompDecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetTempSize(JNIEnv *env, jclass, - jlong metadata_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetTempSize( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t temp_size; auto status = nvcompDecompressGetTempSize(reinterpret_cast(metadata_ptr), &temp_size); check_nvcomp_status(env, status); return temp_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetOutputSize(JNIEnv *env, jclass, - jlong metadata_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetOutputSize( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t out_size; auto status = nvcompDecompressGetOutputSize(reinterpret_cast(metadata_ptr), &out_size); check_nvcomp_status(env, status); return out_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressAsync(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jlong temp_ptr, jlong temp_size, - jlong metadata_ptr, - jlong out_ptr, jlong out_size, jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressAsync( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jlong temp_ptr, jlong temp_size, + jlong metadata_ptr, jlong out_ptr, jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto stream = reinterpret_cast(jstream); auto status = nvcompDecompressAsync(reinterpret_cast(in_ptr), in_size, reinterpret_cast(temp_ptr), temp_size, reinterpret_cast(metadata_ptr), - reinterpret_cast(out_ptr), out_size, - stream); + reinterpret_cast(out_ptr), out_size, stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jboolean JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Data(JNIEnv *env, jclass, jlong in_ptr, jlong in_size) { +JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Data(JNIEnv *env, jclass, + jlong in_ptr, + jlong in_size) { try { cudf::jni::auto_set_device(env); return LZ4IsData(reinterpret_cast(in_ptr), in_size); - } CATCH_STD(env, 0) + } + CATCH_STD(env, 0) } -JNIEXPORT jboolean JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Metadata(JNIEnv *env, jclass, jlong metadata_ptr) { +JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Metadata(JNIEnv *env, jclass, + jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); return LZ4IsMetadata(reinterpret_cast(metadata_ptr)); - } CATCH_STD(env, 0) + } + CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetTempSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetTempSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; size_t temp_size; - auto status = nvcompLZ4CompressGetTempSize(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, &temp_size); + auto status = nvcompLZ4CompressGetTempSize(reinterpret_cast(in_ptr), in_size, comp_type, + &opts, &temp_size); check_nvcomp_status(env, status); return temp_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetOutputSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, - jboolean compute_exact) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetOutputSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size, + jlong temp_ptr, jlong temp_size, jboolean compute_exact) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; size_t out_size; - auto status = nvcompLZ4CompressGetOutputSize(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - &out_size, compute_exact); + auto status = nvcompLZ4CompressGetOutputSize( + reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, &out_size, compute_exact); check_nvcomp_status(env, status); return out_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size, + jlong temp_ptr, jlong temp_size, jlong out_ptr, jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -184,27 +174,23 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress(JNIEnv *env, jclass, opts.chunk_size = chunk_size; auto stream = reinterpret_cast(jstream); size_t compressed_size = out_size; - auto status = nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), &compressed_size, - stream); + auto status = + nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), &compressed_size, stream); check_nvcomp_status(env, status); if (cudaStreamSynchronize(stream) != cudaSuccess) { JNI_THROW_NEW(env, NVCOMP_CUDA_ERROR_CLASS, "Error synchronizing stream", 0); } return compressed_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync(JNIEnv *env, jclass, - jlong compressed_output_ptr, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync( + JNIEnv *env, jclass, jlong compressed_output_ptr, jlong in_ptr, jlong in_size, jint input_type, + jlong chunk_size, jlong temp_ptr, jlong temp_size, jlong out_ptr, jlong out_size, + jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -213,20 +199,17 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync(JNIEnv *env, jclass, auto stream = reinterpret_cast(jstream); auto compressed_size_ptr = reinterpret_cast(compressed_output_ptr); *compressed_size_ptr = out_size; - auto status = nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), compressed_size_ptr, - stream); + auto status = + nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), compressed_size_ptr, stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong jstream) { try { cudf::jni::auto_set_device(env); @@ -240,65 +223,57 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata(JNIEnv* env std::back_inserter(sizes), [](jlong x) -> size_t { return static_cast(x); }); - void* metadata_ptr = nullptr; + void *metadata_ptr = nullptr; auto stream = reinterpret_cast(jstream); auto status = nvcompBatchedLZ4DecompressGetMetadata(input_ptrs.data(), sizes.data(), input_ptrs.size(), &metadata_ptr, stream); check_nvcomp_status(env, status); return reinterpret_cast(metadata_ptr); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressDestroyMetadata(JNIEnv* env, jclass, - jlong metadata_ptr) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressDestroyMetadata( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); - nvcompBatchedLZ4DecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); - } CATCH_STD(env, ); + nvcompBatchedLZ4DecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetTempSize(JNIEnv* env, jclass, - jlong metadata_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetTempSize( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t temp_size; - auto status = nvcompBatchedLZ4DecompressGetTempSize(reinterpret_cast(metadata_ptr), - &temp_size); + auto status = + nvcompBatchedLZ4DecompressGetTempSize(reinterpret_cast(metadata_ptr), &temp_size); check_nvcomp_status(env, status); return static_cast(temp_size); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlongArray JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetOutputSize(JNIEnv* env, jclass, - jlong metadata_ptr, - jint num_outputs) { +JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetOutputSize( + JNIEnv *env, jclass, jlong metadata_ptr, jint num_outputs) { try { cudf::jni::auto_set_device(env); std::vector sizes(num_outputs); - auto status = nvcompBatchedLZ4DecompressGetOutputSize(reinterpret_cast(metadata_ptr), - num_outputs, - sizes.data()); + auto status = nvcompBatchedLZ4DecompressGetOutputSize(reinterpret_cast(metadata_ptr), + num_outputs, sizes.data()); check_nvcomp_status(env, status); cudf::jni::native_jlongArray jsizes(env, num_outputs); std::transform(sizes.begin(), sizes.end(), jsizes.data(), [](size_t x) -> jlong { return static_cast(x); }); return jsizes.get_jArray(); - } CATCH_STD(env, NULL); + } + CATCH_STD(env, NULL); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong temp_ptr, - jlong temp_size, - jlong metadata_ptr, - jlongArray out_ptrs, - jlongArray out_sizes, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong temp_ptr, jlong temp_size, + jlong metadata_ptr, jlongArray out_ptrs, jlongArray out_sizes, jlong jstream) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -325,23 +300,17 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync(JNIEnv* env, jcla [](jlong x) -> size_t { return static_cast(x); }); auto stream = reinterpret_cast(jstream); - auto status = nvcompBatchedLZ4DecompressAsync(input_ptrs.data(), input_sizes.data(), - input_ptrs.size(), - reinterpret_cast(temp_ptr), - static_cast(temp_size), - reinterpret_cast(metadata_ptr), - output_ptrs.data(), - output_sizes.data(), - stream); + auto status = nvcompBatchedLZ4DecompressAsync( + input_ptrs.data(), input_sizes.data(), input_ptrs.size(), + reinterpret_cast(temp_ptr), static_cast(temp_size), + reinterpret_cast(metadata_ptr), output_ptrs.data(), output_sizes.data(), stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong chunk_size) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong chunk_size) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -361,16 +330,13 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize(JNIEnv* env, input_ptrs.size(), &opts, &temp_size); check_nvcomp_status(env, status); return static_cast(temp_size); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlongArray JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong chunk_size, - jlong temp_ptr, - jlong temp_size) { +JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong chunk_size, jlong temp_ptr, + jlong temp_size) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -386,30 +352,22 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize(JNIEnv* env nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; std::vector output_sizes(input_ptrs.size()); - auto status = nvcompBatchedLZ4CompressGetOutputSize(input_ptrs.data(), input_sizes.data(), - input_ptrs.size(), &opts, - reinterpret_cast(temp_ptr), - static_cast(temp_size), - output_sizes.data()); + auto status = nvcompBatchedLZ4CompressGetOutputSize( + input_ptrs.data(), input_sizes.data(), input_ptrs.size(), &opts, + reinterpret_cast(temp_ptr), static_cast(temp_size), output_sizes.data()); check_nvcomp_status(env, status); cudf::jni::native_jlongArray jsizes(env, input_ptrs.size()); std::transform(output_sizes.begin(), output_sizes.end(), jsizes.data(), [](size_t x) -> jlong { return static_cast(x); }); return jsizes.get_jArray(); - } CATCH_STD(env, NULL); + } + CATCH_STD(env, NULL); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync(JNIEnv* env, jclass, - jlong compressed_sizes_out_ptr, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong chunk_size, - jlong temp_ptr, - jlong temp_size, - jlongArray out_ptrs, - jlongArray out_sizes, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync( + JNIEnv *env, jclass, jlong compressed_sizes_out_ptr, jlongArray in_ptrs, jlongArray in_sizes, + jlong chunk_size, jlong temp_ptr, jlong temp_size, jlongArray out_ptrs, jlongArray out_sizes, + jlong jstream) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -431,30 +389,26 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync(JNIEnv* env, jclass cudf::jni::throw_java_exception(env, NVCOMP_ERROR_CLASS, "input/output array size mismatch"); } - auto output_sizes = reinterpret_cast(compressed_sizes_out_ptr); - std::transform(output_jsizes.data(), output_jsizes.data() + output_jsizes.size(), - output_sizes, + auto output_sizes = reinterpret_cast(compressed_sizes_out_ptr); + std::transform(output_jsizes.data(), output_jsizes.data() + output_jsizes.size(), output_sizes, [](jlong x) -> size_t { return static_cast(x); }); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; auto stream = reinterpret_cast(jstream); - auto status = nvcompBatchedLZ4CompressAsync(input_ptrs.data(), input_sizes.data(), - input_ptrs.size(), &opts, - reinterpret_cast(temp_ptr), - static_cast(temp_size), - output_ptrs.data(), - output_sizes, // input/output parameter - stream); + auto status = nvcompBatchedLZ4CompressAsync( + input_ptrs.data(), input_sizes.data(), input_ptrs.size(), &opts, + reinterpret_cast(temp_ptr), static_cast(temp_size), output_ptrs.data(), + output_sizes, // input/output parameter + stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -467,16 +421,13 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize(JNIEnv *env, jc comp_type, &opts, &temp_size); check_nvcomp_status(env, status); return temp_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, - jlong temp_ptr, jlong temp_size, - jboolean compute_exact) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jboolean compute_exact) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -485,23 +436,19 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize(JNIEnv *env, opts.num_deltas = num_deltas; opts.use_bp = use_bp; size_t out_size; - auto status = nvcompCascadedCompressGetOutputSize(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - &out_size, compute_exact); + auto status = nvcompCascadedCompressGetOutputSize( + reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, &out_size, compute_exact); check_nvcomp_status(env, status); return out_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jlong out_ptr, + jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -511,28 +458,23 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress(JNIEnv *env, jclass, opts.use_bp = use_bp; auto stream = reinterpret_cast(jstream); size_t compressed_size = out_size; - auto status = nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), &compressed_size, - stream); + auto status = + nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), &compressed_size, stream); check_nvcomp_status(env, status); if (cudaStreamSynchronize(stream) != cudaSuccess) { JNI_THROW_NEW(env, NVCOMP_CUDA_ERROR_CLASS, "Error synchronizing stream", 0); } return compressed_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync(JNIEnv *env, jclass, - jlong compressed_output_ptr, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync( + JNIEnv *env, jclass, jlong compressed_output_ptr, jlong in_ptr, jlong in_size, jint input_type, + jint num_rles, jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jlong out_ptr, + jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -543,13 +485,13 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync(JNIEnv *env, jclass, auto stream = reinterpret_cast(jstream); auto compressed_size_ptr = reinterpret_cast(compressed_output_ptr); *compressed_size_ptr = out_size; - auto status = nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), - compressed_size_ptr, stream); + auto status = + nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), compressed_size_ptr, stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } } // extern "C" diff --git a/java/src/main/native/src/NvtxRangeJni.cpp b/java/src/main/native/src/NvtxRangeJni.cpp index ea7a148fb4d..afd96632187 100644 --- a/java/src/main/native/src/NvtxRangeJni.cpp +++ b/java/src/main/native/src/NvtxRangeJni.cpp @@ -21,16 +21,15 @@ namespace { struct java_domain { - static constexpr char const* name{"Java"}; + static constexpr char const *name{"Java"}; }; } // anonymous namespace extern "C" { -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, - jstring name, jint color_bits) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, jstring name, + jint color_bits) { try { cudf::jni::native_jstring range_name(env, name); nvtx3::color range_color(static_cast(color_bits)); @@ -40,8 +39,7 @@ Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, CATCH_STD(env, ); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_NvtxRange_pop(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_NvtxRange_pop(JNIEnv *env, jclass clazz) { try { nvtxDomainRangePop(nvtx3::domain::get()); } diff --git a/java/src/main/native/src/ScalarJni.cpp b/java/src/main/native/src/ScalarJni.cpp index 95f934ff91b..7da78c996e7 100644 --- a/java/src/main/native/src/ScalarJni.cpp +++ b/java/src/main/native/src/ScalarJni.cpp @@ -409,30 +409,29 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeTimestampTimeScalar(JNIEn } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeDecimal32Scalar(JNIEnv *env, jclass, - jint value, - jint scale, + jint value, jint scale, jboolean is_valid) { try { cudf::jni::auto_set_device(env); auto const value_ = static_cast(value); auto const scale_ = numeric::scale_type{static_cast(scale)}; - std::unique_ptr s = cudf::make_fixed_point_scalar(value_, scale_); + std::unique_ptr s = + cudf::make_fixed_point_scalar(value_, scale_); s->set_valid(is_valid); return reinterpret_cast(s.release()); } CATCH_STD(env, 0); } - JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeDecimal64Scalar(JNIEnv *env, jclass, - jlong value, - jint scale, + jlong value, jint scale, jboolean is_valid) { try { cudf::jni::auto_set_device(env); auto const value_ = static_cast(value); auto const scale_ = numeric::scale_type{static_cast(scale)}; - std::unique_ptr s = cudf::make_fixed_point_scalar(value_, scale_); + std::unique_ptr s = + cudf::make_fixed_point_scalar(value_, scale_); s->set_valid(is_valid); return reinterpret_cast(s.release()); } @@ -451,8 +450,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_binaryOpSV(JNIEnv *env, jclas cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation( - *lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -470,7 +468,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeListScalar(JNIEnv *env, j // is false, always passes the input view to the scalar, to avoid copying the column // twice. // Let the Java layer make sure the view is empty when `is_valid` is false. - cudf::scalar* s = new cudf::list_scalar(*col_view); + cudf::scalar *s = new cudf::list_scalar(*col_view); s->set_valid(is_valid); return reinterpret_cast(s); } diff --git a/java/src/main/native/src/TableJni.cpp b/java/src/main/native/src/TableJni.cpp index 3799a5dbab3..fcb4444ec1a 100644 --- a/java/src/main/native/src/TableJni.cpp +++ b/java/src/main/native/src/TableJni.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include #include #include @@ -44,8 +46,6 @@ #include "jni_utils.hpp" #include "row_conversion.hpp" -#include - namespace cudf { namespace jni { @@ -255,7 +255,7 @@ class native_arrow_ipc_writer_handle final { initialized = false; } - std::vector get_column_metadata(const cudf::table_view& tview) { + std::vector get_column_metadata(const cudf::table_view &tview) { if (!column_names.empty() && columns_meta.empty()) { // Rebuild the structure of column meta according to table schema. // All the tables written by this writer should share the same schema, @@ -276,7 +276,7 @@ class native_arrow_ipc_writer_handle final { } private: - cudf::column_metadata build_one_column_meta(const cudf::column_view& cview, size_t& idx, + cudf::column_metadata build_one_column_meta(const cudf::column_view &cview, size_t &idx, const bool consume_name = true) { auto col_meta = cudf::column_metadata{}; if (consume_name) { @@ -301,7 +301,7 @@ class native_arrow_ipc_writer_handle final { return col_meta; } - std::string& get_column_name(const size_t idx) { + std::string &get_column_name(const size_t idx) { if (idx < 0 || idx >= column_names.size()) { throw cudf::jni::jni_exception("Missing names for columns or nested struct columns"); } @@ -628,9 +628,9 @@ std::vector resolve_column_order(JNIEnv *env, jbooleanArray jkeys_s std::vector column_order(keys_sort_num); if (keys_sort_num > 0) { std::transform(keys_sort_desc.data(), keys_sort_desc.data() + keys_sort_num, - column_order.begin(), - [](jboolean is_desc) { return is_desc ? cudf::order::DESCENDING - : cudf::order::ASCENDING; }); + column_order.begin(), [](jboolean is_desc) { + return is_desc ? cudf::order::DESCENDING : cudf::order::ASCENDING; + }); } return column_order; } @@ -649,9 +649,9 @@ std::vector resolve_null_precedence(JNIEnv *env, jbooleanArray std::vector null_precedence(null_order_num); if (null_order_num > 0) { std::transform(keys_null_first.data(), keys_null_first.data() + null_order_num, - null_precedence.begin(), - [](jboolean null_before) { return null_before ? cudf::null_order::BEFORE - : cudf::null_order::AFTER; }); + null_precedence.begin(), [](jboolean null_before) { + return null_before ? cudf::null_order::BEFORE : cudf::null_order::AFTER; + }); } return null_precedence; } @@ -659,11 +659,11 @@ std::vector resolve_null_precedence(JNIEnv *env, jbooleanArray namespace { int set_column_metadata(cudf::io::column_in_metadata &column_metadata, - std::vector &col_names, - cudf::jni::native_jbooleanArray &nullability, - cudf::jni::native_jbooleanArray &isInt96, - cudf::jni::native_jintArray &precisions, - cudf::jni::native_jintArray &children, int num_children, int read_index) { + std::vector &col_names, + cudf::jni::native_jbooleanArray &nullability, + cudf::jni::native_jbooleanArray &isInt96, + cudf::jni::native_jintArray &precisions, + cudf::jni::native_jintArray &children, int num_children, int read_index) { int write_index = 0; for (int i = 0; i < num_children; i++, write_index++) { cudf::io::column_in_metadata child; @@ -681,11 +681,11 @@ int set_column_metadata(cudf::io::column_in_metadata &column_metadata, return read_index; } -void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_names, jintArray &j_children, - jbooleanArray &j_col_nullability, jobjectArray &j_metadata_keys, - jobjectArray &j_metadata_values, jint j_compression, jint j_stats_freq, - jbooleanArray &j_isInt96, jintArray &j_precisions, - cudf::io::table_input_metadata& metadata) { +void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_names, + jintArray &j_children, jbooleanArray &j_col_nullability, + jobjectArray &j_metadata_keys, jobjectArray &j_metadata_values, + jint j_compression, jint j_stats_freq, jbooleanArray &j_isInt96, + jintArray &j_precisions, cudf::io::table_input_metadata &metadata) { cudf::jni::auto_set_device(env); cudf::jni::native_jstringArray col_names(env, j_col_names); cudf::jni::native_jbooleanArray col_nullability(env, j_col_nullability); @@ -709,14 +709,14 @@ void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_nam .set_decimal_precision(precisions[read_index]); int childs_children = children[read_index++]; if (childs_children > 0) { - read_index = set_column_metadata(metadata.column_metadata[write_index], cpp_names, - col_nullability, isInt96, precisions, children, childs_children, read_index); + read_index = + set_column_metadata(metadata.column_metadata[write_index], cpp_names, col_nullability, + isInt96, precisions, children, childs_children, read_index); } } for (auto i = 0; i < meta_keys.size(); ++i) { metadata.user_data[meta_keys[i].get()] = meta_values[i].get(); } - } // Check that window parameters are valid. @@ -845,8 +845,7 @@ jlongArray combine_join_results(JNIEnv *env, cudf::table &left_results, extern "C" { -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_createCudfTableView(JNIEnv *env, - jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_createCudfTableView(JNIEnv *env, jclass, jlongArray j_cudf_columns) { JNI_NULL_CHECK(env, j_cudf_columns, "columns are null", 0); @@ -927,13 +926,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_sortOrder(JNIEnv *env, jclass, jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); std::vector order(n_is_descending.size()); for (int i = 0; i < n_is_descending.size(); i++) { @@ -956,7 +955,6 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_sortOrder(JNIEnv *env, jclass, CATCH_STD(env, 0); } - JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_orderBy(JNIEnv *env, jclass, jlong j_input_table, jlongArray j_sort_keys_columns, @@ -978,13 +976,13 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_orderBy(JNIEnv *env, jcla jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and areNullsSmallest lengths don't match", 0); + "columns and areNullsSmallest lengths don't match", 0); std::vector order(n_is_descending.size()); for (int i = 0; i < n_is_descending.size(); i++) { @@ -1032,13 +1030,13 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_merge(JNIEnv *env, jclass jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", NULL); + "columns and is_descending lengths don't match", NULL); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and areNullsSmallest lengths don't match", NULL); + "columns and areNullsSmallest lengths don't match", NULL); std::vector indexes(n_sort_key_indexes.size()); for (int i = 0; i < n_sort_key_indexes.size(); i++) { @@ -1129,8 +1127,8 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readCSV( } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readParquet( - JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, - jlong buffer, jlong buffer_length, jint unit, jboolean strict_decimal_types) { + JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, jlong buffer, + jlong buffer_length, jint unit, jboolean strict_decimal_types) { bool read_buffer = true; if (buffer == 0) { JNI_NULL_CHECK(env, inputfilepath, "input file or buffer must be supplied", NULL); @@ -1186,14 +1184,14 @@ JNIEXPORT long JNICALL Java_ai_rapids_cudf_Table_writeParquetBufferBegin( try { std::unique_ptr data_sink( new cudf::jni::jni_writer_data_sink(env, consumer)); - + using namespace cudf::io; using namespace cudf::jni; sink_info sink{data_sink.get()}; table_input_metadata metadata; - createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, j_metadata_keys, - j_metadata_values, j_compression, j_stats_freq, j_isInt96, j_precisions, - metadata); + createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, + j_metadata_keys, j_metadata_values, j_compression, j_stats_freq, j_isInt96, + j_precisions, metadata); chunked_parquet_writer_options opts = chunked_parquet_writer_options::builder(sink) @@ -1222,11 +1220,12 @@ JNIEXPORT long JNICALL Java_ai_rapids_cudf_Table_writeParquetFileBegin( try { cudf::jni::native_jstring output_path(env, j_output_path); - using namespace cudf::io; - using namespace cudf::jni; + using namespace cudf::io; + using namespace cudf::jni; table_input_metadata metadata; - createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, j_metadata_keys, - j_metadata_values, j_compression, j_stats_freq, j_isInt96, j_precisions, metadata); + createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, + j_metadata_keys, j_metadata_values, j_compression, j_stats_freq, j_isInt96, + j_precisions, metadata); sink_info sink{output_path.get()}; chunked_parquet_writer_options opts = chunked_parquet_writer_options::builder(sink) @@ -1281,8 +1280,8 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_Table_writeParquetEnd(JNIEnv *env, jc } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readORC( - JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, - jlong buffer, jlong buffer_length, jboolean usingNumPyTypes, jint unit) { + JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, jlong buffer, + jlong buffer_length, jboolean usingNumPyTypes, jint unit) { bool read_buffer = true; if (buffer == 0) { JNI_NULL_CHECK(env, inputfilepath, "input file or buffer must be supplied", NULL); @@ -1790,10 +1789,10 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_leftSemiJoin( std::vector right_join_cols( right_join_cols_arr.data(), right_join_cols_arr.data() + right_join_cols_arr.size()); - std::unique_ptr result = cudf::left_semi_join( - *n_left_table, *n_right_table, left_join_cols, right_join_cols, - static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : - cudf::null_equality::UNEQUAL); + std::unique_ptr result = + cudf::left_semi_join(*n_left_table, *n_right_table, left_join_cols, right_join_cols, + static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : + cudf::null_equality::UNEQUAL); return cudf::jni::convert_table_for_return(env, result); } @@ -1819,10 +1818,10 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_leftAntiJoin( std::vector right_join_cols( right_join_cols_arr.data(), right_join_cols_arr.data() + right_join_cols_arr.size()); - std::unique_ptr result = cudf::left_anti_join( - *n_left_table, *n_right_table, left_join_cols, right_join_cols, - static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : - cudf::null_equality::UNEQUAL); + std::unique_ptr result = + cudf::left_anti_join(*n_left_table, *n_right_table, left_join_cols, right_join_cols, + static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : + cudf::null_equality::UNEQUAL); return cudf::jni::convert_table_for_return(env, result); } @@ -1895,7 +1894,8 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_crossJoin(JNIEnv *env, jc JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_interleaveColumns(JNIEnv *env, jclass, jlongArray j_cudf_table_view) { - JNI_NULL_CHECK(env, j_cudf_table_view, "table is null", 0); try { + JNI_NULL_CHECK(env, j_cudf_table_view, "table is null", 0); + try { cudf::jni::auto_set_device(env); cudf::table_view *table_view = reinterpret_cast(j_cudf_table_view); std::unique_ptr result = cudf::interleave_columns(*table_view); @@ -1943,9 +1943,7 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_partition(JNIEnv *env, jc cudf::column_view *n_part_column = reinterpret_cast(partition_column); cudf::jni::native_jintArray n_output_offsets(env, output_offsets); - auto result = cudf::partition(*n_input_table, - *n_part_column, - number_of_partitions); + auto result = cudf::partition(*n_input_table, *n_part_column, number_of_partitions); for (size_t i = 0; i < result.second.size() - 1; i++) { // for what ever reason partition returns the length of the result at then @@ -1959,12 +1957,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_partition(JNIEnv *env, jc CATCH_STD(env, NULL); } -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition(JNIEnv *env, jclass, - jlong input_table, - jintArray columns_to_hash, - jint hash_function, - jint number_of_partitions, - jintArray output_offsets) { +JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition( + JNIEnv *env, jclass, jlong input_table, jintArray columns_to_hash, jint hash_function, + jint number_of_partitions, jintArray output_offsets) { JNI_NULL_CHECK(env, input_table, "input table is null", NULL); JNI_NULL_CHECK(env, columns_to_hash, "columns_to_hash is null", NULL); @@ -1986,10 +1981,7 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition(JNIEnv *env } std::pair, std::vector> result = - cudf::hash_partition(*n_input_table, - columns_to_hash_vec, - number_of_partitions, - hash_func); + cudf::hash_partition(*n_input_table, columns_to_hash_vec, number_of_partitions, hash_func); for (size_t i = 0; i < result.second.size(); i++) { n_output_offsets[i] = result.second[i]; @@ -2025,9 +2017,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_roundRobinPartition( } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_groupByAggregate( - JNIEnv *env, jclass, jlong input_table, jintArray keys, - jintArray aggregate_column_indices, jlongArray agg_instances, jboolean ignore_null_keys, - jboolean jkey_sorted, jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { + JNIEnv *env, jclass, jlong input_table, jintArray keys, jintArray aggregate_column_indices, + jlongArray agg_instances, jboolean ignore_null_keys, jboolean jkey_sorted, + jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { JNI_NULL_CHECK(env, input_table, "input table is null", NULL); JNI_NULL_CHECK(env, keys, "input keys are null", NULL); JNI_NULL_CHECK(env, aggregate_column_indices, "input aggregate_column_indices are null", NULL); @@ -2046,16 +2038,11 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_groupByAggregate( } cudf::table_view n_keys_table(n_keys_cols); - auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, - n_keys.size()); - auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, - n_keys.size()); - cudf::groupby::groupby grouper(n_keys_table, - ignore_null_keys ? cudf::null_policy::EXCLUDE - : cudf::null_policy::INCLUDE, - jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO, - column_order, - null_precedence); + auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, n_keys.size()); + auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, n_keys.size()); + cudf::groupby::groupby grouper( + n_keys_table, ignore_null_keys ? cudf::null_policy::EXCLUDE : cudf::null_policy::INCLUDE, + jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO, column_order, null_precedence); // Aggregates are passed in already grouped by column, so we just need to fill it in // as we go. @@ -2248,8 +2235,8 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplit(JNIEnv cudf::jni::native_jobjectArray n_result = cudf::jni::contiguous_table_array(env, result.size()); for (size_t i = 0; i < result.size(); i++) { - n_result.set(i, cudf::jni::contiguous_table_from(env, result[i].data, - result[i].table.num_rows())); + n_result.set( + i, cudf::jni::contiguous_table_from(env, result[i].data, result[i].table.num_rows())); } return n_result.wrapped(); } @@ -2294,8 +2281,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rollingWindowAggregate( std::vector> result_columns; for (int i(0); i < values.size(); ++i) { - cudf::rolling_aggregation * agg = dynamic_cast(agg_instances[i]); - JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", nullptr); + cudf::rolling_aggregation *agg = dynamic_cast(agg_instances[i]); + JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", + nullptr); int agg_column_index = values[i]; if (default_output[i] != nullptr) { @@ -2303,9 +2291,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rollingWindowAggregate( groupby_keys, input_table->column(agg_column_index), *default_output[i], preceding[i], following[i], min_periods[i], *agg))); } else { - result_columns.emplace_back(std::move(cudf::grouped_rolling_window( - groupby_keys, input_table->column(agg_column_index), preceding[i], following[i], - min_periods[i], *agg))); + result_columns.emplace_back(std::move( + cudf::grouped_rolling_window(groupby_keys, input_table->column(agg_column_index), + preceding[i], following[i], min_periods[i], *agg))); } } @@ -2319,9 +2307,8 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_timeRangeRollingWindowAgg JNIEnv *env, jclass, jlong j_input_table, jintArray j_keys, jintArray j_timestamp_column_indices, jbooleanArray j_is_timestamp_ascending, jintArray j_aggregate_column_indices, jlongArray j_agg_instances, jintArray j_min_periods, - jintArray j_preceding, jintArray j_following, - jbooleanArray j_unbounded_preceding, jbooleanArray j_unbounded_following, - jboolean ignore_null_keys) { + jintArray j_preceding, jintArray j_following, jbooleanArray j_unbounded_preceding, + jbooleanArray j_unbounded_following, jboolean ignore_null_keys) { JNI_NULL_CHECK(env, j_input_table, "input table is null", NULL); JNI_NULL_CHECK(env, j_keys, "input keys are null", NULL); @@ -2362,23 +2349,19 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_timeRangeRollingWindowAgg for (int i(0); i < values.size(); ++i) { int agg_column_index = values[i]; - cudf::rolling_aggregation * agg = dynamic_cast(agg_instances[i]); - JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", nullptr); - - result_columns.emplace_back( - std::move( - cudf::grouped_time_range_rolling_window( - groupby_keys, - input_table->column(timestamps[i]), - timestamp_ascending[i] ? cudf::order::ASCENDING : cudf::order::DESCENDING, - input_table->column(agg_column_index), - unbounded_preceding[i] ? cudf::window_bounds::unbounded() : cudf::window_bounds::get(preceding[i]), - unbounded_following[i] ? cudf::window_bounds::unbounded() : cudf::window_bounds::get(following[i]), - min_periods[i], - *agg - ) - ) - ); + cudf::rolling_aggregation *agg = dynamic_cast(agg_instances[i]); + JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", + nullptr); + + result_columns.emplace_back(std::move(cudf::grouped_time_range_rolling_window( + groupby_keys, input_table->column(timestamps[i]), + timestamp_ascending[i] ? cudf::order::ASCENDING : cudf::order::DESCENDING, + input_table->column(agg_column_index), + unbounded_preceding[i] ? cudf::window_bounds::unbounded() : + cudf::window_bounds::get(preceding[i]), + unbounded_following[i] ? cudf::window_bounds::unbounded() : + cudf::window_bounds::get(following[i]), + min_periods[i], *agg))); } auto result_table = std::make_unique(std::move(result_columns)); @@ -2443,24 +2426,20 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_explodeOuterPosition(JNIE CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_rowBitCount(JNIEnv* env, jclass, jlong j_table) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_rowBitCount(JNIEnv *env, jclass, jlong j_table) { JNI_NULL_CHECK(env, j_table, "table is null", 0); try { cudf::jni::auto_set_device(env); - auto t = reinterpret_cast(j_table); + auto t = reinterpret_cast(j_table); std::unique_ptr result = cudf::row_bit_count(*t); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); } -JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(JNIEnv *env, jclass, - jlong jinput_table, - jintArray jkey_indices, - jboolean jignore_null_keys, - jboolean jkey_sorted, - jbooleanArray jkeys_sort_desc, - jbooleanArray jkeys_null_first) { +JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups( + JNIEnv *env, jclass, jlong jinput_table, jintArray jkey_indices, jboolean jignore_null_keys, + jboolean jkey_sorted, jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { JNI_NULL_CHECK(env, jinput_table, "table native handle is null", 0); JNI_NULL_CHECK(env, jkey_indices, "key indices are null", 0); // Two main steps to split the groups in the input table. @@ -2478,17 +2457,16 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J std::vector key_indices(n_key_indices.data(), n_key_indices.data() + n_key_indices.size()); auto keys = input_table->select(key_indices); - auto null_handling = jignore_null_keys ? cudf::null_policy::EXCLUDE - : cudf::null_policy::INCLUDE; + auto null_handling = + jignore_null_keys ? cudf::null_policy::EXCLUDE : cudf::null_policy::INCLUDE; auto keys_are_sorted = jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO; - auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, - key_indices.size()); - auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, - key_indices.size()); + auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, key_indices.size()); + auto null_precedence = + cudf::jni::resolve_null_precedence(env, jkeys_null_first, key_indices.size()); // Constructs a groupby - cudf::groupby::groupby grouper(keys, null_handling, keys_are_sorted, - column_order, null_precedence); + cudf::groupby::groupby grouper(keys, null_handling, keys_are_sorted, column_order, + null_precedence); // 1) Gets the groups(keys, offsets, values) from groupby. // @@ -2505,7 +2483,7 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J // not key column, so adds it as value column. value_indices.emplace_back(index); } - index ++; + index++; } cudf::table_view values_view = input_table->select(value_indices); cudf::groupby::groupby::groups groups = grouper.get_groups(values_view); @@ -2518,31 +2496,32 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J auto key_view_it = key_view.begin(); for (auto key_id : key_indices) { grouped_cols.at(key_id) = std::move(*key_view_it); - key_view_it ++; + key_view_it++; } // value columns auto value_view = groups.values->view(); auto value_view_it = value_view.begin(); for (auto value_id : value_indices) { grouped_cols.at(value_id) = std::move(*value_view_it); - value_view_it ++; + value_view_it++; } cudf::table_view grouped_table(grouped_cols); // When no key columns, uses the input table instead, because the output // of 'get_groups' is empty. - auto& grouped_view = key_indices.empty() ? *input_table : grouped_table; + auto &grouped_view = key_indices.empty() ? *input_table : grouped_table; // Resolves the split indices from offsets vector directly to avoid copying. Since // the offsets vector may be very large if there are too many small groups. - std::vector& split_indices = groups.offsets; + std::vector &split_indices = groups.offsets; // Offsets laysout is [0, split indices..., num_rows] or [0] for empty keys, so // need to removes the first and last elements. split_indices.erase(split_indices.begin()); - if (!split_indices.empty()) { split_indices.pop_back(); } + if (!split_indices.empty()) { + split_indices.pop_back(); + } // 2) Splits the groups. - std::vector result = - cudf::contiguous_split(grouped_view, split_indices); + std::vector result = cudf::contiguous_split(grouped_view, split_indices); // Release the grouped table right away after split done. groups.keys.reset(nullptr); groups.values.reset(nullptr); @@ -2551,8 +2530,8 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J cudf::jni::native_jobjectArray n_result = cudf::jni::contiguous_table_array(env, result.size()); for (size_t i = 0; i < result.size(); i++) { - n_result.set(i, cudf::jni::contiguous_table_from(env, result[i].data, - result[i].table.num_rows())); + n_result.set( + i, cudf::jni::contiguous_table_from(env, result[i].data, result[i].table.num_rows())); } return n_result.wrapped(); } diff --git a/java/src/main/native/src/cudf_jni_apis.hpp b/java/src/main/native/src/cudf_jni_apis.hpp index 14999156890..fbcca0c82ee 100644 --- a/java/src/main/native/src/cudf_jni_apis.hpp +++ b/java/src/main/native/src/cudf_jni_apis.hpp @@ -75,7 +75,7 @@ void auto_set_device(JNIEnv *env); * The operation has not necessarily completed when this returns, but it could overlap with * operations occurring on other streams. */ -void device_memset_async(JNIEnv *env, rmm::device_buffer& buf, char value); +void device_memset_async(JNIEnv *env, rmm::device_buffer &buf, char value); } // namespace jni } // namespace cudf diff --git a/java/src/main/native/src/dtype_utils.hpp b/java/src/main/native/src/dtype_utils.hpp index bde7bd2894e..9fae0c585e6 100644 --- a/java/src/main/native/src/dtype_utils.hpp +++ b/java/src/main/native/src/dtype_utils.hpp @@ -15,9 +15,10 @@ */ #pragma once -#include #include +#include + namespace cudf { namespace jni { @@ -25,9 +26,7 @@ namespace jni { inline cudf::data_type timestamp_to_duration(cudf::data_type dt) { cudf::type_id duration_type_id; switch (dt.id()) { - case cudf::type_id::TIMESTAMP_DAYS: - duration_type_id = cudf::type_id::DURATION_DAYS; - break; + case cudf::type_id::TIMESTAMP_DAYS: duration_type_id = cudf::type_id::DURATION_DAYS; break; case cudf::type_id::TIMESTAMP_SECONDS: duration_type_id = cudf::type_id::DURATION_SECONDS; break; @@ -40,14 +39,13 @@ inline cudf::data_type timestamp_to_duration(cudf::data_type dt) { case cudf::type_id::TIMESTAMP_NANOSECONDS: duration_type_id = cudf::type_id::DURATION_NANOSECONDS; break; - default: - throw std::logic_error("Unexpected type in timestamp_to_duration"); + default: throw std::logic_error("Unexpected type in timestamp_to_duration"); } return cudf::data_type(duration_type_id); } inline bool is_decimal_type(cudf::type_id n_type) { - return n_type == cudf::type_id::DECIMAL32 || n_type == cudf::type_id::DECIMAL64 ; + return n_type == cudf::type_id::DECIMAL32 || n_type == cudf::type_id::DECIMAL64; } // create data_type including scale for decimal type diff --git a/java/src/main/native/src/map_lookup.cu b/java/src/main/native/src/map_lookup.cu index 0ba683b45f1..82e6714967a 100644 --- a/java/src/main/native/src/map_lookup.cu +++ b/java/src/main/native/src/map_lookup.cu @@ -157,9 +157,9 @@ std::unique_ptr map_lookup(column_view const &map_column, string_scalar auto values_column = structs_column.child(1); auto table_for_gather = table_view{std::vector{values_column}}; - auto gathered_table = cudf::detail::gather( - table_for_gather, gather_map->view(), out_of_bounds_policy::NULLIFY, - detail::negative_index_policy::NOT_ALLOWED, stream, mr); + auto gathered_table = + cudf::detail::gather(table_for_gather, gather_map->view(), out_of_bounds_policy::NULLIFY, + detail::negative_index_policy::NOT_ALLOWED, stream, mr); return std::make_unique(std::move(gathered_table->get_column(0))); } diff --git a/java/src/main/native/src/prefix_sum.cu b/java/src/main/native/src/prefix_sum.cu index e3c53696185..277ca1d4dc1 100644 --- a/java/src/main/native/src/prefix_sum.cu +++ b/java/src/main/native/src/prefix_sum.cu @@ -14,33 +14,27 @@ * limitations under the License. */ -#include - #include #include - #include -#include #include - +#include +#include namespace cudf { namespace jni { -std::unique_ptr prefix_sum(column_view const &value_column, - rmm::cuda_stream_view stream, +std::unique_ptr prefix_sum(column_view const &value_column, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource *mr) { // Defensive checks. CUDF_EXPECTS(value_column.type().id() == type_id::INT64, "Only longs are supported."); CUDF_EXPECTS(!value_column.has_nulls(), "NULLS are not supported"); - auto result = make_numeric_column(value_column.type(), value_column.size(), - mask_state::ALL_VALID, stream, mr); + auto result = make_numeric_column(value_column.type(), value_column.size(), mask_state::ALL_VALID, + stream, mr); - thrust::inclusive_scan(rmm::exec_policy(stream), - value_column.begin(), - value_column.end(), - result->mutable_view().begin()); + thrust::inclusive_scan(rmm::exec_policy(stream), value_column.begin(), + value_column.end(), result->mutable_view().begin()); return result; } diff --git a/java/src/main/native/src/prefix_sum.hpp b/java/src/main/native/src/prefix_sum.hpp index 8f39f9a8c69..ea58a027207 100644 --- a/java/src/main/native/src/prefix_sum.hpp +++ b/java/src/main/native/src/prefix_sum.hpp @@ -27,8 +27,7 @@ namespace jni { * @brief compute the prefix sum of a column of longs */ std::unique_ptr -prefix_sum(column_view const &value_column, - rmm::cuda_stream_view stream = rmm::cuda_stream_default, +prefix_sum(column_view const &value_column, rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); } // namespace jni diff --git a/python/cudf/cudf/_lib/aggregation.pxd b/python/cudf/cudf/_lib/aggregation.pxd index 56fa9fdc63e..f608dab3fe1 100644 --- a/python/cudf/cudf/_lib/aggregation.pxd +++ b/python/cudf/cudf/_lib/aggregation.pxd @@ -1,8 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.aggregation cimport aggregation -from cudf._lib.cpp.aggregation cimport rolling_aggregation + +from cudf._lib.cpp.aggregation cimport aggregation, rolling_aggregation cdef class Aggregation: diff --git a/python/cudf/cudf/_lib/aggregation.pyx b/python/cudf/cudf/_lib/aggregation.pyx index cda35025c7e..4c94452c73d 100644 --- a/python/cudf/cudf/_lib/aggregation.pyx +++ b/python/cudf/cudf/_lib/aggregation.pyx @@ -2,27 +2,30 @@ from enum import Enum -import pandas as pd import numba import numpy as np -from libcpp.string cimport string +import pandas as pd + from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector +from libcpp.string cimport string from libcpp.utility cimport move +from libcpp.vector cimport vector + +from cudf._lib.types import NullHandling, cudf_to_np_types, np_to_cudf_types from cudf.utils import cudautils -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types, NullHandling from cudf._lib.types cimport ( underlying_type_t_interpolation, underlying_type_t_null_policy, underlying_type_t_type_id, ) -from cudf._lib.types import Interpolation from numba.np import numpy_support -cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.types import Interpolation + cimport cudf._lib.cpp.aggregation as libcudf_aggregation +cimport cudf._lib.cpp.types as libcudf_types class AggregationKind(Enum): diff --git a/python/cudf/cudf/_lib/avro.pyx b/python/cudf/cudf/_lib/avro.pyx index ed98429a2d6..52ddbd8b8fb 100644 --- a/python/cudf/cudf/_lib/avro.pyx +++ b/python/cudf/cudf/_lib/avro.pyx @@ -1,14 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.io.avro cimport ( - avro_reader_options, - read_avro as libcudf_read_avro -) - from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector +from cudf._lib.cpp.io.avro cimport ( + avro_reader_options, + read_avro as libcudf_read_avro, +) from cudf._lib.cpp.io.types cimport table_with_metadata from cudf._lib.cpp.types cimport size_type from cudf._lib.io.utils cimport make_source_info diff --git a/python/cudf/cudf/_lib/binaryop.pxd b/python/cudf/cudf/_lib/binaryop.pxd index 3fb36055465..1f6022251b3 100644 --- a/python/cudf/cudf/_lib/binaryop.pxd +++ b/python/cudf/cudf/_lib/binaryop.pxd @@ -2,5 +2,4 @@ from libc.stdint cimport int32_t - ctypedef int32_t underlying_type_t_binary_operator diff --git a/python/cudf/cudf/_lib/binaryop.pyx b/python/cudf/cudf/_lib/binaryop.pyx index 5eaec640b15..d8d4fe0b40b 100644 --- a/python/cudf/cudf/_lib/binaryop.pyx +++ b/python/cudf/cudf/_lib/binaryop.pyx @@ -1,32 +1,33 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import numpy as np from enum import IntEnum +import numpy as np + from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.utility cimport move from cudf._lib.binaryop cimport underlying_type_t_binary_operator from cudf._lib.column cimport Column + from cudf._lib.replace import replace_nulls from cudf._lib.scalar import as_device_scalar + from cudf._lib.scalar cimport DeviceScalar + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport ( - data_type, - type_id, -) +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.types cimport data_type, type_id +from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id -from cudf.utils.dtypes import is_string_dtype, is_scalar +from cudf.utils.dtypes import is_scalar, is_string_dtype -from cudf._lib.cpp.binaryop cimport binary_operator cimport cudf._lib.cpp.binaryop as cpp_binaryop +from cudf._lib.cpp.binaryop cimport binary_operator class BinaryOperation(IntEnum): diff --git a/python/cudf/cudf/_lib/column.pxd b/python/cudf/cudf/_lib/column.pxd index 6fb834410e6..2df958466c6 100644 --- a/python/cudf/cudf/_lib/column.pxd +++ b/python/cudf/cudf/_lib/column.pxd @@ -5,12 +5,9 @@ from libcpp.memory cimport unique_ptr from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.types cimport size_type - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.types cimport size_type cdef class Column: diff --git a/python/cudf/cudf/_lib/column.pyi b/python/cudf/cudf/_lib/column.pyi index 3387a9f268e..bafa1c914fd 100644 --- a/python/cudf/cudf/_lib/column.pyi +++ b/python/cudf/cudf/_lib/column.pyi @@ -1,13 +1,13 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from __future__ import annotations -from typing import Tuple, Union, TypeVar, Optional -from cudf._typing import DtypeObj, Dtype, ScalarLike +from typing import Optional, Tuple, TypeVar, Union + +from cudf._typing import Dtype, DtypeObj, ScalarLike from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase - T = TypeVar("T") class Column: diff --git a/python/cudf/cudf/_lib/column.pyx b/python/cudf/cudf/_lib/column.pyx index a3e01a4ac9d..b5223a32a18 100644 --- a/python/cudf/cudf/_lib/column.pyx +++ b/python/cudf/cudf/_lib/column.pyx @@ -3,51 +3,54 @@ import cupy as cp import numpy as np import pandas as pd + import rmm import cudf - +import cudf._lib as libcudfxx from cudf.core.buffer import Buffer from cudf.utils.dtypes import ( is_categorical_dtype, is_decimal_dtype, is_list_dtype, - is_struct_dtype + is_struct_dtype, ) -import cudf._lib as libcudfxx from cpython.buffer cimport PyObject_CheckBuffer from libc.stdint cimport uintptr_t -from libcpp.pair cimport pair from libcpp cimport bool -from libcpp.memory cimport unique_ptr, make_unique -from libcpp.vector cimport vector +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move +from libcpp.vector cimport vector + +from rmm._lib.device_buffer cimport DeviceBuffer + from cudf._lib.cpp.strings.convert.convert_integers cimport ( - from_integers as cpp_from_integers + from_integers as cpp_from_integers, ) -from rmm._lib.device_buffer cimport DeviceBuffer +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types from cudf._lib.types cimport ( - underlying_type_t_type_id, dtype_from_column_view, - dtype_to_data_type + dtype_to_data_type, + underlying_type_t_type_id, ) + from cudf._lib.null_mask import bitmask_allocation_size_bytes +cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.unary as libcudf_unary from cudf._lib.cpp.column.column cimport column, column_contents -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.column.column_factories cimport ( make_column_from_scalar as cpp_make_column_from_scalar, - make_numeric_column + make_numeric_column, ) +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.scalar cimport DeviceScalar -cimport cudf._lib.cpp.types as libcudf_types -cimport cudf._lib.cpp.unary as libcudf_unary cdef class Column: diff --git a/python/cudf/cudf/_lib/concat.pyx b/python/cudf/cudf/_lib/concat.pyx index cef93798601..86778e0a9e1 100644 --- a/python/cudf/cudf/_lib/concat.pyx +++ b/python/cudf/cudf/_lib/concat.pyx @@ -1,29 +1,29 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr, make_unique -from libcpp.vector cimport vector +from libcpp.memory cimport make_unique, unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.concatenate cimport ( - concatenate_masks as libcudf_concatenate_masks, concatenate_columns as libcudf_concatenate_columns, - concatenate_tables as libcudf_concatenate_tables + concatenate_masks as libcudf_concatenate_masks, + concatenate_tables as libcudf_concatenate_tables, ) -from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.table.table cimport table, table_view - -from cudf._lib.column cimport Column from cudf._lib.table cimport Table from cudf._lib.utils cimport ( make_column_views, + make_table_data_views, make_table_views, - make_table_data_views ) from cudf.core.buffer import Buffer -from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + cpdef concat_masks(object columns): cdef device_buffer c_result diff --git a/python/cudf/cudf/_lib/copying.pyx b/python/cudf/cudf/_lib/copying.pyx index 548e16155dd..5780c0735ef 100644 --- a/python/cudf/cudf/_lib/copying.pyx +++ b/python/cudf/cudf/_lib/copying.pyx @@ -2,33 +2,33 @@ import pandas as pd +from libc.stdint cimport int32_t, int64_t from libcpp cimport bool -from libcpp.memory cimport make_unique, unique_ptr, shared_ptr, make_shared -from libcpp.vector cimport vector +from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr from libcpp.utility cimport move -from libc.stdint cimport int32_t, int64_t +from libcpp.vector cimport vector from cudf._lib.column cimport Column + from cudf._lib.scalar import as_device_scalar + from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table + from cudf._lib.reduce import minmax +cimport cudf._lib.cpp.copying as cpp_copying from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.libcpp.functional cimport reference_wrapper +from cudf._lib.cpp.lists.gather cimport ( + segmented_gather as cpp_segmented_gather, +) +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.lists.gather cimport ( - segmented_gather as cpp_segmented_gather -) -cimport cudf._lib.cpp.copying as cpp_copying # workaround for https://github.com/cython/cython/issues/3885 ctypedef const scalar constscalar diff --git a/python/cudf/cudf/_lib/cpp/aggregation.pxd b/python/cudf/cudf/_lib/cpp/aggregation.pxd index 839bdae7427..b13815c925d 100644 --- a/python/cudf/cudf/_lib/cpp/aggregation.pxd +++ b/python/cudf/cudf/_lib/cpp/aggregation.pxd @@ -1,14 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.string cimport string from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.vector cimport vector from cudf._lib.cpp.types cimport ( - size_type, data_type, interpolation, - null_policy + null_policy, + size_type, ) diff --git a/python/cudf/cudf/_lib/cpp/binaryop.pxd b/python/cudf/cudf/_lib/cpp/binaryop.pxd index 2e36070a164..3557ecd8487 100644 --- a/python/cudf/cudf/_lib/cpp/binaryop.pxd +++ b/python/cudf/cudf/_lib/cpp/binaryop.pxd @@ -4,11 +4,10 @@ from libcpp.memory cimport unique_ptr from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport ( - data_type -) +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.types cimport data_type + cdef extern from "cudf/binaryop.hpp" namespace "cudf" nogil: ctypedef enum binary_operator: diff --git a/python/cudf/cudf/_lib/cpp/column/column.pxd b/python/cudf/cudf/_lib/cpp/column/column.pxd index 8e880337f94..205a1548c54 100644 --- a/python/cudf/cudf/_lib/cpp/column/column.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column.pxd @@ -1,14 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from libcpp cimport bool from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.types cimport size_type, data_type -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) + +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/column/column.hpp" namespace "cudf" nogil: cdef cppclass column_contents "cudf::column::contents": diff --git a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd index 1da72160dfb..0f22e788bd7 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd @@ -1,14 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.types cimport ( - data_type, - mask_state, - size_type, -) +from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport scalar -from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.types cimport data_type, mask_state, size_type + cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_numeric_column(data_type type, diff --git a/python/cudf/cudf/_lib/cpp/column/column_view.pxd b/python/cudf/cudf/_lib/cpp/column/column_view.pxd index e711fd62f8f..39c1c958531 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_view.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_view.pxd @@ -1,13 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp cimport bool +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport ( - size_type, - data_type, - bitmask_type -) +from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type cdef extern from "cudf/column/column_view.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/concatenate.pxd b/python/cudf/cudf/_lib/cpp/concatenate.pxd index c776d23aa85..05068318962 100644 --- a/python/cudf/cudf/_lib/cpp/concatenate.pxd +++ b/python/cudf/cudf/_lib/cpp/concatenate.pxd @@ -3,11 +3,12 @@ from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from rmm._lib.device_buffer cimport device_buffer + from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.table.table cimport table, table_view from cudf._lib.cpp.utilities.host_span cimport host_span -from rmm._lib.device_buffer cimport device_buffer cdef extern from "cudf/concatenate.hpp" namespace "cudf" nogil: # The versions of concatenate taking vectors don't exist in libcudf diff --git a/python/cudf/cudf/_lib/cpp/copying.pxd b/python/cudf/cudf/_lib/cpp/copying.pxd index 55cbc3880ac..b3688248e2d 100644 --- a/python/cudf/cudf/_lib/cpp/copying.pxd +++ b/python/cudf/cudf/_lib/cpp/copying.pxd @@ -1,17 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from rmm._lib.device_buffer cimport device_buffer - -from libcpp cimport bool from libc.stdint cimport int32_t, int64_t +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from rmm._lib.device_buffer cimport device_buffer + from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.libcpp.functional cimport reference_wrapper from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table diff --git a/python/cudf/cudf/_lib/cpp/filling.pxd b/python/cudf/cudf/_lib/cpp/filling.pxd index 79bf3c496e8..42bdd827452 100644 --- a/python/cudf/cudf/_lib/cpp/filling.pxd +++ b/python/cudf/cudf/_lib/cpp/filling.pxd @@ -4,15 +4,11 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/filling.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/gpuarrow.pxd b/python/cudf/cudf/_lib/cpp/gpuarrow.pxd index 3e21d784b6f..6ebae78b5cd 100644 --- a/python/cudf/cudf/_lib/cpp/gpuarrow.pxd +++ b/python/cudf/cudf/_lib/cpp/gpuarrow.pxd @@ -1,13 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader from pyarrow.includes.libarrow cimport ( - CStatus, - CMessage, CBufferReader, - CMessageReader + CMessage, + CMessageReader, + CStatus, ) +from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader + cdef extern from "cudf/ipc.hpp" nogil: diff --git a/python/cudf/cudf/_lib/cpp/groupby.pxd b/python/cudf/cudf/_lib/cpp/groupby.pxd index 2225898d697..dea6feec857 100644 --- a/python/cudf/cudf/_lib/cpp/groupby.pxd +++ b/python/cudf/cudf/_lib/cpp/groupby.pxd @@ -1,16 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair -from libcpp cimport bool +from libcpp.vector cimport vector +from cudf._lib.cpp.aggregation cimport aggregation +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.aggregation cimport aggregation -from cudf._lib.cpp.types cimport size_type, order, null_order, null_policy +from cudf._lib.cpp.types cimport null_order, null_policy, order, size_type cdef extern from "cudf/groupby.hpp" \ diff --git a/python/cudf/cudf/_lib/cpp/hash.pxd b/python/cudf/cudf/_lib/cpp/hash.pxd index 5cecf50cd98..f07a6c0f046 100644 --- a/python/cudf/cudf/_lib/cpp/hash.pxd +++ b/python/cudf/cudf/_lib/cpp/hash.pxd @@ -4,10 +4,10 @@ from libc.stdint cimport uint32_t from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/hashing.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/interop.pxd b/python/cudf/cudf/_lib/cpp/interop.pxd index ed082e26853..e81f0d617fb 100644 --- a/python/cudf/cudf/_lib/cpp/interop.pxd +++ b/python/cudf/cudf/_lib/cpp/interop.pxd @@ -1,16 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.memory cimport shared_ptr -from libcpp.vector cimport vector +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string - +from libcpp.vector cimport vector from pyarrow.lib cimport CTable -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types + +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view + cdef extern from "dlpack/dlpack.h" nogil: ctypedef struct DLManagedTensor: void(*deleter)(DLManagedTensor*) except + diff --git a/python/cudf/cudf/_lib/cpp/io/avro.pxd b/python/cudf/cudf/_lib/cpp/io/avro.pxd index ac726cdd04d..6efe42e5208 100644 --- a/python/cudf/cudf/_lib/cpp/io/avro.pxd +++ b/python/cudf/cudf/_lib/cpp/io/avro.pxd @@ -3,8 +3,8 @@ from libcpp.string cimport string from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport size_type cimport cudf._lib.cpp.io.types as cudf_io_types +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/io/avro.hpp" \ diff --git a/python/cudf/cudf/_lib/cpp/io/csv.pxd b/python/cudf/cudf/_lib/cpp/io/csv.pxd index 6b6d36b3899..c5e235b5697 100644 --- a/python/cudf/cudf/_lib/cpp/io/csv.pxd +++ b/python/cudf/cudf/_lib/cpp/io/csv.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/csv.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/json.pxd b/python/cudf/cudf/_lib/cpp/io/json.pxd index 31a5afa2bac..6f20195e87f 100644 --- a/python/cudf/cudf/_lib/cpp/io/json.pxd +++ b/python/cudf/cudf/_lib/cpp/io/json.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/json.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/orc.pxd b/python/cudf/cudf/_lib/cpp/io/orc.pxd index 7449f2c510c..d5e874d796e 100644 --- a/python/cudf/cudf/_lib/cpp/io/orc.pxd +++ b/python/cudf/cudf/_lib/cpp/io/orc.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/orc.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd b/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd index e1128884491..57be1b1c90c 100644 --- a/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd +++ b/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.string cimport string +from libcpp.vector cimport vector cimport cudf._lib.cpp.io.types as cudf_io_types diff --git a/python/cudf/cudf/_lib/cpp/io/parquet.pxd b/python/cudf/cudf/_lib/cpp/io/parquet.pxd index 39da6b26502..e2053f8ce4f 100644 --- a/python/cudf/cudf/_lib/cpp/io/parquet.pxd +++ b/python/cudf/cudf/_lib/cpp/io/parquet.pxd @@ -1,15 +1,16 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool -from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.map cimport map from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t +from libcpp.string cimport string +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/parquet.hpp" namespace "cudf::io" nogil: cdef cppclass parquet_reader_options: diff --git a/python/cudf/cudf/_lib/cpp/io/types.pxd b/python/cudf/cudf/_lib/cpp/io/types.pxd index 907d7763579..7fa6406bd29 100644 --- a/python/cudf/cudf/_lib/cpp/io/types.pxd +++ b/python/cudf/cudf/_lib/cpp/io/types.pxd @@ -1,13 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr, shared_ptr -from libcpp.string cimport string from libcpp.map cimport map +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.pair cimport pair +from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.pair cimport pair from pyarrow.includes.libarrow cimport CRandomAccessFile + from cudf._lib.cpp.table.table cimport table diff --git a/python/cudf/cudf/_lib/cpp/join.pxd b/python/cudf/cudf/_lib/cpp/join.pxd index c221fea926d..171658c78ee 100644 --- a/python/cudf/cudf/_lib/cpp/join.pxd +++ b/python/cudf/cudf/_lib/cpp/join.pxd @@ -1,18 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector -from libcpp.pair cimport pair from libcpp cimport bool -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair +from libcpp.vector cimport vector + +from rmm._lib.device_uvector cimport device_uvector from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type -from rmm._lib.device_uvector cimport device_uvector - ctypedef unique_ptr[device_uvector[size_type]] gather_map_type diff --git a/python/cudf/cudf/_lib/cpp/labeling.pxd b/python/cudf/cudf/_lib/cpp/labeling.pxd index 996ae4f9e38..af9c4bb9a04 100644 --- a/python/cudf/cudf/_lib/cpp/labeling.pxd +++ b/python/cudf/cudf/_lib/cpp/labeling.pxd @@ -5,6 +5,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/labeling/label_bins.hpp" namespace "cudf" nogil: ctypedef enum inclusive: YES "cudf::inclusive::YES" diff --git a/python/cudf/cudf/_lib/cpp/lists/contains.pxd b/python/cudf/cudf/_lib/cpp/lists/contains.pxd index ec2f61d08fa..5790ae4e787 100644 --- a/python/cudf/cudf/_lib/cpp/lists/contains.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/contains.pxd @@ -1,12 +1,12 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.column.column_view cimport column_view cdef extern from "cudf/lists/contains.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] contains( diff --git a/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd b/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd index 57d6daefd37..9be38f26237 100644 --- a/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd @@ -5,5 +5,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view + cdef extern from "cudf/lists/count_elements.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] count_elements(const lists_column_view) except + diff --git a/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd b/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd index 40b1836f932..81d54104320 100644 --- a/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd @@ -2,9 +2,10 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.types cimport null_equality, nan_equality +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.types cimport nan_equality, null_equality + cdef extern from "cudf/lists/drop_list_duplicates.hpp" \ namespace "cudf::lists" nogil: diff --git a/python/cudf/cudf/_lib/cpp/lists/explode.pxd b/python/cudf/cudf/_lib/cpp/lists/explode.pxd index cd2d44d2e42..c3e15dd203c 100644 --- a/python/cudf/cudf/_lib/cpp/lists/explode.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/explode.pxd @@ -6,6 +6,7 @@ from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/lists/explode.hpp" namespace "cudf" nogil: cdef unique_ptr[table] explode_outer( const table_view, diff --git a/python/cudf/cudf/_lib/cpp/lists/extract.pxd b/python/cudf/cudf/_lib/cpp/lists/extract.pxd index 89fa893c17d..a023f728989 100644 --- a/python/cudf/cudf/_lib/cpp/lists/extract.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/extract.pxd @@ -4,9 +4,9 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view - from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/lists/extract.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] extract_list_element( const lists_column_view, diff --git a/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd b/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd index 3290f52fba7..aa18ede41bd 100644 --- a/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd @@ -1,8 +1,6 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view cdef extern from "cudf/lists/lists_column_view.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/lists/sorting.pxd b/python/cudf/cudf/_lib/cpp/lists/sorting.pxd index 55e8e09427c..2115885ed95 100644 --- a/python/cudf/cudf/_lib/cpp/lists/sorting.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/sorting.pxd @@ -2,9 +2,9 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport order, null_order from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.types cimport null_order, order cdef extern from "cudf/lists/sorting.hpp" namespace "cudf::lists" nogil: diff --git a/python/cudf/cudf/_lib/cpp/merge.pxd b/python/cudf/cudf/_lib/cpp/merge.pxd index b2d3d802e76..32fe14ac479 100644 --- a/python/cudf/cudf/_lib/cpp/merge.pxd +++ b/python/cudf/cudf/_lib/cpp/merge.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/merge.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/null_mask.pxd b/python/cudf/cudf/_lib/cpp/null_mask.pxd index b83c7a433c8..c225a16297b 100644 --- a/python/cudf/cudf/_lib/cpp/null_mask.pxd +++ b/python/cudf/cudf/_lib/cpp/null_mask.pxd @@ -4,8 +4,8 @@ from libc.stdint cimport int32_t from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.column.column_view cimport column_view cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.cpp.column.column_view cimport column_view ctypedef int32_t underlying_type_t_mask_state diff --git a/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd b/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd index 2a27cd3c338..38682854892 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd @@ -6,6 +6,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "nvtext/edit_distance.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] edit_distance( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd b/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd index 52a91cba057..06147df38f2 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd @@ -7,6 +7,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type + cdef extern from "nvtext/generate_ngrams.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] generate_ngrams( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd index d6145a8048d..d716df22546 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd @@ -7,6 +7,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type + cdef extern from "nvtext/ngrams_tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] ngrams_tokenize( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd index 7d8ec891692..f012670317a 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd @@ -6,6 +6,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "nvtext/normalize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] normalize_spaces( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd b/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd index 2de562e91b4..c4e5258a710 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd @@ -2,10 +2,10 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type cdef extern from "nvtext/replace.hpp" namespace "nvtext" nogil: diff --git a/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd b/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd index b8b816c212e..5a92b45b6dd 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd @@ -7,6 +7,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type + cdef extern from "nvtext/stemmer.hpp" namespace "nvtext" nogil: ctypedef enum letter_type: CONSONANT 'nvtext::letter_type::CONSONANT' diff --git a/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd index 013ce9de8f4..cdb39e3c7fa 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd @@ -1,10 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint16_t, uint32_t from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.string cimport string -from libc.stdint cimport uint16_t, uint32_t - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view diff --git a/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd index 2442c12de82..8b80f50e381 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd @@ -6,6 +6,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar + cdef extern from "nvtext/tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] tokenize( diff --git a/python/cudf/cudf/_lib/cpp/partitioning.pxd b/python/cudf/cudf/_lib/cpp/partitioning.pxd index 8f89c09e52c..5c58dbcc4ac 100644 --- a/python/cudf/cudf/_lib/cpp/partitioning.pxd +++ b/python/cudf/cudf/_lib/cpp/partitioning.pxd @@ -1,15 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libc.stdint cimport uint32_t -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.column.column_view cimport column_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/quantiles.pxd b/python/cudf/cudf/_lib/cpp/quantiles.pxd index f7817dfb97f..03fda16856c 100644 --- a/python/cudf/cudf/_lib/cpp/quantiles.pxd +++ b/python/cudf/cudf/_lib/cpp/quantiles.pxd @@ -1,19 +1,18 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view - from cudf._lib.cpp.types cimport ( interpolation, null_order, - order_info, order, + order_info, sorted, ) diff --git a/python/cudf/cudf/_lib/cpp/reduce.pxd b/python/cudf/cudf/_lib/cpp/reduce.pxd index dfe1ffd3669..53c8cd59468 100644 --- a/python/cudf/cudf/_lib/cpp/reduce.pxd +++ b/python/cudf/cudf/_lib/cpp/reduce.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.types cimport data_type -from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.aggregation cimport aggregation from libcpp.memory cimport unique_ptr from libcpp.utility cimport pair +from cudf._lib.aggregation cimport aggregation +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.types cimport data_type +from cudf._lib.scalar cimport DeviceScalar + cdef extern from "cudf/reduction.hpp" namespace "cudf" nogil: cdef unique_ptr[scalar] cpp_reduce "cudf::reduce" ( diff --git a/python/cudf/cudf/_lib/cpp/replace.pxd b/python/cudf/cudf/_lib/cpp/replace.pxd index 6fd844acb75..c1ec89a6233 100644 --- a/python/cudf/cudf/_lib/cpp/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/replace.pxd @@ -2,14 +2,12 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.scalar.scalar cimport scalar + cdef extern from "cudf/replace.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/reshape.pxd b/python/cudf/cudf/_lib/cpp/reshape.pxd index 2985b9282b3..5b9d40aa2ad 100644 --- a/python/cudf/cudf/_lib/cpp/reshape.pxd +++ b/python/cudf/cudf/_lib/cpp/reshape.pxd @@ -2,10 +2,11 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/reshape.hpp" namespace "cudf" nogil: cdef unique_ptr[column] interleave_columns( diff --git a/python/cudf/cudf/_lib/cpp/rolling.pxd b/python/cudf/cudf/_lib/cpp/rolling.pxd index 4ccc0f5ae9b..df2e833edc2 100644 --- a/python/cudf/cudf/_lib/cpp/rolling.pxd +++ b/python/cudf/cudf/_lib/cpp/rolling.pxd @@ -2,12 +2,12 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.aggregation cimport rolling_aggregation from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.aggregation cimport rolling_aggregation +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/rolling.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/round.pxd b/python/cudf/cudf/_lib/cpp/round.pxd index 78f18dcacce..66d76c35d72 100644 --- a/python/cudf/cudf/_lib/cpp/round.pxd +++ b/python/cudf/cudf/_lib/cpp/round.pxd @@ -6,6 +6,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/round.hpp" namespace "cudf" nogil: ctypedef enum rounding_method "cudf::rounding_method": diff --git a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd index fec1c6382e6..92f1cd602d6 100644 --- a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd +++ b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd @@ -1,14 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport ( - int32_t, int64_t -) +from libc.stdint cimport int32_t, int64_t from libcpp cimport bool from libcpp.string cimport string from cudf._lib.cpp.types cimport data_type from cudf._lib.cpp.wrappers.decimals cimport scale_type + cdef extern from "cudf/scalar/scalar.hpp" namespace "cudf" nogil: cdef cppclass scalar: scalar() except + diff --git a/python/cudf/cudf/_lib/cpp/search.pxd b/python/cudf/cudf/_lib/cpp/search.pxd index 521b681dc24..4df73881ea5 100644 --- a/python/cudf/cudf/_lib/cpp/search.pxd +++ b/python/cudf/cudf/_lib/cpp/search.pxd @@ -1,12 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/search.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/sorting.pxd b/python/cudf/cudf/_lib/cpp/sorting.pxd index 845457e423f..d614ef64ee2 100644 --- a/python/cudf/cudf/_lib/cpp/sorting.pxd +++ b/python/cudf/cudf/_lib/cpp/sorting.pxd @@ -4,13 +4,14 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types + cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: ctypedef enum rank_method: diff --git a/python/cudf/cudf/_lib/cpp/stream_compaction.pxd b/python/cudf/cudf/_lib/cpp/stream_compaction.pxd index c575f4eb17d..5b81d369ef5 100644 --- a/python/cudf/cudf/_lib/cpp/stream_compaction.pxd +++ b/python/cudf/cudf/_lib/cpp/stream_compaction.pxd @@ -1,17 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from libcpp cimport bool -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.cpp.types cimport ( - size_type, null_policy, nan_policy, null_equality -) from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport ( + nan_policy, + null_equality, + null_policy, + size_type, +) cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" \ diff --git a/python/cudf/cudf/_lib/cpp/strings/attributes.pxd b/python/cudf/cudf/_lib/cpp/strings/attributes.pxd index abac963fe94..31133b45b6d 100644 --- a/python/cudf/cudf/_lib/cpp/strings/attributes.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/attributes.pxd @@ -5,6 +5,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/attributes.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] count_characters( diff --git a/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd b/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd index eb24c6ab417..02a4469f495 100644 --- a/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd @@ -4,6 +4,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/capitalize.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] capitalize( const column_view & strings) except + diff --git a/python/cudf/cudf/_lib/cpp/strings/case.pxd b/python/cudf/cudf/_lib/cpp/strings/case.pxd index 7c38657a43e..01cd08c10ff 100644 --- a/python/cudf/cudf/_lib/cpp/strings/case.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/case.pxd @@ -4,6 +4,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/case.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] to_lower( const column_view & strings) except + diff --git a/python/cudf/cudf/_lib/cpp/strings/char_types.pxd b/python/cudf/cudf/_lib/cpp/strings/char_types.pxd index 934269c6f25..ae921c6ead9 100644 --- a/python/cudf/cudf/_lib/cpp/strings/char_types.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/char_types.pxd @@ -1,10 +1,12 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar + cdef extern from "cudf/strings/char_types/char_types.hpp" \ namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/combine.pxd b/python/cudf/cudf/_lib/cpp/strings/combine.pxd index 250c6441882..0a7d00b6e34 100644 --- a/python/cudf/cudf/_lib/cpp/strings/combine.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/combine.pxd @@ -1,10 +1,12 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.table.table_view cimport table_view + cdef extern from "cudf/strings/combine.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/contains.pxd b/python/cudf/cudf/_lib/cpp/strings/contains.pxd index e6fb9127814..bde0b4fdfb7 100644 --- a/python/cudf/cudf/_lib/cpp/strings/contains.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/contains.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view cdef extern from "cudf/strings/contains.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd index ca494696ae8..96cb43973f1 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_booleans.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd index 4bd57a16d64..5a9228608e5 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd @@ -1,11 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string cdef extern from "cudf/strings/convert/convert_datetime.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd index 98faebfcaa2..8c54fd52aa2 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd @@ -1,11 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string cdef extern from "cudf/strings/convert/convert_durations.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd index 77d72acb670..a993c5b17b8 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd @@ -1,10 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_fixed_point.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd index 55a84b60efd..6388f43077d 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd @@ -1,10 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_floats.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd index 6e45d4ba869..6c962ec2988 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd @@ -1,10 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_integers.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd index 37eea254605..d6e881caea4 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_ipv4.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd index a7bcb8d8078..5d9991dd610 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_urls.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/extract.pxd b/python/cudf/cudf/_lib/cpp/strings/extract.pxd index acec41bddc8..518b1c9ed60 100644 --- a/python/cudf/cudf/_lib/cpp/strings/extract.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/extract.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table -from libcpp.string cimport string cdef extern from "cudf/strings/extract.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/find.pxd b/python/cudf/cudf/_lib/cpp/strings/find.pxd index 05451fe0599..953d5c30b2a 100644 --- a/python/cudf/cudf/_lib/cpp/strings/find.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/find.pxd @@ -1,12 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/find.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] contains( diff --git a/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd b/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd index 286fe72d058..27b19728f60 100644 --- a/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd @@ -1,8 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/find_multiple.hpp" namespace "cudf::strings" \ nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/findall.pxd b/python/cudf/cudf/_lib/cpp/strings/findall.pxd index 818135b6cd0..189d0770b81 100644 --- a/python/cudf/cudf/_lib/cpp/strings/findall.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/findall.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table -from libcpp.string cimport string cdef extern from "cudf/strings/findall.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/json.pxd b/python/cudf/cudf/_lib/cpp/strings/json.pxd index c0e215f2085..972e3c99d59 100644 --- a/python/cudf/cudf/_lib/cpp/strings/json.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/json.pxd @@ -1,12 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from libcpp.memory cimport unique_ptr from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport scalar, string_scalar cdef extern from "cudf/strings/json.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/padding.pxd b/python/cudf/cudf/_lib/cpp/strings/padding.pxd index af1f235f7ea..2077e687be3 100644 --- a/python/cudf/cudf/_lib/cpp/strings/padding.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/padding.pxd @@ -1,12 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libc.stdint cimport int32_t +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string -from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/padding.hpp" namespace "cudf::strings" nogil: ctypedef enum pad_side: diff --git a/python/cudf/cudf/_lib/cpp/strings/replace.pxd b/python/cudf/cudf/_lib/cpp/strings/replace.pxd index 312c8fb1753..2a9c6913bb3 100644 --- a/python/cudf/cudf/_lib/cpp/strings/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/replace.pxd @@ -1,13 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type +from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string -from libc.stdint cimport int32_t +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/strings/replace.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd b/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd index 8d19c67acd0..33ccbc34a8e 100644 --- a/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from libcpp.memory cimport unique_ptr from libcpp.string cimport string +from libcpp.vector cimport vector + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table cimport table -from libcpp.string cimport string -from libcpp.vector cimport vector +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/replace_re.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd b/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd index cdfa8b78e03..fb83512e9f0 100644 --- a/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd @@ -1,12 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table cimport table + cdef extern from "cudf/strings/split/partition.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/split/split.pxd b/python/cudf/cudf/_lib/cpp/strings/split/split.pxd index db9bf91336a..4a90aa233f0 100644 --- a/python/cudf/cudf/_lib/cpp/strings/split/split.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/split/split.pxd @@ -1,12 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/split/split.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/strip.pxd b/python/cudf/cudf/_lib/cpp/strings/strip.pxd index a03917dc44b..82a84fd2d14 100644 --- a/python/cudf/cudf/_lib/cpp/strings/strip.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/strip.pxd @@ -1,9 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar + cdef extern from "cudf/strings/strip.hpp" namespace "cudf::strings" nogil: ctypedef enum strip_type: diff --git a/python/cudf/cudf/_lib/cpp/strings/substring.pxd b/python/cudf/cudf/_lib/cpp/strings/substring.pxd index 0d558ad9670..ec69c5acc03 100644 --- a/python/cudf/cudf/_lib/cpp/strings/substring.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/substring.pxd @@ -1,10 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport numeric_scalar +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/substring.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] slice_strings( diff --git a/python/cudf/cudf/_lib/cpp/strings/translate.pxd b/python/cudf/cudf/_lib/cpp/strings/translate.pxd index 3f40543a49a..3239ba314e4 100644 --- a/python/cudf/cudf/_lib/cpp/strings/translate.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/translate.pxd @@ -2,13 +2,14 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair +from libcpp.vector cimport vector from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from libcpp.vector cimport vector -from libcpp.pair cimport pair -from cudf._lib.cpp.types cimport char_utf8 from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport char_utf8 + cdef extern from "cudf/strings/translate.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/wrap.pxd b/python/cudf/cudf/_lib/cpp/strings/wrap.pxd index f5fa115b31c..62c791799ad 100644 --- a/python/cudf/cudf/_lib/cpp/strings/wrap.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/wrap.pxd @@ -1,9 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/wrap.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/table/table.pxd b/python/cudf/cudf/_lib/cpp/table/table.pxd index ffa8dd1fc98..13e1ceb6430 100644 --- a/python/cudf/cudf/_lib/cpp/table/table.pxd +++ b/python/cudf/cudf/_lib/cpp/table/table.pxd @@ -1,14 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table_view cimport ( - table_view, - mutable_table_view -) +from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/table/table.hpp" namespace "cudf" nogil: cdef cppclass table: diff --git a/python/cudf/cudf/_lib/cpp/table/table_view.pxd b/python/cudf/cudf/_lib/cpp/table/table_view.pxd index 7bbfa69836c..728b6d2be4b 100644 --- a/python/cudf/cudf/_lib/cpp/table/table_view.pxd +++ b/python/cudf/cudf/_lib/cpp/table/table_view.pxd @@ -2,11 +2,9 @@ from libcpp.vector cimport vector +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) + cdef extern from "cudf/table/table_view.hpp" namespace "cudf" nogil: cdef cppclass table_view: diff --git a/python/cudf/cudf/_lib/cpp/transform.pxd b/python/cudf/cudf/_lib/cpp/transform.pxd index 5e37336cb94..484e3997f34 100644 --- a/python/cudf/cudf/_lib/cpp/transform.pxd +++ b/python/cudf/cudf/_lib/cpp/transform.pxd @@ -1,21 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.string cimport string -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair +from libcpp.string cimport string from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.types cimport ( - bitmask_type, - data_type, - size_type, -) from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type cdef extern from "cudf/transform.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/unary.pxd b/python/cudf/cudf/_lib/cpp/unary.pxd index b5682ee6694..83a5701eaf0 100644 --- a/python/cudf/cudf/_lib/cpp/unary.pxd +++ b/python/cudf/cudf/_lib/cpp/unary.pxd @@ -2,15 +2,10 @@ from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column_view cimport ( - column_view -) -from cudf._lib.cpp.column.column cimport ( - column -) -from cudf._lib.cpp.types cimport ( - data_type -) + +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport data_type ctypedef int32_t underlying_type_t_unary_op diff --git a/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd b/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd index cbbe3710347..7e591e96373 100644 --- a/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd +++ b/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd @@ -2,6 +2,7 @@ from libcpp.vector cimport vector + cdef extern from "cudf/utilities/span.hpp" namespace "cudf" nogil: cdef cppclass host_span[T]: host_span() except + diff --git a/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd b/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd index 9de23fb2595..74efdb08bea 100644 --- a/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd +++ b/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd @@ -1,5 +1,6 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from libc.stdint cimport int64_t, int32_t +from libc.stdint cimport int32_t, int64_t + cdef extern from "cudf/fixed_point/fixed_point.hpp" namespace "numeric" nogil: # cython type stub to help resolve to numeric::decimal64 diff --git a/python/cudf/cudf/_lib/csv.pyx b/python/cudf/cudf/_lib/csv.pyx index f3cde6d449a..5cd75b15210 100644 --- a/python/cudf/cudf/_lib/csv.pyx +++ b/python/cudf/cudf/_lib/csv.pyx @@ -3,33 +3,31 @@ from libcpp cimport bool from libcpp.memory cimport make_unique, unique_ptr from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector +import numpy as np import pandas as pd + import cudf -import numpy as np from cudf._lib.cpp.types cimport size_type import collections.abc as abc import errno -from io import BytesIO, StringIO import os - from enum import IntEnum - -from libcpp cimport bool +from io import BytesIO, StringIO from libc.stdint cimport int32_t +from libcpp cimport bool from cudf._lib.cpp.io.csv cimport ( - read_csv as cpp_read_csv, csv_reader_options, - write_csv as cpp_write_csv, csv_writer_options, + read_csv as cpp_read_csv, + write_csv as cpp_write_csv, ) - from cudf._lib.cpp.io.types cimport ( compression_type, data_sink, @@ -37,11 +35,11 @@ from cudf._lib.cpp.io.types cimport ( sink_info, source_info, table_metadata, - table_with_metadata + table_with_metadata, ) -from cudf._lib.io.utils cimport make_source_info, make_sink_info -from cudf._lib.table cimport Table, make_table_view from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.io.utils cimport make_sink_info, make_source_info +from cudf._lib.table cimport Table, make_table_view ctypedef int32_t underlying_type_t_compression diff --git a/python/cudf/cudf/_lib/datetime.pyx b/python/cudf/cudf/_lib/datetime.pyx index 3e40cb62f9c..d048325c283 100644 --- a/python/cudf/cudf/_lib/datetime.pyx +++ b/python/cudf/cudf/_lib/datetime.pyx @@ -1,13 +1,11 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +cimport cudf._lib.cpp.datetime as libcudf_datetime +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.column cimport Column - -cimport cudf._lib.cpp.datetime as libcudf_datetime - def add_months(Column col, Column months): # months must be int16 dtype diff --git a/python/cudf/cudf/_lib/filling.pyx b/python/cudf/cudf/_lib/filling.pyx index a3941c9479b..d9fdf72415c 100644 --- a/python/cudf/cudf/_lib/filling.pyx +++ b/python/cudf/cudf/_lib/filling.pyx @@ -6,13 +6,10 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column +cimport cudf._lib.cpp.filling as cpp_filling from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view @@ -20,8 +17,6 @@ from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table -cimport cudf._lib.cpp.filling as cpp_filling - def fill_in_place(Column destination, int begin, int end, DeviceScalar value): cdef mutable_column_view c_destination = destination.mutable_view() diff --git a/python/cudf/cudf/_lib/gpuarrow.pyx b/python/cudf/cudf/_lib/gpuarrow.pyx index 6513cd59424..8cb42e54e24 100644 --- a/python/cudf/cudf/_lib/gpuarrow.pyx +++ b/python/cudf/cudf/_lib/gpuarrow.pyx @@ -4,22 +4,26 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from pyarrow._cuda cimport CudaBuffer from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader + from cudf._lib.cpp.gpuarrow cimport CCudaMessageReader + from numba.cuda.cudadrv.devicearray import DeviceNDArray + from pyarrow.includes.common cimport GetResultValue from pyarrow.includes.libarrow cimport ( - CMessage, CBufferReader, - CMessageReader, CIpcReadOptions, - CRecordBatchStreamReader + CMessage, + CMessageReader, + CRecordBatchStreamReader, ) from pyarrow.lib cimport ( - _CRecordBatchReader, Buffer, Schema, - pyarrow_wrap_schema + _CRecordBatchReader, + pyarrow_wrap_schema, ) + import pyarrow as pa diff --git a/python/cudf/cudf/_lib/groupby.pyx b/python/cudf/cudf/_lib/groupby.pyx index 3d1a6493028..4b1530921a5 100644 --- a/python/cudf/cudf/_lib/groupby.pyx +++ b/python/cudf/cudf/_lib/groupby.pyx @@ -1,33 +1,33 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from collections import defaultdict + +import numpy as np from pandas.core.groupby.groupby import DataError + +import rmm + from cudf.utils.dtypes import ( is_categorical_dtype, - is_string_dtype, - is_list_dtype, + is_decimal_dtype, is_interval_dtype, + is_list_dtype, + is_string_dtype, is_struct_dtype, - is_decimal_dtype, ) -import numpy as np -import rmm - -from libcpp.pair cimport pair +from libcpp cimport bool from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move from libcpp.vector cimport vector -from libcpp cimport bool -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table +cimport cudf._lib.cpp.groupby as libcudf_groupby +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.aggregation cimport Aggregation, make_aggregation - +from cudf._lib.column cimport Column from cudf._lib.cpp.table.table cimport table, table_view -cimport cudf._lib.cpp.types as libcudf_types -cimport cudf._lib.cpp.groupby as libcudf_groupby - +from cudf._lib.table cimport Table # The sets below define the possible aggregations that can be performed on # different dtypes. These strings must be elements of the AggregationKind enum. diff --git a/python/cudf/cudf/_lib/hash.pyx b/python/cudf/cudf/_lib/hash.pyx index 196c88a8a20..198e7a748c9 100644 --- a/python/cudf/cudf/_lib/hash.pyx +++ b/python/cudf/cudf/_lib/hash.pyx @@ -2,24 +2,19 @@ from libc.stdint cimport uint32_t from libcpp cimport bool -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.hash cimport hash as cpp_hash +from cudf._lib.cpp.partitioning cimport hash_partition as cpp_hash_partition from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.hash cimport ( - hash as cpp_hash -) -from cudf._lib.cpp.partitioning cimport ( - hash_partition as cpp_hash_partition, -) -cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.table cimport Table def hash_partition(Table source_table, object columns_to_hash, diff --git a/python/cudf/cudf/_lib/interop.pyx b/python/cudf/cudf/_lib/interop.pyx index 04971b58cd2..08ea58e4587 100644 --- a/python/cudf/cudf/_lib/interop.pyx +++ b/python/cudf/cudf/_lib/interop.pyx @@ -2,27 +2,25 @@ import cudf -from cudf._lib.table cimport Table -from libcpp.vector cimport vector -from libcpp.string cimport string +from cpython cimport pycapsule from libcpp cimport bool - -from libcpp.memory cimport unique_ptr, shared_ptr +from libcpp.memory cimport shared_ptr, unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move +from libcpp.vector cimport vector +from pyarrow.lib cimport CTable, pyarrow_unwrap_table, pyarrow_wrap_table -from cpython cimport pycapsule - -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from pyarrow.lib cimport CTable, pyarrow_wrap_table, pyarrow_unwrap_table from cudf._lib.cpp.interop cimport ( - to_arrow as cpp_to_arrow, + DLManagedTensor, + column_metadata, from_arrow as cpp_from_arrow, from_dlpack as cpp_from_dlpack, + to_arrow as cpp_to_arrow, to_dlpack as cpp_to_dlpack, - column_metadata, - DLManagedTensor ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.table cimport Table def from_dlpack(dlpack_capsule): diff --git a/python/cudf/cudf/_lib/io/datasource.pxd b/python/cudf/cudf/_lib/io/datasource.pxd index 528a6c52edd..705a3600f68 100644 --- a/python/cudf/cudf/_lib/io/datasource.pxd +++ b/python/cudf/cudf/_lib/io/datasource.pxd @@ -1,8 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.io.types cimport datasource + cdef class Datasource: cdef datasource* get_datasource(self) nogil except * diff --git a/python/cudf/cudf/_lib/io/datasource.pyx b/python/cudf/cudf/_lib/io/datasource.pyx index b706847647b..ddfd9a3540a 100644 --- a/python/cudf/cudf/_lib/io/datasource.pyx +++ b/python/cudf/cudf/_lib/io/datasource.pyx @@ -1,8 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.io.types cimport datasource + cdef class Datasource: cdef datasource* get_datasource(self) nogil except *: with gil: diff --git a/python/cudf/cudf/_lib/io/utils.pxd b/python/cudf/cudf/_lib/io/utils.pxd index 0a793b2d018..233e4f7c635 100644 --- a/python/cudf/cudf/_lib/io/utils.pxd +++ b/python/cudf/cudf/_lib/io/utils.pxd @@ -2,7 +2,8 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.io.types cimport source_info, sink_info, data_sink +from cudf._lib.cpp.io.types cimport data_sink, sink_info, source_info + cdef source_info make_source_info(list src) except* cdef sink_info make_sink_info(src, unique_ptr[data_sink] & data) except* diff --git a/python/cudf/cudf/_lib/io/utils.pyx b/python/cudf/cudf/_lib/io/utils.pyx index 6598a7af626..846086107e1 100644 --- a/python/cudf/cudf/_lib/io/utils.pyx +++ b/python/cudf/cudf/_lib/io/utils.pyx @@ -4,20 +4,29 @@ from cpython.buffer cimport PyBUF_READ from cpython.memoryview cimport PyMemoryView_FromMemory from libcpp.map cimport map from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move -from libcpp.vector cimport vector from libcpp.pair cimport pair from libcpp.string cimport string -from cudf._lib.cpp.io.types cimport source_info, io_type, host_buffer -from cudf._lib.cpp.io.types cimport sink_info, data_sink, datasource +from libcpp.utility cimport move +from libcpp.vector cimport vector + +from cudf._lib.cpp.io.types cimport ( + data_sink, + datasource, + host_buffer, + io_type, + sink_info, + source_info, +) from cudf._lib.io.datasource cimport Datasource import codecs import errno import io import os + import cudf + # Converts the Python source input to libcudf++ IO source_info # with the appropriate type and source values cdef source_info make_source_info(list src) except*: diff --git a/python/cudf/cudf/_lib/join.pyx b/python/cudf/cudf/_lib/join.pyx index 193c2ca9d67..186f8d32aeb 100644 --- a/python/cudf/cudf/_lib/join.pyx +++ b/python/cudf/cudf/_lib/join.pyx @@ -1,24 +1,22 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import cudf - from itertools import chain -from libcpp.memory cimport unique_ptr, make_unique +import cudf + +from libcpp cimport bool +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move from libcpp.vector cimport vector -from libcpp.pair cimport pair -from libcpp cimport bool +cimport cudf._lib.cpp.join as cpp_join from cudf._lib.column cimport Column -from cudf._lib.table cimport Table, columns_from_ptr - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.types cimport size_type, data_type, type_id from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.join as cpp_join - +from cudf._lib.cpp.types cimport data_type, size_type, type_id +from cudf._lib.table cimport Table, columns_from_ptr # The functions below return the *gathermaps* that represent # the join result when joining on the keys `lhs` and `rhs`. diff --git a/python/cudf/cudf/_lib/json.pyx b/python/cudf/cudf/_lib/json.pyx index 7a6ec47ab66..f46303d8c78 100644 --- a/python/cudf/cudf/_lib/json.pyx +++ b/python/cudf/cudf/_lib/json.pyx @@ -3,24 +3,25 @@ # cython: boundscheck = False -import cudf import collections.abc as abc import io import os +import cudf + from libcpp cimport bool from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector +cimport cudf._lib.cpp.io.types as cudf_io_types from cudf._lib.cpp.io.json cimport ( + json_reader_options, read_json as libcudf_read_json, - json_reader_options ) from cudf._lib.cpp.types cimport size_type from cudf._lib.io.utils cimport make_source_info from cudf._lib.table cimport Table -cimport cudf._lib.cpp.io.types as cudf_io_types cpdef read_json(object filepath_or_buffer, diff --git a/python/cudf/cudf/_lib/labeling.pyx b/python/cudf/cudf/_lib/labeling.pyx index 1b553024347..088942064a8 100644 --- a/python/cudf/cudf/_lib/labeling.pyx +++ b/python/cudf/cudf/_lib/labeling.pyx @@ -1,20 +1,21 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -import numpy as np from enum import IntEnum +import numpy as np + from libc.stdint cimport uint32_t from libcpp cimport bool as cbool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from cudf._lib.column cimport Column + from cudf._lib.replace import replace_nulls -from cudf._lib.cpp.labeling cimport inclusive -from cudf._lib.cpp.labeling cimport label_bins as cpp_label_bins from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.labeling cimport inclusive, label_bins as cpp_label_bins # Note that the parameter input shadows a Python built-in in the local scope, diff --git a/python/cudf/cudf/_lib/lists.pyx b/python/cudf/cudf/_lib/lists.pyx index 9bc0550bdf0..9f4be2e389a 100644 --- a/python/cudf/cudf/_lib/lists.pyx +++ b/python/cudf/cudf/_lib/lists.pyx @@ -1,48 +1,41 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr, shared_ptr, make_shared +from libcpp.memory cimport make_shared, shared_ptr, unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.count_elements cimport ( - count_elements as cpp_count_elements -) -from cudf._lib.cpp.lists.explode cimport ( - explode_outer as cpp_explode_outer + count_elements as cpp_count_elements, ) from cudf._lib.cpp.lists.drop_list_duplicates cimport ( - drop_list_duplicates as cpp_drop_list_duplicates -) -from cudf._lib.cpp.lists.sorting cimport ( - sort_lists as cpp_sort_lists + drop_list_duplicates as cpp_drop_list_duplicates, ) +from cudf._lib.cpp.lists.explode cimport explode_outer as cpp_explode_outer from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column - -from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.lists.sorting cimport sort_lists as cpp_sort_lists from cudf._lib.cpp.scalar.scalar cimport scalar - from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport ( - size_type, + nan_equality, null_equality, - order, null_order, - nan_equality + order, + size_type, ) - -from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table - from cudf._lib.types cimport ( - underlying_type_t_null_order, underlying_type_t_order + underlying_type_t_null_order, + underlying_type_t_order, ) + from cudf.core.dtypes import ListDtype from cudf._lib.cpp.lists.contains cimport contains - from cudf._lib.cpp.lists.extract cimport extract_list_element diff --git a/python/cudf/cudf/_lib/merge.pyx b/python/cudf/cudf/_lib/merge.pyx index 81d5807906a..cc2d405c207 100644 --- a/python/cudf/cudf/_lib/merge.pyx +++ b/python/cudf/cudf/_lib/merge.pyx @@ -1,17 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp cimport bool +from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - +from cudf._lib.cpp.merge cimport merge as cpp_merge from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.merge cimport merge as cpp_merge -cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.table cimport Table def merge_sorted( diff --git a/python/cudf/cudf/_lib/null_mask.pyx b/python/cudf/cudf/_lib/null_mask.pyx index 8c209cd86bd..3eaa6b5e588 100644 --- a/python/cudf/cudf/_lib/null_mask.pyx +++ b/python/cudf/cudf/_lib/null_mask.pyx @@ -2,22 +2,23 @@ from enum import Enum -from libcpp.memory cimport unique_ptr, make_unique +from libcpp.memory cimport make_unique, unique_ptr from libcpp.utility cimport move -from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from cudf._lib.column cimport Column + import cudf._lib as libcudfxx -from cudf._lib.cpp.types cimport mask_state, size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.null_mask cimport ( + bitmask_allocation_size_bytes as cpp_bitmask_allocation_size_bytes, copy_bitmask as cpp_copy_bitmask, create_null_mask as cpp_create_null_mask, - bitmask_allocation_size_bytes as cpp_bitmask_allocation_size_bytes, - underlying_type_t_mask_state + underlying_type_t_mask_state, ) +from cudf._lib.cpp.types cimport mask_state, size_type from cudf.core.buffer import Buffer diff --git a/python/cudf/cudf/_lib/nvtext/edit_distance.pyx b/python/cudf/cudf/_lib/nvtext/edit_distance.pyx index f9fae570469..a51d77b9b37 100644 --- a/python/cudf/cudf/_lib/nvtext/edit_distance.pyx +++ b/python/cudf/cudf/_lib/nvtext/edit_distance.pyx @@ -4,12 +4,12 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.edit_distance cimport ( - edit_distance as cpp_edit_distance + edit_distance as cpp_edit_distance, ) -from cudf._lib.column cimport Column def edit_distance(Column strings, Column targets): diff --git a/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx b/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx index 48d67110621..5fcec570dcb 100644 --- a/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx +++ b/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx @@ -3,15 +3,15 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.generate_ngrams cimport ( + generate_character_ngrams as cpp_generate_character_ngrams, generate_ngrams as cpp_generate_ngrams, - generate_character_ngrams as cpp_generate_character_ngrams ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx b/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx index cf0a4a0f55a..1e9e0e39ff1 100644 --- a/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.ngrams_tokenize cimport ( - ngrams_tokenize as cpp_ngrams_tokenize + ngrams_tokenize as cpp_ngrams_tokenize, ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/normalize.pyx b/python/cudf/cudf/_lib/nvtext/normalize.pyx index 88f0f0a957a..e475f0cd996 100644 --- a/python/cudf/cudf/_lib/nvtext/normalize.pyx +++ b/python/cudf/cudf/_lib/nvtext/normalize.pyx @@ -4,13 +4,13 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.normalize cimport ( normalize_characters as cpp_normalize_characters, - normalize_spaces as cpp_normalize_spaces + normalize_spaces as cpp_normalize_spaces, ) -from cudf._lib.column cimport Column def normalize_spaces(Column strings): diff --git a/python/cudf/cudf/_lib/nvtext/replace.pyx b/python/cudf/cudf/_lib/nvtext/replace.pyx index cb552161b52..b4f37ac3ec7 100644 --- a/python/cudf/cudf/_lib/nvtext/replace.pyx +++ b/python/cudf/cudf/_lib/nvtext/replace.pyx @@ -3,15 +3,15 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.replace cimport ( - replace_tokens as cpp_replace_tokens, filter_tokens as cpp_filter_tokens, + replace_tokens as cpp_replace_tokens, ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/stemmer.pyx b/python/cudf/cudf/_lib/nvtext/stemmer.pyx index 1aca32a5667..89d4b07b7ad 100644 --- a/python/cudf/cudf/_lib/nvtext/stemmer.pyx +++ b/python/cudf/cudf/_lib/nvtext/stemmer.pyx @@ -2,19 +2,19 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from enum import IntEnum +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column - from cudf._lib.cpp.nvtext.stemmer cimport ( - porter_stemmer_measure as cpp_porter_stemmer_measure, is_letter as cpp_is_letter, - letter_type as letter_type + letter_type as letter_type, + porter_stemmer_measure as cpp_porter_stemmer_measure, + underlying_type_t_letter_type, ) -from cudf._lib.cpp.nvtext.stemmer cimport underlying_type_t_letter_type +from cudf._lib.cpp.types cimport size_type class LetterType(IntEnum): diff --git a/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx b/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx index 3cf3cbe1ef2..49f24436b88 100644 --- a/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx @@ -1,22 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint32_t, uintptr_t from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.string cimport string -from libc.stdint cimport uint32_t -from libc.stdint cimport uintptr_t +from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.nvtext.subword_tokenize cimport( - subword_tokenize as cpp_subword_tokenize, +from cudf._lib.cpp.nvtext.subword_tokenize cimport ( hashed_vocabulary as cpp_hashed_vocabulary, load_vocabulary_file as cpp_load_vocabulary_file, - tokenizer_result as cpp_tokenizer_result, move as tr_move, + subword_tokenize as cpp_subword_tokenize, + tokenizer_result as cpp_tokenizer_result, ) -from cudf._lib.column cimport Column cdef class Hashed_Vocabulary: diff --git a/python/cudf/cudf/_lib/nvtext/tokenize.pyx b/python/cudf/cudf/_lib/nvtext/tokenize.pyx index c7f5c2a12c4..5fc852c2ab0 100644 --- a/python/cudf/cudf/_lib/nvtext/tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/tokenize.pyx @@ -3,17 +3,17 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.tokenize cimport ( - tokenize as cpp_tokenize, - detokenize as cpp_detokenize, + character_tokenize as cpp_character_tokenize, count_tokens as cpp_count_tokens, - character_tokenize as cpp_character_tokenize + detokenize as cpp_detokenize, + tokenize as cpp_tokenize, ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/orc.pyx b/python/cudf/cudf/_lib/orc.pyx index 69d67c5b02d..ea4b4ae7ca3 100644 --- a/python/cudf/cudf/_lib/orc.pyx +++ b/python/cudf/cudf/_lib/orc.pyx @@ -3,23 +3,23 @@ import cudf from libcpp cimport bool, int -from libcpp.memory cimport unique_ptr, make_unique +from libcpp.memory cimport make_unique, unique_ptr from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move -from cudf._lib.cpp.column.column cimport column +from libcpp.vector cimport vector -from cudf._lib.cpp.io.orc_metadata cimport ( - raw_orc_statistics, - read_raw_orc_statistics as libcudf_read_raw_orc_statistics -) +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.io.orc cimport ( + chunked_orc_writer_options, + orc_chunked_writer, orc_reader_options, - read_orc as libcudf_read_orc, orc_writer_options, + read_orc as libcudf_read_orc, write_orc as libcudf_write_orc, - chunked_orc_writer_options, - orc_chunked_writer +) +from cudf._lib.cpp.io.orc_metadata cimport ( + raw_orc_statistics, + read_raw_orc_statistics as libcudf_read_raw_orc_statistics, ) from cudf._lib.cpp.io.types cimport ( compression_type, @@ -27,27 +27,23 @@ from cudf._lib.cpp.io.types cimport ( sink_info, source_info, table_metadata, + table_metadata_with_nullability, table_with_metadata, - table_metadata_with_nullability ) - from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport ( - data_type, type_id, size_type -) - -from cudf._lib.io.utils cimport make_source_info, make_sink_info +from cudf._lib.cpp.types cimport data_type, size_type, type_id +from cudf._lib.io.utils cimport make_sink_info, make_source_info from cudf._lib.table cimport Table + from cudf._lib.types import np_to_cudf_types + from cudf._lib.types cimport underlying_type_t_type_id + import numpy as np from cudf._lib.utils cimport get_column_names -from cudf._lib.utils import ( - _index_level_name, - generate_pandas_metadata, -) +from cudf._lib.utils import _index_level_name, generate_pandas_metadata cpdef read_raw_orc_statistics(filepath_or_buffer): diff --git a/python/cudf/cudf/_lib/parquet.pyx b/python/cudf/cudf/_lib/parquet.pyx index 4ea2adec23a..088b475139b 100644 --- a/python/cudf/cudf/_lib/parquet.pyx +++ b/python/cudf/cudf/_lib/parquet.pyx @@ -2,70 +2,64 @@ # cython: boundscheck = False -import cudf import errno import os -import pyarrow as pa from collections import OrderedDict +import pyarrow as pa + +import cudf + try: import ujson as json except ImportError: import json -from cython.operator import dereference import numpy as np +from cython.operator import dereference from cudf.utils.dtypes import ( - np_to_pa_dtype, is_categorical_dtype, + is_decimal_dtype, is_list_dtype, is_struct_dtype, - is_decimal_dtype, + np_to_pa_dtype, ) from cudf._lib.utils cimport get_column_names -from cudf._lib.utils import ( - _index_level_name, - generate_pandas_metadata, -) -from libc.stdlib cimport free +from cudf._lib.utils import _index_level_name, generate_pandas_metadata + from libc.stdint cimport uint8_t -from libcpp.memory cimport unique_ptr, make_unique -from libcpp.string cimport string +from libc.stdlib cimport free +from libcpp cimport bool from libcpp.map cimport map -from libcpp.vector cimport vector +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from libcpp cimport bool - +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport data_type, size_type -from cudf._lib.table cimport Table -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport ( - table_view -) +cimport cudf._lib.cpp.io.types as cudf_io_types +cimport cudf._lib.cpp.types as cudf_types +from cudf._lib.column cimport Column from cudf._lib.cpp.io.parquet cimport ( - read_parquet as parquet_reader, - parquet_reader_options, - table_input_metadata, - column_in_metadata, - parquet_writer_options, - write_parquet as parquet_writer, - parquet_chunked_writer as cpp_parquet_chunked_writer, chunked_parquet_writer_options, chunked_parquet_writer_options_builder, + column_in_metadata, merge_rowgroup_metadata as parquet_merge_metadata, + parquet_chunked_writer as cpp_parquet_chunked_writer, + parquet_reader_options, + parquet_writer_options, + read_parquet as parquet_reader, + table_input_metadata, + write_parquet as parquet_writer, ) -from cudf._lib.column cimport Column -from cudf._lib.io.utils cimport ( - make_source_info, - make_sink_info -) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport data_type, size_type +from cudf._lib.io.utils cimport make_sink_info, make_source_info +from cudf._lib.table cimport Table -cimport cudf._lib.cpp.types as cudf_types -cimport cudf._lib.cpp.io.types as cudf_io_types cdef class BufferArrayFromVector: cdef Py_ssize_t length diff --git a/python/cudf/cudf/_lib/partitioning.pyx b/python/cudf/cudf/_lib/partitioning.pyx index b33ccb24039..865138bec84 100644 --- a/python/cudf/cudf/_lib/partitioning.pyx +++ b/python/cudf/cudf/_lib/partitioning.pyx @@ -1,22 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector +from libcpp.pair cimport pair from libcpp.utility cimport move +from libcpp.vector cimport vector from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.partitioning cimport partition as cpp_partition from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.table cimport Table -from cudf._lib.cpp.partitioning cimport ( - partition as cpp_partition, -) from cudf._lib.stream_compaction import distinct_count as cpp_distinct_count + cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/quantiles.pyx b/python/cudf/cudf/_lib/quantiles.pyx index 0c1338103be..45a4ff7c92c 100644 --- a/python/cudf/cudf/_lib/quantiles.pyx +++ b/python/cudf/cudf/_lib/quantiles.pyx @@ -1,34 +1,36 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table from cudf._lib.types cimport ( - underlying_type_t_order, + underlying_type_t_interpolation, underlying_type_t_null_order, + underlying_type_t_order, underlying_type_t_sorted, - underlying_type_t_interpolation, ) + from cudf._lib.types import Interpolation + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.quantiles cimport ( + quantile as cpp_quantile, + quantiles as cpp_quantiles, +) from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport ( interpolation, null_order, order, - sorted, order_info, -) -from cudf._lib.cpp.quantiles cimport ( - quantile as cpp_quantile, - quantiles as cpp_quantiles, + sorted, ) diff --git a/python/cudf/cudf/_lib/reduce.pyx b/python/cudf/cudf/_lib/reduce.pyx index e5723331f3c..49ebb0a2528 100644 --- a/python/cudf/cudf/_lib/reduce.pyx +++ b/python/cudf/cudf/_lib/reduce.pyx @@ -1,20 +1,25 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. import cudf -from cudf.utils.dtypes import is_decimal_dtype from cudf.core.dtypes import Decimal64Dtype -from cudf._lib.cpp.reduce cimport cpp_reduce, cpp_scan, scan_type, cpp_minmax +from cudf.utils.dtypes import is_decimal_dtype + +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.reduce cimport cpp_minmax, cpp_reduce, cpp_scan, scan_type from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.types cimport data_type, type_id -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.column cimport Column + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type -from cudf._lib.aggregation cimport make_aggregation, Aggregation + from libcpp.memory cimport unique_ptr from libcpp.utility cimport move, pair + +from cudf._lib.aggregation cimport Aggregation, make_aggregation +from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id + import numpy as np cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/replace.pyx b/python/cudf/cudf/_lib/replace.pyx index cdedd3ac022..2ae0835566b 100644 --- a/python/cudf/cudf/_lib/replace.pyx +++ b/python/cudf/cudf/_lib/replace.pyx @@ -6,22 +6,20 @@ from libcpp.utility cimport move from cudf.utils.dtypes import is_scalar from cudf._lib.column cimport Column + from cudf._lib.scalar import as_device_scalar -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.replace cimport ( - replace_policy as cpp_replace_policy, + clamp as cpp_clamp, find_and_replace_all as cpp_find_and_replace_all, + normalize_nans_and_zeros as cpp_normalize_nans_and_zeros, replace_nulls as cpp_replace_nulls, - clamp as cpp_clamp, - normalize_nans_and_zeros as cpp_normalize_nans_and_zeros + replace_policy as cpp_replace_policy, ) +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.scalar cimport DeviceScalar def replace(Column input_col, Column values_to_replace, diff --git a/python/cudf/cudf/_lib/reshape.pyx b/python/cudf/cudf/_lib/reshape.pyx index cebe48eb697..fbed410de86 100644 --- a/python/cudf/cudf/_lib/reshape.pyx +++ b/python/cudf/cudf/_lib/reshape.pyx @@ -2,18 +2,17 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view - from cudf._lib.cpp.reshape cimport ( interleave_columns as cpp_interleave_columns, - tile as cpp_tile + tile as cpp_tile, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.table cimport Table def interleave_columns(Table source_table): diff --git a/python/cudf/cudf/_lib/rolling.pyx b/python/cudf/cudf/_lib/rolling.pyx index 6fe661a25a5..87c2fa6178f 100644 --- a/python/cudf/cudf/_lib/rolling.pyx +++ b/python/cudf/cudf/_lib/rolling.pyx @@ -1,21 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from __future__ import print_function -import cudf + import pandas as pd +import cudf + from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.aggregation cimport RollingAggregation, make_rolling_aggregation - -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.rolling cimport ( - rolling_window as cpp_rolling_window -) +from cudf._lib.cpp.rolling cimport rolling_window as cpp_rolling_window +from cudf._lib.cpp.types cimport size_type def rolling(Column source_column, Column pre_column_window, diff --git a/python/cudf/cudf/_lib/round.pyx b/python/cudf/cudf/_lib/round.pyx index 660d6d91670..cb6bca373a4 100644 --- a/python/cudf/cudf/_lib/round.pyx +++ b/python/cudf/cudf/_lib/round.pyx @@ -4,12 +4,11 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from cudf._lib.column cimport Column - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.round cimport ( + round as cpp_round, rounding_method as cpp_rounding_method, - round as cpp_round ) diff --git a/python/cudf/cudf/_lib/scalar.pyx b/python/cudf/cudf/_lib/scalar.pyx index b31f0675422..919b652a43e 100644 --- a/python/cudf/cudf/_lib/scalar.pyx +++ b/python/cudf/cudf/_lib/scalar.pyx @@ -1,5 +1,6 @@ # Copyright (c) 2020, NVIDIA CORPORATION. import decimal + import numpy as np import pandas as pd @@ -13,37 +14,42 @@ from libc.stdint cimport ( uint32_t, uint64_t, ) +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp cimport bool import cudf -from cudf._lib.types import cudf_to_np_types, duration_unit_map -from cudf._lib.types import datetime_unit_map -from cudf._lib.types cimport underlying_type_t_type_id +from cudf._lib.types import ( + cudf_to_np_types, + datetime_unit_map, + duration_unit_map, +) -from cudf._lib.cpp.wrappers.timestamps cimport ( - timestamp_s, - timestamp_ms, - timestamp_us, - timestamp_ns +from cudf._lib.cpp.scalar.scalar cimport ( + duration_scalar, + fixed_point_scalar, + numeric_scalar, + scalar, + string_scalar, + timestamp_scalar, ) -from cudf._lib.cpp.wrappers.durations cimport( - duration_s, +from cudf._lib.cpp.wrappers.decimals cimport decimal64, scale_type +from cudf._lib.cpp.wrappers.durations cimport ( duration_ms, + duration_ns, + duration_s, duration_us, - duration_ns ) -from cudf._lib.cpp.wrappers.decimals cimport decimal64, scale_type -from cudf._lib.cpp.scalar.scalar cimport ( - scalar, - numeric_scalar, - timestamp_scalar, - duration_scalar, - string_scalar, - fixed_point_scalar +from cudf._lib.cpp.wrappers.timestamps cimport ( + timestamp_ms, + timestamp_ns, + timestamp_s, + timestamp_us, ) +from cudf._lib.types cimport underlying_type_t_type_id + from cudf.utils.dtypes import _decimal_to_int64 + cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/search.pyx b/python/cudf/cudf/_lib/search.pyx index 402e3456821..33471028d66 100644 --- a/python/cudf/cudf/_lib/search.pyx +++ b/python/cudf/cudf/_lib/search.pyx @@ -1,17 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector +cimport cudf._lib.cpp.search as cpp_search +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types -cimport cudf._lib.cpp.search as cpp_search +from cudf._lib.table cimport Table def search_sorted( diff --git a/python/cudf/cudf/_lib/sort.pxd b/python/cudf/cudf/_lib/sort.pxd index 6a06c132daa..d7488889555 100644 --- a/python/cudf/cudf/_lib/sort.pxd +++ b/python/cudf/cudf/_lib/sort.pxd @@ -1,2 +1,3 @@ from libc.stdint cimport int32_t + ctypedef int32_t underlying_type_t_rank_method diff --git a/python/cudf/cudf/_lib/sort.pyx b/python/cudf/cudf/_lib/sort.pyx index a20ab4c1bf4..1d15052e41a 100644 --- a/python/cudf/cudf/_lib/sort.pyx +++ b/python/cudf/cudf/_lib/sort.pyx @@ -4,23 +4,26 @@ import pandas as pd from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector + from enum import IntEnum from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.search cimport lower_bound, upper_bound -from cudf._lib.cpp.sorting cimport( - rank, rank_method, sorted_order, is_sorted as cpp_is_sorted +from cudf._lib.cpp.sorting cimport ( + is_sorted as cpp_is_sorted, + rank, + rank_method, + sorted_order, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport null_order, null_policy, order from cudf._lib.sort cimport underlying_type_t_rank_method -from cudf._lib.cpp.types cimport order, null_order, null_policy +from cudf._lib.table cimport Table def is_sorted( diff --git a/python/cudf/cudf/_lib/stream_compaction.pyx b/python/cudf/cudf/_lib/stream_compaction.pyx index cabbdf89b4e..a7326efcc03 100644 --- a/python/cudf/cudf/_lib/stream_compaction.pyx +++ b/python/cudf/cudf/_lib/stream_compaction.pyx @@ -2,27 +2,29 @@ import pandas as pd +from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector from libcpp.utility cimport move -from libcpp cimport bool +from libcpp.vector cimport vector from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - -from cudf._lib.cpp.types cimport ( - size_type, null_policy, nan_policy, null_equality -) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.stream_compaction cimport ( - duplicate_keep_option, - drop_nulls as cpp_drop_nulls, apply_boolean_mask as cpp_apply_boolean_mask, + distinct_count as cpp_distinct_count, drop_duplicates as cpp_drop_duplicates, - distinct_count as cpp_distinct_count + drop_nulls as cpp_drop_nulls, + duplicate_keep_option, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport ( + nan_policy, + null_equality, + null_policy, + size_type, +) +from cudf._lib.table cimport Table def drop_nulls(Table source_table, how="any", keys=None, thresh=None): diff --git a/python/cudf/cudf/_lib/string_casting.pyx b/python/cudf/cudf/_lib/string_casting.pyx index 7d58e3b5dcc..5c74a15e814 100644 --- a/python/cudf/cudf/_lib/string_casting.pyx +++ b/python/cudf/cudf/_lib/string_casting.pyx @@ -3,56 +3,57 @@ import numpy as np from cudf._lib.column cimport Column + from cudf._lib.scalar import as_device_scalar + from cudf._lib.scalar cimport DeviceScalar + from cudf._lib.types import np_to_cudf_types + from cudf._lib.types cimport underlying_type_t_type_id from cudf.core.column.column import as_column +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string +from libcpp.utility cimport move + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.convert.convert_booleans cimport ( + from_booleans as cpp_from_booleans, to_booleans as cpp_to_booleans, - from_booleans as cpp_from_booleans ) from cudf._lib.cpp.strings.convert.convert_datetime cimport ( - to_timestamps as cpp_to_timestamps, from_timestamps as cpp_from_timestamps, - is_timestamp as cpp_is_timestamp + is_timestamp as cpp_is_timestamp, + to_timestamps as cpp_to_timestamps, +) +from cudf._lib.cpp.strings.convert.convert_durations cimport ( + from_durations as cpp_from_durations, + to_durations as cpp_to_durations, ) from cudf._lib.cpp.strings.convert.convert_floats cimport ( + from_floats as cpp_from_floats, to_floats as cpp_to_floats, - from_floats as cpp_from_floats ) from cudf._lib.cpp.strings.convert.convert_integers cimport ( - to_integers as cpp_to_integers, from_integers as cpp_from_integers, hex_to_integers as cpp_hex_to_integers, - is_hex as cpp_is_hex + is_hex as cpp_is_hex, + to_integers as cpp_to_integers, ) from cudf._lib.cpp.strings.convert.convert_ipv4 cimport ( - ipv4_to_integers as cpp_ipv4_to_integers, integers_to_ipv4 as cpp_integers_to_ipv4, - is_ipv4 as cpp_is_ipv4 + ipv4_to_integers as cpp_ipv4_to_integers, + is_ipv4 as cpp_is_ipv4, ) from cudf._lib.cpp.strings.convert.convert_urls cimport ( + url_decode as cpp_url_decode, url_encode as cpp_url_encode, - url_decode as cpp_url_decode -) -from cudf._lib.cpp.strings.convert.convert_durations cimport ( - to_durations as cpp_to_durations, - from_durations as cpp_from_durations -) -from cudf._lib.cpp.types cimport ( - type_id, - data_type, ) - -from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move -from libcpp.string cimport string +from cudf._lib.cpp.types cimport data_type, type_id def floating_to_string(Column input_col): diff --git a/python/cudf/cudf/_lib/strings/attributes.pyx b/python/cudf/cudf/_lib/strings/attributes.pyx index 3e0bacda546..8720fad7455 100644 --- a/python/cudf/cudf/_lib/strings/attributes.pyx +++ b/python/cudf/cudf/_lib/strings/attributes.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.attributes cimport ( - count_characters as cpp_count_characters, code_points as cpp_code_points, - count_bytes as cpp_count_bytes + count_bytes as cpp_count_bytes, + count_characters as cpp_count_characters, ) -from cudf._lib.column cimport Column def count_characters(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/capitalize.pyx b/python/cudf/cudf/_lib/strings/capitalize.pyx index 8316d42ee15..bb1bf25ef7b 100644 --- a/python/cudf/cudf/_lib/strings/capitalize.pyx +++ b/python/cudf/cudf/_lib/strings/capitalize.pyx @@ -3,13 +3,13 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.capitalize cimport ( capitalize as cpp_capitalize, title as cpp_title, ) -from cudf._lib.column cimport Column def capitalize(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/case.pyx b/python/cudf/cudf/_lib/strings/case.pyx index 6f114519374..13679f3fb02 100644 --- a/python/cudf/cudf/_lib/strings/case.pyx +++ b/python/cudf/cudf/_lib/strings/case.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.case cimport ( swapcase as cpp_swapcase, to_lower as cpp_to_lower, - to_upper as cpp_to_upper + to_upper as cpp_to_upper, ) -from cudf._lib.column cimport Column def to_upper(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/char_types.pyx b/python/cudf/cudf/_lib/strings/char_types.pyx index 1890e98f956..3ef9db2345d 100644 --- a/python/cudf/cudf/_lib/strings/char_types.pyx +++ b/python/cudf/cudf/_lib/strings/char_types.pyx @@ -4,17 +4,16 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.char_types cimport ( all_characters_of_type as cpp_all_characters_of_type, filter_characters_of_type as cpp_filter_characters_of_type, string_character_types as string_character_types, ) +from cudf._lib.scalar cimport DeviceScalar def filter_alphanum(Column source_strings, object py_repl, bool keep=True): diff --git a/python/cudf/cudf/_lib/strings/combine.pyx b/python/cudf/cudf/_lib/strings/combine.pyx index 25619de3ed0..b24f8ff666f 100644 --- a/python/cudf/cudf/_lib/strings/combine.pyx +++ b/python/cudf/cudf/_lib/strings/combine.pyx @@ -1,23 +1,22 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type + from cudf._lib.column cimport Column -from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string -from cudf._lib.table cimport Table - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.combine cimport ( concatenate as cpp_concatenate, + concatenate_list_elements as cpp_concatenate_list_elements, join_strings as cpp_join_strings, - concatenate_list_elements as cpp_concatenate_list_elements ) +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def concatenate(Table source_strings, diff --git a/python/cudf/cudf/_lib/strings/contains.pyx b/python/cudf/cudf/_lib/strings/contains.pyx index 256803c9479..1f622378280 100644 --- a/python/cudf/cudf/_lib/strings/contains.pyx +++ b/python/cudf/cudf/_lib/strings/contains.pyx @@ -1,18 +1,18 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.contains cimport ( contains_re as cpp_contains_re, count_re as cpp_count_re, - matches_re as cpp_matches_re + matches_re as cpp_matches_re, ) -from libcpp.string cimport string +from cudf._lib.scalar cimport DeviceScalar def contains_re(Column source_strings, object reg_ex): diff --git a/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx b/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx index 38d238b8266..ae61df3d271 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx @@ -3,27 +3,26 @@ import numpy as np from cudf._lib.column cimport Column + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id + from cudf._lib.cpp.types cimport DECIMAL64 +from cudf._lib.types cimport underlying_type_t_type_id from cudf.core.column.column import as_column +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string +from libcpp.utility cimport move + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_fixed_point cimport ( - to_fixed_point as cpp_to_fixed_point, from_fixed_point as cpp_from_fixed_point, - is_fixed_point as cpp_is_fixed_point -) -from cudf._lib.cpp.types cimport ( - type_id, - data_type, + is_fixed_point as cpp_is_fixed_point, + to_fixed_point as cpp_to_fixed_point, ) - -from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move -from libcpp.string cimport string +from cudf._lib.cpp.types cimport data_type, type_id def from_decimal(Column input_col): diff --git a/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx b/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx index 195d9b71f6e..d47b1e6e651 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx @@ -4,10 +4,9 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_floats cimport ( is_float as cpp_is_float, ) diff --git a/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx b/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx index d1bae1edd37..08bcca93086 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx @@ -4,10 +4,9 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_integers cimport ( is_integer as cpp_is_integer, ) diff --git a/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx b/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx index 6aab99b3ec5..c391719e853 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx @@ -2,13 +2,13 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_urls cimport ( - url_encode as cpp_url_encode, url_decode as cpp_url_decode, + url_encode as cpp_url_encode, ) diff --git a/python/cudf/cudf/_lib/strings/extract.pyx b/python/cudf/cudf/_lib/strings/extract.pyx index 5828b62b999..58558fade24 100644 --- a/python/cudf/cudf/_lib/strings/extract.pyx +++ b/python/cudf/cudf/_lib/strings/extract.pyx @@ -1,20 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.strings.extract cimport extract as cpp_extract from cudf._lib.cpp.table.table cimport table +from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table -from cudf._lib.cpp.column.column cimport column - -from cudf._lib.cpp.strings.extract cimport ( - extract as cpp_extract -) -from libcpp.string cimport string - def extract(Column source_strings, object pattern): """ diff --git a/python/cudf/cudf/_lib/strings/find.pyx b/python/cudf/cudf/_lib/strings/find.pyx index 3a360d31ef2..788c0a2524a 100644 --- a/python/cudf/cudf/_lib/strings/find.pyx +++ b/python/cudf/cudf/_lib/strings/find.pyx @@ -1,21 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type - from cudf._lib.cpp.strings.find cimport ( contains as cpp_contains, ends_with as cpp_ends_with, - starts_with as cpp_starts_with, find as cpp_find, - rfind as cpp_rfind + rfind as cpp_rfind, + starts_with as cpp_starts_with, ) +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def contains(Column source_strings, object py_target): diff --git a/python/cudf/cudf/_lib/strings/find_multiple.pyx b/python/cudf/cudf/_lib/strings/find_multiple.pyx index 5c33be07d15..4ac86ce4ef5 100644 --- a/python/cudf/cudf/_lib/strings/find_multiple.pyx +++ b/python/cudf/cudf/_lib/strings/find_multiple.pyx @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.find_multiple cimport ( find_multiple as cpp_find_multiple, ) diff --git a/python/cudf/cudf/_lib/strings/findall.pyx b/python/cudf/cudf/_lib/strings/findall.pyx index 7dbfbe62def..cc5730c467d 100644 --- a/python/cudf/cudf/_lib/strings/findall.pyx +++ b/python/cudf/cudf/_lib/strings/findall.pyx @@ -1,20 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.table.table cimport table -from cudf._lib.table cimport Table +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar - -from cudf._lib.cpp.strings.findall cimport ( - findall_re as cpp_findall_re -) -from libcpp.string cimport string +from cudf._lib.cpp.strings.findall cimport findall_re as cpp_findall_re +from cudf._lib.cpp.table.table cimport table +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def findall(Column source_strings, pattern): diff --git a/python/cudf/cudf/_lib/strings/json.pyx b/python/cudf/cudf/_lib/strings/json.pyx index 211bbe9d4f0..c7545b6e481 100644 --- a/python/cudf/cudf/_lib/strings/json.pyx +++ b/python/cudf/cudf/_lib/strings/json.pyx @@ -2,16 +2,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.strings.json cimport get_json_object as cpp_get_json_object from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.column.column cimport column - -from cudf._lib.cpp.strings.json cimport ( - get_json_object as cpp_get_json_object -) def get_json_object(Column col, object py_json_path): diff --git a/python/cudf/cudf/_lib/strings/padding.pyx b/python/cudf/cudf/_lib/strings/padding.pyx index 52c66495d92..c7b97977d60 100644 --- a/python/cudf/cudf/_lib/strings/padding.pyx +++ b/python/cudf/cudf/_lib/strings/padding.pyx @@ -2,19 +2,22 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar + from enum import IntEnum + from libcpp.string cimport string -from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.strings.padding cimport ( pad as cpp_pad, + pad_side as pad_side, zfill as cpp_zfill, - pad_side as pad_side ) from cudf._lib.strings.padding cimport underlying_type_t_pad_side diff --git a/python/cudf/cudf/_lib/strings/replace.pyx b/python/cudf/cudf/_lib/strings/replace.pyx index 429e356be4a..f5c47d2a2ed 100644 --- a/python/cudf/cudf/_lib/strings/replace.pyx +++ b/python/cudf/cudf/_lib/strings/replace.pyx @@ -1,24 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column - -from libc.stdint cimport int32_t - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.replace cimport ( + replace as cpp_replace, replace_slice as cpp_replace_slice, - replace as cpp_replace -) - -from cudf._lib.cpp.strings.substring cimport ( - slice_strings as cpp_slice_strings ) +from cudf._lib.cpp.strings.substring cimport slice_strings as cpp_slice_strings +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def slice_replace(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/replace_re.pyx b/python/cudf/cudf/_lib/strings/replace_re.pyx index 7993e3a172f..20fb903c60c 100644 --- a/python/cudf/cudf/_lib/strings/replace_re.pyx +++ b/python/cudf/cudf/_lib/strings/replace_re.pyx @@ -1,21 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.types cimport size_type from libcpp.vector cimport vector +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar - from cudf._lib.cpp.strings.replace_re cimport ( replace_re as cpp_replace_re, - replace_with_backrefs as cpp_replace_with_backrefs + replace_with_backrefs as cpp_replace_with_backrefs, ) -from libcpp.string cimport string +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def replace_re(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/split/partition.pyx b/python/cudf/cudf/_lib/strings/split/partition.pyx index 64d625bcb26..590de5bf526 100644 --- a/python/cudf/cudf/_lib/strings/split/partition.pyx +++ b/python/cudf/cudf/_lib/strings/split/partition.pyx @@ -1,23 +1,22 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.split.partition cimport ( partition as cpp_partition, rpartition as cpp_rpartition, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def partition(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/split/split.pyx b/python/cudf/cudf/_lib/strings/split/split.pyx index 2dd66f99ad5..599f7602b51 100644 --- a/python/cudf/cudf/_lib/strings/split/split.pyx +++ b/python/cudf/cudf/_lib/strings/split/split.pyx @@ -1,25 +1,24 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table -from cudf._lib.cpp.table.table cimport table +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.split.split cimport ( - split as cpp_split, rsplit as cpp_rsplit, + rsplit_record as cpp_rsplit_record, + split as cpp_split, split_record as cpp_split_record, - rsplit_record as cpp_rsplit_record ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def split(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/strip.pyx b/python/cudf/cudf/_lib/strings/strip.pyx index 72dffa3d897..d3430a53cc6 100644 --- a/python/cudf/cudf/_lib/strings/strip.pyx +++ b/python/cudf/cudf/_lib/strings/strip.pyx @@ -1,19 +1,19 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.strip cimport ( strip as cpp_strip, - strip_type as strip_type + strip_type as strip_type, ) +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def strip(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/substring.pyx b/python/cudf/cudf/_lib/strings/substring.pyx index add9e67b09f..761e9503aba 100644 --- a/python/cudf/cudf/_lib/strings/substring.pyx +++ b/python/cudf/cudf/_lib/strings/substring.pyx @@ -1,20 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type + import numpy as np -from cudf._lib.cpp.strings.substring cimport ( - slice_strings as cpp_slice_strings -) +from cudf._lib.cpp.strings.substring cimport slice_strings as cpp_slice_strings from cudf._lib.scalar import as_device_scalar -from cudf._lib.scalar cimport DeviceScalar + from cudf._lib.cpp.scalar.scalar cimport numeric_scalar +from cudf._lib.scalar cimport DeviceScalar def slice_strings(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/translate.pyx b/python/cudf/cudf/_lib/strings/translate.pyx index 32b145736ca..7a5cf502ba3 100644 --- a/python/cudf/cudf/_lib/strings/translate.pyx +++ b/python/cudf/cudf/_lib/strings/translate.pyx @@ -2,21 +2,21 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move +from libcpp.vector cimport vector +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.translate cimport ( - translate as cpp_translate, + filter_characters as cpp_filter_characters, filter_type as filter_type, - filter_characters as cpp_filter_characters + translate as cpp_translate, ) -from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from libcpp.vector cimport vector -from libcpp.pair cimport pair from cudf._lib.cpp.types cimport char_utf8 +from cudf._lib.scalar cimport DeviceScalar def translate(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/wrap.pyx b/python/cudf/cudf/_lib/strings/wrap.pyx index 814df1f1a72..5ebc33f77ef 100644 --- a/python/cudf/cudf/_lib/strings/wrap.pyx +++ b/python/cudf/cudf/_lib/strings/wrap.pyx @@ -2,14 +2,12 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view + +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.strings.wrap cimport wrap as cpp_wrap from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column - -from cudf._lib.cpp.strings.wrap cimport ( - wrap as cpp_wrap -) def wrap(Column source_strings, diff --git a/python/cudf/cudf/_lib/table.pxd b/python/cudf/cudf/_lib/table.pxd index ff0223b2519..e1bffbc3864 100644 --- a/python/cudf/cudf/_lib/table.pxd +++ b/python/cudf/cudf/_lib/table.pxd @@ -3,9 +3,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport ( - table_view, mutable_table_view -) +from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view cdef class Table: diff --git a/python/cudf/cudf/_lib/table.pyi b/python/cudf/cudf/_lib/table.pyi index 772e940f812..2a5dfb2a4dd 100644 --- a/python/cudf/cudf/_lib/table.pyi +++ b/python/cudf/cudf/_lib/table.pyi @@ -1,6 +1,6 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from typing import List, Any, Optional, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, List, Optional import cudf diff --git a/python/cudf/cudf/_lib/table.pyx b/python/cudf/cudf/_lib/table.pyx index 93d79ba6843..07d7a0fcf02 100644 --- a/python/cudf/cudf/_lib/table.pyx +++ b/python/cudf/cudf/_lib/table.pyx @@ -8,23 +8,16 @@ from cudf.core.column_accessor import ColumnAccessor from cython.operator cimport dereference from libc.stdint cimport uintptr_t -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector from cudf._lib.column cimport Column - -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport ( - table_view, - mutable_table_view -) +from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view +from cudf._lib.cpp.types cimport size_type cdef class Table: diff --git a/python/cudf/cudf/_lib/transform.pyx b/python/cudf/cudf/_lib/transform.pyx index 2c83f8b86e0..c8b448b6e30 100644 --- a/python/cudf/cudf/_lib/transform.pyx +++ b/python/cudf/cudf/_lib/transform.pyx @@ -1,33 +1,32 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import cudf import numpy as np + +import cudf from cudf.utils import cudautils from libc.stdint cimport uintptr_t - -from libcpp.string cimport string from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.pair cimport pair +from libcpp.string cimport string +from libcpp.utility cimport move + +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from cudf._lib.column cimport Column from cudf._lib.table cimport Table -from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer + from cudf.core.buffer import Buffer -from cudf._lib.cpp.types cimport ( - bitmask_type, - data_type, - size_type, - type_id, -) +from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type, type_id + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.types cimport underlying_type_t_type_id from numba.np import numpy_support diff --git a/python/cudf/cudf/_lib/transpose.pyx b/python/cudf/cudf/_lib/transpose.pyx index d2b053789cd..d12cfa7511d 100644 --- a/python/cudf/cudf/_lib/transpose.pyx +++ b/python/cudf/cudf/_lib/transpose.pyx @@ -4,19 +4,16 @@ import cudf from cudf.utils.dtypes import is_categorical_dtype from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.pair cimport pair +from libcpp.utility cimport move from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.transpose cimport ( - transpose as cpp_transpose -) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.transpose cimport transpose as cpp_transpose +from cudf._lib.table cimport Table def transpose(Table source): diff --git a/python/cudf/cudf/_lib/types.pxd b/python/cudf/cudf/_lib/types.pxd index 383b3665bd9..dbbe9b1e05a 100644 --- a/python/cudf/cudf/_lib/types.pxd +++ b/python/cudf/cudf/_lib/types.pxd @@ -2,9 +2,10 @@ from libc.stdint cimport int32_t from libcpp cimport bool + +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -cimport cudf._lib.cpp.types as libcudf_types ctypedef bool underlying_type_t_order ctypedef bool underlying_type_t_null_order diff --git a/python/cudf/cudf/_lib/types.pyx b/python/cudf/cudf/_lib/types.pyx index e9ed4f21ddd..4b83208f772 100644 --- a/python/cudf/cudf/_lib/types.pyx +++ b/python/cudf/cudf/_lib/types.pyx @@ -4,17 +4,18 @@ from enum import IntEnum import numpy as np -from libcpp.memory cimport shared_ptr, make_shared +from libcpp.memory cimport make_shared, shared_ptr +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.types cimport ( - underlying_type_t_order, + underlying_type_t_interpolation, underlying_type_t_null_order, + underlying_type_t_order, underlying_type_t_sorted, - underlying_type_t_interpolation ) -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf.core.dtypes import ListDtype, StructDtype, Decimal64Dtype + +from cudf.core.dtypes import Decimal64Dtype, ListDtype, StructDtype from cudf.utils.dtypes import is_decimal_dtype, is_list_dtype, is_struct_dtype cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/unary.pyx b/python/cudf/cudf/_lib/unary.pyx index 3bac0cde9c6..c06723fe442 100644 --- a/python/cudf/cudf/_lib/unary.pyx +++ b/python/cudf/cudf/_lib/unary.pyx @@ -1,34 +1,29 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. from enum import IntEnum + from cudf.utils.dtypes import is_decimal_dtype from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + import numpy as np from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view + from cudf._lib.types import np_to_cudf_types -from cudf._lib.cpp.types cimport ( - size_type, - data_type, - type_id, -) -from cudf._lib.column import np_to_cudf_types, cudf_to_np_types -from cudf._lib.cpp.unary cimport ( - underlying_type_t_unary_op, - unary_operator, -) - -from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type -cimport cudf._lib.cpp.unary as libcudf_unary +from cudf._lib.cpp.types cimport data_type, size_type, type_id + +from cudf._lib.column import cudf_to_np_types, np_to_cudf_types + cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.unary as libcudf_unary +from cudf._lib.cpp.unary cimport unary_operator, underlying_type_t_unary_op +from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id class UnaryOp(IntEnum): diff --git a/python/cudf/cudf/_lib/utils.pxd b/python/cudf/cudf/_lib/utils.pxd index 03a032ac131..e8ac858d8b2 100644 --- a/python/cudf/cudf/_lib/utils.pxd +++ b/python/cudf/cudf/_lib/utils.pxd @@ -2,10 +2,12 @@ from libcpp.string cimport string from libcpp.vector cimport vector + from cudf._lib.cpp.column.column cimport column_view from cudf._lib.cpp.table.table cimport table_view from cudf._lib.table cimport Table + cdef vector[column_view] make_column_views(object columns) except* cdef vector[table_view] make_table_views(object tables) except* cdef vector[table_view] make_table_data_views(object tables) except* diff --git a/python/cudf/cudf/_lib/utils.pyx b/python/cudf/cudf/_lib/utils.pyx index 13eedb34c18..b0ca36e730a 100644 --- a/python/cudf/cudf/_lib/utils.pyx +++ b/python/cudf/cudf/_lib/utils.pyx @@ -1,29 +1,29 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -import cudf - import pyarrow as pa -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table -from cudf._lib.cpp.column.column cimport column_view -from cudf._lib.cpp.table.table cimport table_view +import cudf from libc.stdint cimport uint8_t from libcpp.string cimport string from libcpp.vector cimport vector +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column_view +from cudf._lib.cpp.table.table cimport table_view +from cudf._lib.table cimport Table + try: import ujson as json except ImportError: import json from cudf.utils.dtypes import ( - np_to_pa_dtype, is_categorical_dtype, + is_decimal_dtype, is_list_dtype, is_struct_dtype, - is_decimal_dtype, + np_to_pa_dtype, ) diff --git a/python/cudf/cudf/api/extensions/accessor.py b/python/cudf/cudf/api/extensions/accessor.py index 0d1f78cdd33..8c0c4332d72 100644 --- a/python/cudf/cudf/api/extensions/accessor.py +++ b/python/cudf/cudf/api/extensions/accessor.py @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf.utils.docutils import docfmt_partial import warnings -import cudf from pandas.core.accessor import CachedAccessor +import cudf +from cudf.utils.docutils import docfmt_partial _docstring_register_accessor = """ Extends `cudf.{klass}` with custom defined accessor diff --git a/python/cudf/cudf/benchmarks/bench_cudf_io.py b/python/cudf/cudf/benchmarks/bench_cudf_io.py index 1a01904374c..20f5afa1eaf 100644 --- a/python/cudf/cudf/benchmarks/bench_cudf_io.py +++ b/python/cudf/cudf/benchmarks/bench_cudf_io.py @@ -1,11 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import pytest -import cudf import glob import io + +import pytest from conftest import option +import cudf + def get_dataset_dir(): if option.dataset_dir == "NONE": diff --git a/python/cudf/cudf/benchmarks/get_datasets.py b/python/cudf/cudf/benchmarks/get_datasets.py index c793970eb3f..f3b66eda512 100644 --- a/python/cudf/cudf/benchmarks/get_datasets.py +++ b/python/cudf/cudf/benchmarks/get_datasets.py @@ -1,8 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +import argparse import os import shutil -import argparse from collections import namedtuple # Update url and dir where datasets needs to be copied diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index 25552009444..9b48c1ce259 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -28,8 +28,8 @@ from cudf.utils.dtypes import ( is_categorical_dtype, is_column_like, - is_numerical_dtype, is_decimal_dtype, + is_numerical_dtype, is_scalar, min_scalar_type, ) diff --git a/python/cudf/cudf/core/subword_tokenizer.py b/python/cudf/cudf/core/subword_tokenizer.py index 9058491d8e7..60139f7d7af 100644 --- a/python/cudf/cudf/core/subword_tokenizer.py +++ b/python/cudf/cudf/core/subword_tokenizer.py @@ -1,13 +1,15 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from __future__ import annotations + from typing import Union -import cupy as cp from warnings import warn +import cupy as cp + from cudf._lib.nvtext.subword_tokenize import ( - subword_tokenize_inmem_hash as cpp_subword_tokenize, Hashed_Vocabulary as cpp_hashed_vocabulary, + subword_tokenize_inmem_hash as cpp_subword_tokenize, ) diff --git a/python/cudf/cudf/core/tools/numeric.py b/python/cudf/cudf/core/tools/numeric.py index 74f7d16e4ff..bd67c4a60eb 100644 --- a/python/cudf/cudf/core/tools/numeric.py +++ b/python/cudf/cudf/core/tools/numeric.py @@ -6,20 +6,19 @@ import pandas as pd import cudf +import cudf._lib as libcudf from cudf.core.column import as_column from cudf.utils.dtypes import ( can_convert_to_column, - is_numerical_dtype, - is_datetime_dtype, - is_timedelta_dtype, is_categorical_dtype, - is_string_dtype, + is_datetime_dtype, is_list_dtype, + is_numerical_dtype, + is_string_dtype, is_struct_dtype, + is_timedelta_dtype, ) -import cudf._lib as libcudf - def to_numeric(arg, errors="raise", downcast=None): """ diff --git a/python/cudf/cudf/tests/test_array_ufunc.py b/python/cudf/cudf/tests/test_array_ufunc.py index f9e0bb2ce8a..c459caace0e 100644 --- a/python/cudf/cudf/tests/test_array_ufunc.py +++ b/python/cudf/cudf/tests/test_array_ufunc.py @@ -1,8 +1,9 @@ -import cudf -import numpy as np import cupy as cp +import numpy as np import pandas as pd import pytest + +import cudf from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_compile_udf.py b/python/cudf/cudf/tests/test_compile_udf.py index 96c0e91d8d7..d965f35ccdd 100644 --- a/python/cudf/cudf/tests/test_compile_udf.py +++ b/python/cudf/cudf/tests/test_compile_udf.py @@ -1,8 +1,9 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from cudf.utils import cudautils from numba import types +from cudf.utils import cudautils + def setup_function(): cudautils._udf_code_cache.clear() diff --git a/python/cudf/cudf/tests/test_concat.py b/python/cudf/cudf/tests/test_concat.py index 31dc6012905..b68c9d929cd 100644 --- a/python/cudf/cudf/tests/test_concat.py +++ b/python/cudf/cudf/tests/test_concat.py @@ -7,9 +7,9 @@ import pytest import cudf as gd +from cudf.core.dtypes import Decimal64Dtype from cudf.tests.utils import assert_eq, assert_exceptions_equal from cudf.utils.dtypes import is_categorical_dtype -from cudf.core.dtypes import Decimal64Dtype def make_frames(index=None, nulls="none"): diff --git a/python/cudf/cudf/tests/test_custom_accessor.py b/python/cudf/cudf/tests/test_custom_accessor.py index d72b5875677..46970f4762d 100644 --- a/python/cudf/cudf/tests/test_custom_accessor.py +++ b/python/cudf/cudf/tests/test_custom_accessor.py @@ -2,8 +2,8 @@ import pandas as pd import pytest -import cudf as gd +import cudf as gd from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_dtypes.py b/python/cudf/cudf/tests/test_dtypes.py index b6e2aac0304..174625a7b89 100644 --- a/python/cudf/cudf/tests/test_dtypes.py +++ b/python/cudf/cudf/tests/test_dtypes.py @@ -9,9 +9,9 @@ from cudf.core.dtypes import ( CategoricalDtype, Decimal64Dtype, + IntervalDtype, ListDtype, StructDtype, - IntervalDtype, ) from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_hash_vocab.py b/python/cudf/cudf/tests/test_hash_vocab.py index 529552cb2d9..a30f4e20849 100644 --- a/python/cudf/cudf/tests/test_hash_vocab.py +++ b/python/cudf/cudf/tests/test_hash_vocab.py @@ -1,9 +1,11 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from cudf.utils.hash_vocab_utils import hash_vocab -import os import filecmp +import os + import pytest +from cudf.utils.hash_vocab_utils import hash_vocab + @pytest.fixture(scope="module") def datadir(datadir): diff --git a/python/cudf/cudf/tests/test_replace.py b/python/cudf/cudf/tests/test_replace.py index 6dca539b8d5..14338c2e64a 100644 --- a/python/cudf/cudf/tests/test_replace.py +++ b/python/cudf/cudf/tests/test_replace.py @@ -1,11 +1,11 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. import re +from decimal import Decimal import numpy as np import pandas as pd import pytest -from decimal import Decimal import cudf from cudf.core.dtypes import Decimal64Dtype diff --git a/python/cudf/cudf/tests/test_scan.py b/python/cudf/cudf/tests/test_scan.py index f7e8c5a8563..f77fc0b19da 100644 --- a/python/cudf/cudf/tests/test_scan.py +++ b/python/cudf/cudf/tests/test_scan.py @@ -5,8 +5,8 @@ import pytest import cudf -from cudf.tests.utils import INTEGER_TYPES, NUMERIC_TYPES, assert_eq, gen_rand from cudf.core.dtypes import Decimal64Dtype +from cudf.tests.utils import INTEGER_TYPES, NUMERIC_TYPES, assert_eq, gen_rand params_sizes = [0, 1, 2, 5] diff --git a/python/cudf/cudf/tests/test_seriesmap.py b/python/cudf/cudf/tests/test_seriesmap.py index 324074b6021..6fd1a70433b 100644 --- a/python/cudf/cudf/tests/test_seriesmap.py +++ b/python/cudf/cudf/tests/test_seriesmap.py @@ -4,10 +4,10 @@ from math import floor import numpy as np -import cudf import pandas as pd import pytest +import cudf from cudf import Series from cudf.tests.utils import assert_eq, assert_exceptions_equal diff --git a/python/cudf/cudf/tests/test_subword_tokenizer.py b/python/cudf/cudf/tests/test_subword_tokenizer.py index bdb343a41f7..d5207c79b86 100644 --- a/python/cudf/cudf/tests/test_subword_tokenizer.py +++ b/python/cudf/cudf/tests/test_subword_tokenizer.py @@ -1,8 +1,9 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from transformers import BertTokenizer -import pytest import os + import numpy as np +import pytest +from transformers import BertTokenizer import cudf from cudf.core.subword_tokenizer import SubwordTokenizer diff --git a/python/cudf/cudf/tests/test_udf_binops.py b/python/cudf/cudf/tests/test_udf_binops.py index 00d05a8c3a5..df7361ab183 100644 --- a/python/cudf/cudf/tests/test_udf_binops.py +++ b/python/cudf/cudf/tests/test_udf_binops.py @@ -3,14 +3,13 @@ import numpy as np import pytest +from numba.cuda import compile_ptx +from numba.np import numpy_support from cudf import _lib as libcudf from cudf.core import Series from cudf.utils import dtypes as dtypeutils -from numba.cuda import compile_ptx -from numba.np import numpy_support - @pytest.mark.parametrize( "dtype", sorted(list(dtypeutils.NUMERIC_TYPES - {"int8"})) diff --git a/python/cudf/cudf/utils/applyutils.py b/python/cudf/cudf/utils/applyutils.py index 610b0997d85..c8fb7c1a47d 100644 --- a/python/cudf/cudf/utils/applyutils.py +++ b/python/cudf/cudf/utils/applyutils.py @@ -4,6 +4,7 @@ from typing import Any, Dict from numba import cuda +from numba.core.utils import pysignature import cudf from cudf import _lib as libcudf @@ -11,9 +12,6 @@ from cudf.utils import utils from cudf.utils.docutils import docfmt_partial -from numba.core.utils import pysignature - - _doc_applyparams = """ df : DataFrame The source dataframe. diff --git a/python/cudf/cudf/utils/cudautils.py b/python/cudf/cudf/utils/cudautils.py index 262fe304dd8..df3b6ec3d93 100755 --- a/python/cudf/cudf/utils/cudautils.py +++ b/python/cudf/cudf/utils/cudautils.py @@ -4,11 +4,9 @@ import cachetools import numpy as np from numba import cuda - -import cudf - from numba.np import numpy_support +import cudf # # Misc kernels diff --git a/python/cudf/cudf/utils/utils.py b/python/cudf/cudf/utils/utils.py index f1841129e20..96d89a829cf 100644 --- a/python/cudf/cudf/utils/utils.py +++ b/python/cudf/cudf/utils/utils.py @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -import functools import decimal +import functools from collections.abc import Sequence from typing import FrozenSet, Set, Union diff --git a/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd b/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd index d7c310fc6e2..fc985e58b68 100644 --- a/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd +++ b/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd @@ -1,12 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport int32_t, int64_t +from libcpp cimport bool +from libcpp.map cimport map +from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.map cimport map -from libcpp cimport bool -from libc.stdint cimport int32_t, int64_t + from cudf._lib.cpp.io.types cimport datasource -from libcpp.memory cimport unique_ptr from cudf._lib.io.datasource cimport Datasource diff --git a/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx b/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx index fad62eb38b0..5588b69938b 100644 --- a/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx +++ b/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx @@ -1,13 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.string cimport string -from libcpp.map cimport map from libc.stdint cimport int32_t, int64_t from libcpp cimport bool +from libcpp.map cimport map +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.io.types cimport datasource -from libcpp.memory cimport unique_ptr, make_unique + from cudf_kafka._lib.kafka cimport kafka_consumer + cdef class KafkaDatasource(Datasource): def __cinit__(self, diff --git a/python/custreamz/custreamz/tests/test_dataframes.py b/python/custreamz/custreamz/tests/test_dataframes.py index d5fffd30d57..24f6e46f6c5 100644 --- a/python/custreamz/custreamz/tests/test_dataframes.py +++ b/python/custreamz/custreamz/tests/test_dataframes.py @@ -12,13 +12,14 @@ import numpy as np import pandas as pd import pytest -from streamz import Stream -from streamz.dask import DaskStream -from streamz.dataframe import Aggregation, DataFrame, DataFrames, Series from dask.dataframe.utils import assert_eq from distributed import Client +from streamz import Stream +from streamz.dask import DaskStream +from streamz.dataframe import Aggregation, DataFrame, DataFrames, Series + cudf = pytest.importorskip("cudf") diff --git a/python/dask_cudf/dask_cudf/tests/test_accessor.py b/python/dask_cudf/dask_cudf/tests/test_accessor.py index 76589682717..0077225754b 100644 --- a/python/dask_cudf/dask_cudf/tests/test_accessor.py +++ b/python/dask_cudf/dask_cudf/tests/test_accessor.py @@ -5,11 +5,11 @@ from dask import dataframe as dd -import dask_cudf as dgd - from cudf import DataFrame, Series from cudf.tests.utils import assert_eq +import dask_cudf as dgd + ############################################################################# # Datetime Accessor # ############################################################################# diff --git a/python/dask_cudf/dask_cudf/tests/test_delayed_io.py b/python/dask_cudf/dask_cudf/tests/test_delayed_io.py index a103d9fe8c2..7789664afae 100644 --- a/python/dask_cudf/dask_cudf/tests/test_delayed_io.py +++ b/python/dask_cudf/dask_cudf/tests/test_delayed_io.py @@ -7,10 +7,10 @@ from dask.delayed import delayed -import dask_cudf as dgd - import cudf as gd +import dask_cudf as dgd + @delayed def load_data(nelem, ident): diff --git a/python/dask_cudf/dask_cudf/tests/test_join.py b/python/dask_cudf/dask_cudf/tests/test_join.py index d8781af6c6e..58811ee98fc 100644 --- a/python/dask_cudf/dask_cudf/tests/test_join.py +++ b/python/dask_cudf/dask_cudf/tests/test_join.py @@ -6,10 +6,10 @@ from dask import dataframe as dd -import dask_cudf as dgd - import cudf +import dask_cudf as dgd + param_nrows = [5, 10, 50, 100] diff --git a/python/dask_cudf/dask_cudf/tests/test_reductions.py b/python/dask_cudf/dask_cudf/tests/test_reductions.py index 030b7717fbc..c34fbc3b0e7 100644 --- a/python/dask_cudf/dask_cudf/tests/test_reductions.py +++ b/python/dask_cudf/dask_cudf/tests/test_reductions.py @@ -6,10 +6,10 @@ from dask import dataframe as dd -import dask_cudf as dgd - import cudf +import dask_cudf as dgd + def _make_random_frame(nelem, npartitions=2): df = pd.DataFrame( diff --git a/python/dask_cudf/dask_cudf/tests/test_sort.py b/python/dask_cudf/dask_cudf/tests/test_sort.py index 855b2bb9a0b..a12d5792219 100644 --- a/python/dask_cudf/dask_cudf/tests/test_sort.py +++ b/python/dask_cudf/dask_cudf/tests/test_sort.py @@ -4,10 +4,10 @@ import dask from dask import dataframe as dd -import dask_cudf - import cudf +import dask_cudf + @pytest.mark.parametrize("by", ["a", "b", "c", "d", ["a", "b"], ["c", "d"]]) @pytest.mark.parametrize("nelem", [10, 500]) From bdb23db8fc6e91bbe90b4dbf9cea0b91ac416eb4 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Mon, 21 Jun 2021 14:31:56 -0400 Subject: [PATCH 09/18] Revert "Run updated hooks across codebase" This reverts commit 220a722b3d584cad6447e6d73b85ca73b038a837. --- .../tests/kafka_consumer_tests.cpp | 2 +- java/src/main/native/include/jni_utils.hpp | 25 +- java/src/main/native/src/AggregationJni.cpp | 26 +- java/src/main/native/src/ColumnVectorJni.cpp | 108 ++--- java/src/main/native/src/ColumnViewJni.cpp | 374 ++++++++++-------- .../main/native/src/ContiguousTableJni.cpp | 2 +- java/src/main/native/src/CudaJni.cpp | 3 +- .../src/HostMemoryBufferNativeUtilsJni.cpp | 42 +- java/src/main/native/src/NvcompJni.cpp | 366 +++++++++-------- java/src/main/native/src/NvtxRangeJni.cpp | 10 +- java/src/main/native/src/ScalarJni.cpp | 18 +- java/src/main/native/src/TableJni.cpp | 247 ++++++------ java/src/main/native/src/cudf_jni_apis.hpp | 2 +- java/src/main/native/src/dtype_utils.hpp | 12 +- java/src/main/native/src/map_lookup.cu | 6 +- java/src/main/native/src/prefix_sum.cu | 20 +- java/src/main/native/src/prefix_sum.hpp | 3 +- python/cudf/cudf/_lib/aggregation.pxd | 4 +- python/cudf/cudf/_lib/aggregation.pyx | 15 +- python/cudf/cudf/_lib/avro.pyx | 11 +- python/cudf/cudf/_lib/binaryop.pxd | 1 + python/cudf/cudf/_lib/binaryop.pyx | 19 +- python/cudf/cudf/_lib/column.pxd | 7 +- python/cudf/cudf/_lib/column.pyi | 6 +- python/cudf/cudf/_lib/column.pyx | 33 +- python/cudf/cudf/_lib/concat.pyx | 18 +- python/cudf/cudf/_lib/copying.pyx | 24 +- python/cudf/cudf/_lib/cpp/aggregation.pxd | 6 +- python/cudf/cudf/_lib/cpp/binaryop.pxd | 7 +- python/cudf/cudf/_lib/cpp/column/column.pxd | 10 +- .../cudf/_lib/cpp/column/column_factories.pxd | 9 +- .../cudf/cudf/_lib/cpp/column/column_view.pxd | 8 +- python/cudf/cudf/_lib/cpp/concatenate.pxd | 3 +- python/cudf/cudf/_lib/cpp/copying.pxd | 11 +- python/cudf/cudf/_lib/cpp/filling.pxd | 6 +- python/cudf/cudf/_lib/cpp/gpuarrow.pxd | 9 +- python/cudf/cudf/_lib/cpp/groupby.pxd | 12 +- python/cudf/cudf/_lib/cpp/hash.pxd | 2 +- python/cudf/cudf/_lib/cpp/interop.pxd | 10 +- python/cudf/cudf/_lib/cpp/io/avro.pxd | 2 +- python/cudf/cudf/_lib/cpp/io/csv.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/json.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/orc.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd | 2 +- python/cudf/cudf/_lib/cpp/io/parquet.pxd | 9 +- python/cudf/cudf/_lib/cpp/io/types.pxd | 6 +- python/cudf/cudf/_lib/cpp/join.pxd | 10 +- python/cudf/cudf/_lib/cpp/labeling.pxd | 1 - python/cudf/cudf/_lib/cpp/lists/contains.pxd | 4 +- .../cudf/_lib/cpp/lists/count_elements.pxd | 1 - .../_lib/cpp/lists/drop_list_duplicates.pxd | 5 +- python/cudf/cudf/_lib/cpp/lists/explode.pxd | 1 - python/cudf/cudf/_lib/cpp/lists/extract.pxd | 2 +- .../cudf/_lib/cpp/lists/lists_column_view.pxd | 4 +- python/cudf/cudf/_lib/cpp/lists/sorting.pxd | 2 +- python/cudf/cudf/_lib/cpp/merge.pxd | 4 +- python/cudf/cudf/_lib/cpp/null_mask.pxd | 2 +- .../cudf/_lib/cpp/nvtext/edit_distance.pxd | 1 - .../cudf/_lib/cpp/nvtext/generate_ngrams.pxd | 1 - .../cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd | 1 - .../cudf/cudf/_lib/cpp/nvtext/normalize.pxd | 1 - python/cudf/cudf/_lib/cpp/nvtext/replace.pxd | 2 +- python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd | 1 - .../cudf/_lib/cpp/nvtext/subword_tokenize.pxd | 3 +- python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd | 1 - python/cudf/cudf/_lib/cpp/partitioning.pxd | 6 +- python/cudf/cudf/_lib/cpp/quantiles.pxd | 5 +- python/cudf/cudf/_lib/cpp/reduce.pxd | 13 +- python/cudf/cudf/_lib/cpp/replace.pxd | 10 +- python/cudf/cudf/_lib/cpp/reshape.pxd | 3 +- python/cudf/cudf/_lib/cpp/rolling.pxd | 6 +- python/cudf/cudf/_lib/cpp/round.pxd | 1 - python/cudf/cudf/_lib/cpp/scalar/scalar.pxd | 5 +- python/cudf/cudf/_lib/cpp/search.pxd | 4 +- python/cudf/cudf/_lib/cpp/sorting.pxd | 5 +- .../cudf/cudf/_lib/cpp/stream_compaction.pxd | 13 +- .../cudf/cudf/_lib/cpp/strings/attributes.pxd | 1 - .../cudf/cudf/_lib/cpp/strings/capitalize.pxd | 1 - python/cudf/cudf/_lib/cpp/strings/case.pxd | 1 - .../cudf/cudf/_lib/cpp/strings/char_types.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/combine.pxd | 8 +- .../cudf/cudf/_lib/cpp/strings/contains.pxd | 3 +- .../cpp/strings/convert/convert_booleans.pxd | 3 +- .../cpp/strings/convert/convert_datetime.pxd | 5 +- .../cpp/strings/convert/convert_durations.pxd | 5 +- .../strings/convert/convert_fixed_point.pxd | 3 +- .../cpp/strings/convert/convert_floats.pxd | 3 +- .../cpp/strings/convert/convert_integers.pxd | 3 +- .../_lib/cpp/strings/convert/convert_ipv4.pxd | 3 +- .../_lib/cpp/strings/convert/convert_urls.pxd | 3 +- python/cudf/cudf/_lib/cpp/strings/extract.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/find.pxd | 4 +- .../cudf/_lib/cpp/strings/find_multiple.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/findall.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/json.pxd | 5 +- python/cudf/cudf/_lib/cpp/strings/padding.pxd | 9 +- python/cudf/cudf/_lib/cpp/strings/replace.pxd | 8 +- .../cudf/cudf/_lib/cpp/strings/replace_re.pxd | 9 +- .../cudf/_lib/cpp/strings/split/partition.pxd | 8 +- .../cudf/_lib/cpp/strings/split/split.pxd | 10 +- python/cudf/cudf/_lib/cpp/strings/strip.pxd | 6 +- .../cudf/cudf/_lib/cpp/strings/substring.pxd | 6 +- .../cudf/cudf/_lib/cpp/strings/translate.pxd | 7 +- python/cudf/cudf/_lib/cpp/strings/wrap.pxd | 6 +- python/cudf/cudf/_lib/cpp/table/table.pxd | 10 +- .../cudf/cudf/_lib/cpp/table/table_view.pxd | 6 +- python/cudf/cudf/_lib/cpp/transform.pxd | 10 +- python/cudf/cudf/_lib/cpp/unary.pxd | 13 +- .../cudf/_lib/cpp/utilities/host_span.pxd | 1 - .../cudf/cudf/_lib/cpp/wrappers/decimals.pxd | 3 +- python/cudf/cudf/_lib/csv.pyx | 22 +- python/cudf/cudf/_lib/datetime.pyx | 6 +- python/cudf/cudf/_lib/filling.pyx | 9 +- python/cudf/cudf/_lib/gpuarrow.pyx | 14 +- python/cudf/cudf/_lib/groupby.pyx | 28 +- python/cudf/cudf/_lib/hash.pyx | 15 +- python/cudf/cudf/_lib/interop.pyx | 24 +- python/cudf/cudf/_lib/io/datasource.pxd | 2 - python/cudf/cudf/_lib/io/datasource.pyx | 2 - python/cudf/cudf/_lib/io/utils.pxd | 3 +- python/cudf/cudf/_lib/io/utils.pyx | 17 +- python/cudf/cudf/_lib/join.pyx | 18 +- python/cudf/cudf/_lib/json.pyx | 9 +- python/cudf/cudf/_lib/labeling.pyx | 7 +- python/cudf/cudf/_lib/lists.pyx | 37 +- python/cudf/cudf/_lib/merge.pyx | 11 +- python/cudf/cudf/_lib/null_mask.pyx | 11 +- .../cudf/cudf/_lib/nvtext/edit_distance.pyx | 4 +- .../cudf/cudf/_lib/nvtext/generate_ngrams.pyx | 8 +- .../cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx | 8 +- python/cudf/cudf/_lib/nvtext/normalize.pyx | 4 +- python/cudf/cudf/_lib/nvtext/replace.pyx | 8 +- python/cudf/cudf/_lib/nvtext/stemmer.pyx | 12 +- .../cudf/_lib/nvtext/subword_tokenize.pyx | 13 +- python/cudf/cudf/_lib/nvtext/tokenize.pyx | 12 +- python/cudf/cudf/_lib/orc.pyx | 38 +- python/cudf/cudf/_lib/parquet.pyx | 64 +-- python/cudf/cudf/_lib/partitioning.pyx | 14 +- python/cudf/cudf/_lib/quantiles.pyx | 18 +- python/cudf/cudf/_lib/reduce.pyx | 19 +- python/cudf/cudf/_lib/replace.pyx | 16 +- python/cudf/cudf/_lib/reshape.pyx | 13 +- python/cudf/cudf/_lib/rolling.pyx | 13 +- python/cudf/cudf/_lib/round.pyx | 3 +- python/cudf/cudf/_lib/scalar.pyx | 46 +-- python/cudf/cudf/_lib/search.pyx | 9 +- python/cudf/cudf/_lib/sort.pxd | 1 - python/cudf/cudf/_lib/sort.pyx | 19 +- python/cudf/cudf/_lib/stream_compaction.pyx | 26 +- python/cudf/cudf/_lib/string_casting.pyx | 43 +- python/cudf/cudf/_lib/strings/attributes.pyx | 6 +- python/cudf/cudf/_lib/strings/capitalize.pyx | 2 +- python/cudf/cudf/_lib/strings/case.pyx | 4 +- python/cudf/cudf/_lib/strings/char_types.pyx | 7 +- python/cudf/cudf/_lib/strings/combine.pyx | 19 +- python/cudf/cudf/_lib/strings/contains.pyx | 10 +- .../strings/convert/convert_fixed_point.pyx | 21 +- .../_lib/strings/convert/convert_floats.pyx | 3 +- .../_lib/strings/convert/convert_integers.pyx | 3 +- .../_lib/strings/convert/convert_urls.pyx | 6 +- python/cudf/cudf/_lib/strings/extract.pyx | 15 +- python/cudf/cudf/_lib/strings/find.pyx | 12 +- .../cudf/cudf/_lib/strings/find_multiple.pyx | 4 +- python/cudf/cudf/_lib/strings/findall.pyx | 17 +- python/cudf/cudf/_lib/strings/json.pyx | 10 +- python/cudf/cudf/_lib/strings/padding.pyx | 9 +- python/cudf/cudf/_lib/strings/replace.pyx | 20 +- python/cudf/cudf/_lib/strings/replace_re.pyx | 13 +- .../cudf/_lib/strings/split/partition.pyx | 19 +- python/cudf/cudf/_lib/strings/split/split.pyx | 23 +- python/cudf/cudf/_lib/strings/strip.pyx | 14 +- python/cudf/cudf/_lib/strings/substring.pyx | 13 +- python/cudf/cudf/_lib/strings/translate.pyx | 12 +- python/cudf/cudf/_lib/strings/wrap.pyx | 10 +- python/cudf/cudf/_lib/table.pxd | 4 +- python/cudf/cudf/_lib/table.pyi | 2 +- python/cudf/cudf/_lib/table.pyx | 15 +- python/cudf/cudf/_lib/transform.pyx | 23 +- python/cudf/cudf/_lib/transpose.pyx | 13 +- python/cudf/cudf/_lib/types.pxd | 3 +- python/cudf/cudf/_lib/types.pyx | 13 +- python/cudf/cudf/_lib/unary.pyx | 27 +- python/cudf/cudf/_lib/utils.pxd | 2 - python/cudf/cudf/_lib/utils.pyx | 16 +- python/cudf/cudf/api/extensions/accessor.py | 4 +- python/cudf/cudf/benchmarks/bench_cudf_io.py | 6 +- python/cudf/cudf/benchmarks/get_datasets.py | 2 +- python/cudf/cudf/core/frame.py | 2 +- python/cudf/cudf/core/subword_tokenizer.py | 6 +- python/cudf/cudf/core/tools/numeric.py | 11 +- python/cudf/cudf/tests/test_array_ufunc.py | 5 +- python/cudf/cudf/tests/test_compile_udf.py | 3 +- python/cudf/cudf/tests/test_concat.py | 2 +- .../cudf/cudf/tests/test_custom_accessor.py | 2 +- python/cudf/cudf/tests/test_dtypes.py | 2 +- python/cudf/cudf/tests/test_hash_vocab.py | 6 +- python/cudf/cudf/tests/test_replace.py | 2 +- python/cudf/cudf/tests/test_scan.py | 2 +- python/cudf/cudf/tests/test_seriesmap.py | 2 +- .../cudf/cudf/tests/test_subword_tokenizer.py | 5 +- python/cudf/cudf/tests/test_udf_binops.py | 5 +- python/cudf/cudf/utils/applyutils.py | 4 +- python/cudf/cudf/utils/cudautils.py | 4 +- python/cudf/cudf/utils/utils.py | 2 +- python/cudf_kafka/cudf_kafka/_lib/kafka.pxd | 9 +- python/cudf_kafka/cudf_kafka/_lib/kafka.pyx | 9 +- .../custreamz/tests/test_dataframes.py | 7 +- .../dask_cudf/tests/test_accessor.py | 4 +- .../dask_cudf/tests/test_delayed_io.py | 4 +- python/dask_cudf/dask_cudf/tests/test_join.py | 4 +- .../dask_cudf/tests/test_reductions.py | 4 +- python/dask_cudf/dask_cudf/tests/test_sort.py | 4 +- 212 files changed, 1578 insertions(+), 1414 deletions(-) diff --git a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp index dbfd7a29efd..0f88d0b2564 100644 --- a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp +++ b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp @@ -20,8 +20,8 @@ #include #include "cudf_kafka/kafka_consumer.hpp" -#include #include +#include namespace kafka = cudf::io::external::kafka; diff --git a/java/src/main/native/include/jni_utils.hpp b/java/src/main/native/include/jni_utils.hpp index 4b6696e3911..3ce136dda19 100644 --- a/java/src/main/native/include/jni_utils.hpp +++ b/java/src/main/native/include/jni_utils.hpp @@ -243,13 +243,21 @@ template class nativ return data_ptr; } - const N_TYPE *const begin() const { return data(); } + const N_TYPE *const begin() const { + return data(); + } - N_TYPE *begin() { return data(); } + N_TYPE *begin() { + return data(); + } - const N_TYPE *const end() const { return data() + size(); } + const N_TYPE *const end() const { + return data() + size(); + } - N_TYPE *end() { return data() + size(); } + N_TYPE *end() { + return data() + size(); + } const J_ARRAY_TYPE get_jArray() const { return orig; } @@ -307,7 +315,7 @@ template class native_jpointerArray { int size() const noexcept { return wrapped.size(); } - T *operator[](int index) const { + T *operator[](int index) const { if (data() == NULL) { throw_java_exception(env, NPE_CLASS, "pointer is NULL"); } @@ -746,8 +754,8 @@ inline void jni_cuda_check(JNIEnv *const env, cudaError_t cuda_status) { if (cudaErrorMemoryAllocation == cudaPeekAtLastError()) { \ cudaGetLastError(); \ } \ - auto what = \ - std::string("Could not allocate native memory: ") + (e.what() == nullptr ? "" : e.what()); \ + auto what = std::string("Could not allocate native memory: ") + \ + (e.what() == nullptr ? "" : e.what()); \ JNI_CHECK_THROW_NEW(env, cudf::jni::OOM_CLASS, what.c_str(), ret_val); \ } \ catch (const std::exception &e) { \ @@ -755,4 +763,5 @@ inline void jni_cuda_check(JNIEnv *const env, cudaError_t cuda_status) { JNI_CHECK_THROW_NEW(env, class_name, e.what(), ret_val); \ } -#define CATCH_STD(env, ret_val) CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val) +#define CATCH_STD(env, ret_val) \ + CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val) diff --git a/java/src/main/native/src/AggregationJni.cpp b/java/src/main/native/src/AggregationJni.cpp index b4ea1f9c33f..63c2c33202e 100644 --- a/java/src/main/native/src/AggregationJni.cpp +++ b/java/src/main/native/src/AggregationJni.cpp @@ -20,7 +20,8 @@ extern "C" { -JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env, jclass class_object, +JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env, + jclass class_object, jlong ptr) { try { cudf::jni::auto_set_device(env); @@ -50,7 +51,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv case 3: // MAX ret = cudf::make_max_aggregation(); break; - // case 4 COUNT + //case 4 COUNT case 5: // ANY ret = cudf::make_any_aggregation(); break; @@ -101,8 +102,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNthAgg(JNIEnv *env try { cudf::jni::auto_set_device(env); - std::unique_ptr ret = cudf::make_nth_element_aggregation( - offset, include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE); + std::unique_ptr ret = + cudf::make_nth_element_aggregation(offset, + include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE); return reinterpret_cast(ret.release()); } CATCH_STD(env, 0); @@ -110,7 +112,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNthAgg(JNIEnv *env JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createDdofAgg(JNIEnv *env, jclass class_object, - jint kind, jint ddof) { + jint kind, + jint ddof) { try { cudf::jni::auto_set_device(env); @@ -176,7 +179,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createQuantAgg(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv *env, jclass class_object, - jint kind, jint offset) { + jint kind, + jint offset) { try { cudf::jni::auto_set_device(env); @@ -196,8 +200,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg( - JNIEnv *env, jclass class_object, jboolean include_nulls) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg(JNIEnv *env, + jclass class_object, + jboolean include_nulls) { try { cudf::jni::auto_set_device(env); cudf::null_policy policy = @@ -221,8 +226,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectSetAgg(JNIE nulls_equal ? cudf::null_equality::EQUAL : cudf::null_equality::UNEQUAL; cudf::nan_equality nan_equality = nans_equal ? cudf::nan_equality::ALL_EQUAL : cudf::nan_equality::UNEQUAL; - std::unique_ptr ret = - cudf::make_collect_set_aggregation(null_policy, null_equality, nan_equality); + std::unique_ptr ret = cudf::make_collect_set_aggregation(null_policy, + null_equality, + nan_equality); return reinterpret_cast(ret.release()); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/ColumnVectorJni.cpp b/java/src/main/native/src/ColumnVectorJni.cpp index 89592a8a17c..85bbdd41b4a 100644 --- a/java/src/main/native/src/ColumnVectorJni.cpp +++ b/java/src/main/native/src/ColumnVectorJni.cpp @@ -17,18 +17,18 @@ #include #include #include -#include #include -#include #include +#include +#include +#include +#include #include #include #include -#include #include #include #include -#include #include "cudf_jni_apis.hpp" #include "dtype_utils.hpp" @@ -54,9 +54,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_sequence(JNIEnv *env, j CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow( - JNIEnv *env, jclass, jint j_type, jlong j_col_length, jlong j_null_count, jobject j_data_obj, - jobject j_validity_obj, jobject j_offsets_obj) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow(JNIEnv *env, jclass, + jint j_type, + jlong j_col_length, + jlong j_null_count, + jobject j_data_obj, + jobject j_validity_obj, + jobject j_offsets_obj) { try { cudf::jni::auto_set_device(env); cudf::type_id n_type = static_cast(j_type); @@ -79,22 +83,17 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow( offsets_address = env->GetDirectBufferAddress(j_offsets_obj); offsets_length = env->GetDirectBufferCapacity(j_offsets_obj); } - auto data_buffer = - arrow::Buffer::Wrap(static_cast(data_address), static_cast(data_length)); - auto null_buffer = arrow::Buffer::Wrap(static_cast(validity_address), - static_cast(validity_length)); - auto offsets_buffer = arrow::Buffer::Wrap(static_cast(offsets_address), - static_cast(offsets_length)); + auto data_buffer = arrow::Buffer::Wrap(static_cast(data_address), static_cast(data_length)); + auto null_buffer = arrow::Buffer::Wrap(static_cast(validity_address), static_cast(validity_length)); + auto offsets_buffer = arrow::Buffer::Wrap(static_cast(offsets_address), static_cast(offsets_length)); std::shared_ptr arrow_array; switch (n_type) { case cudf::type_id::DECIMAL32: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL32 yet", - 0); + JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL32 yet", 0); break; case cudf::type_id::DECIMAL64: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL64 yet", - 0); + JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DECIMAL64 yet", 0); break; case cudf::type_id::STRUCT: JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting STRUCT yet", 0); @@ -103,23 +102,19 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow( JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting LIST yet", 0); break; case cudf::type_id::DICTIONARY32: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, - "Don't support converting DICTIONARY32 yet", 0); + JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Don't support converting DICTIONARY32 yet", 0); break; case cudf::type_id::STRING: - arrow_array = std::make_shared(j_col_length, offsets_buffer, - data_buffer, null_buffer, j_null_count); + arrow_array = std::make_shared(j_col_length, offsets_buffer, data_buffer, null_buffer, j_null_count); break; default: // this handles the primitive types - arrow_array = cudf::detail::to_arrow_array(n_type, j_col_length, data_buffer, null_buffer, - j_null_count); + arrow_array = cudf::detail::to_arrow_array(n_type, j_col_length, data_buffer, null_buffer, j_null_count); } auto name_and_type = arrow::field("col", arrow_array->type()); std::vector> fields = {name_and_type}; std::shared_ptr schema = std::make_shared(fields); - auto arrow_table = - arrow::Table::Make(schema, std::vector>{arrow_array}); + auto arrow_table = arrow::Table::Make(schema, std::vector>{arrow_array}); std::unique_ptr table_result = cudf::from_arrow(*(arrow_table)); std::vector> retCols = table_result->release(); if (retCols.size() != 1) { @@ -130,24 +125,28 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromArrow( CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_stringConcatenation( - JNIEnv *env, jclass, jlongArray column_handles, jlong separator, jlong narep) { + +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_stringConcatenation(JNIEnv *env, jclass, + jlongArray column_handles, + jlong separator, + jlong narep) { JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); JNI_NULL_CHECK(env, separator, "separator string scalar object is null", 0); JNI_NULL_CHECK(env, narep, "narep string scalar object is null", 0); try { cudf::jni::auto_set_device(env); - const auto &separator_scalar = *reinterpret_cast(separator); - const auto &narep_scalar = *reinterpret_cast(narep); + const auto& separator_scalar = *reinterpret_cast(separator); + const auto& narep_scalar = *reinterpret_cast(narep); cudf::jni::native_jpointerArray n_cudf_columns(env, column_handles); std::vector column_views; - std::transform(n_cudf_columns.data(), n_cudf_columns.data() + n_cudf_columns.size(), + std::transform(n_cudf_columns.data(), + n_cudf_columns.data() + n_cudf_columns.size(), std::back_inserter(column_views), [](auto const &p_column) { return *p_column; }); std::unique_ptr result = - cudf::strings::concatenate(cudf::table_view(column_views), separator_scalar, narep_scalar); + cudf::strings::concatenate(cudf::table_view(column_views), separator_scalar, narep_scalar); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -159,25 +158,28 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_concatListByRow(JNIEnv JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); try { cudf::jni::auto_set_device(env); - auto null_policy = ignore_null ? cudf::lists::concatenate_null_policy::IGNORE : - cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW; + auto null_policy = ignore_null ? cudf::lists::concatenate_null_policy::IGNORE + : cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW; cudf::jni::native_jpointerArray n_cudf_columns(env, column_handles); std::vector column_views; - std::transform(n_cudf_columns.data(), n_cudf_columns.data() + n_cudf_columns.size(), + std::transform(n_cudf_columns.data(), + n_cudf_columns.data() + n_cudf_columns.size(), std::back_inserter(column_views), [](auto const &p_column) { return *p_column; }); std::unique_ptr result = - cudf::lists::concatenate_rows(cudf::table_view(column_views), null_policy); + cudf::lists::concatenate_rows(cudf::table_view(column_views), null_policy); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeList(JNIEnv *env, jobject j_object, - jlongArray handles, jlong j_type, - jint scale, jlong row_count) { + jlongArray handles, + jlong j_type, + jint scale, + jlong row_count) { using ScalarType = cudf::scalar_type_t; JNI_NULL_CHECK(env, handles, "native view handles are null", 0) try { @@ -197,8 +199,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeList(JNIEnv *env, j auto offsets = cudf::make_column_from_scalar(*zero, row_count + 1); cudf::data_type n_data_type = cudf::jni::make_data_type(j_type, scale); auto empty_col = cudf::make_empty_column(n_data_type); - ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(empty_col), 0, - rmm::device_buffer()); + ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(empty_col), + 0, rmm::device_buffer()); } else { auto count = cudf::make_numeric_scalar(cudf::data_type(cudf::type_id::INT32)); count->set_valid(true); @@ -206,8 +208,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeList(JNIEnv *env, j std::unique_ptr offsets = cudf::sequence(row_count + 1, *zero, *count); auto data_col = cudf::interleave_columns(cudf::table_view(children_vector)); - ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(data_col), 0, - rmm::device_buffer()); + ret = cudf::make_lists_column(row_count, std::move(offsets), std::move(data_col), + 0, rmm::device_buffer()); } return reinterpret_cast(ret.release()); @@ -248,9 +250,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromScalar(JNIEnv *env, // type. // (Assumes the `row_count` is not big, otherwise there would be a performance issue.) // Checks the `row_count` because `cudf::concatenate` does not support no rows. - auto data_col = row_count > 0 ? - cudf::concatenate(std::vector(row_count, s_val)) : - cudf::empty_like(s_val); + auto data_col = row_count > 0 + ? cudf::concatenate(std::vector(row_count, s_val)) + : cudf::empty_like(s_val); col = cudf::make_lists_column(row_count, std::move(offsets), std::move(data_col), cudf::state_null_count(mask_state, row_count), cudf::create_null_mask(row_count, mask_state)); @@ -278,6 +280,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_fromScalar(JNIEnv *env, CATCH_STD(env, 0); } + JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_concatenate(JNIEnv *env, jclass clazz, jlongArray column_handles) { JNI_NULL_CHECK(env, column_handles, "input columns are null", 0); @@ -302,10 +305,12 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_concatenate(JNIEnv *env CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, + jobject j_object, jlongArray column_handles, jint hash_function_id, - jintArray initial_values, jint seed) { + jintArray initial_values, + jint seed) { JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); JNI_NULL_CHECK(env, initial_values, "array of initial values is null", 0); @@ -317,13 +322,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, jobje [](auto const &p_column) { return *p_column; }); cudf::table_view *input_table = new cudf::table_view(column_views); - cudf::jni::native_jintArray native_iv(env, initial_values); + cudf::jni::native_jintArray native_iv (env, initial_values); std::vector vector_iv; std::transform(native_iv.data(), native_iv.data() + native_iv.size(), - std::back_inserter(vector_iv), [](auto const &iv) { return iv; }); + std::back_inserter(vector_iv), + [](auto const &iv) { return iv; }); - std::unique_ptr result = - cudf::hash(*input_table, static_cast(hash_function_id), vector_iv, seed); + std::unique_ptr result = cudf::hash(*input_table, static_cast(hash_function_id), vector_iv, seed); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -373,7 +378,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_getNativeColumnView(JNI CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeEmptyCudfColumn(JNIEnv *env, jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_makeEmptyCudfColumn(JNIEnv *env, + jclass, jint j_type, jint scale) { diff --git a/java/src/main/native/src/ColumnViewJni.cpp b/java/src/main/native/src/ColumnViewJni.cpp index e7cfaedbb25..8d2d67b8fd0 100644 --- a/java/src/main/native/src/ColumnViewJni.cpp +++ b/java/src/main/native/src/ColumnViewJni.cpp @@ -23,11 +23,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -49,26 +47,27 @@ #include #include #include -#include #include #include #include #include #include #include -#include +#include #include #include #include +#include +#include +#include #include - #include "cudf/types.hpp" +#include "prefix_sum.hpp" #include "cudf_jni_apis.hpp" #include "dtype_utils.hpp" #include "jni.h" #include "jni_utils.hpp" -#include "prefix_sum.hpp" namespace { @@ -85,9 +84,10 @@ std::size_t calc_device_memory_size(cudf::column_view const &view) { total += cudf::size_of(dtype) * view.size(); } - return std::accumulate( - view.child_begin(), view.child_end(), total, - [](std::size_t t, cudf::column_view const &v) { return t + calc_device_memory_size(v); }); + return std::accumulate(view.child_begin(), view.child_end(), total, + [](std::size_t t, cudf::column_view const &v) { + return t + calc_device_memory_size(v); + }); } } // anonymous namespace @@ -155,7 +155,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_replaceNullsColumn(JNIEnv } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVV(JNIEnv *env, jclass, - jlong j_pred_vec, jlong j_true_vec, + jlong j_pred_vec, + jlong j_true_vec, jlong j_false_vec) { JNI_NULL_CHECK(env, j_pred_vec, "predicate column is null", 0); JNI_NULL_CHECK(env, j_true_vec, "true column is null", 0); @@ -172,7 +173,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVV(JNIEnv *env, jcl } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVS(JNIEnv *env, jclass, - jlong j_pred_vec, jlong j_true_vec, + jlong j_pred_vec, + jlong j_true_vec, jlong j_false_scalar) { JNI_NULL_CHECK(env, j_pred_vec, "predicate column is null", 0); JNI_NULL_CHECK(env, j_true_vec, "true column is null", 0); @@ -225,9 +227,10 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseSS(JNIEnv *env, jcl CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_reduce(JNIEnv *env, jclass, jlong j_col_view, - jlong j_agg, jint j_dtype, - jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_reduce(JNIEnv *env, jclass, + jlong j_col_view, + jlong j_agg, + jint j_dtype, jint scale) { JNI_NULL_CHECK(env, j_col_view, "column view is null", 0); JNI_NULL_CHECK(env, j_agg, "aggregation is null", 0); try { @@ -262,8 +265,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_quantile(JNIEnv *env, jcl } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_rollingWindow( - JNIEnv *env, jclass clazz, jlong input_col, jlong default_output_col, jint min_periods, - jlong agg_ptr, jint preceding, jint following, jlong preceding_col, jlong following_col) { + JNIEnv *env, jclass clazz, jlong input_col, jlong default_output_col, + jint min_periods, jlong agg_ptr, jint preceding, + jint following, jlong preceding_col, jlong following_col) { JNI_NULL_CHECK(env, input_col, "native handle is null", 0); JNI_NULL_CHECK(env, agg_ptr, "aggregation handle is null", 0); @@ -274,28 +278,27 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_rollingWindow( reinterpret_cast(default_output_col); cudf::column_view *n_preceding_col = reinterpret_cast(preceding_col); cudf::column_view *n_following_col = reinterpret_cast(following_col); - cudf::rolling_aggregation *agg = - dynamic_cast(reinterpret_cast(agg_ptr)); + cudf::rolling_aggregation * agg = dynamic_cast(reinterpret_cast(agg_ptr)); JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", 0); std::unique_ptr ret; if (n_default_output_col != nullptr) { if (n_preceding_col != nullptr && n_following_col != nullptr) { - CUDF_FAIL("A default output column is not currently supported with variable length " - "preceding and following"); - // ret = cudf::rolling_window(*n_input_col, *n_default_output_col, + CUDF_FAIL("A default output column is not currently supported with variable length preceding and following"); + //ret = cudf::rolling_window(*n_input_col, *n_default_output_col, // *n_preceding_col, *n_following_col, min_periods, agg); } else { - ret = cudf::rolling_window(*n_input_col, *n_default_output_col, preceding, following, - min_periods, *agg); + ret = cudf::rolling_window(*n_input_col, *n_default_output_col, + preceding, following, min_periods, *agg); } } else { if (n_preceding_col != nullptr && n_following_col != nullptr) { - ret = cudf::rolling_window(*n_input_col, *n_preceding_col, *n_following_col, min_periods, - *agg); + ret = cudf::rolling_window(*n_input_col, *n_preceding_col, *n_following_col, + min_periods, *agg); } else { - ret = cudf::rolling_window(*n_input_col, preceding, following, min_periods, *agg); + ret = cudf::rolling_window(*n_input_col, preceding, following, min_periods, + *agg); } } return reinterpret_cast(ret.release()); @@ -367,8 +370,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_listContains(JNIEnv *env, } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_listContainsColumn(JNIEnv *env, jclass, - jlong column_view, - jlong lookup_key_cv) { + jlong column_view, + jlong lookup_key_cv) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, lookup_key_cv, "lookup column is null", 0); try { @@ -488,7 +491,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_byteCount(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_findAndReplaceAll(JNIEnv *env, jclass clazz, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_findAndReplaceAll(JNIEnv *env, + jclass clazz, jlong old_values_handle, jlong new_values_handle, jlong input_handle) { @@ -575,21 +579,23 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_unaryOperation(JNIEnv *en CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_round(JNIEnv *env, jclass, jlong input_ptr, - jint decimal_places, - jint rounding_method) { - JNI_NULL_CHECK(env, input_ptr, "input is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *input = reinterpret_cast(input_ptr); - cudf::rounding_method method = static_cast(rounding_method); - std::unique_ptr ret = cudf::round(*input, decimal_places, method); - return reinterpret_cast(ret.release()); - } - CATCH_STD(env, 0); -} -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, jlong input_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_round(JNIEnv *env, jclass, + jlong input_ptr, jint decimal_places, + jint rounding_method) { + JNI_NULL_CHECK(env, input_ptr, "input is null", 0); + try { + cudf::jni::auto_set_device(env); + cudf::column_view *input = reinterpret_cast(input_ptr); + cudf::rounding_method method = static_cast(rounding_method); + std::unique_ptr ret = cudf::round(*input, decimal_places, method); + return reinterpret_cast(ret.release()); + } + CATCH_STD(env, 0); +} + +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, + jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -600,7 +606,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_month(JNIEnv *env, jclass, jlong input_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_month(JNIEnv *env, jclass, + jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -622,7 +629,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_day(JNIEnv *env, jclass, CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_hour(JNIEnv *env, jclass, jlong input_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_hour(JNIEnv *env, jclass, + jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -693,8 +701,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_dayOfYear(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclass, jlong handle, - jint type, jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclass, + jlong handle, jint type, + jint scale) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { cudf::jni::auto_set_device(env); @@ -707,9 +716,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas } if (n_data_type.id() == cudf::type_id::STRING) { switch (column->type().id()) { - case cudf::type_id::BOOL8: result = cudf::strings::from_booleans(*column); break; + case cudf::type_id::BOOL8: + result = cudf::strings::from_booleans(*column); + break; case cudf::type_id::FLOAT32: - case cudf::type_id::FLOAT64: result = cudf::strings::from_floats(*column); break; + case cudf::type_id::FLOAT64: + result = cudf::strings::from_floats(*column); + break; case cudf::type_id::INT8: case cudf::type_id::UINT8: case cudf::type_id::INT16: @@ -717,16 +730,24 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas case cudf::type_id::INT32: case cudf::type_id::UINT32: case cudf::type_id::INT64: - case cudf::type_id::UINT64: result = cudf::strings::from_integers(*column); break; + case cudf::type_id::UINT64: + result = cudf::strings::from_integers(*column); + break; case cudf::type_id::DECIMAL32: - case cudf::type_id::DECIMAL64: result = cudf::strings::from_fixed_point(*column); break; + case cudf::type_id::DECIMAL64: + result = cudf::strings::from_fixed_point(*column); + break; default: JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Invalid data type", 0); } } else if (column->type().id() == cudf::type_id::STRING) { switch (n_data_type.id()) { - case cudf::type_id::BOOL8: result = cudf::strings::to_booleans(*column); break; + case cudf::type_id::BOOL8: + result = cudf::strings::to_booleans(*column); + break; case cudf::type_id::FLOAT32: - case cudf::type_id::FLOAT64: result = cudf::strings::to_floats(*column, n_data_type); break; + case cudf::type_id::FLOAT64: + result = cudf::strings::to_floats(*column, n_data_type); + break; case cudf::type_id::INT8: case cudf::type_id::UINT8: case cudf::type_id::INT16: @@ -749,26 +770,30 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas // "reinterpret" casting will be supported via https://github.com/rapidsai/cudf/pull/5358 if (n_data_type.id() == cudf::type_id::TIMESTAMP_DAYS) { if (column->type().id() != cudf::type_id::INT32) { - JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", - "Numeric cast to TIMESTAMP_DAYS requires INT32", 0); + JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Numeric cast to TIMESTAMP_DAYS requires INT32", 0); } } else { if (column->type().id() != cudf::type_id::INT64) { - JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", - "Numeric cast to non-day timestamp requires INT64", 0); + JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Numeric cast to non-day timestamp requires INT64", 0); } } cudf::data_type duration_type = cudf::jni::timestamp_to_duration(n_data_type); - cudf::column_view duration_view = cudf::column_view( - duration_type, column->size(), column->head(), column->null_mask(), column->null_count()); + cudf::column_view duration_view = cudf::column_view(duration_type, + column->size(), + column->head(), + column->null_mask(), + column->null_count()); result = cudf::cast(duration_view, n_data_type); } else if (cudf::is_timestamp(column->type()) && cudf::is_numeric(n_data_type)) { // This is a temporary workaround to allow Java to cast from timestamp types to integral types // without forcing an intermediate duration column to be manifested. Ultimately this style of // "reinterpret" casting will be supported via https://github.com/rapidsai/cudf/pull/5358 cudf::data_type duration_type = cudf::jni::timestamp_to_duration(column->type()); - cudf::column_view duration_view = cudf::column_view( - duration_type, column->size(), column->head(), column->null_mask(), column->null_count()); + cudf::column_view duration_view = cudf::column_view(duration_type, + column->size(), + column->head(), + column->null_mask(), + column->null_count()); result = cudf::cast(duration_view, n_data_type); } else { result = cudf::cast(*column, n_data_type); @@ -778,8 +803,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitCastTo(JNIEnv *env, jclass, jlong handle, - jint type, jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitCastTo(JNIEnv *env, jclass, + jlong handle, jint type, + jint scale) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { cudf::jni::auto_set_device(env); @@ -825,8 +851,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringTimestampToTimestam } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isTimestamp(JNIEnv *env, jclass, - jlong handle, - jstring formatObj) { + jlong handle, jstring formatObj) { JNI_NULL_CHECK(env, handle, "column is null", 0); JNI_NULL_CHECK(env, formatObj, "format is null", 0); @@ -836,8 +861,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isTimestamp(JNIEnv *env, cudf::column_view *column = reinterpret_cast(handle); cudf::strings_column_view strings_column(*column); - std::unique_ptr result = - cudf::strings::is_timestamp(strings_column, format.get()); + std::unique_ptr result = cudf::strings::is_timestamp( + strings_column, format.get()); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -875,7 +900,8 @@ JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_ColumnView_containsScalar(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_containsVector(JNIEnv *env, jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_containsVector(JNIEnv *env, + jobject j_object, jlong j_haystack_handle, jlong j_needle_handle) { JNI_NULL_CHECK(env, j_haystack_handle, "haystack vector is null", false); @@ -925,7 +951,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringStartWith(JNIEnv *e CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env, jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env, + jobject j_object, jlong j_view_handle, jlong comp_string) { JNI_NULL_CHECK(env, j_view_handle, "column is null", false); @@ -943,7 +970,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringContains(JNIEnv *env, jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringContains(JNIEnv *env, + jobject j_object, jlong j_view_handle, jlong comp_string) { JNI_NULL_CHECK(env, j_view_handle, "column is null", false); @@ -1011,7 +1039,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_binaryOpVV(JNIEnv *env, j cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation( + *lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1042,7 +1071,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_binaryOpVS(JNIEnv *env, j cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation( + *lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1087,8 +1117,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringColumn(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringLocate(JNIEnv *env, jclass, jlong column_view, - jlong substring, jint start, - jint end) { + jlong substring, + jint start, jint end) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, substring, "target string scalar is null", 0); try { @@ -1105,7 +1135,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringLocate(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplace(JNIEnv *env, jclass, jlong column_view, - jlong target, jlong replace) { + jlong target, + jlong replace) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, target, "target string scalar is null", 0); JNI_NULL_CHECK(env, replace, "replace string scalar is null", 0); @@ -1138,8 +1169,11 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_mapLookup(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs( - JNIEnv *env, jclass, jlong column_view, jstring patternObj, jstring replaceObj) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs(JNIEnv *env, + jclass, + jlong column_view, + jstring patternObj, + jstring replaceObj) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, patternObj, "pattern string is null", 0); @@ -1151,8 +1185,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs cudf::jni::native_jstring ss_pattern(env, patternObj); cudf::jni::native_jstring ss_replace(env, replaceObj); - std::unique_ptr result = - cudf::strings::replace_with_backrefs(scv, ss_pattern.get(), ss_replace.get()); + std::unique_ptr result = cudf::strings::replace_with_backrefs( + scv, ss_pattern.get(), ss_replace.get()); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1174,8 +1208,11 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_zfill(JNIEnv *env, jclass CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_pad(JNIEnv *env, jclass, jlong column_view, - jint j_width, jint j_side, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_pad(JNIEnv *env, + jclass, + jlong column_view, + jint j_width, + jint j_side, jstring fill_char) { JNI_NULL_CHECK(env, column_view, "column is null", 0); @@ -1274,8 +1311,11 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_normalizeNANsAndZeros(JNI CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidity( - JNIEnv *env, jobject j_object, jlong base_column, jlongArray column_handles, jint bin_op) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidity(JNIEnv *env, + jobject j_object, + jlong base_column, + jlongArray column_handles, + jint bin_op) { JNI_NULL_CHECK(env, base_column, "base column native handle is null", 0); JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); try { @@ -1297,14 +1337,15 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit cudf::table_view *input_table = new cudf::table_view(column_views); cudf::binary_operator op = static_cast(bin_op); - switch (op) { + switch(op) { case cudf::binary_operator::BITWISE_AND: copy->set_null_mask(cudf::bitmask_and(*input_table)); break; case cudf::binary_operator::BITWISE_OR: copy->set_null_mask(cudf::bitmask_or(*input_table)); break; - default: JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Unsupported merge operation", 0); + default: + JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Unsupported merge operation", 0); } return reinterpret_cast(copy.release()); @@ -1317,8 +1358,11 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit // should typically only be called from the CudfColumn inner class. //////// -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView( - JNIEnv *env, jclass, jint j_type, jint scale, jlong j_data, jlong j_data_size, jlong j_offset, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv *env, + jclass, jint j_type, + jint scale, jlong j_data, + jlong j_data_size, + jlong j_offset, jlong j_valid, jint j_null_count, jint size, jlongArray j_children) { try { @@ -1336,8 +1380,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView( if (n_type == cudf::type_id::STRING) { if (size == 0) { - ret.reset( - new cudf::column_view(cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0)); + ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0)); } else { JNI_NULL_CHECK(env, j_offset, "offset is null", 0); // This must be kept in sync with how string columns are created @@ -1361,21 +1404,20 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView( offsets_size = size + 1; offsets = reinterpret_cast(j_offset); } - cudf::column_view offsets_column(cudf::data_type{cudf::type_id::INT32}, offsets_size, - offsets); + cudf::column_view offsets_column(cudf::data_type{cudf::type_id::INT32}, offsets_size, offsets); ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::LIST}, size, nullptr, valid, - j_null_count, 0, {offsets_column, *children[0]})); - } else if (n_type == cudf::type_id::STRUCT) { - JNI_NULL_CHECK(env, j_children, "children of a struct are null", 0); - cudf::jni::native_jpointerArray children(env, j_children); - std::vector children_vector(children.size()); - for (int i = 0; i < children.size(); i++) { - children_vector[i] = *children[i]; - } - ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, size, nullptr, valid, - j_null_count, 0, children_vector)); - } else { - ret.reset(new cudf::column_view(n_data_type, size, data, valid, j_null_count)); + j_null_count, 0, {offsets_column, *children[0]})); + } else if (n_type == cudf::type_id::STRUCT) { + JNI_NULL_CHECK(env, j_children, "children of a struct are null", 0); + cudf::jni::native_jpointerArray children(env, j_children); + std::vector children_vector(children.size()); + for (int i = 0; i < children.size(); i++) { + children_vector[i] = *children[i]; + } + ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, size, nullptr, valid, + j_null_count, 0, children_vector)); + } else { + ret.reset(new cudf::column_view(n_data_type, size, data, valid, j_null_count)); } return reinterpret_cast(ret.release()); @@ -1383,7 +1425,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView( CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *env, jobject j_object, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *env, + jobject j_object, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1394,7 +1437,8 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *en CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv *env, jclass, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv *env, + jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1405,7 +1449,8 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeRowCount(JNIEnv *env, jclass, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeRowCount(JNIEnv *env, + jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1452,8 +1497,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeDataAddress(JNIE cudf::column_view data_view = view.chars(); result = reinterpret_cast(data_view.data()); } - } else if (column->type().id() != cudf::type_id::LIST && - column->type().id() != cudf::type_id::STRUCT) { + } else if(column->type().id() != cudf::type_id::LIST && column->type().id() != cudf::type_id::STRUCT) { result = reinterpret_cast(column->data()); } return result; @@ -1474,8 +1518,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeDataLength(JNIEn cudf::column_view data_view = view.chars(); result = data_view.size(); } - } else if (column->type().id() != cudf::type_id::LIST && - column->type().id() != cudf::type_id::STRUCT) { + } else if(column->type().id() != cudf::type_id::LIST && column->type().id() != cudf::type_id::STRUCT) { result = cudf::size_of(column->type()) * column->size(); } return result; @@ -1487,49 +1530,45 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeNumChildren(JNIEn jobject j_object, jlong handle) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *column = reinterpret_cast(handle); - // Strings has children(offsets and chars) but not a nested child() we care about here. - if (column->type().id() == cudf::type_id::STRING) { - return 0; - } else if (column->type().id() == cudf::type_id::LIST) { - // first child is always offsets in lists which we do not want to count here - return static_cast(column->num_children() - 1); - } else if (column->type().id() == cudf::type_id::STRUCT) { - return static_cast(column->num_children()); - } else { - return 0; + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + cudf::column_view *column = reinterpret_cast(handle); + // Strings has children(offsets and chars) but not a nested child() we care about here. + if (column->type().id() == cudf::type_id::STRING) { + return 0; + } else if (column->type().id() == cudf::type_id::LIST) { + // first child is always offsets in lists which we do not want to count here + return static_cast(column->num_children() - 1); + } else if (column->type().id() == cudf::type_id::STRUCT) { + return static_cast(column->num_children()); + } else { + return 0; + } } - } - CATCH_STD(env, 0); + CATCH_STD(env, 0); + } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getChildCvPointer(JNIEnv *env, jobject j_object, - jlong handle, - jint child_index) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *column = reinterpret_cast(handle); - if (column->type().id() == cudf::type_id::LIST) { - std::unique_ptr view = - std::make_unique(*column); - // first child is always offsets which we do not want to get from this call - std::unique_ptr next_view = - std::make_unique(column->child(1 + child_index)); - return reinterpret_cast(next_view.release()); - } else { - std::unique_ptr view = - std::make_unique(*column); - std::unique_ptr next_view = - std::make_unique(column->child(child_index)); - return reinterpret_cast(next_view.release()); + jlong handle, jint child_index) { + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + cudf::column_view *column = reinterpret_cast(handle); + if (column->type().id() == cudf::type_id::LIST) { + std::unique_ptr view = std::make_unique(*column); + // first child is always offsets which we do not want to get from this call + std::unique_ptr next_view = std::make_unique(column->child(1 + child_index)); + return reinterpret_cast(next_view.release()); + } else { + std::unique_ptr view = std::make_unique(*column); + std::unique_ptr next_view = std::make_unique(column->child(child_index)); + return reinterpret_cast(next_view.release()); + } } - } - CATCH_STD(env, 0); + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeOffsetsAddress(JNIEnv *env, jclass, @@ -1582,7 +1621,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeOffsetsLength(JN CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress(JNIEnv *env, jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress(JNIEnv *env, + jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1593,7 +1633,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress( CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityLength(JNIEnv *env, jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityLength(JNIEnv *env, + jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1620,13 +1661,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidPointerSize JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getDeviceMemorySize(JNIEnv *env, jclass, jlong handle) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - auto view = reinterpret_cast(handle); - return calc_device_memory_size(*view); - } - CATCH_STD(env, 0); + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + auto view = reinterpret_cast(handle); + return calc_device_memory_size(*view); + } + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_clamper(JNIEnv *env, jobject j_object, @@ -1685,7 +1726,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeStructView(JNIEnv *en children_vector[i] = *children[i]; } ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, row_count, nullptr, - nullptr, 0, 0, children_vector)); + nullptr, 0, 0, children_vector)); return reinterpret_cast(ret.release()); } @@ -1730,6 +1771,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_nansToNulls(JNIEnv *env, CATCH_STD(env, 0) } + JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isFloat(JNIEnv *env, jobject j_object, jlong handle) { @@ -1759,7 +1801,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isInteger(JNIEnv *env, jo } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isIntegerWithType(JNIEnv *env, jobject, - jlong handle, jint j_dtype, + jlong handle, + jint j_dtype, jint scale) { JNI_NULL_CHECK(env, handle, "native view handle is null", 0) @@ -1774,8 +1817,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isIntegerWithType(JNIEnv CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv *env, jobject j_object, jlong handle) { JNI_NULL_CHECK(env, handle, "native view handle is null", 0) @@ -1790,16 +1832,15 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env, jclass, - jlong j_view_handle, - jlong j_scalar_handle) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env, jclass, + jlong j_view_handle, jlong j_scalar_handle) { - JNI_NULL_CHECK(env, j_view_handle, "view cannot be null", 0); - JNI_NULL_CHECK(env, j_scalar_handle, "path cannot be null", 0); + JNI_NULL_CHECK(env, j_view_handle, "view cannot be null", 0); + JNI_NULL_CHECK(env, j_scalar_handle, "path cannot be null", 0); try { cudf::jni::auto_set_device(env); - cudf::column_view *n_column_view = reinterpret_cast(j_view_handle); + cudf::column_view* n_column_view = reinterpret_cast(j_view_handle); cudf::strings_column_view n_strings_col_view(*n_column_view); cudf::string_scalar *n_scalar_path = reinterpret_cast(j_scalar_handle); @@ -1808,5 +1849,6 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env return reinterpret_cast(result.release()); } CATCH_STD(env, 0) + } } // extern "C" diff --git a/java/src/main/native/src/ContiguousTableJni.cpp b/java/src/main/native/src/ContiguousTableJni.cpp index f592d80834c..352256af450 100644 --- a/java/src/main/native/src/ContiguousTableJni.cpp +++ b/java/src/main/native/src/ContiguousTableJni.cpp @@ -93,7 +93,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ContiguousTable_createPackedMetadata auto data_addr = reinterpret_cast(j_buffer_addr); auto data_size = static_cast(j_buffer_length); auto metadata_ptr = - new cudf::packed_columns::metadata(cudf::pack_metadata(*table, data_addr, data_size)); + new cudf::packed_columns::metadata(cudf::pack_metadata(*table, data_addr, data_size)); return reinterpret_cast(metadata_ptr); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/CudaJni.cpp b/java/src/main/native/src/CudaJni.cpp index 9b65a335fa7..f5eb09fa2d4 100644 --- a/java/src/main/native/src/CudaJni.cpp +++ b/java/src/main/native/src/CudaJni.cpp @@ -15,7 +15,6 @@ */ #include - #include "jni_utils.hpp" namespace { @@ -50,7 +49,7 @@ void auto_set_device(JNIEnv *env) { } /** Fills all the bytes in the buffer 'buf' with 'value'. */ -void device_memset_async(JNIEnv *env, rmm::device_buffer &buf, char value) { +void device_memset_async(JNIEnv *env, rmm::device_buffer& buf, char value) { cudaError_t cuda_status = cudaMemsetAsync((void *)buf.data(), value, buf.size()); jni_cuda_check(env, cuda_status); } diff --git a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp index 16b8630b04a..4a38516db92 100644 --- a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp +++ b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp @@ -14,26 +14,32 @@ * limitations under the License. */ +#include + +#include +#include #include #include -#include #include #include -#include -#include - #include "jni_utils.hpp" extern "C" { -JNIEXPORT jobject JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_wrapRangeInBuffer( - JNIEnv *env, jclass, jlong addr, jlong len) { +JNIEXPORT jobject JNICALL +Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_wrapRangeInBuffer(JNIEnv *env, jclass, + jlong addr, + jlong len) { return env->NewDirectByteBuffer(reinterpret_cast(addr), len); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap( - JNIEnv *env, jclass, jstring jpath, jint mode, jlong offset, jlong length) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap(JNIEnv* env, jclass, + jstring jpath, + jint mode, + jlong offset, + jlong length) { JNI_NULL_CHECK(env, jpath, "path is null", 0); JNI_ARG_CHECK(env, (mode == 0 || mode == 1), "bad mode value", 0); try { @@ -44,31 +50,29 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap( cudf::jni::throw_java_exception(env, "java/io/IOException", strerror(errno)); } - void *address = mmap(NULL, length, (mode == 0) ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, - fd, offset); + void* address = mmap(NULL, length, + (mode == 0) ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); if (address == MAP_FAILED) { - char const *error_msg = strerror(errno); + char const* error_msg = strerror(errno); close(fd); cudf::jni::throw_java_exception(env, "java/io/IOException", error_msg); } close(fd); return reinterpret_cast(address); - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_munmap(JNIEnv *env, jclass, - jlong address, - jlong length) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_munmap(JNIEnv* env, jclass, + jlong address, jlong length) { JNI_NULL_CHECK(env, address, "address is NULL", ); try { - int rc = munmap(reinterpret_cast(address), length); + int rc = munmap(reinterpret_cast(address), length); if (rc == -1) { cudf::jni::throw_java_exception(env, "java/io/IOException", strerror(errno)); } - } - CATCH_STD(env, ); + } CATCH_STD(env, ); } } // extern "C" diff --git a/java/src/main/native/src/NvcompJni.cpp b/java/src/main/native/src/NvcompJni.cpp index 5ba87221597..9ef3b1f958a 100644 --- a/java/src/main/native/src/NvcompJni.cpp +++ b/java/src/main/native/src/NvcompJni.cpp @@ -29,7 +29,8 @@ constexpr char const *UNSUPPORTED_CLASS = "java/lang/UnsupportedOperationExcepti void check_nvcomp_status(JNIEnv *env, nvcompError_t status) { switch (status) { - case nvcompSuccess: break; + case nvcompSuccess: + break; case nvcompErrorInvalidValue: cudf::jni::throw_java_exception(env, ILLEGAL_ARG_CLASS, "nvcomp invalid value"); break; @@ -49,8 +50,10 @@ void check_nvcomp_status(JNIEnv *env, nvcompError_t status) { extern "C" { -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jlong jstream) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jlong jstream) { try { cudf::jni::auto_set_device(env); void *metadata_ptr; @@ -59,114 +62,121 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetada &metadata_ptr, stream); check_nvcomp_status(env, status); return reinterpret_cast(metadata_ptr); - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressDestroyMetadata( - JNIEnv *env, jclass, jlong metadata_ptr) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressDestroyMetadata(JNIEnv *env, jclass, + jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); nvcompDecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); - } - CATCH_STD(env, ); + } CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetTempSize( - JNIEnv *env, jclass, jlong metadata_ptr) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetTempSize(JNIEnv *env, jclass, + jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t temp_size; auto status = nvcompDecompressGetTempSize(reinterpret_cast(metadata_ptr), &temp_size); check_nvcomp_status(env, status); return temp_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetOutputSize( - JNIEnv *env, jclass, jlong metadata_ptr) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetOutputSize(JNIEnv *env, jclass, + jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t out_size; auto status = nvcompDecompressGetOutputSize(reinterpret_cast(metadata_ptr), &out_size); check_nvcomp_status(env, status); return out_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressAsync( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jlong temp_ptr, jlong temp_size, - jlong metadata_ptr, jlong out_ptr, jlong out_size, jlong jstream) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressAsync(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jlong temp_ptr, jlong temp_size, + jlong metadata_ptr, + jlong out_ptr, jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto stream = reinterpret_cast(jstream); auto status = nvcompDecompressAsync(reinterpret_cast(in_ptr), in_size, reinterpret_cast(temp_ptr), temp_size, reinterpret_cast(metadata_ptr), - reinterpret_cast(out_ptr), out_size, stream); + reinterpret_cast(out_ptr), out_size, + stream); check_nvcomp_status(env, status); - } - CATCH_STD(env, ); + } CATCH_STD(env, ); } -JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Data(JNIEnv *env, jclass, - jlong in_ptr, - jlong in_size) { +JNIEXPORT jboolean JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Data(JNIEnv *env, jclass, jlong in_ptr, jlong in_size) { try { cudf::jni::auto_set_device(env); return LZ4IsData(reinterpret_cast(in_ptr), in_size); - } - CATCH_STD(env, 0) + } CATCH_STD(env, 0) } -JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Metadata(JNIEnv *env, jclass, - jlong metadata_ptr) { +JNIEXPORT jboolean JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Metadata(JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); return LZ4IsMetadata(reinterpret_cast(metadata_ptr)); - } - CATCH_STD(env, 0) + } CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetTempSize( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetTempSize(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jint input_type, jlong chunk_size) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; size_t temp_size; - auto status = nvcompLZ4CompressGetTempSize(reinterpret_cast(in_ptr), in_size, comp_type, - &opts, &temp_size); + auto status = nvcompLZ4CompressGetTempSize(reinterpret_cast(in_ptr), in_size, + comp_type, &opts, &temp_size); check_nvcomp_status(env, status); return temp_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetOutputSize( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, jboolean compute_exact) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetOutputSize(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jint input_type, jlong chunk_size, + jlong temp_ptr, jlong temp_size, + jboolean compute_exact) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; size_t out_size; - auto status = nvcompLZ4CompressGetOutputSize( - reinterpret_cast(in_ptr), in_size, comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, &out_size, compute_exact); + auto status = nvcompLZ4CompressGetOutputSize(reinterpret_cast(in_ptr), in_size, + comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + &out_size, compute_exact); check_nvcomp_status(env, status); return out_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, jlong out_ptr, jlong out_size, jlong jstream) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jint input_type, jlong chunk_size, + jlong temp_ptr, jlong temp_size, + jlong out_ptr, jlong out_size, + jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -174,23 +184,27 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress( opts.chunk_size = chunk_size; auto stream = reinterpret_cast(jstream); size_t compressed_size = out_size; - auto status = - nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), &compressed_size, stream); + auto status = nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, + comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), &compressed_size, + stream); check_nvcomp_status(env, status); if (cudaStreamSynchronize(stream) != cudaSuccess) { JNI_THROW_NEW(env, NVCOMP_CUDA_ERROR_CLASS, "Error synchronizing stream", 0); } return compressed_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync( - JNIEnv *env, jclass, jlong compressed_output_ptr, jlong in_ptr, jlong in_size, jint input_type, - jlong chunk_size, jlong temp_ptr, jlong temp_size, jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync(JNIEnv *env, jclass, + jlong compressed_output_ptr, + jlong in_ptr, jlong in_size, + jint input_type, jlong chunk_size, + jlong temp_ptr, jlong temp_size, + jlong out_ptr, jlong out_size, + jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -199,17 +213,20 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync( auto stream = reinterpret_cast(jstream); auto compressed_size_ptr = reinterpret_cast(compressed_output_ptr); *compressed_size_ptr = out_size; - auto status = - nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), compressed_size_ptr, stream); + auto status = nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, + comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), compressed_size_ptr, + stream); check_nvcomp_status(env, status); - } - CATCH_STD(env, ); + } CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata( - JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong jstream) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata(JNIEnv* env, jclass, + jlongArray in_ptrs, + jlongArray in_sizes, + jlong jstream) { try { cudf::jni::auto_set_device(env); @@ -223,57 +240,65 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4Decompres std::back_inserter(sizes), [](jlong x) -> size_t { return static_cast(x); }); - void *metadata_ptr = nullptr; + void* metadata_ptr = nullptr; auto stream = reinterpret_cast(jstream); auto status = nvcompBatchedLZ4DecompressGetMetadata(input_ptrs.data(), sizes.data(), input_ptrs.size(), &metadata_ptr, stream); check_nvcomp_status(env, status); return reinterpret_cast(metadata_ptr); - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressDestroyMetadata( - JNIEnv *env, jclass, jlong metadata_ptr) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressDestroyMetadata(JNIEnv* env, jclass, + jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); - nvcompBatchedLZ4DecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); - } - CATCH_STD(env, ); + nvcompBatchedLZ4DecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); + } CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetTempSize( - JNIEnv *env, jclass, jlong metadata_ptr) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetTempSize(JNIEnv* env, jclass, + jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t temp_size; - auto status = - nvcompBatchedLZ4DecompressGetTempSize(reinterpret_cast(metadata_ptr), &temp_size); + auto status = nvcompBatchedLZ4DecompressGetTempSize(reinterpret_cast(metadata_ptr), + &temp_size); check_nvcomp_status(env, status); return static_cast(temp_size); - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetOutputSize( - JNIEnv *env, jclass, jlong metadata_ptr, jint num_outputs) { +JNIEXPORT jlongArray JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetOutputSize(JNIEnv* env, jclass, + jlong metadata_ptr, + jint num_outputs) { try { cudf::jni::auto_set_device(env); std::vector sizes(num_outputs); - auto status = nvcompBatchedLZ4DecompressGetOutputSize(reinterpret_cast(metadata_ptr), - num_outputs, sizes.data()); + auto status = nvcompBatchedLZ4DecompressGetOutputSize(reinterpret_cast(metadata_ptr), + num_outputs, + sizes.data()); check_nvcomp_status(env, status); cudf::jni::native_jlongArray jsizes(env, num_outputs); std::transform(sizes.begin(), sizes.end(), jsizes.data(), [](size_t x) -> jlong { return static_cast(x); }); return jsizes.get_jArray(); - } - CATCH_STD(env, NULL); + } CATCH_STD(env, NULL); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync( - JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong temp_ptr, jlong temp_size, - jlong metadata_ptr, jlongArray out_ptrs, jlongArray out_sizes, jlong jstream) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync(JNIEnv* env, jclass, + jlongArray in_ptrs, + jlongArray in_sizes, + jlong temp_ptr, + jlong temp_size, + jlong metadata_ptr, + jlongArray out_ptrs, + jlongArray out_sizes, + jlong jstream) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -300,17 +325,23 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4Decompress [](jlong x) -> size_t { return static_cast(x); }); auto stream = reinterpret_cast(jstream); - auto status = nvcompBatchedLZ4DecompressAsync( - input_ptrs.data(), input_sizes.data(), input_ptrs.size(), - reinterpret_cast(temp_ptr), static_cast(temp_size), - reinterpret_cast(metadata_ptr), output_ptrs.data(), output_sizes.data(), stream); + auto status = nvcompBatchedLZ4DecompressAsync(input_ptrs.data(), input_sizes.data(), + input_ptrs.size(), + reinterpret_cast(temp_ptr), + static_cast(temp_size), + reinterpret_cast(metadata_ptr), + output_ptrs.data(), + output_sizes.data(), + stream); check_nvcomp_status(env, status); - } - CATCH_STD(env, ); + } CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize( - JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong chunk_size) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize(JNIEnv* env, jclass, + jlongArray in_ptrs, + jlongArray in_sizes, + jlong chunk_size) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -330,13 +361,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressG input_ptrs.size(), &opts, &temp_size); check_nvcomp_status(env, status); return static_cast(temp_size); - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize( - JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong chunk_size, jlong temp_ptr, - jlong temp_size) { +JNIEXPORT jlongArray JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize(JNIEnv* env, jclass, + jlongArray in_ptrs, + jlongArray in_sizes, + jlong chunk_size, + jlong temp_ptr, + jlong temp_size) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -352,22 +386,30 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4Comp nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; std::vector output_sizes(input_ptrs.size()); - auto status = nvcompBatchedLZ4CompressGetOutputSize( - input_ptrs.data(), input_sizes.data(), input_ptrs.size(), &opts, - reinterpret_cast(temp_ptr), static_cast(temp_size), output_sizes.data()); + auto status = nvcompBatchedLZ4CompressGetOutputSize(input_ptrs.data(), input_sizes.data(), + input_ptrs.size(), &opts, + reinterpret_cast(temp_ptr), + static_cast(temp_size), + output_sizes.data()); check_nvcomp_status(env, status); cudf::jni::native_jlongArray jsizes(env, input_ptrs.size()); std::transform(output_sizes.begin(), output_sizes.end(), jsizes.data(), [](size_t x) -> jlong { return static_cast(x); }); return jsizes.get_jArray(); - } - CATCH_STD(env, NULL); + } CATCH_STD(env, NULL); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync( - JNIEnv *env, jclass, jlong compressed_sizes_out_ptr, jlongArray in_ptrs, jlongArray in_sizes, - jlong chunk_size, jlong temp_ptr, jlong temp_size, jlongArray out_ptrs, jlongArray out_sizes, - jlong jstream) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync(JNIEnv* env, jclass, + jlong compressed_sizes_out_ptr, + jlongArray in_ptrs, + jlongArray in_sizes, + jlong chunk_size, + jlong temp_ptr, + jlong temp_size, + jlongArray out_ptrs, + jlongArray out_sizes, + jlong jstream) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -389,26 +431,30 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAs cudf::jni::throw_java_exception(env, NVCOMP_ERROR_CLASS, "input/output array size mismatch"); } - auto output_sizes = reinterpret_cast(compressed_sizes_out_ptr); - std::transform(output_jsizes.data(), output_jsizes.data() + output_jsizes.size(), output_sizes, + auto output_sizes = reinterpret_cast(compressed_sizes_out_ptr); + std::transform(output_jsizes.data(), output_jsizes.data() + output_jsizes.size(), + output_sizes, [](jlong x) -> size_t { return static_cast(x); }); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; auto stream = reinterpret_cast(jstream); - auto status = nvcompBatchedLZ4CompressAsync( - input_ptrs.data(), input_sizes.data(), input_ptrs.size(), &opts, - reinterpret_cast(temp_ptr), static_cast(temp_size), output_ptrs.data(), - output_sizes, // input/output parameter - stream); + auto status = nvcompBatchedLZ4CompressAsync(input_ptrs.data(), input_sizes.data(), + input_ptrs.size(), &opts, + reinterpret_cast(temp_ptr), + static_cast(temp_size), + output_ptrs.data(), + output_sizes, // input/output parameter + stream); check_nvcomp_status(env, status); - } - CATCH_STD(env, ); + } CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -421,13 +467,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGet comp_type, &opts, &temp_size); check_nvcomp_status(env, status); return temp_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jboolean compute_exact) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp, + jlong temp_ptr, jlong temp_size, + jboolean compute_exact) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -436,19 +485,23 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGet opts.num_deltas = num_deltas; opts.use_bp = use_bp; size_t out_size; - auto status = nvcompCascadedCompressGetOutputSize( - reinterpret_cast(in_ptr), in_size, comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, &out_size, compute_exact); + auto status = nvcompCascadedCompressGetOutputSize(reinterpret_cast(in_ptr), in_size, + comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + &out_size, compute_exact); check_nvcomp_status(env, status); return out_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress( - JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jlong out_ptr, - jlong out_size, jlong jstream) { +JNIEXPORT jlong JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress(JNIEnv *env, jclass, + jlong in_ptr, jlong in_size, + jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp, + jlong temp_ptr, jlong temp_size, + jlong out_ptr, jlong out_size, + jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -458,23 +511,28 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress( opts.use_bp = use_bp; auto stream = reinterpret_cast(jstream); size_t compressed_size = out_size; - auto status = - nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), &compressed_size, stream); + auto status = nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, + comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), &compressed_size, + stream); check_nvcomp_status(env, status); if (cudaStreamSynchronize(stream) != cudaSuccess) { JNI_THROW_NEW(env, NVCOMP_CUDA_ERROR_CLASS, "Error synchronizing stream", 0); } return compressed_size; - } - CATCH_STD(env, 0); + } CATCH_STD(env, 0); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync( - JNIEnv *env, jclass, jlong compressed_output_ptr, jlong in_ptr, jlong in_size, jint input_type, - jint num_rles, jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jlong out_ptr, - jlong out_size, jlong jstream) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync(JNIEnv *env, jclass, + jlong compressed_output_ptr, + jlong in_ptr, jlong in_size, + jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp, + jlong temp_ptr, jlong temp_size, + jlong out_ptr, jlong out_size, + jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -485,13 +543,13 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsyn auto stream = reinterpret_cast(jstream); auto compressed_size_ptr = reinterpret_cast(compressed_output_ptr); *compressed_size_ptr = out_size; - auto status = - nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), compressed_size_ptr, stream); + auto status = nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, + comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), + compressed_size_ptr, stream); check_nvcomp_status(env, status); - } - CATCH_STD(env, ); + } CATCH_STD(env, ); } } // extern "C" diff --git a/java/src/main/native/src/NvtxRangeJni.cpp b/java/src/main/native/src/NvtxRangeJni.cpp index afd96632187..ea7a148fb4d 100644 --- a/java/src/main/native/src/NvtxRangeJni.cpp +++ b/java/src/main/native/src/NvtxRangeJni.cpp @@ -21,15 +21,16 @@ namespace { struct java_domain { - static constexpr char const *name{"Java"}; + static constexpr char const* name{"Java"}; }; } // anonymous namespace extern "C" { -JNIEXPORT void JNICALL Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, jstring name, - jint color_bits) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, + jstring name, jint color_bits) { try { cudf::jni::native_jstring range_name(env, name); nvtx3::color range_color(static_cast(color_bits)); @@ -39,7 +40,8 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass cl CATCH_STD(env, ); } -JNIEXPORT void JNICALL Java_ai_rapids_cudf_NvtxRange_pop(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL +Java_ai_rapids_cudf_NvtxRange_pop(JNIEnv *env, jclass clazz) { try { nvtxDomainRangePop(nvtx3::domain::get()); } diff --git a/java/src/main/native/src/ScalarJni.cpp b/java/src/main/native/src/ScalarJni.cpp index 7da78c996e7..95f934ff91b 100644 --- a/java/src/main/native/src/ScalarJni.cpp +++ b/java/src/main/native/src/ScalarJni.cpp @@ -409,29 +409,30 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeTimestampTimeScalar(JNIEn } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeDecimal32Scalar(JNIEnv *env, jclass, - jint value, jint scale, + jint value, + jint scale, jboolean is_valid) { try { cudf::jni::auto_set_device(env); auto const value_ = static_cast(value); auto const scale_ = numeric::scale_type{static_cast(scale)}; - std::unique_ptr s = - cudf::make_fixed_point_scalar(value_, scale_); + std::unique_ptr s = cudf::make_fixed_point_scalar(value_, scale_); s->set_valid(is_valid); return reinterpret_cast(s.release()); } CATCH_STD(env, 0); } + JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeDecimal64Scalar(JNIEnv *env, jclass, - jlong value, jint scale, + jlong value, + jint scale, jboolean is_valid) { try { cudf::jni::auto_set_device(env); auto const value_ = static_cast(value); auto const scale_ = numeric::scale_type{static_cast(scale)}; - std::unique_ptr s = - cudf::make_fixed_point_scalar(value_, scale_); + std::unique_ptr s = cudf::make_fixed_point_scalar(value_, scale_); s->set_valid(is_valid); return reinterpret_cast(s.release()); } @@ -450,7 +451,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_binaryOpSV(JNIEnv *env, jclas cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation( + *lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -468,7 +470,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeListScalar(JNIEnv *env, j // is false, always passes the input view to the scalar, to avoid copying the column // twice. // Let the Java layer make sure the view is empty when `is_valid` is false. - cudf::scalar *s = new cudf::list_scalar(*col_view); + cudf::scalar* s = new cudf::list_scalar(*col_view); s->set_valid(is_valid); return reinterpret_cast(s); } diff --git a/java/src/main/native/src/TableJni.cpp b/java/src/main/native/src/TableJni.cpp index fcb4444ec1a..3799a5dbab3 100644 --- a/java/src/main/native/src/TableJni.cpp +++ b/java/src/main/native/src/TableJni.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include #include #include @@ -46,6 +44,8 @@ #include "jni_utils.hpp" #include "row_conversion.hpp" +#include + namespace cudf { namespace jni { @@ -255,7 +255,7 @@ class native_arrow_ipc_writer_handle final { initialized = false; } - std::vector get_column_metadata(const cudf::table_view &tview) { + std::vector get_column_metadata(const cudf::table_view& tview) { if (!column_names.empty() && columns_meta.empty()) { // Rebuild the structure of column meta according to table schema. // All the tables written by this writer should share the same schema, @@ -276,7 +276,7 @@ class native_arrow_ipc_writer_handle final { } private: - cudf::column_metadata build_one_column_meta(const cudf::column_view &cview, size_t &idx, + cudf::column_metadata build_one_column_meta(const cudf::column_view& cview, size_t& idx, const bool consume_name = true) { auto col_meta = cudf::column_metadata{}; if (consume_name) { @@ -301,7 +301,7 @@ class native_arrow_ipc_writer_handle final { return col_meta; } - std::string &get_column_name(const size_t idx) { + std::string& get_column_name(const size_t idx) { if (idx < 0 || idx >= column_names.size()) { throw cudf::jni::jni_exception("Missing names for columns or nested struct columns"); } @@ -628,9 +628,9 @@ std::vector resolve_column_order(JNIEnv *env, jbooleanArray jkeys_s std::vector column_order(keys_sort_num); if (keys_sort_num > 0) { std::transform(keys_sort_desc.data(), keys_sort_desc.data() + keys_sort_num, - column_order.begin(), [](jboolean is_desc) { - return is_desc ? cudf::order::DESCENDING : cudf::order::ASCENDING; - }); + column_order.begin(), + [](jboolean is_desc) { return is_desc ? cudf::order::DESCENDING + : cudf::order::ASCENDING; }); } return column_order; } @@ -649,9 +649,9 @@ std::vector resolve_null_precedence(JNIEnv *env, jbooleanArray std::vector null_precedence(null_order_num); if (null_order_num > 0) { std::transform(keys_null_first.data(), keys_null_first.data() + null_order_num, - null_precedence.begin(), [](jboolean null_before) { - return null_before ? cudf::null_order::BEFORE : cudf::null_order::AFTER; - }); + null_precedence.begin(), + [](jboolean null_before) { return null_before ? cudf::null_order::BEFORE + : cudf::null_order::AFTER; }); } return null_precedence; } @@ -659,11 +659,11 @@ std::vector resolve_null_precedence(JNIEnv *env, jbooleanArray namespace { int set_column_metadata(cudf::io::column_in_metadata &column_metadata, - std::vector &col_names, - cudf::jni::native_jbooleanArray &nullability, - cudf::jni::native_jbooleanArray &isInt96, - cudf::jni::native_jintArray &precisions, - cudf::jni::native_jintArray &children, int num_children, int read_index) { + std::vector &col_names, + cudf::jni::native_jbooleanArray &nullability, + cudf::jni::native_jbooleanArray &isInt96, + cudf::jni::native_jintArray &precisions, + cudf::jni::native_jintArray &children, int num_children, int read_index) { int write_index = 0; for (int i = 0; i < num_children; i++, write_index++) { cudf::io::column_in_metadata child; @@ -681,11 +681,11 @@ int set_column_metadata(cudf::io::column_in_metadata &column_metadata, return read_index; } -void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_names, - jintArray &j_children, jbooleanArray &j_col_nullability, - jobjectArray &j_metadata_keys, jobjectArray &j_metadata_values, - jint j_compression, jint j_stats_freq, jbooleanArray &j_isInt96, - jintArray &j_precisions, cudf::io::table_input_metadata &metadata) { +void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_names, jintArray &j_children, + jbooleanArray &j_col_nullability, jobjectArray &j_metadata_keys, + jobjectArray &j_metadata_values, jint j_compression, jint j_stats_freq, + jbooleanArray &j_isInt96, jintArray &j_precisions, + cudf::io::table_input_metadata& metadata) { cudf::jni::auto_set_device(env); cudf::jni::native_jstringArray col_names(env, j_col_names); cudf::jni::native_jbooleanArray col_nullability(env, j_col_nullability); @@ -709,14 +709,14 @@ void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_nam .set_decimal_precision(precisions[read_index]); int childs_children = children[read_index++]; if (childs_children > 0) { - read_index = - set_column_metadata(metadata.column_metadata[write_index], cpp_names, col_nullability, - isInt96, precisions, children, childs_children, read_index); + read_index = set_column_metadata(metadata.column_metadata[write_index], cpp_names, + col_nullability, isInt96, precisions, children, childs_children, read_index); } } for (auto i = 0; i < meta_keys.size(); ++i) { metadata.user_data[meta_keys[i].get()] = meta_values[i].get(); } + } // Check that window parameters are valid. @@ -845,7 +845,8 @@ jlongArray combine_join_results(JNIEnv *env, cudf::table &left_results, extern "C" { -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_createCudfTableView(JNIEnv *env, jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_createCudfTableView(JNIEnv *env, + jclass, jlongArray j_cudf_columns) { JNI_NULL_CHECK(env, j_cudf_columns, "columns are null", 0); @@ -926,13 +927,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_sortOrder(JNIEnv *env, jclass, jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); std::vector order(n_is_descending.size()); for (int i = 0; i < n_is_descending.size(); i++) { @@ -955,6 +956,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_sortOrder(JNIEnv *env, jclass, CATCH_STD(env, 0); } + JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_orderBy(JNIEnv *env, jclass, jlong j_input_table, jlongArray j_sort_keys_columns, @@ -976,13 +978,13 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_orderBy(JNIEnv *env, jcla jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and areNullsSmallest lengths don't match", 0); + "columns and areNullsSmallest lengths don't match", 0); std::vector order(n_is_descending.size()); for (int i = 0; i < n_is_descending.size(); i++) { @@ -1030,13 +1032,13 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_merge(JNIEnv *env, jclass jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", NULL); + "columns and is_descending lengths don't match", NULL); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and areNullsSmallest lengths don't match", NULL); + "columns and areNullsSmallest lengths don't match", NULL); std::vector indexes(n_sort_key_indexes.size()); for (int i = 0; i < n_sort_key_indexes.size(); i++) { @@ -1127,8 +1129,8 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readCSV( } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readParquet( - JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, jlong buffer, - jlong buffer_length, jint unit, jboolean strict_decimal_types) { + JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, + jlong buffer, jlong buffer_length, jint unit, jboolean strict_decimal_types) { bool read_buffer = true; if (buffer == 0) { JNI_NULL_CHECK(env, inputfilepath, "input file or buffer must be supplied", NULL); @@ -1184,14 +1186,14 @@ JNIEXPORT long JNICALL Java_ai_rapids_cudf_Table_writeParquetBufferBegin( try { std::unique_ptr data_sink( new cudf::jni::jni_writer_data_sink(env, consumer)); - + using namespace cudf::io; using namespace cudf::jni; sink_info sink{data_sink.get()}; table_input_metadata metadata; - createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, - j_metadata_keys, j_metadata_values, j_compression, j_stats_freq, j_isInt96, - j_precisions, metadata); + createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, j_metadata_keys, + j_metadata_values, j_compression, j_stats_freq, j_isInt96, j_precisions, + metadata); chunked_parquet_writer_options opts = chunked_parquet_writer_options::builder(sink) @@ -1220,12 +1222,11 @@ JNIEXPORT long JNICALL Java_ai_rapids_cudf_Table_writeParquetFileBegin( try { cudf::jni::native_jstring output_path(env, j_output_path); - using namespace cudf::io; - using namespace cudf::jni; + using namespace cudf::io; + using namespace cudf::jni; table_input_metadata metadata; - createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, - j_metadata_keys, j_metadata_values, j_compression, j_stats_freq, j_isInt96, - j_precisions, metadata); + createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, j_metadata_keys, + j_metadata_values, j_compression, j_stats_freq, j_isInt96, j_precisions, metadata); sink_info sink{output_path.get()}; chunked_parquet_writer_options opts = chunked_parquet_writer_options::builder(sink) @@ -1280,8 +1281,8 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_Table_writeParquetEnd(JNIEnv *env, jc } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readORC( - JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, jlong buffer, - jlong buffer_length, jboolean usingNumPyTypes, jint unit) { + JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, + jlong buffer, jlong buffer_length, jboolean usingNumPyTypes, jint unit) { bool read_buffer = true; if (buffer == 0) { JNI_NULL_CHECK(env, inputfilepath, "input file or buffer must be supplied", NULL); @@ -1789,10 +1790,10 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_leftSemiJoin( std::vector right_join_cols( right_join_cols_arr.data(), right_join_cols_arr.data() + right_join_cols_arr.size()); - std::unique_ptr result = - cudf::left_semi_join(*n_left_table, *n_right_table, left_join_cols, right_join_cols, - static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : - cudf::null_equality::UNEQUAL); + std::unique_ptr result = cudf::left_semi_join( + *n_left_table, *n_right_table, left_join_cols, right_join_cols, + static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : + cudf::null_equality::UNEQUAL); return cudf::jni::convert_table_for_return(env, result); } @@ -1818,10 +1819,10 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_leftAntiJoin( std::vector right_join_cols( right_join_cols_arr.data(), right_join_cols_arr.data() + right_join_cols_arr.size()); - std::unique_ptr result = - cudf::left_anti_join(*n_left_table, *n_right_table, left_join_cols, right_join_cols, - static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : - cudf::null_equality::UNEQUAL); + std::unique_ptr result = cudf::left_anti_join( + *n_left_table, *n_right_table, left_join_cols, right_join_cols, + static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : + cudf::null_equality::UNEQUAL); return cudf::jni::convert_table_for_return(env, result); } @@ -1894,8 +1895,7 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_crossJoin(JNIEnv *env, jc JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_interleaveColumns(JNIEnv *env, jclass, jlongArray j_cudf_table_view) { - JNI_NULL_CHECK(env, j_cudf_table_view, "table is null", 0); - try { + JNI_NULL_CHECK(env, j_cudf_table_view, "table is null", 0); try { cudf::jni::auto_set_device(env); cudf::table_view *table_view = reinterpret_cast(j_cudf_table_view); std::unique_ptr result = cudf::interleave_columns(*table_view); @@ -1943,7 +1943,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_partition(JNIEnv *env, jc cudf::column_view *n_part_column = reinterpret_cast(partition_column); cudf::jni::native_jintArray n_output_offsets(env, output_offsets); - auto result = cudf::partition(*n_input_table, *n_part_column, number_of_partitions); + auto result = cudf::partition(*n_input_table, + *n_part_column, + number_of_partitions); for (size_t i = 0; i < result.second.size() - 1; i++) { // for what ever reason partition returns the length of the result at then @@ -1957,9 +1959,12 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_partition(JNIEnv *env, jc CATCH_STD(env, NULL); } -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition( - JNIEnv *env, jclass, jlong input_table, jintArray columns_to_hash, jint hash_function, - jint number_of_partitions, jintArray output_offsets) { +JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition(JNIEnv *env, jclass, + jlong input_table, + jintArray columns_to_hash, + jint hash_function, + jint number_of_partitions, + jintArray output_offsets) { JNI_NULL_CHECK(env, input_table, "input table is null", NULL); JNI_NULL_CHECK(env, columns_to_hash, "columns_to_hash is null", NULL); @@ -1981,7 +1986,10 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition( } std::pair, std::vector> result = - cudf::hash_partition(*n_input_table, columns_to_hash_vec, number_of_partitions, hash_func); + cudf::hash_partition(*n_input_table, + columns_to_hash_vec, + number_of_partitions, + hash_func); for (size_t i = 0; i < result.second.size(); i++) { n_output_offsets[i] = result.second[i]; @@ -2017,9 +2025,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_roundRobinPartition( } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_groupByAggregate( - JNIEnv *env, jclass, jlong input_table, jintArray keys, jintArray aggregate_column_indices, - jlongArray agg_instances, jboolean ignore_null_keys, jboolean jkey_sorted, - jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { + JNIEnv *env, jclass, jlong input_table, jintArray keys, + jintArray aggregate_column_indices, jlongArray agg_instances, jboolean ignore_null_keys, + jboolean jkey_sorted, jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { JNI_NULL_CHECK(env, input_table, "input table is null", NULL); JNI_NULL_CHECK(env, keys, "input keys are null", NULL); JNI_NULL_CHECK(env, aggregate_column_indices, "input aggregate_column_indices are null", NULL); @@ -2038,11 +2046,16 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_groupByAggregate( } cudf::table_view n_keys_table(n_keys_cols); - auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, n_keys.size()); - auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, n_keys.size()); - cudf::groupby::groupby grouper( - n_keys_table, ignore_null_keys ? cudf::null_policy::EXCLUDE : cudf::null_policy::INCLUDE, - jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO, column_order, null_precedence); + auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, + n_keys.size()); + auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, + n_keys.size()); + cudf::groupby::groupby grouper(n_keys_table, + ignore_null_keys ? cudf::null_policy::EXCLUDE + : cudf::null_policy::INCLUDE, + jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO, + column_order, + null_precedence); // Aggregates are passed in already grouped by column, so we just need to fill it in // as we go. @@ -2235,8 +2248,8 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplit(JNIEnv cudf::jni::native_jobjectArray n_result = cudf::jni::contiguous_table_array(env, result.size()); for (size_t i = 0; i < result.size(); i++) { - n_result.set( - i, cudf::jni::contiguous_table_from(env, result[i].data, result[i].table.num_rows())); + n_result.set(i, cudf::jni::contiguous_table_from(env, result[i].data, + result[i].table.num_rows())); } return n_result.wrapped(); } @@ -2281,9 +2294,8 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rollingWindowAggregate( std::vector> result_columns; for (int i(0); i < values.size(); ++i) { - cudf::rolling_aggregation *agg = dynamic_cast(agg_instances[i]); - JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", - nullptr); + cudf::rolling_aggregation * agg = dynamic_cast(agg_instances[i]); + JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", nullptr); int agg_column_index = values[i]; if (default_output[i] != nullptr) { @@ -2291,9 +2303,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rollingWindowAggregate( groupby_keys, input_table->column(agg_column_index), *default_output[i], preceding[i], following[i], min_periods[i], *agg))); } else { - result_columns.emplace_back(std::move( - cudf::grouped_rolling_window(groupby_keys, input_table->column(agg_column_index), - preceding[i], following[i], min_periods[i], *agg))); + result_columns.emplace_back(std::move(cudf::grouped_rolling_window( + groupby_keys, input_table->column(agg_column_index), preceding[i], following[i], + min_periods[i], *agg))); } } @@ -2307,8 +2319,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_timeRangeRollingWindowAgg JNIEnv *env, jclass, jlong j_input_table, jintArray j_keys, jintArray j_timestamp_column_indices, jbooleanArray j_is_timestamp_ascending, jintArray j_aggregate_column_indices, jlongArray j_agg_instances, jintArray j_min_periods, - jintArray j_preceding, jintArray j_following, jbooleanArray j_unbounded_preceding, - jbooleanArray j_unbounded_following, jboolean ignore_null_keys) { + jintArray j_preceding, jintArray j_following, + jbooleanArray j_unbounded_preceding, jbooleanArray j_unbounded_following, + jboolean ignore_null_keys) { JNI_NULL_CHECK(env, j_input_table, "input table is null", NULL); JNI_NULL_CHECK(env, j_keys, "input keys are null", NULL); @@ -2349,19 +2362,23 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_timeRangeRollingWindowAgg for (int i(0); i < values.size(); ++i) { int agg_column_index = values[i]; - cudf::rolling_aggregation *agg = dynamic_cast(agg_instances[i]); - JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", - nullptr); - - result_columns.emplace_back(std::move(cudf::grouped_time_range_rolling_window( - groupby_keys, input_table->column(timestamps[i]), - timestamp_ascending[i] ? cudf::order::ASCENDING : cudf::order::DESCENDING, - input_table->column(agg_column_index), - unbounded_preceding[i] ? cudf::window_bounds::unbounded() : - cudf::window_bounds::get(preceding[i]), - unbounded_following[i] ? cudf::window_bounds::unbounded() : - cudf::window_bounds::get(following[i]), - min_periods[i], *agg))); + cudf::rolling_aggregation * agg = dynamic_cast(agg_instances[i]); + JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", nullptr); + + result_columns.emplace_back( + std::move( + cudf::grouped_time_range_rolling_window( + groupby_keys, + input_table->column(timestamps[i]), + timestamp_ascending[i] ? cudf::order::ASCENDING : cudf::order::DESCENDING, + input_table->column(agg_column_index), + unbounded_preceding[i] ? cudf::window_bounds::unbounded() : cudf::window_bounds::get(preceding[i]), + unbounded_following[i] ? cudf::window_bounds::unbounded() : cudf::window_bounds::get(following[i]), + min_periods[i], + *agg + ) + ) + ); } auto result_table = std::make_unique(std::move(result_columns)); @@ -2426,20 +2443,24 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_explodeOuterPosition(JNIE CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_rowBitCount(JNIEnv *env, jclass, jlong j_table) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_rowBitCount(JNIEnv* env, jclass, jlong j_table) { JNI_NULL_CHECK(env, j_table, "table is null", 0); try { cudf::jni::auto_set_device(env); - auto t = reinterpret_cast(j_table); + auto t = reinterpret_cast(j_table); std::unique_ptr result = cudf::row_bit_count(*t); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); } -JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups( - JNIEnv *env, jclass, jlong jinput_table, jintArray jkey_indices, jboolean jignore_null_keys, - jboolean jkey_sorted, jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { +JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(JNIEnv *env, jclass, + jlong jinput_table, + jintArray jkey_indices, + jboolean jignore_null_keys, + jboolean jkey_sorted, + jbooleanArray jkeys_sort_desc, + jbooleanArray jkeys_null_first) { JNI_NULL_CHECK(env, jinput_table, "table native handle is null", 0); JNI_NULL_CHECK(env, jkey_indices, "key indices are null", 0); // Two main steps to split the groups in the input table. @@ -2457,16 +2478,17 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups( std::vector key_indices(n_key_indices.data(), n_key_indices.data() + n_key_indices.size()); auto keys = input_table->select(key_indices); - auto null_handling = - jignore_null_keys ? cudf::null_policy::EXCLUDE : cudf::null_policy::INCLUDE; + auto null_handling = jignore_null_keys ? cudf::null_policy::EXCLUDE + : cudf::null_policy::INCLUDE; auto keys_are_sorted = jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO; - auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, key_indices.size()); - auto null_precedence = - cudf::jni::resolve_null_precedence(env, jkeys_null_first, key_indices.size()); + auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, + key_indices.size()); + auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, + key_indices.size()); // Constructs a groupby - cudf::groupby::groupby grouper(keys, null_handling, keys_are_sorted, column_order, - null_precedence); + cudf::groupby::groupby grouper(keys, null_handling, keys_are_sorted, + column_order, null_precedence); // 1) Gets the groups(keys, offsets, values) from groupby. // @@ -2483,7 +2505,7 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups( // not key column, so adds it as value column. value_indices.emplace_back(index); } - index++; + index ++; } cudf::table_view values_view = input_table->select(value_indices); cudf::groupby::groupby::groups groups = grouper.get_groups(values_view); @@ -2496,32 +2518,31 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups( auto key_view_it = key_view.begin(); for (auto key_id : key_indices) { grouped_cols.at(key_id) = std::move(*key_view_it); - key_view_it++; + key_view_it ++; } // value columns auto value_view = groups.values->view(); auto value_view_it = value_view.begin(); for (auto value_id : value_indices) { grouped_cols.at(value_id) = std::move(*value_view_it); - value_view_it++; + value_view_it ++; } cudf::table_view grouped_table(grouped_cols); // When no key columns, uses the input table instead, because the output // of 'get_groups' is empty. - auto &grouped_view = key_indices.empty() ? *input_table : grouped_table; + auto& grouped_view = key_indices.empty() ? *input_table : grouped_table; // Resolves the split indices from offsets vector directly to avoid copying. Since // the offsets vector may be very large if there are too many small groups. - std::vector &split_indices = groups.offsets; + std::vector& split_indices = groups.offsets; // Offsets laysout is [0, split indices..., num_rows] or [0] for empty keys, so // need to removes the first and last elements. split_indices.erase(split_indices.begin()); - if (!split_indices.empty()) { - split_indices.pop_back(); - } + if (!split_indices.empty()) { split_indices.pop_back(); } // 2) Splits the groups. - std::vector result = cudf::contiguous_split(grouped_view, split_indices); + std::vector result = + cudf::contiguous_split(grouped_view, split_indices); // Release the grouped table right away after split done. groups.keys.reset(nullptr); groups.values.reset(nullptr); @@ -2530,8 +2551,8 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups( cudf::jni::native_jobjectArray n_result = cudf::jni::contiguous_table_array(env, result.size()); for (size_t i = 0; i < result.size(); i++) { - n_result.set( - i, cudf::jni::contiguous_table_from(env, result[i].data, result[i].table.num_rows())); + n_result.set(i, cudf::jni::contiguous_table_from(env, result[i].data, + result[i].table.num_rows())); } return n_result.wrapped(); } diff --git a/java/src/main/native/src/cudf_jni_apis.hpp b/java/src/main/native/src/cudf_jni_apis.hpp index fbcca0c82ee..14999156890 100644 --- a/java/src/main/native/src/cudf_jni_apis.hpp +++ b/java/src/main/native/src/cudf_jni_apis.hpp @@ -75,7 +75,7 @@ void auto_set_device(JNIEnv *env); * The operation has not necessarily completed when this returns, but it could overlap with * operations occurring on other streams. */ -void device_memset_async(JNIEnv *env, rmm::device_buffer &buf, char value); +void device_memset_async(JNIEnv *env, rmm::device_buffer& buf, char value); } // namespace jni } // namespace cudf diff --git a/java/src/main/native/src/dtype_utils.hpp b/java/src/main/native/src/dtype_utils.hpp index 9fae0c585e6..bde7bd2894e 100644 --- a/java/src/main/native/src/dtype_utils.hpp +++ b/java/src/main/native/src/dtype_utils.hpp @@ -15,9 +15,8 @@ */ #pragma once -#include - #include +#include namespace cudf { namespace jni { @@ -26,7 +25,9 @@ namespace jni { inline cudf::data_type timestamp_to_duration(cudf::data_type dt) { cudf::type_id duration_type_id; switch (dt.id()) { - case cudf::type_id::TIMESTAMP_DAYS: duration_type_id = cudf::type_id::DURATION_DAYS; break; + case cudf::type_id::TIMESTAMP_DAYS: + duration_type_id = cudf::type_id::DURATION_DAYS; + break; case cudf::type_id::TIMESTAMP_SECONDS: duration_type_id = cudf::type_id::DURATION_SECONDS; break; @@ -39,13 +40,14 @@ inline cudf::data_type timestamp_to_duration(cudf::data_type dt) { case cudf::type_id::TIMESTAMP_NANOSECONDS: duration_type_id = cudf::type_id::DURATION_NANOSECONDS; break; - default: throw std::logic_error("Unexpected type in timestamp_to_duration"); + default: + throw std::logic_error("Unexpected type in timestamp_to_duration"); } return cudf::data_type(duration_type_id); } inline bool is_decimal_type(cudf::type_id n_type) { - return n_type == cudf::type_id::DECIMAL32 || n_type == cudf::type_id::DECIMAL64; + return n_type == cudf::type_id::DECIMAL32 || n_type == cudf::type_id::DECIMAL64 ; } // create data_type including scale for decimal type diff --git a/java/src/main/native/src/map_lookup.cu b/java/src/main/native/src/map_lookup.cu index 82e6714967a..0ba683b45f1 100644 --- a/java/src/main/native/src/map_lookup.cu +++ b/java/src/main/native/src/map_lookup.cu @@ -157,9 +157,9 @@ std::unique_ptr map_lookup(column_view const &map_column, string_scalar auto values_column = structs_column.child(1); auto table_for_gather = table_view{std::vector{values_column}}; - auto gathered_table = - cudf::detail::gather(table_for_gather, gather_map->view(), out_of_bounds_policy::NULLIFY, - detail::negative_index_policy::NOT_ALLOWED, stream, mr); + auto gathered_table = cudf::detail::gather( + table_for_gather, gather_map->view(), out_of_bounds_policy::NULLIFY, + detail::negative_index_policy::NOT_ALLOWED, stream, mr); return std::make_unique(std::move(gathered_table->get_column(0))); } diff --git a/java/src/main/native/src/prefix_sum.cu b/java/src/main/native/src/prefix_sum.cu index 277ca1d4dc1..e3c53696185 100644 --- a/java/src/main/native/src/prefix_sum.cu +++ b/java/src/main/native/src/prefix_sum.cu @@ -14,27 +14,33 @@ * limitations under the License. */ +#include + #include #include + #include -#include #include -#include +#include + namespace cudf { namespace jni { -std::unique_ptr prefix_sum(column_view const &value_column, rmm::cuda_stream_view stream, +std::unique_ptr prefix_sum(column_view const &value_column, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource *mr) { // Defensive checks. CUDF_EXPECTS(value_column.type().id() == type_id::INT64, "Only longs are supported."); CUDF_EXPECTS(!value_column.has_nulls(), "NULLS are not supported"); - auto result = make_numeric_column(value_column.type(), value_column.size(), mask_state::ALL_VALID, - stream, mr); + auto result = make_numeric_column(value_column.type(), value_column.size(), + mask_state::ALL_VALID, stream, mr); - thrust::inclusive_scan(rmm::exec_policy(stream), value_column.begin(), - value_column.end(), result->mutable_view().begin()); + thrust::inclusive_scan(rmm::exec_policy(stream), + value_column.begin(), + value_column.end(), + result->mutable_view().begin()); return result; } diff --git a/java/src/main/native/src/prefix_sum.hpp b/java/src/main/native/src/prefix_sum.hpp index ea58a027207..8f39f9a8c69 100644 --- a/java/src/main/native/src/prefix_sum.hpp +++ b/java/src/main/native/src/prefix_sum.hpp @@ -27,7 +27,8 @@ namespace jni { * @brief compute the prefix sum of a column of longs */ std::unique_ptr -prefix_sum(column_view const &value_column, rmm::cuda_stream_view stream = rmm::cuda_stream_default, +prefix_sum(column_view const &value_column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); } // namespace jni diff --git a/python/cudf/cudf/_lib/aggregation.pxd b/python/cudf/cudf/_lib/aggregation.pxd index f608dab3fe1..56fa9fdc63e 100644 --- a/python/cudf/cudf/_lib/aggregation.pxd +++ b/python/cudf/cudf/_lib/aggregation.pxd @@ -1,8 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr - -from cudf._lib.cpp.aggregation cimport aggregation, rolling_aggregation +from cudf._lib.cpp.aggregation cimport aggregation +from cudf._lib.cpp.aggregation cimport rolling_aggregation cdef class Aggregation: diff --git a/python/cudf/cudf/_lib/aggregation.pyx b/python/cudf/cudf/_lib/aggregation.pyx index 4c94452c73d..cda35025c7e 100644 --- a/python/cudf/cudf/_lib/aggregation.pyx +++ b/python/cudf/cudf/_lib/aggregation.pyx @@ -2,30 +2,27 @@ from enum import Enum +import pandas as pd import numba import numpy as np -import pandas as pd - -from libcpp.memory cimport unique_ptr from libcpp.string cimport string -from libcpp.utility cimport move +from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector - -from cudf._lib.types import NullHandling, cudf_to_np_types, np_to_cudf_types +from libcpp.utility cimport move from cudf.utils import cudautils +from cudf._lib.types import np_to_cudf_types, cudf_to_np_types, NullHandling from cudf._lib.types cimport ( underlying_type_t_interpolation, underlying_type_t_null_policy, underlying_type_t_type_id, ) +from cudf._lib.types import Interpolation from numba.np import numpy_support -from cudf._lib.types import Interpolation - -cimport cudf._lib.cpp.aggregation as libcudf_aggregation cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.aggregation as libcudf_aggregation class AggregationKind(Enum): diff --git a/python/cudf/cudf/_lib/avro.pyx b/python/cudf/cudf/_lib/avro.pyx index 52ddbd8b8fb..ed98429a2d6 100644 --- a/python/cudf/cudf/_lib/avro.pyx +++ b/python/cudf/cudf/_lib/avro.pyx @@ -1,13 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.string cimport string -from libcpp.utility cimport move -from libcpp.vector cimport vector - from cudf._lib.cpp.io.avro cimport ( avro_reader_options, - read_avro as libcudf_read_avro, + read_avro as libcudf_read_avro ) + +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp.utility cimport move + from cudf._lib.cpp.io.types cimport table_with_metadata from cudf._lib.cpp.types cimport size_type from cudf._lib.io.utils cimport make_source_info diff --git a/python/cudf/cudf/_lib/binaryop.pxd b/python/cudf/cudf/_lib/binaryop.pxd index 1f6022251b3..3fb36055465 100644 --- a/python/cudf/cudf/_lib/binaryop.pxd +++ b/python/cudf/cudf/_lib/binaryop.pxd @@ -2,4 +2,5 @@ from libc.stdint cimport int32_t + ctypedef int32_t underlying_type_t_binary_operator diff --git a/python/cudf/cudf/_lib/binaryop.pyx b/python/cudf/cudf/_lib/binaryop.pyx index d8d4fe0b40b..5eaec640b15 100644 --- a/python/cudf/cudf/_lib/binaryop.pyx +++ b/python/cudf/cudf/_lib/binaryop.pyx @@ -1,8 +1,7 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from enum import IntEnum - import numpy as np +from enum import IntEnum from libcpp.memory cimport unique_ptr from libcpp.string cimport string @@ -10,24 +9,24 @@ from libcpp.utility cimport move from cudf._lib.binaryop cimport underlying_type_t_binary_operator from cudf._lib.column cimport Column - from cudf._lib.replace import replace_nulls from cudf._lib.scalar import as_device_scalar - from cudf._lib.scalar cimport DeviceScalar - from cudf._lib.types import np_to_cudf_types +from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.types cimport data_type, type_id -from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport ( + data_type, + type_id, +) -from cudf.utils.dtypes import is_scalar, is_string_dtype +from cudf.utils.dtypes import is_string_dtype, is_scalar -cimport cudf._lib.cpp.binaryop as cpp_binaryop from cudf._lib.cpp.binaryop cimport binary_operator +cimport cudf._lib.cpp.binaryop as cpp_binaryop class BinaryOperation(IntEnum): diff --git a/python/cudf/cudf/_lib/column.pxd b/python/cudf/cudf/_lib/column.pxd index 2df958466c6..6fb834410e6 100644 --- a/python/cudf/cudf/_lib/column.pxd +++ b/python/cudf/cudf/_lib/column.pxd @@ -5,10 +5,13 @@ from libcpp.memory cimport unique_ptr from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport ( + column_view, mutable_column_view +) + cdef class Column: cdef public: diff --git a/python/cudf/cudf/_lib/column.pyi b/python/cudf/cudf/_lib/column.pyi index bafa1c914fd..3387a9f268e 100644 --- a/python/cudf/cudf/_lib/column.pyi +++ b/python/cudf/cudf/_lib/column.pyi @@ -1,13 +1,13 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from __future__ import annotations +from typing import Tuple, Union, TypeVar, Optional -from typing import Optional, Tuple, TypeVar, Union - -from cudf._typing import Dtype, DtypeObj, ScalarLike +from cudf._typing import DtypeObj, Dtype, ScalarLike from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase + T = TypeVar("T") class Column: diff --git a/python/cudf/cudf/_lib/column.pyx b/python/cudf/cudf/_lib/column.pyx index b5223a32a18..a3e01a4ac9d 100644 --- a/python/cudf/cudf/_lib/column.pyx +++ b/python/cudf/cudf/_lib/column.pyx @@ -3,54 +3,51 @@ import cupy as cp import numpy as np import pandas as pd - import rmm import cudf -import cudf._lib as libcudfxx + from cudf.core.buffer import Buffer from cudf.utils.dtypes import ( is_categorical_dtype, is_decimal_dtype, is_list_dtype, - is_struct_dtype, + is_struct_dtype ) +import cudf._lib as libcudfxx from cpython.buffer cimport PyObject_CheckBuffer from libc.stdint cimport uintptr_t -from libcpp cimport bool -from libcpp.memory cimport make_unique, unique_ptr from libcpp.pair cimport pair -from libcpp.utility cimport move +from libcpp cimport bool +from libcpp.memory cimport unique_ptr, make_unique from libcpp.vector cimport vector - -from rmm._lib.device_buffer cimport DeviceBuffer - +from libcpp.utility cimport move from cudf._lib.cpp.strings.convert.convert_integers cimport ( - from_integers as cpp_from_integers, + from_integers as cpp_from_integers ) -from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +from rmm._lib.device_buffer cimport DeviceBuffer +from cudf._lib.types import np_to_cudf_types, cudf_to_np_types from cudf._lib.types cimport ( - dtype_from_column_view, - dtype_to_data_type, underlying_type_t_type_id, + dtype_from_column_view, + dtype_to_data_type ) - from cudf._lib.null_mask import bitmask_allocation_size_bytes -cimport cudf._lib.cpp.types as libcudf_types -cimport cudf._lib.cpp.unary as libcudf_unary from cudf._lib.cpp.column.column cimport column, column_contents +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.column.column_factories cimport ( make_column_from_scalar as cpp_make_column_from_scalar, - make_numeric_column, + make_numeric_column ) -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.scalar cimport DeviceScalar +cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.unary as libcudf_unary cdef class Column: diff --git a/python/cudf/cudf/_lib/concat.pyx b/python/cudf/cudf/_lib/concat.pyx index 86778e0a9e1..cef93798601 100644 --- a/python/cudf/cudf/_lib/concat.pyx +++ b/python/cudf/cudf/_lib/concat.pyx @@ -1,29 +1,29 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport make_unique, unique_ptr -from libcpp.utility cimport move +from libcpp.memory cimport unique_ptr, make_unique from libcpp.vector cimport vector +from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.concatenate cimport ( - concatenate_columns as libcudf_concatenate_columns, concatenate_masks as libcudf_concatenate_masks, - concatenate_tables as libcudf_concatenate_tables, + concatenate_columns as libcudf_concatenate_columns, + concatenate_tables as libcudf_concatenate_tables ) +from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.table.table cimport table, table_view + +from cudf._lib.column cimport Column from cudf._lib.table cimport Table from cudf._lib.utils cimport ( make_column_views, - make_table_data_views, make_table_views, + make_table_data_views ) from cudf.core.buffer import Buffer -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer - +from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer cpdef concat_masks(object columns): cdef device_buffer c_result diff --git a/python/cudf/cudf/_lib/copying.pyx b/python/cudf/cudf/_lib/copying.pyx index 5780c0735ef..548e16155dd 100644 --- a/python/cudf/cudf/_lib/copying.pyx +++ b/python/cudf/cudf/_lib/copying.pyx @@ -2,33 +2,33 @@ import pandas as pd -from libc.stdint cimport int32_t, int64_t from libcpp cimport bool -from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr -from libcpp.utility cimport move +from libcpp.memory cimport make_unique, unique_ptr, shared_ptr, make_shared from libcpp.vector cimport vector +from libcpp.utility cimport move +from libc.stdint cimport int32_t, int64_t from cudf._lib.column cimport Column - from cudf._lib.scalar import as_device_scalar - from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table - from cudf._lib.reduce import minmax -cimport cudf._lib.cpp.copying as cpp_copying from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view -from cudf._lib.cpp.libcpp.functional cimport reference_wrapper -from cudf._lib.cpp.lists.gather cimport ( - segmented_gather as cpp_segmented_gather, +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view ) -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.libcpp.functional cimport reference_wrapper from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.lists.gather cimport ( + segmented_gather as cpp_segmented_gather +) +cimport cudf._lib.cpp.copying as cpp_copying # workaround for https://github.com/cython/cython/issues/3885 ctypedef const scalar constscalar diff --git a/python/cudf/cudf/_lib/cpp/aggregation.pxd b/python/cudf/cudf/_lib/cpp/aggregation.pxd index b13815c925d..839bdae7427 100644 --- a/python/cudf/cudf/_lib/cpp/aggregation.pxd +++ b/python/cudf/cudf/_lib/cpp/aggregation.pxd @@ -1,14 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr from libcpp.string cimport string +from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector from cudf._lib.cpp.types cimport ( + size_type, data_type, interpolation, - null_policy, - size_type, + null_policy ) diff --git a/python/cudf/cudf/_lib/cpp/binaryop.pxd b/python/cudf/cudf/_lib/cpp/binaryop.pxd index 3557ecd8487..2e36070a164 100644 --- a/python/cudf/cudf/_lib/cpp/binaryop.pxd +++ b/python/cudf/cudf/_lib/cpp/binaryop.pxd @@ -4,10 +4,11 @@ from libcpp.memory cimport unique_ptr from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.types cimport data_type - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport ( + data_type +) cdef extern from "cudf/binaryop.hpp" namespace "cudf" nogil: ctypedef enum binary_operator: diff --git a/python/cudf/cudf/_lib/cpp/column/column.pxd b/python/cudf/cudf/_lib/cpp/column/column.pxd index 205a1548c54..8e880337f94 100644 --- a/python/cudf/cudf/_lib/cpp/column/column.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column.pxd @@ -1,14 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from libcpp cimport bool from rmm._lib.device_buffer cimport device_buffer - -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view -from cudf._lib.cpp.types cimport data_type, size_type - +from cudf._lib.cpp.types cimport size_type, data_type +from cudf._lib.cpp.column.column_view cimport ( + column_view, mutable_column_view +) cdef extern from "cudf/column/column.hpp" namespace "cudf" nogil: cdef cppclass column_contents "cudf::column::contents": diff --git a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd index 0f22e788bd7..1da72160dfb 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd @@ -1,11 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.types cimport ( + data_type, + mask_state, + size_type, +) from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.types cimport data_type, mask_state, size_type - +from libcpp.memory cimport unique_ptr cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_numeric_column(data_type type, diff --git a/python/cudf/cudf/_lib/cpp/column/column_view.pxd b/python/cudf/cudf/_lib/cpp/column/column_view.pxd index 39c1c958531..e711fd62f8f 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_view.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_view.pxd @@ -1,9 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp cimport bool from libcpp.vector cimport vector +from libcpp cimport bool -from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type +from cudf._lib.cpp.types cimport ( + size_type, + data_type, + bitmask_type +) cdef extern from "cudf/column/column_view.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/concatenate.pxd b/python/cudf/cudf/_lib/cpp/concatenate.pxd index 05068318962..c776d23aa85 100644 --- a/python/cudf/cudf/_lib/cpp/concatenate.pxd +++ b/python/cudf/cudf/_lib/cpp/concatenate.pxd @@ -3,12 +3,11 @@ from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from rmm._lib.device_buffer cimport device_buffer - from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.table.table cimport table, table_view from cudf._lib.cpp.utilities.host_span cimport host_span +from rmm._lib.device_buffer cimport device_buffer cdef extern from "cudf/concatenate.hpp" namespace "cudf" nogil: # The versions of concatenate taking vectors don't exist in libcudf diff --git a/python/cudf/cudf/_lib/cpp/copying.pxd b/python/cudf/cudf/_lib/cpp/copying.pxd index b3688248e2d..55cbc3880ac 100644 --- a/python/cudf/cudf/_lib/cpp/copying.pxd +++ b/python/cudf/cudf/_lib/cpp/copying.pxd @@ -1,14 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport int32_t, int64_t +from rmm._lib.device_buffer cimport device_buffer + from libcpp cimport bool +from libc.stdint cimport int32_t, int64_t from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from rmm._lib.device_buffer cimport device_buffer - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view +) from cudf._lib.cpp.libcpp.functional cimport reference_wrapper from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table diff --git a/python/cudf/cudf/_lib/cpp/filling.pxd b/python/cudf/cudf/_lib/cpp/filling.pxd index 42bdd827452..79bf3c496e8 100644 --- a/python/cudf/cudf/_lib/cpp/filling.pxd +++ b/python/cudf/cudf/_lib/cpp/filling.pxd @@ -4,11 +4,15 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view +) from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/filling.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/gpuarrow.pxd b/python/cudf/cudf/_lib/cpp/gpuarrow.pxd index 6ebae78b5cd..3e21d784b6f 100644 --- a/python/cudf/cudf/_lib/cpp/gpuarrow.pxd +++ b/python/cudf/cudf/_lib/cpp/gpuarrow.pxd @@ -1,14 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader from pyarrow.includes.libarrow cimport ( - CBufferReader, - CMessage, - CMessageReader, CStatus, + CMessage, + CBufferReader, + CMessageReader ) -from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader - cdef extern from "cudf/ipc.hpp" nogil: diff --git a/python/cudf/cudf/_lib/cpp/groupby.pxd b/python/cudf/cudf/_lib/cpp/groupby.pxd index dea6feec857..2225898d697 100644 --- a/python/cudf/cudf/_lib/cpp/groupby.pxd +++ b/python/cudf/cudf/_lib/cpp/groupby.pxd @@ -1,16 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp cimport bool +from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair -from libcpp.vector cimport vector +from libcpp cimport bool -from cudf._lib.cpp.aggregation cimport aggregation -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport null_order, null_policy, order, size_type +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.aggregation cimport aggregation +from cudf._lib.cpp.types cimport size_type, order, null_order, null_policy cdef extern from "cudf/groupby.hpp" \ diff --git a/python/cudf/cudf/_lib/cpp/hash.pxd b/python/cudf/cudf/_lib/cpp/hash.pxd index f07a6c0f046..5cecf50cd98 100644 --- a/python/cudf/cudf/_lib/cpp/hash.pxd +++ b/python/cudf/cudf/_lib/cpp/hash.pxd @@ -4,10 +4,10 @@ from libc.stdint cimport uint32_t from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/hashing.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/interop.pxd b/python/cudf/cudf/_lib/cpp/interop.pxd index e81f0d617fb..ed082e26853 100644 --- a/python/cudf/cudf/_lib/cpp/interop.pxd +++ b/python/cudf/cudf/_lib/cpp/interop.pxd @@ -1,16 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport shared_ptr, unique_ptr -from libcpp.string cimport string +from libcpp.memory cimport unique_ptr +from libcpp.memory cimport shared_ptr from libcpp.vector cimport vector -from pyarrow.lib cimport CTable +from libcpp.string cimport string -from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +from pyarrow.lib cimport CTable +from cudf._lib.types import np_to_cudf_types, cudf_to_np_types from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view - cdef extern from "dlpack/dlpack.h" nogil: ctypedef struct DLManagedTensor: void(*deleter)(DLManagedTensor*) except + diff --git a/python/cudf/cudf/_lib/cpp/io/avro.pxd b/python/cudf/cudf/_lib/cpp/io/avro.pxd index 6efe42e5208..ac726cdd04d 100644 --- a/python/cudf/cudf/_lib/cpp/io/avro.pxd +++ b/python/cudf/cudf/_lib/cpp/io/avro.pxd @@ -3,8 +3,8 @@ from libcpp.string cimport string from libcpp.vector cimport vector -cimport cudf._lib.cpp.io.types as cudf_io_types from cudf._lib.cpp.types cimport size_type +cimport cudf._lib.cpp.io.types as cudf_io_types cdef extern from "cudf/io/avro.hpp" \ diff --git a/python/cudf/cudf/_lib/cpp/io/csv.pxd b/python/cudf/cudf/_lib/cpp/io/csv.pxd index c5e235b5697..6b6d36b3899 100644 --- a/python/cudf/cudf/_lib/cpp/io/csv.pxd +++ b/python/cudf/cudf/_lib/cpp/io/csv.pxd @@ -1,15 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport uint8_t from libcpp cimport bool -from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector +from libcpp.memory cimport shared_ptr, unique_ptr +from libc.stdint cimport uint8_t +from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view -from cudf._lib.cpp.types cimport data_type, size_type - cdef extern from "cudf/io/csv.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/json.pxd b/python/cudf/cudf/_lib/cpp/io/json.pxd index 6f20195e87f..31a5afa2bac 100644 --- a/python/cudf/cudf/_lib/cpp/io/json.pxd +++ b/python/cudf/cudf/_lib/cpp/io/json.pxd @@ -1,15 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport uint8_t from libcpp cimport bool -from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector +from libcpp.memory cimport shared_ptr, unique_ptr +from libc.stdint cimport uint8_t +from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view -from cudf._lib.cpp.types cimport data_type, size_type - cdef extern from "cudf/io/json.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/orc.pxd b/python/cudf/cudf/_lib/cpp/io/orc.pxd index d5e874d796e..7449f2c510c 100644 --- a/python/cudf/cudf/_lib/cpp/io/orc.pxd +++ b/python/cudf/cudf/_lib/cpp/io/orc.pxd @@ -1,15 +1,14 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from libc.stdint cimport uint8_t from libcpp cimport bool -from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector +from libcpp.memory cimport shared_ptr, unique_ptr +from libc.stdint cimport uint8_t +from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view -from cudf._lib.cpp.types cimport data_type, size_type - cdef extern from "cudf/io/orc.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd b/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd index 57be1b1c90c..e1128884491 100644 --- a/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd +++ b/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from libcpp.string cimport string from libcpp.vector cimport vector +from libcpp.string cimport string cimport cudf._lib.cpp.io.types as cudf_io_types diff --git a/python/cudf/cudf/_lib/cpp/io/parquet.pxd b/python/cudf/cudf/_lib/cpp/io/parquet.pxd index e2053f8ce4f..39da6b26502 100644 --- a/python/cudf/cudf/_lib/cpp/io/parquet.pxd +++ b/python/cudf/cudf/_lib/cpp/io/parquet.pxd @@ -1,16 +1,15 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from libc.stdint cimport uint8_t from libcpp cimport bool -from libcpp.map cimport map -from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector +from libcpp.map cimport map +from libcpp.memory cimport shared_ptr, unique_ptr +from libc.stdint cimport uint8_t +from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view -from cudf._lib.cpp.types cimport data_type, size_type - cdef extern from "cudf/io/parquet.hpp" namespace "cudf::io" nogil: cdef cppclass parquet_reader_options: diff --git a/python/cudf/cudf/_lib/cpp/io/types.pxd b/python/cudf/cudf/_lib/cpp/io/types.pxd index 7fa6406bd29..907d7763579 100644 --- a/python/cudf/cudf/_lib/cpp/io/types.pxd +++ b/python/cudf/cudf/_lib/cpp/io/types.pxd @@ -1,13 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool +from libcpp.memory cimport unique_ptr, shared_ptr +from libcpp.string cimport string from libcpp.map cimport map -from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.pair cimport pair -from libcpp.string cimport string from libcpp.vector cimport vector +from libcpp.pair cimport pair from pyarrow.includes.libarrow cimport CRandomAccessFile - from cudf._lib.cpp.table.table cimport table diff --git a/python/cudf/cudf/_lib/cpp/join.pxd b/python/cudf/cudf/_lib/cpp/join.pxd index 171658c78ee..c221fea926d 100644 --- a/python/cudf/cudf/_lib/cpp/join.pxd +++ b/python/cudf/cudf/_lib/cpp/join.pxd @@ -1,16 +1,18 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.pair cimport pair from libcpp.vector cimport vector - -from rmm._lib.device_uvector cimport device_uvector +from libcpp.pair cimport pair +from libcpp cimport bool +from libcpp.pair cimport pair +from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type +from rmm._lib.device_uvector cimport device_uvector + ctypedef unique_ptr[device_uvector[size_type]] gather_map_type diff --git a/python/cudf/cudf/_lib/cpp/labeling.pxd b/python/cudf/cudf/_lib/cpp/labeling.pxd index af9c4bb9a04..996ae4f9e38 100644 --- a/python/cudf/cudf/_lib/cpp/labeling.pxd +++ b/python/cudf/cudf/_lib/cpp/labeling.pxd @@ -5,7 +5,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "cudf/labeling/label_bins.hpp" namespace "cudf" nogil: ctypedef enum inclusive: YES "cudf::inclusive::YES" diff --git a/python/cudf/cudf/_lib/cpp/lists/contains.pxd b/python/cudf/cudf/_lib/cpp/lists/contains.pxd index 5790ae4e787..ec2f61d08fa 100644 --- a/python/cudf/cudf/_lib/cpp/lists/contains.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/contains.pxd @@ -1,12 +1,12 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.column.column_view cimport column_view cdef extern from "cudf/lists/contains.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] contains( diff --git a/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd b/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd index 9be38f26237..57d6daefd37 100644 --- a/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd @@ -5,6 +5,5 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view - cdef extern from "cudf/lists/count_elements.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] count_elements(const lists_column_view) except + diff --git a/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd b/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd index 81d54104320..40b1836f932 100644 --- a/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd @@ -2,10 +2,9 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.types cimport nan_equality, null_equality - +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.types cimport null_equality, nan_equality cdef extern from "cudf/lists/drop_list_duplicates.hpp" \ namespace "cudf::lists" nogil: diff --git a/python/cudf/cudf/_lib/cpp/lists/explode.pxd b/python/cudf/cudf/_lib/cpp/lists/explode.pxd index c3e15dd203c..cd2d44d2e42 100644 --- a/python/cudf/cudf/_lib/cpp/lists/explode.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/explode.pxd @@ -6,7 +6,6 @@ from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type - cdef extern from "cudf/lists/explode.hpp" namespace "cudf" nogil: cdef unique_ptr[table] explode_outer( const table_view, diff --git a/python/cudf/cudf/_lib/cpp/lists/extract.pxd b/python/cudf/cudf/_lib/cpp/lists/extract.pxd index a023f728989..89fa893c17d 100644 --- a/python/cudf/cudf/_lib/cpp/lists/extract.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/extract.pxd @@ -4,8 +4,8 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/lists/extract.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] extract_list_element( diff --git a/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd b/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd index aa18ede41bd..3290f52fba7 100644 --- a/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd @@ -1,6 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.column.column_view cimport ( + column_view, mutable_column_view +) cdef extern from "cudf/lists/lists_column_view.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/lists/sorting.pxd b/python/cudf/cudf/_lib/cpp/lists/sorting.pxd index 2115885ed95..55e8e09427c 100644 --- a/python/cudf/cudf/_lib/cpp/lists/sorting.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/sorting.pxd @@ -2,9 +2,9 @@ from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.types cimport order, null_order from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.types cimport null_order, order cdef extern from "cudf/lists/sorting.hpp" namespace "cudf::lists" nogil: diff --git a/python/cudf/cudf/_lib/cpp/merge.pxd b/python/cudf/cudf/_lib/cpp/merge.pxd index 32fe14ac479..b2d3d802e76 100644 --- a/python/cudf/cudf/_lib/cpp/merge.pxd +++ b/python/cudf/cudf/_lib/cpp/merge.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from libcpp.memory cimport unique_ptr -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/merge.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/null_mask.pxd b/python/cudf/cudf/_lib/cpp/null_mask.pxd index c225a16297b..b83c7a433c8 100644 --- a/python/cudf/cudf/_lib/cpp/null_mask.pxd +++ b/python/cudf/cudf/_lib/cpp/null_mask.pxd @@ -4,8 +4,8 @@ from libc.stdint cimport int32_t from rmm._lib.device_buffer cimport device_buffer -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column_view cimport column_view +cimport cudf._lib.cpp.types as libcudf_types ctypedef int32_t underlying_type_t_mask_state diff --git a/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd b/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd index 38682854892..2a27cd3c338 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd @@ -6,7 +6,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "nvtext/edit_distance.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] edit_distance( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd b/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd index 06147df38f2..52a91cba057 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd @@ -7,7 +7,6 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type - cdef extern from "nvtext/generate_ngrams.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] generate_ngrams( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd index d716df22546..d6145a8048d 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd @@ -7,7 +7,6 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type - cdef extern from "nvtext/ngrams_tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] ngrams_tokenize( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd index f012670317a..7d8ec891692 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd @@ -6,7 +6,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "nvtext/normalize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] normalize_spaces( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd b/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd index c4e5258a710..2de562e91b4 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd @@ -2,10 +2,10 @@ from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type cdef extern from "nvtext/replace.hpp" namespace "nvtext" nogil: diff --git a/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd b/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd index 5a92b45b6dd..b8b816c212e 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd @@ -7,7 +7,6 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type - cdef extern from "nvtext/stemmer.hpp" namespace "nvtext" nogil: ctypedef enum letter_type: CONSONANT 'nvtext::letter_type::CONSONANT' diff --git a/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd index cdb39e3c7fa..013ce9de8f4 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport uint16_t, uint32_t from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.string cimport string +from libc.stdint cimport uint16_t, uint32_t + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view diff --git a/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd index 8b80f50e381..2442c12de82 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd @@ -6,7 +6,6 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar - cdef extern from "nvtext/tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] tokenize( diff --git a/python/cudf/cudf/_lib/cpp/partitioning.pxd b/python/cudf/cudf/_lib/cpp/partitioning.pxd index 5c58dbcc4ac..8f89c09e52c 100644 --- a/python/cudf/cudf/_lib/cpp/partitioning.pxd +++ b/python/cudf/cudf/_lib/cpp/partitioning.pxd @@ -1,15 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libc.stdint cimport uint32_t -from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair +from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.column.column_view cimport column_view +cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/quantiles.pxd b/python/cudf/cudf/_lib/cpp/quantiles.pxd index 03fda16856c..f7817dfb97f 100644 --- a/python/cudf/cudf/_lib/cpp/quantiles.pxd +++ b/python/cudf/cudf/_lib/cpp/quantiles.pxd @@ -1,18 +1,19 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view + from cudf._lib.cpp.types cimport ( interpolation, null_order, - order, order_info, + order, sorted, ) diff --git a/python/cudf/cudf/_lib/cpp/reduce.pxd b/python/cudf/cudf/_lib/cpp/reduce.pxd index 53c8cd59468..dfe1ffd3669 100644 --- a/python/cudf/cudf/_lib/cpp/reduce.pxd +++ b/python/cudf/cudf/_lib/cpp/reduce.pxd @@ -1,14 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.utility cimport pair - -from cudf._lib.aggregation cimport aggregation -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.types cimport data_type +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.column.column cimport column from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.aggregation cimport aggregation +from libcpp.memory cimport unique_ptr +from libcpp.utility cimport pair cdef extern from "cudf/reduction.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/replace.pxd b/python/cudf/cudf/_lib/cpp/replace.pxd index c1ec89a6233..6fd844acb75 100644 --- a/python/cudf/cudf/_lib/cpp/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/replace.pxd @@ -2,12 +2,14 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +from cudf._lib.types import np_to_cudf_types, cudf_to_np_types -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.scalar.scalar cimport scalar - +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view +) cdef extern from "cudf/replace.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/reshape.pxd b/python/cudf/cudf/_lib/cpp/reshape.pxd index 5b9d40aa2ad..2985b9282b3 100644 --- a/python/cudf/cudf/_lib/cpp/reshape.pxd +++ b/python/cudf/cudf/_lib/cpp/reshape.pxd @@ -2,11 +2,10 @@ from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport size_type - cdef extern from "cudf/reshape.hpp" namespace "cudf" nogil: cdef unique_ptr[column] interleave_columns( diff --git a/python/cudf/cudf/_lib/cpp/rolling.pxd b/python/cudf/cudf/_lib/cpp/rolling.pxd index df2e833edc2..4ccc0f5ae9b 100644 --- a/python/cudf/cudf/_lib/cpp/rolling.pxd +++ b/python/cudf/cudf/_lib/cpp/rolling.pxd @@ -2,12 +2,12 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +from cudf._lib.types import np_to_cudf_types, cudf_to_np_types -from cudf._lib.cpp.aggregation cimport rolling_aggregation +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.aggregation cimport rolling_aggregation cdef extern from "cudf/rolling.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/round.pxd b/python/cudf/cudf/_lib/cpp/round.pxd index 66d76c35d72..78f18dcacce 100644 --- a/python/cudf/cudf/_lib/cpp/round.pxd +++ b/python/cudf/cudf/_lib/cpp/round.pxd @@ -6,7 +6,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "cudf/round.hpp" namespace "cudf" nogil: ctypedef enum rounding_method "cudf::rounding_method": diff --git a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd index 92f1cd602d6..fec1c6382e6 100644 --- a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd +++ b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd @@ -1,13 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport int32_t, int64_t +from libc.stdint cimport ( + int32_t, int64_t +) from libcpp cimport bool from libcpp.string cimport string from cudf._lib.cpp.types cimport data_type from cudf._lib.cpp.wrappers.decimals cimport scale_type - cdef extern from "cudf/scalar/scalar.hpp" namespace "cudf" nogil: cdef cppclass scalar: scalar() except + diff --git a/python/cudf/cudf/_lib/cpp/search.pxd b/python/cudf/cudf/_lib/cpp/search.pxd index 4df73881ea5..521b681dc24 100644 --- a/python/cudf/cudf/_lib/cpp/search.pxd +++ b/python/cudf/cudf/_lib/cpp/search.pxd @@ -1,12 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from libcpp.memory cimport unique_ptr -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view +cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/search.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/sorting.pxd b/python/cudf/cudf/_lib/cpp/sorting.pxd index d614ef64ee2..845457e423f 100644 --- a/python/cudf/cudf/_lib/cpp/sorting.pxd +++ b/python/cudf/cudf/_lib/cpp/sorting.pxd @@ -4,14 +4,13 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +from cudf._lib.types import np_to_cudf_types, cudf_to_np_types -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view - +cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: ctypedef enum rank_method: diff --git a/python/cudf/cudf/_lib/cpp/stream_compaction.pxd b/python/cudf/cudf/_lib/cpp/stream_compaction.pxd index 5b81d369ef5..c575f4eb17d 100644 --- a/python/cudf/cudf/_lib/cpp/stream_compaction.pxd +++ b/python/cudf/cudf/_lib/cpp/stream_compaction.pxd @@ -1,20 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from libcpp cimport bool -from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.cpp.types cimport ( + size_type, null_policy, nan_policy, null_equality +) from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport ( - nan_policy, - null_equality, - null_policy, - size_type, -) cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" \ diff --git a/python/cudf/cudf/_lib/cpp/strings/attributes.pxd b/python/cudf/cudf/_lib/cpp/strings/attributes.pxd index 31133b45b6d..abac963fe94 100644 --- a/python/cudf/cudf/_lib/cpp/strings/attributes.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/attributes.pxd @@ -5,7 +5,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "cudf/strings/attributes.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] count_characters( diff --git a/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd b/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd index 02a4469f495..eb24c6ab417 100644 --- a/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd @@ -4,7 +4,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "cudf/strings/capitalize.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] capitalize( const column_view & strings) except + diff --git a/python/cudf/cudf/_lib/cpp/strings/case.pxd b/python/cudf/cudf/_lib/cpp/strings/case.pxd index 01cd08c10ff..7c38657a43e 100644 --- a/python/cudf/cudf/_lib/cpp/strings/case.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/case.pxd @@ -4,7 +4,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "cudf/strings/case.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] to_lower( const column_view & strings) except + diff --git a/python/cudf/cudf/_lib/cpp/strings/char_types.pxd b/python/cudf/cudf/_lib/cpp/strings/char_types.pxd index ae921c6ead9..934269c6f25 100644 --- a/python/cudf/cudf/_lib/cpp/strings/char_types.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/char_types.pxd @@ -1,12 +1,10 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr - -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport string_scalar - cdef extern from "cudf/strings/char_types/char_types.hpp" \ namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/combine.pxd b/python/cudf/cudf/_lib/cpp/strings/combine.pxd index 0a7d00b6e34..250c6441882 100644 --- a/python/cudf/cudf/_lib/cpp/strings/combine.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/combine.pxd @@ -1,12 +1,10 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table_view cimport table_view - +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.column.column cimport column cdef extern from "cudf/strings/combine.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/contains.pxd b/python/cudf/cudf/_lib/cpp/strings/contains.pxd index bde0b4fdfb7..e6fb9127814 100644 --- a/python/cudf/cudf/_lib/cpp/strings/contains.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/contains.pxd @@ -1,10 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view cdef extern from "cudf/strings/contains.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd index 96cb43973f1..ca494696ae8 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd @@ -1,10 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_booleans.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd index 5a9228608e5..4bd57a16d64 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd @@ -1,12 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string cdef extern from "cudf/strings/convert/convert_datetime.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd index 8c54fd52aa2..98faebfcaa2 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd @@ -1,12 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string cdef extern from "cudf/strings/convert/convert_durations.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd index a993c5b17b8..77d72acb670 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd @@ -1,11 +1,10 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type +from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_fixed_point.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd index 6388f43077d..55a84b60efd 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd @@ -1,11 +1,10 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type +from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_floats.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd index 6c962ec2988..6e45d4ba869 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd @@ -1,11 +1,10 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type +from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_integers.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd index d6e881caea4..37eea254605 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd @@ -1,10 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_ipv4.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd index 5d9991dd610..a7bcb8d8078 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd @@ -1,10 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_urls.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/extract.pxd b/python/cudf/cudf/_lib/cpp/strings/extract.pxd index 518b1c9ed60..acec41bddc8 100644 --- a/python/cudf/cudf/_lib/cpp/strings/extract.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/extract.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table +from libcpp.string cimport string cdef extern from "cudf/strings/extract.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/find.pxd b/python/cudf/cudf/_lib/cpp/strings/find.pxd index 953d5c30b2a..05451fe0599 100644 --- a/python/cudf/cudf/_lib/cpp/strings/find.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/find.pxd @@ -1,14 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type - cdef extern from "cudf/strings/find.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] contains( diff --git a/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd b/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd index 27b19728f60..286fe72d058 100644 --- a/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd @@ -1,10 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "cudf/strings/find_multiple.hpp" namespace "cudf::strings" \ nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/findall.pxd b/python/cudf/cudf/_lib/cpp/strings/findall.pxd index 189d0770b81..818135b6cd0 100644 --- a/python/cudf/cudf/_lib/cpp/strings/findall.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/findall.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table +from libcpp.string cimport string cdef extern from "cudf/strings/findall.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/json.pxd b/python/cudf/cudf/_lib/cpp/strings/json.pxd index 972e3c99d59..c0e215f2085 100644 --- a/python/cudf/cudf/_lib/cpp/strings/json.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/json.pxd @@ -1,11 +1,12 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from libcpp.memory cimport unique_ptr from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport scalar, string_scalar +from cudf._lib.cpp.scalar.scalar cimport scalar cdef extern from "cudf/strings/json.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/padding.pxd b/python/cudf/cudf/_lib/cpp/strings/padding.pxd index 2077e687be3..af1f235f7ea 100644 --- a/python/cudf/cudf/_lib/cpp/strings/padding.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/padding.pxd @@ -1,13 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libc.stdint cimport int32_t -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type - +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from libcpp.string cimport string +from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.column.column cimport column cdef extern from "cudf/strings/padding.hpp" namespace "cudf::strings" nogil: ctypedef enum pad_side: diff --git a/python/cudf/cudf/_lib/cpp/strings/replace.pxd b/python/cudf/cudf/_lib/cpp/strings/replace.pxd index 2a9c6913bb3..312c8fb1753 100644 --- a/python/cudf/cudf/_lib/cpp/strings/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/replace.pxd @@ -1,13 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport int32_t +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type from libcpp.memory cimport unique_ptr from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type +from libcpp.string cimport string +from libc.stdint cimport int32_t cdef extern from "cudf/strings/replace.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd b/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd index 33ccbc34a8e..8d19c67acd0 100644 --- a/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd @@ -1,15 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type from libcpp.memory cimport unique_ptr from libcpp.string cimport string -from libcpp.vector cimport vector - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.types cimport size_type - +from libcpp.string cimport string +from libcpp.vector cimport vector cdef extern from "cudf/strings/replace_re.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd b/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd index fb83512e9f0..cdfa8b78e03 100644 --- a/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd @@ -1,14 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string - -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from libcpp.string cimport string +from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table - cdef extern from "cudf/strings/split/partition.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/split/split.pxd b/python/cudf/cudf/_lib/cpp/strings/split/split.pxd index 4a90aa233f0..db9bf91336a 100644 --- a/python/cudf/cudf/_lib/cpp/strings/split/split.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/split/split.pxd @@ -1,14 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string - -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.scalar.scalar cimport string_scalar +from libcpp.string cimport string +from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.types cimport size_type - cdef extern from "cudf/strings/split/split.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/strip.pxd b/python/cudf/cudf/_lib/cpp/strings/strip.pxd index 82a84fd2d14..a03917dc44b 100644 --- a/python/cudf/cudf/_lib/cpp/strings/strip.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/strip.pxd @@ -1,11 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar - +from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.column.column cimport column cdef extern from "cudf/strings/strip.hpp" namespace "cudf::strings" nogil: ctypedef enum strip_type: diff --git a/python/cudf/cudf/_lib/cpp/strings/substring.pxd b/python/cudf/cudf/_lib/cpp/strings/substring.pxd index ec69c5acc03..0d558ad9670 100644 --- a/python/cudf/cudf/_lib/cpp/strings/substring.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/substring.pxd @@ -1,12 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr - -from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport numeric_scalar -from cudf._lib.cpp.types cimport size_type - cdef extern from "cudf/strings/substring.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] slice_strings( diff --git a/python/cudf/cudf/_lib/cpp/strings/translate.pxd b/python/cudf/cudf/_lib/cpp/strings/translate.pxd index 3239ba314e4..3f40543a49a 100644 --- a/python/cudf/cudf/_lib/cpp/strings/translate.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/translate.pxd @@ -2,14 +2,13 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.pair cimport pair -from libcpp.vector cimport vector from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar +from libcpp.vector cimport vector +from libcpp.pair cimport pair from cudf._lib.cpp.types cimport char_utf8 - +from cudf._lib.cpp.scalar.scalar cimport string_scalar cdef extern from "cudf/strings/translate.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/wrap.pxd b/python/cudf/cudf/_lib/cpp/strings/wrap.pxd index 62c791799ad..f5fa115b31c 100644 --- a/python/cudf/cudf/_lib/cpp/strings/wrap.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/wrap.pxd @@ -1,11 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr - -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type - +from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.column.column cimport column cdef extern from "cudf/strings/wrap.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/table/table.pxd b/python/cudf/cudf/_lib/cpp/table/table.pxd index 13e1ceb6430..ffa8dd1fc98 100644 --- a/python/cudf/cudf/_lib/cpp/table/table.pxd +++ b/python/cudf/cudf/_lib/cpp/table/table.pxd @@ -1,12 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view from cudf._lib.cpp.types cimport size_type - +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.table.table_view cimport ( + table_view, + mutable_table_view +) cdef extern from "cudf/table/table.hpp" namespace "cudf" nogil: cdef cppclass table: diff --git a/python/cudf/cudf/_lib/cpp/table/table_view.pxd b/python/cudf/cudf/_lib/cpp/table/table_view.pxd index 728b6d2be4b..7bbfa69836c 100644 --- a/python/cudf/cudf/_lib/cpp/table/table_view.pxd +++ b/python/cudf/cudf/_lib/cpp/table/table_view.pxd @@ -2,9 +2,11 @@ from libcpp.vector cimport vector -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.types cimport size_type - +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view +) cdef extern from "cudf/table/table_view.hpp" namespace "cudf" nogil: cdef cppclass table_view: diff --git a/python/cudf/cudf/_lib/cpp/transform.pxd b/python/cudf/cudf/_lib/cpp/transform.pxd index 484e3997f34..5e37336cb94 100644 --- a/python/cudf/cudf/_lib/cpp/transform.pxd +++ b/python/cudf/cudf/_lib/cpp/transform.pxd @@ -1,17 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr -from libcpp.pair cimport pair from libcpp.string cimport string +from libcpp.pair cimport pair +from libcpp.memory cimport unique_ptr from rmm._lib.device_buffer cimport device_buffer +from cudf._lib.cpp.types cimport ( + bitmask_type, + data_type, + size_type, +) from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type cdef extern from "cudf/transform.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/unary.pxd b/python/cudf/cudf/_lib/cpp/unary.pxd index 83a5701eaf0..b5682ee6694 100644 --- a/python/cudf/cudf/_lib/cpp/unary.pxd +++ b/python/cudf/cudf/_lib/cpp/unary.pxd @@ -2,10 +2,15 @@ from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr - -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport data_type +from cudf._lib.cpp.column.column_view cimport ( + column_view +) +from cudf._lib.cpp.column.column cimport ( + column +) +from cudf._lib.cpp.types cimport ( + data_type +) ctypedef int32_t underlying_type_t_unary_op diff --git a/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd b/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd index 7e591e96373..cbbe3710347 100644 --- a/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd +++ b/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd @@ -2,7 +2,6 @@ from libcpp.vector cimport vector - cdef extern from "cudf/utilities/span.hpp" namespace "cudf" nogil: cdef cppclass host_span[T]: host_span() except + diff --git a/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd b/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd index 74efdb08bea..9de23fb2595 100644 --- a/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd +++ b/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd @@ -1,6 +1,5 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from libc.stdint cimport int32_t, int64_t - +from libc.stdint cimport int64_t, int32_t cdef extern from "cudf/fixed_point/fixed_point.hpp" namespace "numeric" nogil: # cython type stub to help resolve to numeric::decimal64 diff --git a/python/cudf/cudf/_lib/csv.pyx b/python/cudf/cudf/_lib/csv.pyx index 5cd75b15210..f3cde6d449a 100644 --- a/python/cudf/cudf/_lib/csv.pyx +++ b/python/cudf/cudf/_lib/csv.pyx @@ -3,31 +3,33 @@ from libcpp cimport bool from libcpp.memory cimport make_unique, unique_ptr from libcpp.string cimport string -from libcpp.utility cimport move from libcpp.vector cimport vector +from libcpp.utility cimport move -import numpy as np import pandas as pd - import cudf +import numpy as np from cudf._lib.cpp.types cimport size_type import collections.abc as abc import errno +from io import BytesIO, StringIO import os + from enum import IntEnum -from io import BytesIO, StringIO -from libc.stdint cimport int32_t from libcpp cimport bool +from libc.stdint cimport int32_t + from cudf._lib.cpp.io.csv cimport ( - csv_reader_options, - csv_writer_options, read_csv as cpp_read_csv, + csv_reader_options, write_csv as cpp_write_csv, + csv_writer_options, ) + from cudf._lib.cpp.io.types cimport ( compression_type, data_sink, @@ -35,11 +37,11 @@ from cudf._lib.cpp.io.types cimport ( sink_info, source_info, table_metadata, - table_with_metadata, + table_with_metadata ) -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.io.utils cimport make_sink_info, make_source_info +from cudf._lib.io.utils cimport make_source_info, make_sink_info from cudf._lib.table cimport Table, make_table_view +from cudf._lib.cpp.table.table_view cimport table_view ctypedef int32_t underlying_type_t_compression diff --git a/python/cudf/cudf/_lib/datetime.pyx b/python/cudf/cudf/_lib/datetime.pyx index d048325c283..3e40cb62f9c 100644 --- a/python/cudf/cudf/_lib/datetime.pyx +++ b/python/cudf/cudf/_lib/datetime.pyx @@ -1,11 +1,13 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -cimport cudf._lib.cpp.datetime as libcudf_datetime -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.column cimport Column + +cimport cudf._lib.cpp.datetime as libcudf_datetime + def add_months(Column col, Column months): # months must be int16 dtype diff --git a/python/cudf/cudf/_lib/filling.pyx b/python/cudf/cudf/_lib/filling.pyx index d9fdf72415c..a3941c9479b 100644 --- a/python/cudf/cudf/_lib/filling.pyx +++ b/python/cudf/cudf/_lib/filling.pyx @@ -6,10 +6,13 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -cimport cudf._lib.cpp.filling as cpp_filling +from cudf._lib.column cimport Column from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view +) from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view @@ -17,6 +20,8 @@ from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table +cimport cudf._lib.cpp.filling as cpp_filling + def fill_in_place(Column destination, int begin, int end, DeviceScalar value): cdef mutable_column_view c_destination = destination.mutable_view() diff --git a/python/cudf/cudf/_lib/gpuarrow.pyx b/python/cudf/cudf/_lib/gpuarrow.pyx index 8cb42e54e24..6513cd59424 100644 --- a/python/cudf/cudf/_lib/gpuarrow.pyx +++ b/python/cudf/cudf/_lib/gpuarrow.pyx @@ -4,26 +4,22 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from pyarrow._cuda cimport CudaBuffer from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader - from cudf._lib.cpp.gpuarrow cimport CCudaMessageReader - from numba.cuda.cudadrv.devicearray import DeviceNDArray - from pyarrow.includes.common cimport GetResultValue from pyarrow.includes.libarrow cimport ( - CBufferReader, - CIpcReadOptions, CMessage, + CBufferReader, CMessageReader, - CRecordBatchStreamReader, + CIpcReadOptions, + CRecordBatchStreamReader ) from pyarrow.lib cimport ( + _CRecordBatchReader, Buffer, Schema, - _CRecordBatchReader, - pyarrow_wrap_schema, + pyarrow_wrap_schema ) - import pyarrow as pa diff --git a/python/cudf/cudf/_lib/groupby.pyx b/python/cudf/cudf/_lib/groupby.pyx index 4b1530921a5..3d1a6493028 100644 --- a/python/cudf/cudf/_lib/groupby.pyx +++ b/python/cudf/cudf/_lib/groupby.pyx @@ -1,33 +1,33 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from collections import defaultdict - -import numpy as np from pandas.core.groupby.groupby import DataError - -import rmm - from cudf.utils.dtypes import ( is_categorical_dtype, - is_decimal_dtype, - is_interval_dtype, - is_list_dtype, is_string_dtype, + is_list_dtype, + is_interval_dtype, is_struct_dtype, + is_decimal_dtype, ) -from libcpp cimport bool -from libcpp.memory cimport unique_ptr +import numpy as np +import rmm + from libcpp.pair cimport pair +from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from libcpp.vector cimport vector +from libcpp cimport bool -cimport cudf._lib.cpp.groupby as libcudf_groupby -cimport cudf._lib.cpp.types as libcudf_types -from cudf._lib.aggregation cimport Aggregation, make_aggregation from cudf._lib.column cimport Column -from cudf._lib.cpp.table.table cimport table, table_view from cudf._lib.table cimport Table +from cudf._lib.aggregation cimport Aggregation, make_aggregation + +from cudf._lib.cpp.table.table cimport table, table_view +cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.groupby as libcudf_groupby + # The sets below define the possible aggregations that can be performed on # different dtypes. These strings must be elements of the AggregationKind enum. diff --git a/python/cudf/cudf/_lib/hash.pyx b/python/cudf/cudf/_lib/hash.pyx index 198e7a748c9..196c88a8a20 100644 --- a/python/cudf/cudf/_lib/hash.pyx +++ b/python/cudf/cudf/_lib/hash.pyx @@ -2,19 +2,24 @@ from libc.stdint cimport uint32_t from libcpp cimport bool -from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair +from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from libcpp.vector cimport vector -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column +from cudf._lib.table cimport Table + from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.hash cimport hash as cpp_hash -from cudf._lib.cpp.partitioning cimport hash_partition as cpp_hash_partition from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.table cimport Table +from cudf._lib.cpp.hash cimport ( + hash as cpp_hash +) +from cudf._lib.cpp.partitioning cimport ( + hash_partition as cpp_hash_partition, +) +cimport cudf._lib.cpp.types as libcudf_types def hash_partition(Table source_table, object columns_to_hash, diff --git a/python/cudf/cudf/_lib/interop.pyx b/python/cudf/cudf/_lib/interop.pyx index 08ea58e4587..04971b58cd2 100644 --- a/python/cudf/cudf/_lib/interop.pyx +++ b/python/cudf/cudf/_lib/interop.pyx @@ -2,25 +2,27 @@ import cudf -from cpython cimport pycapsule -from libcpp cimport bool -from libcpp.memory cimport shared_ptr, unique_ptr +from cudf._lib.table cimport Table +from libcpp.vector cimport vector from libcpp.string cimport string +from libcpp cimport bool + +from libcpp.memory cimport unique_ptr, shared_ptr from libcpp.utility cimport move -from libcpp.vector cimport vector -from pyarrow.lib cimport CTable, pyarrow_unwrap_table, pyarrow_wrap_table +from cpython cimport pycapsule + +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from pyarrow.lib cimport CTable, pyarrow_wrap_table, pyarrow_unwrap_table from cudf._lib.cpp.interop cimport ( - DLManagedTensor, - column_metadata, + to_arrow as cpp_to_arrow, from_arrow as cpp_from_arrow, from_dlpack as cpp_from_dlpack, - to_arrow as cpp_to_arrow, to_dlpack as cpp_to_dlpack, + column_metadata, + DLManagedTensor ) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.table cimport Table def from_dlpack(dlpack_capsule): diff --git a/python/cudf/cudf/_lib/io/datasource.pxd b/python/cudf/cudf/_lib/io/datasource.pxd index 705a3600f68..528a6c52edd 100644 --- a/python/cudf/cudf/_lib/io/datasource.pxd +++ b/python/cudf/cudf/_lib/io/datasource.pxd @@ -1,10 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.io.types cimport datasource - cdef class Datasource: cdef datasource* get_datasource(self) nogil except * diff --git a/python/cudf/cudf/_lib/io/datasource.pyx b/python/cudf/cudf/_lib/io/datasource.pyx index ddfd9a3540a..b706847647b 100644 --- a/python/cudf/cudf/_lib/io/datasource.pyx +++ b/python/cudf/cudf/_lib/io/datasource.pyx @@ -1,10 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr - from cudf._lib.cpp.io.types cimport datasource - cdef class Datasource: cdef datasource* get_datasource(self) nogil except *: with gil: diff --git a/python/cudf/cudf/_lib/io/utils.pxd b/python/cudf/cudf/_lib/io/utils.pxd index 233e4f7c635..0a793b2d018 100644 --- a/python/cudf/cudf/_lib/io/utils.pxd +++ b/python/cudf/cudf/_lib/io/utils.pxd @@ -2,8 +2,7 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.io.types cimport data_sink, sink_info, source_info - +from cudf._lib.cpp.io.types cimport source_info, sink_info, data_sink cdef source_info make_source_info(list src) except* cdef sink_info make_sink_info(src, unique_ptr[data_sink] & data) except* diff --git a/python/cudf/cudf/_lib/io/utils.pyx b/python/cudf/cudf/_lib/io/utils.pyx index 846086107e1..6598a7af626 100644 --- a/python/cudf/cudf/_lib/io/utils.pyx +++ b/python/cudf/cudf/_lib/io/utils.pyx @@ -4,29 +4,20 @@ from cpython.buffer cimport PyBUF_READ from cpython.memoryview cimport PyMemoryView_FromMemory from libcpp.map cimport map from libcpp.memory cimport unique_ptr -from libcpp.pair cimport pair -from libcpp.string cimport string from libcpp.utility cimport move from libcpp.vector cimport vector - -from cudf._lib.cpp.io.types cimport ( - data_sink, - datasource, - host_buffer, - io_type, - sink_info, - source_info, -) +from libcpp.pair cimport pair +from libcpp.string cimport string +from cudf._lib.cpp.io.types cimport source_info, io_type, host_buffer +from cudf._lib.cpp.io.types cimport sink_info, data_sink, datasource from cudf._lib.io.datasource cimport Datasource import codecs import errno import io import os - import cudf - # Converts the Python source input to libcudf++ IO source_info # with the appropriate type and source values cdef source_info make_source_info(list src) except*: diff --git a/python/cudf/cudf/_lib/join.pyx b/python/cudf/cudf/_lib/join.pyx index 186f8d32aeb..193c2ca9d67 100644 --- a/python/cudf/cudf/_lib/join.pyx +++ b/python/cudf/cudf/_lib/join.pyx @@ -1,22 +1,24 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from itertools import chain - import cudf -from libcpp cimport bool -from libcpp.memory cimport make_unique, unique_ptr -from libcpp.pair cimport pair +from itertools import chain + +from libcpp.memory cimport unique_ptr, make_unique from libcpp.utility cimport move from libcpp.vector cimport vector +from libcpp.pair cimport pair +from libcpp cimport bool -cimport cudf._lib.cpp.join as cpp_join from cudf._lib.column cimport Column +from cudf._lib.table cimport Table, columns_from_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.types cimport size_type, data_type, type_id from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport data_type, size_type, type_id -from cudf._lib.table cimport Table, columns_from_ptr +cimport cudf._lib.cpp.join as cpp_join + # The functions below return the *gathermaps* that represent # the join result when joining on the keys `lhs` and `rhs`. diff --git a/python/cudf/cudf/_lib/json.pyx b/python/cudf/cudf/_lib/json.pyx index f46303d8c78..7a6ec47ab66 100644 --- a/python/cudf/cudf/_lib/json.pyx +++ b/python/cudf/cudf/_lib/json.pyx @@ -3,25 +3,24 @@ # cython: boundscheck = False +import cudf import collections.abc as abc import io import os -import cudf - from libcpp cimport bool from libcpp.string cimport string -from libcpp.utility cimport move from libcpp.vector cimport vector +from libcpp.utility cimport move -cimport cudf._lib.cpp.io.types as cudf_io_types from cudf._lib.cpp.io.json cimport ( - json_reader_options, read_json as libcudf_read_json, + json_reader_options ) from cudf._lib.cpp.types cimport size_type from cudf._lib.io.utils cimport make_source_info from cudf._lib.table cimport Table +cimport cudf._lib.cpp.io.types as cudf_io_types cpdef read_json(object filepath_or_buffer, diff --git a/python/cudf/cudf/_lib/labeling.pyx b/python/cudf/cudf/_lib/labeling.pyx index 088942064a8..1b553024347 100644 --- a/python/cudf/cudf/_lib/labeling.pyx +++ b/python/cudf/cudf/_lib/labeling.pyx @@ -1,8 +1,7 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from enum import IntEnum - import numpy as np +from enum import IntEnum from libc.stdint cimport uint32_t from libcpp cimport bool as cbool @@ -10,12 +9,12 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from cudf._lib.column cimport Column - from cudf._lib.replace import replace_nulls +from cudf._lib.cpp.labeling cimport inclusive +from cudf._lib.cpp.labeling cimport label_bins as cpp_label_bins from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.labeling cimport inclusive, label_bins as cpp_label_bins # Note that the parameter input shadows a Python built-in in the local scope, diff --git a/python/cudf/cudf/_lib/lists.pyx b/python/cudf/cudf/_lib/lists.pyx index 9f4be2e389a..9bc0550bdf0 100644 --- a/python/cudf/cudf/_lib/lists.pyx +++ b/python/cudf/cudf/_lib/lists.pyx @@ -1,41 +1,48 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport make_shared, shared_ptr, unique_ptr +from libcpp.memory cimport unique_ptr, shared_ptr, make_shared from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.count_elements cimport ( - count_elements as cpp_count_elements, + count_elements as cpp_count_elements +) +from cudf._lib.cpp.lists.explode cimport ( + explode_outer as cpp_explode_outer ) from cudf._lib.cpp.lists.drop_list_duplicates cimport ( - drop_list_duplicates as cpp_drop_list_duplicates, + drop_list_duplicates as cpp_drop_list_duplicates +) +from cudf._lib.cpp.lists.sorting cimport ( + sort_lists as cpp_sort_lists ) -from cudf._lib.cpp.lists.explode cimport explode_outer as cpp_explode_outer from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.lists.sorting cimport sort_lists as cpp_sort_lists +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.column.column cimport column + +from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.scalar.scalar cimport scalar + from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport ( - nan_equality, + size_type, null_equality, - null_order, order, - size_type, + null_order, + nan_equality ) -from cudf._lib.scalar cimport DeviceScalar + +from cudf._lib.column cimport Column from cudf._lib.table cimport Table + from cudf._lib.types cimport ( - underlying_type_t_null_order, - underlying_type_t_order, + underlying_type_t_null_order, underlying_type_t_order ) - from cudf.core.dtypes import ListDtype from cudf._lib.cpp.lists.contains cimport contains + from cudf._lib.cpp.lists.extract cimport extract_list_element diff --git a/python/cudf/cudf/_lib/merge.pyx b/python/cudf/cudf/_lib/merge.pyx index cc2d405c207..81d5807906a 100644 --- a/python/cudf/cudf/_lib/merge.pyx +++ b/python/cudf/cudf/_lib/merge.pyx @@ -1,16 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp cimport bool +from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp.vector cimport vector +from libcpp cimport bool -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column -from cudf._lib.cpp.merge cimport merge as cpp_merge +from cudf._lib.table cimport Table + from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.table cimport Table +from cudf._lib.cpp.merge cimport merge as cpp_merge +cimport cudf._lib.cpp.types as libcudf_types def merge_sorted( diff --git a/python/cudf/cudf/_lib/null_mask.pyx b/python/cudf/cudf/_lib/null_mask.pyx index 3eaa6b5e588..8c209cd86bd 100644 --- a/python/cudf/cudf/_lib/null_mask.pyx +++ b/python/cudf/cudf/_lib/null_mask.pyx @@ -2,23 +2,22 @@ from enum import Enum -from libcpp.memory cimport make_unique, unique_ptr +from libcpp.memory cimport unique_ptr, make_unique from libcpp.utility cimport move -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer +from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer from cudf._lib.column cimport Column - import cudf._lib as libcudfxx +from cudf._lib.cpp.types cimport mask_state, size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.null_mask cimport ( - bitmask_allocation_size_bytes as cpp_bitmask_allocation_size_bytes, copy_bitmask as cpp_copy_bitmask, create_null_mask as cpp_create_null_mask, - underlying_type_t_mask_state, + bitmask_allocation_size_bytes as cpp_bitmask_allocation_size_bytes, + underlying_type_t_mask_state ) -from cudf._lib.cpp.types cimport mask_state, size_type from cudf.core.buffer import Buffer diff --git a/python/cudf/cudf/_lib/nvtext/edit_distance.pyx b/python/cudf/cudf/_lib/nvtext/edit_distance.pyx index a51d77b9b37..f9fae570469 100644 --- a/python/cudf/cudf/_lib/nvtext/edit_distance.pyx +++ b/python/cudf/cudf/_lib/nvtext/edit_distance.pyx @@ -4,12 +4,12 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.edit_distance cimport ( - edit_distance as cpp_edit_distance, + edit_distance as cpp_edit_distance ) +from cudf._lib.column cimport Column def edit_distance(Column strings, Column targets): diff --git a/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx b/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx index 5fcec570dcb..48d67110621 100644 --- a/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx +++ b/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx @@ -3,15 +3,15 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.generate_ngrams cimport ( - generate_character_ngrams as cpp_generate_character_ngrams, generate_ngrams as cpp_generate_ngrams, + generate_character_ngrams as cpp_generate_character_ngrams ) -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx b/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx index 1e9e0e39ff1..cf0a4a0f55a 100644 --- a/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.ngrams_tokenize cimport ( - ngrams_tokenize as cpp_ngrams_tokenize, + ngrams_tokenize as cpp_ngrams_tokenize ) -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/normalize.pyx b/python/cudf/cudf/_lib/nvtext/normalize.pyx index e475f0cd996..88f0f0a957a 100644 --- a/python/cudf/cudf/_lib/nvtext/normalize.pyx +++ b/python/cudf/cudf/_lib/nvtext/normalize.pyx @@ -4,13 +4,13 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.normalize cimport ( normalize_characters as cpp_normalize_characters, - normalize_spaces as cpp_normalize_spaces, + normalize_spaces as cpp_normalize_spaces ) +from cudf._lib.column cimport Column def normalize_spaces(Column strings): diff --git a/python/cudf/cudf/_lib/nvtext/replace.pyx b/python/cudf/cudf/_lib/nvtext/replace.pyx index b4f37ac3ec7..cb552161b52 100644 --- a/python/cudf/cudf/_lib/nvtext/replace.pyx +++ b/python/cudf/cudf/_lib/nvtext/replace.pyx @@ -3,15 +3,15 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.replace cimport ( - filter_tokens as cpp_filter_tokens, replace_tokens as cpp_replace_tokens, + filter_tokens as cpp_filter_tokens, ) -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/stemmer.pyx b/python/cudf/cudf/_lib/nvtext/stemmer.pyx index 89d4b07b7ad..1aca32a5667 100644 --- a/python/cudf/cudf/_lib/nvtext/stemmer.pyx +++ b/python/cudf/cudf/_lib/nvtext/stemmer.pyx @@ -2,19 +2,19 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - from enum import IntEnum -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column + from cudf._lib.cpp.nvtext.stemmer cimport ( - is_letter as cpp_is_letter, - letter_type as letter_type, porter_stemmer_measure as cpp_porter_stemmer_measure, - underlying_type_t_letter_type, + is_letter as cpp_is_letter, + letter_type as letter_type ) -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.nvtext.stemmer cimport underlying_type_t_letter_type class LetterType(IntEnum): diff --git a/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx b/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx index 49f24436b88..3cf3cbe1ef2 100644 --- a/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx @@ -1,21 +1,22 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport uint32_t, uintptr_t from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move +from libcpp.string cimport string +from libc.stdint cimport uint32_t +from libc.stdint cimport uintptr_t -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.nvtext.subword_tokenize cimport ( +from cudf._lib.cpp.nvtext.subword_tokenize cimport( + subword_tokenize as cpp_subword_tokenize, hashed_vocabulary as cpp_hashed_vocabulary, load_vocabulary_file as cpp_load_vocabulary_file, - move as tr_move, - subword_tokenize as cpp_subword_tokenize, tokenizer_result as cpp_tokenizer_result, + move as tr_move, ) +from cudf._lib.column cimport Column cdef class Hashed_Vocabulary: diff --git a/python/cudf/cudf/_lib/nvtext/tokenize.pyx b/python/cudf/cudf/_lib/nvtext/tokenize.pyx index 5fc852c2ab0..c7f5c2a12c4 100644 --- a/python/cudf/cudf/_lib/nvtext/tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/tokenize.pyx @@ -3,17 +3,17 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.tokenize cimport ( - character_tokenize as cpp_character_tokenize, - count_tokens as cpp_count_tokens, - detokenize as cpp_detokenize, tokenize as cpp_tokenize, + detokenize as cpp_detokenize, + count_tokens as cpp_count_tokens, + character_tokenize as cpp_character_tokenize ) -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/orc.pyx b/python/cudf/cudf/_lib/orc.pyx index ea4b4ae7ca3..69d67c5b02d 100644 --- a/python/cudf/cudf/_lib/orc.pyx +++ b/python/cudf/cudf/_lib/orc.pyx @@ -3,23 +3,23 @@ import cudf from libcpp cimport bool, int -from libcpp.memory cimport make_unique, unique_ptr +from libcpp.memory cimport unique_ptr, make_unique from libcpp.string cimport string -from libcpp.utility cimport move from libcpp.vector cimport vector - +from libcpp.utility cimport move from cudf._lib.cpp.column.column cimport column + +from cudf._lib.cpp.io.orc_metadata cimport ( + raw_orc_statistics, + read_raw_orc_statistics as libcudf_read_raw_orc_statistics +) from cudf._lib.cpp.io.orc cimport ( - chunked_orc_writer_options, - orc_chunked_writer, orc_reader_options, - orc_writer_options, read_orc as libcudf_read_orc, + orc_writer_options, write_orc as libcudf_write_orc, -) -from cudf._lib.cpp.io.orc_metadata cimport ( - raw_orc_statistics, - read_raw_orc_statistics as libcudf_read_raw_orc_statistics, + chunked_orc_writer_options, + orc_chunked_writer ) from cudf._lib.cpp.io.types cimport ( compression_type, @@ -27,23 +27,27 @@ from cudf._lib.cpp.io.types cimport ( sink_info, source_info, table_metadata, - table_metadata_with_nullability, table_with_metadata, + table_metadata_with_nullability ) + from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport data_type, size_type, type_id -from cudf._lib.io.utils cimport make_sink_info, make_source_info -from cudf._lib.table cimport Table +from cudf._lib.cpp.types cimport ( + data_type, type_id, size_type +) +from cudf._lib.io.utils cimport make_source_info, make_sink_info +from cudf._lib.table cimport Table from cudf._lib.types import np_to_cudf_types - from cudf._lib.types cimport underlying_type_t_type_id - import numpy as np from cudf._lib.utils cimport get_column_names -from cudf._lib.utils import _index_level_name, generate_pandas_metadata +from cudf._lib.utils import ( + _index_level_name, + generate_pandas_metadata, +) cpdef read_raw_orc_statistics(filepath_or_buffer): diff --git a/python/cudf/cudf/_lib/parquet.pyx b/python/cudf/cudf/_lib/parquet.pyx index 088b475139b..4ea2adec23a 100644 --- a/python/cudf/cudf/_lib/parquet.pyx +++ b/python/cudf/cudf/_lib/parquet.pyx @@ -2,64 +2,70 @@ # cython: boundscheck = False +import cudf import errno import os -from collections import OrderedDict - import pyarrow as pa - -import cudf +from collections import OrderedDict try: import ujson as json except ImportError: import json -import numpy as np from cython.operator import dereference +import numpy as np from cudf.utils.dtypes import ( + np_to_pa_dtype, is_categorical_dtype, - is_decimal_dtype, is_list_dtype, is_struct_dtype, - np_to_pa_dtype, + is_decimal_dtype, ) from cudf._lib.utils cimport get_column_names +from cudf._lib.utils import ( + _index_level_name, + generate_pandas_metadata, +) -from cudf._lib.utils import _index_level_name, generate_pandas_metadata - -from libc.stdint cimport uint8_t from libc.stdlib cimport free -from libcpp cimport bool -from libcpp.map cimport map -from libcpp.memory cimport make_unique, unique_ptr +from libc.stdint cimport uint8_t +from libcpp.memory cimport unique_ptr, make_unique from libcpp.string cimport string -from libcpp.utility cimport move +from libcpp.map cimport map from libcpp.vector cimport vector +from libcpp.utility cimport move +from libcpp cimport bool -cimport cudf._lib.cpp.io.types as cudf_io_types -cimport cudf._lib.cpp.types as cudf_types -from cudf._lib.column cimport Column + +from cudf._lib.cpp.types cimport data_type, size_type +from cudf._lib.table cimport Table +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport ( + table_view +) from cudf._lib.cpp.io.parquet cimport ( - chunked_parquet_writer_options, - chunked_parquet_writer_options_builder, - column_in_metadata, - merge_rowgroup_metadata as parquet_merge_metadata, - parquet_chunked_writer as cpp_parquet_chunked_writer, - parquet_reader_options, - parquet_writer_options, read_parquet as parquet_reader, + parquet_reader_options, table_input_metadata, + column_in_metadata, + parquet_writer_options, write_parquet as parquet_writer, + parquet_chunked_writer as cpp_parquet_chunked_writer, + chunked_parquet_writer_options, + chunked_parquet_writer_options_builder, + merge_rowgroup_metadata as parquet_merge_metadata, +) +from cudf._lib.column cimport Column +from cudf._lib.io.utils cimport ( + make_source_info, + make_sink_info ) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport data_type, size_type -from cudf._lib.io.utils cimport make_sink_info, make_source_info -from cudf._lib.table cimport Table +cimport cudf._lib.cpp.types as cudf_types +cimport cudf._lib.cpp.io.types as cudf_io_types cdef class BufferArrayFromVector: cdef Py_ssize_t length diff --git a/python/cudf/cudf/_lib/partitioning.pyx b/python/cudf/cudf/_lib/partitioning.pyx index 865138bec84..b33ccb24039 100644 --- a/python/cudf/cudf/_lib/partitioning.pyx +++ b/python/cudf/cudf/_lib/partitioning.pyx @@ -1,20 +1,22 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair -from libcpp.utility cimport move +from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from libcpp.utility cimport move from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.partitioning cimport partition as cpp_partition +from cudf._lib.table cimport Table + from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.table cimport Table +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.partitioning cimport ( + partition as cpp_partition, +) from cudf._lib.stream_compaction import distinct_count as cpp_distinct_count - cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/quantiles.pyx b/python/cudf/cudf/_lib/quantiles.pyx index 45a4ff7c92c..0c1338103be 100644 --- a/python/cudf/cudf/_lib/quantiles.pyx +++ b/python/cudf/cudf/_lib/quantiles.pyx @@ -1,36 +1,34 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool +from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp.vector cimport vector from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table from cudf._lib.types cimport ( - underlying_type_t_interpolation, - underlying_type_t_null_order, underlying_type_t_order, + underlying_type_t_null_order, underlying_type_t_sorted, + underlying_type_t_interpolation, ) - from cudf._lib.types import Interpolation - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.quantiles cimport ( - quantile as cpp_quantile, - quantiles as cpp_quantiles, -) from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport ( interpolation, null_order, order, - order_info, sorted, + order_info, +) +from cudf._lib.cpp.quantiles cimport ( + quantile as cpp_quantile, + quantiles as cpp_quantiles, ) diff --git a/python/cudf/cudf/_lib/reduce.pyx b/python/cudf/cudf/_lib/reduce.pyx index 49ebb0a2528..e5723331f3c 100644 --- a/python/cudf/cudf/_lib/reduce.pyx +++ b/python/cudf/cudf/_lib/reduce.pyx @@ -1,25 +1,20 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. import cudf -from cudf.core.dtypes import Decimal64Dtype from cudf.utils.dtypes import is_decimal_dtype - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.reduce cimport cpp_minmax, cpp_reduce, cpp_scan, scan_type +from cudf.core.dtypes import Decimal64Dtype +from cudf._lib.cpp.reduce cimport cpp_reduce, cpp_scan, scan_type, cpp_minmax from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.types cimport data_type, type_id +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.column.column cimport column from cudf._lib.scalar cimport DeviceScalar - +from cudf._lib.column cimport Column from cudf._lib.types import np_to_cudf_types - +from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type +from cudf._lib.aggregation cimport make_aggregation, Aggregation from libcpp.memory cimport unique_ptr from libcpp.utility cimport move, pair - -from cudf._lib.aggregation cimport Aggregation, make_aggregation -from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id - import numpy as np cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/replace.pyx b/python/cudf/cudf/_lib/replace.pyx index 2ae0835566b..cdedd3ac022 100644 --- a/python/cudf/cudf/_lib/replace.pyx +++ b/python/cudf/cudf/_lib/replace.pyx @@ -6,20 +6,22 @@ from libcpp.utility cimport move from cudf.utils.dtypes import is_scalar from cudf._lib.column cimport Column - from cudf._lib.scalar import as_device_scalar +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view +) from cudf._lib.cpp.replace cimport ( - clamp as cpp_clamp, + replace_policy as cpp_replace_policy, find_and_replace_all as cpp_find_and_replace_all, - normalize_nans_and_zeros as cpp_normalize_nans_and_zeros, replace_nulls as cpp_replace_nulls, - replace_policy as cpp_replace_policy, + clamp as cpp_clamp, + normalize_nans_and_zeros as cpp_normalize_nans_and_zeros ) -from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.scalar cimport DeviceScalar def replace(Column input_col, Column values_to_replace, diff --git a/python/cudf/cudf/_lib/reshape.pyx b/python/cudf/cudf/_lib/reshape.pyx index fbed410de86..cebe48eb697 100644 --- a/python/cudf/cudf/_lib/reshape.pyx +++ b/python/cudf/cudf/_lib/reshape.pyx @@ -2,17 +2,18 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - from cudf._lib.column cimport Column +from cudf._lib.table cimport Table + +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view + from cudf._lib.cpp.reshape cimport ( interleave_columns as cpp_interleave_columns, - tile as cpp_tile, + tile as cpp_tile ) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.table cimport Table def interleave_columns(Table source_table): diff --git a/python/cudf/cudf/_lib/rolling.pyx b/python/cudf/cudf/_lib/rolling.pyx index 87c2fa6178f..6fe661a25a5 100644 --- a/python/cudf/cudf/_lib/rolling.pyx +++ b/python/cudf/cudf/_lib/rolling.pyx @@ -1,20 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from __future__ import print_function - -import pandas as pd - import cudf +import pandas as pd from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.aggregation cimport RollingAggregation, make_rolling_aggregation from cudf._lib.column cimport Column +from cudf._lib.aggregation cimport RollingAggregation, make_rolling_aggregation + +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.rolling cimport rolling_window as cpp_rolling_window -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.rolling cimport ( + rolling_window as cpp_rolling_window +) def rolling(Column source_column, Column pre_column_window, diff --git a/python/cudf/cudf/_lib/round.pyx b/python/cudf/cudf/_lib/round.pyx index cb6bca373a4..660d6d91670 100644 --- a/python/cudf/cudf/_lib/round.pyx +++ b/python/cudf/cudf/_lib/round.pyx @@ -4,11 +4,12 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from cudf._lib.column cimport Column + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.round cimport ( - round as cpp_round, rounding_method as cpp_rounding_method, + round as cpp_round ) diff --git a/python/cudf/cudf/_lib/scalar.pyx b/python/cudf/cudf/_lib/scalar.pyx index 919b652a43e..b31f0675422 100644 --- a/python/cudf/cudf/_lib/scalar.pyx +++ b/python/cudf/cudf/_lib/scalar.pyx @@ -1,6 +1,5 @@ # Copyright (c) 2020, NVIDIA CORPORATION. import decimal - import numpy as np import pandas as pd @@ -14,42 +13,37 @@ from libc.stdint cimport ( uint32_t, uint64_t, ) -from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from libcpp cimport bool import cudf -from cudf._lib.types import ( - cudf_to_np_types, - datetime_unit_map, - duration_unit_map, -) +from cudf._lib.types import cudf_to_np_types, duration_unit_map +from cudf._lib.types import datetime_unit_map +from cudf._lib.types cimport underlying_type_t_type_id -from cudf._lib.cpp.scalar.scalar cimport ( - duration_scalar, - fixed_point_scalar, - numeric_scalar, - scalar, - string_scalar, - timestamp_scalar, +from cudf._lib.cpp.wrappers.timestamps cimport ( + timestamp_s, + timestamp_ms, + timestamp_us, + timestamp_ns ) -from cudf._lib.cpp.wrappers.decimals cimport decimal64, scale_type -from cudf._lib.cpp.wrappers.durations cimport ( - duration_ms, - duration_ns, +from cudf._lib.cpp.wrappers.durations cimport( duration_s, + duration_ms, duration_us, + duration_ns ) -from cudf._lib.cpp.wrappers.timestamps cimport ( - timestamp_ms, - timestamp_ns, - timestamp_s, - timestamp_us, +from cudf._lib.cpp.wrappers.decimals cimport decimal64, scale_type +from cudf._lib.cpp.scalar.scalar cimport ( + scalar, + numeric_scalar, + timestamp_scalar, + duration_scalar, + string_scalar, + fixed_point_scalar ) -from cudf._lib.types cimport underlying_type_t_type_id - from cudf.utils.dtypes import _decimal_to_int64 - cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/search.pyx b/python/cudf/cudf/_lib/search.pyx index 33471028d66..402e3456821 100644 --- a/python/cudf/cudf/_lib/search.pyx +++ b/python/cudf/cudf/_lib/search.pyx @@ -1,16 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp.vector cimport vector -cimport cudf._lib.cpp.search as cpp_search -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column +from cudf._lib.table cimport Table + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.table cimport Table +cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.search as cpp_search def search_sorted( diff --git a/python/cudf/cudf/_lib/sort.pxd b/python/cudf/cudf/_lib/sort.pxd index d7488889555..6a06c132daa 100644 --- a/python/cudf/cudf/_lib/sort.pxd +++ b/python/cudf/cudf/_lib/sort.pxd @@ -1,3 +1,2 @@ from libc.stdint cimport int32_t - ctypedef int32_t underlying_type_t_rank_method diff --git a/python/cudf/cudf/_lib/sort.pyx b/python/cudf/cudf/_lib/sort.pyx index 1d15052e41a..a20ab4c1bf4 100644 --- a/python/cudf/cudf/_lib/sort.pyx +++ b/python/cudf/cudf/_lib/sort.pyx @@ -4,26 +4,23 @@ import pandas as pd from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.vector cimport vector - +from libcpp.utility cimport move from enum import IntEnum from cudf._lib.column cimport Column +from cudf._lib.table cimport Table + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.search cimport lower_bound, upper_bound -from cudf._lib.cpp.sorting cimport ( - is_sorted as cpp_is_sorted, - rank, - rank_method, - sorted_order, -) from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport null_order, null_policy, order +from cudf._lib.cpp.search cimport lower_bound, upper_bound +from cudf._lib.cpp.sorting cimport( + rank, rank_method, sorted_order, is_sorted as cpp_is_sorted +) from cudf._lib.sort cimport underlying_type_t_rank_method -from cudf._lib.table cimport Table +from cudf._lib.cpp.types cimport order, null_order, null_policy def is_sorted( diff --git a/python/cudf/cudf/_lib/stream_compaction.pyx b/python/cudf/cudf/_lib/stream_compaction.pyx index a7326efcc03..cabbdf89b4e 100644 --- a/python/cudf/cudf/_lib/stream_compaction.pyx +++ b/python/cudf/cudf/_lib/stream_compaction.pyx @@ -2,29 +2,27 @@ import pandas as pd -from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.vector cimport vector +from libcpp.utility cimport move +from libcpp cimport bool from cudf._lib.column cimport Column +from cudf._lib.table cimport Table + +from cudf._lib.cpp.types cimport ( + size_type, null_policy, nan_policy, null_equality +) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.stream_compaction cimport ( + duplicate_keep_option, + drop_nulls as cpp_drop_nulls, apply_boolean_mask as cpp_apply_boolean_mask, - distinct_count as cpp_distinct_count, drop_duplicates as cpp_drop_duplicates, - drop_nulls as cpp_drop_nulls, - duplicate_keep_option, + distinct_count as cpp_distinct_count ) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport ( - nan_policy, - null_equality, - null_policy, - size_type, -) -from cudf._lib.table cimport Table def drop_nulls(Table source_table, how="any", keys=None, thresh=None): diff --git a/python/cudf/cudf/_lib/string_casting.pyx b/python/cudf/cudf/_lib/string_casting.pyx index 5c74a15e814..7d58e3b5dcc 100644 --- a/python/cudf/cudf/_lib/string_casting.pyx +++ b/python/cudf/cudf/_lib/string_casting.pyx @@ -3,57 +3,56 @@ import numpy as np from cudf._lib.column cimport Column - from cudf._lib.scalar import as_device_scalar - from cudf._lib.scalar cimport DeviceScalar - from cudf._lib.types import np_to_cudf_types - from cudf._lib.types cimport underlying_type_t_type_id from cudf.core.column.column import as_column -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string -from libcpp.utility cimport move - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.convert.convert_booleans cimport ( - from_booleans as cpp_from_booleans, to_booleans as cpp_to_booleans, + from_booleans as cpp_from_booleans ) from cudf._lib.cpp.strings.convert.convert_datetime cimport ( - from_timestamps as cpp_from_timestamps, - is_timestamp as cpp_is_timestamp, to_timestamps as cpp_to_timestamps, -) -from cudf._lib.cpp.strings.convert.convert_durations cimport ( - from_durations as cpp_from_durations, - to_durations as cpp_to_durations, + from_timestamps as cpp_from_timestamps, + is_timestamp as cpp_is_timestamp ) from cudf._lib.cpp.strings.convert.convert_floats cimport ( - from_floats as cpp_from_floats, to_floats as cpp_to_floats, + from_floats as cpp_from_floats ) from cudf._lib.cpp.strings.convert.convert_integers cimport ( + to_integers as cpp_to_integers, from_integers as cpp_from_integers, hex_to_integers as cpp_hex_to_integers, - is_hex as cpp_is_hex, - to_integers as cpp_to_integers, + is_hex as cpp_is_hex ) from cudf._lib.cpp.strings.convert.convert_ipv4 cimport ( - integers_to_ipv4 as cpp_integers_to_ipv4, ipv4_to_integers as cpp_ipv4_to_integers, - is_ipv4 as cpp_is_ipv4, + integers_to_ipv4 as cpp_integers_to_ipv4, + is_ipv4 as cpp_is_ipv4 ) from cudf._lib.cpp.strings.convert.convert_urls cimport ( - url_decode as cpp_url_decode, url_encode as cpp_url_encode, + url_decode as cpp_url_decode +) +from cudf._lib.cpp.strings.convert.convert_durations cimport ( + to_durations as cpp_to_durations, + from_durations as cpp_from_durations +) +from cudf._lib.cpp.types cimport ( + type_id, + data_type, ) -from cudf._lib.cpp.types cimport data_type, type_id + +from libcpp.memory cimport unique_ptr +from libcpp.utility cimport move +from libcpp.string cimport string def floating_to_string(Column input_col): diff --git a/python/cudf/cudf/_lib/strings/attributes.pyx b/python/cudf/cudf/_lib/strings/attributes.pyx index 8720fad7455..3e0bacda546 100644 --- a/python/cudf/cudf/_lib/strings/attributes.pyx +++ b/python/cudf/cudf/_lib/strings/attributes.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.attributes cimport ( - code_points as cpp_code_points, - count_bytes as cpp_count_bytes, count_characters as cpp_count_characters, + code_points as cpp_code_points, + count_bytes as cpp_count_bytes ) +from cudf._lib.column cimport Column def count_characters(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/capitalize.pyx b/python/cudf/cudf/_lib/strings/capitalize.pyx index bb1bf25ef7b..8316d42ee15 100644 --- a/python/cudf/cudf/_lib/strings/capitalize.pyx +++ b/python/cudf/cudf/_lib/strings/capitalize.pyx @@ -3,13 +3,13 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.capitalize cimport ( capitalize as cpp_capitalize, title as cpp_title, ) +from cudf._lib.column cimport Column def capitalize(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/case.pyx b/python/cudf/cudf/_lib/strings/case.pyx index 13679f3fb02..6f114519374 100644 --- a/python/cudf/cudf/_lib/strings/case.pyx +++ b/python/cudf/cudf/_lib/strings/case.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.case cimport ( swapcase as cpp_swapcase, to_lower as cpp_to_lower, - to_upper as cpp_to_upper, + to_upper as cpp_to_upper ) +from cudf._lib.column cimport Column def to_upper(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/char_types.pyx b/python/cudf/cudf/_lib/strings/char_types.pyx index 3ef9db2345d..1890e98f956 100644 --- a/python/cudf/cudf/_lib/strings/char_types.pyx +++ b/python/cudf/cudf/_lib/strings/char_types.pyx @@ -4,16 +4,17 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.column.column cimport column + from cudf._lib.cpp.strings.char_types cimport ( all_characters_of_type as cpp_all_characters_of_type, filter_characters_of_type as cpp_filter_characters_of_type, string_character_types as string_character_types, ) -from cudf._lib.scalar cimport DeviceScalar def filter_alphanum(Column source_strings, object py_repl, bool keep=True): diff --git a/python/cudf/cudf/_lib/strings/combine.pyx b/python/cudf/cudf/_lib/strings/combine.pyx index b24f8ff666f..25619de3ed0 100644 --- a/python/cudf/cudf/_lib/strings/combine.pyx +++ b/python/cudf/cudf/_lib/strings/combine.pyx @@ -1,22 +1,23 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column +from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.column.column cimport column +from cudf._lib.scalar cimport DeviceScalar +from libcpp.string cimport string +from cudf._lib.table cimport Table + from cudf._lib.cpp.strings.combine cimport ( concatenate as cpp_concatenate, - concatenate_list_elements as cpp_concatenate_list_elements, join_strings as cpp_join_strings, + concatenate_list_elements as cpp_concatenate_list_elements ) -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.table cimport Table def concatenate(Table source_strings, diff --git a/python/cudf/cudf/_lib/strings/contains.pyx b/python/cudf/cudf/_lib/strings/contains.pyx index 1f622378280..256803c9479 100644 --- a/python/cudf/cudf/_lib/strings/contains.pyx +++ b/python/cudf/cudf/_lib/strings/contains.pyx @@ -1,18 +1,18 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move - from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.strings.contains cimport ( contains_re as cpp_contains_re, count_re as cpp_count_re, - matches_re as cpp_matches_re, + matches_re as cpp_matches_re ) -from cudf._lib.scalar cimport DeviceScalar +from libcpp.string cimport string def contains_re(Column source_strings, object reg_ex): diff --git a/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx b/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx index ae61df3d271..38d238b8266 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx @@ -3,26 +3,27 @@ import numpy as np from cudf._lib.column cimport Column - from cudf._lib.types import np_to_cudf_types - -from cudf._lib.cpp.types cimport DECIMAL64 from cudf._lib.types cimport underlying_type_t_type_id +from cudf._lib.cpp.types cimport DECIMAL64 from cudf.core.column.column import as_column -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string -from libcpp.utility cimport move - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_fixed_point cimport ( - from_fixed_point as cpp_from_fixed_point, - is_fixed_point as cpp_is_fixed_point, to_fixed_point as cpp_to_fixed_point, + from_fixed_point as cpp_from_fixed_point, + is_fixed_point as cpp_is_fixed_point ) -from cudf._lib.cpp.types cimport data_type, type_id +from cudf._lib.cpp.types cimport ( + type_id, + data_type, +) + +from libcpp.memory cimport unique_ptr +from libcpp.utility cimport move +from libcpp.string cimport string def from_decimal(Column input_col): diff --git a/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx b/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx index d47b1e6e651..195d9b71f6e 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx @@ -4,9 +4,10 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.strings.convert.convert_floats cimport ( is_float as cpp_is_float, ) diff --git a/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx b/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx index 08bcca93086..d1bae1edd37 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx @@ -4,9 +4,10 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.strings.convert.convert_integers cimport ( is_integer as cpp_is_integer, ) diff --git a/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx b/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx index c391719e853..6aab99b3ec5 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx @@ -2,13 +2,13 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.strings.convert.convert_urls cimport ( - url_decode as cpp_url_decode, url_encode as cpp_url_encode, + url_decode as cpp_url_decode, ) diff --git a/python/cudf/cudf/_lib/strings/extract.pyx b/python/cudf/cudf/_lib/strings/extract.pyx index 58558fade24..5828b62b999 100644 --- a/python/cudf/cudf/_lib/strings/extract.pyx +++ b/python/cudf/cudf/_lib/strings/extract.pyx @@ -1,17 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move - from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.strings.extract cimport extract as cpp_extract -from cudf._lib.cpp.table.table cimport table from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.table.table cimport table from cudf._lib.table cimport Table +from cudf._lib.cpp.column.column cimport column + +from cudf._lib.cpp.strings.extract cimport ( + extract as cpp_extract +) +from libcpp.string cimport string + def extract(Column source_strings, object pattern): """ diff --git a/python/cudf/cudf/_lib/strings/find.pyx b/python/cudf/cudf/_lib/strings/find.pyx index 788c0a2524a..3a360d31ef2 100644 --- a/python/cudf/cudf/_lib/strings/find.pyx +++ b/python/cudf/cudf/_lib/strings/find.pyx @@ -1,21 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type + from cudf._lib.cpp.strings.find cimport ( contains as cpp_contains, ends_with as cpp_ends_with, - find as cpp_find, - rfind as cpp_rfind, starts_with as cpp_starts_with, + find as cpp_find, + rfind as cpp_rfind ) -from cudf._lib.cpp.types cimport size_type -from cudf._lib.scalar cimport DeviceScalar def contains(Column source_strings, object py_target): diff --git a/python/cudf/cudf/_lib/strings/find_multiple.pyx b/python/cudf/cudf/_lib/strings/find_multiple.pyx index 4ac86ce4ef5..5c33be07d15 100644 --- a/python/cudf/cudf/_lib/strings/find_multiple.pyx +++ b/python/cudf/cudf/_lib/strings/find_multiple.pyx @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.strings.find_multiple cimport ( find_multiple as cpp_find_multiple, ) diff --git a/python/cudf/cudf/_lib/strings/findall.pyx b/python/cudf/cudf/_lib/strings/findall.pyx index cc5730c467d..7dbfbe62def 100644 --- a/python/cudf/cudf/_lib/strings/findall.pyx +++ b/python/cudf/cudf/_lib/strings/findall.pyx @@ -1,18 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move - from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.strings.findall cimport findall_re as cpp_findall_re -from cudf._lib.cpp.table.table cimport table from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.table.table cimport table from cudf._lib.table cimport Table +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.scalar.scalar cimport string_scalar + +from cudf._lib.cpp.strings.findall cimport ( + findall_re as cpp_findall_re +) +from libcpp.string cimport string + def findall(Column source_strings, pattern): """ diff --git a/python/cudf/cudf/_lib/strings/json.pyx b/python/cudf/cudf/_lib/strings/json.pyx index c7545b6e481..211bbe9d4f0 100644 --- a/python/cudf/cudf/_lib/strings/json.pyx +++ b/python/cudf/cudf/_lib/strings/json.pyx @@ -2,14 +2,16 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.strings.json cimport get_json_object as cpp_get_json_object from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.column.column cimport column + +from cudf._lib.cpp.strings.json cimport ( + get_json_object as cpp_get_json_object +) def get_json_object(Column col, object py_json_path): diff --git a/python/cudf/cudf/_lib/strings/padding.pyx b/python/cudf/cudf/_lib/strings/padding.pyx index c7b97977d60..52c66495d92 100644 --- a/python/cudf/cudf/_lib/strings/padding.pyx +++ b/python/cudf/cudf/_lib/strings/padding.pyx @@ -2,22 +2,19 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar - from enum import IntEnum - from libcpp.string cimport string - from cudf._lib.cpp.column.column cimport column + from cudf._lib.cpp.strings.padding cimport ( pad as cpp_pad, - pad_side as pad_side, zfill as cpp_zfill, + pad_side as pad_side ) from cudf._lib.strings.padding cimport underlying_type_t_pad_side diff --git a/python/cudf/cudf/_lib/strings/replace.pyx b/python/cudf/cudf/_lib/strings/replace.pyx index f5c47d2a2ed..429e356be4a 100644 --- a/python/cudf/cudf/_lib/strings/replace.pyx +++ b/python/cudf/cudf/_lib/strings/replace.pyx @@ -1,20 +1,24 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.column.column cimport column + +from libc.stdint cimport int32_t + from cudf._lib.cpp.strings.replace cimport ( - replace as cpp_replace, replace_slice as cpp_replace_slice, + replace as cpp_replace +) + +from cudf._lib.cpp.strings.substring cimport ( + slice_strings as cpp_slice_strings ) -from cudf._lib.cpp.strings.substring cimport slice_strings as cpp_slice_strings -from cudf._lib.cpp.types cimport size_type -from cudf._lib.scalar cimport DeviceScalar def slice_replace(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/replace_re.pyx b/python/cudf/cudf/_lib/strings/replace_re.pyx index 20fb903c60c..7993e3a172f 100644 --- a/python/cudf/cudf/_lib/strings/replace_re.pyx +++ b/python/cudf/cudf/_lib/strings/replace_re.pyx @@ -1,20 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move +from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.types cimport size_type from libcpp.vector cimport vector -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar + from cudf._lib.cpp.strings.replace_re cimport ( replace_re as cpp_replace_re, - replace_with_backrefs as cpp_replace_with_backrefs, + replace_with_backrefs as cpp_replace_with_backrefs ) -from cudf._lib.cpp.types cimport size_type -from cudf._lib.scalar cimport DeviceScalar +from libcpp.string cimport string def replace_re(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/split/partition.pyx b/python/cudf/cudf/_lib/strings/split/partition.pyx index 590de5bf526..64d625bcb26 100644 --- a/python/cudf/cudf/_lib/strings/split/partition.pyx +++ b/python/cudf/cudf/_lib/strings/split/partition.pyx @@ -1,22 +1,23 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column +from cudf._lib.table cimport Table + +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.scalar cimport DeviceScalar +from libcpp.string cimport string + from cudf._lib.cpp.strings.split.partition cimport ( partition as cpp_partition, rpartition as cpp_rpartition, ) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.table cimport Table def partition(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/split/split.pyx b/python/cudf/cudf/_lib/strings/split/split.pyx index 599f7602b51..2dd66f99ad5 100644 --- a/python/cudf/cudf/_lib/strings/split/split.pyx +++ b/python/cudf/cudf/_lib/strings/split/split.pyx @@ -1,24 +1,25 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column +from cudf._lib.table cimport Table + +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.scalar cimport DeviceScalar +from libcpp.string cimport string + from cudf._lib.cpp.strings.split.split cimport ( - rsplit as cpp_rsplit, - rsplit_record as cpp_rsplit_record, split as cpp_split, + rsplit as cpp_rsplit, split_record as cpp_split_record, + rsplit_record as cpp_rsplit_record ) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.table cimport Table def split(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/strip.pyx b/python/cudf/cudf/_lib/strings/strip.pyx index d3430a53cc6..72dffa3d897 100644 --- a/python/cudf/cudf/_lib/strings/strip.pyx +++ b/python/cudf/cudf/_lib/strings/strip.pyx @@ -1,19 +1,19 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar +from libcpp.string cimport string +from cudf._lib.cpp.column.column cimport column + from cudf._lib.cpp.strings.strip cimport ( strip as cpp_strip, - strip_type as strip_type, + strip_type as strip_type ) -from cudf._lib.cpp.types cimport size_type -from cudf._lib.scalar cimport DeviceScalar def strip(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/substring.pyx b/python/cudf/cudf/_lib/strings/substring.pyx index 761e9503aba..add9e67b09f 100644 --- a/python/cudf/cudf/_lib/strings/substring.pyx +++ b/python/cudf/cudf/_lib/strings/substring.pyx @@ -1,21 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type - +from cudf._lib.cpp.column.column cimport column import numpy as np -from cudf._lib.cpp.strings.substring cimport slice_strings as cpp_slice_strings +from cudf._lib.cpp.strings.substring cimport ( + slice_strings as cpp_slice_strings +) from cudf._lib.scalar import as_device_scalar - -from cudf._lib.cpp.scalar.scalar cimport numeric_scalar from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.scalar.scalar cimport numeric_scalar def slice_strings(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/translate.pyx b/python/cudf/cudf/_lib/strings/translate.pyx index 7a5cf502ba3..32b145736ca 100644 --- a/python/cudf/cudf/_lib/strings/translate.pyx +++ b/python/cudf/cudf/_lib/strings/translate.pyx @@ -2,21 +2,21 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.pair cimport pair from libcpp.utility cimport move -from libcpp.vector cimport vector -from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.translate cimport ( - filter_characters as cpp_filter_characters, - filter_type as filter_type, translate as cpp_translate, + filter_type as filter_type, + filter_characters as cpp_filter_characters ) -from cudf._lib.cpp.types cimport char_utf8 +from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar +from libcpp.vector cimport vector +from libcpp.pair cimport pair +from cudf._lib.cpp.types cimport char_utf8 def translate(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/wrap.pyx b/python/cudf/cudf/_lib/strings/wrap.pyx index 5ebc33f77ef..814df1f1a72 100644 --- a/python/cudf/cudf/_lib/strings/wrap.pyx +++ b/python/cudf/cudf/_lib/strings/wrap.pyx @@ -2,12 +2,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.strings.wrap cimport wrap as cpp_wrap +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column + +from cudf._lib.cpp.strings.wrap cimport ( + wrap as cpp_wrap +) def wrap(Column source_strings, diff --git a/python/cudf/cudf/_lib/table.pxd b/python/cudf/cudf/_lib/table.pxd index e1bffbc3864..ff0223b2519 100644 --- a/python/cudf/cudf/_lib/table.pxd +++ b/python/cudf/cudf/_lib/table.pxd @@ -3,7 +3,9 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view +from cudf._lib.cpp.table.table_view cimport ( + table_view, mutable_table_view +) cdef class Table: diff --git a/python/cudf/cudf/_lib/table.pyi b/python/cudf/cudf/_lib/table.pyi index 2a5dfb2a4dd..772e940f812 100644 --- a/python/cudf/cudf/_lib/table.pyi +++ b/python/cudf/cudf/_lib/table.pyi @@ -1,6 +1,6 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from typing import TYPE_CHECKING, Any, List, Optional +from typing import List, Any, Optional, TYPE_CHECKING import cudf diff --git a/python/cudf/cudf/_lib/table.pyx b/python/cudf/cudf/_lib/table.pyx index 07d7a0fcf02..93d79ba6843 100644 --- a/python/cudf/cudf/_lib/table.pyx +++ b/python/cudf/cudf/_lib/table.pyx @@ -8,16 +8,23 @@ from cudf.core.column_accessor import ColumnAccessor from cython.operator cimport dereference from libc.stdint cimport uintptr_t +from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp.vector cimport vector from cudf._lib.column cimport Column + +from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.column.column_view cimport ( + column_view, + mutable_column_view +) from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.table.table_view cimport ( + table_view, + mutable_table_view +) cdef class Table: diff --git a/python/cudf/cudf/_lib/transform.pyx b/python/cudf/cudf/_lib/transform.pyx index c8b448b6e30..2c83f8b86e0 100644 --- a/python/cudf/cudf/_lib/transform.pyx +++ b/python/cudf/cudf/_lib/transform.pyx @@ -1,32 +1,33 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import numpy as np - import cudf +import numpy as np from cudf.utils import cudautils from libc.stdint cimport uintptr_t -from libcpp.memory cimport unique_ptr -from libcpp.pair cimport pair + from libcpp.string cimport string +from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer +from libcpp.pair cimport pair from cudf._lib.column cimport Column from cudf._lib.table cimport Table - +from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer from cudf.core.buffer import Buffer -from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type, type_id - +from cudf._lib.cpp.types cimport ( + bitmask_type, + data_type, + size_type, + type_id, +) from cudf._lib.types import np_to_cudf_types - +from cudf._lib.types cimport underlying_type_t_type_id from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.types cimport underlying_type_t_type_id from numba.np import numpy_support diff --git a/python/cudf/cudf/_lib/transpose.pyx b/python/cudf/cudf/_lib/transpose.pyx index d12cfa7511d..d2b053789cd 100644 --- a/python/cudf/cudf/_lib/transpose.pyx +++ b/python/cudf/cudf/_lib/transpose.pyx @@ -4,16 +4,19 @@ import cudf from cudf.utils.dtypes import is_categorical_dtype from libcpp.memory cimport unique_ptr -from libcpp.pair cimport pair from libcpp.utility cimport move +from libcpp.pair cimport pair from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.table cimport Table + from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.transpose cimport transpose as cpp_transpose -from cudf._lib.table cimport Table +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.transpose cimport ( + transpose as cpp_transpose +) def transpose(Table source): diff --git a/python/cudf/cudf/_lib/types.pxd b/python/cudf/cudf/_lib/types.pxd index dbbe9b1e05a..383b3665bd9 100644 --- a/python/cudf/cudf/_lib/types.pxd +++ b/python/cudf/cudf/_lib/types.pxd @@ -2,10 +2,9 @@ from libc.stdint cimport int32_t from libcpp cimport bool - -cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +cimport cudf._lib.cpp.types as libcudf_types ctypedef bool underlying_type_t_order ctypedef bool underlying_type_t_null_order diff --git a/python/cudf/cudf/_lib/types.pyx b/python/cudf/cudf/_lib/types.pyx index 4b83208f772..e9ed4f21ddd 100644 --- a/python/cudf/cudf/_lib/types.pyx +++ b/python/cudf/cudf/_lib/types.pyx @@ -4,18 +4,17 @@ from enum import IntEnum import numpy as np -from libcpp.memory cimport make_shared, shared_ptr +from libcpp.memory cimport shared_ptr, make_shared -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.types cimport ( - underlying_type_t_interpolation, - underlying_type_t_null_order, underlying_type_t_order, + underlying_type_t_null_order, underlying_type_t_sorted, + underlying_type_t_interpolation ) - -from cudf.core.dtypes import Decimal64Dtype, ListDtype, StructDtype +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf.core.dtypes import ListDtype, StructDtype, Decimal64Dtype from cudf.utils.dtypes import is_decimal_dtype, is_list_dtype, is_struct_dtype cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/unary.pyx b/python/cudf/cudf/_lib/unary.pyx index c06723fe442..3bac0cde9c6 100644 --- a/python/cudf/cudf/_lib/unary.pyx +++ b/python/cudf/cudf/_lib/unary.pyx @@ -1,29 +1,34 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. from enum import IntEnum - from cudf.utils.dtypes import is_decimal_dtype from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move - import numpy as np from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view - +from cudf._lib.cpp.column.column_view cimport ( + column_view, mutable_column_view +) from cudf._lib.types import np_to_cudf_types +from cudf._lib.cpp.types cimport ( + size_type, + data_type, + type_id, +) +from cudf._lib.column import np_to_cudf_types, cudf_to_np_types +from cudf._lib.cpp.unary cimport ( + underlying_type_t_unary_op, + unary_operator, +) + +from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type -from cudf._lib.cpp.types cimport data_type, size_type, type_id - -from cudf._lib.column import cudf_to_np_types, np_to_cudf_types - -cimport cudf._lib.cpp.types as libcudf_types cimport cudf._lib.cpp.unary as libcudf_unary -from cudf._lib.cpp.unary cimport unary_operator, underlying_type_t_unary_op -from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id +cimport cudf._lib.cpp.types as libcudf_types class UnaryOp(IntEnum): diff --git a/python/cudf/cudf/_lib/utils.pxd b/python/cudf/cudf/_lib/utils.pxd index e8ac858d8b2..03a032ac131 100644 --- a/python/cudf/cudf/_lib/utils.pxd +++ b/python/cudf/cudf/_lib/utils.pxd @@ -2,12 +2,10 @@ from libcpp.string cimport string from libcpp.vector cimport vector - from cudf._lib.cpp.column.column cimport column_view from cudf._lib.cpp.table.table cimport table_view from cudf._lib.table cimport Table - cdef vector[column_view] make_column_views(object columns) except* cdef vector[table_view] make_table_views(object tables) except* cdef vector[table_view] make_table_data_views(object tables) except* diff --git a/python/cudf/cudf/_lib/utils.pyx b/python/cudf/cudf/_lib/utils.pyx index b0ca36e730a..13eedb34c18 100644 --- a/python/cudf/cudf/_lib/utils.pyx +++ b/python/cudf/cudf/_lib/utils.pyx @@ -1,17 +1,17 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -import pyarrow as pa - import cudf -from libc.stdint cimport uint8_t -from libcpp.string cimport string -from libcpp.vector cimport vector +import pyarrow as pa from cudf._lib.column cimport Column +from cudf._lib.table cimport Table from cudf._lib.cpp.column.column cimport column_view from cudf._lib.cpp.table.table cimport table_view -from cudf._lib.table cimport Table + +from libc.stdint cimport uint8_t +from libcpp.string cimport string +from libcpp.vector cimport vector try: import ujson as json @@ -19,11 +19,11 @@ except ImportError: import json from cudf.utils.dtypes import ( + np_to_pa_dtype, is_categorical_dtype, - is_decimal_dtype, is_list_dtype, is_struct_dtype, - np_to_pa_dtype, + is_decimal_dtype, ) diff --git a/python/cudf/cudf/api/extensions/accessor.py b/python/cudf/cudf/api/extensions/accessor.py index 8c0c4332d72..0d1f78cdd33 100644 --- a/python/cudf/cudf/api/extensions/accessor.py +++ b/python/cudf/cudf/api/extensions/accessor.py @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from cudf.utils.docutils import docfmt_partial import warnings +import cudf from pandas.core.accessor import CachedAccessor -import cudf -from cudf.utils.docutils import docfmt_partial _docstring_register_accessor = """ Extends `cudf.{klass}` with custom defined accessor diff --git a/python/cudf/cudf/benchmarks/bench_cudf_io.py b/python/cudf/cudf/benchmarks/bench_cudf_io.py index 20f5afa1eaf..1a01904374c 100644 --- a/python/cudf/cudf/benchmarks/bench_cudf_io.py +++ b/python/cudf/cudf/benchmarks/bench_cudf_io.py @@ -1,13 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +import pytest +import cudf import glob import io - -import pytest from conftest import option -import cudf - def get_dataset_dir(): if option.dataset_dir == "NONE": diff --git a/python/cudf/cudf/benchmarks/get_datasets.py b/python/cudf/cudf/benchmarks/get_datasets.py index f3b66eda512..c793970eb3f 100644 --- a/python/cudf/cudf/benchmarks/get_datasets.py +++ b/python/cudf/cudf/benchmarks/get_datasets.py @@ -1,8 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import argparse import os import shutil +import argparse from collections import namedtuple # Update url and dir where datasets needs to be copied diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index 9b48c1ce259..25552009444 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -28,8 +28,8 @@ from cudf.utils.dtypes import ( is_categorical_dtype, is_column_like, - is_decimal_dtype, is_numerical_dtype, + is_decimal_dtype, is_scalar, min_scalar_type, ) diff --git a/python/cudf/cudf/core/subword_tokenizer.py b/python/cudf/cudf/core/subword_tokenizer.py index 60139f7d7af..9058491d8e7 100644 --- a/python/cudf/cudf/core/subword_tokenizer.py +++ b/python/cudf/cudf/core/subword_tokenizer.py @@ -1,15 +1,13 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from __future__ import annotations - from typing import Union -from warnings import warn - import cupy as cp +from warnings import warn from cudf._lib.nvtext.subword_tokenize import ( - Hashed_Vocabulary as cpp_hashed_vocabulary, subword_tokenize_inmem_hash as cpp_subword_tokenize, + Hashed_Vocabulary as cpp_hashed_vocabulary, ) diff --git a/python/cudf/cudf/core/tools/numeric.py b/python/cudf/cudf/core/tools/numeric.py index bd67c4a60eb..74f7d16e4ff 100644 --- a/python/cudf/cudf/core/tools/numeric.py +++ b/python/cudf/cudf/core/tools/numeric.py @@ -6,19 +6,20 @@ import pandas as pd import cudf -import cudf._lib as libcudf from cudf.core.column import as_column from cudf.utils.dtypes import ( can_convert_to_column, - is_categorical_dtype, - is_datetime_dtype, - is_list_dtype, is_numerical_dtype, + is_datetime_dtype, + is_timedelta_dtype, + is_categorical_dtype, is_string_dtype, + is_list_dtype, is_struct_dtype, - is_timedelta_dtype, ) +import cudf._lib as libcudf + def to_numeric(arg, errors="raise", downcast=None): """ diff --git a/python/cudf/cudf/tests/test_array_ufunc.py b/python/cudf/cudf/tests/test_array_ufunc.py index c459caace0e..f9e0bb2ce8a 100644 --- a/python/cudf/cudf/tests/test_array_ufunc.py +++ b/python/cudf/cudf/tests/test_array_ufunc.py @@ -1,9 +1,8 @@ -import cupy as cp +import cudf import numpy as np +import cupy as cp import pandas as pd import pytest - -import cudf from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_compile_udf.py b/python/cudf/cudf/tests/test_compile_udf.py index d965f35ccdd..96c0e91d8d7 100644 --- a/python/cudf/cudf/tests/test_compile_udf.py +++ b/python/cudf/cudf/tests/test_compile_udf.py @@ -1,8 +1,7 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from numba import types - from cudf.utils import cudautils +from numba import types def setup_function(): diff --git a/python/cudf/cudf/tests/test_concat.py b/python/cudf/cudf/tests/test_concat.py index b68c9d929cd..31dc6012905 100644 --- a/python/cudf/cudf/tests/test_concat.py +++ b/python/cudf/cudf/tests/test_concat.py @@ -7,9 +7,9 @@ import pytest import cudf as gd -from cudf.core.dtypes import Decimal64Dtype from cudf.tests.utils import assert_eq, assert_exceptions_equal from cudf.utils.dtypes import is_categorical_dtype +from cudf.core.dtypes import Decimal64Dtype def make_frames(index=None, nulls="none"): diff --git a/python/cudf/cudf/tests/test_custom_accessor.py b/python/cudf/cudf/tests/test_custom_accessor.py index 46970f4762d..d72b5875677 100644 --- a/python/cudf/cudf/tests/test_custom_accessor.py +++ b/python/cudf/cudf/tests/test_custom_accessor.py @@ -2,8 +2,8 @@ import pandas as pd import pytest - import cudf as gd + from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_dtypes.py b/python/cudf/cudf/tests/test_dtypes.py index 174625a7b89..b6e2aac0304 100644 --- a/python/cudf/cudf/tests/test_dtypes.py +++ b/python/cudf/cudf/tests/test_dtypes.py @@ -9,9 +9,9 @@ from cudf.core.dtypes import ( CategoricalDtype, Decimal64Dtype, - IntervalDtype, ListDtype, StructDtype, + IntervalDtype, ) from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_hash_vocab.py b/python/cudf/cudf/tests/test_hash_vocab.py index a30f4e20849..529552cb2d9 100644 --- a/python/cudf/cudf/tests/test_hash_vocab.py +++ b/python/cudf/cudf/tests/test_hash_vocab.py @@ -1,11 +1,9 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -import filecmp +from cudf.utils.hash_vocab_utils import hash_vocab import os - +import filecmp import pytest -from cudf.utils.hash_vocab_utils import hash_vocab - @pytest.fixture(scope="module") def datadir(datadir): diff --git a/python/cudf/cudf/tests/test_replace.py b/python/cudf/cudf/tests/test_replace.py index 14338c2e64a..6dca539b8d5 100644 --- a/python/cudf/cudf/tests/test_replace.py +++ b/python/cudf/cudf/tests/test_replace.py @@ -1,11 +1,11 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. import re -from decimal import Decimal import numpy as np import pandas as pd import pytest +from decimal import Decimal import cudf from cudf.core.dtypes import Decimal64Dtype diff --git a/python/cudf/cudf/tests/test_scan.py b/python/cudf/cudf/tests/test_scan.py index f77fc0b19da..f7e8c5a8563 100644 --- a/python/cudf/cudf/tests/test_scan.py +++ b/python/cudf/cudf/tests/test_scan.py @@ -5,8 +5,8 @@ import pytest import cudf -from cudf.core.dtypes import Decimal64Dtype from cudf.tests.utils import INTEGER_TYPES, NUMERIC_TYPES, assert_eq, gen_rand +from cudf.core.dtypes import Decimal64Dtype params_sizes = [0, 1, 2, 5] diff --git a/python/cudf/cudf/tests/test_seriesmap.py b/python/cudf/cudf/tests/test_seriesmap.py index 6fd1a70433b..324074b6021 100644 --- a/python/cudf/cudf/tests/test_seriesmap.py +++ b/python/cudf/cudf/tests/test_seriesmap.py @@ -4,10 +4,10 @@ from math import floor import numpy as np +import cudf import pandas as pd import pytest -import cudf from cudf import Series from cudf.tests.utils import assert_eq, assert_exceptions_equal diff --git a/python/cudf/cudf/tests/test_subword_tokenizer.py b/python/cudf/cudf/tests/test_subword_tokenizer.py index d5207c79b86..bdb343a41f7 100644 --- a/python/cudf/cudf/tests/test_subword_tokenizer.py +++ b/python/cudf/cudf/tests/test_subword_tokenizer.py @@ -1,9 +1,8 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. +from transformers import BertTokenizer +import pytest import os - import numpy as np -import pytest -from transformers import BertTokenizer import cudf from cudf.core.subword_tokenizer import SubwordTokenizer diff --git a/python/cudf/cudf/tests/test_udf_binops.py b/python/cudf/cudf/tests/test_udf_binops.py index df7361ab183..00d05a8c3a5 100644 --- a/python/cudf/cudf/tests/test_udf_binops.py +++ b/python/cudf/cudf/tests/test_udf_binops.py @@ -3,13 +3,14 @@ import numpy as np import pytest -from numba.cuda import compile_ptx -from numba.np import numpy_support from cudf import _lib as libcudf from cudf.core import Series from cudf.utils import dtypes as dtypeutils +from numba.cuda import compile_ptx +from numba.np import numpy_support + @pytest.mark.parametrize( "dtype", sorted(list(dtypeutils.NUMERIC_TYPES - {"int8"})) diff --git a/python/cudf/cudf/utils/applyutils.py b/python/cudf/cudf/utils/applyutils.py index c8fb7c1a47d..610b0997d85 100644 --- a/python/cudf/cudf/utils/applyutils.py +++ b/python/cudf/cudf/utils/applyutils.py @@ -4,7 +4,6 @@ from typing import Any, Dict from numba import cuda -from numba.core.utils import pysignature import cudf from cudf import _lib as libcudf @@ -12,6 +11,9 @@ from cudf.utils import utils from cudf.utils.docutils import docfmt_partial +from numba.core.utils import pysignature + + _doc_applyparams = """ df : DataFrame The source dataframe. diff --git a/python/cudf/cudf/utils/cudautils.py b/python/cudf/cudf/utils/cudautils.py index df3b6ec3d93..262fe304dd8 100755 --- a/python/cudf/cudf/utils/cudautils.py +++ b/python/cudf/cudf/utils/cudautils.py @@ -4,10 +4,12 @@ import cachetools import numpy as np from numba import cuda -from numba.np import numpy_support import cudf +from numba.np import numpy_support + + # # Misc kernels # diff --git a/python/cudf/cudf/utils/utils.py b/python/cudf/cudf/utils/utils.py index 96d89a829cf..f1841129e20 100644 --- a/python/cudf/cudf/utils/utils.py +++ b/python/cudf/cudf/utils/utils.py @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -import decimal import functools +import decimal from collections.abc import Sequence from typing import FrozenSet, Set, Union diff --git a/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd b/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd index fc985e58b68..d7c310fc6e2 100644 --- a/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd +++ b/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd @@ -1,13 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport int32_t, int64_t -from libcpp cimport bool -from libcpp.map cimport map -from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector - +from libcpp.map cimport map +from libcpp cimport bool +from libc.stdint cimport int32_t, int64_t from cudf._lib.cpp.io.types cimport datasource +from libcpp.memory cimport unique_ptr from cudf._lib.io.datasource cimport Datasource diff --git a/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx b/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx index 5588b69938b..fad62eb38b0 100644 --- a/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx +++ b/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx @@ -1,16 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.string cimport string +from libcpp.map cimport map from libc.stdint cimport int32_t, int64_t from libcpp cimport bool -from libcpp.map cimport map -from libcpp.memory cimport make_unique, unique_ptr -from libcpp.string cimport string - from cudf._lib.cpp.io.types cimport datasource - +from libcpp.memory cimport unique_ptr, make_unique from cudf_kafka._lib.kafka cimport kafka_consumer - cdef class KafkaDatasource(Datasource): def __cinit__(self, diff --git a/python/custreamz/custreamz/tests/test_dataframes.py b/python/custreamz/custreamz/tests/test_dataframes.py index 24f6e46f6c5..d5fffd30d57 100644 --- a/python/custreamz/custreamz/tests/test_dataframes.py +++ b/python/custreamz/custreamz/tests/test_dataframes.py @@ -12,14 +12,13 @@ import numpy as np import pandas as pd import pytest - -from dask.dataframe.utils import assert_eq -from distributed import Client - from streamz import Stream from streamz.dask import DaskStream from streamz.dataframe import Aggregation, DataFrame, DataFrames, Series +from dask.dataframe.utils import assert_eq +from distributed import Client + cudf = pytest.importorskip("cudf") diff --git a/python/dask_cudf/dask_cudf/tests/test_accessor.py b/python/dask_cudf/dask_cudf/tests/test_accessor.py index 0077225754b..76589682717 100644 --- a/python/dask_cudf/dask_cudf/tests/test_accessor.py +++ b/python/dask_cudf/dask_cudf/tests/test_accessor.py @@ -5,11 +5,11 @@ from dask import dataframe as dd +import dask_cudf as dgd + from cudf import DataFrame, Series from cudf.tests.utils import assert_eq -import dask_cudf as dgd - ############################################################################# # Datetime Accessor # ############################################################################# diff --git a/python/dask_cudf/dask_cudf/tests/test_delayed_io.py b/python/dask_cudf/dask_cudf/tests/test_delayed_io.py index 7789664afae..a103d9fe8c2 100644 --- a/python/dask_cudf/dask_cudf/tests/test_delayed_io.py +++ b/python/dask_cudf/dask_cudf/tests/test_delayed_io.py @@ -7,10 +7,10 @@ from dask.delayed import delayed -import cudf as gd - import dask_cudf as dgd +import cudf as gd + @delayed def load_data(nelem, ident): diff --git a/python/dask_cudf/dask_cudf/tests/test_join.py b/python/dask_cudf/dask_cudf/tests/test_join.py index 58811ee98fc..d8781af6c6e 100644 --- a/python/dask_cudf/dask_cudf/tests/test_join.py +++ b/python/dask_cudf/dask_cudf/tests/test_join.py @@ -6,10 +6,10 @@ from dask import dataframe as dd -import cudf - import dask_cudf as dgd +import cudf + param_nrows = [5, 10, 50, 100] diff --git a/python/dask_cudf/dask_cudf/tests/test_reductions.py b/python/dask_cudf/dask_cudf/tests/test_reductions.py index c34fbc3b0e7..030b7717fbc 100644 --- a/python/dask_cudf/dask_cudf/tests/test_reductions.py +++ b/python/dask_cudf/dask_cudf/tests/test_reductions.py @@ -6,10 +6,10 @@ from dask import dataframe as dd -import cudf - import dask_cudf as dgd +import cudf + def _make_random_frame(nelem, npartitions=2): df = pd.DataFrame( diff --git a/python/dask_cudf/dask_cudf/tests/test_sort.py b/python/dask_cudf/dask_cudf/tests/test_sort.py index a12d5792219..855b2bb9a0b 100644 --- a/python/dask_cudf/dask_cudf/tests/test_sort.py +++ b/python/dask_cudf/dask_cudf/tests/test_sort.py @@ -4,10 +4,10 @@ import dask from dask import dataframe as dd -import cudf - import dask_cudf +import cudf + @pytest.mark.parametrize("by", ["a", "b", "c", "d", ["a", "b"], ["c", "d"]]) @pytest.mark.parametrize("nelem", [10, 500]) From c301e3fae706672ac395a818c608d10107877855 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Mon, 21 Jun 2021 14:34:10 -0400 Subject: [PATCH 10/18] Run hooks again --- .../tests/kafka_consumer_tests.cpp | 2 +- java/src/main/native/include/jni_utils.hpp | 25 +- java/src/main/native/src/AggregationJni.cpp | 26 +- java/src/main/native/src/ColumnViewJni.cpp | 438 ++++++++---------- .../main/native/src/ContiguousTableJni.cpp | 2 +- java/src/main/native/src/CudaJni.cpp | 3 +- .../src/HostMemoryBufferNativeUtilsJni.cpp | 42 +- java/src/main/native/src/NvcompJni.cpp | 366 ++++++--------- java/src/main/native/src/NvtxRangeJni.cpp | 10 +- java/src/main/native/src/RmmJni.cpp | 9 +- java/src/main/native/src/ScalarJni.cpp | 16 +- java/src/main/native/src/TableJni.cpp | 260 +++++------ java/src/main/native/src/cudf_jni_apis.hpp | 2 +- java/src/main/native/src/dtype_utils.hpp | 12 +- java/src/main/native/src/map_lookup.hpp | 5 +- java/src/main/native/src/prefix_sum.cu | 20 +- java/src/main/native/src/prefix_sum.hpp | 3 +- python/cudf/cudf/_lib/aggregation.pxd | 4 +- python/cudf/cudf/_lib/aggregation.pyx | 15 +- python/cudf/cudf/_lib/avro.pyx | 11 +- python/cudf/cudf/_lib/binaryop.pxd | 1 - python/cudf/cudf/_lib/binaryop.pyx | 19 +- python/cudf/cudf/_lib/column.pxd | 7 +- python/cudf/cudf/_lib/column.pyi | 6 +- python/cudf/cudf/_lib/column.pyx | 33 +- python/cudf/cudf/_lib/concat.pyx | 18 +- python/cudf/cudf/_lib/copying.pyx | 24 +- python/cudf/cudf/_lib/cpp/aggregation.pxd | 6 +- python/cudf/cudf/_lib/cpp/binaryop.pxd | 7 +- python/cudf/cudf/_lib/cpp/column/column.pxd | 10 +- .../cudf/_lib/cpp/column/column_factories.pxd | 9 +- .../cudf/cudf/_lib/cpp/column/column_view.pxd | 8 +- python/cudf/cudf/_lib/cpp/concatenate.pxd | 3 +- python/cudf/cudf/_lib/cpp/copying.pxd | 11 +- python/cudf/cudf/_lib/cpp/filling.pxd | 6 +- python/cudf/cudf/_lib/cpp/gpuarrow.pxd | 9 +- python/cudf/cudf/_lib/cpp/groupby.pxd | 16 +- python/cudf/cudf/_lib/cpp/hash.pxd | 2 +- python/cudf/cudf/_lib/cpp/interop.pxd | 10 +- python/cudf/cudf/_lib/cpp/io/avro.pxd | 2 +- python/cudf/cudf/_lib/cpp/io/csv.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/json.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/orc.pxd | 7 +- python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd | 2 +- python/cudf/cudf/_lib/cpp/io/parquet.pxd | 9 +- python/cudf/cudf/_lib/cpp/io/types.pxd | 6 +- python/cudf/cudf/_lib/cpp/join.pxd | 10 +- python/cudf/cudf/_lib/cpp/labeling.pxd | 1 + python/cudf/cudf/_lib/cpp/lists/combine.pxd | 1 + python/cudf/cudf/_lib/cpp/lists/contains.pxd | 4 +- .../cudf/_lib/cpp/lists/count_elements.pxd | 1 + .../_lib/cpp/lists/drop_list_duplicates.pxd | 5 +- python/cudf/cudf/_lib/cpp/lists/explode.pxd | 1 + python/cudf/cudf/_lib/cpp/lists/extract.pxd | 2 +- .../cudf/_lib/cpp/lists/lists_column_view.pxd | 4 +- python/cudf/cudf/_lib/cpp/lists/sorting.pxd | 2 +- python/cudf/cudf/_lib/cpp/merge.pxd | 4 +- python/cudf/cudf/_lib/cpp/null_mask.pxd | 2 +- .../cudf/_lib/cpp/nvtext/edit_distance.pxd | 1 + .../cudf/_lib/cpp/nvtext/generate_ngrams.pxd | 1 + .../cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd | 1 + .../cudf/cudf/_lib/cpp/nvtext/normalize.pxd | 1 + python/cudf/cudf/_lib/cpp/nvtext/replace.pxd | 2 +- python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd | 1 + .../cudf/_lib/cpp/nvtext/subword_tokenize.pxd | 3 +- python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd | 1 + python/cudf/cudf/_lib/cpp/partitioning.pxd | 6 +- python/cudf/cudf/_lib/cpp/quantiles.pxd | 5 +- python/cudf/cudf/_lib/cpp/reduce.pxd | 13 +- python/cudf/cudf/_lib/cpp/replace.pxd | 10 +- python/cudf/cudf/_lib/cpp/reshape.pxd | 3 +- python/cudf/cudf/_lib/cpp/rolling.pxd | 6 +- python/cudf/cudf/_lib/cpp/round.pxd | 1 + python/cudf/cudf/_lib/cpp/scalar/scalar.pxd | 7 +- python/cudf/cudf/_lib/cpp/search.pxd | 4 +- python/cudf/cudf/_lib/cpp/sorting.pxd | 5 +- .../cudf/cudf/_lib/cpp/stream_compaction.pxd | 13 +- .../cudf/cudf/_lib/cpp/strings/attributes.pxd | 1 + .../cudf/cudf/_lib/cpp/strings/capitalize.pxd | 1 + python/cudf/cudf/_lib/cpp/strings/case.pxd | 1 + .../cudf/cudf/_lib/cpp/strings/char_types.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/combine.pxd | 8 +- .../cudf/cudf/_lib/cpp/strings/contains.pxd | 3 +- .../cpp/strings/convert/convert_booleans.pxd | 3 +- .../cpp/strings/convert/convert_datetime.pxd | 5 +- .../cpp/strings/convert/convert_durations.pxd | 5 +- .../strings/convert/convert_fixed_point.pxd | 3 +- .../cpp/strings/convert/convert_floats.pxd | 3 +- .../cpp/strings/convert/convert_integers.pxd | 3 +- .../_lib/cpp/strings/convert/convert_ipv4.pxd | 3 +- .../_lib/cpp/strings/convert/convert_urls.pxd | 3 +- python/cudf/cudf/_lib/cpp/strings/extract.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/find.pxd | 4 +- .../cudf/_lib/cpp/strings/find_multiple.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/findall.pxd | 4 +- python/cudf/cudf/_lib/cpp/strings/json.pxd | 5 +- python/cudf/cudf/_lib/cpp/strings/padding.pxd | 9 +- python/cudf/cudf/_lib/cpp/strings/replace.pxd | 8 +- .../cudf/cudf/_lib/cpp/strings/replace_re.pxd | 9 +- .../cudf/_lib/cpp/strings/split/partition.pxd | 8 +- .../cudf/_lib/cpp/strings/split/split.pxd | 10 +- python/cudf/cudf/_lib/cpp/strings/strip.pxd | 6 +- .../cudf/cudf/_lib/cpp/strings/substring.pxd | 6 +- .../cudf/cudf/_lib/cpp/strings/translate.pxd | 7 +- python/cudf/cudf/_lib/cpp/strings/wrap.pxd | 6 +- python/cudf/cudf/_lib/cpp/table/table.pxd | 10 +- .../cudf/cudf/_lib/cpp/table/table_view.pxd | 6 +- python/cudf/cudf/_lib/cpp/transform.pxd | 10 +- python/cudf/cudf/_lib/cpp/unary.pxd | 13 +- .../cudf/_lib/cpp/utilities/host_span.pxd | 1 + .../cudf/cudf/_lib/cpp/wrappers/decimals.pxd | 3 +- python/cudf/cudf/_lib/csv.pyx | 22 +- python/cudf/cudf/_lib/datetime.pyx | 6 +- python/cudf/cudf/_lib/filling.pyx | 9 +- python/cudf/cudf/_lib/gpuarrow.pyx | 14 +- python/cudf/cudf/_lib/groupby.pyx | 37 +- python/cudf/cudf/_lib/hash.pyx | 15 +- python/cudf/cudf/_lib/interop.pyx | 24 +- python/cudf/cudf/_lib/io/datasource.pxd | 2 + python/cudf/cudf/_lib/io/datasource.pyx | 2 + python/cudf/cudf/_lib/io/utils.pxd | 3 +- python/cudf/cudf/_lib/io/utils.pyx | 17 +- python/cudf/cudf/_lib/join.pyx | 18 +- python/cudf/cudf/_lib/json.pyx | 9 +- python/cudf/cudf/_lib/labeling.pyx | 7 +- python/cudf/cudf/_lib/lists.pyx | 43 +- python/cudf/cudf/_lib/merge.pyx | 11 +- python/cudf/cudf/_lib/null_mask.pyx | 11 +- .../cudf/cudf/_lib/nvtext/edit_distance.pyx | 4 +- .../cudf/cudf/_lib/nvtext/generate_ngrams.pyx | 8 +- .../cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx | 8 +- python/cudf/cudf/_lib/nvtext/normalize.pyx | 4 +- python/cudf/cudf/_lib/nvtext/replace.pyx | 8 +- python/cudf/cudf/_lib/nvtext/stemmer.pyx | 12 +- .../cudf/_lib/nvtext/subword_tokenize.pyx | 13 +- python/cudf/cudf/_lib/nvtext/tokenize.pyx | 12 +- python/cudf/cudf/_lib/orc.pyx | 38 +- python/cudf/cudf/_lib/parquet.pyx | 64 ++- python/cudf/cudf/_lib/partitioning.pyx | 14 +- python/cudf/cudf/_lib/quantiles.pyx | 18 +- python/cudf/cudf/_lib/reduce.pyx | 19 +- python/cudf/cudf/_lib/replace.pyx | 16 +- python/cudf/cudf/_lib/reshape.pyx | 13 +- python/cudf/cudf/_lib/rolling.pyx | 13 +- python/cudf/cudf/_lib/round.pyx | 3 +- python/cudf/cudf/_lib/scalar.pyx | 49 +- python/cudf/cudf/_lib/search.pyx | 9 +- python/cudf/cudf/_lib/sort.pxd | 1 + python/cudf/cudf/_lib/sort.pyx | 19 +- python/cudf/cudf/_lib/stream_compaction.pyx | 26 +- python/cudf/cudf/_lib/string_casting.pyx | 43 +- python/cudf/cudf/_lib/strings/attributes.pyx | 6 +- python/cudf/cudf/_lib/strings/capitalize.pyx | 2 +- python/cudf/cudf/_lib/strings/case.pyx | 4 +- python/cudf/cudf/_lib/strings/char_types.pyx | 7 +- python/cudf/cudf/_lib/strings/combine.pyx | 21 +- python/cudf/cudf/_lib/strings/contains.pyx | 10 +- .../strings/convert/convert_fixed_point.pyx | 21 +- .../_lib/strings/convert/convert_floats.pyx | 3 +- .../_lib/strings/convert/convert_integers.pyx | 3 +- .../_lib/strings/convert/convert_urls.pyx | 6 +- python/cudf/cudf/_lib/strings/extract.pyx | 15 +- python/cudf/cudf/_lib/strings/find.pyx | 12 +- .../cudf/cudf/_lib/strings/find_multiple.pyx | 4 +- python/cudf/cudf/_lib/strings/findall.pyx | 17 +- python/cudf/cudf/_lib/strings/json.pyx | 10 +- python/cudf/cudf/_lib/strings/padding.pyx | 9 +- python/cudf/cudf/_lib/strings/replace.pyx | 20 +- python/cudf/cudf/_lib/strings/replace_re.pyx | 13 +- .../cudf/_lib/strings/split/partition.pyx | 19 +- python/cudf/cudf/_lib/strings/split/split.pyx | 23 +- python/cudf/cudf/_lib/strings/strip.pyx | 14 +- python/cudf/cudf/_lib/strings/substring.pyx | 13 +- python/cudf/cudf/_lib/strings/translate.pyx | 12 +- python/cudf/cudf/_lib/strings/wrap.pyx | 10 +- python/cudf/cudf/_lib/table.pxd | 4 +- python/cudf/cudf/_lib/table.pyi | 2 +- python/cudf/cudf/_lib/table.pyx | 15 +- python/cudf/cudf/_lib/transform.pyx | 23 +- python/cudf/cudf/_lib/transpose.pyx | 13 +- python/cudf/cudf/_lib/types.pxd | 3 +- python/cudf/cudf/_lib/types.pyx | 13 +- python/cudf/cudf/_lib/unary.pyx | 27 +- python/cudf/cudf/_lib/utils.pxd | 2 + python/cudf/cudf/_lib/utils.pyx | 16 +- python/cudf/cudf/api/extensions/accessor.py | 4 +- python/cudf/cudf/benchmarks/bench_cudf_io.py | 6 +- python/cudf/cudf/benchmarks/get_datasets.py | 2 +- python/cudf/cudf/core/column/categorical.py | 2 +- python/cudf/cudf/core/column/decimal.py | 2 +- python/cudf/cudf/core/cut.py | 15 +- python/cudf/cudf/core/subword_tokenizer.py | 6 +- python/cudf/cudf/tests/test_array_ufunc.py | 5 +- python/cudf/cudf/tests/test_compile_udf.py | 3 +- python/cudf/cudf/tests/test_concat.py | 4 +- .../cudf/cudf/tests/test_custom_accessor.py | 2 +- python/cudf/cudf/tests/test_cut.py | 5 +- python/cudf/cudf/tests/test_hash_vocab.py | 6 +- python/cudf/cudf/tests/test_orc.py | 4 +- python/cudf/cudf/tests/test_replace.py | 2 +- python/cudf/cudf/tests/test_scan.py | 2 +- python/cudf/cudf/tests/test_seriesmap.py | 2 +- .../cudf/cudf/tests/test_subword_tokenizer.py | 5 +- python/cudf/cudf/tests/test_udf_binops.py | 5 +- python/cudf/cudf/utils/applyutils.py | 4 +- python/cudf/cudf/utils/cudautils.py | 4 +- python/cudf_kafka/cudf_kafka/_lib/kafka.pxd | 9 +- python/cudf_kafka/cudf_kafka/_lib/kafka.pyx | 9 +- .../custreamz/tests/test_dataframes.py | 7 +- .../dask_cudf/tests/test_delayed_io.py | 4 +- python/dask_cudf/dask_cudf/tests/test_join.py | 4 +- .../dask_cudf/tests/test_reductions.py | 4 +- python/dask_cudf/dask_cudf/tests/test_sort.py | 4 +- 213 files changed, 1415 insertions(+), 1588 deletions(-) diff --git a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp index 0f88d0b2564..dbfd7a29efd 100644 --- a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp +++ b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp @@ -20,8 +20,8 @@ #include #include "cudf_kafka/kafka_consumer.hpp" -#include #include +#include namespace kafka = cudf::io::external::kafka; diff --git a/java/src/main/native/include/jni_utils.hpp b/java/src/main/native/include/jni_utils.hpp index 3ce136dda19..4b6696e3911 100644 --- a/java/src/main/native/include/jni_utils.hpp +++ b/java/src/main/native/include/jni_utils.hpp @@ -243,21 +243,13 @@ template class nativ return data_ptr; } - const N_TYPE *const begin() const { - return data(); - } + const N_TYPE *const begin() const { return data(); } - N_TYPE *begin() { - return data(); - } + N_TYPE *begin() { return data(); } - const N_TYPE *const end() const { - return data() + size(); - } + const N_TYPE *const end() const { return data() + size(); } - N_TYPE *end() { - return data() + size(); - } + N_TYPE *end() { return data() + size(); } const J_ARRAY_TYPE get_jArray() const { return orig; } @@ -315,7 +307,7 @@ template class native_jpointerArray { int size() const noexcept { return wrapped.size(); } - T *operator[](int index) const { + T *operator[](int index) const { if (data() == NULL) { throw_java_exception(env, NPE_CLASS, "pointer is NULL"); } @@ -754,8 +746,8 @@ inline void jni_cuda_check(JNIEnv *const env, cudaError_t cuda_status) { if (cudaErrorMemoryAllocation == cudaPeekAtLastError()) { \ cudaGetLastError(); \ } \ - auto what = std::string("Could not allocate native memory: ") + \ - (e.what() == nullptr ? "" : e.what()); \ + auto what = \ + std::string("Could not allocate native memory: ") + (e.what() == nullptr ? "" : e.what()); \ JNI_CHECK_THROW_NEW(env, cudf::jni::OOM_CLASS, what.c_str(), ret_val); \ } \ catch (const std::exception &e) { \ @@ -763,5 +755,4 @@ inline void jni_cuda_check(JNIEnv *const env, cudaError_t cuda_status) { JNI_CHECK_THROW_NEW(env, class_name, e.what(), ret_val); \ } -#define CATCH_STD(env, ret_val) \ - CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val) +#define CATCH_STD(env, ret_val) CATCH_STD_CLASS(env, cudf::jni::CUDF_ERROR_CLASS, ret_val) diff --git a/java/src/main/native/src/AggregationJni.cpp b/java/src/main/native/src/AggregationJni.cpp index 63c2c33202e..b4ea1f9c33f 100644 --- a/java/src/main/native/src/AggregationJni.cpp +++ b/java/src/main/native/src/AggregationJni.cpp @@ -20,8 +20,7 @@ extern "C" { -JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env, - jclass class_object, +JNIEXPORT void JNICALL Java_ai_rapids_cudf_Aggregation_close(JNIEnv *env, jclass class_object, jlong ptr) { try { cudf::jni::auto_set_device(env); @@ -51,7 +50,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv case 3: // MAX ret = cudf::make_max_aggregation(); break; - //case 4 COUNT + // case 4 COUNT case 5: // ANY ret = cudf::make_any_aggregation(); break; @@ -102,9 +101,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNthAgg(JNIEnv *env try { cudf::jni::auto_set_device(env); - std::unique_ptr ret = - cudf::make_nth_element_aggregation(offset, - include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE); + std::unique_ptr ret = cudf::make_nth_element_aggregation( + offset, include_nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE); return reinterpret_cast(ret.release()); } CATCH_STD(env, 0); @@ -112,8 +110,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNthAgg(JNIEnv *env JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createDdofAgg(JNIEnv *env, jclass class_object, - jint kind, - jint ddof) { + jint kind, jint ddof) { try { cudf::jni::auto_set_device(env); @@ -179,8 +176,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createQuantAgg(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv *env, jclass class_object, - jint kind, - jint offset) { + jint kind, jint offset) { try { cudf::jni::auto_set_device(env); @@ -200,9 +196,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createLeadLagAgg(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg(JNIEnv *env, - jclass class_object, - jboolean include_nulls) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectListAgg( + JNIEnv *env, jclass class_object, jboolean include_nulls) { try { cudf::jni::auto_set_device(env); cudf::null_policy policy = @@ -226,9 +221,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createCollectSetAgg(JNIE nulls_equal ? cudf::null_equality::EQUAL : cudf::null_equality::UNEQUAL; cudf::nan_equality nan_equality = nans_equal ? cudf::nan_equality::ALL_EQUAL : cudf::nan_equality::UNEQUAL; - std::unique_ptr ret = cudf::make_collect_set_aggregation(null_policy, - null_equality, - nan_equality); + std::unique_ptr ret = + cudf::make_collect_set_aggregation(null_policy, null_equality, nan_equality); return reinterpret_cast(ret.release()); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/ColumnViewJni.cpp b/java/src/main/native/src/ColumnViewJni.cpp index bb8cc09851d..cccfda5aa96 100644 --- a/java/src/main/native/src/ColumnViewJni.cpp +++ b/java/src/main/native/src/ColumnViewJni.cpp @@ -23,9 +23,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -49,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -56,21 +59,19 @@ #include #include #include -#include +#include #include #include #include -#include -#include -#include #include + #include "cudf/types.hpp" -#include "prefix_sum.hpp" #include "cudf_jni_apis.hpp" #include "dtype_utils.hpp" #include "jni.h" #include "jni_utils.hpp" +#include "prefix_sum.hpp" namespace { @@ -87,10 +88,9 @@ std::size_t calc_device_memory_size(cudf::column_view const &view) { total += cudf::size_of(dtype) * view.size(); } - return std::accumulate(view.child_begin(), view.child_end(), total, - [](std::size_t t, cudf::column_view const &v) { - return t + calc_device_memory_size(v); - }); + return std::accumulate( + view.child_begin(), view.child_end(), total, + [](std::size_t t, cudf::column_view const &v) { return t + calc_device_memory_size(v); }); } } // anonymous namespace @@ -158,8 +158,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_replaceNullsColumn(JNIEnv } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVV(JNIEnv *env, jclass, - jlong j_pred_vec, - jlong j_true_vec, + jlong j_pred_vec, jlong j_true_vec, jlong j_false_vec) { JNI_NULL_CHECK(env, j_pred_vec, "predicate column is null", 0); JNI_NULL_CHECK(env, j_true_vec, "true column is null", 0); @@ -176,8 +175,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVV(JNIEnv *env, jcl } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseVS(JNIEnv *env, jclass, - jlong j_pred_vec, - jlong j_true_vec, + jlong j_pred_vec, jlong j_true_vec, jlong j_false_scalar) { JNI_NULL_CHECK(env, j_pred_vec, "predicate column is null", 0); JNI_NULL_CHECK(env, j_true_vec, "true column is null", 0); @@ -230,24 +228,21 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_ifElseSS(JNIEnv *env, jcl CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getElement(JNIEnv *env, jclass, - jlong from, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getElement(JNIEnv *env, jclass, jlong from, jint index) { JNI_NULL_CHECK(env, from, "from column is null", 0); try { cudf::jni::auto_set_device(env); auto from_vec = reinterpret_cast(from); - std::unique_ptr result = - cudf::get_element(*from_vec, index); + std::unique_ptr result = cudf::get_element(*from_vec, index); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_reduce(JNIEnv *env, jclass, - jlong j_col_view, - jlong j_agg, - jint j_dtype, jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_reduce(JNIEnv *env, jclass, jlong j_col_view, + jlong j_agg, jint j_dtype, + jint scale) { JNI_NULL_CHECK(env, j_col_view, "column view is null", 0); JNI_NULL_CHECK(env, j_agg, "aggregation is null", 0); try { @@ -282,9 +277,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_quantile(JNIEnv *env, jcl } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_rollingWindow( - JNIEnv *env, jclass clazz, jlong input_col, jlong default_output_col, - jint min_periods, jlong agg_ptr, jint preceding, - jint following, jlong preceding_col, jlong following_col) { + JNIEnv *env, jclass clazz, jlong input_col, jlong default_output_col, jint min_periods, + jlong agg_ptr, jint preceding, jint following, jlong preceding_col, jlong following_col) { JNI_NULL_CHECK(env, input_col, "native handle is null", 0); JNI_NULL_CHECK(env, agg_ptr, "aggregation handle is null", 0); @@ -295,27 +289,28 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_rollingWindow( reinterpret_cast(default_output_col); cudf::column_view *n_preceding_col = reinterpret_cast(preceding_col); cudf::column_view *n_following_col = reinterpret_cast(following_col); - cudf::rolling_aggregation * agg = dynamic_cast(reinterpret_cast(agg_ptr)); + cudf::rolling_aggregation *agg = + dynamic_cast(reinterpret_cast(agg_ptr)); JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", 0); std::unique_ptr ret; if (n_default_output_col != nullptr) { if (n_preceding_col != nullptr && n_following_col != nullptr) { - CUDF_FAIL("A default output column is not currently supported with variable length preceding and following"); - //ret = cudf::rolling_window(*n_input_col, *n_default_output_col, + CUDF_FAIL("A default output column is not currently supported with variable length " + "preceding and following"); + // ret = cudf::rolling_window(*n_input_col, *n_default_output_col, // *n_preceding_col, *n_following_col, min_periods, agg); } else { - ret = cudf::rolling_window(*n_input_col, *n_default_output_col, - preceding, following, min_periods, *agg); + ret = cudf::rolling_window(*n_input_col, *n_default_output_col, preceding, following, + min_periods, *agg); } } else { if (n_preceding_col != nullptr && n_following_col != nullptr) { - ret = cudf::rolling_window(*n_input_col, *n_preceding_col, *n_following_col, - min_periods, *agg); + ret = cudf::rolling_window(*n_input_col, *n_preceding_col, *n_following_col, min_periods, + *agg); } else { - ret = cudf::rolling_window(*n_input_col, preceding, following, min_periods, - *agg); + ret = cudf::rolling_window(*n_input_col, preceding, following, min_periods, *agg); } } return reinterpret_cast(ret.release()); @@ -387,8 +382,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_listContains(JNIEnv *env, } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_listContainsColumn(JNIEnv *env, jclass, - jlong column_view, - jlong lookup_key_cv) { + jlong column_view, + jlong lookup_key_cv) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, lookup_key_cv, "lookup column is null", 0); try { @@ -474,7 +469,7 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_ColumnView_split(JNIEnv *env, j cudf::jni::native_jlongArray n_result(env, result.size()); for (size_t i = 0; i < result.size(); i++) { - cudf::column_view const * c = new cudf::column_view(result[i]); + cudf::column_view const *c = new cudf::column_view(result[i]); n_result[i] = reinterpret_cast(c); } return n_result.get_jArray(); @@ -521,8 +516,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_byteCount(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_findAndReplaceAll(JNIEnv *env, - jclass clazz, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_findAndReplaceAll(JNIEnv *env, jclass clazz, jlong old_values_handle, jlong new_values_handle, jlong input_handle) { @@ -609,23 +603,21 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_unaryOperation(JNIEnv *en CATCH_STD(env, 0); } - -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_round(JNIEnv *env, jclass, - jlong input_ptr, jint decimal_places, - jint rounding_method) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_round(JNIEnv *env, jclass, jlong input_ptr, + jint decimal_places, + jint rounding_method) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *input = reinterpret_cast(input_ptr); - cudf::rounding_method method = static_cast(rounding_method); - std::unique_ptr ret = cudf::round(*input, decimal_places, method); - return reinterpret_cast(ret.release()); - } - CATCH_STD(env, 0); -} - -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, - jlong input_ptr) { + try { + cudf::jni::auto_set_device(env); + cudf::column_view *input = reinterpret_cast(input_ptr); + cudf::rounding_method method = static_cast(rounding_method); + std::unique_ptr ret = cudf::round(*input, decimal_places, method); + return reinterpret_cast(ret.release()); + } + CATCH_STD(env, 0); +} + +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -636,8 +628,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_year(JNIEnv *env, jclass, CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_month(JNIEnv *env, jclass, - jlong input_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_month(JNIEnv *env, jclass, jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -659,8 +650,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_day(JNIEnv *env, jclass, CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_hour(JNIEnv *env, jclass, - jlong input_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_hour(JNIEnv *env, jclass, jlong input_ptr) { JNI_NULL_CHECK(env, input_ptr, "input is null", 0); try { cudf::jni::auto_set_device(env); @@ -731,9 +721,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_dayOfYear(JNIEnv *env, jc CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclass, - jlong handle, jint type, - jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclass, jlong handle, + jint type, jint scale) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { cudf::jni::auto_set_device(env); @@ -746,13 +735,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas } if (n_data_type.id() == cudf::type_id::STRING) { switch (column->type().id()) { - case cudf::type_id::BOOL8: - result = cudf::strings::from_booleans(*column); - break; + case cudf::type_id::BOOL8: result = cudf::strings::from_booleans(*column); break; case cudf::type_id::FLOAT32: - case cudf::type_id::FLOAT64: - result = cudf::strings::from_floats(*column); - break; + case cudf::type_id::FLOAT64: result = cudf::strings::from_floats(*column); break; case cudf::type_id::INT8: case cudf::type_id::UINT8: case cudf::type_id::INT16: @@ -760,24 +745,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas case cudf::type_id::INT32: case cudf::type_id::UINT32: case cudf::type_id::INT64: - case cudf::type_id::UINT64: - result = cudf::strings::from_integers(*column); - break; + case cudf::type_id::UINT64: result = cudf::strings::from_integers(*column); break; case cudf::type_id::DECIMAL32: - case cudf::type_id::DECIMAL64: - result = cudf::strings::from_fixed_point(*column); - break; + case cudf::type_id::DECIMAL64: result = cudf::strings::from_fixed_point(*column); break; default: JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Invalid data type", 0); } } else if (column->type().id() == cudf::type_id::STRING) { switch (n_data_type.id()) { - case cudf::type_id::BOOL8: - result = cudf::strings::to_booleans(*column); - break; + case cudf::type_id::BOOL8: result = cudf::strings::to_booleans(*column); break; case cudf::type_id::FLOAT32: - case cudf::type_id::FLOAT64: - result = cudf::strings::to_floats(*column, n_data_type); - break; + case cudf::type_id::FLOAT64: result = cudf::strings::to_floats(*column, n_data_type); break; case cudf::type_id::INT8: case cudf::type_id::UINT8: case cudf::type_id::INT16: @@ -800,30 +777,26 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas // "reinterpret" casting will be supported via https://github.com/rapidsai/cudf/pull/5358 if (n_data_type.id() == cudf::type_id::TIMESTAMP_DAYS) { if (column->type().id() != cudf::type_id::INT32) { - JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Numeric cast to TIMESTAMP_DAYS requires INT32", 0); + JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", + "Numeric cast to TIMESTAMP_DAYS requires INT32", 0); } } else { if (column->type().id() != cudf::type_id::INT64) { - JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Numeric cast to non-day timestamp requires INT64", 0); + JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", + "Numeric cast to non-day timestamp requires INT64", 0); } } cudf::data_type duration_type = cudf::jni::timestamp_to_duration(n_data_type); - cudf::column_view duration_view = cudf::column_view(duration_type, - column->size(), - column->head(), - column->null_mask(), - column->null_count()); + cudf::column_view duration_view = cudf::column_view( + duration_type, column->size(), column->head(), column->null_mask(), column->null_count()); result = cudf::cast(duration_view, n_data_type); } else if (cudf::is_timestamp(column->type()) && cudf::is_numeric(n_data_type)) { // This is a temporary workaround to allow Java to cast from timestamp types to integral types // without forcing an intermediate duration column to be manifested. Ultimately this style of // "reinterpret" casting will be supported via https://github.com/rapidsai/cudf/pull/5358 cudf::data_type duration_type = cudf::jni::timestamp_to_duration(column->type()); - cudf::column_view duration_view = cudf::column_view(duration_type, - column->size(), - column->head(), - column->null_mask(), - column->null_count()); + cudf::column_view duration_view = cudf::column_view( + duration_type, column->size(), column->head(), column->null_mask(), column->null_count()); result = cudf::cast(duration_view, n_data_type); } else { result = cudf::cast(*column, n_data_type); @@ -833,9 +806,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitCastTo(JNIEnv *env, jclass, - jlong handle, jint type, - jint scale) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitCastTo(JNIEnv *env, jclass, jlong handle, + jint type, jint scale) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { cudf::jni::auto_set_device(env); @@ -881,7 +853,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringTimestampToTimestam } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isTimestamp(JNIEnv *env, jclass, - jlong handle, jstring formatObj) { + jlong handle, + jstring formatObj) { JNI_NULL_CHECK(env, handle, "column is null", 0); JNI_NULL_CHECK(env, formatObj, "format is null", 0); @@ -891,8 +864,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isTimestamp(JNIEnv *env, cudf::column_view *column = reinterpret_cast(handle); cudf::strings_column_view strings_column(*column); - std::unique_ptr result = cudf::strings::is_timestamp( - strings_column, format.get()); + std::unique_ptr result = + cudf::strings::is_timestamp(strings_column, format.get()); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -930,8 +903,7 @@ JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_ColumnView_containsScalar(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_containsVector(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_containsVector(JNIEnv *env, jobject j_object, jlong j_haystack_handle, jlong j_needle_handle) { JNI_NULL_CHECK(env, j_haystack_handle, "haystack vector is null", false); @@ -981,8 +953,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringStartWith(JNIEnv *e CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env, jobject j_object, jlong j_view_handle, jlong comp_string) { JNI_NULL_CHECK(env, j_view_handle, "column is null", false); @@ -1000,8 +971,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringEndWith(JNIEnv *env CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringContains(JNIEnv *env, - jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringContains(JNIEnv *env, jobject j_object, jlong j_view_handle, jlong comp_string) { JNI_NULL_CHECK(env, j_view_handle, "column is null", false); @@ -1069,8 +1039,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_binaryOpVV(JNIEnv *env, j cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation( - *lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1101,8 +1070,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_binaryOpVS(JNIEnv *env, j cudf::data_type n_data_type = cudf::jni::make_data_type(out_dtype, scale); cudf::binary_operator op = static_cast(int_op); - std::unique_ptr result = cudf::binary_operation( - *lhs, *rhs, op, n_data_type); + std::unique_ptr result = cudf::binary_operation(*lhs, *rhs, op, n_data_type); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1147,8 +1115,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringColumn(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringLocate(JNIEnv *env, jclass, jlong column_view, - jlong substring, - jint start, jint end) { + jlong substring, jint start, + jint end) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, substring, "target string scalar is null", 0); try { @@ -1165,8 +1133,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_substringLocate(JNIEnv *e JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplace(JNIEnv *env, jclass, jlong column_view, - jlong target, - jlong replace) { + jlong target, jlong replace) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, target, "target string scalar is null", 0); JNI_NULL_CHECK(env, replace, "replace string scalar is null", 0); @@ -1215,11 +1182,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_mapContains(JNIEnv *env, CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs(JNIEnv *env, - jclass, - jlong column_view, - jstring patternObj, - jstring replaceObj) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs( + JNIEnv *env, jclass, jlong column_view, jstring patternObj, jstring replaceObj) { JNI_NULL_CHECK(env, column_view, "column is null", 0); JNI_NULL_CHECK(env, patternObj, "pattern string is null", 0); @@ -1231,8 +1195,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringReplaceWithBackrefs cudf::jni::native_jstring ss_pattern(env, patternObj); cudf::jni::native_jstring ss_replace(env, replaceObj); - std::unique_ptr result = cudf::strings::replace_with_backrefs( - scv, ss_pattern.get(), ss_replace.get()); + std::unique_ptr result = + cudf::strings::replace_with_backrefs(scv, ss_pattern.get(), ss_replace.get()); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); @@ -1254,11 +1218,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_zfill(JNIEnv *env, jclass CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_pad(JNIEnv *env, - jclass, - jlong column_view, - jint j_width, - jint j_side, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_pad(JNIEnv *env, jclass, jlong column_view, + jint j_width, jint j_side, jstring fill_char) { JNI_NULL_CHECK(env, column_view, "column is null", 0); @@ -1357,11 +1318,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_normalizeNANsAndZeros(JNI CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidity(JNIEnv *env, - jobject j_object, - jlong base_column, - jlongArray column_handles, - jint bin_op) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidity( + JNIEnv *env, jobject j_object, jlong base_column, jlongArray column_handles, jint bin_op) { JNI_NULL_CHECK(env, base_column, "base column native handle is null", 0); JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0); try { @@ -1383,15 +1341,14 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit cudf::table_view *input_table = new cudf::table_view(column_views); cudf::binary_operator op = static_cast(bin_op); - switch(op) { + switch (op) { case cudf::binary_operator::BITWISE_AND: copy->set_null_mask(cudf::bitmask_and(*input_table)); break; case cudf::binary_operator::BITWISE_OR: copy->set_null_mask(cudf::bitmask_or(*input_table)); break; - default: - JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Unsupported merge operation", 0); + default: JNI_THROW_NEW(env, cudf::jni::ILLEGAL_ARG_CLASS, "Unsupported merge operation", 0); } return reinterpret_cast(copy.release()); @@ -1404,11 +1361,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit // should typically only be called from the CudfColumn inner class. //////// -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv *env, - jclass, jint j_type, - jint scale, jlong j_data, - jlong j_data_size, - jlong j_offset, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView( + JNIEnv *env, jclass, jint j_type, jint scale, jlong j_data, jlong j_data_size, jlong j_offset, jlong j_valid, jint j_null_count, jint size, jlongArray j_children) { try { @@ -1426,7 +1380,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv if (n_type == cudf::type_id::STRING) { if (size == 0) { - ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0)); + ret.reset( + new cudf::column_view(cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0)); } else { JNI_NULL_CHECK(env, j_offset, "offset is null", 0); // This must be kept in sync with how string columns are created @@ -1450,20 +1405,21 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv offsets_size = size + 1; offsets = reinterpret_cast(j_offset); } - cudf::column_view offsets_column(cudf::data_type{cudf::type_id::INT32}, offsets_size, offsets); + cudf::column_view offsets_column(cudf::data_type{cudf::type_id::INT32}, offsets_size, + offsets); ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::LIST}, size, nullptr, valid, - j_null_count, 0, {offsets_column, *children[0]})); - } else if (n_type == cudf::type_id::STRUCT) { - JNI_NULL_CHECK(env, j_children, "children of a struct are null", 0); - cudf::jni::native_jpointerArray children(env, j_children); - std::vector children_vector(children.size()); - for (int i = 0; i < children.size(); i++) { - children_vector[i] = *children[i]; - } - ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, size, nullptr, valid, - j_null_count, 0, children_vector)); - } else { - ret.reset(new cudf::column_view(n_data_type, size, data, valid, j_null_count)); + j_null_count, 0, {offsets_column, *children[0]})); + } else if (n_type == cudf::type_id::STRUCT) { + JNI_NULL_CHECK(env, j_children, "children of a struct are null", 0); + cudf::jni::native_jpointerArray children(env, j_children); + std::vector children_vector(children.size()); + for (int i = 0; i < children.size(); i++) { + children_vector[i] = *children[i]; + } + ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, size, nullptr, valid, + j_null_count, 0, children_vector)); + } else { + ret.reset(new cudf::column_view(n_data_type, size, data, valid, j_null_count)); } return reinterpret_cast(ret.release()); @@ -1471,8 +1427,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeCudfColumnView(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *env, - jobject j_object, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *env, jobject j_object, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1483,8 +1438,7 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeId(JNIEnv *en CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv *env, - jclass, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1495,8 +1449,7 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeTypeScale(JNIEnv CATCH_STD(env, 0); } -JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeRowCount(JNIEnv *env, - jclass, +JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeRowCount(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1543,7 +1496,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeDataAddress(JNIE cudf::column_view data_view = view.chars(); result = reinterpret_cast(data_view.data()); } - } else if(column->type().id() != cudf::type_id::LIST && column->type().id() != cudf::type_id::STRUCT) { + } else if (column->type().id() != cudf::type_id::LIST && + column->type().id() != cudf::type_id::STRUCT) { result = reinterpret_cast(column->data()); } return result; @@ -1564,7 +1518,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeDataLength(JNIEn cudf::column_view data_view = view.chars(); result = data_view.size(); } - } else if(column->type().id() != cudf::type_id::LIST && column->type().id() != cudf::type_id::STRUCT) { + } else if (column->type().id() != cudf::type_id::LIST && + column->type().id() != cudf::type_id::STRUCT) { result = cudf::size_of(column->type()) * column->size(); } return result; @@ -1576,45 +1531,49 @@ JNIEXPORT jint JNICALL Java_ai_rapids_cudf_ColumnView_getNativeNumChildren(JNIEn jobject j_object, jlong handle) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *column = reinterpret_cast(handle); - // Strings has children(offsets and chars) but not a nested child() we care about here. - if (column->type().id() == cudf::type_id::STRING) { - return 0; - } else if (column->type().id() == cudf::type_id::LIST) { - // first child is always offsets in lists which we do not want to count here - return static_cast(column->num_children() - 1); - } else if (column->type().id() == cudf::type_id::STRUCT) { - return static_cast(column->num_children()); - } else { - return 0; - } + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + cudf::column_view *column = reinterpret_cast(handle); + // Strings has children(offsets and chars) but not a nested child() we care about here. + if (column->type().id() == cudf::type_id::STRING) { + return 0; + } else if (column->type().id() == cudf::type_id::LIST) { + // first child is always offsets in lists which we do not want to count here + return static_cast(column->num_children() - 1); + } else if (column->type().id() == cudf::type_id::STRUCT) { + return static_cast(column->num_children()); + } else { + return 0; } - CATCH_STD(env, 0); - + } + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getChildCvPointer(JNIEnv *env, jobject j_object, - jlong handle, jint child_index) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - cudf::column_view *column = reinterpret_cast(handle); - if (column->type().id() == cudf::type_id::LIST) { - std::unique_ptr view = std::make_unique(*column); - // first child is always offsets which we do not want to get from this call - std::unique_ptr next_view = std::make_unique(column->child(1 + child_index)); - return reinterpret_cast(next_view.release()); - } else { - std::unique_ptr view = std::make_unique(*column); - std::unique_ptr next_view = std::make_unique(column->child(child_index)); - return reinterpret_cast(next_view.release()); - } + jlong handle, + jint child_index) { + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + cudf::column_view *column = reinterpret_cast(handle); + if (column->type().id() == cudf::type_id::LIST) { + std::unique_ptr view = + std::make_unique(*column); + // first child is always offsets which we do not want to get from this call + std::unique_ptr next_view = + std::make_unique(column->child(1 + child_index)); + return reinterpret_cast(next_view.release()); + } else { + std::unique_ptr view = + std::make_unique(*column); + std::unique_ptr next_view = + std::make_unique(column->child(child_index)); + return reinterpret_cast(next_view.release()); } - CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeOffsetsAddress(JNIEnv *env, jclass, @@ -1667,8 +1626,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeOffsetsLength(JN CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress(JNIEnv *env, - jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1679,8 +1637,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityAddress( CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityLength(JNIEnv *env, - jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidityLength(JNIEnv *env, jclass, jlong handle) { JNI_NULL_CHECK(env, handle, "native handle is null", 0); try { @@ -1707,13 +1664,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getNativeValidPointerSize JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getDeviceMemorySize(JNIEnv *env, jclass, jlong handle) { - JNI_NULL_CHECK(env, handle, "native handle is null", 0); - try { - cudf::jni::auto_set_device(env); - auto view = reinterpret_cast(handle); - return calc_device_memory_size(*view); - } - CATCH_STD(env, 0); + JNI_NULL_CHECK(env, handle, "native handle is null", 0); + try { + cudf::jni::auto_set_device(env); + auto view = reinterpret_cast(handle); + return calc_device_memory_size(*view); + } + CATCH_STD(env, 0); } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_clamper(JNIEnv *env, jobject j_object, @@ -1772,7 +1729,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeStructView(JNIEnv *en children_vector[i] = *children[i]; } ret.reset(new cudf::column_view(cudf::data_type{cudf::type_id::STRUCT}, row_count, nullptr, - nullptr, 0, 0, children_vector)); + nullptr, 0, 0, children_vector)); return reinterpret_cast(ret.release()); } @@ -1817,7 +1774,6 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_nansToNulls(JNIEnv *env, CATCH_STD(env, 0) } - JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isFloat(JNIEnv *env, jobject j_object, jlong handle) { @@ -1847,8 +1803,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isInteger(JNIEnv *env, jo } JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isIntegerWithType(JNIEnv *env, jobject, - jlong handle, - jint j_dtype, + jlong handle, jint j_dtype, jint scale) { JNI_NULL_CHECK(env, handle, "native view handle is null", 0) @@ -1863,7 +1818,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_isIntegerWithType(JNIEnv CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv *env, jobject j_object, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv *env, + jobject j_object, jlong handle) { JNI_NULL_CHECK(env, handle, "native view handle is null", 0) @@ -1878,15 +1834,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_copyColumnViewToCV(JNIEnv CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env, jclass, - jlong j_view_handle, jlong j_scalar_handle) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env, jclass, + jlong j_view_handle, + jlong j_scalar_handle) { - JNI_NULL_CHECK(env, j_view_handle, "view cannot be null", 0); - JNI_NULL_CHECK(env, j_scalar_handle, "path cannot be null", 0); + JNI_NULL_CHECK(env, j_view_handle, "view cannot be null", 0); + JNI_NULL_CHECK(env, j_scalar_handle, "path cannot be null", 0); try { cudf::jni::auto_set_device(env); - cudf::column_view* n_column_view = reinterpret_cast(j_view_handle); + cudf::column_view *n_column_view = reinterpret_cast(j_view_handle); cudf::strings_column_view n_strings_col_view(*n_column_view); cudf::string_scalar *n_scalar_path = reinterpret_cast(j_scalar_handle); @@ -1895,66 +1852,57 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_getJSONObject(JNIEnv *env return reinterpret_cast(result.release()); } CATCH_STD(env, 0) - } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringConcatenationListElementsSepCol(JNIEnv *env, jclass, - jlong column_handle, - jlong sep_handle, - jlong separator_narep, - jlong col_narep, - jboolean separate_nulls, - jboolean empty_string_output_if_empty_list) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringConcatenationListElementsSepCol( + JNIEnv *env, jclass, jlong column_handle, jlong sep_handle, jlong separator_narep, + jlong col_narep, jboolean separate_nulls, jboolean empty_string_output_if_empty_list) { JNI_NULL_CHECK(env, column_handle, "column handle is null", 0); JNI_NULL_CHECK(env, sep_handle, "separator column handle is null", 0); JNI_NULL_CHECK(env, separator_narep, "separator narep string scalar object is null", 0); JNI_NULL_CHECK(env, col_narep, "column narep string scalar object is null", 0); try { cudf::jni::auto_set_device(env); - const auto& separator_narep_scalar = *reinterpret_cast(separator_narep); - const auto& col_narep_scalar = *reinterpret_cast(col_narep); - auto null_policy = separate_nulls ? cudf::strings::separator_on_nulls::YES - : cudf::strings::separator_on_nulls::NO; - auto empty_list_output = - empty_string_output_if_empty_list ? cudf::strings::output_if_empty_list::EMPTY_STRING - : cudf::strings::output_if_empty_list::NULL_ELEMENT; + const auto &separator_narep_scalar = *reinterpret_cast(separator_narep); + const auto &col_narep_scalar = *reinterpret_cast(col_narep); + auto null_policy = separate_nulls ? cudf::strings::separator_on_nulls::YES : + cudf::strings::separator_on_nulls::NO; + auto empty_list_output = empty_string_output_if_empty_list ? + cudf::strings::output_if_empty_list::EMPTY_STRING : + cudf::strings::output_if_empty_list::NULL_ELEMENT; cudf::column_view *column = reinterpret_cast(sep_handle); cudf::strings_column_view strings_column(*column); cudf::column_view *cv = reinterpret_cast(column_handle); cudf::lists_column_view lcv(*cv); std::unique_ptr result = - cudf::strings::join_list_elements(lcv, strings_column, separator_narep_scalar, - col_narep_scalar, null_policy, empty_list_output); + cudf::strings::join_list_elements(lcv, strings_column, separator_narep_scalar, + col_narep_scalar, null_policy, empty_list_output); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringConcatenationListElements(JNIEnv *env, jclass, - jlong column_handle, - jlong separator, - jlong narep, - jboolean separate_nulls, - jboolean empty_string_output_if_empty_list) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_stringConcatenationListElements( + JNIEnv *env, jclass, jlong column_handle, jlong separator, jlong narep, jboolean separate_nulls, + jboolean empty_string_output_if_empty_list) { JNI_NULL_CHECK(env, column_handle, "column handle is null", 0); JNI_NULL_CHECK(env, separator, "separator string scalar object is null", 0); JNI_NULL_CHECK(env, narep, "separator narep string scalar object is null", 0); try { cudf::jni::auto_set_device(env); - const auto& separator_scalar = *reinterpret_cast(separator); - const auto& narep_scalar = *reinterpret_cast(narep); - auto null_policy = separate_nulls ? cudf::strings::separator_on_nulls::YES - : cudf::strings::separator_on_nulls::NO; - auto empty_list_output = - empty_string_output_if_empty_list ? cudf::strings::output_if_empty_list::EMPTY_STRING - : cudf::strings::output_if_empty_list::NULL_ELEMENT; + const auto &separator_scalar = *reinterpret_cast(separator); + const auto &narep_scalar = *reinterpret_cast(narep); + auto null_policy = separate_nulls ? cudf::strings::separator_on_nulls::YES : + cudf::strings::separator_on_nulls::NO; + auto empty_list_output = empty_string_output_if_empty_list ? + cudf::strings::output_if_empty_list::EMPTY_STRING : + cudf::strings::output_if_empty_list::NULL_ELEMENT; cudf::column_view *cv = reinterpret_cast(column_handle); cudf::lists_column_view lcv(*cv); - std::unique_ptr result = - cudf::strings::join_list_elements(lcv, separator_scalar, narep_scalar, - null_policy, empty_list_output); + std::unique_ptr result = cudf::strings::join_list_elements( + lcv, separator_scalar, narep_scalar, null_policy, empty_list_output); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/ContiguousTableJni.cpp b/java/src/main/native/src/ContiguousTableJni.cpp index 352256af450..f592d80834c 100644 --- a/java/src/main/native/src/ContiguousTableJni.cpp +++ b/java/src/main/native/src/ContiguousTableJni.cpp @@ -93,7 +93,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ContiguousTable_createPackedMetadata auto data_addr = reinterpret_cast(j_buffer_addr); auto data_size = static_cast(j_buffer_length); auto metadata_ptr = - new cudf::packed_columns::metadata(cudf::pack_metadata(*table, data_addr, data_size)); + new cudf::packed_columns::metadata(cudf::pack_metadata(*table, data_addr, data_size)); return reinterpret_cast(metadata_ptr); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/CudaJni.cpp b/java/src/main/native/src/CudaJni.cpp index 987ff87f8ac..4f1239a8966 100644 --- a/java/src/main/native/src/CudaJni.cpp +++ b/java/src/main/native/src/CudaJni.cpp @@ -15,6 +15,7 @@ */ #include + #include "jni_utils.hpp" namespace { @@ -49,7 +50,7 @@ void auto_set_device(JNIEnv *env) { } /** Fills all the bytes in the buffer 'buf' with 'value'. */ -void device_memset_async(JNIEnv *env, rmm::device_buffer& buf, char value) { +void device_memset_async(JNIEnv *env, rmm::device_buffer &buf, char value) { cudaError_t cuda_status = cudaMemsetAsync((void *)buf.data(), value, buf.size()); jni_cuda_check(env, cuda_status); } diff --git a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp index 4a38516db92..16b8630b04a 100644 --- a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp +++ b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp @@ -14,32 +14,26 @@ * limitations under the License. */ -#include - -#include -#include #include #include +#include #include #include +#include +#include + #include "jni_utils.hpp" extern "C" { -JNIEXPORT jobject JNICALL -Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_wrapRangeInBuffer(JNIEnv *env, jclass, - jlong addr, - jlong len) { +JNIEXPORT jobject JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_wrapRangeInBuffer( + JNIEnv *env, jclass, jlong addr, jlong len) { return env->NewDirectByteBuffer(reinterpret_cast(addr), len); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap(JNIEnv* env, jclass, - jstring jpath, - jint mode, - jlong offset, - jlong length) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap( + JNIEnv *env, jclass, jstring jpath, jint mode, jlong offset, jlong length) { JNI_NULL_CHECK(env, jpath, "path is null", 0); JNI_ARG_CHECK(env, (mode == 0 || mode == 1), "bad mode value", 0); try { @@ -50,29 +44,31 @@ Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_mmap(JNIEnv* env, jclass, cudf::jni::throw_java_exception(env, "java/io/IOException", strerror(errno)); } - void* address = mmap(NULL, length, - (mode == 0) ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); + void *address = mmap(NULL, length, (mode == 0) ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, + fd, offset); if (address == MAP_FAILED) { - char const* error_msg = strerror(errno); + char const *error_msg = strerror(errno); close(fd); cudf::jni::throw_java_exception(env, "java/io/IOException", error_msg); } close(fd); return reinterpret_cast(address); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_munmap(JNIEnv* env, jclass, - jlong address, jlong length) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_HostMemoryBufferNativeUtils_munmap(JNIEnv *env, jclass, + jlong address, + jlong length) { JNI_NULL_CHECK(env, address, "address is NULL", ); try { - int rc = munmap(reinterpret_cast(address), length); + int rc = munmap(reinterpret_cast(address), length); if (rc == -1) { cudf::jni::throw_java_exception(env, "java/io/IOException", strerror(errno)); } - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } } // extern "C" diff --git a/java/src/main/native/src/NvcompJni.cpp b/java/src/main/native/src/NvcompJni.cpp index 9ef3b1f958a..5ba87221597 100644 --- a/java/src/main/native/src/NvcompJni.cpp +++ b/java/src/main/native/src/NvcompJni.cpp @@ -29,8 +29,7 @@ constexpr char const *UNSUPPORTED_CLASS = "java/lang/UnsupportedOperationExcepti void check_nvcomp_status(JNIEnv *env, nvcompError_t status) { switch (status) { - case nvcompSuccess: - break; + case nvcompSuccess: break; case nvcompErrorInvalidValue: cudf::jni::throw_java_exception(env, ILLEGAL_ARG_CLASS, "nvcomp invalid value"); break; @@ -50,10 +49,8 @@ void check_nvcomp_status(JNIEnv *env, nvcompError_t status) { extern "C" { -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jlong jstream) { try { cudf::jni::auto_set_device(env); void *metadata_ptr; @@ -62,121 +59,114 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetMetadata(JNIEnv *env, jclass, &metadata_ptr, stream); check_nvcomp_status(env, status); return reinterpret_cast(metadata_ptr); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressDestroyMetadata(JNIEnv *env, jclass, - jlong metadata_ptr) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressDestroyMetadata( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); nvcompDecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetTempSize(JNIEnv *env, jclass, - jlong metadata_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetTempSize( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t temp_size; auto status = nvcompDecompressGetTempSize(reinterpret_cast(metadata_ptr), &temp_size); check_nvcomp_status(env, status); return temp_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetOutputSize(JNIEnv *env, jclass, - jlong metadata_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressGetOutputSize( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t out_size; auto status = nvcompDecompressGetOutputSize(reinterpret_cast(metadata_ptr), &out_size); check_nvcomp_status(env, status); return out_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressAsync(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jlong temp_ptr, jlong temp_size, - jlong metadata_ptr, - jlong out_ptr, jlong out_size, jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_decompressAsync( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jlong temp_ptr, jlong temp_size, + jlong metadata_ptr, jlong out_ptr, jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto stream = reinterpret_cast(jstream); auto status = nvcompDecompressAsync(reinterpret_cast(in_ptr), in_size, reinterpret_cast(temp_ptr), temp_size, reinterpret_cast(metadata_ptr), - reinterpret_cast(out_ptr), out_size, - stream); + reinterpret_cast(out_ptr), out_size, stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jboolean JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Data(JNIEnv *env, jclass, jlong in_ptr, jlong in_size) { +JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Data(JNIEnv *env, jclass, + jlong in_ptr, + jlong in_size) { try { cudf::jni::auto_set_device(env); return LZ4IsData(reinterpret_cast(in_ptr), in_size); - } CATCH_STD(env, 0) + } + CATCH_STD(env, 0) } -JNIEXPORT jboolean JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Metadata(JNIEnv *env, jclass, jlong metadata_ptr) { +JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Metadata(JNIEnv *env, jclass, + jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); return LZ4IsMetadata(reinterpret_cast(metadata_ptr)); - } CATCH_STD(env, 0) + } + CATCH_STD(env, 0) } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetTempSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetTempSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; size_t temp_size; - auto status = nvcompLZ4CompressGetTempSize(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, &temp_size); + auto status = nvcompLZ4CompressGetTempSize(reinterpret_cast(in_ptr), in_size, comp_type, + &opts, &temp_size); check_nvcomp_status(env, status); return temp_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetOutputSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, - jboolean compute_exact) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressGetOutputSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size, + jlong temp_ptr, jlong temp_size, jboolean compute_exact) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; size_t out_size; - auto status = nvcompLZ4CompressGetOutputSize(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - &out_size, compute_exact); + auto status = nvcompLZ4CompressGetOutputSize( + reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, &out_size, compute_exact); check_nvcomp_status(env, status); return out_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jlong chunk_size, + jlong temp_ptr, jlong temp_size, jlong out_ptr, jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -184,27 +174,23 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4Compress(JNIEnv *env, jclass, opts.chunk_size = chunk_size; auto stream = reinterpret_cast(jstream); size_t compressed_size = out_size; - auto status = nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), &compressed_size, - stream); + auto status = + nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), &compressed_size, stream); check_nvcomp_status(env, status); if (cudaStreamSynchronize(stream) != cudaSuccess) { JNI_THROW_NEW(env, NVCOMP_CUDA_ERROR_CLASS, "Error synchronizing stream", 0); } return compressed_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync(JNIEnv *env, jclass, - jlong compressed_output_ptr, - jlong in_ptr, jlong in_size, - jint input_type, jlong chunk_size, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync( + JNIEnv *env, jclass, jlong compressed_output_ptr, jlong in_ptr, jlong in_size, jint input_type, + jlong chunk_size, jlong temp_ptr, jlong temp_size, jlong out_ptr, jlong out_size, + jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -213,20 +199,17 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync(JNIEnv *env, jclass, auto stream = reinterpret_cast(jstream); auto compressed_size_ptr = reinterpret_cast(compressed_output_ptr); *compressed_size_ptr = out_size; - auto status = nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), compressed_size_ptr, - stream); + auto status = + nvcompLZ4CompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), compressed_size_ptr, stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong jstream) { try { cudf::jni::auto_set_device(env); @@ -240,65 +223,57 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetMetadata(JNIEnv* env std::back_inserter(sizes), [](jlong x) -> size_t { return static_cast(x); }); - void* metadata_ptr = nullptr; + void *metadata_ptr = nullptr; auto stream = reinterpret_cast(jstream); auto status = nvcompBatchedLZ4DecompressGetMetadata(input_ptrs.data(), sizes.data(), input_ptrs.size(), &metadata_ptr, stream); check_nvcomp_status(env, status); return reinterpret_cast(metadata_ptr); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressDestroyMetadata(JNIEnv* env, jclass, - jlong metadata_ptr) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressDestroyMetadata( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); - nvcompBatchedLZ4DecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); - } CATCH_STD(env, ); + nvcompBatchedLZ4DecompressDestroyMetadata(reinterpret_cast(metadata_ptr)); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetTempSize(JNIEnv* env, jclass, - jlong metadata_ptr) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetTempSize( + JNIEnv *env, jclass, jlong metadata_ptr) { try { cudf::jni::auto_set_device(env); size_t temp_size; - auto status = nvcompBatchedLZ4DecompressGetTempSize(reinterpret_cast(metadata_ptr), - &temp_size); + auto status = + nvcompBatchedLZ4DecompressGetTempSize(reinterpret_cast(metadata_ptr), &temp_size); check_nvcomp_status(env, status); return static_cast(temp_size); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlongArray JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetOutputSize(JNIEnv* env, jclass, - jlong metadata_ptr, - jint num_outputs) { +JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressGetOutputSize( + JNIEnv *env, jclass, jlong metadata_ptr, jint num_outputs) { try { cudf::jni::auto_set_device(env); std::vector sizes(num_outputs); - auto status = nvcompBatchedLZ4DecompressGetOutputSize(reinterpret_cast(metadata_ptr), - num_outputs, - sizes.data()); + auto status = nvcompBatchedLZ4DecompressGetOutputSize(reinterpret_cast(metadata_ptr), + num_outputs, sizes.data()); check_nvcomp_status(env, status); cudf::jni::native_jlongArray jsizes(env, num_outputs); std::transform(sizes.begin(), sizes.end(), jsizes.data(), [](size_t x) -> jlong { return static_cast(x); }); return jsizes.get_jArray(); - } CATCH_STD(env, NULL); + } + CATCH_STD(env, NULL); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong temp_ptr, - jlong temp_size, - jlong metadata_ptr, - jlongArray out_ptrs, - jlongArray out_sizes, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong temp_ptr, jlong temp_size, + jlong metadata_ptr, jlongArray out_ptrs, jlongArray out_sizes, jlong jstream) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -325,23 +300,17 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4DecompressAsync(JNIEnv* env, jcla [](jlong x) -> size_t { return static_cast(x); }); auto stream = reinterpret_cast(jstream); - auto status = nvcompBatchedLZ4DecompressAsync(input_ptrs.data(), input_sizes.data(), - input_ptrs.size(), - reinterpret_cast(temp_ptr), - static_cast(temp_size), - reinterpret_cast(metadata_ptr), - output_ptrs.data(), - output_sizes.data(), - stream); + auto status = nvcompBatchedLZ4DecompressAsync( + input_ptrs.data(), input_sizes.data(), input_ptrs.size(), + reinterpret_cast(temp_ptr), static_cast(temp_size), + reinterpret_cast(metadata_ptr), output_ptrs.data(), output_sizes.data(), stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong chunk_size) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong chunk_size) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -361,16 +330,13 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize(JNIEnv* env, input_ptrs.size(), &opts, &temp_size); check_nvcomp_status(env, status); return static_cast(temp_size); - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlongArray JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize(JNIEnv* env, jclass, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong chunk_size, - jlong temp_ptr, - jlong temp_size) { +JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize( + JNIEnv *env, jclass, jlongArray in_ptrs, jlongArray in_sizes, jlong chunk_size, jlong temp_ptr, + jlong temp_size) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -386,30 +352,22 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetOutputSize(JNIEnv* env nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; std::vector output_sizes(input_ptrs.size()); - auto status = nvcompBatchedLZ4CompressGetOutputSize(input_ptrs.data(), input_sizes.data(), - input_ptrs.size(), &opts, - reinterpret_cast(temp_ptr), - static_cast(temp_size), - output_sizes.data()); + auto status = nvcompBatchedLZ4CompressGetOutputSize( + input_ptrs.data(), input_sizes.data(), input_ptrs.size(), &opts, + reinterpret_cast(temp_ptr), static_cast(temp_size), output_sizes.data()); check_nvcomp_status(env, status); cudf::jni::native_jlongArray jsizes(env, input_ptrs.size()); std::transform(output_sizes.begin(), output_sizes.end(), jsizes.data(), [](size_t x) -> jlong { return static_cast(x); }); return jsizes.get_jArray(); - } CATCH_STD(env, NULL); + } + CATCH_STD(env, NULL); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync(JNIEnv* env, jclass, - jlong compressed_sizes_out_ptr, - jlongArray in_ptrs, - jlongArray in_sizes, - jlong chunk_size, - jlong temp_ptr, - jlong temp_size, - jlongArray out_ptrs, - jlongArray out_sizes, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync( + JNIEnv *env, jclass, jlong compressed_sizes_out_ptr, jlongArray in_ptrs, jlongArray in_sizes, + jlong chunk_size, jlong temp_ptr, jlong temp_size, jlongArray out_ptrs, jlongArray out_sizes, + jlong jstream) { try { cudf::jni::auto_set_device(env); cudf::jni::native_jpointerArray input_ptrs(env, in_ptrs); @@ -431,30 +389,26 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressAsync(JNIEnv* env, jclass cudf::jni::throw_java_exception(env, NVCOMP_ERROR_CLASS, "input/output array size mismatch"); } - auto output_sizes = reinterpret_cast(compressed_sizes_out_ptr); - std::transform(output_jsizes.data(), output_jsizes.data() + output_jsizes.size(), - output_sizes, + auto output_sizes = reinterpret_cast(compressed_sizes_out_ptr); + std::transform(output_jsizes.data(), output_jsizes.data() + output_jsizes.size(), output_sizes, [](jlong x) -> size_t { return static_cast(x); }); nvcompLZ4FormatOpts opts{}; opts.chunk_size = chunk_size; auto stream = reinterpret_cast(jstream); - auto status = nvcompBatchedLZ4CompressAsync(input_ptrs.data(), input_sizes.data(), - input_ptrs.size(), &opts, - reinterpret_cast(temp_ptr), - static_cast(temp_size), - output_ptrs.data(), - output_sizes, // input/output parameter - stream); + auto status = nvcompBatchedLZ4CompressAsync( + input_ptrs.data(), input_sizes.data(), input_ptrs.size(), &opts, + reinterpret_cast(temp_ptr), static_cast(temp_size), output_ptrs.data(), + output_sizes, // input/output parameter + stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -467,16 +421,13 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetTempSize(JNIEnv *env, jc comp_type, &opts, &temp_size); check_nvcomp_status(env, status); return temp_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, - jlong temp_ptr, jlong temp_size, - jboolean compute_exact) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jboolean compute_exact) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -485,23 +436,19 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressGetOutputSize(JNIEnv *env, opts.num_deltas = num_deltas; opts.use_bp = use_bp; size_t out_size; - auto status = nvcompCascadedCompressGetOutputSize(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - &out_size, compute_exact); + auto status = nvcompCascadedCompressGetOutputSize( + reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, &out_size, compute_exact); check_nvcomp_status(env, status); return out_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress(JNIEnv *env, jclass, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress( + JNIEnv *env, jclass, jlong in_ptr, jlong in_size, jint input_type, jint num_rles, + jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jlong out_ptr, + jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -511,28 +458,23 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompress(JNIEnv *env, jclass, opts.use_bp = use_bp; auto stream = reinterpret_cast(jstream); size_t compressed_size = out_size; - auto status = nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), &compressed_size, - stream); + auto status = + nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), &compressed_size, stream); check_nvcomp_status(env, status); if (cudaStreamSynchronize(stream) != cudaSuccess) { JNI_THROW_NEW(env, NVCOMP_CUDA_ERROR_CLASS, "Error synchronizing stream", 0); } return compressed_size; - } CATCH_STD(env, 0); + } + CATCH_STD(env, 0); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync(JNIEnv *env, jclass, - jlong compressed_output_ptr, - jlong in_ptr, jlong in_size, - jint input_type, jint num_rles, - jint num_deltas, jboolean use_bp, - jlong temp_ptr, jlong temp_size, - jlong out_ptr, jlong out_size, - jlong jstream) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync( + JNIEnv *env, jclass, jlong compressed_output_ptr, jlong in_ptr, jlong in_size, jint input_type, + jint num_rles, jint num_deltas, jboolean use_bp, jlong temp_ptr, jlong temp_size, jlong out_ptr, + jlong out_size, jlong jstream) { try { cudf::jni::auto_set_device(env); auto comp_type = static_cast(input_type); @@ -543,13 +485,13 @@ Java_ai_rapids_cudf_nvcomp_NvcompJni_cascadedCompressAsync(JNIEnv *env, jclass, auto stream = reinterpret_cast(jstream); auto compressed_size_ptr = reinterpret_cast(compressed_output_ptr); *compressed_size_ptr = out_size; - auto status = nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, - comp_type, &opts, - reinterpret_cast(temp_ptr), temp_size, - reinterpret_cast(out_ptr), - compressed_size_ptr, stream); + auto status = + nvcompCascadedCompressAsync(reinterpret_cast(in_ptr), in_size, comp_type, &opts, + reinterpret_cast(temp_ptr), temp_size, + reinterpret_cast(out_ptr), compressed_size_ptr, stream); check_nvcomp_status(env, status); - } CATCH_STD(env, ); + } + CATCH_STD(env, ); } } // extern "C" diff --git a/java/src/main/native/src/NvtxRangeJni.cpp b/java/src/main/native/src/NvtxRangeJni.cpp index ea7a148fb4d..afd96632187 100644 --- a/java/src/main/native/src/NvtxRangeJni.cpp +++ b/java/src/main/native/src/NvtxRangeJni.cpp @@ -21,16 +21,15 @@ namespace { struct java_domain { - static constexpr char const* name{"Java"}; + static constexpr char const *name{"Java"}; }; } // anonymous namespace extern "C" { -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, - jstring name, jint color_bits) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, jstring name, + jint color_bits) { try { cudf::jni::native_jstring range_name(env, name); nvtx3::color range_color(static_cast(color_bits)); @@ -40,8 +39,7 @@ Java_ai_rapids_cudf_NvtxRange_push(JNIEnv *env, jclass clazz, CATCH_STD(env, ); } -JNIEXPORT void JNICALL -Java_ai_rapids_cudf_NvtxRange_pop(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_NvtxRange_pop(JNIEnv *env, jclass clazz) { try { nvtxDomainRangePop(nvtx3::domain::get()); } diff --git a/java/src/main/native/src/RmmJni.cpp b/java/src/main/native/src/RmmJni.cpp index e604fc7dd46..0105f8c43ca 100644 --- a/java/src/main/native/src/RmmJni.cpp +++ b/java/src/main/native/src/RmmJni.cpp @@ -330,12 +330,9 @@ std::shared_ptr Initialized_resource{}; extern "C" { -JNIEXPORT void JNICALL Java_ai_rapids_cudf_Rmm_initializeInternal(JNIEnv *env, jclass clazz, - jint allocation_mode, jint log_to, - jstring jpath, jlong pool_size, - jlong max_pool_size, - jlong allocation_alignment, - jlong alignment_threshold) { +JNIEXPORT void JNICALL Java_ai_rapids_cudf_Rmm_initializeInternal( + JNIEnv *env, jclass clazz, jint allocation_mode, jint log_to, jstring jpath, jlong pool_size, + jlong max_pool_size, jlong allocation_alignment, jlong alignment_threshold) { try { // make sure the CUDA device is setup in the context cudaError_t cuda_status = cudaFree(0); diff --git a/java/src/main/native/src/ScalarJni.cpp b/java/src/main/native/src/ScalarJni.cpp index f58290395e3..50e6a66ce4f 100644 --- a/java/src/main/native/src/ScalarJni.cpp +++ b/java/src/main/native/src/ScalarJni.cpp @@ -139,13 +139,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_getListAsColumnView(JNIEnv *e CATCH_STD(env, 0); } -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Scalar_getChildrenFromStructScalar(JNIEnv *env, jclass, - jlong scalar_handle) { +JNIEXPORT jlongArray JNICALL +Java_ai_rapids_cudf_Scalar_getChildrenFromStructScalar(JNIEnv *env, jclass, jlong scalar_handle) { JNI_NULL_CHECK(env, scalar_handle, "scalar handle is null", 0); try { cudf::jni::auto_set_device(env); - const auto s = reinterpret_cast(scalar_handle); - const cudf::table_view& table = s->view(); + const auto s = reinterpret_cast(scalar_handle); + const cudf::table_view &table = s->view(); cudf::jni::native_jpointerArray column_handles(env, table.num_columns()); for (int i = 0; i < table.num_columns(); i++) { column_handles[i] = new cudf::column_view(table.column(i)); @@ -502,12 +502,10 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Scalar_makeStructScalar(JNIEnv *env, cudf::jni::native_jpointerArray column_pointers(env, handles); std::vector columns; columns.reserve(column_pointers.size()); - std::transform(column_pointers.data(), - column_pointers.data() + column_pointers.size(), - std::back_inserter(columns), - [](auto const& col_ptr) { return *col_ptr; }); + std::transform(column_pointers.data(), column_pointers.data() + column_pointers.size(), + std::back_inserter(columns), [](auto const &col_ptr) { return *col_ptr; }); auto s = std::make_unique( - cudf::host_span{columns}, is_valid); + cudf::host_span{columns}, is_valid); return reinterpret_cast(s.release()); } CATCH_STD(env, 0); diff --git a/java/src/main/native/src/TableJni.cpp b/java/src/main/native/src/TableJni.cpp index 4b01745382b..ccdebbbafef 100644 --- a/java/src/main/native/src/TableJni.cpp +++ b/java/src/main/native/src/TableJni.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include #include #include @@ -44,8 +46,6 @@ #include "jni_utils.hpp" #include "row_conversion.hpp" -#include - namespace cudf { namespace jni { @@ -255,7 +255,7 @@ class native_arrow_ipc_writer_handle final { initialized = false; } - std::vector get_column_metadata(const cudf::table_view& tview) { + std::vector get_column_metadata(const cudf::table_view &tview) { if (!column_names.empty() && columns_meta.empty()) { // Rebuild the structure of column meta according to table schema. // All the tables written by this writer should share the same schema, @@ -276,7 +276,7 @@ class native_arrow_ipc_writer_handle final { } private: - cudf::column_metadata build_one_column_meta(const cudf::column_view& cview, size_t& idx, + cudf::column_metadata build_one_column_meta(const cudf::column_view &cview, size_t &idx, const bool consume_name = true) { auto col_meta = cudf::column_metadata{}; if (consume_name) { @@ -301,7 +301,7 @@ class native_arrow_ipc_writer_handle final { return col_meta; } - std::string& get_column_name(const size_t idx) { + std::string &get_column_name(const size_t idx) { if (idx < 0 || idx >= column_names.size()) { throw cudf::jni::jni_exception("Missing names for columns or nested struct columns"); } @@ -628,9 +628,9 @@ std::vector resolve_column_order(JNIEnv *env, jbooleanArray jkeys_s std::vector column_order(keys_sort_num); if (keys_sort_num > 0) { std::transform(keys_sort_desc.data(), keys_sort_desc.data() + keys_sort_num, - column_order.begin(), - [](jboolean is_desc) { return is_desc ? cudf::order::DESCENDING - : cudf::order::ASCENDING; }); + column_order.begin(), [](jboolean is_desc) { + return is_desc ? cudf::order::DESCENDING : cudf::order::ASCENDING; + }); } return column_order; } @@ -649,9 +649,9 @@ std::vector resolve_null_precedence(JNIEnv *env, jbooleanArray std::vector null_precedence(null_order_num); if (null_order_num > 0) { std::transform(keys_null_first.data(), keys_null_first.data() + null_order_num, - null_precedence.begin(), - [](jboolean null_before) { return null_before ? cudf::null_order::BEFORE - : cudf::null_order::AFTER; }); + null_precedence.begin(), [](jboolean null_before) { + return null_before ? cudf::null_order::BEFORE : cudf::null_order::AFTER; + }); } return null_precedence; } @@ -659,11 +659,11 @@ std::vector resolve_null_precedence(JNIEnv *env, jbooleanArray namespace { int set_column_metadata(cudf::io::column_in_metadata &column_metadata, - std::vector &col_names, - cudf::jni::native_jbooleanArray &nullability, - cudf::jni::native_jbooleanArray &isInt96, - cudf::jni::native_jintArray &precisions, - cudf::jni::native_jintArray &children, int num_children, int read_index) { + std::vector &col_names, + cudf::jni::native_jbooleanArray &nullability, + cudf::jni::native_jbooleanArray &isInt96, + cudf::jni::native_jintArray &precisions, + cudf::jni::native_jintArray &children, int num_children, int read_index) { int write_index = 0; for (int i = 0; i < num_children; i++, write_index++) { cudf::io::column_in_metadata child; @@ -681,11 +681,11 @@ int set_column_metadata(cudf::io::column_in_metadata &column_metadata, return read_index; } -void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_names, jintArray &j_children, - jbooleanArray &j_col_nullability, jobjectArray &j_metadata_keys, - jobjectArray &j_metadata_values, jint j_compression, jint j_stats_freq, - jbooleanArray &j_isInt96, jintArray &j_precisions, - cudf::io::table_input_metadata& metadata) { +void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_names, + jintArray &j_children, jbooleanArray &j_col_nullability, + jobjectArray &j_metadata_keys, jobjectArray &j_metadata_values, + jint j_compression, jint j_stats_freq, jbooleanArray &j_isInt96, + jintArray &j_precisions, cudf::io::table_input_metadata &metadata) { cudf::jni::auto_set_device(env); cudf::jni::native_jstringArray col_names(env, j_col_names); cudf::jni::native_jbooleanArray col_nullability(env, j_col_nullability); @@ -709,14 +709,14 @@ void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_nam .set_decimal_precision(precisions[read_index]); int childs_children = children[read_index++]; if (childs_children > 0) { - read_index = set_column_metadata(metadata.column_metadata[write_index], cpp_names, - col_nullability, isInt96, precisions, children, childs_children, read_index); + read_index = + set_column_metadata(metadata.column_metadata[write_index], cpp_names, col_nullability, + isInt96, precisions, children, childs_children, read_index); } } for (auto i = 0; i < meta_keys.size(); ++i) { metadata.user_data[meta_keys[i].get()] = meta_values[i].get(); } - } // Check that window parameters are valid. @@ -855,8 +855,7 @@ jlongArray combine_join_results(JNIEnv *env, cudf::table &left_results, extern "C" { -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_createCudfTableView(JNIEnv *env, - jclass, +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_createCudfTableView(JNIEnv *env, jclass, jlongArray j_cudf_columns) { JNI_NULL_CHECK(env, j_cudf_columns, "columns are null", 0); @@ -937,13 +936,13 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_sortOrder(JNIEnv *env, jclass, jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); std::vector order(n_is_descending.size()); for (int i = 0; i < n_is_descending.size(); i++) { @@ -966,7 +965,6 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_sortOrder(JNIEnv *env, jclass, CATCH_STD(env, 0); } - JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_orderBy(JNIEnv *env, jclass, jlong j_input_table, jlongArray j_sort_keys_columns, @@ -988,13 +986,13 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_orderBy(JNIEnv *env, jcla jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", 0); + "columns and is_descending lengths don't match", 0); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and areNullsSmallest lengths don't match", 0); + "columns and areNullsSmallest lengths don't match", 0); std::vector order(n_is_descending.size()); for (int i = 0; i < n_is_descending.size(); i++) { @@ -1042,13 +1040,13 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_merge(JNIEnv *env, jclass jsize num_columns_is_desc = n_is_descending.size(); JNI_ARG_CHECK(env, num_columns_is_desc == num_columns, - "columns and is_descending lengths don't match", NULL); + "columns and is_descending lengths don't match", NULL); const cudf::jni::native_jbooleanArray n_are_nulls_smallest(env, j_are_nulls_smallest); jsize num_columns_null_smallest = n_are_nulls_smallest.size(); JNI_ARG_CHECK(env, num_columns_null_smallest == num_columns, - "columns and areNullsSmallest lengths don't match", NULL); + "columns and areNullsSmallest lengths don't match", NULL); std::vector indexes(n_sort_key_indexes.size()); for (int i = 0; i < n_sort_key_indexes.size(); i++) { @@ -1139,8 +1137,8 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readCSV( } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readParquet( - JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, - jlong buffer, jlong buffer_length, jint unit, jboolean strict_decimal_types) { + JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, jlong buffer, + jlong buffer_length, jint unit, jboolean strict_decimal_types) { bool read_buffer = true; if (buffer == 0) { JNI_NULL_CHECK(env, inputfilepath, "input file or buffer must be supplied", NULL); @@ -1196,14 +1194,14 @@ JNIEXPORT long JNICALL Java_ai_rapids_cudf_Table_writeParquetBufferBegin( try { std::unique_ptr data_sink( new cudf::jni::jni_writer_data_sink(env, consumer)); - + using namespace cudf::io; using namespace cudf::jni; sink_info sink{data_sink.get()}; table_input_metadata metadata; - createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, j_metadata_keys, - j_metadata_values, j_compression, j_stats_freq, j_isInt96, j_precisions, - metadata); + createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, + j_metadata_keys, j_metadata_values, j_compression, j_stats_freq, j_isInt96, + j_precisions, metadata); chunked_parquet_writer_options opts = chunked_parquet_writer_options::builder(sink) @@ -1232,11 +1230,12 @@ JNIEXPORT long JNICALL Java_ai_rapids_cudf_Table_writeParquetFileBegin( try { cudf::jni::native_jstring output_path(env, j_output_path); - using namespace cudf::io; - using namespace cudf::jni; + using namespace cudf::io; + using namespace cudf::jni; table_input_metadata metadata; - createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, j_metadata_keys, - j_metadata_values, j_compression, j_stats_freq, j_isInt96, j_precisions, metadata); + createTableMetaData(env, j_num_children, j_col_names, j_children, j_col_nullability, + j_metadata_keys, j_metadata_values, j_compression, j_stats_freq, j_isInt96, + j_precisions, metadata); sink_info sink{output_path.get()}; chunked_parquet_writer_options opts = chunked_parquet_writer_options::builder(sink) @@ -1291,8 +1290,8 @@ JNIEXPORT void JNICALL Java_ai_rapids_cudf_Table_writeParquetEnd(JNIEnv *env, jc } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_readORC( - JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, - jlong buffer, jlong buffer_length, jboolean usingNumPyTypes, jint unit) { + JNIEnv *env, jclass, jobjectArray filter_col_names, jstring inputfilepath, jlong buffer, + jlong buffer_length, jboolean usingNumPyTypes, jint unit) { bool read_buffer = true; if (buffer == 0) { JNI_NULL_CHECK(env, inputfilepath, "input file or buffer must be supplied", NULL); @@ -1800,10 +1799,10 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_leftSemiJoin( std::vector right_join_cols( right_join_cols_arr.data(), right_join_cols_arr.data() + right_join_cols_arr.size()); - std::unique_ptr result = cudf::left_semi_join( - *n_left_table, *n_right_table, left_join_cols, right_join_cols, - static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : - cudf::null_equality::UNEQUAL); + std::unique_ptr result = + cudf::left_semi_join(*n_left_table, *n_right_table, left_join_cols, right_join_cols, + static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : + cudf::null_equality::UNEQUAL); return cudf::jni::convert_table_for_return(env, result); } @@ -1829,10 +1828,10 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_leftAntiJoin( std::vector right_join_cols( right_join_cols_arr.data(), right_join_cols_arr.data() + right_join_cols_arr.size()); - std::unique_ptr result = cudf::left_anti_join( - *n_left_table, *n_right_table, left_join_cols, right_join_cols, - static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : - cudf::null_equality::UNEQUAL); + std::unique_ptr result = + cudf::left_anti_join(*n_left_table, *n_right_table, left_join_cols, right_join_cols, + static_cast(compare_nulls_equal) ? cudf::null_equality::EQUAL : + cudf::null_equality::UNEQUAL); return cudf::jni::convert_table_for_return(env, result); } @@ -1905,7 +1904,8 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_crossJoin(JNIEnv *env, jc JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_interleaveColumns(JNIEnv *env, jclass, jlongArray j_cudf_table_view) { - JNI_NULL_CHECK(env, j_cudf_table_view, "table is null", 0); try { + JNI_NULL_CHECK(env, j_cudf_table_view, "table is null", 0); + try { cudf::jni::auto_set_device(env); cudf::table_view *table_view = reinterpret_cast(j_cudf_table_view); std::unique_ptr result = cudf::interleave_columns(*table_view); @@ -1953,9 +1953,7 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_partition(JNIEnv *env, jc cudf::column_view *n_part_column = reinterpret_cast(partition_column); cudf::jni::native_jintArray n_output_offsets(env, output_offsets); - auto result = cudf::partition(*n_input_table, - *n_part_column, - number_of_partitions); + auto result = cudf::partition(*n_input_table, *n_part_column, number_of_partitions); for (size_t i = 0; i < result.second.size() - 1; i++) { // for what ever reason partition returns the length of the result at then @@ -1969,12 +1967,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_partition(JNIEnv *env, jc CATCH_STD(env, NULL); } -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition(JNIEnv *env, jclass, - jlong input_table, - jintArray columns_to_hash, - jint hash_function, - jint number_of_partitions, - jintArray output_offsets) { +JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition( + JNIEnv *env, jclass, jlong input_table, jintArray columns_to_hash, jint hash_function, + jint number_of_partitions, jintArray output_offsets) { JNI_NULL_CHECK(env, input_table, "input table is null", NULL); JNI_NULL_CHECK(env, columns_to_hash, "columns_to_hash is null", NULL); @@ -1996,10 +1991,7 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_hashPartition(JNIEnv *env } std::pair, std::vector> result = - cudf::hash_partition(*n_input_table, - columns_to_hash_vec, - number_of_partitions, - hash_func); + cudf::hash_partition(*n_input_table, columns_to_hash_vec, number_of_partitions, hash_func); for (size_t i = 0; i < result.second.size(); i++) { n_output_offsets[i] = result.second[i]; @@ -2035,9 +2027,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_roundRobinPartition( } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_groupByAggregate( - JNIEnv *env, jclass, jlong input_table, jintArray keys, - jintArray aggregate_column_indices, jlongArray agg_instances, jboolean ignore_null_keys, - jboolean jkey_sorted, jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { + JNIEnv *env, jclass, jlong input_table, jintArray keys, jintArray aggregate_column_indices, + jlongArray agg_instances, jboolean ignore_null_keys, jboolean jkey_sorted, + jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { JNI_NULL_CHECK(env, input_table, "input table is null", NULL); JNI_NULL_CHECK(env, keys, "input keys are null", NULL); JNI_NULL_CHECK(env, aggregate_column_indices, "input aggregate_column_indices are null", NULL); @@ -2056,16 +2048,11 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_groupByAggregate( } cudf::table_view n_keys_table(n_keys_cols); - auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, - n_keys.size()); - auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, - n_keys.size()); - cudf::groupby::groupby grouper(n_keys_table, - ignore_null_keys ? cudf::null_policy::EXCLUDE - : cudf::null_policy::INCLUDE, - jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO, - column_order, - null_precedence); + auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, n_keys.size()); + auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, n_keys.size()); + cudf::groupby::groupby grouper( + n_keys_table, ignore_null_keys ? cudf::null_policy::EXCLUDE : cudf::null_policy::INCLUDE, + jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO, column_order, null_precedence); // Aggregates are passed in already grouped by column, so we just need to fill it in // as we go. @@ -2258,8 +2245,8 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplit(JNIEnv cudf::jni::native_jobjectArray n_result = cudf::jni::contiguous_table_array(env, result.size()); for (size_t i = 0; i < result.size(); i++) { - n_result.set(i, cudf::jni::contiguous_table_from(env, result[i].data, - result[i].table.num_rows())); + n_result.set( + i, cudf::jni::contiguous_table_from(env, result[i].data, result[i].table.num_rows())); } return n_result.wrapped(); } @@ -2304,8 +2291,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rollingWindowAggregate( std::vector> result_columns; for (int i(0); i < values.size(); ++i) { - cudf::rolling_aggregation * agg = dynamic_cast(agg_instances[i]); - JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", nullptr); + cudf::rolling_aggregation *agg = dynamic_cast(agg_instances[i]); + JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", + nullptr); int agg_column_index = values[i]; if (default_output[i] != nullptr) { @@ -2313,9 +2301,9 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rollingWindowAggregate( groupby_keys, input_table->column(agg_column_index), *default_output[i], preceding[i], following[i], min_periods[i], *agg))); } else { - result_columns.emplace_back(std::move(cudf::grouped_rolling_window( - groupby_keys, input_table->column(agg_column_index), preceding[i], following[i], - min_periods[i], *agg))); + result_columns.emplace_back(std::move( + cudf::grouped_rolling_window(groupby_keys, input_table->column(agg_column_index), + preceding[i], following[i], min_periods[i], *agg))); } } @@ -2326,12 +2314,11 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rollingWindowAggregate( } JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rangeRollingWindowAggregate( - JNIEnv *env, jclass, jlong j_input_table, jintArray j_keys, - jintArray j_orderby_column_indices, jbooleanArray j_is_orderby_ascending, - jintArray j_aggregate_column_indices, jlongArray j_agg_instances, jintArray j_min_periods, - jlongArray j_preceding, jlongArray j_following, - jbooleanArray j_unbounded_preceding, jbooleanArray j_unbounded_following, - jboolean ignore_null_keys) { + JNIEnv *env, jclass, jlong j_input_table, jintArray j_keys, jintArray j_orderby_column_indices, + jbooleanArray j_is_orderby_ascending, jintArray j_aggregate_column_indices, + jlongArray j_agg_instances, jintArray j_min_periods, jlongArray j_preceding, + jlongArray j_following, jbooleanArray j_unbounded_preceding, + jbooleanArray j_unbounded_following, jboolean ignore_null_keys) { JNI_NULL_CHECK(env, j_input_table, "input table is null", NULL); JNI_NULL_CHECK(env, j_keys, "input keys are null", NULL); @@ -2383,7 +2370,7 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rangeRollingWindowAggrega unbounded_type = cudf::data_type{cudf::type_id::DURATION_DAYS}; break; case cudf::type_id::TIMESTAMP_SECONDS: - unbounded_type =cudf::data_type{cudf::type_id::DURATION_SECONDS}; + unbounded_type = cudf::data_type{cudf::type_id::DURATION_SECONDS}; break; case cudf::type_id::TIMESTAMP_MILLISECONDS: unbounded_type = cudf::data_type{cudf::type_id::DURATION_MILLISECONDS}; @@ -2394,30 +2381,23 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_rangeRollingWindowAggrega case cudf::type_id::TIMESTAMP_NANOSECONDS: unbounded_type = cudf::data_type{cudf::type_id::DURATION_NANOSECONDS}; break; - default: - break; + default: break; } } - cudf::rolling_aggregation * agg = dynamic_cast(agg_instances[i]); - JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", nullptr); - - result_columns.emplace_back( - std::move( - cudf::grouped_range_rolling_window( - groupby_keys, - order_by_column, - orderbys_ascending[i] ? cudf::order::ASCENDING : cudf::order::DESCENDING, - input_table->column(agg_column_index), - unbounded_preceding[i] ? cudf::range_window_bounds::unbounded(unbounded_type) : - cudf::range_window_bounds::get(*preceding[i]), - unbounded_following[i] ? cudf::range_window_bounds::unbounded(unbounded_type) : - cudf::range_window_bounds::get(*following[i]), - min_periods[i], - *agg - ) - ) - ); + cudf::rolling_aggregation *agg = dynamic_cast(agg_instances[i]); + JNI_ARG_CHECK(env, agg != nullptr, "aggregation is not an instance of rolling_aggregation", + nullptr); + + result_columns.emplace_back(std::move(cudf::grouped_range_rolling_window( + groupby_keys, order_by_column, + orderbys_ascending[i] ? cudf::order::ASCENDING : cudf::order::DESCENDING, + input_table->column(agg_column_index), + unbounded_preceding[i] ? cudf::range_window_bounds::unbounded(unbounded_type) : + cudf::range_window_bounds::get(*preceding[i]), + unbounded_following[i] ? cudf::range_window_bounds::unbounded(unbounded_type) : + cudf::range_window_bounds::get(*following[i]), + min_periods[i], *agg))); } auto result_table = std::make_unique(std::move(result_columns)); @@ -2482,24 +2462,20 @@ JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_Table_explodeOuterPosition(JNIE CATCH_STD(env, 0); } -JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_rowBitCount(JNIEnv* env, jclass, jlong j_table) { +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_rowBitCount(JNIEnv *env, jclass, jlong j_table) { JNI_NULL_CHECK(env, j_table, "table is null", 0); try { cudf::jni::auto_set_device(env); - auto t = reinterpret_cast(j_table); + auto t = reinterpret_cast(j_table); std::unique_ptr result = cudf::row_bit_count(*t); return reinterpret_cast(result.release()); } CATCH_STD(env, 0); } -JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(JNIEnv *env, jclass, - jlong jinput_table, - jintArray jkey_indices, - jboolean jignore_null_keys, - jboolean jkey_sorted, - jbooleanArray jkeys_sort_desc, - jbooleanArray jkeys_null_first) { +JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups( + JNIEnv *env, jclass, jlong jinput_table, jintArray jkey_indices, jboolean jignore_null_keys, + jboolean jkey_sorted, jbooleanArray jkeys_sort_desc, jbooleanArray jkeys_null_first) { JNI_NULL_CHECK(env, jinput_table, "table native handle is null", 0); JNI_NULL_CHECK(env, jkey_indices, "key indices are null", 0); // Two main steps to split the groups in the input table. @@ -2517,17 +2493,16 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J std::vector key_indices(n_key_indices.data(), n_key_indices.data() + n_key_indices.size()); auto keys = input_table->select(key_indices); - auto null_handling = jignore_null_keys ? cudf::null_policy::EXCLUDE - : cudf::null_policy::INCLUDE; + auto null_handling = + jignore_null_keys ? cudf::null_policy::EXCLUDE : cudf::null_policy::INCLUDE; auto keys_are_sorted = jkey_sorted ? cudf::sorted::YES : cudf::sorted::NO; - auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, - key_indices.size()); - auto null_precedence = cudf::jni::resolve_null_precedence(env, jkeys_null_first, - key_indices.size()); + auto column_order = cudf::jni::resolve_column_order(env, jkeys_sort_desc, key_indices.size()); + auto null_precedence = + cudf::jni::resolve_null_precedence(env, jkeys_null_first, key_indices.size()); // Constructs a groupby - cudf::groupby::groupby grouper(keys, null_handling, keys_are_sorted, - column_order, null_precedence); + cudf::groupby::groupby grouper(keys, null_handling, keys_are_sorted, column_order, + null_precedence); // 1) Gets the groups(keys, offsets, values) from groupby. // @@ -2544,7 +2519,7 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J // not key column, so adds it as value column. value_indices.emplace_back(index); } - index ++; + index++; } cudf::table_view values_view = input_table->select(value_indices); cudf::groupby::groupby::groups groups = grouper.get_groups(values_view); @@ -2557,31 +2532,32 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J auto key_view_it = key_view.begin(); for (auto key_id : key_indices) { grouped_cols.at(key_id) = std::move(*key_view_it); - key_view_it ++; + key_view_it++; } // value columns auto value_view = groups.values->view(); auto value_view_it = value_view.begin(); for (auto value_id : value_indices) { grouped_cols.at(value_id) = std::move(*value_view_it); - value_view_it ++; + value_view_it++; } cudf::table_view grouped_table(grouped_cols); // When no key columns, uses the input table instead, because the output // of 'get_groups' is empty. - auto& grouped_view = key_indices.empty() ? *input_table : grouped_table; + auto &grouped_view = key_indices.empty() ? *input_table : grouped_table; // Resolves the split indices from offsets vector directly to avoid copying. Since // the offsets vector may be very large if there are too many small groups. - std::vector& split_indices = groups.offsets; + std::vector &split_indices = groups.offsets; // Offsets laysout is [0, split indices..., num_rows] or [0] for empty keys, so // need to removes the first and last elements. split_indices.erase(split_indices.begin()); - if (!split_indices.empty()) { split_indices.pop_back(); } + if (!split_indices.empty()) { + split_indices.pop_back(); + } // 2) Splits the groups. - std::vector result = - cudf::contiguous_split(grouped_view, split_indices); + std::vector result = cudf::contiguous_split(grouped_view, split_indices); // Release the grouped table right away after split done. groups.keys.reset(nullptr); groups.values.reset(nullptr); @@ -2590,8 +2566,8 @@ JNIEXPORT jobjectArray JNICALL Java_ai_rapids_cudf_Table_contiguousSplitGroups(J cudf::jni::native_jobjectArray n_result = cudf::jni::contiguous_table_array(env, result.size()); for (size_t i = 0; i < result.size(); i++) { - n_result.set(i, cudf::jni::contiguous_table_from(env, result[i].data, - result[i].table.num_rows())); + n_result.set( + i, cudf::jni::contiguous_table_from(env, result[i].data, result[i].table.num_rows())); } return n_result.wrapped(); } diff --git a/java/src/main/native/src/cudf_jni_apis.hpp b/java/src/main/native/src/cudf_jni_apis.hpp index 14999156890..fbcca0c82ee 100644 --- a/java/src/main/native/src/cudf_jni_apis.hpp +++ b/java/src/main/native/src/cudf_jni_apis.hpp @@ -75,7 +75,7 @@ void auto_set_device(JNIEnv *env); * The operation has not necessarily completed when this returns, but it could overlap with * operations occurring on other streams. */ -void device_memset_async(JNIEnv *env, rmm::device_buffer& buf, char value); +void device_memset_async(JNIEnv *env, rmm::device_buffer &buf, char value); } // namespace jni } // namespace cudf diff --git a/java/src/main/native/src/dtype_utils.hpp b/java/src/main/native/src/dtype_utils.hpp index bde7bd2894e..9fae0c585e6 100644 --- a/java/src/main/native/src/dtype_utils.hpp +++ b/java/src/main/native/src/dtype_utils.hpp @@ -15,9 +15,10 @@ */ #pragma once -#include #include +#include + namespace cudf { namespace jni { @@ -25,9 +26,7 @@ namespace jni { inline cudf::data_type timestamp_to_duration(cudf::data_type dt) { cudf::type_id duration_type_id; switch (dt.id()) { - case cudf::type_id::TIMESTAMP_DAYS: - duration_type_id = cudf::type_id::DURATION_DAYS; - break; + case cudf::type_id::TIMESTAMP_DAYS: duration_type_id = cudf::type_id::DURATION_DAYS; break; case cudf::type_id::TIMESTAMP_SECONDS: duration_type_id = cudf::type_id::DURATION_SECONDS; break; @@ -40,14 +39,13 @@ inline cudf::data_type timestamp_to_duration(cudf::data_type dt) { case cudf::type_id::TIMESTAMP_NANOSECONDS: duration_type_id = cudf::type_id::DURATION_NANOSECONDS; break; - default: - throw std::logic_error("Unexpected type in timestamp_to_duration"); + default: throw std::logic_error("Unexpected type in timestamp_to_duration"); } return cudf::data_type(duration_type_id); } inline bool is_decimal_type(cudf::type_id n_type) { - return n_type == cudf::type_id::DECIMAL32 || n_type == cudf::type_id::DECIMAL64 ; + return n_type == cudf::type_id::DECIMAL32 || n_type == cudf::type_id::DECIMAL64; } // create data_type including scale for decimal type diff --git a/java/src/main/native/src/map_lookup.hpp b/java/src/main/native/src/map_lookup.hpp index 301293dc188..40c182da59b 100644 --- a/java/src/main/native/src/map_lookup.hpp +++ b/java/src/main/native/src/map_lookup.hpp @@ -51,7 +51,6 @@ map_lookup(column_view const &map_column, string_scalar lookup_key, bool has_nul rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); - /** * @brief Looks up a "map" column by specified key to see if the key exists or not, * and returns a cudf column of bool value. @@ -80,8 +79,8 @@ map_lookup(column_view const &map_column, string_scalar lookup_key, bool has_nul */ std::unique_ptr map_contains(column_view const &map_column, string_scalar lookup_key, bool has_nulls = true, - rmm::cuda_stream_view stream = rmm::cuda_stream_default, - rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); } // namespace jni diff --git a/java/src/main/native/src/prefix_sum.cu b/java/src/main/native/src/prefix_sum.cu index e3c53696185..277ca1d4dc1 100644 --- a/java/src/main/native/src/prefix_sum.cu +++ b/java/src/main/native/src/prefix_sum.cu @@ -14,33 +14,27 @@ * limitations under the License. */ -#include - #include #include - #include -#include #include - +#include +#include namespace cudf { namespace jni { -std::unique_ptr prefix_sum(column_view const &value_column, - rmm::cuda_stream_view stream, +std::unique_ptr prefix_sum(column_view const &value_column, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource *mr) { // Defensive checks. CUDF_EXPECTS(value_column.type().id() == type_id::INT64, "Only longs are supported."); CUDF_EXPECTS(!value_column.has_nulls(), "NULLS are not supported"); - auto result = make_numeric_column(value_column.type(), value_column.size(), - mask_state::ALL_VALID, stream, mr); + auto result = make_numeric_column(value_column.type(), value_column.size(), mask_state::ALL_VALID, + stream, mr); - thrust::inclusive_scan(rmm::exec_policy(stream), - value_column.begin(), - value_column.end(), - result->mutable_view().begin()); + thrust::inclusive_scan(rmm::exec_policy(stream), value_column.begin(), + value_column.end(), result->mutable_view().begin()); return result; } diff --git a/java/src/main/native/src/prefix_sum.hpp b/java/src/main/native/src/prefix_sum.hpp index 8f39f9a8c69..ea58a027207 100644 --- a/java/src/main/native/src/prefix_sum.hpp +++ b/java/src/main/native/src/prefix_sum.hpp @@ -27,8 +27,7 @@ namespace jni { * @brief compute the prefix sum of a column of longs */ std::unique_ptr -prefix_sum(column_view const &value_column, - rmm::cuda_stream_view stream = rmm::cuda_stream_default, +prefix_sum(column_view const &value_column, rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource()); } // namespace jni diff --git a/python/cudf/cudf/_lib/aggregation.pxd b/python/cudf/cudf/_lib/aggregation.pxd index 56fa9fdc63e..f608dab3fe1 100644 --- a/python/cudf/cudf/_lib/aggregation.pxd +++ b/python/cudf/cudf/_lib/aggregation.pxd @@ -1,8 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.aggregation cimport aggregation -from cudf._lib.cpp.aggregation cimport rolling_aggregation + +from cudf._lib.cpp.aggregation cimport aggregation, rolling_aggregation cdef class Aggregation: diff --git a/python/cudf/cudf/_lib/aggregation.pyx b/python/cudf/cudf/_lib/aggregation.pyx index cda35025c7e..4c94452c73d 100644 --- a/python/cudf/cudf/_lib/aggregation.pyx +++ b/python/cudf/cudf/_lib/aggregation.pyx @@ -2,27 +2,30 @@ from enum import Enum -import pandas as pd import numba import numpy as np -from libcpp.string cimport string +import pandas as pd + from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector +from libcpp.string cimport string from libcpp.utility cimport move +from libcpp.vector cimport vector + +from cudf._lib.types import NullHandling, cudf_to_np_types, np_to_cudf_types from cudf.utils import cudautils -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types, NullHandling from cudf._lib.types cimport ( underlying_type_t_interpolation, underlying_type_t_null_policy, underlying_type_t_type_id, ) -from cudf._lib.types import Interpolation from numba.np import numpy_support -cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.types import Interpolation + cimport cudf._lib.cpp.aggregation as libcudf_aggregation +cimport cudf._lib.cpp.types as libcudf_types class AggregationKind(Enum): diff --git a/python/cudf/cudf/_lib/avro.pyx b/python/cudf/cudf/_lib/avro.pyx index ed98429a2d6..52ddbd8b8fb 100644 --- a/python/cudf/cudf/_lib/avro.pyx +++ b/python/cudf/cudf/_lib/avro.pyx @@ -1,14 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.io.avro cimport ( - avro_reader_options, - read_avro as libcudf_read_avro -) - from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector +from cudf._lib.cpp.io.avro cimport ( + avro_reader_options, + read_avro as libcudf_read_avro, +) from cudf._lib.cpp.io.types cimport table_with_metadata from cudf._lib.cpp.types cimport size_type from cudf._lib.io.utils cimport make_source_info diff --git a/python/cudf/cudf/_lib/binaryop.pxd b/python/cudf/cudf/_lib/binaryop.pxd index 3fb36055465..1f6022251b3 100644 --- a/python/cudf/cudf/_lib/binaryop.pxd +++ b/python/cudf/cudf/_lib/binaryop.pxd @@ -2,5 +2,4 @@ from libc.stdint cimport int32_t - ctypedef int32_t underlying_type_t_binary_operator diff --git a/python/cudf/cudf/_lib/binaryop.pyx b/python/cudf/cudf/_lib/binaryop.pyx index 5eaec640b15..d8d4fe0b40b 100644 --- a/python/cudf/cudf/_lib/binaryop.pyx +++ b/python/cudf/cudf/_lib/binaryop.pyx @@ -1,32 +1,33 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import numpy as np from enum import IntEnum +import numpy as np + from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.utility cimport move from cudf._lib.binaryop cimport underlying_type_t_binary_operator from cudf._lib.column cimport Column + from cudf._lib.replace import replace_nulls from cudf._lib.scalar import as_device_scalar + from cudf._lib.scalar cimport DeviceScalar + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport ( - data_type, - type_id, -) +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.types cimport data_type, type_id +from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id -from cudf.utils.dtypes import is_string_dtype, is_scalar +from cudf.utils.dtypes import is_scalar, is_string_dtype -from cudf._lib.cpp.binaryop cimport binary_operator cimport cudf._lib.cpp.binaryop as cpp_binaryop +from cudf._lib.cpp.binaryop cimport binary_operator class BinaryOperation(IntEnum): diff --git a/python/cudf/cudf/_lib/column.pxd b/python/cudf/cudf/_lib/column.pxd index 6fb834410e6..2df958466c6 100644 --- a/python/cudf/cudf/_lib/column.pxd +++ b/python/cudf/cudf/_lib/column.pxd @@ -5,12 +5,9 @@ from libcpp.memory cimport unique_ptr from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.types cimport size_type - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.types cimport size_type cdef class Column: diff --git a/python/cudf/cudf/_lib/column.pyi b/python/cudf/cudf/_lib/column.pyi index 3387a9f268e..bafa1c914fd 100644 --- a/python/cudf/cudf/_lib/column.pyi +++ b/python/cudf/cudf/_lib/column.pyi @@ -1,13 +1,13 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from __future__ import annotations -from typing import Tuple, Union, TypeVar, Optional -from cudf._typing import DtypeObj, Dtype, ScalarLike +from typing import Optional, Tuple, TypeVar, Union + +from cudf._typing import Dtype, DtypeObj, ScalarLike from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase - T = TypeVar("T") class Column: diff --git a/python/cudf/cudf/_lib/column.pyx b/python/cudf/cudf/_lib/column.pyx index a3e01a4ac9d..b5223a32a18 100644 --- a/python/cudf/cudf/_lib/column.pyx +++ b/python/cudf/cudf/_lib/column.pyx @@ -3,51 +3,54 @@ import cupy as cp import numpy as np import pandas as pd + import rmm import cudf - +import cudf._lib as libcudfxx from cudf.core.buffer import Buffer from cudf.utils.dtypes import ( is_categorical_dtype, is_decimal_dtype, is_list_dtype, - is_struct_dtype + is_struct_dtype, ) -import cudf._lib as libcudfxx from cpython.buffer cimport PyObject_CheckBuffer from libc.stdint cimport uintptr_t -from libcpp.pair cimport pair from libcpp cimport bool -from libcpp.memory cimport unique_ptr, make_unique -from libcpp.vector cimport vector +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move +from libcpp.vector cimport vector + +from rmm._lib.device_buffer cimport DeviceBuffer + from cudf._lib.cpp.strings.convert.convert_integers cimport ( - from_integers as cpp_from_integers + from_integers as cpp_from_integers, ) -from rmm._lib.device_buffer cimport DeviceBuffer +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types from cudf._lib.types cimport ( - underlying_type_t_type_id, dtype_from_column_view, - dtype_to_data_type + dtype_to_data_type, + underlying_type_t_type_id, ) + from cudf._lib.null_mask import bitmask_allocation_size_bytes +cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.unary as libcudf_unary from cudf._lib.cpp.column.column cimport column, column_contents -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.column.column_factories cimport ( make_column_from_scalar as cpp_make_column_from_scalar, - make_numeric_column + make_numeric_column, ) +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.scalar cimport DeviceScalar -cimport cudf._lib.cpp.types as libcudf_types -cimport cudf._lib.cpp.unary as libcudf_unary cdef class Column: diff --git a/python/cudf/cudf/_lib/concat.pyx b/python/cudf/cudf/_lib/concat.pyx index cef93798601..86778e0a9e1 100644 --- a/python/cudf/cudf/_lib/concat.pyx +++ b/python/cudf/cudf/_lib/concat.pyx @@ -1,29 +1,29 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr, make_unique -from libcpp.vector cimport vector +from libcpp.memory cimport make_unique, unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.concatenate cimport ( - concatenate_masks as libcudf_concatenate_masks, concatenate_columns as libcudf_concatenate_columns, - concatenate_tables as libcudf_concatenate_tables + concatenate_masks as libcudf_concatenate_masks, + concatenate_tables as libcudf_concatenate_tables, ) -from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.table.table cimport table, table_view - -from cudf._lib.column cimport Column from cudf._lib.table cimport Table from cudf._lib.utils cimport ( make_column_views, + make_table_data_views, make_table_views, - make_table_data_views ) from cudf.core.buffer import Buffer -from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + cpdef concat_masks(object columns): cdef device_buffer c_result diff --git a/python/cudf/cudf/_lib/copying.pyx b/python/cudf/cudf/_lib/copying.pyx index 463082f0687..5a7f699bb3b 100644 --- a/python/cudf/cudf/_lib/copying.pyx +++ b/python/cudf/cudf/_lib/copying.pyx @@ -2,33 +2,33 @@ import pandas as pd +from libc.stdint cimport int32_t, int64_t from libcpp cimport bool -from libcpp.memory cimport make_unique, unique_ptr, shared_ptr, make_shared -from libcpp.vector cimport vector +from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr from libcpp.utility cimport move -from libc.stdint cimport int32_t, int64_t +from libcpp.vector cimport vector from cudf._lib.column cimport Column + from cudf._lib.scalar import as_device_scalar + from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table + from cudf._lib.reduce import minmax +cimport cudf._lib.cpp.copying as cpp_copying from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.libcpp.functional cimport reference_wrapper +from cudf._lib.cpp.lists.gather cimport ( + segmented_gather as cpp_segmented_gather, +) +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.lists.gather cimport ( - segmented_gather as cpp_segmented_gather -) -cimport cudf._lib.cpp.copying as cpp_copying # workaround for https://github.com/cython/cython/issues/3885 ctypedef const scalar constscalar diff --git a/python/cudf/cudf/_lib/cpp/aggregation.pxd b/python/cudf/cudf/_lib/cpp/aggregation.pxd index 839bdae7427..b13815c925d 100644 --- a/python/cudf/cudf/_lib/cpp/aggregation.pxd +++ b/python/cudf/cudf/_lib/cpp/aggregation.pxd @@ -1,14 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.string cimport string from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.vector cimport vector from cudf._lib.cpp.types cimport ( - size_type, data_type, interpolation, - null_policy + null_policy, + size_type, ) diff --git a/python/cudf/cudf/_lib/cpp/binaryop.pxd b/python/cudf/cudf/_lib/cpp/binaryop.pxd index 2e36070a164..3557ecd8487 100644 --- a/python/cudf/cudf/_lib/cpp/binaryop.pxd +++ b/python/cudf/cudf/_lib/cpp/binaryop.pxd @@ -4,11 +4,10 @@ from libcpp.memory cimport unique_ptr from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport ( - data_type -) +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.types cimport data_type + cdef extern from "cudf/binaryop.hpp" namespace "cudf" nogil: ctypedef enum binary_operator: diff --git a/python/cudf/cudf/_lib/cpp/column/column.pxd b/python/cudf/cudf/_lib/cpp/column/column.pxd index 8e880337f94..205a1548c54 100644 --- a/python/cudf/cudf/_lib/cpp/column/column.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column.pxd @@ -1,14 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from libcpp cimport bool from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.types cimport size_type, data_type -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) + +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/column/column.hpp" namespace "cudf" nogil: cdef cppclass column_contents "cudf::column::contents": diff --git a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd index 1da72160dfb..0f22e788bd7 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd @@ -1,14 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.types cimport ( - data_type, - mask_state, - size_type, -) +from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport scalar -from libcpp.memory cimport unique_ptr +from cudf._lib.cpp.types cimport data_type, mask_state, size_type + cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_numeric_column(data_type type, diff --git a/python/cudf/cudf/_lib/cpp/column/column_view.pxd b/python/cudf/cudf/_lib/cpp/column/column_view.pxd index e711fd62f8f..39c1c958531 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_view.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_view.pxd @@ -1,13 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp cimport bool +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport ( - size_type, - data_type, - bitmask_type -) +from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type cdef extern from "cudf/column/column_view.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/concatenate.pxd b/python/cudf/cudf/_lib/cpp/concatenate.pxd index c776d23aa85..05068318962 100644 --- a/python/cudf/cudf/_lib/cpp/concatenate.pxd +++ b/python/cudf/cudf/_lib/cpp/concatenate.pxd @@ -3,11 +3,12 @@ from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from rmm._lib.device_buffer cimport device_buffer + from cudf._lib.cpp.column.column cimport column, column_view from cudf._lib.cpp.table.table cimport table, table_view from cudf._lib.cpp.utilities.host_span cimport host_span -from rmm._lib.device_buffer cimport device_buffer cdef extern from "cudf/concatenate.hpp" namespace "cudf" nogil: # The versions of concatenate taking vectors don't exist in libcudf diff --git a/python/cudf/cudf/_lib/cpp/copying.pxd b/python/cudf/cudf/_lib/cpp/copying.pxd index c32eb13d908..b3d8cd5541d 100644 --- a/python/cudf/cudf/_lib/cpp/copying.pxd +++ b/python/cudf/cudf/_lib/cpp/copying.pxd @@ -1,17 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from rmm._lib.device_buffer cimport device_buffer - -from libcpp cimport bool from libc.stdint cimport int32_t, int64_t +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +from rmm._lib.device_buffer cimport device_buffer + from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.libcpp.functional cimport reference_wrapper from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table diff --git a/python/cudf/cudf/_lib/cpp/filling.pxd b/python/cudf/cudf/_lib/cpp/filling.pxd index 79bf3c496e8..42bdd827452 100644 --- a/python/cudf/cudf/_lib/cpp/filling.pxd +++ b/python/cudf/cudf/_lib/cpp/filling.pxd @@ -4,15 +4,11 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/filling.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/gpuarrow.pxd b/python/cudf/cudf/_lib/cpp/gpuarrow.pxd index 3e21d784b6f..6ebae78b5cd 100644 --- a/python/cudf/cudf/_lib/cpp/gpuarrow.pxd +++ b/python/cudf/cudf/_lib/cpp/gpuarrow.pxd @@ -1,13 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader from pyarrow.includes.libarrow cimport ( - CStatus, - CMessage, CBufferReader, - CMessageReader + CMessage, + CMessageReader, + CStatus, ) +from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader + cdef extern from "cudf/ipc.hpp" nogil: diff --git a/python/cudf/cudf/_lib/cpp/groupby.pxd b/python/cudf/cudf/_lib/cpp/groupby.pxd index af09b27d916..2d8f251799d 100644 --- a/python/cudf/cudf/_lib/cpp/groupby.pxd +++ b/python/cudf/cudf/_lib/cpp/groupby.pxd @@ -1,19 +1,19 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from libcpp.vector cimport vector +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair -from libcpp cimport bool +from libcpp.vector cimport vector +from cudf._lib.cpp.aggregation cimport aggregation +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.libcpp.functional cimport reference_wrapper +from cudf._lib.cpp.replace cimport replace_policy +from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.aggregation cimport aggregation -from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.types cimport size_type, order, null_order, null_policy -from cudf._lib.cpp.replace cimport replace_policy +from cudf._lib.cpp.types cimport null_order, null_policy, order, size_type from cudf._lib.cpp.utilities.host_span cimport host_span # workaround for https://github.com/cython/cython/issues/3885 diff --git a/python/cudf/cudf/_lib/cpp/hash.pxd b/python/cudf/cudf/_lib/cpp/hash.pxd index 5cecf50cd98..f07a6c0f046 100644 --- a/python/cudf/cudf/_lib/cpp/hash.pxd +++ b/python/cudf/cudf/_lib/cpp/hash.pxd @@ -4,10 +4,10 @@ from libc.stdint cimport uint32_t from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/hashing.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/interop.pxd b/python/cudf/cudf/_lib/cpp/interop.pxd index ed082e26853..e81f0d617fb 100644 --- a/python/cudf/cudf/_lib/cpp/interop.pxd +++ b/python/cudf/cudf/_lib/cpp/interop.pxd @@ -1,16 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.memory cimport shared_ptr -from libcpp.vector cimport vector +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string - +from libcpp.vector cimport vector from pyarrow.lib cimport CTable -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types + +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view + cdef extern from "dlpack/dlpack.h" nogil: ctypedef struct DLManagedTensor: void(*deleter)(DLManagedTensor*) except + diff --git a/python/cudf/cudf/_lib/cpp/io/avro.pxd b/python/cudf/cudf/_lib/cpp/io/avro.pxd index ac726cdd04d..6efe42e5208 100644 --- a/python/cudf/cudf/_lib/cpp/io/avro.pxd +++ b/python/cudf/cudf/_lib/cpp/io/avro.pxd @@ -3,8 +3,8 @@ from libcpp.string cimport string from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport size_type cimport cudf._lib.cpp.io.types as cudf_io_types +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/io/avro.hpp" \ diff --git a/python/cudf/cudf/_lib/cpp/io/csv.pxd b/python/cudf/cudf/_lib/cpp/io/csv.pxd index 6b6d36b3899..c5e235b5697 100644 --- a/python/cudf/cudf/_lib/cpp/io/csv.pxd +++ b/python/cudf/cudf/_lib/cpp/io/csv.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/csv.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/json.pxd b/python/cudf/cudf/_lib/cpp/io/json.pxd index 31a5afa2bac..6f20195e87f 100644 --- a/python/cudf/cudf/_lib/cpp/io/json.pxd +++ b/python/cudf/cudf/_lib/cpp/io/json.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/json.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/orc.pxd b/python/cudf/cudf/_lib/cpp/io/orc.pxd index 7449f2c510c..d5e874d796e 100644 --- a/python/cudf/cudf/_lib/cpp/io/orc.pxd +++ b/python/cudf/cudf/_lib/cpp/io/orc.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/orc.hpp" \ namespace "cudf::io" nogil: diff --git a/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd b/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd index e1128884491..57be1b1c90c 100644 --- a/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd +++ b/python/cudf/cudf/_lib/cpp/io/orc_metadata.pxd @@ -1,7 +1,7 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.string cimport string +from libcpp.vector cimport vector cimport cudf._lib.cpp.io.types as cudf_io_types diff --git a/python/cudf/cudf/_lib/cpp/io/parquet.pxd b/python/cudf/cudf/_lib/cpp/io/parquet.pxd index 39da6b26502..e2053f8ce4f 100644 --- a/python/cudf/cudf/_lib/cpp/io/parquet.pxd +++ b/python/cudf/cudf/_lib/cpp/io/parquet.pxd @@ -1,15 +1,16 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. +from libc.stdint cimport uint8_t from libcpp cimport bool -from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.map cimport map from libcpp.memory cimport shared_ptr, unique_ptr -from libc.stdint cimport uint8_t +from libcpp.string cimport string +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport data_type, size_type cimport cudf._lib.cpp.io.types as cudf_io_types cimport cudf._lib.cpp.table.table_view as cudf_table_view +from cudf._lib.cpp.types cimport data_type, size_type + cdef extern from "cudf/io/parquet.hpp" namespace "cudf::io" nogil: cdef cppclass parquet_reader_options: diff --git a/python/cudf/cudf/_lib/cpp/io/types.pxd b/python/cudf/cudf/_lib/cpp/io/types.pxd index 907d7763579..7fa6406bd29 100644 --- a/python/cudf/cudf/_lib/cpp/io/types.pxd +++ b/python/cudf/cudf/_lib/cpp/io/types.pxd @@ -1,13 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr, shared_ptr -from libcpp.string cimport string from libcpp.map cimport map +from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.pair cimport pair +from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.pair cimport pair from pyarrow.includes.libarrow cimport CRandomAccessFile + from cudf._lib.cpp.table.table cimport table diff --git a/python/cudf/cudf/_lib/cpp/join.pxd b/python/cudf/cudf/_lib/cpp/join.pxd index c221fea926d..171658c78ee 100644 --- a/python/cudf/cudf/_lib/cpp/join.pxd +++ b/python/cudf/cudf/_lib/cpp/join.pxd @@ -1,18 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector -from libcpp.pair cimport pair from libcpp cimport bool -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair +from libcpp.vector cimport vector + +from rmm._lib.device_uvector cimport device_uvector from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type -from rmm._lib.device_uvector cimport device_uvector - ctypedef unique_ptr[device_uvector[size_type]] gather_map_type diff --git a/python/cudf/cudf/_lib/cpp/labeling.pxd b/python/cudf/cudf/_lib/cpp/labeling.pxd index 996ae4f9e38..af9c4bb9a04 100644 --- a/python/cudf/cudf/_lib/cpp/labeling.pxd +++ b/python/cudf/cudf/_lib/cpp/labeling.pxd @@ -5,6 +5,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/labeling/label_bins.hpp" namespace "cudf" nogil: ctypedef enum inclusive: YES "cudf::inclusive::YES" diff --git a/python/cudf/cudf/_lib/cpp/lists/combine.pxd b/python/cudf/cudf/_lib/cpp/lists/combine.pxd index ea9ade178e2..b05b5c05428 100644 --- a/python/cudf/cudf/_lib/cpp/lists/combine.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/combine.pxd @@ -5,6 +5,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table_view cimport table_view + cdef extern from "cudf/lists/combine.hpp" namespace \ "cudf::lists" nogil: cdef unique_ptr[column] concatenate_rows( diff --git a/python/cudf/cudf/_lib/cpp/lists/contains.pxd b/python/cudf/cudf/_lib/cpp/lists/contains.pxd index ec2f61d08fa..5790ae4e787 100644 --- a/python/cudf/cudf/_lib/cpp/lists/contains.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/contains.pxd @@ -1,12 +1,12 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.column.column_view cimport column_view cdef extern from "cudf/lists/contains.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] contains( diff --git a/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd b/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd index 57d6daefd37..9be38f26237 100644 --- a/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/count_elements.pxd @@ -5,5 +5,6 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view + cdef extern from "cudf/lists/count_elements.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] count_elements(const lists_column_view) except + diff --git a/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd b/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd index 40b1836f932..81d54104320 100644 --- a/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/drop_list_duplicates.pxd @@ -2,9 +2,10 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.types cimport null_equality, nan_equality +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.types cimport nan_equality, null_equality + cdef extern from "cudf/lists/drop_list_duplicates.hpp" \ namespace "cudf::lists" nogil: diff --git a/python/cudf/cudf/_lib/cpp/lists/explode.pxd b/python/cudf/cudf/_lib/cpp/lists/explode.pxd index cd2d44d2e42..c3e15dd203c 100644 --- a/python/cudf/cudf/_lib/cpp/lists/explode.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/explode.pxd @@ -6,6 +6,7 @@ from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/lists/explode.hpp" namespace "cudf" nogil: cdef unique_ptr[table] explode_outer( const table_view, diff --git a/python/cudf/cudf/_lib/cpp/lists/extract.pxd b/python/cudf/cudf/_lib/cpp/lists/extract.pxd index 89fa893c17d..a023f728989 100644 --- a/python/cudf/cudf/_lib/cpp/lists/extract.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/extract.pxd @@ -4,9 +4,9 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view - from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/lists/extract.hpp" namespace "cudf::lists" nogil: cdef unique_ptr[column] extract_list_element( const lists_column_view, diff --git a/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd b/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd index 3290f52fba7..aa18ede41bd 100644 --- a/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/lists_column_view.pxd @@ -1,8 +1,6 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view cdef extern from "cudf/lists/lists_column_view.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/lists/sorting.pxd b/python/cudf/cudf/_lib/cpp/lists/sorting.pxd index 55e8e09427c..2115885ed95 100644 --- a/python/cudf/cudf/_lib/cpp/lists/sorting.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/sorting.pxd @@ -2,9 +2,9 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport order, null_order from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view +from cudf._lib.cpp.types cimport null_order, order cdef extern from "cudf/lists/sorting.hpp" namespace "cudf::lists" nogil: diff --git a/python/cudf/cudf/_lib/cpp/merge.pxd b/python/cudf/cudf/_lib/cpp/merge.pxd index b2d3d802e76..32fe14ac479 100644 --- a/python/cudf/cudf/_lib/cpp/merge.pxd +++ b/python/cudf/cudf/_lib/cpp/merge.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/merge.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/null_mask.pxd b/python/cudf/cudf/_lib/cpp/null_mask.pxd index b83c7a433c8..c225a16297b 100644 --- a/python/cudf/cudf/_lib/cpp/null_mask.pxd +++ b/python/cudf/cudf/_lib/cpp/null_mask.pxd @@ -4,8 +4,8 @@ from libc.stdint cimport int32_t from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.column.column_view cimport column_view cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.cpp.column.column_view cimport column_view ctypedef int32_t underlying_type_t_mask_state diff --git a/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd b/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd index 0d846702c9d..11de596ec8f 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/edit_distance.pxd @@ -6,6 +6,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "nvtext/edit_distance.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] edit_distance( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd b/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd index 52a91cba057..06147df38f2 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/generate_ngrams.pxd @@ -7,6 +7,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type + cdef extern from "nvtext/generate_ngrams.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] generate_ngrams( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd index d6145a8048d..d716df22546 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/ngrams_tokenize.pxd @@ -7,6 +7,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type + cdef extern from "nvtext/ngrams_tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] ngrams_tokenize( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd index 7d8ec891692..f012670317a 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/normalize.pxd @@ -6,6 +6,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "nvtext/normalize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] normalize_spaces( diff --git a/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd b/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd index 2de562e91b4..c4e5258a710 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/replace.pxd @@ -2,10 +2,10 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type cdef extern from "nvtext/replace.hpp" namespace "nvtext" nogil: diff --git a/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd b/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd index b8b816c212e..5a92b45b6dd 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/stemmer.pxd @@ -7,6 +7,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type + cdef extern from "nvtext/stemmer.hpp" namespace "nvtext" nogil: ctypedef enum letter_type: CONSONANT 'nvtext::letter_type::CONSONANT' diff --git a/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd index 013ce9de8f4..cdb39e3c7fa 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/subword_tokenize.pxd @@ -1,10 +1,9 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint16_t, uint32_t from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.string cimport string -from libc.stdint cimport uint16_t, uint32_t - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view diff --git a/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd b/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd index 2442c12de82..8b80f50e381 100644 --- a/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd +++ b/python/cudf/cudf/_lib/cpp/nvtext/tokenize.pxd @@ -6,6 +6,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar + cdef extern from "nvtext/tokenize.hpp" namespace "nvtext" nogil: cdef unique_ptr[column] tokenize( diff --git a/python/cudf/cudf/_lib/cpp/partitioning.pxd b/python/cudf/cudf/_lib/cpp/partitioning.pxd index 8f89c09e52c..5c58dbcc4ac 100644 --- a/python/cudf/cudf/_lib/cpp/partitioning.pxd +++ b/python/cudf/cudf/_lib/cpp/partitioning.pxd @@ -1,15 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libc.stdint cimport uint32_t -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.column.column_view cimport column_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/partitioning.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/quantiles.pxd b/python/cudf/cudf/_lib/cpp/quantiles.pxd index f7817dfb97f..03fda16856c 100644 --- a/python/cudf/cudf/_lib/cpp/quantiles.pxd +++ b/python/cudf/cudf/_lib/cpp/quantiles.pxd @@ -1,19 +1,18 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view - from cudf._lib.cpp.types cimport ( interpolation, null_order, - order_info, order, + order_info, sorted, ) diff --git a/python/cudf/cudf/_lib/cpp/reduce.pxd b/python/cudf/cudf/_lib/cpp/reduce.pxd index dfe1ffd3669..53c8cd59468 100644 --- a/python/cudf/cudf/_lib/cpp/reduce.pxd +++ b/python/cudf/cudf/_lib/cpp/reduce.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.types cimport data_type -from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.aggregation cimport aggregation from libcpp.memory cimport unique_ptr from libcpp.utility cimport pair +from cudf._lib.aggregation cimport aggregation +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.types cimport data_type +from cudf._lib.scalar cimport DeviceScalar + cdef extern from "cudf/reduction.hpp" namespace "cudf" nogil: cdef unique_ptr[scalar] cpp_reduce "cudf::reduce" ( diff --git a/python/cudf/cudf/_lib/cpp/replace.pxd b/python/cudf/cudf/_lib/cpp/replace.pxd index 6fd844acb75..c1ec89a6233 100644 --- a/python/cudf/cudf/_lib/cpp/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/replace.pxd @@ -2,14 +2,12 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view +from cudf._lib.cpp.scalar.scalar cimport scalar + cdef extern from "cudf/replace.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/reshape.pxd b/python/cudf/cudf/_lib/cpp/reshape.pxd index 2985b9282b3..5b9d40aa2ad 100644 --- a/python/cudf/cudf/_lib/cpp/reshape.pxd +++ b/python/cudf/cudf/_lib/cpp/reshape.pxd @@ -2,10 +2,11 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/reshape.hpp" namespace "cudf" nogil: cdef unique_ptr[column] interleave_columns( diff --git a/python/cudf/cudf/_lib/cpp/rolling.pxd b/python/cudf/cudf/_lib/cpp/rolling.pxd index 4ccc0f5ae9b..df2e833edc2 100644 --- a/python/cudf/cudf/_lib/cpp/rolling.pxd +++ b/python/cudf/cudf/_lib/cpp/rolling.pxd @@ -2,12 +2,12 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.aggregation cimport rolling_aggregation from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.aggregation cimport rolling_aggregation +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/rolling.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/round.pxd b/python/cudf/cudf/_lib/cpp/round.pxd index 78f18dcacce..66d76c35d72 100644 --- a/python/cudf/cudf/_lib/cpp/round.pxd +++ b/python/cudf/cudf/_lib/cpp/round.pxd @@ -6,6 +6,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/round.hpp" namespace "cudf" nogil: ctypedef enum rounding_method "cudf::rounding_method": diff --git a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd index feb747a5ccd..fd020dabb1b 100644 --- a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd +++ b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd @@ -1,16 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libc.stdint cimport ( - int32_t, int64_t -) +from libc.stdint cimport int32_t, int64_t from libcpp cimport bool from libcpp.string cimport string +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type from cudf._lib.cpp.wrappers.decimals cimport scale_type -from cudf._lib.cpp.column.column_view cimport column_view - cdef extern from "cudf/scalar/scalar.hpp" namespace "cudf" nogil: cdef cppclass scalar: diff --git a/python/cudf/cudf/_lib/cpp/search.pxd b/python/cudf/cudf/_lib/cpp/search.pxd index 521b681dc24..4df73881ea5 100644 --- a/python/cudf/cudf/_lib/cpp/search.pxd +++ b/python/cudf/cudf/_lib/cpp/search.pxd @@ -1,12 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types cdef extern from "cudf/search.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/sorting.pxd b/python/cudf/cudf/_lib/cpp/sorting.pxd index 845457e423f..d614ef64ee2 100644 --- a/python/cudf/cudf/_lib/cpp/sorting.pxd +++ b/python/cudf/cudf/_lib/cpp/sorting.pxd @@ -4,13 +4,14 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types + cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: ctypedef enum rank_method: diff --git a/python/cudf/cudf/_lib/cpp/stream_compaction.pxd b/python/cudf/cudf/_lib/cpp/stream_compaction.pxd index c575f4eb17d..5b81d369ef5 100644 --- a/python/cudf/cudf/_lib/cpp/stream_compaction.pxd +++ b/python/cudf/cudf/_lib/cpp/stream_compaction.pxd @@ -1,17 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.vector cimport vector -from libcpp cimport bool -from cudf._lib.types import np_to_cudf_types, cudf_to_np_types +from cudf._lib.types import cudf_to_np_types, np_to_cudf_types -from cudf._lib.cpp.types cimport ( - size_type, null_policy, nan_policy, null_equality -) from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport ( + nan_policy, + null_equality, + null_policy, + size_type, +) cdef extern from "cudf/stream_compaction.hpp" namespace "cudf" \ diff --git a/python/cudf/cudf/_lib/cpp/strings/attributes.pxd b/python/cudf/cudf/_lib/cpp/strings/attributes.pxd index abac963fe94..31133b45b6d 100644 --- a/python/cudf/cudf/_lib/cpp/strings/attributes.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/attributes.pxd @@ -5,6 +5,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/attributes.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] count_characters( diff --git a/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd b/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd index eb24c6ab417..02a4469f495 100644 --- a/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/capitalize.pxd @@ -4,6 +4,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/capitalize.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] capitalize( const column_view & strings) except + diff --git a/python/cudf/cudf/_lib/cpp/strings/case.pxd b/python/cudf/cudf/_lib/cpp/strings/case.pxd index 7c38657a43e..01cd08c10ff 100644 --- a/python/cudf/cudf/_lib/cpp/strings/case.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/case.pxd @@ -4,6 +4,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/case.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] to_lower( const column_view & strings) except + diff --git a/python/cudf/cudf/_lib/cpp/strings/char_types.pxd b/python/cudf/cudf/_lib/cpp/strings/char_types.pxd index 934269c6f25..ae921c6ead9 100644 --- a/python/cudf/cudf/_lib/cpp/strings/char_types.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/char_types.pxd @@ -1,10 +1,12 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar + cdef extern from "cudf/strings/char_types/char_types.hpp" \ namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/combine.pxd b/python/cudf/cudf/_lib/cpp/strings/combine.pxd index 35d7516d127..2b10427283f 100644 --- a/python/cudf/cudf/_lib/cpp/strings/combine.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/combine.pxd @@ -1,10 +1,12 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.table.table_view cimport table_view + cdef extern from "cudf/strings/combine.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/contains.pxd b/python/cudf/cudf/_lib/cpp/strings/contains.pxd index e6fb9127814..bde0b4fdfb7 100644 --- a/python/cudf/cudf/_lib/cpp/strings/contains.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/contains.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view cdef extern from "cudf/strings/contains.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd index ca494696ae8..96cb43973f1 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_booleans.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_booleans.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd index 4bd57a16d64..5a9228608e5 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_datetime.pxd @@ -1,11 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string cdef extern from "cudf/strings/convert/convert_datetime.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd index 98faebfcaa2..8c54fd52aa2 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_durations.pxd @@ -1,11 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr -from libcpp.string cimport string cdef extern from "cudf/strings/convert/convert_durations.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd index 77d72acb670..a993c5b17b8 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_fixed_point.pxd @@ -1,10 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_fixed_point.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd index 55a84b60efd..6388f43077d 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_floats.pxd @@ -1,10 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_floats.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd index ec45b985544..b5443979b81 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_integers.pxd @@ -1,10 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport data_type -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_integers.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd index 37eea254605..d6e881caea4 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_ipv4.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_ipv4.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd b/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd index a7bcb8d8078..5d9991dd610 100644 --- a/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/convert/convert_urls.pxd @@ -1,9 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from libcpp.memory cimport unique_ptr cdef extern from "cudf/strings/convert/convert_urls.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/extract.pxd b/python/cudf/cudf/_lib/cpp/strings/extract.pxd index acec41bddc8..518b1c9ed60 100644 --- a/python/cudf/cudf/_lib/cpp/strings/extract.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/extract.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table -from libcpp.string cimport string cdef extern from "cudf/strings/extract.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/find.pxd b/python/cudf/cudf/_lib/cpp/strings/find.pxd index 05451fe0599..953d5c30b2a 100644 --- a/python/cudf/cudf/_lib/cpp/strings/find.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/find.pxd @@ -1,12 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/find.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] contains( diff --git a/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd b/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd index 286fe72d058..27b19728f60 100644 --- a/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/find_multiple.pxd @@ -1,8 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view + cdef extern from "cudf/strings/find_multiple.hpp" namespace "cudf::strings" \ nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/findall.pxd b/python/cudf/cudf/_lib/cpp/strings/findall.pxd index 818135b6cd0..189d0770b81 100644 --- a/python/cudf/cudf/_lib/cpp/strings/findall.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/findall.pxd @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table -from libcpp.string cimport string cdef extern from "cudf/strings/findall.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/json.pxd b/python/cudf/cudf/_lib/cpp/strings/json.pxd index c0e215f2085..972e3c99d59 100644 --- a/python/cudf/cudf/_lib/cpp/strings/json.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/json.pxd @@ -1,12 +1,11 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from libcpp.memory cimport unique_ptr from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport scalar, string_scalar cdef extern from "cudf/strings/json.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/padding.pxd b/python/cudf/cudf/_lib/cpp/strings/padding.pxd index af1f235f7ea..2077e687be3 100644 --- a/python/cudf/cudf/_lib/cpp/strings/padding.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/padding.pxd @@ -1,12 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libc.stdint cimport int32_t +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string -from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/padding.hpp" namespace "cudf::strings" nogil: ctypedef enum pad_side: diff --git a/python/cudf/cudf/_lib/cpp/strings/replace.pxd b/python/cudf/cudf/_lib/cpp/strings/replace.pxd index 312c8fb1753..2a9c6913bb3 100644 --- a/python/cudf/cudf/_lib/cpp/strings/replace.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/replace.pxd @@ -1,13 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type +from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string -from libc.stdint cimport int32_t +from cudf._lib.cpp.types cimport size_type cdef extern from "cudf/strings/replace.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd b/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd index 8d19c67acd0..33ccbc34a8e 100644 --- a/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/replace_re.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from libcpp.memory cimport unique_ptr from libcpp.string cimport string +from libcpp.vector cimport vector + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table cimport table -from libcpp.string cimport string -from libcpp.vector cimport vector +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/replace_re.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd b/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd index cdfa8b78e03..fb83512e9f0 100644 --- a/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/split/partition.pxd @@ -1,12 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table cimport table + cdef extern from "cudf/strings/split/partition.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/split/split.pxd b/python/cudf/cudf/_lib/cpp/strings/split/split.pxd index db9bf91336a..4a90aa233f0 100644 --- a/python/cudf/cudf/_lib/cpp/strings/split/split.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/split/split.pxd @@ -1,12 +1,14 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from libcpp.string cimport string from libcpp.memory cimport unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/split/split.hpp" namespace \ "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/strip.pxd b/python/cudf/cudf/_lib/cpp/strings/strip.pxd index a03917dc44b..82a84fd2d14 100644 --- a/python/cudf/cudf/_lib/cpp/strings/strip.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/strip.pxd @@ -1,9 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar + cdef extern from "cudf/strings/strip.hpp" namespace "cudf::strings" nogil: ctypedef enum strip_type: diff --git a/python/cudf/cudf/_lib/cpp/strings/substring.pxd b/python/cudf/cudf/_lib/cpp/strings/substring.pxd index 0d558ad9670..ec69c5acc03 100644 --- a/python/cudf/cudf/_lib/cpp/strings/substring.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/substring.pxd @@ -1,10 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport numeric_scalar +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/substring.hpp" namespace "cudf::strings" nogil: cdef unique_ptr[column] slice_strings( diff --git a/python/cudf/cudf/_lib/cpp/strings/translate.pxd b/python/cudf/cudf/_lib/cpp/strings/translate.pxd index 3f40543a49a..3239ba314e4 100644 --- a/python/cudf/cudf/_lib/cpp/strings/translate.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/translate.pxd @@ -2,13 +2,14 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair +from libcpp.vector cimport vector from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from libcpp.vector cimport vector -from libcpp.pair cimport pair -from cudf._lib.cpp.types cimport char_utf8 from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport char_utf8 + cdef extern from "cudf/strings/translate.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/strings/wrap.pxd b/python/cudf/cudf/_lib/cpp/strings/wrap.pxd index f5fa115b31c..62c791799ad 100644 --- a/python/cudf/cudf/_lib/cpp/strings/wrap.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/wrap.pxd @@ -1,9 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/wrap.hpp" namespace "cudf::strings" nogil: diff --git a/python/cudf/cudf/_lib/cpp/table/table.pxd b/python/cudf/cudf/_lib/cpp/table/table.pxd index ffa8dd1fc98..13e1ceb6430 100644 --- a/python/cudf/cudf/_lib/cpp/table/table.pxd +++ b/python/cudf/cudf/_lib/cpp/table/table.pxd @@ -1,14 +1,12 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table_view cimport ( - table_view, - mutable_table_view -) +from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/table/table.hpp" namespace "cudf" nogil: cdef cppclass table: diff --git a/python/cudf/cudf/_lib/cpp/table/table_view.pxd b/python/cudf/cudf/_lib/cpp/table/table_view.pxd index 7bbfa69836c..728b6d2be4b 100644 --- a/python/cudf/cudf/_lib/cpp/table/table_view.pxd +++ b/python/cudf/cudf/_lib/cpp/table/table_view.pxd @@ -2,11 +2,9 @@ from libcpp.vector cimport vector +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) + cdef extern from "cudf/table/table_view.hpp" namespace "cudf" nogil: cdef cppclass table_view: diff --git a/python/cudf/cudf/_lib/cpp/transform.pxd b/python/cudf/cudf/_lib/cpp/transform.pxd index 5e37336cb94..484e3997f34 100644 --- a/python/cudf/cudf/_lib/cpp/transform.pxd +++ b/python/cudf/cudf/_lib/cpp/transform.pxd @@ -1,21 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.string cimport string -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair +from libcpp.string cimport string from rmm._lib.device_buffer cimport device_buffer -from cudf._lib.cpp.types cimport ( - bitmask_type, - data_type, - size_type, -) from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type cdef extern from "cudf/transform.hpp" namespace "cudf" nogil: diff --git a/python/cudf/cudf/_lib/cpp/unary.pxd b/python/cudf/cudf/_lib/cpp/unary.pxd index b5682ee6694..83a5701eaf0 100644 --- a/python/cudf/cudf/_lib/cpp/unary.pxd +++ b/python/cudf/cudf/_lib/cpp/unary.pxd @@ -2,15 +2,10 @@ from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.column.column_view cimport ( - column_view -) -from cudf._lib.cpp.column.column cimport ( - column -) -from cudf._lib.cpp.types cimport ( - data_type -) + +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport data_type ctypedef int32_t underlying_type_t_unary_op diff --git a/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd b/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd index cbbe3710347..7e591e96373 100644 --- a/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd +++ b/python/cudf/cudf/_lib/cpp/utilities/host_span.pxd @@ -2,6 +2,7 @@ from libcpp.vector cimport vector + cdef extern from "cudf/utilities/span.hpp" namespace "cudf" nogil: cdef cppclass host_span[T]: host_span() except + diff --git a/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd b/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd index 9de23fb2595..74efdb08bea 100644 --- a/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd +++ b/python/cudf/cudf/_lib/cpp/wrappers/decimals.pxd @@ -1,5 +1,6 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from libc.stdint cimport int64_t, int32_t +from libc.stdint cimport int32_t, int64_t + cdef extern from "cudf/fixed_point/fixed_point.hpp" namespace "numeric" nogil: # cython type stub to help resolve to numeric::decimal64 diff --git a/python/cudf/cudf/_lib/csv.pyx b/python/cudf/cudf/_lib/csv.pyx index 1c87096b647..773e81a0a7b 100644 --- a/python/cudf/cudf/_lib/csv.pyx +++ b/python/cudf/cudf/_lib/csv.pyx @@ -3,33 +3,31 @@ from libcpp cimport bool from libcpp.memory cimport make_unique, unique_ptr from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector +import numpy as np import pandas as pd + import cudf -import numpy as np from cudf._lib.cpp.types cimport size_type import collections.abc as abc import errno -from io import BytesIO, StringIO import os - from enum import IntEnum - -from libcpp cimport bool +from io import BytesIO, StringIO from libc.stdint cimport int32_t +from libcpp cimport bool from cudf._lib.cpp.io.csv cimport ( - read_csv as cpp_read_csv, csv_reader_options, - write_csv as cpp_write_csv, csv_writer_options, + read_csv as cpp_read_csv, + write_csv as cpp_write_csv, ) - from cudf._lib.cpp.io.types cimport ( compression_type, data_sink, @@ -37,11 +35,11 @@ from cudf._lib.cpp.io.types cimport ( sink_info, source_info, table_metadata, - table_with_metadata + table_with_metadata, ) -from cudf._lib.io.utils cimport make_source_info, make_sink_info -from cudf._lib.table cimport Table, make_table_view from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.io.utils cimport make_sink_info, make_source_info +from cudf._lib.table cimport Table, make_table_view ctypedef int32_t underlying_type_t_compression diff --git a/python/cudf/cudf/_lib/datetime.pyx b/python/cudf/cudf/_lib/datetime.pyx index 3e40cb62f9c..d048325c283 100644 --- a/python/cudf/cudf/_lib/datetime.pyx +++ b/python/cudf/cudf/_lib/datetime.pyx @@ -1,13 +1,11 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +cimport cudf._lib.cpp.datetime as libcudf_datetime +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.column cimport Column - -cimport cudf._lib.cpp.datetime as libcudf_datetime - def add_months(Column col, Column months): # months must be int16 dtype diff --git a/python/cudf/cudf/_lib/filling.pyx b/python/cudf/cudf/_lib/filling.pyx index a3941c9479b..d9fdf72415c 100644 --- a/python/cudf/cudf/_lib/filling.pyx +++ b/python/cudf/cudf/_lib/filling.pyx @@ -6,13 +6,10 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column +cimport cudf._lib.cpp.filling as cpp_filling from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view @@ -20,8 +17,6 @@ from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table -cimport cudf._lib.cpp.filling as cpp_filling - def fill_in_place(Column destination, int begin, int end, DeviceScalar value): cdef mutable_column_view c_destination = destination.mutable_view() diff --git a/python/cudf/cudf/_lib/gpuarrow.pyx b/python/cudf/cudf/_lib/gpuarrow.pyx index 6513cd59424..8cb42e54e24 100644 --- a/python/cudf/cudf/_lib/gpuarrow.pyx +++ b/python/cudf/cudf/_lib/gpuarrow.pyx @@ -4,22 +4,26 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from pyarrow._cuda cimport CudaBuffer from pyarrow.includes.libarrow_cuda cimport CCudaBufferReader + from cudf._lib.cpp.gpuarrow cimport CCudaMessageReader + from numba.cuda.cudadrv.devicearray import DeviceNDArray + from pyarrow.includes.common cimport GetResultValue from pyarrow.includes.libarrow cimport ( - CMessage, CBufferReader, - CMessageReader, CIpcReadOptions, - CRecordBatchStreamReader + CMessage, + CMessageReader, + CRecordBatchStreamReader, ) from pyarrow.lib cimport ( - _CRecordBatchReader, Buffer, Schema, - pyarrow_wrap_schema + _CRecordBatchReader, + pyarrow_wrap_schema, ) + import pyarrow as pa diff --git a/python/cudf/cudf/_lib/groupby.pyx b/python/cudf/cudf/_lib/groupby.pyx index 1a7f34d74b9..12e3f65a8a2 100644 --- a/python/cudf/cudf/_lib/groupby.pyx +++ b/python/cudf/cudf/_lib/groupby.pyx @@ -1,43 +1,44 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from collections import defaultdict + +import numpy as np from pandas.core.groupby.groupby import DataError + +import rmm + from cudf.utils.dtypes import ( is_categorical_dtype, - is_string_dtype, - is_list_dtype, + is_decimal_dtype, is_interval_dtype, + is_list_dtype, + is_string_dtype, is_struct_dtype, - is_decimal_dtype, ) -import numpy as np -import rmm - -from libcpp.pair cimport pair +from libcpp cimport bool from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move from libcpp.vector cimport vector -from libcpp cimport bool from cudf._lib.column cimport Column -from cudf._lib.table cimport Table from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table + from cudf._lib.scalar import as_device_scalar -from cudf._lib.aggregation cimport Aggregation, make_aggregation -from cudf._lib.cpp.types cimport size_type -from cudf._lib.cpp.scalar.scalar cimport scalar -from cudf._lib.cpp.libcpp.functional cimport reference_wrapper +cimport cudf._lib.cpp.groupby as libcudf_groupby +cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.aggregation cimport Aggregation, make_aggregation from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.table.table cimport table, table_view +from cudf._lib.cpp.libcpp.functional cimport reference_wrapper from cudf._lib.cpp.replace cimport replace_policy -from cudf._lib.cpp.utilities.host_span cimport host_span +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.cpp.table.table cimport table, table_view from cudf._lib.cpp.types cimport size_type -cimport cudf._lib.cpp.types as libcudf_types -cimport cudf._lib.cpp.groupby as libcudf_groupby - +from cudf._lib.cpp.utilities.host_span cimport host_span # The sets below define the possible aggregations that can be performed on # different dtypes. These strings must be elements of the AggregationKind enum. diff --git a/python/cudf/cudf/_lib/hash.pyx b/python/cudf/cudf/_lib/hash.pyx index 196c88a8a20..198e7a748c9 100644 --- a/python/cudf/cudf/_lib/hash.pyx +++ b/python/cudf/cudf/_lib/hash.pyx @@ -2,24 +2,19 @@ from libc.stdint cimport uint32_t from libcpp cimport bool -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.hash cimport hash as cpp_hash +from cudf._lib.cpp.partitioning cimport hash_partition as cpp_hash_partition from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.hash cimport ( - hash as cpp_hash -) -from cudf._lib.cpp.partitioning cimport ( - hash_partition as cpp_hash_partition, -) -cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.table cimport Table def hash_partition(Table source_table, object columns_to_hash, diff --git a/python/cudf/cudf/_lib/interop.pyx b/python/cudf/cudf/_lib/interop.pyx index 04971b58cd2..08ea58e4587 100644 --- a/python/cudf/cudf/_lib/interop.pyx +++ b/python/cudf/cudf/_lib/interop.pyx @@ -2,27 +2,25 @@ import cudf -from cudf._lib.table cimport Table -from libcpp.vector cimport vector -from libcpp.string cimport string +from cpython cimport pycapsule from libcpp cimport bool - -from libcpp.memory cimport unique_ptr, shared_ptr +from libcpp.memory cimport shared_ptr, unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move +from libcpp.vector cimport vector +from pyarrow.lib cimport CTable, pyarrow_unwrap_table, pyarrow_wrap_table -from cpython cimport pycapsule - -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from pyarrow.lib cimport CTable, pyarrow_wrap_table, pyarrow_unwrap_table from cudf._lib.cpp.interop cimport ( - to_arrow as cpp_to_arrow, + DLManagedTensor, + column_metadata, from_arrow as cpp_from_arrow, from_dlpack as cpp_from_dlpack, + to_arrow as cpp_to_arrow, to_dlpack as cpp_to_dlpack, - column_metadata, - DLManagedTensor ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.table cimport Table def from_dlpack(dlpack_capsule): diff --git a/python/cudf/cudf/_lib/io/datasource.pxd b/python/cudf/cudf/_lib/io/datasource.pxd index 528a6c52edd..705a3600f68 100644 --- a/python/cudf/cudf/_lib/io/datasource.pxd +++ b/python/cudf/cudf/_lib/io/datasource.pxd @@ -1,8 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.io.types cimport datasource + cdef class Datasource: cdef datasource* get_datasource(self) nogil except * diff --git a/python/cudf/cudf/_lib/io/datasource.pyx b/python/cudf/cudf/_lib/io/datasource.pyx index b706847647b..ddfd9a3540a 100644 --- a/python/cudf/cudf/_lib/io/datasource.pyx +++ b/python/cudf/cudf/_lib/io/datasource.pyx @@ -1,8 +1,10 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr + from cudf._lib.cpp.io.types cimport datasource + cdef class Datasource: cdef datasource* get_datasource(self) nogil except *: with gil: diff --git a/python/cudf/cudf/_lib/io/utils.pxd b/python/cudf/cudf/_lib/io/utils.pxd index 0a793b2d018..233e4f7c635 100644 --- a/python/cudf/cudf/_lib/io/utils.pxd +++ b/python/cudf/cudf/_lib/io/utils.pxd @@ -2,7 +2,8 @@ from libcpp.memory cimport unique_ptr -from cudf._lib.cpp.io.types cimport source_info, sink_info, data_sink +from cudf._lib.cpp.io.types cimport data_sink, sink_info, source_info + cdef source_info make_source_info(list src) except* cdef sink_info make_sink_info(src, unique_ptr[data_sink] & data) except* diff --git a/python/cudf/cudf/_lib/io/utils.pyx b/python/cudf/cudf/_lib/io/utils.pyx index 6598a7af626..846086107e1 100644 --- a/python/cudf/cudf/_lib/io/utils.pyx +++ b/python/cudf/cudf/_lib/io/utils.pyx @@ -4,20 +4,29 @@ from cpython.buffer cimport PyBUF_READ from cpython.memoryview cimport PyMemoryView_FromMemory from libcpp.map cimport map from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move -from libcpp.vector cimport vector from libcpp.pair cimport pair from libcpp.string cimport string -from cudf._lib.cpp.io.types cimport source_info, io_type, host_buffer -from cudf._lib.cpp.io.types cimport sink_info, data_sink, datasource +from libcpp.utility cimport move +from libcpp.vector cimport vector + +from cudf._lib.cpp.io.types cimport ( + data_sink, + datasource, + host_buffer, + io_type, + sink_info, + source_info, +) from cudf._lib.io.datasource cimport Datasource import codecs import errno import io import os + import cudf + # Converts the Python source input to libcudf++ IO source_info # with the appropriate type and source values cdef source_info make_source_info(list src) except*: diff --git a/python/cudf/cudf/_lib/join.pyx b/python/cudf/cudf/_lib/join.pyx index 193c2ca9d67..186f8d32aeb 100644 --- a/python/cudf/cudf/_lib/join.pyx +++ b/python/cudf/cudf/_lib/join.pyx @@ -1,24 +1,22 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import cudf - from itertools import chain -from libcpp.memory cimport unique_ptr, make_unique +import cudf + +from libcpp cimport bool +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move from libcpp.vector cimport vector -from libcpp.pair cimport pair -from libcpp cimport bool +cimport cudf._lib.cpp.join as cpp_join from cudf._lib.column cimport Column -from cudf._lib.table cimport Table, columns_from_ptr - from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.types cimport size_type, data_type, type_id from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.join as cpp_join - +from cudf._lib.cpp.types cimport data_type, size_type, type_id +from cudf._lib.table cimport Table, columns_from_ptr # The functions below return the *gathermaps* that represent # the join result when joining on the keys `lhs` and `rhs`. diff --git a/python/cudf/cudf/_lib/json.pyx b/python/cudf/cudf/_lib/json.pyx index 48538c50f88..4a15edf8a19 100644 --- a/python/cudf/cudf/_lib/json.pyx +++ b/python/cudf/cudf/_lib/json.pyx @@ -3,24 +3,25 @@ # cython: boundscheck = False -import cudf import collections.abc as abc import io import os +import cudf + from libcpp cimport bool from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector +cimport cudf._lib.cpp.io.types as cudf_io_types from cudf._lib.cpp.io.json cimport ( + json_reader_options, read_json as libcudf_read_json, - json_reader_options ) from cudf._lib.cpp.types cimport size_type from cudf._lib.io.utils cimport make_source_info from cudf._lib.table cimport Table -cimport cudf._lib.cpp.io.types as cudf_io_types cpdef read_json(object filepaths_or_buffers, diff --git a/python/cudf/cudf/_lib/labeling.pyx b/python/cudf/cudf/_lib/labeling.pyx index 1b553024347..088942064a8 100644 --- a/python/cudf/cudf/_lib/labeling.pyx +++ b/python/cudf/cudf/_lib/labeling.pyx @@ -1,20 +1,21 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -import numpy as np from enum import IntEnum +import numpy as np + from libc.stdint cimport uint32_t from libcpp cimport bool as cbool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from cudf._lib.column cimport Column + from cudf._lib.replace import replace_nulls -from cudf._lib.cpp.labeling cimport inclusive -from cudf._lib.cpp.labeling cimport label_bins as cpp_label_bins from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.labeling cimport inclusive, label_bins as cpp_label_bins # Note that the parameter input shadows a Python built-in in the local scope, diff --git a/python/cudf/cudf/_lib/lists.pyx b/python/cudf/cudf/_lib/lists.pyx index 7d8909610dc..245bb3666ea 100644 --- a/python/cudf/cudf/_lib/lists.pyx +++ b/python/cudf/cudf/_lib/lists.pyx @@ -1,52 +1,45 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.memory cimport unique_ptr, shared_ptr, make_shared +from libcpp.memory cimport make_shared, shared_ptr, unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.lists.count_elements cimport ( - count_elements as cpp_count_elements +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.lists.combine cimport ( + concatenate_rows as cpp_concatenate_rows, ) -from cudf._lib.cpp.lists.explode cimport ( - explode_outer as cpp_explode_outer +from cudf._lib.cpp.lists.count_elements cimport ( + count_elements as cpp_count_elements, ) from cudf._lib.cpp.lists.drop_list_duplicates cimport ( - drop_list_duplicates as cpp_drop_list_duplicates -) -from cudf._lib.cpp.lists.sorting cimport ( - sort_lists as cpp_sort_lists -) -from cudf._lib.cpp.lists.combine cimport ( - concatenate_rows as cpp_concatenate_rows + drop_list_duplicates as cpp_drop_list_duplicates, ) +from cudf._lib.cpp.lists.explode cimport explode_outer as cpp_explode_outer from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column - -from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.lists.sorting cimport sort_lists as cpp_sort_lists from cudf._lib.cpp.scalar.scalar cimport scalar - from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport ( - size_type, + nan_equality, null_equality, + null_order, null_policy, order, - null_order, - nan_equality + size_type, ) - -from cudf._lib.column cimport Column +from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table - from cudf._lib.types cimport ( - underlying_type_t_null_order, underlying_type_t_order + underlying_type_t_null_order, + underlying_type_t_order, ) + from cudf.core.dtypes import ListDtype from cudf._lib.cpp.lists.contains cimport contains - from cudf._lib.cpp.lists.extract cimport extract_list_element diff --git a/python/cudf/cudf/_lib/merge.pyx b/python/cudf/cudf/_lib/merge.pyx index 81d5807906a..cc2d405c207 100644 --- a/python/cudf/cudf/_lib/merge.pyx +++ b/python/cudf/cudf/_lib/merge.pyx @@ -1,17 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp cimport bool +from libcpp.vector cimport vector +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - +from cudf._lib.cpp.merge cimport merge as cpp_merge from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.merge cimport merge as cpp_merge -cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.table cimport Table def merge_sorted( diff --git a/python/cudf/cudf/_lib/null_mask.pyx b/python/cudf/cudf/_lib/null_mask.pyx index 81ddbaa48ac..b6e26fe594f 100644 --- a/python/cudf/cudf/_lib/null_mask.pyx +++ b/python/cudf/cudf/_lib/null_mask.pyx @@ -2,22 +2,23 @@ from enum import Enum -from libcpp.memory cimport unique_ptr, make_unique +from libcpp.memory cimport make_unique, unique_ptr from libcpp.utility cimport move -from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from cudf._lib.column cimport Column + import cudf._lib as libcudfxx -from cudf._lib.cpp.types cimport mask_state, size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.null_mask cimport ( + bitmask_allocation_size_bytes as cpp_bitmask_allocation_size_bytes, copy_bitmask as cpp_copy_bitmask, create_null_mask as cpp_create_null_mask, - bitmask_allocation_size_bytes as cpp_bitmask_allocation_size_bytes, - underlying_type_t_mask_state + underlying_type_t_mask_state, ) +from cudf._lib.cpp.types cimport mask_state, size_type from cudf.core.buffer import Buffer diff --git a/python/cudf/cudf/_lib/nvtext/edit_distance.pyx b/python/cudf/cudf/_lib/nvtext/edit_distance.pyx index a1e59585df2..f1e15570e9f 100644 --- a/python/cudf/cudf/_lib/nvtext/edit_distance.pyx +++ b/python/cudf/cudf/_lib/nvtext/edit_distance.pyx @@ -4,13 +4,13 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.edit_distance cimport ( edit_distance as cpp_edit_distance, - edit_distance_matrix as cpp_edit_distance_matrix + edit_distance_matrix as cpp_edit_distance_matrix, ) -from cudf._lib.column cimport Column def edit_distance(Column strings, Column targets): diff --git a/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx b/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx index 48d67110621..5fcec570dcb 100644 --- a/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx +++ b/python/cudf/cudf/_lib/nvtext/generate_ngrams.pyx @@ -3,15 +3,15 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.generate_ngrams cimport ( + generate_character_ngrams as cpp_generate_character_ngrams, generate_ngrams as cpp_generate_ngrams, - generate_character_ngrams as cpp_generate_character_ngrams ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx b/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx index cf0a4a0f55a..1e9e0e39ff1 100644 --- a/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/ngrams_tokenize.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.ngrams_tokenize cimport ( - ngrams_tokenize as cpp_ngrams_tokenize + ngrams_tokenize as cpp_ngrams_tokenize, ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/normalize.pyx b/python/cudf/cudf/_lib/nvtext/normalize.pyx index 88f0f0a957a..e475f0cd996 100644 --- a/python/cudf/cudf/_lib/nvtext/normalize.pyx +++ b/python/cudf/cudf/_lib/nvtext/normalize.pyx @@ -4,13 +4,13 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.normalize cimport ( normalize_characters as cpp_normalize_characters, - normalize_spaces as cpp_normalize_spaces + normalize_spaces as cpp_normalize_spaces, ) -from cudf._lib.column cimport Column def normalize_spaces(Column strings): diff --git a/python/cudf/cudf/_lib/nvtext/replace.pyx b/python/cudf/cudf/_lib/nvtext/replace.pyx index cb552161b52..b4f37ac3ec7 100644 --- a/python/cudf/cudf/_lib/nvtext/replace.pyx +++ b/python/cudf/cudf/_lib/nvtext/replace.pyx @@ -3,15 +3,15 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.replace cimport ( - replace_tokens as cpp_replace_tokens, filter_tokens as cpp_filter_tokens, + replace_tokens as cpp_replace_tokens, ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/nvtext/stemmer.pyx b/python/cudf/cudf/_lib/nvtext/stemmer.pyx index 1aca32a5667..89d4b07b7ad 100644 --- a/python/cudf/cudf/_lib/nvtext/stemmer.pyx +++ b/python/cudf/cudf/_lib/nvtext/stemmer.pyx @@ -2,19 +2,19 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from enum import IntEnum +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column - from cudf._lib.cpp.nvtext.stemmer cimport ( - porter_stemmer_measure as cpp_porter_stemmer_measure, is_letter as cpp_is_letter, - letter_type as letter_type + letter_type as letter_type, + porter_stemmer_measure as cpp_porter_stemmer_measure, + underlying_type_t_letter_type, ) -from cudf._lib.cpp.nvtext.stemmer cimport underlying_type_t_letter_type +from cudf._lib.cpp.types cimport size_type class LetterType(IntEnum): diff --git a/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx b/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx index 3cf3cbe1ef2..49f24436b88 100644 --- a/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/subword_tokenize.pyx @@ -1,22 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport uint32_t, uintptr_t from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.string cimport string -from libc.stdint cimport uint32_t -from libc.stdint cimport uintptr_t +from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.nvtext.subword_tokenize cimport( - subword_tokenize as cpp_subword_tokenize, +from cudf._lib.cpp.nvtext.subword_tokenize cimport ( hashed_vocabulary as cpp_hashed_vocabulary, load_vocabulary_file as cpp_load_vocabulary_file, - tokenizer_result as cpp_tokenizer_result, move as tr_move, + subword_tokenize as cpp_subword_tokenize, + tokenizer_result as cpp_tokenizer_result, ) -from cudf._lib.column cimport Column cdef class Hashed_Vocabulary: diff --git a/python/cudf/cudf/_lib/nvtext/tokenize.pyx b/python/cudf/cudf/_lib/nvtext/tokenize.pyx index c7f5c2a12c4..5fc852c2ab0 100644 --- a/python/cudf/cudf/_lib/nvtext/tokenize.pyx +++ b/python/cudf/cudf/_lib/nvtext/tokenize.pyx @@ -3,17 +3,17 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.nvtext.tokenize cimport ( - tokenize as cpp_tokenize, - detokenize as cpp_detokenize, + character_tokenize as cpp_character_tokenize, count_tokens as cpp_count_tokens, - character_tokenize as cpp_character_tokenize + detokenize as cpp_detokenize, + tokenize as cpp_tokenize, ) -from cudf._lib.column cimport Column +from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.types cimport size_type from cudf._lib.scalar cimport DeviceScalar diff --git a/python/cudf/cudf/_lib/orc.pyx b/python/cudf/cudf/_lib/orc.pyx index 69d67c5b02d..ea4b4ae7ca3 100644 --- a/python/cudf/cudf/_lib/orc.pyx +++ b/python/cudf/cudf/_lib/orc.pyx @@ -3,23 +3,23 @@ import cudf from libcpp cimport bool, int -from libcpp.memory cimport unique_ptr, make_unique +from libcpp.memory cimport make_unique, unique_ptr from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.utility cimport move -from cudf._lib.cpp.column.column cimport column +from libcpp.vector cimport vector -from cudf._lib.cpp.io.orc_metadata cimport ( - raw_orc_statistics, - read_raw_orc_statistics as libcudf_read_raw_orc_statistics -) +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.io.orc cimport ( + chunked_orc_writer_options, + orc_chunked_writer, orc_reader_options, - read_orc as libcudf_read_orc, orc_writer_options, + read_orc as libcudf_read_orc, write_orc as libcudf_write_orc, - chunked_orc_writer_options, - orc_chunked_writer +) +from cudf._lib.cpp.io.orc_metadata cimport ( + raw_orc_statistics, + read_raw_orc_statistics as libcudf_read_raw_orc_statistics, ) from cudf._lib.cpp.io.types cimport ( compression_type, @@ -27,27 +27,23 @@ from cudf._lib.cpp.io.types cimport ( sink_info, source_info, table_metadata, + table_metadata_with_nullability, table_with_metadata, - table_metadata_with_nullability ) - from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.types cimport ( - data_type, type_id, size_type -) - -from cudf._lib.io.utils cimport make_source_info, make_sink_info +from cudf._lib.cpp.types cimport data_type, size_type, type_id +from cudf._lib.io.utils cimport make_sink_info, make_source_info from cudf._lib.table cimport Table + from cudf._lib.types import np_to_cudf_types + from cudf._lib.types cimport underlying_type_t_type_id + import numpy as np from cudf._lib.utils cimport get_column_names -from cudf._lib.utils import ( - _index_level_name, - generate_pandas_metadata, -) +from cudf._lib.utils import _index_level_name, generate_pandas_metadata cpdef read_raw_orc_statistics(filepath_or_buffer): diff --git a/python/cudf/cudf/_lib/parquet.pyx b/python/cudf/cudf/_lib/parquet.pyx index 4ea2adec23a..088b475139b 100644 --- a/python/cudf/cudf/_lib/parquet.pyx +++ b/python/cudf/cudf/_lib/parquet.pyx @@ -2,70 +2,64 @@ # cython: boundscheck = False -import cudf import errno import os -import pyarrow as pa from collections import OrderedDict +import pyarrow as pa + +import cudf + try: import ujson as json except ImportError: import json -from cython.operator import dereference import numpy as np +from cython.operator import dereference from cudf.utils.dtypes import ( - np_to_pa_dtype, is_categorical_dtype, + is_decimal_dtype, is_list_dtype, is_struct_dtype, - is_decimal_dtype, + np_to_pa_dtype, ) from cudf._lib.utils cimport get_column_names -from cudf._lib.utils import ( - _index_level_name, - generate_pandas_metadata, -) -from libc.stdlib cimport free +from cudf._lib.utils import _index_level_name, generate_pandas_metadata + from libc.stdint cimport uint8_t -from libcpp.memory cimport unique_ptr, make_unique -from libcpp.string cimport string +from libc.stdlib cimport free +from libcpp cimport bool from libcpp.map cimport map -from libcpp.vector cimport vector +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from libcpp cimport bool - +from libcpp.vector cimport vector -from cudf._lib.cpp.types cimport data_type, size_type -from cudf._lib.table cimport Table -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport ( - table_view -) +cimport cudf._lib.cpp.io.types as cudf_io_types +cimport cudf._lib.cpp.types as cudf_types +from cudf._lib.column cimport Column from cudf._lib.cpp.io.parquet cimport ( - read_parquet as parquet_reader, - parquet_reader_options, - table_input_metadata, - column_in_metadata, - parquet_writer_options, - write_parquet as parquet_writer, - parquet_chunked_writer as cpp_parquet_chunked_writer, chunked_parquet_writer_options, chunked_parquet_writer_options_builder, + column_in_metadata, merge_rowgroup_metadata as parquet_merge_metadata, + parquet_chunked_writer as cpp_parquet_chunked_writer, + parquet_reader_options, + parquet_writer_options, + read_parquet as parquet_reader, + table_input_metadata, + write_parquet as parquet_writer, ) -from cudf._lib.column cimport Column -from cudf._lib.io.utils cimport ( - make_source_info, - make_sink_info -) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport data_type, size_type +from cudf._lib.io.utils cimport make_sink_info, make_source_info +from cudf._lib.table cimport Table -cimport cudf._lib.cpp.types as cudf_types -cimport cudf._lib.cpp.io.types as cudf_io_types cdef class BufferArrayFromVector: cdef Py_ssize_t length diff --git a/python/cudf/cudf/_lib/partitioning.pyx b/python/cudf/cudf/_lib/partitioning.pyx index b33ccb24039..865138bec84 100644 --- a/python/cudf/cudf/_lib/partitioning.pyx +++ b/python/cudf/cudf/_lib/partitioning.pyx @@ -1,22 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.pair cimport pair from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector +from libcpp.pair cimport pair from libcpp.utility cimport move +from libcpp.vector cimport vector from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.partitioning cimport partition as cpp_partition from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.table cimport Table -from cudf._lib.cpp.partitioning cimport ( - partition as cpp_partition, -) from cudf._lib.stream_compaction import distinct_count as cpp_distinct_count + cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/quantiles.pyx b/python/cudf/cudf/_lib/quantiles.pyx index 0c1338103be..45a4ff7c92c 100644 --- a/python/cudf/cudf/_lib/quantiles.pyx +++ b/python/cudf/cudf/_lib/quantiles.pyx @@ -1,34 +1,36 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp cimport bool -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table from cudf._lib.types cimport ( - underlying_type_t_order, + underlying_type_t_interpolation, underlying_type_t_null_order, + underlying_type_t_order, underlying_type_t_sorted, - underlying_type_t_interpolation, ) + from cudf._lib.types import Interpolation + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.quantiles cimport ( + quantile as cpp_quantile, + quantiles as cpp_quantiles, +) from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport ( interpolation, null_order, order, - sorted, order_info, -) -from cudf._lib.cpp.quantiles cimport ( - quantile as cpp_quantile, - quantiles as cpp_quantiles, + sorted, ) diff --git a/python/cudf/cudf/_lib/reduce.pyx b/python/cudf/cudf/_lib/reduce.pyx index e5723331f3c..49ebb0a2528 100644 --- a/python/cudf/cudf/_lib/reduce.pyx +++ b/python/cudf/cudf/_lib/reduce.pyx @@ -1,20 +1,25 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. import cudf -from cudf.utils.dtypes import is_decimal_dtype from cudf.core.dtypes import Decimal64Dtype -from cudf._lib.cpp.reduce cimport cpp_reduce, cpp_scan, scan_type, cpp_minmax +from cudf.utils.dtypes import is_decimal_dtype + +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.reduce cimport cpp_minmax, cpp_reduce, cpp_scan, scan_type from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.types cimport data_type, type_id -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.column.column cimport column from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.column cimport Column + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type -from cudf._lib.aggregation cimport make_aggregation, Aggregation + from libcpp.memory cimport unique_ptr from libcpp.utility cimport move, pair + +from cudf._lib.aggregation cimport Aggregation, make_aggregation +from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id + import numpy as np cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/replace.pyx b/python/cudf/cudf/_lib/replace.pyx index cdedd3ac022..2ae0835566b 100644 --- a/python/cudf/cudf/_lib/replace.pyx +++ b/python/cudf/cudf/_lib/replace.pyx @@ -6,22 +6,20 @@ from libcpp.utility cimport move from cudf.utils.dtypes import is_scalar from cudf._lib.column cimport Column + from cudf._lib.scalar import as_device_scalar -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.replace cimport ( - replace_policy as cpp_replace_policy, + clamp as cpp_clamp, find_and_replace_all as cpp_find_and_replace_all, + normalize_nans_and_zeros as cpp_normalize_nans_and_zeros, replace_nulls as cpp_replace_nulls, - clamp as cpp_clamp, - normalize_nans_and_zeros as cpp_normalize_nans_and_zeros + replace_policy as cpp_replace_policy, ) +from cudf._lib.cpp.scalar.scalar cimport scalar +from cudf._lib.scalar cimport DeviceScalar def replace(Column input_col, Column values_to_replace, diff --git a/python/cudf/cudf/_lib/reshape.pyx b/python/cudf/cudf/_lib/reshape.pyx index cebe48eb697..fbed410de86 100644 --- a/python/cudf/cudf/_lib/reshape.pyx +++ b/python/cudf/cudf/_lib/reshape.pyx @@ -2,18 +2,17 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view - from cudf._lib.cpp.reshape cimport ( interleave_columns as cpp_interleave_columns, - tile as cpp_tile + tile as cpp_tile, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.table cimport Table def interleave_columns(Table source_table): diff --git a/python/cudf/cudf/_lib/rolling.pyx b/python/cudf/cudf/_lib/rolling.pyx index 6fe661a25a5..87c2fa6178f 100644 --- a/python/cudf/cudf/_lib/rolling.pyx +++ b/python/cudf/cudf/_lib/rolling.pyx @@ -1,21 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from __future__ import print_function -import cudf + import pandas as pd +import cudf + from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.column cimport Column from cudf._lib.aggregation cimport RollingAggregation, make_rolling_aggregation - -from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.rolling cimport ( - rolling_window as cpp_rolling_window -) +from cudf._lib.cpp.rolling cimport rolling_window as cpp_rolling_window +from cudf._lib.cpp.types cimport size_type def rolling(Column source_column, Column pre_column_window, diff --git a/python/cudf/cudf/_lib/round.pyx b/python/cudf/cudf/_lib/round.pyx index 823da40f45b..c5c565561a9 100644 --- a/python/cudf/cudf/_lib/round.pyx +++ b/python/cudf/cudf/_lib/round.pyx @@ -4,12 +4,11 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from cudf._lib.column cimport Column - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.round cimport ( + round as cpp_round, rounding_method as cpp_rounding_method, - round as cpp_round ) diff --git a/python/cudf/cudf/_lib/scalar.pyx b/python/cudf/cudf/_lib/scalar.pyx index cb355a15f15..b0c74409621 100644 --- a/python/cudf/cudf/_lib/scalar.pyx +++ b/python/cudf/cudf/_lib/scalar.pyx @@ -1,5 +1,6 @@ # Copyright (c) 2020, NVIDIA CORPORATION. import decimal + import numpy as np import pandas as pd @@ -13,49 +14,53 @@ from libc.stdint cimport ( uint32_t, uint64_t, ) +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from libcpp cimport bool import cudf -from cudf.core.dtypes import ListDtype from cudf._lib.types import ( cudf_to_np_types, - duration_unit_map + datetime_unit_map, + duration_unit_map, ) -from cudf._lib.types import datetime_unit_map -from cudf._lib.types cimport underlying_type_t_type_id, dtype_from_column_view +from cudf.core.dtypes import ListDtype from cudf._lib.column cimport Column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.table cimport Table +from cudf._lib.types cimport dtype_from_column_view, underlying_type_t_type_id + from cudf._lib.interop import to_arrow -from cudf._lib.cpp.wrappers.timestamps cimport ( - timestamp_s, - timestamp_ms, - timestamp_us, - timestamp_ns -) -from cudf._lib.cpp.wrappers.durations cimport( - duration_s, - duration_ms, - duration_us, - duration_ns -) -from cudf._lib.cpp.wrappers.decimals cimport decimal64, scale_type from cudf._lib.cpp.scalar.scalar cimport ( - scalar, - numeric_scalar, - timestamp_scalar, duration_scalar, - string_scalar, fixed_point_scalar, list_scalar, + numeric_scalar, + scalar, + string_scalar, + timestamp_scalar, +) +from cudf._lib.cpp.wrappers.decimals cimport decimal64, scale_type +from cudf._lib.cpp.wrappers.durations cimport ( + duration_ms, + duration_ns, + duration_s, + duration_us, ) +from cudf._lib.cpp.wrappers.timestamps cimport ( + timestamp_ms, + timestamp_ns, + timestamp_s, + timestamp_us, +) + from cudf.utils.dtypes import _decimal_to_int64, is_list_dtype + cimport cudf._lib.cpp.types as libcudf_types + cdef class DeviceScalar: def __init__(self, value, dtype): diff --git a/python/cudf/cudf/_lib/search.pyx b/python/cudf/cudf/_lib/search.pyx index 402e3456821..33471028d66 100644 --- a/python/cudf/cudf/_lib/search.pyx +++ b/python/cudf/cudf/_lib/search.pyx @@ -1,17 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector +cimport cudf._lib.cpp.search as cpp_search +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view -cimport cudf._lib.cpp.types as libcudf_types -cimport cudf._lib.cpp.search as cpp_search +from cudf._lib.table cimport Table def search_sorted( diff --git a/python/cudf/cudf/_lib/sort.pxd b/python/cudf/cudf/_lib/sort.pxd index 6a06c132daa..d7488889555 100644 --- a/python/cudf/cudf/_lib/sort.pxd +++ b/python/cudf/cudf/_lib/sort.pxd @@ -1,2 +1,3 @@ from libc.stdint cimport int32_t + ctypedef int32_t underlying_type_t_rank_method diff --git a/python/cudf/cudf/_lib/sort.pyx b/python/cudf/cudf/_lib/sort.pyx index a20ab4c1bf4..1d15052e41a 100644 --- a/python/cudf/cudf/_lib/sort.pyx +++ b/python/cudf/cudf/_lib/sort.pyx @@ -4,23 +4,26 @@ import pandas as pd from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector from libcpp.utility cimport move +from libcpp.vector cimport vector + from enum import IntEnum from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.search cimport lower_bound, upper_bound -from cudf._lib.cpp.sorting cimport( - rank, rank_method, sorted_order, is_sorted as cpp_is_sorted +from cudf._lib.cpp.sorting cimport ( + is_sorted as cpp_is_sorted, + rank, + rank_method, + sorted_order, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport null_order, null_policy, order from cudf._lib.sort cimport underlying_type_t_rank_method -from cudf._lib.cpp.types cimport order, null_order, null_policy +from cudf._lib.table cimport Table def is_sorted( diff --git a/python/cudf/cudf/_lib/stream_compaction.pyx b/python/cudf/cudf/_lib/stream_compaction.pyx index cabbdf89b4e..a7326efcc03 100644 --- a/python/cudf/cudf/_lib/stream_compaction.pyx +++ b/python/cudf/cudf/_lib/stream_compaction.pyx @@ -2,27 +2,29 @@ import pandas as pd +from libcpp cimport bool from libcpp.memory cimport unique_ptr -from libcpp.vector cimport vector from libcpp.utility cimport move -from libcpp cimport bool +from libcpp.vector cimport vector from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - -from cudf._lib.cpp.types cimport ( - size_type, null_policy, nan_policy, null_equality -) -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.stream_compaction cimport ( - duplicate_keep_option, - drop_nulls as cpp_drop_nulls, apply_boolean_mask as cpp_apply_boolean_mask, + distinct_count as cpp_distinct_count, drop_duplicates as cpp_drop_duplicates, - distinct_count as cpp_distinct_count + drop_nulls as cpp_drop_nulls, + duplicate_keep_option, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport ( + nan_policy, + null_equality, + null_policy, + size_type, +) +from cudf._lib.table cimport Table def drop_nulls(Table source_table, how="any", keys=None, thresh=None): diff --git a/python/cudf/cudf/_lib/string_casting.pyx b/python/cudf/cudf/_lib/string_casting.pyx index 772a4d60ade..8f65cc9fee5 100644 --- a/python/cudf/cudf/_lib/string_casting.pyx +++ b/python/cudf/cudf/_lib/string_casting.pyx @@ -3,57 +3,58 @@ import numpy as np from cudf._lib.column cimport Column + from cudf._lib.scalar import as_device_scalar + from cudf._lib.scalar cimport DeviceScalar + from cudf._lib.types import np_to_cudf_types + from cudf._lib.types cimport underlying_type_t_type_id from cudf.core.column.column import as_column +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string +from libcpp.utility cimport move + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.convert.convert_booleans cimport ( + from_booleans as cpp_from_booleans, to_booleans as cpp_to_booleans, - from_booleans as cpp_from_booleans ) from cudf._lib.cpp.strings.convert.convert_datetime cimport ( - to_timestamps as cpp_to_timestamps, from_timestamps as cpp_from_timestamps, - is_timestamp as cpp_is_timestamp + is_timestamp as cpp_is_timestamp, + to_timestamps as cpp_to_timestamps, +) +from cudf._lib.cpp.strings.convert.convert_durations cimport ( + from_durations as cpp_from_durations, + to_durations as cpp_to_durations, ) from cudf._lib.cpp.strings.convert.convert_floats cimport ( + from_floats as cpp_from_floats, to_floats as cpp_to_floats, - from_floats as cpp_from_floats ) from cudf._lib.cpp.strings.convert.convert_integers cimport ( - to_integers as cpp_to_integers, from_integers as cpp_from_integers, hex_to_integers as cpp_hex_to_integers, + integers_to_hex as cpp_integers_to_hex, is_hex as cpp_is_hex, - integers_to_hex as cpp_integers_to_hex + to_integers as cpp_to_integers, ) from cudf._lib.cpp.strings.convert.convert_ipv4 cimport ( - ipv4_to_integers as cpp_ipv4_to_integers, integers_to_ipv4 as cpp_integers_to_ipv4, - is_ipv4 as cpp_is_ipv4 + ipv4_to_integers as cpp_ipv4_to_integers, + is_ipv4 as cpp_is_ipv4, ) from cudf._lib.cpp.strings.convert.convert_urls cimport ( + url_decode as cpp_url_decode, url_encode as cpp_url_encode, - url_decode as cpp_url_decode -) -from cudf._lib.cpp.strings.convert.convert_durations cimport ( - to_durations as cpp_to_durations, - from_durations as cpp_from_durations -) -from cudf._lib.cpp.types cimport ( - type_id, - data_type, ) - -from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move -from libcpp.string cimport string +from cudf._lib.cpp.types cimport data_type, type_id def floating_to_string(Column input_col): diff --git a/python/cudf/cudf/_lib/strings/attributes.pyx b/python/cudf/cudf/_lib/strings/attributes.pyx index 3e0bacda546..8720fad7455 100644 --- a/python/cudf/cudf/_lib/strings/attributes.pyx +++ b/python/cudf/cudf/_lib/strings/attributes.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.attributes cimport ( - count_characters as cpp_count_characters, code_points as cpp_code_points, - count_bytes as cpp_count_bytes + count_bytes as cpp_count_bytes, + count_characters as cpp_count_characters, ) -from cudf._lib.column cimport Column def count_characters(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/capitalize.pyx b/python/cudf/cudf/_lib/strings/capitalize.pyx index 8316d42ee15..bb1bf25ef7b 100644 --- a/python/cudf/cudf/_lib/strings/capitalize.pyx +++ b/python/cudf/cudf/_lib/strings/capitalize.pyx @@ -3,13 +3,13 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.capitalize cimport ( capitalize as cpp_capitalize, title as cpp_title, ) -from cudf._lib.column cimport Column def capitalize(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/case.pyx b/python/cudf/cudf/_lib/strings/case.pyx index 6f114519374..13679f3fb02 100644 --- a/python/cudf/cudf/_lib/strings/case.pyx +++ b/python/cudf/cudf/_lib/strings/case.pyx @@ -3,14 +3,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.case cimport ( swapcase as cpp_swapcase, to_lower as cpp_to_lower, - to_upper as cpp_to_upper + to_upper as cpp_to_upper, ) -from cudf._lib.column cimport Column def to_upper(Column source_strings): diff --git a/python/cudf/cudf/_lib/strings/char_types.pyx b/python/cudf/cudf/_lib/strings/char_types.pyx index 1890e98f956..3ef9db2345d 100644 --- a/python/cudf/cudf/_lib/strings/char_types.pyx +++ b/python/cudf/cudf/_lib/strings/char_types.pyx @@ -4,17 +4,16 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.char_types cimport ( all_characters_of_type as cpp_all_characters_of_type, filter_characters_of_type as cpp_filter_characters_of_type, string_character_types as string_character_types, ) +from cudf._lib.scalar cimport DeviceScalar def filter_alphanum(Column source_strings, object py_repl, bool keep=True): diff --git a/python/cudf/cudf/_lib/strings/combine.pyx b/python/cudf/cudf/_lib/strings/combine.pyx index 3d20e5f15b7..e165c76e98d 100644 --- a/python/cudf/cudf/_lib/strings/combine.pyx +++ b/python/cudf/cudf/_lib/strings/combine.pyx @@ -1,25 +1,24 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type + from cudf._lib.column cimport Column -from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string -from cudf._lib.table cimport Table - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.combine cimport ( concatenate as cpp_concatenate, - join_strings as cpp_join_strings, join_list_elements as cpp_join_list_elements, + join_strings as cpp_join_strings, + output_if_empty_list as output_if_empty_list, separator_on_nulls as separator_on_nulls, - output_if_empty_list as output_if_empty_list ) +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def concatenate(Table source_strings, diff --git a/python/cudf/cudf/_lib/strings/contains.pyx b/python/cudf/cudf/_lib/strings/contains.pyx index 256803c9479..1f622378280 100644 --- a/python/cudf/cudf/_lib/strings/contains.pyx +++ b/python/cudf/cudf/_lib/strings/contains.pyx @@ -1,18 +1,18 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.contains cimport ( contains_re as cpp_contains_re, count_re as cpp_count_re, - matches_re as cpp_matches_re + matches_re as cpp_matches_re, ) -from libcpp.string cimport string +from cudf._lib.scalar cimport DeviceScalar def contains_re(Column source_strings, object reg_ex): diff --git a/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx b/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx index 38d238b8266..ae61df3d271 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_fixed_point.pyx @@ -3,27 +3,26 @@ import numpy as np from cudf._lib.column cimport Column + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id + from cudf._lib.cpp.types cimport DECIMAL64 +from cudf._lib.types cimport underlying_type_t_type_id from cudf.core.column.column import as_column +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string +from libcpp.utility cimport move + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_fixed_point cimport ( - to_fixed_point as cpp_to_fixed_point, from_fixed_point as cpp_from_fixed_point, - is_fixed_point as cpp_is_fixed_point -) -from cudf._lib.cpp.types cimport ( - type_id, - data_type, + is_fixed_point as cpp_is_fixed_point, + to_fixed_point as cpp_to_fixed_point, ) - -from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move -from libcpp.string cimport string +from cudf._lib.cpp.types cimport data_type, type_id def from_decimal(Column input_col): diff --git a/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx b/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx index 195d9b71f6e..d47b1e6e651 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_floats.pyx @@ -4,10 +4,9 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_floats cimport ( is_float as cpp_is_float, ) diff --git a/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx b/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx index d1bae1edd37..08bcca93086 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_integers.pyx @@ -4,10 +4,9 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_integers cimport ( is_integer as cpp_is_integer, ) diff --git a/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx b/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx index 6aab99b3ec5..c391719e853 100644 --- a/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx +++ b/python/cudf/cudf/_lib/strings/convert/convert_urls.pyx @@ -2,13 +2,13 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view + from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.convert.convert_urls cimport ( - url_encode as cpp_url_encode, url_decode as cpp_url_decode, + url_encode as cpp_url_encode, ) diff --git a/python/cudf/cudf/_lib/strings/extract.pyx b/python/cudf/cudf/_lib/strings/extract.pyx index 5828b62b999..58558fade24 100644 --- a/python/cudf/cudf/_lib/strings/extract.pyx +++ b/python/cudf/cudf/_lib/strings/extract.pyx @@ -1,20 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.strings.extract cimport extract as cpp_extract from cudf._lib.cpp.table.table cimport table +from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table -from cudf._lib.cpp.column.column cimport column - -from cudf._lib.cpp.strings.extract cimport ( - extract as cpp_extract -) -from libcpp.string cimport string - def extract(Column source_strings, object pattern): """ diff --git a/python/cudf/cudf/_lib/strings/find.pyx b/python/cudf/cudf/_lib/strings/find.pyx index 3a360d31ef2..788c0a2524a 100644 --- a/python/cudf/cudf/_lib/strings/find.pyx +++ b/python/cudf/cudf/_lib/strings/find.pyx @@ -1,21 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type - from cudf._lib.cpp.strings.find cimport ( contains as cpp_contains, ends_with as cpp_ends_with, - starts_with as cpp_starts_with, find as cpp_find, - rfind as cpp_rfind + rfind as cpp_rfind, + starts_with as cpp_starts_with, ) +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def contains(Column source_strings, object py_target): diff --git a/python/cudf/cudf/_lib/strings/find_multiple.pyx b/python/cudf/cudf/_lib/strings/find_multiple.pyx index 5c33be07d15..4ac86ce4ef5 100644 --- a/python/cudf/cudf/_lib/strings/find_multiple.pyx +++ b/python/cudf/cudf/_lib/strings/find_multiple.pyx @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.strings.find_multiple cimport ( find_multiple as cpp_find_multiple, ) diff --git a/python/cudf/cudf/_lib/strings/findall.pyx b/python/cudf/cudf/_lib/strings/findall.pyx index 7dbfbe62def..cc5730c467d 100644 --- a/python/cudf/cudf/_lib/strings/findall.pyx +++ b/python/cudf/cudf/_lib/strings/findall.pyx @@ -1,20 +1,17 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.table.table cimport table -from cudf._lib.table cimport Table +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar - -from cudf._lib.cpp.strings.findall cimport ( - findall_re as cpp_findall_re -) -from libcpp.string cimport string +from cudf._lib.cpp.strings.findall cimport findall_re as cpp_findall_re +from cudf._lib.cpp.table.table cimport table +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def findall(Column source_strings, pattern): diff --git a/python/cudf/cudf/_lib/strings/json.pyx b/python/cudf/cudf/_lib/strings/json.pyx index 211bbe9d4f0..c7545b6e481 100644 --- a/python/cudf/cudf/_lib/strings/json.pyx +++ b/python/cudf/cudf/_lib/strings/json.pyx @@ -2,16 +2,14 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar +from cudf._lib.cpp.strings.json cimport get_json_object as cpp_get_json_object from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.column.column cimport column - -from cudf._lib.cpp.strings.json cimport ( - get_json_object as cpp_get_json_object -) def get_json_object(Column col, object py_json_path): diff --git a/python/cudf/cudf/_lib/strings/padding.pyx b/python/cudf/cudf/_lib/strings/padding.pyx index 52c66495d92..c7b97977d60 100644 --- a/python/cudf/cudf/_lib/strings/padding.pyx +++ b/python/cudf/cudf/_lib/strings/padding.pyx @@ -2,19 +2,22 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column from cudf._lib.scalar cimport DeviceScalar + from enum import IntEnum + from libcpp.string cimport string -from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.strings.padding cimport ( pad as cpp_pad, + pad_side as pad_side, zfill as cpp_zfill, - pad_side as pad_side ) from cudf._lib.strings.padding cimport underlying_type_t_pad_side diff --git a/python/cudf/cudf/_lib/strings/replace.pyx b/python/cudf/cudf/_lib/strings/replace.pyx index 429e356be4a..f5c47d2a2ed 100644 --- a/python/cudf/cudf/_lib/strings/replace.pyx +++ b/python/cudf/cudf/_lib/strings/replace.pyx @@ -1,24 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport int32_t from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar from cudf._lib.cpp.column.column cimport column - -from libc.stdint cimport int32_t - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.replace cimport ( + replace as cpp_replace, replace_slice as cpp_replace_slice, - replace as cpp_replace -) - -from cudf._lib.cpp.strings.substring cimport ( - slice_strings as cpp_slice_strings ) +from cudf._lib.cpp.strings.substring cimport slice_strings as cpp_slice_strings +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def slice_replace(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/replace_re.pyx b/python/cudf/cudf/_lib/strings/replace_re.pyx index 7993e3a172f..20fb903c60c 100644 --- a/python/cudf/cudf/_lib/strings/replace_re.pyx +++ b/python/cudf/cudf/_lib/strings/replace_re.pyx @@ -1,21 +1,20 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from cudf._lib.cpp.types cimport size_type from libcpp.vector cimport vector +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar - from cudf._lib.cpp.strings.replace_re cimport ( replace_re as cpp_replace_re, - replace_with_backrefs as cpp_replace_with_backrefs + replace_with_backrefs as cpp_replace_with_backrefs, ) -from libcpp.string cimport string +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def replace_re(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/split/partition.pyx b/python/cudf/cudf/_lib/strings/split/partition.pyx index 64d625bcb26..590de5bf526 100644 --- a/python/cudf/cudf/_lib/strings/split/partition.pyx +++ b/python/cudf/cudf/_lib/strings/split/partition.pyx @@ -1,23 +1,22 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.split.partition cimport ( partition as cpp_partition, rpartition as cpp_rpartition, ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def partition(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/split/split.pyx b/python/cudf/cudf/_lib/strings/split/split.pyx index 2dd66f99ad5..599f7602b51 100644 --- a/python/cudf/cudf/_lib/strings/split/split.pyx +++ b/python/cudf/cudf/_lib/strings/split/split.pyx @@ -1,25 +1,24 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table -from cudf._lib.cpp.table.table cimport table +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.table.table_view cimport table_view -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.split.split cimport ( - split as cpp_split, rsplit as cpp_rsplit, + rsplit_record as cpp_rsplit_record, + split as cpp_split, split_record as cpp_split_record, - rsplit_record as cpp_rsplit_record ) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar +from cudf._lib.table cimport Table def split(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/strip.pyx b/python/cudf/cudf/_lib/strings/strip.pyx index 72dffa3d897..d3430a53cc6 100644 --- a/python/cudf/cudf/_lib/strings/strip.pyx +++ b/python/cudf/cudf/_lib/strings/strip.pyx @@ -1,19 +1,19 @@ # Copyright (c) 2020, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.scalar.scalar cimport string_scalar -from cudf._lib.cpp.types cimport size_type + from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from libcpp.string cimport string from cudf._lib.cpp.column.column cimport column - +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.strip cimport ( strip as cpp_strip, - strip_type as strip_type + strip_type as strip_type, ) +from cudf._lib.cpp.types cimport size_type +from cudf._lib.scalar cimport DeviceScalar def strip(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/substring.pyx b/python/cudf/cudf/_lib/strings/substring.pyx index add9e67b09f..761e9503aba 100644 --- a/python/cudf/cudf/_lib/strings/substring.pyx +++ b/python/cudf/cudf/_lib/strings/substring.pyx @@ -1,20 +1,21 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column_view cimport column_view from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + from cudf._lib.column cimport Column -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type + import numpy as np -from cudf._lib.cpp.strings.substring cimport ( - slice_strings as cpp_slice_strings -) +from cudf._lib.cpp.strings.substring cimport slice_strings as cpp_slice_strings from cudf._lib.scalar import as_device_scalar -from cudf._lib.scalar cimport DeviceScalar + from cudf._lib.cpp.scalar.scalar cimport numeric_scalar +from cudf._lib.scalar cimport DeviceScalar def slice_strings(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/translate.pyx b/python/cudf/cudf/_lib/strings/translate.pyx index 32b145736ca..7a5cf502ba3 100644 --- a/python/cudf/cudf/_lib/strings/translate.pyx +++ b/python/cudf/cudf/_lib/strings/translate.pyx @@ -2,21 +2,21 @@ from libcpp cimport bool from libcpp.memory cimport unique_ptr +from libcpp.pair cimport pair from libcpp.utility cimport move +from libcpp.vector cimport vector +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.scalar.scalar cimport string_scalar from cudf._lib.cpp.strings.translate cimport ( - translate as cpp_translate, + filter_characters as cpp_filter_characters, filter_type as filter_type, - filter_characters as cpp_filter_characters + translate as cpp_translate, ) -from cudf._lib.column cimport Column -from cudf._lib.scalar cimport DeviceScalar -from libcpp.vector cimport vector -from libcpp.pair cimport pair from cudf._lib.cpp.types cimport char_utf8 +from cudf._lib.scalar cimport DeviceScalar def translate(Column source_strings, diff --git a/python/cudf/cudf/_lib/strings/wrap.pyx b/python/cudf/cudf/_lib/strings/wrap.pyx index 814df1f1a72..5ebc33f77ef 100644 --- a/python/cudf/cudf/_lib/strings/wrap.pyx +++ b/python/cudf/cudf/_lib/strings/wrap.pyx @@ -2,14 +2,12 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from cudf._lib.cpp.column.column_view cimport column_view + +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.strings.wrap cimport wrap as cpp_wrap from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column - -from cudf._lib.cpp.strings.wrap cimport ( - wrap as cpp_wrap -) def wrap(Column source_strings, diff --git a/python/cudf/cudf/_lib/table.pxd b/python/cudf/cudf/_lib/table.pxd index ff0223b2519..e1bffbc3864 100644 --- a/python/cudf/cudf/_lib/table.pxd +++ b/python/cudf/cudf/_lib/table.pxd @@ -3,9 +3,7 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport ( - table_view, mutable_table_view -) +from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view cdef class Table: diff --git a/python/cudf/cudf/_lib/table.pyi b/python/cudf/cudf/_lib/table.pyi index 772e940f812..2a5dfb2a4dd 100644 --- a/python/cudf/cudf/_lib/table.pyi +++ b/python/cudf/cudf/_lib/table.pyi @@ -1,6 +1,6 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from typing import List, Any, Optional, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, List, Optional import cudf diff --git a/python/cudf/cudf/_lib/table.pyx b/python/cudf/cudf/_lib/table.pyx index 93d79ba6843..07d7a0fcf02 100644 --- a/python/cudf/cudf/_lib/table.pyx +++ b/python/cudf/cudf/_lib/table.pyx @@ -8,23 +8,16 @@ from cudf.core.column_accessor import ColumnAccessor from cython.operator cimport dereference from libc.stdint cimport uintptr_t -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr from libcpp.utility cimport move +from libcpp.vector cimport vector from cudf._lib.column cimport Column - -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, - mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport ( - table_view, - mutable_table_view -) +from cudf._lib.cpp.table.table_view cimport mutable_table_view, table_view +from cudf._lib.cpp.types cimport size_type cdef class Table: diff --git a/python/cudf/cudf/_lib/transform.pyx b/python/cudf/cudf/_lib/transform.pyx index 2c83f8b86e0..c8b448b6e30 100644 --- a/python/cudf/cudf/_lib/transform.pyx +++ b/python/cudf/cudf/_lib/transform.pyx @@ -1,33 +1,32 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import cudf import numpy as np + +import cudf from cudf.utils import cudautils from libc.stdint cimport uintptr_t - -from libcpp.string cimport string from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.pair cimport pair +from libcpp.string cimport string +from libcpp.utility cimport move + +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from cudf._lib.column cimport Column from cudf._lib.table cimport Table -from rmm._lib.device_buffer cimport device_buffer, DeviceBuffer + from cudf.core.buffer import Buffer -from cudf._lib.cpp.types cimport ( - bitmask_type, - data_type, - size_type, - type_id, -) +from cudf._lib.cpp.types cimport bitmask_type, data_type, size_type, type_id + from cudf._lib.types import np_to_cudf_types -from cudf._lib.types cimport underlying_type_t_type_id + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.types cimport underlying_type_t_type_id from numba.np import numpy_support diff --git a/python/cudf/cudf/_lib/transpose.pyx b/python/cudf/cudf/_lib/transpose.pyx index d2b053789cd..d12cfa7511d 100644 --- a/python/cudf/cudf/_lib/transpose.pyx +++ b/python/cudf/cudf/_lib/transpose.pyx @@ -4,19 +4,16 @@ import cudf from cudf.utils.dtypes import is_categorical_dtype from libcpp.memory cimport unique_ptr -from libcpp.utility cimport move from libcpp.pair cimport pair +from libcpp.utility cimport move from cudf._lib.column cimport Column -from cudf._lib.table cimport Table - -from cudf._lib.cpp.table.table cimport table -from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.transpose cimport ( - transpose as cpp_transpose -) +from cudf._lib.cpp.table.table cimport table +from cudf._lib.cpp.table.table_view cimport table_view +from cudf._lib.cpp.transpose cimport transpose as cpp_transpose +from cudf._lib.table cimport Table def transpose(Table source): diff --git a/python/cudf/cudf/_lib/types.pxd b/python/cudf/cudf/_lib/types.pxd index 383b3665bd9..dbbe9b1e05a 100644 --- a/python/cudf/cudf/_lib/types.pxd +++ b/python/cudf/cudf/_lib/types.pxd @@ -2,9 +2,10 @@ from libc.stdint cimport int32_t from libcpp cimport bool + +cimport cudf._lib.cpp.types as libcudf_types from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -cimport cudf._lib.cpp.types as libcudf_types ctypedef bool underlying_type_t_order ctypedef bool underlying_type_t_null_order diff --git a/python/cudf/cudf/_lib/types.pyx b/python/cudf/cudf/_lib/types.pyx index e9ed4f21ddd..4b83208f772 100644 --- a/python/cudf/cudf/_lib/types.pyx +++ b/python/cudf/cudf/_lib/types.pyx @@ -4,17 +4,18 @@ from enum import IntEnum import numpy as np -from libcpp.memory cimport shared_ptr, make_shared +from libcpp.memory cimport make_shared, shared_ptr +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view from cudf._lib.types cimport ( - underlying_type_t_order, + underlying_type_t_interpolation, underlying_type_t_null_order, + underlying_type_t_order, underlying_type_t_sorted, - underlying_type_t_interpolation ) -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.lists.lists_column_view cimport lists_column_view -from cudf.core.dtypes import ListDtype, StructDtype, Decimal64Dtype + +from cudf.core.dtypes import Decimal64Dtype, ListDtype, StructDtype from cudf.utils.dtypes import is_decimal_dtype, is_list_dtype, is_struct_dtype cimport cudf._lib.cpp.types as libcudf_types diff --git a/python/cudf/cudf/_lib/unary.pyx b/python/cudf/cudf/_lib/unary.pyx index 3bac0cde9c6..c06723fe442 100644 --- a/python/cudf/cudf/_lib/unary.pyx +++ b/python/cudf/cudf/_lib/unary.pyx @@ -1,34 +1,29 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. from enum import IntEnum + from cudf.utils.dtypes import is_decimal_dtype from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.utility cimport move + import numpy as np from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport ( - column_view, mutable_column_view -) +from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view + from cudf._lib.types import np_to_cudf_types -from cudf._lib.cpp.types cimport ( - size_type, - data_type, - type_id, -) -from cudf._lib.column import np_to_cudf_types, cudf_to_np_types -from cudf._lib.cpp.unary cimport ( - underlying_type_t_unary_op, - unary_operator, -) - -from cudf._lib.types cimport underlying_type_t_type_id, dtype_to_data_type -cimport cudf._lib.cpp.unary as libcudf_unary +from cudf._lib.cpp.types cimport data_type, size_type, type_id + +from cudf._lib.column import cudf_to_np_types, np_to_cudf_types + cimport cudf._lib.cpp.types as libcudf_types +cimport cudf._lib.cpp.unary as libcudf_unary +from cudf._lib.cpp.unary cimport unary_operator, underlying_type_t_unary_op +from cudf._lib.types cimport dtype_to_data_type, underlying_type_t_type_id class UnaryOp(IntEnum): diff --git a/python/cudf/cudf/_lib/utils.pxd b/python/cudf/cudf/_lib/utils.pxd index 03a032ac131..e8ac858d8b2 100644 --- a/python/cudf/cudf/_lib/utils.pxd +++ b/python/cudf/cudf/_lib/utils.pxd @@ -2,10 +2,12 @@ from libcpp.string cimport string from libcpp.vector cimport vector + from cudf._lib.cpp.column.column cimport column_view from cudf._lib.cpp.table.table cimport table_view from cudf._lib.table cimport Table + cdef vector[column_view] make_column_views(object columns) except* cdef vector[table_view] make_table_views(object tables) except* cdef vector[table_view] make_table_data_views(object tables) except* diff --git a/python/cudf/cudf/_lib/utils.pyx b/python/cudf/cudf/_lib/utils.pyx index 13eedb34c18..b0ca36e730a 100644 --- a/python/cudf/cudf/_lib/utils.pyx +++ b/python/cudf/cudf/_lib/utils.pyx @@ -1,29 +1,29 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -import cudf - import pyarrow as pa -from cudf._lib.column cimport Column -from cudf._lib.table cimport Table -from cudf._lib.cpp.column.column cimport column_view -from cudf._lib.cpp.table.table cimport table_view +import cudf from libc.stdint cimport uint8_t from libcpp.string cimport string from libcpp.vector cimport vector +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column_view +from cudf._lib.cpp.table.table cimport table_view +from cudf._lib.table cimport Table + try: import ujson as json except ImportError: import json from cudf.utils.dtypes import ( - np_to_pa_dtype, is_categorical_dtype, + is_decimal_dtype, is_list_dtype, is_struct_dtype, - is_decimal_dtype, + np_to_pa_dtype, ) diff --git a/python/cudf/cudf/api/extensions/accessor.py b/python/cudf/cudf/api/extensions/accessor.py index 2d9fdcaaed3..a27ffa90cfc 100644 --- a/python/cudf/cudf/api/extensions/accessor.py +++ b/python/cudf/cudf/api/extensions/accessor.py @@ -1,11 +1,11 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from cudf.utils.docutils import docfmt_partial import warnings -import cudf from pandas.core.accessor import CachedAccessor +import cudf +from cudf.utils.docutils import docfmt_partial _docstring_register_accessor = """ Extends `cudf.{klass}` with custom defined accessor diff --git a/python/cudf/cudf/benchmarks/bench_cudf_io.py b/python/cudf/cudf/benchmarks/bench_cudf_io.py index 1a01904374c..20f5afa1eaf 100644 --- a/python/cudf/cudf/benchmarks/bench_cudf_io.py +++ b/python/cudf/cudf/benchmarks/bench_cudf_io.py @@ -1,11 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import pytest -import cudf import glob import io + +import pytest from conftest import option +import cudf + def get_dataset_dir(): if option.dataset_dir == "NONE": diff --git a/python/cudf/cudf/benchmarks/get_datasets.py b/python/cudf/cudf/benchmarks/get_datasets.py index c793970eb3f..f3b66eda512 100644 --- a/python/cudf/cudf/benchmarks/get_datasets.py +++ b/python/cudf/cudf/benchmarks/get_datasets.py @@ -1,8 +1,8 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +import argparse import os import shutil -import argparse from collections import namedtuple # Update url and dir where datasets needs to be copied diff --git a/python/cudf/cudf/core/column/categorical.py b/python/cudf/cudf/core/column/categorical.py index e2aa20cc948..ab6a2817dc7 100644 --- a/python/cudf/cudf/core/column/categorical.py +++ b/python/cudf/cudf/core/column/categorical.py @@ -32,10 +32,10 @@ from cudf.core.dtypes import CategoricalDtype from cudf.utils.dtypes import ( is_categorical_dtype, + is_interval_dtype, is_mixed_with_object_dtype, min_signed_type, min_unsigned_type, - is_interval_dtype, ) if TYPE_CHECKING: diff --git a/python/cudf/cudf/core/column/decimal.py b/python/cudf/cudf/core/column/decimal.py index b6bd2f18144..67eeb564990 100644 --- a/python/cudf/cudf/core/column/decimal.py +++ b/python/cudf/cudf/core/column/decimal.py @@ -21,8 +21,8 @@ from cudf.utils.dtypes import is_scalar from cudf.utils.utils import pa_mask_buffer_to_mask -from .numerical_base import NumericalBaseColumn from ...api.types import is_integer_dtype +from .numerical_base import NumericalBaseColumn class DecimalColumn(NumericalBaseColumn): diff --git a/python/cudf/cudf/core/cut.py b/python/cudf/cudf/core/cut.py index 63324dea354..7811f477170 100644 --- a/python/cudf/cudf/core/cut.py +++ b/python/cudf/cudf/core/cut.py @@ -1,13 +1,14 @@ -from cudf._lib.labeling import label_bins -from cudf.core.column import as_column -from cudf.core.column import build_categorical_column -from cudf.core.index import IntervalIndex, interval_range -from cudf.utils.dtypes import is_list_like +from collections.abc import Sequence + import cupy -import cudf import numpy as np import pandas as pd -from collections.abc import Sequence + +import cudf +from cudf._lib.labeling import label_bins +from cudf.core.column import as_column, build_categorical_column +from cudf.core.index import IntervalIndex, interval_range +from cudf.utils.dtypes import is_list_like # from cudf._lib.filling import sequence diff --git a/python/cudf/cudf/core/subword_tokenizer.py b/python/cudf/cudf/core/subword_tokenizer.py index 9058491d8e7..60139f7d7af 100644 --- a/python/cudf/cudf/core/subword_tokenizer.py +++ b/python/cudf/cudf/core/subword_tokenizer.py @@ -1,13 +1,15 @@ # Copyright (c) 2021, NVIDIA CORPORATION. from __future__ import annotations + from typing import Union -import cupy as cp from warnings import warn +import cupy as cp + from cudf._lib.nvtext.subword_tokenize import ( - subword_tokenize_inmem_hash as cpp_subword_tokenize, Hashed_Vocabulary as cpp_hashed_vocabulary, + subword_tokenize_inmem_hash as cpp_subword_tokenize, ) diff --git a/python/cudf/cudf/tests/test_array_ufunc.py b/python/cudf/cudf/tests/test_array_ufunc.py index f9e0bb2ce8a..c459caace0e 100644 --- a/python/cudf/cudf/tests/test_array_ufunc.py +++ b/python/cudf/cudf/tests/test_array_ufunc.py @@ -1,8 +1,9 @@ -import cudf -import numpy as np import cupy as cp +import numpy as np import pandas as pd import pytest + +import cudf from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_compile_udf.py b/python/cudf/cudf/tests/test_compile_udf.py index 96c0e91d8d7..d965f35ccdd 100644 --- a/python/cudf/cudf/tests/test_compile_udf.py +++ b/python/cudf/cudf/tests/test_compile_udf.py @@ -1,8 +1,9 @@ # Copyright (c) 2021, NVIDIA CORPORATION. -from cudf.utils import cudautils from numba import types +from cudf.utils import cudautils + def setup_function(): cudautils._udf_code_cache.clear() diff --git a/python/cudf/cudf/tests/test_concat.py b/python/cudf/cudf/tests/test_concat.py index 5c4c121db4d..1e4882fde0e 100644 --- a/python/cudf/cudf/tests/test_concat.py +++ b/python/cudf/cudf/tests/test_concat.py @@ -1,16 +1,16 @@ # Copyright (c) 2018-2021, NVIDIA CORPORATION. import re +from decimal import Decimal import numpy as np import pandas as pd import pytest -from decimal import Decimal import cudf as gd +from cudf.core.dtypes import Decimal64Dtype from cudf.tests.utils import assert_eq, assert_exceptions_equal from cudf.utils.dtypes import is_categorical_dtype -from cudf.core.dtypes import Decimal64Dtype def make_frames(index=None, nulls="none"): diff --git a/python/cudf/cudf/tests/test_custom_accessor.py b/python/cudf/cudf/tests/test_custom_accessor.py index d72b5875677..46970f4762d 100644 --- a/python/cudf/cudf/tests/test_custom_accessor.py +++ b/python/cudf/cudf/tests/test_custom_accessor.py @@ -2,8 +2,8 @@ import pandas as pd import pytest -import cudf as gd +import cudf as gd from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_cut.py b/python/cudf/cudf/tests/test_cut.py index 926826ac188..7af1e34741b 100644 --- a/python/cudf/cudf/tests/test_cut.py +++ b/python/cudf/cudf/tests/test_cut.py @@ -4,10 +4,11 @@ Test related to Cut """ -import pandas as pd import numpy as np -from cudf.core.cut import cut +import pandas as pd import pytest + +from cudf.core.cut import cut from cudf.tests.utils import assert_eq diff --git a/python/cudf/cudf/tests/test_hash_vocab.py b/python/cudf/cudf/tests/test_hash_vocab.py index 529552cb2d9..a30f4e20849 100644 --- a/python/cudf/cudf/tests/test_hash_vocab.py +++ b/python/cudf/cudf/tests/test_hash_vocab.py @@ -1,9 +1,11 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from cudf.utils.hash_vocab_utils import hash_vocab -import os import filecmp +import os + import pytest +from cudf.utils.hash_vocab_utils import hash_vocab + @pytest.fixture(scope="module") def datadir(datadir): diff --git a/python/cudf/cudf/tests/test_orc.py b/python/cudf/cudf/tests/test_orc.py index c3a33f75ee3..e2d731a3ebe 100644 --- a/python/cudf/cudf/tests/test_orc.py +++ b/python/cudf/cudf/tests/test_orc.py @@ -1,6 +1,7 @@ # Copyright (c) 2019-2021, NVIDIA CORPORATION. import datetime +import decimal import os from io import BytesIO @@ -10,12 +11,11 @@ import pyarrow.orc import pyorc import pytest -import decimal import cudf +from cudf.core.dtypes import Decimal64Dtype from cudf.io.orc import ORCWriter from cudf.tests.utils import assert_eq, gen_rand_series, supported_numpy_dtypes -from cudf.core.dtypes import Decimal64Dtype @pytest.fixture(scope="module") diff --git a/python/cudf/cudf/tests/test_replace.py b/python/cudf/cudf/tests/test_replace.py index 6dca539b8d5..14338c2e64a 100644 --- a/python/cudf/cudf/tests/test_replace.py +++ b/python/cudf/cudf/tests/test_replace.py @@ -1,11 +1,11 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. import re +from decimal import Decimal import numpy as np import pandas as pd import pytest -from decimal import Decimal import cudf from cudf.core.dtypes import Decimal64Dtype diff --git a/python/cudf/cudf/tests/test_scan.py b/python/cudf/cudf/tests/test_scan.py index f7e8c5a8563..f77fc0b19da 100644 --- a/python/cudf/cudf/tests/test_scan.py +++ b/python/cudf/cudf/tests/test_scan.py @@ -5,8 +5,8 @@ import pytest import cudf -from cudf.tests.utils import INTEGER_TYPES, NUMERIC_TYPES, assert_eq, gen_rand from cudf.core.dtypes import Decimal64Dtype +from cudf.tests.utils import INTEGER_TYPES, NUMERIC_TYPES, assert_eq, gen_rand params_sizes = [0, 1, 2, 5] diff --git a/python/cudf/cudf/tests/test_seriesmap.py b/python/cudf/cudf/tests/test_seriesmap.py index 324074b6021..6fd1a70433b 100644 --- a/python/cudf/cudf/tests/test_seriesmap.py +++ b/python/cudf/cudf/tests/test_seriesmap.py @@ -4,10 +4,10 @@ from math import floor import numpy as np -import cudf import pandas as pd import pytest +import cudf from cudf import Series from cudf.tests.utils import assert_eq, assert_exceptions_equal diff --git a/python/cudf/cudf/tests/test_subword_tokenizer.py b/python/cudf/cudf/tests/test_subword_tokenizer.py index bdb343a41f7..d5207c79b86 100644 --- a/python/cudf/cudf/tests/test_subword_tokenizer.py +++ b/python/cudf/cudf/tests/test_subword_tokenizer.py @@ -1,8 +1,9 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. -from transformers import BertTokenizer -import pytest import os + import numpy as np +import pytest +from transformers import BertTokenizer import cudf from cudf.core.subword_tokenizer import SubwordTokenizer diff --git a/python/cudf/cudf/tests/test_udf_binops.py b/python/cudf/cudf/tests/test_udf_binops.py index 00d05a8c3a5..df7361ab183 100644 --- a/python/cudf/cudf/tests/test_udf_binops.py +++ b/python/cudf/cudf/tests/test_udf_binops.py @@ -3,14 +3,13 @@ import numpy as np import pytest +from numba.cuda import compile_ptx +from numba.np import numpy_support from cudf import _lib as libcudf from cudf.core import Series from cudf.utils import dtypes as dtypeutils -from numba.cuda import compile_ptx -from numba.np import numpy_support - @pytest.mark.parametrize( "dtype", sorted(list(dtypeutils.NUMERIC_TYPES - {"int8"})) diff --git a/python/cudf/cudf/utils/applyutils.py b/python/cudf/cudf/utils/applyutils.py index 610b0997d85..c8fb7c1a47d 100644 --- a/python/cudf/cudf/utils/applyutils.py +++ b/python/cudf/cudf/utils/applyutils.py @@ -4,6 +4,7 @@ from typing import Any, Dict from numba import cuda +from numba.core.utils import pysignature import cudf from cudf import _lib as libcudf @@ -11,9 +12,6 @@ from cudf.utils import utils from cudf.utils.docutils import docfmt_partial -from numba.core.utils import pysignature - - _doc_applyparams = """ df : DataFrame The source dataframe. diff --git a/python/cudf/cudf/utils/cudautils.py b/python/cudf/cudf/utils/cudautils.py index 262fe304dd8..df3b6ec3d93 100755 --- a/python/cudf/cudf/utils/cudautils.py +++ b/python/cudf/cudf/utils/cudautils.py @@ -4,11 +4,9 @@ import cachetools import numpy as np from numba import cuda - -import cudf - from numba.np import numpy_support +import cudf # # Misc kernels diff --git a/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd b/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd index d7c310fc6e2..fc985e58b68 100644 --- a/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd +++ b/python/cudf_kafka/cudf_kafka/_lib/kafka.pxd @@ -1,12 +1,13 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +from libc.stdint cimport int32_t, int64_t +from libcpp cimport bool +from libcpp.map cimport map +from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from libcpp.map cimport map -from libcpp cimport bool -from libc.stdint cimport int32_t, int64_t + from cudf._lib.cpp.io.types cimport datasource -from libcpp.memory cimport unique_ptr from cudf._lib.io.datasource cimport Datasource diff --git a/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx b/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx index fad62eb38b0..5588b69938b 100644 --- a/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx +++ b/python/cudf_kafka/cudf_kafka/_lib/kafka.pyx @@ -1,13 +1,16 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from libcpp.string cimport string -from libcpp.map cimport map from libc.stdint cimport int32_t, int64_t from libcpp cimport bool +from libcpp.map cimport map +from libcpp.memory cimport make_unique, unique_ptr +from libcpp.string cimport string + from cudf._lib.cpp.io.types cimport datasource -from libcpp.memory cimport unique_ptr, make_unique + from cudf_kafka._lib.kafka cimport kafka_consumer + cdef class KafkaDatasource(Datasource): def __cinit__(self, diff --git a/python/custreamz/custreamz/tests/test_dataframes.py b/python/custreamz/custreamz/tests/test_dataframes.py index d5fffd30d57..24f6e46f6c5 100644 --- a/python/custreamz/custreamz/tests/test_dataframes.py +++ b/python/custreamz/custreamz/tests/test_dataframes.py @@ -12,13 +12,14 @@ import numpy as np import pandas as pd import pytest -from streamz import Stream -from streamz.dask import DaskStream -from streamz.dataframe import Aggregation, DataFrame, DataFrames, Series from dask.dataframe.utils import assert_eq from distributed import Client +from streamz import Stream +from streamz.dask import DaskStream +from streamz.dataframe import Aggregation, DataFrame, DataFrames, Series + cudf = pytest.importorskip("cudf") diff --git a/python/dask_cudf/dask_cudf/tests/test_delayed_io.py b/python/dask_cudf/dask_cudf/tests/test_delayed_io.py index a103d9fe8c2..7789664afae 100644 --- a/python/dask_cudf/dask_cudf/tests/test_delayed_io.py +++ b/python/dask_cudf/dask_cudf/tests/test_delayed_io.py @@ -7,10 +7,10 @@ from dask.delayed import delayed -import dask_cudf as dgd - import cudf as gd +import dask_cudf as dgd + @delayed def load_data(nelem, ident): diff --git a/python/dask_cudf/dask_cudf/tests/test_join.py b/python/dask_cudf/dask_cudf/tests/test_join.py index d8781af6c6e..58811ee98fc 100644 --- a/python/dask_cudf/dask_cudf/tests/test_join.py +++ b/python/dask_cudf/dask_cudf/tests/test_join.py @@ -6,10 +6,10 @@ from dask import dataframe as dd -import dask_cudf as dgd - import cudf +import dask_cudf as dgd + param_nrows = [5, 10, 50, 100] diff --git a/python/dask_cudf/dask_cudf/tests/test_reductions.py b/python/dask_cudf/dask_cudf/tests/test_reductions.py index 030b7717fbc..c34fbc3b0e7 100644 --- a/python/dask_cudf/dask_cudf/tests/test_reductions.py +++ b/python/dask_cudf/dask_cudf/tests/test_reductions.py @@ -6,10 +6,10 @@ from dask import dataframe as dd -import dask_cudf as dgd - import cudf +import dask_cudf as dgd + def _make_random_frame(nelem, npartitions=2): df = pd.DataFrame( diff --git a/python/dask_cudf/dask_cudf/tests/test_sort.py b/python/dask_cudf/dask_cudf/tests/test_sort.py index 855b2bb9a0b..a12d5792219 100644 --- a/python/dask_cudf/dask_cudf/tests/test_sort.py +++ b/python/dask_cudf/dask_cudf/tests/test_sort.py @@ -4,10 +4,10 @@ import dask from dask import dataframe as dd -import dask_cudf - import cudf +import dask_cudf + @pytest.mark.parametrize("by", ["a", "b", "c", "d", ["a", "b"], ["c", "d"]]) @pytest.mark.parametrize("nelem", [10, 500]) From 6cead3be1cfbfec87fcac553347eb52b0f8a3dd9 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Tue, 22 Jun 2021 12:03:20 -0400 Subject: [PATCH 11/18] Temporary fix for style failures --- ci/checks/style.sh | 2 +- python/dask_cudf/dask_cudf/io/tests/test_json.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/checks/style.sh b/ci/checks/style.sh index 811343aef0a..1d81f476828 100755 --- a/ci/checks/style.sh +++ b/ci/checks/style.sh @@ -14,7 +14,7 @@ LANG=C.UTF-8 source activate gdf # Run isort-cudf and get results/return code -ISORT_CUDF=`isort python/cudf --check-only --settings-path=python/cudf/setup.cfg 2>&1` +ISORT_CUDF=`isort python/cudf --check-only --skip-glob *.pyx --settings-path=python/cudf/setup.cfg 2>&1` ISORT_CUDF_RETVAL=$? # Run isort-cudf-kafka and get results/return code diff --git a/python/dask_cudf/dask_cudf/io/tests/test_json.py b/python/dask_cudf/dask_cudf/io/tests/test_json.py index 3a1e98feb31..a4920b94c0b 100644 --- a/python/dask_cudf/dask_cudf/io/tests/test_json.py +++ b/python/dask_cudf/dask_cudf/io/tests/test_json.py @@ -4,7 +4,7 @@ import pytest import dask -import dask.dataframe as dd +from dask import dataframe as dd from dask.utils import tmpfile import dask_cudf From d34eeb9b91cccb1bced4cd7bf33f20c468ccbc08 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Thu, 24 Jun 2021 00:30:10 -0400 Subject: [PATCH 12/18] Run pre-commit hooks again --- java/src/main/native/src/AggregationJni.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/java/src/main/native/src/AggregationJni.cpp b/java/src/main/native/src/AggregationJni.cpp index 0d8d90ddea3..abbce946ef6 100644 --- a/java/src/main/native/src/AggregationJni.cpp +++ b/java/src/main/native/src/AggregationJni.cpp @@ -83,9 +83,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv // case 18: COLLECT_LIST // case 19: COLLECT_SET // case 20: MERGE_LISTS - case 20: - ret = cudf::make_merge_lists_aggregation(); - break; + case 20: ret = cudf::make_merge_lists_aggregation(); break; // case 21: MERGE_SETS // case 22: LEAD // case 23: LAG @@ -243,8 +241,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createMergeSetsAgg(JNIEn nulls_equal ? cudf::null_equality::EQUAL : cudf::null_equality::UNEQUAL; cudf::nan_equality nan_equality = nans_equal ? cudf::nan_equality::ALL_EQUAL : cudf::nan_equality::UNEQUAL; - std::unique_ptr ret = cudf::make_merge_sets_aggregation(null_equality, - nan_equality); + std::unique_ptr ret = + cudf::make_merge_sets_aggregation(null_equality, nan_equality); return reinterpret_cast(ret.release()); } CATCH_STD(env, 0); From 994e77075290816b909be8d64fcd53e4e0e83594 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Thu, 24 Jun 2021 00:34:44 -0400 Subject: [PATCH 13/18] Retain old import style with isort skip --- python/dask_cudf/dask_cudf/io/tests/test_json.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/dask_cudf/dask_cudf/io/tests/test_json.py b/python/dask_cudf/dask_cudf/io/tests/test_json.py index a4920b94c0b..fb5217ceed7 100644 --- a/python/dask_cudf/dask_cudf/io/tests/test_json.py +++ b/python/dask_cudf/dask_cudf/io/tests/test_json.py @@ -4,11 +4,12 @@ import pytest import dask -from dask import dataframe as dd from dask.utils import tmpfile import dask_cudf +import dask.dataframe as dd # isort:skip + def test_read_json(tmp_path): df1 = dask.datasets.timeseries( From 44399d39aaae3cdf3e2cbd46f86fa49334d671e8 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Thu, 24 Jun 2021 12:23:33 -0400 Subject: [PATCH 14/18] Bump copyright on affected files --- cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp | 2 +- cpp/scripts/run-clang-format.py | 2 +- java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp | 2 +- java/src/main/native/src/NvcompJni.cpp | 2 +- java/src/main/native/src/NvtxRangeJni.cpp | 2 +- python/cudf/cudf/_lib/cpp/strings/extract.pxd | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp index dbfd7a29efd..fa3d7d887aa 100644 --- a/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp +++ b/cpp/libcudf_kafka/tests/kafka_consumer_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cpp/scripts/run-clang-format.py b/cpp/scripts/run-clang-format.py index cb77611fa3c..642a298c015 100755 --- a/cpp/scripts/run-clang-format.py +++ b/cpp/scripts/run-clang-format.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-2021, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp index 16b8630b04a..f9e05d27798 100644 --- a/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp +++ b/java/src/main/native/src/HostMemoryBufferNativeUtilsJni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/src/main/native/src/NvcompJni.cpp b/java/src/main/native/src/NvcompJni.cpp index 5ba87221597..0e34d2856f5 100644 --- a/java/src/main/native/src/NvcompJni.cpp +++ b/java/src/main/native/src/NvcompJni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/src/main/native/src/NvtxRangeJni.cpp b/java/src/main/native/src/NvtxRangeJni.cpp index afd96632187..3e50327be8b 100644 --- a/java/src/main/native/src/NvtxRangeJni.cpp +++ b/java/src/main/native/src/NvtxRangeJni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/python/cudf/cudf/_lib/cpp/strings/extract.pxd b/python/cudf/cudf/_lib/cpp/strings/extract.pxd index 518b1c9ed60..606369c8994 100644 --- a/python/cudf/cudf/_lib/cpp/strings/extract.pxd +++ b/python/cudf/cudf/_lib/cpp/strings/extract.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from libcpp.string cimport string From bb622a90aba489d20e92215740862fa86b91f1f8 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Wed, 30 Jun 2021 14:58:40 -0400 Subject: [PATCH 15/18] Run hooks again --- python/cudf/cudf/_lib/copying.pxd | 2 +- python/dask_cudf/dask_cudf/tests/test_accessor.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/cudf/cudf/_lib/copying.pxd b/python/cudf/cudf/_lib/copying.pxd index 1668ef05f3f..8a288c66ea9 100644 --- a/python/cudf/cudf/_lib/copying.pxd +++ b/python/cudf/cudf/_lib/copying.pxd @@ -1,8 +1,8 @@ # Copyright (c) 2021, NVIDIA CORPORATION. +from cudf._lib.cpp.copying cimport packed_columns from cudf._lib.table cimport Table -from cudf._lib.cpp.copying cimport packed_columns cdef class _CPackedColumns: cdef packed_columns c_obj diff --git a/python/dask_cudf/dask_cudf/tests/test_accessor.py b/python/dask_cudf/dask_cudf/tests/test_accessor.py index 94e0169bdf9..342f2b60180 100644 --- a/python/dask_cudf/dask_cudf/tests/test_accessor.py +++ b/python/dask_cudf/dask_cudf/tests/test_accessor.py @@ -5,11 +5,11 @@ from dask import dataframe as dd -import dask_cudf as dgd - from cudf import DataFrame, Series from cudf.testing._utils import assert_eq, does_not_raise +import dask_cudf as dgd + ############################################################################# # Datetime Accessor # ############################################################################# From 323d3a52505231d60d44d1fd963d1d412fe221c4 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Fri, 2 Jul 2021 17:49:18 -0400 Subject: [PATCH 16/18] Fix test failures --- ci/gpu/build.sh | 4 +- ci/gpu/java.sh | 145 ++++++++++++++++++ conda/environments/cudf_dev_cuda11.0.yml | 2 +- conda/environments/cudf_dev_cuda11.2.yml | 2 +- conda/recipes/cudf/meta.yaml | 2 +- conda/recipes/libcudf/meta.yaml | 2 +- cpp/include/cudf/strings/capitalize.hpp | 23 ++- cpp/src/strings/capitalize.cu | 123 ++++++++------- cpp/tests/strings/case_tests.cpp | 78 +++++++--- .../main/java/ai/rapids/cudf/ColumnView.java | 29 ++++ java/src/main/native/src/ColumnViewJni.cpp | 18 ++- .../java/ai/rapids/cudf/ColumnVectorTest.java | 25 +++ python/cudf/cudf/_lib/copying.pyx | 4 +- python/cudf/cudf/_lib/cpp/lists/combine.pxd | 16 ++ python/cudf/cudf/_lib/cpp/scalar/scalar.pxd | 1 + python/cudf/cudf/_lib/gpuarrow.pyx | 8 +- python/cudf/cudf/_lib/lists.pyx | 19 +++ python/cudf/cudf/_lib/scalar.pyx | 51 +++--- python/cudf/cudf/core/column/categorical.py | 6 +- python/cudf/cudf/core/column/lists.py | 123 ++++++++++++--- python/cudf/cudf/core/column/methods.py | 12 +- python/cudf/cudf/core/column/string.py | 13 +- python/cudf/cudf/core/indexing.py | 5 +- python/cudf/cudf/core/scalar.py | 2 +- python/cudf/cudf/tests/test_list.py | 102 ++++++++++++ python/cudf/cudf/tests/test_string.py | 6 +- 26 files changed, 651 insertions(+), 170 deletions(-) create mode 100755 ci/gpu/java.sh diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index c854e67fbdf..355b18f4543 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -201,8 +201,8 @@ fi ################################################################################ # If examples grows too large to build, should move to cpu side -gpuci_logger "Building libcudf examples" -$WORKSPACE/cpp/examples/build.sh +# gpuci_logger "Building libcudf examples" +# $WORKSPACE/cpp/examples/build.sh # set environment variable for numpy 1.16 # will be enabled for later versions by default diff --git a/ci/gpu/java.sh b/ci/gpu/java.sh new file mode 100755 index 00000000000..8c4b597d12d --- /dev/null +++ b/ci/gpu/java.sh @@ -0,0 +1,145 @@ +#!/bin/bash +# Copyright (c) 2018-2020, NVIDIA CORPORATION. +############################################## +# cuDF GPU build and test script for CI # +############################################## +set -e +NUMARGS=$# +ARGS=$* + +# Arg parsing function +function hasArg { + (( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ") +} + +# Set path and build parallel level +export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH +export PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} + +# Set home to the job's workspace +export HOME="$WORKSPACE" + +# Switch to project root; also root of repo checkout +cd "$WORKSPACE" + +# Determine CUDA release version +export CUDA_REL=${CUDA_VERSION%.*} +export CONDA_ARTIFACT_PATH="$WORKSPACE/ci/artifacts/cudf/cpu/.conda-bld/" + +# Parse git describe +export GIT_DESCRIBE_TAG=`git describe --tags` +export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` + +################################################################################ +# TRAP - Setup trap for removing jitify cache +################################################################################ + +# Set `LIBCUDF_KERNEL_CACHE_PATH` environment variable to $HOME/.jitify-cache +# because it's local to the container's virtual file system, and not shared with +# other CI jobs like `/tmp` is +export LIBCUDF_KERNEL_CACHE_PATH="$HOME/.jitify-cache" + +function remove_libcudf_kernel_cache_dir { + EXITCODE=$? + gpuci_logger "TRAP: Removing kernel cache dir: $LIBCUDF_KERNEL_CACHE_PATH" + rm -rf "$LIBCUDF_KERNEL_CACHE_PATH" \ + || gpuci_logger "[ERROR] TRAP: Could not rm -rf $LIBCUDF_KERNEL_CACHE_PATH" + exit $EXITCODE +} + +# Set trap to run on exit +gpuci_logger "TRAP: Set trap to remove jitify cache on exit" +trap remove_libcudf_kernel_cache_dir EXIT + +mkdir -p "$LIBCUDF_KERNEL_CACHE_PATH" \ + || gpuci_logger "[ERROR] TRAP: Could not mkdir -p $LIBCUDF_KERNEL_CACHE_PATH" + +################################################################################ +# SETUP - Check environment +################################################################################ + +gpuci_logger "Check environment variables" +env + +gpuci_logger "Check GPU usage" +nvidia-smi + +gpuci_logger "Activate conda env" +. /opt/conda/etc/profile.d/conda.sh +conda activate rapids + +gpuci_logger "Check conda environment" +conda info +conda config --show-sources +conda list --show-channel-urls + +gpuci_logger "Install dependencies" +gpuci_conda_retry install -y \ + "cudatoolkit=$CUDA_REL" \ + "rapids-build-env=$MINOR_VERSION.*" \ + "rapids-notebook-env=$MINOR_VERSION.*" \ + "dask-cuda=${MINOR_VERSION}" \ + "rmm=$MINOR_VERSION.*" \ + "ucx-py=0.21.*" \ + "openjdk=8.*" \ + "maven" + +# https://docs.rapids.ai/maintainers/depmgmt/ +# gpuci_conda_retry remove --force rapids-build-env rapids-notebook-env +# gpuci_conda_retry install -y "your-pkg=1.0.0" + + +gpuci_logger "Check compiler versions" +python --version +$CC --version +$CXX --version + +gpuci_logger "Check conda environment" +conda info +conda config --show-sources +conda list --show-channel-urls + +function install_dask { + # Install the main version of dask, distributed, and streamz + gpuci_logger "Install the main version of dask, distributed, and streamz" + set -x + pip install "git+https://github.com/dask/distributed.git@main" --upgrade --no-deps + pip install "git+https://github.com/dask/dask.git@main" --upgrade --no-deps + # Need to uninstall streamz that is already in the env. + pip uninstall -y streamz + pip install "git+https://github.com/python-streamz/streamz.git@master" --upgrade --no-deps + set +x +} + +################################################################################ +# INSTALL - Install libcudf artifacts +################################################################################ + +export LIB_BUILD_DIR="$WORKSPACE/ci/artifacts/cudf/cpu/libcudf_work/cpp/build" +export CUDF_ROOT=${LIB_BUILD_DIR} +export LD_LIBRARY_PATH="$LIB_BUILD_DIR:$CONDA_PREFIX/lib:$LD_LIBRARY_PATH" + +CUDF_CONDA_FILE=`find ${CONDA_ARTIFACT_PATH} -name "libcudf-*.tar.bz2"` +CUDF_CONDA_FILE=`basename "$CUDF_CONDA_FILE" .tar.bz2` #get filename without extension +CUDF_CONDA_FILE=${CUDF_CONDA_FILE//-/=} #convert to conda install +KAFKA_CONDA_FILE=`find ${CONDA_ARTIFACT_PATH} -name "libcudf_kafka-*.tar.bz2"` +KAFKA_CONDA_FILE=`basename "$KAFKA_CONDA_FILE" .tar.bz2` #get filename without extension +KAFKA_CONDA_FILE=${KAFKA_CONDA_FILE//-/=} #convert to conda install + +gpuci_logger "Installing $CUDF_CONDA_FILE & $KAFKA_CONDA_FILE" +conda install -c ${CONDA_ARTIFACT_PATH} "$CUDF_CONDA_FILE" "$KAFKA_CONDA_FILE" + +install_dask + +################################################################################ +# TEST - Run java tests +################################################################################ + +gpuci_logger "Check GPU usage" +nvidia-smi + +gpuci_logger "Running Java Tests" +cd ${WORKSPACE}/java +mvn test -B -DCUDF_JNI_ARROW_STATIC=OFF + +return ${EXITCODE} diff --git a/conda/environments/cudf_dev_cuda11.0.yml b/conda/environments/cudf_dev_cuda11.0.yml index 5561a573609..c2a7f3d9b94 100644 --- a/conda/environments/cudf_dev_cuda11.0.yml +++ b/conda/environments/cudf_dev_cuda11.0.yml @@ -17,7 +17,7 @@ dependencies: - numba>=0.53.1 - numpy - pandas>=1.0,<1.3.0dev0 - - pyarrow=4.0.1 + - pyarrow=4.0.1=*cuda - fastavro>=0.22.9 - notebook>=0.5.0 - cython>=0.29,<0.30 diff --git a/conda/environments/cudf_dev_cuda11.2.yml b/conda/environments/cudf_dev_cuda11.2.yml index 6c8ae4cb9b0..ad2b8cd5403 100644 --- a/conda/environments/cudf_dev_cuda11.2.yml +++ b/conda/environments/cudf_dev_cuda11.2.yml @@ -17,7 +17,7 @@ dependencies: - numba>=0.53.1 - numpy - pandas>=1.0,<1.3.0dev0 - - pyarrow=4.0.1 + - pyarrow=4.0.1=*cuda - fastavro>=0.22.9 - notebook>=0.5.0 - cython>=0.29,<0.30 diff --git a/conda/recipes/cudf/meta.yaml b/conda/recipes/cudf/meta.yaml index 3da7c63857d..c0636d11ee8 100644 --- a/conda/recipes/cudf/meta.yaml +++ b/conda/recipes/cudf/meta.yaml @@ -30,7 +30,7 @@ requirements: - setuptools - numba >=0.53.1 - dlpack>=0.5,<0.6.0a0 - - pyarrow 4.0.1 + - pyarrow 4.0.1 *cuda - libcudf {{ version }} - rmm {{ minor_version }} - cudatoolkit {{ cuda_version }} diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 6464013d646..b69c0aa8169 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -37,7 +37,7 @@ requirements: host: - librmm {{ minor_version }}.* - cudatoolkit {{ cuda_version }}.* - - arrow-cpp 4.0.1 + - arrow-cpp 4.0.1 *cuda - arrow-cpp-proc * cuda - dlpack>=0.5,<0.6.0a0 run: diff --git a/cpp/include/cudf/strings/capitalize.hpp b/cpp/include/cudf/strings/capitalize.hpp index 372d9faf13f..604756b5d09 100644 --- a/cpp/include/cudf/strings/capitalize.hpp +++ b/cpp/include/cudf/strings/capitalize.hpp @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include @@ -30,21 +31,33 @@ namespace strings { /** * @brief Returns a column of capitalized strings. * - * Any null string entries return corresponding null output column entries. + * If the `delimiters` is an empty string, then only the first character of each + * row is capitalized. Otherwise, a non-delimiter character is capitalized after + * any delimiter character is found. * * @code{.pseudo} * Example: - * input = ["tesT1", "a Test", "Another Test"]; + * input = ["tesT1", "a Test", "Another Test", "a\tb"]; * output = capitalize(input) - * output is ["Test1", "A test", "Another test"] + * output is ["Test1", "A test", "Another test", "A\tb"] + * output = capitalize(input, " ") + * output is ["Test1", "A Test", "Another Test", "A\tb"] + * output = capitalize(input, " \t") + * output is ["Test1", "A Test", "Another Test", "A\tB"] * @endcode * - * @param[in] input String column. - * @param[in] mr Device memory resource used to allocate the returned column's device memory + * Any null string entries return corresponding null output column entries. + * + * @throw cudf::logic_error if `delimiter.is_valid()` is `false`. + * + * @param input String column. + * @param delimiters Characters for identifying words to capitalize. + * @param mr Device memory resource used to allocate the returned column's device memory * @return Column of strings capitalized from the input column. */ std::unique_ptr capitalize( strings_column_view const& input, + string_scalar const& delimiters = string_scalar(""), rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** diff --git a/cpp/src/strings/capitalize.cu b/cpp/src/strings/capitalize.cu index c1e341217ab..93b0edc1855 100644 --- a/cpp/src/strings/capitalize.cu +++ b/cpp/src/strings/capitalize.cu @@ -38,12 +38,24 @@ namespace { * @brief Base class for capitalize and title functors. * * Utility functions here manage access to the character case and flags tables. + * Any derived class must supply a `capitalize_next` member function. + * + * @tparam Derived class uses the CRTP pattern to reuse code logic. */ +template struct base_fn { character_flags_table_type const* d_flags; character_cases_table_type const* d_case_table; + column_device_view const d_column; + offset_type* d_offsets{}; + char* d_chars{}; - base_fn() : d_flags(get_character_flags_table()), d_case_table(get_character_cases_table()) {} + base_fn(column_device_view const& d_column) + : d_flags(get_character_flags_table()), + d_case_table(get_character_cases_table()), + d_column(d_column) + { + } using char_info = thrust::pair; @@ -58,35 +70,31 @@ struct base_fn { { return codepoint_to_utf8(d_case_table[info.first]); } -}; - -/** - * @brief Capitalize functor. - * - * This capitalizes the first letter of the string. - * Also lower-case any characters after the first letter. - */ -struct capitalize_fn : base_fn { - column_device_view const d_column; - offset_type* d_offsets{}; - char* d_chars{}; - - capitalize_fn(column_device_view const& d_column) : base_fn(), d_column(d_column) {} + /** + * @brief Operator called for each row in `d_column`. + * + * This logic is shared by capitalize() and title() functions. + * The derived class must supply a `capitalize_next` member function. + */ __device__ void operator()(size_type idx) { if (d_column.is_null(idx)) { if (!d_chars) d_offsets[idx] = 0; } + Derived& derived = static_cast(*this); auto const d_str = d_column.element(idx); offset_type bytes = 0; auto d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr; + bool capitalize = true; for (auto itr = d_str.begin(); itr != d_str.end(); ++itr) { auto const info = get_char_info(*itr); auto const flag = info.second; - auto const change_case = (itr == d_str.begin()) ? IS_LOWER(flag) : IS_UPPER(flag); + auto const change_case = capitalize ? IS_LOWER(flag) : IS_UPPER(flag); auto const new_char = change_case ? convert_char(info) : *itr; + // capitalize the next char if this one is a delimiter + capitalize = derived.capitalize_next(*itr, flag); if (d_buffer) d_buffer += detail::from_char_utf8(new_char, d_buffer); @@ -97,51 +105,48 @@ struct capitalize_fn : base_fn { } }; +/** + * @brief Capitalize functor. + * + * This capitalizes the first character of the string and lower-cases + * the remaining characters. + * If a delimiter is specified, capitalization continues within the string + * on the first eligible character after any delimiter. + */ +struct capitalize_fn : base_fn { + string_view const d_delimiters; + + capitalize_fn(column_device_view const& d_column, string_view const& d_delimiters) + : base_fn(d_column), d_delimiters(d_delimiters) + { + } + + __device__ bool capitalize_next(char_utf8 const chr, character_flags_table_type const) + { + return !d_delimiters.empty() && (d_delimiters.find(chr) >= 0); + } +}; + /** * @brief Title functor. * * This capitalizes the first letter of each word. - * The beginning of a word is identified as the first alphabetic - * character after a non-alphabetic character. - * Also, lower-case all other alpabetic characters. + * The beginning of a word is identified as the first sequence_type + * character after a non-sequence_type character. + * Also, lower-case all other alphabetic characters. */ -struct title_fn : base_fn { - column_device_view const d_column; +struct title_fn : base_fn { string_character_types sequence_type; - offset_type* d_offsets{}; - char* d_chars{}; title_fn(column_device_view const& d_column, string_character_types sequence_type) - : base_fn(), d_column(d_column), sequence_type(sequence_type) + : base_fn(d_column), sequence_type(sequence_type) { } - __device__ void operator()(size_type idx) + __device__ bool capitalize_next(char_utf8 const, character_flags_table_type const flag) { - if (d_column.is_null(idx)) { - if (!d_chars) d_offsets[idx] = 0; - } - - auto const d_str = d_column.element(idx); - offset_type bytes = 0; - auto d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr; - bool capitalize = true; - for (auto itr = d_str.begin(); itr != d_str.end(); ++itr) { - auto const info = get_char_info(*itr); - auto const flag = info.second; - auto const change_case = - (flag & sequence_type) && (capitalize ? IS_LOWER(flag) : IS_UPPER(flag)); - auto const new_char = change_case ? convert_char(info) : *itr; - // capitalize the next char if this one is not a sequence_type - capitalize = (flag & sequence_type) == 0; - - if (d_buffer) - d_buffer += detail::from_char_utf8(new_char, d_buffer); - else - bytes += detail::bytes_in_char_utf8(new_char); - } - if (!d_chars) d_offsets[idx] = bytes; - } + return (flag & sequence_type) == 0; + }; }; /** @@ -154,10 +159,10 @@ struct title_fn : base_fn { * @param mr Device memory resource used for allocating the new device_buffer */ template -std::unique_ptr capitalize_utility(CapitalFn cfn, - strings_column_view const& input, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +std::unique_ptr capitalizer(CapitalFn cfn, + strings_column_view const& input, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { auto children = cudf::strings::detail::make_strings_children(cfn, input.size(), stream, mr); @@ -173,12 +178,15 @@ std::unique_ptr capitalize_utility(CapitalFn cfn, } // namespace std::unique_ptr capitalize(strings_column_view const& input, + string_scalar const& delimiters, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { + CUDF_EXPECTS(delimiters.is_valid(stream), "Delimiter must be a valid string"); if (input.is_empty()) return make_empty_column(data_type{type_id::STRING}); - auto d_column = column_device_view::create(input.parent(), stream); - return capitalize_utility(capitalize_fn{*d_column}, input, stream, mr); + auto const d_column = column_device_view::create(input.parent(), stream); + auto const d_delimiters = delimiters.value(stream); + return capitalizer(capitalize_fn{*d_column, d_delimiters}, input, stream, mr); } std::unique_ptr title(strings_column_view const& input, @@ -188,16 +196,17 @@ std::unique_ptr title(strings_column_view const& input, { if (input.is_empty()) return make_empty_column(data_type{type_id::STRING}); auto d_column = column_device_view::create(input.parent(), stream); - return capitalize_utility(title_fn{*d_column, sequence_type}, input, stream, mr); + return capitalizer(title_fn{*d_column, sequence_type}, input, stream, mr); } } // namespace detail std::unique_ptr capitalize(strings_column_view const& input, + string_scalar const& delimiter, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); - return detail::capitalize(input, rmm::cuda_stream_default, mr); + return detail::capitalize(input, delimiter, rmm::cuda_stream_default, mr); } std::unique_ptr title(strings_column_view const& input, diff --git a/cpp/tests/strings/case_tests.cpp b/cpp/tests/strings/case_tests.cpp index f04905282df..ae6e1e8db69 100644 --- a/cpp/tests/strings/case_tests.cpp +++ b/cpp/tests/strings/case_tests.cpp @@ -97,36 +97,34 @@ TEST_F(StringsCaseTest, Swapcase) CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } -TEST_F(StringsCaseTest, EmptyStringsColumn) -{ - cudf::column_view zero_size_strings_column( - cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0); - auto strings_view = cudf::strings_column_view(zero_size_strings_column); - auto results = cudf::strings::to_lower(strings_view); - auto view = results->view(); - cudf::test::expect_strings_empty(results->view()); -} - TEST_F(StringsCaseTest, Capitalize) { - std::vector h_strings{ - "SȺȺnich xyZ", "Examples aBc", "thesé", nullptr, "ARE THE", "tést strings", ""}; - std::vector h_expected{ - "Sⱥⱥnich xyz", "Examples abc", "Thesé", nullptr, "Are the", "Tést strings", ""}; - cudf::test::strings_column_wrapper strings( - h_strings.begin(), - h_strings.end(), - thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; })); + {"SȺȺnich xyZ", "Examples aBc", "thesé", "", "ARE\tTHE", "tést\tstrings", ""}, + {1, 1, 1, 0, 1, 1, 1}); auto strings_view = cudf::strings_column_view(strings); - auto results = cudf::strings::capitalize(strings_view); - - cudf::test::strings_column_wrapper expected( - h_expected.begin(), - h_expected.end(), - thrust::make_transform_iterator(h_expected.begin(), [](auto str) { return str != nullptr; })); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + { + auto results = cudf::strings::capitalize(strings_view); + cudf::test::strings_column_wrapper expected( + {"Sⱥⱥnich xyz", "Examples abc", "Thesé", "", "Are\tthe", "Tést\tstrings", ""}, + {1, 1, 1, 0, 1, 1, 1}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + } + { + auto results = cudf::strings::capitalize(strings_view, std::string(" ")); + cudf::test::strings_column_wrapper expected( + {"Sⱥⱥnich Xyz", "Examples Abc", "Thesé", "", "Are\tthe", "Tést\tstrings", ""}, + {1, 1, 1, 0, 1, 1, 1}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + } + { + auto results = cudf::strings::capitalize(strings_view, std::string(" \t")); + cudf::test::strings_column_wrapper expected( + {"Sⱥⱥnich Xyz", "Examples Abc", "Thesé", "", "Are\tThe", "Tést\tStrings", ""}, + {1, 1, 1, 0, 1, 1, 1}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + } } TEST_F(StringsCaseTest, Title) @@ -174,3 +172,33 @@ TEST_F(StringsCaseTest, MultiCharLower) CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } + +TEST_F(StringsCaseTest, EmptyStringsColumn) +{ + cudf::column_view zero_size_strings_column( + cudf::data_type{cudf::type_id::STRING}, 0, nullptr, nullptr, 0); + auto strings_view = cudf::strings_column_view(zero_size_strings_column); + + auto results = cudf::strings::to_lower(strings_view); + cudf::test::expect_strings_empty(results->view()); + + results = cudf::strings::to_upper(strings_view); + cudf::test::expect_strings_empty(results->view()); + + results = cudf::strings::swapcase(strings_view); + cudf::test::expect_strings_empty(results->view()); + + results = cudf::strings::capitalize(strings_view); + cudf::test::expect_strings_empty(results->view()); + + results = cudf::strings::title(strings_view); + cudf::test::expect_strings_empty(results->view()); +} + +TEST_F(StringsCaseTest, ErrorTest) +{ + cudf::test::strings_column_wrapper input{"the column intentionally left blank"}; + auto view = cudf::strings_column_view(input); + + EXPECT_THROW(cudf::strings::capitalize(view, cudf::string_scalar("", false)), cudf::logic_error); +} diff --git a/java/src/main/java/ai/rapids/cudf/ColumnView.java b/java/src/main/java/ai/rapids/cudf/ColumnView.java index 7912a525597..7299a6a716b 100644 --- a/java/src/main/java/ai/rapids/cudf/ColumnView.java +++ b/java/src/main/java/ai/rapids/cudf/ColumnView.java @@ -1497,6 +1497,33 @@ public final ColumnVector toTitle() { assert type.equals(DType.STRING); return new ColumnVector(title(getNativeView())); } + + /** + * Returns a column of capitalized strings. + * + * If the `delimiters` is an empty string, then only the first character of each + * row is capitalized. Otherwise, a non-delimiter character is capitalized after + * any delimiter character is found. + * + * Example: + * input = ["tesT1", "a Test", "Another Test", "a\tb"]; + * delimiters = "" + * output is ["Test1", "A test", "Another test", "A\tb"] + * delimiters = " " + * output is ["Test1", "A Test", "Another Test", "A\tb"] + * + * Any null string entries return corresponding null output column entries. + * + * @param delimiters Used if identifying words to capitalize. Should not be null. + * @return a column of capitalized strings. Users should close the returned column. + */ + public final ColumnVector capitalize(Scalar delimiters) { + if (DType.STRING.equals(type) && DType.STRING.equals(delimiters.getType())) { + return new ColumnVector(capitalize(getNativeView(), delimiters.getScalarHandle())); + } + throw new IllegalArgumentException("Both input column and delimiters scalar should be" + + " string type. But got column: " + type + ", scalar: " + delimiters.getType()); + } ///////////////////////////////////////////////////////////////////////////// // TYPE CAST ///////////////////////////////////////////////////////////////////////////// @@ -3322,6 +3349,8 @@ private static native long clamper(long nativeView, long loScalarHandle, long lo protected static native long title(long handle); + private static native long capitalize(long strsColHandle, long delimitersHandle); + private static native long makeStructView(long[] handles, long rowCount); private static native long isTimestamp(long nativeView, String format); diff --git a/java/src/main/native/src/ColumnViewJni.cpp b/java/src/main/native/src/ColumnViewJni.cpp index b0bc276714a..83ba4d56d68 100644 --- a/java/src/main/native/src/ColumnViewJni.cpp +++ b/java/src/main/native/src/ColumnViewJni.cpp @@ -71,7 +71,6 @@ #include "dtype_utils.hpp" #include "jni.h" #include "jni_utils.hpp" -#include "prefix_sum.hpp" namespace { @@ -1747,6 +1746,23 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_title(JNIEnv *env, jobjec CATCH_STD(env, 0); } +JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_capitalize(JNIEnv *env, jobject j_object, + jlong strs_handle, + jlong delimiters_handle) { + + JNI_NULL_CHECK(env, strs_handle, "native view handle is null", 0) + JNI_NULL_CHECK(env, delimiters_handle, "delimiters scalar handle is null", 0) + + try { + cudf::jni::auto_set_device(env); + cudf::column_view *view = reinterpret_cast(strs_handle); + cudf::string_scalar *deli = reinterpret_cast(delimiters_handle); + std::unique_ptr result = cudf::strings::capitalize(*view, *deli); + return reinterpret_cast(result.release()); + } + CATCH_STD(env, 0); +} + JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_makeStructView(JNIEnv *env, jobject j_object, jlongArray handles, jlong row_count) { diff --git a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java index a121309d8aa..753deceb59d 100644 --- a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java +++ b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java @@ -4458,6 +4458,31 @@ void testStringTitlize() { } } + @Test + void testStringCapitalize() { + try (ColumnVector cv = ColumnVector.fromStrings("s Park", "S\nqL", "lower \tcase", + null, "", "UPPER\rCASE")) { + try (Scalar deli = Scalar.fromString(""); + ColumnVector result = cv.capitalize(deli); + ColumnVector expected = ColumnVector.fromStrings("S park", "S\nql", "Lower \tcase", + null, "", "Upper\rcase")) { + assertColumnsAreEqual(expected, result); + } + try (Scalar deli = Scalar.fromString(" "); + ColumnVector result = cv.capitalize(deli); + ColumnVector expected = ColumnVector.fromStrings("S Park", "S\nql", "Lower \tcase", + null, "", "Upper\rcase")) { + assertColumnsAreEqual(expected, result); + } + try (Scalar deli = Scalar.fromString(" \t\n"); + ColumnVector result = cv.capitalize(deli); + ColumnVector expected = ColumnVector.fromStrings("S Park", "S\nQl", "Lower \tCase", + null, "", "Upper\rcase")) { + assertColumnsAreEqual(expected, result); + } + } + } + @Test void testNansToNulls() { Float[] floats = new Float[]{1.2f, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, null, diff --git a/python/cudf/cudf/_lib/copying.pyx b/python/cudf/cudf/_lib/copying.pyx index cf282af3d77..71462ecafa1 100644 --- a/python/cudf/cudf/_lib/copying.pyx +++ b/python/cudf/cudf/_lib/copying.pyx @@ -20,11 +20,9 @@ from cudf._lib.scalar cimport DeviceScalar from cudf._lib.table cimport Table from cudf._lib.reduce import minmax - -cimport cudf._lib.cpp.copying as cpp_copying - from cudf.core.abc import Serializable +cimport cudf._lib.cpp.copying as cpp_copying from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view, mutable_column_view from cudf._lib.cpp.libcpp.functional cimport reference_wrapper diff --git a/python/cudf/cudf/_lib/cpp/lists/combine.pxd b/python/cudf/cudf/_lib/cpp/lists/combine.pxd index b05b5c05428..a7ad8e7ba41 100644 --- a/python/cudf/cudf/_lib/cpp/lists/combine.pxd +++ b/python/cudf/cudf/_lib/cpp/lists/combine.pxd @@ -3,11 +3,27 @@ from libcpp.memory cimport unique_ptr from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view cdef extern from "cudf/lists/combine.hpp" namespace \ "cudf::lists" nogil: + + ctypedef enum concatenate_null_policy: + IGNORE "cudf::lists::concatenate_null_policy::IGNORE" + NULLIFY_OUTPUT_ROW \ + "cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW" + cdef unique_ptr[column] concatenate_rows( const table_view input_table ) except + + + cdef unique_ptr[column] concatenate_list_elements( + const table_view input_table, + ) except + + + cdef unique_ptr[column] concatenate_list_elements( + const column_view input_table, + concatenate_null_policy null_policy + ) except + diff --git a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd index 30c97c5f338..2af87c3fa14 100644 --- a/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd +++ b/python/cudf/cudf/_lib/cpp/scalar/scalar.pxd @@ -64,6 +64,7 @@ cdef extern from "cudf/scalar/scalar.hpp" namespace "cudf" nogil: cdef cppclass list_scalar(scalar): list_scalar(column_view col) except + + list_scalar(column_view col, bool is_valid) except + column_view view() except + cdef cppclass struct_scalar(scalar): diff --git a/python/cudf/cudf/_lib/gpuarrow.pyx b/python/cudf/cudf/_lib/gpuarrow.pyx index 9f4b9b0e7cb..0768517485e 100644 --- a/python/cudf/cudf/_lib/gpuarrow.pyx +++ b/python/cudf/cudf/_lib/gpuarrow.pyx @@ -17,13 +17,7 @@ from pyarrow.includes.libarrow cimport ( CMessageReader, CRecordBatchStreamReader, ) -from pyarrow.lib cimport ( - Buffer, - RecordBatchReader, - Schema, - _CRecordBatchReader, - pyarrow_wrap_schema, -) +from pyarrow.lib cimport Buffer, RecordBatchReader, Schema, pyarrow_wrap_schema import pyarrow as pa diff --git a/python/cudf/cudf/_lib/lists.pyx b/python/cudf/cudf/_lib/lists.pyx index 245bb3666ea..8ada3376fdb 100644 --- a/python/cudf/cudf/_lib/lists.pyx +++ b/python/cudf/cudf/_lib/lists.pyx @@ -8,6 +8,8 @@ from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.lists.combine cimport ( + concatenate_list_elements as cpp_concatenate_list_elements, + concatenate_null_policy, concatenate_rows as cpp_concatenate_rows, ) from cudf._lib.cpp.lists.count_elements cimport ( @@ -174,3 +176,20 @@ def concatenate_rows(Table tbl): result = Column.from_unique_ptr(move(c_result)) return result + + +def concatenate_list_elements(Column input_column, dropna=False): + cdef concatenate_null_policy policy = ( + concatenate_null_policy.IGNORE if dropna + else concatenate_null_policy.NULLIFY_OUTPUT_ROW + ) + cdef column_view c_input = input_column.view() + cdef unique_ptr[column] c_result + + with nogil: + c_result = move(cpp_concatenate_list_elements( + c_input, + policy + )) + + return Column.from_unique_ptr(move(c_result)) diff --git a/python/cudf/cudf/_lib/scalar.pyx b/python/cudf/cudf/_lib/scalar.pyx index a23f974423d..037b40133d4 100644 --- a/python/cudf/cudf/_lib/scalar.pyx +++ b/python/cudf/cudf/_lib/scalar.pyx @@ -39,7 +39,24 @@ from cudf._lib.cpp.scalar.scalar cimport ( duration_scalar, fixed_point_scalar, list_scalar, + numeric_scalar, + scalar, + string_scalar, struct_scalar, + timestamp_scalar, +) +from cudf._lib.cpp.wrappers.decimals cimport decimal64, scale_type +from cudf._lib.cpp.wrappers.durations cimport ( + duration_ms, + duration_ns, + duration_s, + duration_us, +) +from cudf._lib.cpp.wrappers.timestamps cimport ( + timestamp_ms, + timestamp_ns, + timestamp_s, + timestamp_us, ) from cudf.utils.dtypes import _decimal_to_int64, is_list_dtype, is_struct_dtype @@ -322,20 +339,18 @@ cdef _set_list_from_pylist(unique_ptr[scalar]& s, value = value if valid else [cudf.NA] cdef Column col if isinstance(dtype.element_type, ListDtype): - col = cudf.core.column.as_column( - pa.array( - value, from_pandas=True, type=dtype.element_type.to_arrow() - ) - ) + pa_type = dtype.element_type.to_arrow() else: - col = cudf.core.column.as_column( - pa.array(value, from_pandas=True) - ) + pa_type = dtype.to_arrow().value_type + col = cudf.core.column.as_column( + pa.array(value, from_pandas=True, type=pa_type) + ) cdef column_view col_view = col.view() s.reset( - new list_scalar(col_view) + new list_scalar(col_view, valid) ) + cdef _get_py_list_from_list(unique_ptr[scalar]& s): if not s.get()[0].is_valid(): @@ -486,18 +501,16 @@ cdef _get_np_scalar_from_timedelta64(unique_ptr[scalar]& s): def as_device_scalar(val, dtype=None): - if dtype: - if isinstance(val, (cudf.Scalar, DeviceScalar)) and dtype != val.dtype: - raise TypeError("Can't update dtype of existing GPU scalar") + if isinstance(val, (cudf.Scalar, DeviceScalar)): + if dtype == val.dtype or dtype is None: + if isinstance(val, DeviceScalar): + return val + else: + return val.device_value else: - return cudf.Scalar(value=val, dtype=dtype).device_value + raise TypeError("Can't update dtype of existing GPU scalar") else: - if isinstance(val, DeviceScalar): - return val - if isinstance(val, cudf.Scalar): - return val.device_value - else: - return cudf.Scalar(val).device_value + return cudf.Scalar(val, dtype=dtype).device_value def _is_null_host_scalar(slr): diff --git a/python/cudf/cudf/core/column/categorical.py b/python/cudf/cudf/core/column/categorical.py index 135fb6e6f30..cbcc30d38a7 100644 --- a/python/cudf/cudf/core/column/categorical.py +++ b/python/cudf/cudf/core/column/categorical.py @@ -12,7 +12,6 @@ Optional, Sequence, Tuple, - Union, cast, ) @@ -28,7 +27,7 @@ from cudf._typing import ColumnLike, Dtype, ScalarLike from cudf.core.buffer import Buffer from cudf.core.column import column -from cudf.core.column.methods import ColumnMethodsMixin +from cudf.core.column.methods import ColumnMethodsMixin, ParentType from cudf.core.dtypes import CategoricalDtype from cudf.utils.dtypes import ( is_categorical_dtype, @@ -48,9 +47,6 @@ ) -ParentType = Union["cudf.Series", "cudf.Index"] - - class CategoricalAccessor(ColumnMethodsMixin): _column: CategoricalColumn diff --git a/python/cudf/cudf/core/column/lists.py b/python/cudf/cudf/core/column/lists.py index 8257e8aa6d0..843190f38aa 100644 --- a/python/cudf/cudf/core/column/lists.py +++ b/python/cudf/cudf/core/column/lists.py @@ -8,6 +8,7 @@ import cudf from cudf._lib.copying import segmented_gather from cudf._lib.lists import ( + concatenate_list_elements, concatenate_rows, contains_scalar, count_elements, @@ -16,15 +17,17 @@ sort_lists, ) from cudf._lib.table import Table -from cudf._typing import BinaryOperand, Dtype +from cudf._typing import BinaryOperand, ColumnLike, Dtype, ScalarLike from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase, as_column, column -from cudf.core.column.methods import ColumnMethodsMixin +from cudf.core.column.methods import ColumnMethodsMixin, ParentType from cudf.core.dtypes import ListDtype from cudf.utils.dtypes import _is_non_decimal_numeric_dtype, is_list_dtype class ListColumn(ColumnBase): + dtype: ListDtype + def __init__( self, size, dtype, mask=None, offset=0, null_count=None, children=(), ): @@ -74,6 +77,18 @@ def __sizeof__(self): return self._cached_sizeof + def __setitem__(self, key, value): + if isinstance(value, list): + value = cudf.Scalar(value) + if isinstance(value, cudf.Scalar): + if value.dtype != self.dtype: + raise TypeError("list nesting level mismatch") + elif value is cudf.NA: + value = cudf.Scalar(value, dtype=self.dtype) + else: + raise ValueError(f"Can not set {value} into ListColumn") + super().__setitem__(key, value) + @property def base_size(self): # in some cases, libcudf will return an empty ListColumn with no @@ -266,14 +281,16 @@ class ListMethods(ColumnMethodsMixin): List methods for Series """ - def __init__(self, column, parent=None): + _column: ListColumn + + def __init__(self, column: ListColumn, parent: ParentType = None): if not is_list_dtype(column.dtype): raise AttributeError( "Can only use .list accessor with a 'list' dtype" ) super().__init__(column=column, parent=parent) - def get(self, index): + def get(self, index: int) -> ParentType: """ Extract element at the given index from each component @@ -305,10 +322,10 @@ def get(self, index): else: raise IndexError("list index out of range") - def contains(self, search_key): + def contains(self, search_key: ScalarLike) -> ParentType: """ - Creates a column of bool values indicating whether the specified scalar - is an element of each row of a list column. + Returns boolean values indicating whether the specified scalar + is an element of each row. Parameters ---------- @@ -317,7 +334,7 @@ def contains(self, search_key): Returns ------- - Column + Series or Index Examples -------- @@ -345,14 +362,14 @@ def contains(self, search_key): return res @property - def leaves(self): + def leaves(self) -> ParentType: """ From a Series of (possibly nested) lists, obtain the elements from the innermost lists as a flat Series (one value per row). Returns ------- - Series + Series or Index Examples -------- @@ -373,7 +390,7 @@ def leaves(self): self._column.elements, retain_index=False ) - def len(self): + def len(self) -> ParentType: """ Computes the length of each element in the Series/Index. @@ -397,18 +414,18 @@ def len(self): """ return self._return_or_inplace(count_elements(self._column)) - def take(self, lists_indices): + def take(self, lists_indices: ColumnLike) -> ParentType: """ Collect list elements based on given indices. Parameters ---------- - lists_indices: List type arrays + lists_indices: Series-like of lists Specifies what to collect from each row Returns ------- - ListColumn + Series or Index Examples -------- @@ -452,14 +469,14 @@ def take(self, lists_indices): else: return res - def unique(self): + def unique(self) -> ParentType: """ - Returns unique element for each list in the column, order for each - unique element is not guaranteed. + Returns the unique elements in each list. + The ordering of elements is not guaranteed. Returns ------- - ListColumn + Series or Index Examples -------- @@ -489,12 +506,12 @@ def unique(self): def sort_values( self, - ascending=True, - inplace=False, - kind="quicksort", - na_position="last", - ignore_index=False, - ): + ascending: bool = True, + inplace: bool = False, + kind: str = "quicksort", + na_position: str = "last", + ignore_index: bool = False, + ) -> ParentType: """ Sort each list by the values. @@ -511,7 +528,7 @@ def sort_values( Returns ------- - ListColumn with each list sorted + Series or Index with each list sorted Notes ----- @@ -540,3 +557,59 @@ def sort_values( sort_lists(self._column, ascending, na_position), retain_index=not ignore_index, ) + + def concat(self, dropna=True) -> ParentType: + """ + For a column with at least one level of nesting, concatenate the + lists in each row. + + Parameters + ---------- + dropna: bool, optional + If True (default), ignores top-level null elements in each row. + If False, and top-level null elements are present, the resulting + row in the output is null. + + Returns + ------- + Series or Index + + Examples + -------- + >>> s1 + 0 [[1.0, 2.0], [3.0, 4.0, 5.0]] + 1 [[6.0, None], [7.0], [8.0, 9.0]] + dtype: list + >>> s1.list.concat() + 0 [1.0, 2.0, 3.0, 4.0, 5.0] + 1 [6.0, None, 7.0, 8.0, 9.0] + dtype: list + + Null values at the top-level in each row are dropped by default: + + >>> s2 + 0 [[1.0, 2.0], None, [3.0, 4.0, 5.0]] + 1 [[6.0, None], [7.0], [8.0, 9.0]] + dtype: list + >>> s2.list.concat() + 0 [1.0, 2.0, 3.0, 4.0, 5.0] + 1 [6.0, None, 7.0, 8.0, 9.0] + dtype: list + + Use ``dropna=False`` to produce a null instead: + + >>> s2.list.concat(dropna=False) + 0 None + 1 [6.0, nan, 7.0, 8.0, 9.0] + dtype: list + """ + try: + result = concatenate_list_elements(self._column, dropna=dropna) + except RuntimeError as e: + if "Rows of the input column must be lists." in str(e): + raise ValueError( + "list.concat() can only be called on " + "list columns with at least one level " + "of nesting" + ) + return self._return_or_inplace(result) diff --git a/python/cudf/cudf/core/column/methods.py b/python/cudf/cudf/core/column/methods.py index d7b416d06c9..4b448e27a53 100644 --- a/python/cudf/cudf/core/column/methods.py +++ b/python/cudf/cudf/core/column/methods.py @@ -11,15 +11,17 @@ if TYPE_CHECKING: from cudf.core.column import ColumnBase +ParentType = Union["cudf.Series", "cudf.BaseIndex"] + class ColumnMethodsMixin: _column: ColumnBase - _parent: Optional[Union["cudf.Series", "cudf.Index"]] + _parent: Optional[Union["cudf.Series", "cudf.BaseIndex"]] def __init__( self, column: ColumnBase, - parent: Union["cudf.Series", "cudf.Index"] = None, + parent: Union["cudf.Series", "cudf.BaseIndex"] = None, ): self._column = column self._parent = parent @@ -27,13 +29,13 @@ def __init__( @overload def _return_or_inplace( self, new_col, inplace: Literal[False], expand=False, retain_index=True - ) -> Union["cudf.Series", "cudf.Index"]: + ) -> Union["cudf.Series", "cudf.BaseIndex"]: ... @overload def _return_or_inplace( self, new_col, expand: bool = False, retain_index: bool = True - ) -> Union["cudf.Series", "cudf.Index"]: + ) -> Union["cudf.Series", "cudf.BaseIndex"]: ... @overload @@ -49,7 +51,7 @@ def _return_or_inplace( inplace: bool = False, expand: bool = False, retain_index: bool = True, - ) -> Optional[Union["cudf.Series", "cudf.Index"]]: + ) -> Optional[Union["cudf.Series", "cudf.BaseIndex"]]: ... def _return_or_inplace( diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index a6a9de2e77b..0902167be8b 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -161,7 +161,7 @@ from cudf.api.types import is_integer from cudf.core.buffer import Buffer from cudf.core.column import column, datetime -from cudf.core.column.methods import ColumnMethodsMixin +from cudf.core.column.methods import ColumnMethodsMixin, ParentType from cudf.utils import utils from cudf.utils.docutils import copy_docstring from cudf.utils.dtypes import ( @@ -171,6 +171,12 @@ is_string_dtype, ) + +def str_to_boolean(column: StringColumn): + """Takes in string column and returns boolean column """ + return (column.str().len() > cudf.Scalar(0, dtype="int8")).fillna(False) + + _str_to_numeric_typecast_functions = { np.dtype("int8"): str_cast.stoi8, np.dtype("int16"): str_cast.stoi16, @@ -182,7 +188,7 @@ np.dtype("uint64"): str_cast.stoul, np.dtype("float32"): str_cast.stof, np.dtype("float64"): str_cast.stod, - np.dtype("bool"): str_cast.to_booleans, + np.dtype("bool"): str_to_boolean, } _numeric_to_str_typecast_functions = { @@ -216,9 +222,6 @@ } -ParentType = Union["cudf.Series", "cudf.core.index.BaseIndex"] - - class StringMethods(ColumnMethodsMixin): def __init__(self, column, parent=None): """ diff --git a/python/cudf/cudf/core/indexing.py b/python/cudf/cudf/core/indexing.py index 6711171612a..933fd768d7c 100755 --- a/python/cudf/cudf/core/indexing.py +++ b/python/cudf/cudf/core/indexing.py @@ -110,7 +110,10 @@ def __setitem__(self, key, value): # coerce value into a scalar or column if is_scalar(value): value = to_cudf_compatible_scalar(value) - else: + elif not ( + isinstance(value, list) + and isinstance(self._sr._column.dtype, cudf.ListDtype) + ): value = column.as_column(value) if ( not isinstance( diff --git a/python/cudf/cudf/core/scalar.py b/python/cudf/cudf/core/scalar.py index a17d1dad9b3..ad39642cf60 100644 --- a/python/cudf/cudf/core/scalar.py +++ b/python/cudf/cudf/core/scalar.py @@ -127,7 +127,7 @@ def _preprocess_host_value(self, value, dtype): ) return value, dtype elif isinstance(dtype, ListDtype): - if value is not None: + if value not in {None, NA}: raise ValueError(f"Can not coerce {value} to ListDtype") else: return NA, dtype diff --git a/python/cudf/cudf/tests/test_list.py b/python/cudf/cudf/tests/test_list.py index a6a9ba97ef5..abd24ddd0fd 100644 --- a/python/cudf/cudf/tests/test_list.py +++ b/python/cudf/cudf/tests/test_list.py @@ -1,5 +1,6 @@ # Copyright (c) 2020-2021, NVIDIA CORPORATION. import functools +import operator import numpy as np import pandas as pd @@ -324,6 +325,43 @@ def test_contains_null_search_key(data, expect): assert_eq(expect, got) +@pytest.mark.parametrize( + "row", + [ + [[]], + [[1]], + [[1, 2]], + [[1, 2], [3, 4, 5]], + [[1, 2], [], [3, 4, 5]], + [[1, 2, None], [3, 4, 5]], + [[1, 2, None], None, [3, 4, 5]], + [[1, 2, None], None, [], [3, 4, 5]], + [[[1, 2], [3, 4]], [[5, 6, 7], [8, 9]]], + [[["a", "c", "de", None], None, ["fg"]], [["abc", "de"], None]], + ], +) +@pytest.mark.parametrize("dropna", [True, False]) +def test_concat_elements(row, dropna): + if any(x is None for x in row): + if dropna: + row = [x for x in row if x is not None] + result = functools.reduce(operator.add, row) + else: + result = None + else: + result = functools.reduce(operator.add, row) + + expect = pd.Series([result]) + got = cudf.Series([row]).list.concat(dropna=dropna) + assert_eq(expect, got) + + +def test_concat_elements_raise(): + s = cudf.Series([[1, 2, 3]]) # no nesting + with pytest.raises(ValueError): + s.list.concat() + + def test_concatenate_rows_of_lists(): pdf = pd.DataFrame({"val": [["a", "a"], ["b"], ["c"]]}) gdf = cudf.from_pandas(pdf) @@ -457,3 +495,67 @@ def test_serialize_list_columns(data): df = cudf.DataFrame(data) recreated = df.__class__.deserialize(*df.serialize()) assert_eq(recreated, df) + + +@pytest.mark.parametrize( + "data,item", + [ + ( + # basic list into a list column + [[1, 2, 3], [4, 5, 6], [7, 8, 9]], + [0, 0, 0], + ), + ( + # nested list into nested list column + [ + [[1, 2, 3], [4, 5, 6]], + [[1, 2, 3], [4, 5, 6]], + [[1, 2, 3], [4, 5, 6]], + ], + [[0, 0, 0], [0, 0, 0]], + ), + ( + # NA into a list column + [[1, 2, 3], [4, 5, 6], [7, 8, 9]], + NA, + ), + ( + # NA into nested list column + [ + [[1, 2, 3], [4, 5, 6]], + [[1, 2, 3], [4, 5, 6]], + [[1, 2, 3], [4, 5, 6]], + ], + NA, + ), + ], +) +def test_listcol_setitem(data, item): + sr = cudf.Series(data) + + sr[1] = item + data[1] = item + expect = cudf.Series(data) + + assert_eq(expect, sr) + + +@pytest.mark.parametrize( + "data,item,error", + [ + ( + [[1, 2, 3], [4, 5, 6], [7, 8, 9]], + [[1, 2, 3], [4, 5, 6]], + "list nesting level mismatch", + ), + ( + [[1, 2, 3], [4, 5, 6], [7, 8, 9]], + 0, + "Can not set 0 into ListColumn", + ), + ], +) +def test_listcol_setitem_error_cases(data, item, error): + sr = cudf.Series(data) + with pytest.raises(BaseException, match=error): + sr[1] = item diff --git a/python/cudf/cudf/tests/test_string.py b/python/cudf/cudf/tests/test_string.py index 3c153a16a13..a8c00ce031e 100644 --- a/python/cudf/cudf/tests/test_string.py +++ b/python/cudf/cudf/tests/test_string.py @@ -200,11 +200,7 @@ def test_string_astype(dtype): ps = pd.Series(data) gs = cudf.Series(data) - # Pandas str --> bool typecasting always returns True if there's a string - if dtype.startswith("bool"): - expect = ps == "True" - else: - expect = ps.astype(dtype) + expect = ps.astype(dtype) got = gs.astype(dtype) assert_eq(expect, got) From 16554355c74f13e28cddd1cc428782eae7cd720e Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Thu, 8 Jul 2021 10:38:04 -0400 Subject: [PATCH 17/18] Fix merge conflicts --- python/cudf/cudf/_lib/io/utils.pxd | 14 ++++++++-- python/cudf/cudf/_lib/io/utils.pyx | 40 ++++++++++++++++++++++++++++- python/cudf/cudf/_lib/orc.pyx | 17 +++++++++++-- python/cudf/cudf/_lib/parquet.pyx | 41 +++++------------------------- 4 files changed, 72 insertions(+), 40 deletions(-) diff --git a/python/cudf/cudf/_lib/io/utils.pxd b/python/cudf/cudf/_lib/io/utils.pxd index 233e4f7c635..82ad9d67f78 100644 --- a/python/cudf/cudf/_lib/io/utils.pxd +++ b/python/cudf/cudf/_lib/io/utils.pxd @@ -1,9 +1,19 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr +from libcpp.vector cimport vector -from cudf._lib.cpp.io.types cimport data_sink, sink_info, source_info +from cudf._lib.cpp.io.types cimport ( + column_name_info, + data_sink, + sink_info, + source_info, +) +from cudf._lib.table cimport Table cdef source_info make_source_info(list src) except* cdef sink_info make_sink_info(src, unique_ptr[data_sink] & data) except* +cdef update_struct_field_names( + Table table, + vector[column_name_info]& schema_info) diff --git a/python/cudf/cudf/_lib/io/utils.pyx b/python/cudf/cudf/_lib/io/utils.pyx index 846086107e1..72ab64f6249 100644 --- a/python/cudf/cudf/_lib/io/utils.pyx +++ b/python/cudf/cudf/_lib/io/utils.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, NVIDIA CORPORATION. from cpython.buffer cimport PyBUF_READ from cpython.memoryview cimport PyMemoryView_FromMemory @@ -9,7 +9,9 @@ from libcpp.string cimport string from libcpp.utility cimport move from libcpp.vector cimport vector +from cudf._lib.column cimport Column from cudf._lib.cpp.io.types cimport ( + column_name_info, data_sink, datasource, host_buffer, @@ -25,6 +27,7 @@ import io import os import cudf +from cudf.utils.dtypes import is_struct_dtype # Converts the Python source input to libcudf++ IO source_info @@ -117,3 +120,38 @@ cdef cppclass iobase_data_sink(data_sink): size_t bytes_written() with gil: return buf.tell() + + +cdef update_struct_field_names( + Table table, + vector[column_name_info]& schema_info +): + for i, (name, col) in enumerate(table._data.items()): + table._data[name] = _update_column_struct_field_names( + col, schema_info[i] + ) + + +cdef Column _update_column_struct_field_names( + Column col, + column_name_info& info +): + cdef vector[string] field_names + + if is_struct_dtype(col): + field_names.reserve(len(col.base_children)) + for i in range(info.children.size()): + field_names.push_back(info.children[i].name) + col = col._rename_fields( + field_names + ) + + if col.children: + children = list(col.children) + for i, child in enumerate(children): + children[i] = _update_column_struct_field_names( + child, + info.children[i] + ) + col.set_base_children(tuple(children)) + return col diff --git a/python/cudf/cudf/_lib/orc.pyx b/python/cudf/cudf/_lib/orc.pyx index 2383c15c1a0..2470c15f541 100644 --- a/python/cudf/cudf/_lib/orc.pyx +++ b/python/cudf/cudf/_lib/orc.pyx @@ -9,6 +9,10 @@ from libcpp.utility cimport move from libcpp.vector cimport vector from cudf._lib.cpp.column.column cimport column + +from cudf.utils.dtypes import is_struct_dtype + +from cudf._lib.column cimport Column from cudf._lib.cpp.io.orc cimport ( chunked_orc_writer_options, orc_chunked_writer, @@ -22,6 +26,7 @@ from cudf._lib.cpp.io.orc_metadata cimport ( read_raw_orc_statistics as libcudf_read_raw_orc_statistics, ) from cudf._lib.cpp.io.types cimport ( + column_name_info, compression_type, data_sink, sink_info, @@ -32,7 +37,11 @@ from cudf._lib.cpp.io.types cimport ( ) from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport data_type, size_type, type_id -from cudf._lib.io.utils cimport make_sink_info, make_source_info +from cudf._lib.io.utils cimport ( + make_sink_info, + make_source_info, + update_struct_field_names, +) from cudf._lib.table cimport Table from cudf._lib.types import np_to_cudf_types @@ -102,7 +111,11 @@ cpdef read_orc(object filepaths_or_buffers, names = [name.decode() for name in c_result.metadata.column_names] - return Table.from_unique_ptr(move(c_result.tbl), names) + tbl = Table.from_unique_ptr(move(c_result.tbl), names) + + update_struct_field_names(tbl, c_result.metadata.schema_info) + + return tbl cdef compression_type _get_comp_type(object compression): diff --git a/python/cudf/cudf/_lib/parquet.pyx b/python/cudf/cudf/_lib/parquet.pyx index 088b475139b..52f3aada00b 100644 --- a/python/cudf/cudf/_lib/parquet.pyx +++ b/python/cudf/cudf/_lib/parquet.pyx @@ -57,7 +57,11 @@ from cudf._lib.cpp.io.parquet cimport ( from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport data_type, size_type -from cudf._lib.io.utils cimport make_sink_info, make_source_info +from cudf._lib.io.utils cimport ( + make_sink_info, + make_source_info, + update_struct_field_names, +) from cudf._lib.table cimport Table @@ -181,7 +185,7 @@ cpdef read_parquet(filepaths_or_buffers, columns=None, row_groups=None, ) ) - _update_struct_field_names(df, c_out_table.metadata.schema_info) + update_struct_field_names(df, c_out_table.metadata.schema_info) if df.empty and meta is not None: cols_dtype_map = {} @@ -513,39 +517,6 @@ cdef cudf_io_types.compression_type _get_comp_type(object compression): raise ValueError("Unsupported `compression` type") -cdef _update_struct_field_names( - Table table, - vector[cudf_io_types.column_name_info]& schema_info -): - for i, (name, col) in enumerate(table._data.items()): - table._data[name] = _update_column_struct_field_names( - col, schema_info[i] - ) - -cdef Column _update_column_struct_field_names( - Column col, - cudf_io_types.column_name_info& info -): - cdef vector[string] field_names - - if is_struct_dtype(col): - field_names.reserve(len(col.base_children)) - for i in range(info.children.size()): - field_names.push_back(info.children[i].name) - col = col._rename_fields( - field_names - ) - - if col.children: - children = list(col.children) - for i, child in enumerate(children): - children[i] = _update_column_struct_field_names( - child, - info.children[i] - ) - col.set_base_children(tuple(children)) - return col - cdef _set_col_metadata(Column col, column_in_metadata& col_meta): if is_struct_dtype(col): for i, (child_col, name) in enumerate( From 3e799bd964ada69b1d8c660b3c67f9dc52f3c480 Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Tue, 13 Jul 2021 11:44:50 -0400 Subject: [PATCH 18/18] Fix merge conflicts --- python/cudf/cudf/_lib/scalar.pyx | 35 ++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/_lib/scalar.pyx b/python/cudf/cudf/_lib/scalar.pyx index 037b40133d4..7cc67c54bd1 100644 --- a/python/cudf/cudf/_lib/scalar.pyx +++ b/python/cudf/cudf/_lib/scalar.pyx @@ -33,7 +33,7 @@ from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.table cimport Table from cudf._lib.types cimport dtype_from_column_view, underlying_type_t_type_id -from cudf._lib.interop import to_arrow +from cudf._lib.interop import from_arrow, to_arrow from cudf._lib.cpp.scalar.scalar cimport ( duration_scalar, @@ -93,6 +93,8 @@ cdef class DeviceScalar: elif isinstance(dtype, cudf.ListDtype): _set_list_from_pylist( self.c_value, value, dtype, valid) + elif isinstance(dtype, cudf.StructDtype): + _set_struct_from_pydict(self.c_value, value, dtype, valid) elif pd.api.types.is_string_dtype(dtype): _set_string_from_np_string(self.c_value, value, valid) elif pd.api.types.is_numeric_dtype(dtype): @@ -178,7 +180,6 @@ cdef class DeviceScalar: s.c_value = move(ptr) cdtype = s.get_raw_ptr()[0].type() - if cdtype.id() == libcudf_types.DECIMAL64 and dtype is None: raise TypeError( "Must pass a dtype when constructing from a fixed-point scalar" @@ -314,6 +315,36 @@ cdef _set_decimal64_from_scalar(unique_ptr[scalar]& s, ) ) +cdef _set_struct_from_pydict(unique_ptr[scalar]& s, + object value, + object dtype, + bool valid=True): + arrow_schema = dtype.to_arrow() + columns = [str(i) for i in range(len(arrow_schema))] + if valid: + pyarrow_table = pa.Table.from_arrays( + [ + pa.array([value[f.name]], from_pandas=True, type=f.type) + for f in arrow_schema + ], + names=columns + ) + else: + pyarrow_table = pa.Table.from_arrays( + [ + pa.array([], from_pandas=True, type=f.type) + for f in arrow_schema + ], + names=columns + ) + + cdef Table table = from_arrow(pyarrow_table, column_names=columns) + cdef table_view struct_view = table.view() + + s.reset( + new struct_scalar(struct_view, valid) + ) + cdef _get_py_dict_from_struct(unique_ptr[scalar]& s): if not s.get()[0].is_valid(): return cudf.NA