libcudf  23.12.00
Files | Functions

Files

file  filling.hpp
 Column APIs for fill, repeat, and sequence.
 

Functions

void cudf::fill_in_place (mutable_column_view &destination, size_type begin, size_type end, scalar const &value, rmm::cuda_stream_view stream=cudf::get_default_stream())
 Fills a range of elements in-place in a column with a scalar value. More...
 
std::unique_ptr< columncudf::fill (column_view const &input, size_type begin, size_type end, scalar const &value, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Fills a range of elements in a column out-of-place with a scalar value. More...
 
std::unique_ptr< tablecudf::repeat (table_view const &input_table, column_view const &count, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Repeat rows of a Table. More...
 
std::unique_ptr< tablecudf::repeat (table_view const &input_table, size_type count, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Repeat rows of a Table. More...
 
std::unique_ptr< columncudf::sequence (size_type size, scalar const &init, scalar const &step, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Fills a column with a sequence of value specified by an initial value and a step. More...
 
std::unique_ptr< columncudf::sequence (size_type size, scalar const &init, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Fills a column with a sequence of value specified by an initial value and a step of 1. More...
 
std::unique_ptr< cudf::columncudf::calendrical_month_sequence (size_type size, scalar const &init, size_type months, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Generate a sequence of timestamps beginning at init and incrementing by months for each successive element, i.e., output[i] = init + i * months for i in [0, size). More...
 

Detailed Description

Function Documentation

◆ calendrical_month_sequence()

std::unique_ptr<cudf::column> cudf::calendrical_month_sequence ( size_type  size,
scalar const &  init,
size_type  months,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Generate a sequence of timestamps beginning at init and incrementing by months for each successive element, i.e., output[i] = init + i * months for i in [0, size).

If a given date is invalid, the date is scaled back to the last available day of that month.

Example:

size = 3
init = 2020-01-31 08:00:00
months = 1
return = [2020-01-31 08:00:00, 2020-02-29 08:00:00, 2020-03-31 08:00:00]
Exceptions
cudf::logic_errorif input datatype is not a TIMESTAMP
Parameters
sizeNumber of timestamps to generate
initThe initial timestamp
monthsMonths to increment
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
Timestamps column with sequences of months

◆ fill()

std::unique_ptr<column> cudf::fill ( column_view const &  input,
size_type  begin,
size_type  end,
scalar const &  value,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Fills a range of elements in a column out-of-place with a scalar value.

Creates a new column as-if an in-place fill was performed into input; i.e. it is as if a copy of input was created first and then the elements indicated by the indices [begin, end) were overwritten by value.

Exceptions
cudf::logic_errorfor invalid range (if begin < 0, begin > end, or end > destination.size()).
cudf::logic_errorif destination and value have different types.
Parameters
inputThe input column used to create a new column. The new column is created by replacing the values of input in the specified range with value.
beginThe starting index of the fill range (inclusive)
endThe index of the last element in the fill range (exclusive)
valueThe scalar value to fill
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
The result output column

◆ fill_in_place()

void cudf::fill_in_place ( mutable_column_view destination,
size_type  begin,
size_type  end,
scalar const &  value,
rmm::cuda_stream_view  stream = cudf::get_default_stream() 
)

Fills a range of elements in-place in a column with a scalar value.

Fills N elements of destination starting at begin with value, where N = (end - begin).

Overwrites the range of elements in destination indicated by the indices [begin, end) with value. Use the out-of-place fill function returning std::unique_ptr<column> for use cases requiring memory reallocation.

Exceptions
cudf::logic_errorif memory reallocation is required (e.g. for variable width types).
cudf::logic_errorfor invalid range (if begin < 0, begin > end, or end > destination.size()).
cudf::logic_errorif destination and value have different types.
cudf::logic_errorif value is invalid but destination is not nullable.
Parameters
destinationThe preallocated column to fill into
beginThe starting index of the fill range (inclusive)
endThe index of the last element in the fill range (exclusive)
valueThe scalar value to fill
streamCUDA stream used for device memory operations and kernel launches

◆ repeat() [1/2]

std::unique_ptr<table> cudf::repeat ( table_view const &  input_table,
column_view const &  count,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Repeat rows of a Table.

Creates a new table by repeating the rows of input_table. The number of repetitions of each element is defined by the value at the corresponding index of count Example:

in = [4,5,6]
count = [1,2,3]
return = [4,5,5,6,6,6]

count should not have null values; should not contain negative values; and the sum of count elements should not overflow the size_type's limit. The behavior of this function is undefined if count has negative values or the sum overflows.

Exceptions
cudf::logic_errorif the data type of count is not size_type.
cudf::logic_errorif input_table and count have different number of rows.
cudf::logic_errorif count has null values.
Parameters
input_tableInput table
countNon-nullable column of an integral type
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned table's device memory
Returns
The result table containing the repetitions

◆ repeat() [2/2]

std::unique_ptr<table> cudf::repeat ( table_view const &  input_table,
size_type  count,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Repeat rows of a Table.

Creates a new table by repeating count times the rows of input_table. Example:

in = [4,5,6]
count = 2
return = [4,4,5,5,6,6]
Exceptions
cudf::logic_errorif count is negative.
std::overflow_errorif input_table.num_rows() * count overflows size_type.
Parameters
input_tableInput table
countNumber of repetitions
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned table's device memory
Returns
The result table containing the repetitions

◆ sequence() [1/2]

std::unique_ptr<column> cudf::sequence ( size_type  size,
scalar const &  init,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Fills a column with a sequence of value specified by an initial value and a step of 1.

Creates a new column and fills with size values starting at init and incrementing by 1, generating the sequence [ init, init+1, init+2, ... init + (size - 1)]

size = 3
init = 0
return = [0, 1, 2]
Exceptions
cudf::logic_errorif init is not numeric.
cudf::logic_errorif size is < 0.
Parameters
sizeSize of the output column
initFirst value in the sequence
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
The result column containing the generated sequence

◆ sequence() [2/2]

std::unique_ptr<column> cudf::sequence ( size_type  size,
scalar const &  init,
scalar const &  step,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Fills a column with a sequence of value specified by an initial value and a step.

Creates a new column and fills with size values starting at init and incrementing by step, generating the sequence [ init, init+step, init+2*step, ... init + (size - 1)*step]

size = 3
init = 0
step = 2
return = [0, 2, 4]
Exceptions
cudf::logic_errorif init and step are not the same type.
cudf::logic_errorif scalar types are not numeric.
cudf::logic_errorif size is < 0.
Parameters
sizeSize of the output column
initFirst value in the sequence
stepIncrement value
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
The result column containing the generated sequence