2222// / \file iceberg/expression/predicate.h
2323// / Predicate interface for boolean expressions that test terms.
2424
25+ #include < concepts>
26+
2527#include " iceberg/expression/expression.h"
2628#include " iceberg/expression/term.h"
2729
2830namespace iceberg {
2931
32+ template <typename T>
33+ concept TermType = std::derived_from<T, Term>;
34+
3035// / \brief A predicate is a boolean expression that tests a term against some criteria.
3136// /
3237// / \tparam TermType The type of the term being tested
33- template <typename TermType>
38+ template <TermType T >
3439class ICEBERG_EXPORT Predicate : public Expression {
3540 public:
3641 // / \brief Create a predicate with an operation and term.
3742 // /
3843 // / \param op The operation this predicate performs
3944 // / \param term The term this predicate tests
40- Predicate (Expression::Operation op, std::shared_ptr<TermType > term);
45+ Predicate (Expression::Operation op, std::shared_ptr<T > term);
4146
4247 ~Predicate () override ;
4348
4449 Expression::Operation op () const override { return operation_; }
4550
4651 // / \brief Returns the term this predicate tests.
47- const std::shared_ptr<TermType >& term () const { return term_; }
52+ const std::shared_ptr<T >& term () const { return term_; }
4853
4954 protected:
5055 Expression::Operation operation_;
51- std::shared_ptr<TermType > term_;
56+ std::shared_ptr<T > term_;
5257};
5358
5459// / \brief Unbound predicates contain unbound terms and must be bound to a concrete schema
@@ -108,8 +113,6 @@ class ICEBERG_EXPORT BoundPredicate : public Predicate<BoundTerm>, public Bound
108113
109114 Result<Literal::Value> Evaluate (const StructLike& data) const override ;
110115
111- Result<std::vector<Literal::Value>> Evaluate (const ArrowArray& data) const override ;
112-
113116 // / \brief Test a value against this predicate.
114117 // /
115118 // / \param value The value to test
@@ -122,7 +125,7 @@ class ICEBERG_EXPORT BoundPredicate : public Predicate<BoundTerm>, public Bound
122125 // A literal predicate (compares against a literal).
123126 kLiteral ,
124127 // A set predicate (tests membership in a set).
125- kIn ,
128+ kSet ,
126129 };
127130
128131 // / \brief Returns the kind of this bound predicate.
@@ -195,7 +198,7 @@ class ICEBERG_EXPORT BoundSetPredicate : public BoundPredicate {
195198
196199 Result<bool > Test (const Literal::Value& value) const override ;
197200
198- Kind kind () const override { return Kind::kIn ; }
201+ Kind kind () const override { return Kind::kSet ; }
199202
200203 std::string ToString () const override ;
201204
0 commit comments