#pragma once #include #include "storage/common/table.h" #include "storage/common/field_meta.h" class TupleCell // TODO rename to Cell { public: TupleCell() = default; TupleCell(FieldMeta *meta, char *data) : TupleCell(nullptr, meta, data) {} TupleCell(Table *table, FieldMeta *meta, char *data) : table_(table), attr_type_(meta->type()), data_(data) {} void set_table(Table *table) { this->table_ = table; } void set_type(AttrType type) { this->attr_type_ = type; } void set_data(char *data) { this->data_ = data; } void set_data(const char *data) { this->set_data(const_cast(data)); } void to_string(std::ostream &os) const; int compare(const TupleCell &other) const; private: Table *table_ = nullptr; AttrType attr_type_ = UNDEFINED; char *data_ = nullptr; // real data. no need to move to field_meta.offset };