-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathDelete.h
56 lines (45 loc) · 1.53 KB
/
Delete.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef DB_DELETE_H
#define DB_DELETE_H
#include <db/TransactionId.h>
#include <db/TupleDesc.h>
#include <db/Tuple.h>
#include <db/Operator.h>
#include <db/DbIterator.h>
namespace db {
/**
* The delete operator. Delete reads tuples from its child operator and removes
* them from the table they belong to.
*/
class Delete : public Operator {
// TODO pa3.3: add private members
protected:
/**
* Deletes tuples as they are read from the child operator. Deletes are
* processed via the buffer pool (which can be accessed via the
* Database.getBufferPool() method.
*
* @return A 1-field tuple containing the number of deleted records.
* @see Database#getBufferPool
* @see BufferPool#deleteTuple
*/
std::optional<Tuple> fetchNext() override;
public:
/**
* Constructor specifying the transaction that this delete belongs to as
* well as the child to read from.
*
* @param t
* The transaction this delete runs in
* @param child
* The child operator from which to read tuples for deletion
*/
Delete(TransactionId t, DbIterator *child);
const TupleDesc &getTupleDesc() const override;
void open() override;
void close() override;
void rewind() override;
std::vector<DbIterator *> getChildren() override;
void setChildren(std::vector<DbIterator *> children) override;
};
}
#endif