#pragma once #include "storage/common/field.h" #include "sql/expr/tuple_cell.h" class Tuple; class Expression { public: Expression() = default; virtual ~Expression() = default; virtual RC get_value(const Tuple &tuple, TupleCell &cell) const = 0; }; class FieldExpr : public Expression { public: FieldExpr() = default; FieldExpr(const Table *table, const FieldMeta *field) : field_(table, field) {} virtual ~FieldExpr() = default; Field &field() { return field_; } const Field &field() const { return field_; } const char *table_name() const { return field_.table_name(); } const char *field_name() const { return field_.field_name(); } RC get_value(const Tuple &tuple, TupleCell &cell) const override; private: Field field_; }; class ValueExpr : public Expression { public: ValueExpr() = default; ValueExpr(const Value &value) : tuple_cell(value.type, (char *)value.data) {} virtual ~ValueExpr() = default; RC get_value(const Tuple &tuple, TupleCell & cell) const override; private: TupleCell tuple_cell; };