Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Table class #9315

Merged
merged 8 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
stream_compaction,
string_casting,
strings,
table,
transpose,
unary,
text,
Expand Down
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/avro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ from cudf._lib.cpp.io.avro cimport (
from cudf._lib.cpp.io.types cimport table_with_metadata
from cudf._lib.cpp.types cimport size_type
from cudf._lib.io.utils cimport make_source_info
from cudf._lib.table cimport Table
from cudf._lib.utils cimport data_from_unique_ptr


Expand Down
7 changes: 5 additions & 2 deletions python/cudf/cudf/_lib/concat.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ from cudf._lib.cpp.concatenate cimport (
concatenate_tables as libcudf_concatenate_tables,
)
from cudf._lib.cpp.table.table cimport table, table_view
from cudf._lib.table cimport Table, table_view_from_table
from cudf._lib.utils cimport data_from_unique_ptr, make_column_views
from cudf._lib.utils cimport (
data_from_unique_ptr,
make_column_views,
table_view_from_table,
)

from cudf.core.buffer import Buffer

Expand Down
4 changes: 0 additions & 4 deletions python/cudf/cudf/_lib/copying.pxd
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Copyright (c) 2021, NVIDIA CORPORATION.

from cudf._lib.cpp.copying cimport packed_columns
from cudf._lib.table cimport Table


cdef class _CPackedColumns:
cdef packed_columns c_obj
cdef object column_names
cdef object column_dtypes
cdef object index_names

@staticmethod
cdef _CPackedColumns from_py_table(Table input_table, keep_index=*)
39 changes: 18 additions & 21 deletions python/cudf/cudf/_lib/copying.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ from libcpp.vector cimport vector

from rmm._lib.device_buffer cimport DeviceBuffer

import cudf
isVoid marked this conversation as resolved.
Show resolved Hide resolved
from cudf.core.buffer import Buffer

from cudf._lib.column cimport Column

from cudf._lib.scalar import as_device_scalar

from cudf._lib.scalar cimport DeviceScalar
from cudf._lib.table cimport (
Table,
table_view_from_columns,
table_view_from_table,
)
from cudf._lib.utils cimport table_view_from_columns, table_view_from_table

from cudf._lib.reduce import minmax
from cudf.core.abc import Serializable
Expand Down Expand Up @@ -147,7 +144,7 @@ def copy_range(Column input_column,


def gather(
Table source_table,
source_table,
Column gather_map,
bool keep_index=True,
bool nullify=False
Expand Down Expand Up @@ -265,7 +262,7 @@ def _reverse_column(Column source_column):
)


def _reverse_table(Table source_table):
def _reverse_table(source_table):
cdef table_view reverse_table_view = table_view_from_columns(source_table)

cdef unique_ptr[table] c_result
Expand Down Expand Up @@ -326,7 +323,7 @@ def column_allocate_like(Column input_column, size=None):
return Column.from_unique_ptr(move(c_result))


def table_empty_like(Table input_table, bool keep_index=True):
def table_empty_like(input_table, bool keep_index=True):

cdef table_view input_table_view = table_view_from_table(
input_table, not keep_index
Expand Down Expand Up @@ -375,7 +372,7 @@ def column_slice(Column input_column, object indices):
return result


def table_slice(Table input_table, object indices, bool keep_index=True):
def table_slice(input_table, object indices, bool keep_index=True):

cdef table_view input_table_view = table_view_from_table(
input_table, not keep_index
Expand Down Expand Up @@ -442,7 +439,7 @@ def column_split(Column input_column, object splits):
return result


def table_split(Table input_table, object splits, bool keep_index=True):
def table_split(input_table, object splits, bool keep_index=True):

cdef table_view input_table_view = table_view_from_table(
input_table, not keep_index
Expand Down Expand Up @@ -582,7 +579,7 @@ def copy_if_else(object lhs, object rhs, Column boolean_mask):
as_device_scalar(lhs), as_device_scalar(rhs), boolean_mask)


def _boolean_mask_scatter_table(Table input_table, Table target_table,
def _boolean_mask_scatter_table(input_table, target_table,
Column boolean_mask):

cdef table_view input_table_view = table_view_from_columns(input_table)
Expand All @@ -607,7 +604,7 @@ def _boolean_mask_scatter_table(Table input_table, Table target_table,
)


def _boolean_mask_scatter_scalar(list input_scalars, Table target_table,
def _boolean_mask_scatter_scalar(list input_scalars, target_table,
Column boolean_mask):

cdef vector[reference_wrapper[constscalar]] input_scalar_vector
Expand Down Expand Up @@ -639,10 +636,10 @@ def _boolean_mask_scatter_scalar(list input_scalars, Table target_table,

# TODO: This function is currently unused but should be used in
# ColumnBase.__setitem__, see https://github.com/rapidsai/cudf/issues/8667.
def boolean_mask_scatter(object input, Table target_table,
def boolean_mask_scatter(object input, target_table,
Column boolean_mask):

if isinstance(input, Table):
if isinstance(input, cudf.core.frame.Frame):
return _boolean_mask_scatter_table(
input,
target_table,
Expand Down Expand Up @@ -697,7 +694,7 @@ def get_element(Column input_column, size_type index):
)


def sample(Table input, size_type n,
def sample(input, size_type n,
bool replace, int64_t seed, bool keep_index=True):
cdef table_view tbl_view = table_view_from_table(input, not keep_index)
cdef cpp_copying.sample_with_replacement replacement
Expand Down Expand Up @@ -745,7 +742,7 @@ def segmented_gather(Column source_column, Column gather_map):
cdef class _CPackedColumns:

@staticmethod
cdef _CPackedColumns from_py_table(Table input_table, keep_index=True):
def from_py_table(input_table, keep_index=True):
isVoid marked this conversation as resolved.
Show resolved Hide resolved
"""
Construct a ``PackedColumns`` object from a ``cudf.DataFrame``.
"""
Expand Down Expand Up @@ -846,7 +843,7 @@ cdef class _CPackedColumns:
return p

def unpack(self):
output_table = Table(*data_from_table_view(
output_table = cudf.core.frame.Frame(*data_from_table_view(
cpp_copying.unpack(self.c_obj),
self,
self.column_names,
Expand All @@ -863,7 +860,7 @@ cdef class _CPackedColumns:

class PackedColumns(Serializable):
"""
A packed representation of a ``cudf.Table``, with all columns residing
A packed representation of a Frame, with all columns residing
in a single GPU memory buffer.
"""

Expand Down Expand Up @@ -903,14 +900,14 @@ class PackedColumns(Serializable):

def pack(input_table, keep_index=True):
"""
Pack the columns of a ``cudf.Table`` into a single GPU memory buffer.
Pack the columns of a cudf Frame into a single GPU memory buffer.
"""
return PackedColumns.from_py_table(input_table, keep_index)


def unpack(packed):
"""
Unpack the results of packing a ``cudf.Table``, returning a new
``Table`` in the process.
Unpack the results of packing a cudf Frame returning a new
cudf Frame in the process.
"""
return packed.unpack()
7 changes: 3 additions & 4 deletions python/cudf/cudf/_lib/csv.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ from cudf._lib.cpp.io.types cimport (
)
from cudf._lib.cpp.table.table_view cimport table_view
from cudf._lib.io.utils cimport make_sink_info, make_source_info
from cudf._lib.table cimport (
Table,
from cudf._lib.utils cimport (
data_from_unique_ptr,
table_view_from_columns,
table_view_from_table,
)
from cudf._lib.utils cimport data_from_unique_ptr

ctypedef int32_t underlying_type_t_compression

Expand Down Expand Up @@ -446,7 +445,7 @@ def read_csv(


cpdef write_csv(
Table table,
table,
object path_or_buf=None,
object sep=",",
object na_rep="",
Expand Down
9 changes: 4 additions & 5 deletions python/cudf/cudf/_lib/filling.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ from cudf._lib.cpp.table.table cimport table
from cudf._lib.cpp.table.table_view cimport table_view
from cudf._lib.cpp.types cimport size_type
from cudf._lib.scalar cimport DeviceScalar
from cudf._lib.table cimport Table, table_view_from_table
from cudf._lib.utils cimport data_from_unique_ptr
from cudf._lib.utils cimport data_from_unique_ptr, table_view_from_table


def fill_in_place(Column destination, int begin, int end, DeviceScalar value):
Expand Down Expand Up @@ -51,14 +50,14 @@ def fill(Column destination, int begin, int end, DeviceScalar value):
return Column.from_unique_ptr(move(c_result))


def repeat(Table inp, object count, bool check_count=False):
def repeat(inp, object count, bool check_count=False):
if isinstance(count, Column):
return _repeat_via_column(inp, count, check_count)
else:
return _repeat_via_size_type(inp, count)


def _repeat_via_column(Table inp, Column count, bool check_count):
def _repeat_via_column(inp, Column count, bool check_count):
cdef table_view c_inp = table_view_from_table(inp)
cdef column_view c_count = count.view()
cdef bool c_check_count = check_count
Expand All @@ -78,7 +77,7 @@ def _repeat_via_column(Table inp, Column count, bool check_count):
)


def _repeat_via_size_type(Table inp, size_type count):
def _repeat_via_size_type(inp, size_type count):
cdef table_view c_inp = table_view_from_table(inp)
cdef unique_ptr[table] c_result

Expand Down
24 changes: 12 additions & 12 deletions python/cudf/cudf/_lib/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import cudf

from cudf._lib.column cimport Column
from cudf._lib.scalar cimport DeviceScalar
from cudf._lib.table cimport Table, table_view_from_table
from cudf._lib.utils cimport table_view_from_table

from cudf._lib.scalar import as_device_scalar

Expand Down Expand Up @@ -66,7 +66,7 @@ cdef class GroupBy:
cdef unique_ptr[libcudf_groupby.groupby] c_obj
cdef dict __dict__

def __cinit__(self, Table keys, bool dropna=True, *args, **kwargs):
def __cinit__(self, keys, bool dropna=True, *args, **kwargs):
cdef libcudf_types.null_policy c_null_handling

if dropna:
Expand All @@ -84,11 +84,11 @@ cdef class GroupBy:
)
)

def __init__(self, Table keys, bool dropna=True):
def __init__(self, keys, bool dropna=True):
self.keys = keys
self.dropna = dropna

def groups(self, Table values):
def groups(self, values):

cdef table_view values_view = table_view_from_table(values)

Expand All @@ -112,7 +112,7 @@ cdef class GroupBy:
)
return grouped_keys, grouped_values, c_group_offsets

def aggregate_internal(self, Table values, aggregations):
def aggregate_internal(self, values, aggregations):
from cudf.core.column_accessor import ColumnAccessor
cdef vector[libcudf_groupby.aggregation_request] c_agg_requests
cdef libcudf_groupby.aggregation_request c_agg_request
Expand Down Expand Up @@ -191,7 +191,7 @@ cdef class GroupBy:
return result_data, cudf.core.index._index_from_data(
grouped_keys)

def scan_internal(self, Table values, aggregations):
def scan_internal(self, values, aggregations):
from cudf.core.column_accessor import ColumnAccessor
cdef vector[libcudf_groupby.scan_request] c_agg_requests
cdef libcudf_groupby.scan_request c_agg_request
Expand Down Expand Up @@ -270,13 +270,13 @@ cdef class GroupBy:
return result_data, cudf.core.index._index_from_data(
grouped_keys)

def aggregate(self, Table values, aggregations):
def aggregate(self, values, aggregations):
"""
Parameters
----------
values : Table
values : Frame
aggregations
A dict mapping column names in `Table` to a list of aggregations
A dict mapping column names in `Frame` to a list of aggregations
to perform on that column

Each aggregation may be specified as:
Expand All @@ -285,14 +285,14 @@ cdef class GroupBy:

Returns
-------
Table of aggregated values
Frame of aggregated values
"""
if _is_all_scan_aggregate(aggregations):
return self.scan_internal(values, aggregations)

return self.aggregate_internal(values, aggregations)

def shift(self, Table values, int periods, list fill_values):
def shift(self, values, int periods, list fill_values):
cdef table_view view = table_view_from_table(values)
cdef size_type num_col = view.num_columns()
cdef vector[size_type] offsets = vector[size_type](num_col, periods)
Expand Down Expand Up @@ -328,7 +328,7 @@ cdef class GroupBy:

return shifted, grouped_keys

def replace_nulls(self, Table values, object method):
def replace_nulls(self, values, object method):
cdef table_view val_view = table_view_from_table(values)
cdef pair[unique_ptr[table], unique_ptr[table]] c_result
cdef replace_policy policy = (
Expand Down
7 changes: 3 additions & 4 deletions python/cudf/cudf/_lib/hash.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ from cudf._lib.cpp.hash cimport hash as cpp_hash
from cudf._lib.cpp.partitioning cimport hash_partition as cpp_hash_partition
from cudf._lib.cpp.table.table cimport table
from cudf._lib.cpp.table.table_view cimport table_view
from cudf._lib.table cimport Table, table_view_from_table
from cudf._lib.utils cimport data_from_unique_ptr
from cudf._lib.utils cimport data_from_unique_ptr, table_view_from_table


def hash_partition(Table source_table, object columns_to_hash,
def hash_partition(source_table, object columns_to_hash,
int num_partitions, bool keep_index=True):
cdef vector[libcudf_types.size_type] c_columns_to_hash = columns_to_hash
cdef int c_num_partitions = num_partitions
Expand Down Expand Up @@ -55,7 +54,7 @@ def hash_partition(Table source_table, object columns_to_hash,
)


def hash(Table source_table, object initial_hash_values=None, int seed=0):
def hash(source_table, object initial_hash_values=None, int seed=0):
cdef vector[uint32_t] c_initial_hash = initial_hash_values or []
cdef table_view c_source_view = table_view_from_table(
source_table, ignore_index=True)
Expand Down
Loading