Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] Support creating decimal vectors from scalar #6723

Merged
merged 9 commits into from
Nov 17, 2020

Conversation

sperlingxx
Copy link
Contributor

Currently, we will get unexpected results when creating decimal column vectors from decimal scalar and row number. The reason is that we perform in_place_fill with fixed-point data type directly.

This PR attempts to fix this problem through peforming in_place_fill with underlying data type of fixed-point columns. Related tests are provided in java package.

@GPUtester
Copy link
Collaborator

Please update the changelog in order to start CI tests.

View the gpuCI docs here.

@sperlingxx sperlingxx changed the title [Review] fix: creating decimal vectors from scalar [Review] support creating decimal vectors from scalar Nov 10, 2020
@codecov
Copy link

codecov bot commented Nov 10, 2020

Codecov Report

Merging #6723 (7d60267) into branch-0.17 (158cb6b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           branch-0.17    #6723   +/-   ##
============================================
  Coverage        81.77%   81.77%           
============================================
  Files               96       96           
  Lines            15885    15885           
============================================
  Hits             12990    12990           
  Misses            2895     2895           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 158cb6b...7d60267. Read the comment docs.

cudf::size_type end,
cudaStream_t stream = 0)
{
in_place_fill<T>(destination, begin, end, value, stream);
if (value.type().id() == cudf::type_id::DECIMAL32) {
auto s = cudf::make_numeric_scalar(cudf::data_type(cudf::type_id::INT32));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to use make_fixed_point_scalar here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codereport I think we need int32-typed scalar to keep align with int32-typed column view. Acually, I am not familiar with cudf native. If I am wrong, please correct me. Thank you!

@codereport codereport changed the title [Review] support creating decimal vectors from scalar [REVIEW] Support creating decimal vectors from scalar Nov 10, 2020
cpp/src/filling/fill.cu Outdated Show resolved Hide resolved
cpp/src/filling/fill.cu Outdated Show resolved Hide resolved
cpp/src/filling/fill.cu Outdated Show resolved Hide resolved
cpp/src/filling/fill.cu Outdated Show resolved Hide resolved
Comment on lines 80 to 83
auto in_place_view = cudf::mutable_column_view{s->type(),
destination.size(),
reinterpret_cast<void*>(destination.data<T>()),
destination.null_mask()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logical_cast.

Copy link
Contributor Author

@sperlingxx sperlingxx Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jrhemstad , thanks for review! I've replaced this code piece with logicial_cast. Meanwhile, I found logicial_cast can't work at here directly. There exists two obstacles:

  1. With logicial_cast, we can only get (immutable) column_view. But we really need mutable_column_view here.
  2. Fixed-point types are not logically castable in current.

I attempted to solve above two problems. But I am not quite confident in my work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will review the logical_cast for fixed_point. I was just looking at this code the other day.

Copy link
Contributor

@revans2 revans2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the java side the changes look fine.

@@ -54,23 +59,30 @@ struct ColumnViewAllTypesTests : public cudf::test::BaseFixture {
TYPED_TEST_CASE(ColumnViewAllTypesTests, cudf::test::FixedWidthTypes);

template <typename FromType, typename ToType, typename Iterator>
void do_logical_cast(cudf::column_view const& input, Iterator begin, Iterator end)
void do_logical_cast(cudf::test::detail::column_wrapper& input, Iterator begin, Iterator end)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be column_wrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to change here. I used column_wrapper to adapt both column_view and mutable_column_view.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mutable_column_view is implicitly convertible to column_view.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've updated with implicit conversion.

Comment on lines +76 to +78
using RepType = typename T::rep;
auto s = cudf::numeric_scalar<RepType>(unscaled, value.is_valid());
auto view = cudf::logical_cast(destination, s.type());
in_place_fill<RepType>(view, begin, end, s, stream);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much nicer now!

cpp/include/cudf/utilities/traits.hpp Show resolved Hide resolved
java/src/main/native/src/ColumnVectorJni.cpp Show resolved Hide resolved
cpp/include/cudf/column/column_view.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@revans2 revans2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good from the java side

sperlingxx and others added 4 commits November 14, 2020 10:08
Copy link
Contributor

@codereport codereport left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@sperlingxx sperlingxx merged commit 42fe218 into rapidsai:branch-0.17 Nov 17, 2020
@sperlingxx sperlingxx deleted the fix_dec_v_from_s branch November 18, 2020 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants