Skip to content

Commit

Permalink
Minor refactoring of methods to get the underlying column type (#3458)
Browse files Browse the repository at this point in the history
WIP for #1691
  • Loading branch information
oleksiyskononenko authored and samukweku committed Apr 28, 2023
1 parent 7158865 commit 9ecdd96
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/core/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ class Column
size_t nrows() const noexcept;
size_t na_count() const;
const dt::Type& type() const noexcept;
const dt::Type& data_type() const noexcept;
dt::LType ltype() const noexcept;
dt::SType stype() const noexcept;

// For categorical columns this method will return the stype of the data,
// the column is backed up with. For all the other column types,
// this method is equivalent to `stype()`.
// For categorical columns these methods will return the stype/type
// of the data the column is backed up with. For all the other column types,
// these methods are equivalent to `stype()`/`type()`.
dt::SType data_stype() const noexcept;
const dt::Type& data_type() const noexcept;

size_t elemsize() const noexcept;
bool is_fixedwidth() const noexcept;
Expand Down
7 changes: 5 additions & 2 deletions src/core/column/column_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,13 @@ size_t ColumnImpl::null_count() const {
return stats()->nacount();
}

const Type& ColumnImpl::data_type() const {
return type_.is_categorical()? child(0).type()
: type_;
}

SType ColumnImpl::data_stype() const {
return type_.is_categorical()? child(0).stype()
: stype();
return data_type().stype();
}


Expand Down
12 changes: 7 additions & 5 deletions src/core/column/column_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ class ColumnImpl
public:
size_t nrows() const noexcept { return nrows_; }
SType stype() const { return type_.stype(); }
SType data_stype() const;
const Type& type() const { return type_; }
const Type& data_type() const {
return type_.is_categorical()? child(0).type()
: type_;
}

// For categorical columns these methods will return the stype/type
// of the data the column is backed up with. For all the other column types,
// these methods are equivalent to `stype()`/`type()`.
SType data_stype() const;
const Type& data_type() const;

virtual bool is_virtual() const noexcept = 0;
virtual bool computationally_expensive() const { return false; }
virtual size_t memory_footprint() const noexcept = 0;
Expand Down

0 comments on commit 9ecdd96

Please sign in to comment.