-
Notifications
You must be signed in to change notification settings - Fork 924
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose stream-ordering in scalar and avro APIs (#17766)
Contributes to #13744 Replaces conversion operators in derived classes of `cudf::scalar` with stream-ordered `get_value(stream)` member function. Adds stream parameter to `cudf::io::read_avro` Authors: - Shruti Shivakumar (https://github.com/shrshi) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Vukasin Milovanovic (https://github.com/vuule) - David Wendt (https://github.com/davidwendt) - https://github.com/nvdbaranec URL: #17766
- Loading branch information
Showing
7 changed files
with
70 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2019-2023, NVIDIA CORPORATION. | ||
* Copyright (c) 2019-2025, NVIDIA CORPORATION. | ||
* | ||
* Copyright 2018-2019 BlazingDB, Inc. | ||
* Copyright 2018 Christian Noboa Mardini <[email protected]> | ||
|
@@ -69,6 +69,20 @@ struct NearEqualComparator { | |
} | ||
}; | ||
|
||
template <typename TypeLhs, typename ScalarType> | ||
TypeLhs scalar_host_value(cudf::scalar const& lhs) | ||
{ | ||
auto sclr = static_cast<ScalarType const&>(lhs); | ||
auto stream = cudf::get_default_stream(); | ||
if constexpr (std::is_same_v<ScalarType, cudf::string_scalar>) { | ||
return sclr.to_string(stream); | ||
} else if constexpr (std::is_same_v<ScalarType, cudf::fixed_point_scalar<TypeLhs>>) { | ||
return sclr.fixed_point_value(stream); | ||
} else { | ||
return sclr.value(stream); | ||
} | ||
} | ||
|
||
template <typename TypeOut, | ||
typename TypeLhs, | ||
typename TypeRhs, | ||
|
@@ -81,7 +95,7 @@ void ASSERT_BINOP(cudf::column_view const& out, | |
TypeOp&& op, | ||
ValueComparator const& value_comparator = ValueComparator()) | ||
{ | ||
auto lhs_h = static_cast<ScalarType const&>(lhs).operator TypeLhs(); | ||
auto lhs_h = scalar_host_value<TypeLhs, ScalarType>(lhs); | ||
auto rhs_h = cudf::test::to_host<TypeRhs>(rhs); | ||
auto rhs_data = rhs_h.first; | ||
auto out_h = cudf::test::to_host<TypeOut>(out); | ||
|
@@ -129,7 +143,7 @@ void ASSERT_BINOP(cudf::column_view const& out, | |
TypeOp&& op, | ||
ValueComparator const& value_comparator = ValueComparator()) | ||
{ | ||
auto rhs_h = static_cast<ScalarType const&>(rhs).operator TypeRhs(); | ||
auto rhs_h = scalar_host_value<TypeRhs, ScalarType>(rhs); | ||
auto lhs_h = cudf::test::to_host<TypeLhs>(lhs); | ||
auto lhs_data = lhs_h.first; | ||
auto out_h = cudf::test::to_host<TypeOut>(out); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/default_stream.hpp> | ||
#include <cudf_test/type_lists.hpp> | ||
|
||
#include <cudf/scalar/scalar.hpp> | ||
|
||
template <typename T> | ||
struct TypedScalarTest : public cudf::test::BaseFixture {}; | ||
|
||
TYPED_TEST_SUITE(TypedScalarTest, cudf::test::FixedWidthTypes); | ||
|
||
TYPED_TEST(TypedScalarTest, DefaultValidity) | ||
{ | ||
using Type = cudf::device_storage_type_t<TypeParam>; | ||
Type value = static_cast<Type>(cudf::test::make_type_param_scalar<TypeParam>(7)); | ||
cudf::scalar_type_t<TypeParam> s(value, true, cudf::test::get_default_stream()); | ||
EXPECT_EQ(value, s.value(cudf::test::get_default_stream())); | ||
} | ||
|
||
struct StringScalarTest : public cudf::test::BaseFixture {}; | ||
|
||
TEST_F(StringScalarTest, DefaultValidity) | ||
{ | ||
std::string value = "test string"; | ||
auto s = cudf::string_scalar(value, true, cudf::test::get_default_stream()); | ||
EXPECT_EQ(value, s.to_string(cudf::test::get_default_stream())); | ||
} |