intmain(){ int *a; int c = 100; a = &c; // 通过指针构造 unique_ptr<int> up_1(newint(999)); // 通过指向类型的构造函数赋值,注意这里是数值不是指针,非常常用 unique_ptr<int> up_4 = std::make_unique<int>(10);
classSeqScanExecutor : public AbstractExecutor { public: /** * Construct a new SeqScanExecutor instance. * @param exec_ctx The executor context * @param plan The sequential scan plan to be executed */ SeqScanExecutor(ExecutorContext *exec_ctx, const SeqScanPlanNode *plan);
/** Initialize the sequential scan */ voidInit()override;
/** * Yield the next tuple from the sequential scan. * @param[out] tuple The next tuple produced by the scan * @param[out] rid The next tuple RID produced by the scan * @return `true` if a tuple was produced, `false` if there are no more tuples */ autoNext(Tuple *tuple, RID *rid) -> booloverride;
/** @return The output schema for the sequential scan */ autoGetOutputSchema()const -> const Schema & override{ return plan_->OutputSchema(); }
private: /** The sequential scan plan node to be executed */ const SeqScanPlanNode *plan_; TableIterator table_iterator_ = {nullptr, RID(), nullptr}; TableInfo *table_info_; };
classInsertExecutor : public AbstractExecutor { public: /** * Construct a new InsertExecutor instance. * @param exec_ctx The executor context * @param plan The insert plan to be executed * @param child_executor The child executor from which inserted tuples are pulled */ InsertExecutor(ExecutorContext *exec_ctx, const InsertPlanNode *plan, std::unique_ptr<AbstractExecutor> &&child_executor);
/** Initialize the insert */ voidInit()override;
/** * Yield the number of rows inserted into the table. * @param[out] tuple The integer tuple indicating the number of rows inserted into the table * @param[out] rid The next tuple RID produced by the insert (ignore, not used) * @return `true` if a tuple was produced, `false` if there are no more tuples * * NOTE: InsertExecutor::Next() does not use the `rid` out-parameter. * NOTE: InsertExecutor::Next() returns true with number of inserted rows produced only once. */ autoNext([[maybe_unused]] Tuple *tuple, RID *rid) -> booloverride;
/** @return The output schema for the insert */ autoGetOutputSchema()const -> const Schema & override{ return plan_->OutputSchema(); };
private: /** The insert plan node to be executed*/ const InsertPlanNode *plan_;
classDeleteExecutor : public AbstractExecutor { public: /** * Construct a new DeleteExecutor instance. * @param exec_ctx The executor context * @param plan The delete plan to be executed * @param child_executor The child executor that feeds the delete */ DeleteExecutor(ExecutorContext *exec_ctx, const DeletePlanNode *plan, std::unique_ptr<AbstractExecutor> &&child_executor);
/** Initialize the delete */ voidInit()override;
/** * Yield the number of rows deleted from the table. * @param[out] tuple The integer tuple indicating the number of rows deleted from the table * @param[out] rid The next tuple RID produced by the delete (ignore, not used) * @return `true` if a tuple was produced, `false` if there are no more tuples * * NOTE: DeleteExecutor::Next() does not use the `rid` out-parameter. * NOTE: DeleteExecutor::Next() returns true with the number of deleted rows produced only once. */ autoNext([[maybe_unused]] Tuple *tuple, RID *rid) -> booloverride;
/** @return The output schema for the delete */ autoGetOutputSchema()const -> const Schema & override{ return plan_->OutputSchema(); };
private: /** The delete plan node to be executed */ const DeletePlanNode *plan_; /** The child executor from which RIDs for deleted tuples are pulled */ std::unique_ptr<AbstractExecutor> child_executor_;