Skip to content

Commit

Permalink
Refactor: more exprssion helper function
Browse files Browse the repository at this point in the history
Signed-off-by: Ziy1-Tan <[email protected]>
  • Loading branch information
Ziy1-Tan committed Jul 4, 2023
1 parent 8911968 commit 9a090dd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
40 changes: 36 additions & 4 deletions cpp/include/gar/utils/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,53 @@ inline Expression* Expression::Make(const Property& p1, const Property& p2) {
return new OpType(new ExpressionProperty(p1), new ExpressionProperty(p2));
}

static inline Expression* Not(Expression* expr) {
static inline Expression* _Property(const Property& property) {
return new ExpressionProperty(property);
}

static inline Expression* _Property(const std::string& name) {
return new ExpressionProperty(Property(name));
}

template <typename T>
static inline Expression* _Literal(T value) {
return new ExpressionLiteral<T>(value);
}

static inline Expression* _Not(Expression* expr) {
return new OperatorNot(expr);
}

static inline Expression* IsNull(Expression* expr, bool nan_is_null = false) {
static inline Expression* _IsNull(Expression* expr, bool nan_is_null = false) {
return new OperatorIsNull(expr, nan_is_null);
}

static inline Expression* And(Expression* lhs, Expression* rhs) {
static inline Expression* _And(Expression* lhs, Expression* rhs) {
return new OperatorAnd(lhs, rhs);
}

static inline Expression* Or(Expression* lhs, Expression* rhs) {
static inline Expression* _Or(Expression* lhs, Expression* rhs) {
return new OperatorOr(lhs, rhs);
}

static inline Expression* _Equal(Expression* lhs, Expression* rhs) {
return new Equal(lhs, rhs);
}
static inline Expression* _NotEqual(Expression* lhs, Expression* rhs) {
return new NotEqual(lhs, rhs);
}
static inline Expression* _GreaterThan(Expression* lhs, Expression* rhs) {
return new GreaterThan(lhs, rhs);
}
static inline Expression* _GreaterEqual(Expression* lhs, Expression* rhs) {
return new GreaterEqual(lhs, rhs);
}
static inline Expression* _LessThan(Expression* lhs, Expression* rhs) {
return new LessThan(lhs, rhs);
}
static inline Expression* _LessEqual(Expression* lhs, Expression* rhs) {
return new LessEqual(lhs, rhs);
}

} // namespace GAR_NAMESPACE_INTERNAL
#endif // GAR_UTILS_EXPRESSION_H_
2 changes: 1 addition & 1 deletion cpp/test/test_arrow_chunk_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ TEST_CASE("test_adj_list_property_pushdown") {

auto expr1 = Expression::Make<LessThan>("2012-06-02T04:30:44.526+0000", prop);
auto expr2 = Expression::Make<Equal>(prop, prop);
auto filter = And(expr1, expr2);
auto filter = _And(expr1, expr2);
auto defer = std::unique_ptr<Expression>(filter);

std::vector<std::string> expected_cols{"creationDate"};
Expand Down

0 comments on commit 9a090dd

Please sign in to comment.