Skip to content

Commit 70ffce7

Browse files
committed
Add back get_element
1 parent 9c1f4a2 commit 70ffce7

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

python/morpheus/morpheus/_lib/cudf_helpers.pyx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ from cudf._lib.column cimport Column
3535

3636
# isort: off
3737

38-
# imports needed for from_column_view_with_fix
39-
import pylibcudf as plc
40-
from pylibcudf cimport Column as plc_Column, Table as plc_Table
38+
# imports needed for get_element, which is required by from_column_view_with_fix
39+
cimport pylibcudf.libcudf.copying as cpp_copying
4140
from pylibcudf.libcudf.column.column_view cimport column_view
41+
from libcpp.memory cimport make_unique, unique_ptr
42+
from pylibcudf.libcudf.scalar.scalar cimport scalar
43+
from pylibcudf cimport Table as plc_Table, Scalar as plc_Scalar
44+
import pylibcudf as plc
45+
46+
# imports needed for from_column_view_with_fix
4247
import rmm
4348
from libc.stdint cimport uintptr_t
4449
from cudf.core.buffer import (
@@ -59,6 +64,18 @@ from cudf._lib.null_mask import bitmask_allocation_size_bytes
5964

6065
# isort: on
6166

67+
cdef get_element(column_view col_view, size_type index):
68+
69+
cdef unique_ptr[scalar] c_output
70+
with nogil:
71+
c_output = move(
72+
cpp_copying.get_element(col_view, index)
73+
)
74+
75+
plc_scalar = plc_Scalar.from_libcudf(move(c_output))
76+
return plc.interop.to_arrow(plc_scalar).to_py()
77+
78+
6279
cdef Column from_column_view_with_fix(column_view cv, object owner):
6380
"""
6481
Given a ``cudf::column_view``, constructs a ``cudf.Column`` from it,
@@ -101,13 +118,9 @@ cdef Column from_column_view_with_fix(column_view cv, object owner):
101118
if offset_child_column.size() == 0:
102119
base_nbytes = 0
103120
else:
104-
offset_child_column_owner = owner.children[offsets_column_index]
105-
plc_owner = offset_child_column_owner.to_pylibcudf(mode="read")
106-
plc_offsets_col = plc_Column.from_column_view(
107-
offset_child_column, plc_owner
108-
)
109-
plc_scalar = plc.copying.get_element(plc_offsets_col, offset_child_column.size()-1)
110-
base_nbytes = plc.interop.to_arrow(plc_scalar).as_py()
121+
chars_size = get_element(
122+
offset_child_column, offset_child_column.size()-1)
123+
base_nbytes = chars_size
111124

112125
if data_ptr:
113126
if data_owner is None:

0 commit comments

Comments
 (0)