CMU 15-445
Experiment Objective#
This experiment is a preliminary implementation of "CMU 15-445/645". It mainly tests the proficiency of using C++.
The course I took is fall20221. The relevant code can be downloaded from Release2.
This course mainly involves two aspects:
- How to set up the environment
- The use of C++
Environment Setup#
I use the development method of using a virtual machine (Ubuntu) + local computer SSH.
Install the following plugins in vscode:
C/C++
CMake
CMake Tools
Remote - SSH
First, download and unzip the required code.
wget https://github.com/cmu-db/bustub/archive/refs/tags/v20221128-2022fall.tar.gz
tar -zxvf v20221128-2022fall.tar.gz
Then, use VScode
SSH to directly enter the current directory of the remote computer.
After that, install the necessary software.
sudo build_support/packages.sh
Then, there are several options in Vscode that need to be set.
Click on the bottom
Generate
Then select Clang 12.01 x86_64-pc-linux-gnu
to start coding happily.
Debug#
There is a button next to Generate [all]
, switch it to the one you need.
The test method used is GTest
.
Just remove all DIABLE_
in the target Test file and you can start testing.
For example, in the path /test/primer/starter_trie_test.cpp
, remove all DIABLE_
, and then try to output the result. Press to debug at the breakpoints you set. Press to get the result directly.
Debug
Run result
Use of C++#
There is not much to say about this aspect.
Just grasp the usage of std::unique_ptr
.
Here are a few examples.
Traverse the nodes of the trie
auto cur_node = &this->root_; // ! Pointer to a smart pointer
auto par_node = cur_node;
while(cur_node != nullptr) {
cur_node = cur_node->get()-> GetChildNode(ch);
...
par_node = cur_node;
}
How to dynamically construct a subclass node on a parent class pointer
auto tmp_node = std::make_unique<T>(std::move(*cur_node) , value);
par_node-> get() -> InsertChildNode(ch, std::move(*tmp_node));
cur_node = par_node-> GetChildNode(ch);
Get the value in the subclass space by type casting
auto tmp_node = dynamic_cast<TrieNodeWithValue<T> *>(cur_node->get());
If you are unable to complete it because the course has ended, you can refer to my code.
Footnotes#
-
Official website of CMU 15-445/645 fall2022 https://15445.courses.cs.cmu.edu/fall2022/ ↩
-
bustub source code address https://github.com/cmu-db/bustub ↩