Skip to content

Commit cf4d08d

Browse files
committed
use FExpr_FuncUnary for isna
1 parent e28bf7c commit cf4d08d

File tree

2 files changed

+21
-67
lines changed

2 files changed

+21
-67
lines changed

src/core/expr/funary/fexpr_isna.cc

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//------------------------------------------------------------------------------
2-
// Copyright 2023 H2O.ai
2+
// Copyright 2022-2023 H2O.ai
33
//
44
// Permission is hereby granted, free of charge, to any person obtaining a
55
// copy of this software and associated documentation files (the "Software"),
@@ -19,42 +19,37 @@
1919
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2020
// IN THE SOFTWARE.
2121
//------------------------------------------------------------------------------
22-
#include "expr/funary/fexpr_isna.h"
2322
#include "column/const.h"
2423
#include "column/isna.h"
24+
#include "expr/fexpr_column.h"
2525
#include "documentation.h"
26+
#include "expr/fexpr_func_unary.h"
2627
#include "expr/eval_context.h"
27-
#include "expr/fexpr_column.h"
2828
#include "expr/workframe.h"
2929
#include "python/xargs.h"
30+
#include "stype.h"
3031
namespace dt {
3132
namespace expr {
3233

33-
FExpr_ISNA::FExpr_ISNA(ptrExpr &&arg)
34-
: arg_(std::move(arg))
35-
{}
3634

37-
std::string FExpr_ISNA::repr() const {
38-
std::string out = "isna";
39-
out += '(';
40-
out += arg_->repr();
41-
out += ')';
42-
return out;
43-
}
35+
class FExpr_ISNA : public FExpr_FuncUnary {
36+
public:
37+
using FExpr_FuncUnary::FExpr_FuncUnary;
4438

45-
Workframe FExpr_ISNA::evaluate_n(EvalContext &ctx) const {
46-
Workframe wf = arg_->evaluate_n(ctx);
4739

48-
for (size_t i = 0; i < wf.ncols(); ++i) {
49-
Column coli = wf.retrieve_column(i);
50-
bool is_void_column = coli.stype() == SType::VOID;
51-
coli = is_void_column? Const_ColumnImpl::make_bool_column(coli.nrows(), true)
52-
: Column(new Isna_ColumnImpl(std::move(coli)));
53-
wf.replace_column(i, std::move(coli));
54-
}
40+
std::string name() const override {
41+
return "isna";
42+
}
43+
44+
45+
Column evaluate1(Column&& col) const override{
46+
bool is_void_column = col.stype() == SType::VOID;
47+
col = is_void_column? Const_ColumnImpl::make_bool_column(col.nrows(), true)
48+
: Column(new Isna_ColumnImpl(std::move(col)));
49+
return std::move(col);
50+
}
51+
};
5552

56-
return wf;
57-
}
5853

5954
static py::oobj pyfn_isna(const py::XArgs &args) {
6055
auto isna = args[0].to_oobj();
@@ -68,5 +63,5 @@ DECLARE_PYFN(&pyfn_isna)
6863
->n_positional_args(1)
6964
->n_required_args(1);
7065

71-
} // namespace expr
72-
} // namespace dt
66+
67+
}} // dt::expr

src/core/expr/funary/fexpr_isna.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)