def column_select_by_boolmask(column, boolmask): """Select by a boolean mask to a column. Returns (selected_column, selected_positions) """ from cudf.dataframe.numerical import NumericalColumn assert column.null_count == 0 # We don't properly handle the boolmask yet boolbits = cudautils.compact_mask_bytes(boolmask.to_gpu_array()) indices = cudautils.arange(len(boolmask)) _, selinds = cudautils.copy_to_dense(indices, mask=boolbits) _, selvals = cudautils.copy_to_dense(column.data.to_gpu_array(), mask=boolbits) selected_values = column.replace(data=Buffer(selvals)) selected_index = Buffer(selinds) return selected_values, NumericalColumn(data=selected_index, dtype=selected_index.dtype)
def _copy_to_dense_buffer(self): data = self.data.to_gpu_array() mask = self.mask.to_gpu_array() nnz, mem = cudautils.copy_to_dense(data=data, mask=mask) return Buffer(mem, size=nnz, capacity=mem.size)