Skip to content

Commit

Permalink
Replace unnecessary uses of UNKNOWN_NULL_COUNT (#13102)
Browse files Browse the repository at this point in the history
This PR replaces uses of `cudf::UNKNOWN_NULL_COUNT` where the null count is either already known or trivially computed.

Contributes to #11968

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - David Wendt (https://github.com/davidwendt)
  - Nghia Truong (https://github.com/ttnghia)

URL: #13102
  • Loading branch information
vyasr authored Apr 10, 2023
1 parent 30411b5 commit cab6522
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cpp/src/binaryop/compiled/binary_ops.cu
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ scalar_as_column_view::return_type scalar_as_column_view::operator()<cudf::strin
auto col_v = column_view(s.type(),
1,
nullptr,
(bitmask_type const*)s.validity_data(),
cudf::UNKNOWN_NULL_COUNT,
reinterpret_cast<bitmask_type const*>(s.validity_data()),
static_cast<size_type>(!s.is_valid(stream)),
0,
{offsets_column->view(), chars_column_v});
return std::pair{col_v, std::move(offsets_column)};
Expand Down
10 changes: 3 additions & 7 deletions cpp/src/copying/pack.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -159,12 +159,8 @@ packed_columns::metadata pack_metadata(ColumnIter begin,

// first metadata entry is a stub indicating how many total (top level) columns
// there are
metadata.emplace_back(data_type{type_id::EMPTY},
static_cast<size_type>(std::distance(begin, end)),
UNKNOWN_NULL_COUNT,
-1,
-1,
0);
metadata.emplace_back(
data_type{type_id::EMPTY}, static_cast<size_type>(std::distance(begin, end)), 0, -1, -1, 0);

std::for_each(begin, end, [&metadata, &contiguous_buffer, &buffer_size](column_view const& col) {
build_column_metadata(metadata, col, contiguous_buffer, buffer_size);
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/interop/from_arrow.cu
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::string_view>(
auto out_col = make_strings_column(num_rows,
std::move(offsets_column),
std::move(chars_column),
UNKNOWN_NULL_COUNT,
array.null_count(),
std::move(*get_mask_buffer(array, stream, mr)));

return num_rows == array.length()
Expand Down Expand Up @@ -324,7 +324,7 @@ std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::dictionary32>(
return make_dictionary_column(std::move(keys_column),
std::move(indices_column),
std::move(*(column_contents.null_mask)),
UNKNOWN_NULL_COUNT);
array.null_count());
}

template <>
Expand Down Expand Up @@ -357,7 +357,7 @@ std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::struct_view>(
}

return make_structs_column(
array.length(), move(child_columns), UNKNOWN_NULL_COUNT, std::move(out_mask), stream, mr);
array.length(), move(child_columns), array.null_count(), std::move(out_mask), stream, mr);
}

template <>
Expand All @@ -381,7 +381,7 @@ std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::list_view>(
auto out_col = make_lists_column(num_rows,
std::move(offsets_column),
std::move(child_column),
UNKNOWN_NULL_COUNT,
array.null_count(),
std::move(*get_mask_buffer(array, stream, mr)),
stream,
mr);
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/lists/copying/concatenate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include <algorithm>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
Expand All @@ -29,6 +28,7 @@

#include <thrust/transform.h>

#include <algorithm>
#include <memory>

namespace cudf {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/lists/dremel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ dremel_data get_encoding(column_view h_col,
col.size(),
col.head(),
col.null_mask(),
UNKNOWN_NULL_COUNT,
col.null_count(),
col.offset(),
std::move(children));
};
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/transform/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::unique_ptr<column> transform(column_view const& input,
CUDF_EXPECTS(is_fixed_width(input.type()), "Unexpected non-fixed-width type.");

std::unique_ptr<column> output = make_fixed_width_column(
output_type, input.size(), copy_bitmask(input), cudf::UNKNOWN_NULL_COUNT, stream, mr);
output_type, input.size(), copy_bitmask(input), input.null_count(), stream, mr);

if (input.is_empty()) { return output; }

Expand Down

0 comments on commit cab6522

Please sign in to comment.