Skip to content

Commit 32b059b

Browse files
authored
feat: update LockRequestQueue::request_queue_ & fix typos & ensure format consistency (#576)
* feat: Add std::shared_ptr for the request_queue_ in LockManager::LockRequestQueue * fix: Fix typos & Ensure format consistency * fix: Fix typos & Ensure format consistency * feat: Change TableOid() to GetTableOid(), ensure the consistency of function names * feat: Add book keeping note to give a hint for students on PJ4, T3
1 parent 1181138 commit 32b059b

28 files changed

+59
-45
lines changed

src/include/buffer/buffer_pool_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BufferPoolManager {
3535
* @brief Creates a new BufferPoolManager.
3636
* @param pool_size the size of the buffer pool
3737
* @param disk_manager the disk manager
38-
* @param replacer_k the lookback constant k for the LRU-K replacer
38+
* @param replacer_k the LookBack constant k for the LRU-K replacer
3939
* @param log_manager the log manager (for testing only: nullptr = disable logging). Please ignore this for P1.
4040
*/
4141
BufferPoolManager(size_t pool_size, DiskManager *disk_manager, size_t replacer_k = LRUK_REPLACER_K,

src/include/buffer/lru_k_replacer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class LRUKNode {
4444
* current timestamp and the timestamp of kth previous access.
4545
*
4646
* A frame with less than k historical references is given
47-
* +inf as its backward k-distance. When multipe frames have +inf backward k-distance,
47+
* +inf as its backward k-distance. When multiple frames have +inf backward k-distance,
4848
* classical LRU algorithm is used to choose victim.
4949
*/
5050
class LRUKReplacer {

src/include/concurrency/lock_manager.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class LockManager {
6565
class LockRequestQueue {
6666
public:
6767
/** List of lock requests for the same resource (table or row) */
68-
std::list<LockRequest *> request_queue_;
68+
std::list<std::shared_ptr<LockRequest>> request_queue_;
6969
/** For notifying blocked transactions on this rid */
7070
std::condition_variable cv_;
7171
/** txn_id of an upgrading transaction (if any) */
@@ -154,8 +154,12 @@ class LockManager {
154154
* - If requested lock mode is the same as that of the lock presently held,
155155
* Lock() should return true since it already has the lock.
156156
* - If requested lock mode is different, Lock() should upgrade the lock held by the transaction.
157+
* - Basically there should be three steps to perform a lock upgrade in general
158+
* - 1. Check the precondition of upgrade
159+
* - 2. Drop the current lock, reserve the upgrade position
160+
* - 3. Wait to get the new lock granted
157161
*
158-
* A lock request being upgraded should be prioritised over other waiting lock requests on the same resource.
162+
* A lock request being upgraded should be prioritized over other waiting lock requests on the same resource.
159163
*
160164
* While upgrading, only the following transitions should be allowed:
161165
* IS -> [S, X, IX, SIX]
@@ -173,6 +177,9 @@ class LockManager {
173177
* BOOK KEEPING:
174178
* If a lock is granted to a transaction, lock manager should update its
175179
* lock sets appropriately (check transaction.h)
180+
*
181+
* You probably want to consider which type of lock to directly apply on table
182+
* when implementing executor later
176183
*/
177184

178185
/**

src/include/container/disk/hash/disk_extendible_hash_table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class DiskExtendibleHashTable {
9090
* for extendible hashing.
9191
*
9292
* @param key the key to hash
93-
* @return the downcasted 32-bit hash
93+
* @return the down-casted 32-bit hash
9494
*/
9595
inline auto Hash(KeyType key) -> uint32_t;
9696

src/include/execution/executors/aggregation_executor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,13 @@ class AggregationExecutor : public AbstractExecutor {
198198
private:
199199
/** The aggregation plan node */
200200
const AggregationPlanNode *plan_;
201+
201202
/** The child executor that produces tuples over which the aggregation is computed */
202203
std::unique_ptr<AbstractExecutor> child_executor_;
204+
203205
/** Simple aggregation hash table */
204206
// TODO(Student): Uncomment SimpleAggregationHashTable aht_;
207+
205208
/** Simple aggregation hash table iterator */
206209
// TODO(Student): Uncomment SimpleAggregationHashTable::Iterator aht_iterator_;
207210
};

src/include/execution/executors/delete_executor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class DeleteExecutor : public AbstractExecutor {
5858
private:
5959
/** The delete plan node to be executed */
6060
const DeletePlanNode *plan_;
61+
6162
/** The child executor from which RIDs for deleted tuples are pulled */
6263
std::unique_ptr<AbstractExecutor> child_executor_;
6364
};

src/include/execution/executors/limit_executor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class LimitExecutor : public AbstractExecutor {
5151
private:
5252
/** The limit plan node to be executed */
5353
const LimitPlanNode *plan_;
54+
5455
/** The child executor from which tuples are obtained */
5556
std::unique_ptr<AbstractExecutor> child_executor_;
5657
};

src/include/execution/executors/nested_index_join_executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class NestIndexJoinExecutor : public AbstractExecutor {
3434
public:
3535
/**
3636
* Creates a new nested index join executor.
37-
* @param exec_ctx the context that the hash join should be performed in
38-
* @param plan the nested index join plan node
37+
* @param exec_ctx the context that the nested index join should be performed in
38+
* @param plan the nested index join plan to be executed
3939
* @param child_executor the outer table
4040
*/
4141
NestIndexJoinExecutor(ExecutorContext *exec_ctx, const NestedIndexJoinPlanNode *plan,

src/include/execution/executors/nested_loop_join_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class NestedLoopJoinExecutor : public AbstractExecutor {
3030
/**
3131
* Construct a new NestedLoopJoinExecutor instance.
3232
* @param exec_ctx The executor context
33-
* @param plan The NestedLoop join plan to be executed
33+
* @param plan The nested loop join plan to be executed
3434
* @param left_executor The child executor that produces tuple for the left side of join
3535
* @param right_executor The child executor that produces tuple for the right side of join
3636
*/

src/include/execution/executors/topn_check_executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
namespace bustub {
2323

2424
/**
25-
* TopNCheckExecutor checks the number of items in topn executor container
25+
* TopNCheckExecutor checks the number of items in TopN executor container
2626
*/
2727
class TopNCheckExecutor : public AbstractExecutor {
2828
public:
2929
/**
3030
* Construct a new TopNCheckExecutor instance.
3131
* @param exec_ctx The executor context
3232
* @param plan The TopN plan to be executed
33-
* @param child_executor The topn child executor
33+
* @param child_executor The TopN child executor
3434
*/
3535
TopNCheckExecutor(ExecutorContext *exec_ctx, const TopNPlanNode *plan,
3636
std::unique_ptr<AbstractExecutor> &&child_executor, TopNExecutor *topn_executor);

0 commit comments

Comments
 (0)