CMPT 454 Project Milestone

CMPT 454 Project Milestone 1: Buffer Pool
Total marks: Total marks: 100
Overall percentage: Overall percentage: 16%
Due:: Jun 11 (23:59)
In this project milestone, you are going to implement a buffer manager discussed in the class. You should use C++11 to Qnish this
project. If you use more recent C++ standards (e.g., C++17), make sure to update the required standard in CMakeLists.txt. See
Tutorial 2 for a quick overview of C++11 features. If your code (as a result of using more recent C++ standards) requires a speciQc
version of GCC/Clang, please document it in your submission and make corresponding changes in your CMakeLists.txt Qle. You are
not allowed to use external libraries other than standard C++ library. All code must run on a Linux machine. We will grade your code
on a Linux machine.
Note: It is very important that you are familiar with the provided codebase to be able to Qnish the required tasks (described later).
Make sure you understand the following two sections before attempting the problems in Section 3. Also check out Tutorial 1 for
basic information on project architecture and building and working on the project code.
1. Setting up the Base Code
We have prepared the basic code skeleton for you to start with. Assuming you have set up your repo as in Project Milestone 0,
issue the following commands to get it in your code repo:
$ git fetch --all
$ git merge base/master --allow-unrelated-histories
1.1 Code Structure
Now you should see a new yase_internal.h header Qle and a BufferManager directory in which there are multiple header (.h)
and source (.cc) Qles:
buffer_manager.{h,cc}: buffer manager implementation, including page frame management, replacement algorithm.
table.{h,cc}: user-visible table abstraction. The test progam uses structures deQned and implemented in these Qles to
manipulate data.
file.{h,cc}: implements storage Qles that hold data for tables. Each table corresponds to a Qle.
page.{h,cc}: data and directory page abstractions.
1.2 Building the Code
Dependencies: Dependencies: The code depends on the glog, g_ags, gtest libraries for logging, handling command-line parameters and testing,

代写CMPT 454作业、代做Buffer Pool作业、代写C++编程语言作业、代做C++实验作业
and CMake for conQguring and building. You will need to have these libraries installed in your system (or build your own). If you are
using CSIL server, then all these packages should have already been installed. Each Linux distribution has its own package
manager so you will need to Qnd out yourself. Below are guidelines for Arch Linux and Ubuntu.
For Arch Linux users: The following command will get you all set directly: $sudo pacman -S cmake gtest gflags googleglog.
Proceed to the "Building the code" section.
For Ubuntu users: To install these libraries in your own Ubuntu system, issue the following commands:
$ sudo apt-get install cmake
$ sudo apt-get install libgoogle-glog-dev libgflags-dev libgtest-dev // Note the ‘dev‘ suffix
To use gtest on Ubuntu, you need to do some extra work to build gtest by yourself as the gtest packages in Ubuntu only give source
code stored under /usr/src/gtest. To do so, follow the steps below:
$ mkdir ~/gtest && cd ~/gtest // Create a gtest folder in your own directory
$ cd gtest
$ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=on /usr/src/gtest // Build a shared library
$ make -jN // Replace N with the number of threads you‘d like to use for compiling
Then issue sudo make install if you are using your own machine. If you are using CSIL machine, you may skip this step, and
change your top-level CMakeLists.txt to include the library install path using -L/home/[username]/gtest when linking with
gtest (i.e., tell the compiler where to Qnd libgtest.so). This can be done by adding the following to the top-level CMakeLists.txt:
link_directories("/home/[username]/gtest"). Finally, in some environments you may need to also add -lpthread to your
CMakeLists.txt (e.g., by adding a new line link_libraries("-lpthread -pthread").
Building the code: Building the code:Once you have all the dependencies set up, use the following commands to build the project:
$ mkdir build && cd build // Create a separate directory to build the project
$ cmake -DCMAKE_BUILD_TYPE=[Debug/Release/RelWithDebInfo] ..
$ make -jN
2. YASE Architecture
We design YASE to be a row-store that is capable of storing Qxed-length records (size can be speciQed by the user) using slotted
pages. Free and occupied pages are tracked by directory pages. Each table is backed by a single Qle that stores both directory and
data pages.
Supported operations: Supported operations: Insert, delete, read, and update a record. The BufferManager/table.{h,cc} Qles deQne these uservisible
interfaces. The insert operation will return the record ID (RID) of the inserted record, the other operations require an RID as
the input and returns true if the operation succeeded. RID and page ID are deQned in yase_internal.h.
Table and Space Management: Table and Space Management: Each table is backed by a Qle (represented by the File structure deQned in file.{h,cc}). We
use directory pages to manage pages in the table. Upon initialization, the user speciQes the maximum amount of data that can be
stored by the table (see Table‘s constructor in table.h). Since the maximum size of a Qle is known, the number of directory
pages is also Qxed. In each Qle, we store all directory pages in the beginning of the Qle, and each directory entry includes two Qelds:
free_slots and allocated, which represents the number of free slots in the corresponding data page and whether the data
page was allocated.
Data Page: Data Page: Data pages follow the bit array design where at the end of the page is a header area that includes (1) record count and
(2) a bit array (one bit per slot to indicate whether the slot is vacant). Data records are stored one after another starting from the
beginning of the page. To delete a record, we simply reset the slot‘s bit in the bit array to 0 and decrement record count, then
increment the free_slots Qeld in the corresponding directory page.
Page, File, Record IDs: Page, File, Record IDs: RIDs are 8-byte integers subdivided into three parts (Qle ID, page ID and slot ID) occupying different parts
of the 8-byte (64 bits). The Qle ID indicates which Qle (table) this record belongs to; the page ID indicates which page inside the Qle
stores the record; the slot ID indicates the slot in the page storing the record. File IDs are 16-bit integers, while both page and slot
IDs are 24-bit long. Detailed deQnitions for PageID and RID can be found in yase_internal.h. An important note is that page IDs
are local to Qles, i.e., page IDs run from 0 to maximum for each different Qle ID. Similarly, slot IDs are page-local, running from 0 to
maximum for each different page.
3. Tasks
There are three tasks in this project milestone. Storage-level functionality (insert/delete/read/update) are already provided in the
base code. You will need to Qnish the missing buffer pool functionality based on the given code. Since the code is missing in
functionality, buffer_manager_test will not pass until you correctly implement the required components.
3.1. Task 1 - Buffer Pool Structure [40 marks]
The buffer pool is deQned by the BufferManager class in buffer_manager.h. First, Qnish the constructor function to initialize
the buffer pool with an array of page frames (described by the Page structure). Detailed steps are provided in the code. Also Qnish
the destructor function to free the page frames allocated upon class destruction.
Next, follow the approach discussed in class (slide 5 of Storage Management - Part 2), set up a PageID - Page Frame mapping.
Note that PageIDs are local to each Qle. Your buffer manager should support multiple tables. That is, you should setup another
FileID - File object mapping in order to be able to process pages belonging to different table.
Hint: For both mappings, you may use std::map or std::unorderd_map. An example is included in the code at lines 83-87 of
buffer_manager.h
Next, implement the PinPage and UnpinPage functions that pins and unpins a page with a given page ID. PinPage is used by the
Table and File classes to load a page in the buffer pool in order to modify (e.g., insert record) it. PinPage‘s signature is Page
*PinPage(PageID page_id, bool new_page = false);. The return value (Page *)is a page frame that contains a page
backed by storage.
The UnpinPage function is as simple as just decrementing the pin count in the Page structure provided.
Check the buffer_manager.{h,cc} for details. You are free to modify the buffer manager code (including removing/replacing
variable/function deQnitions), but you are not allowed to change the insert/delete/read/update interfaces exported by table.h.
3.2. Task 2 - LRU Replacement Algorithm [40 marks]
Your PinPage function should use LRU to evict a page when needed. You are free to use different approaches to implement LRU.
One way is to follow the approach that is discussed in class, by using a queue of unpinned pages. A page frame (i.e., Page*) is
added to the tail of the queue when its pin count is zero. The head page on the queue will be the candidate for eviction. When
eviting a page, make sure to properly _ush the page back back using File::FlushPage.
3.3. Task 3 - Testing Your Code [20 marks]
Under the Tests directory a new test program (buffer_manager_test.cc) is given to get you started on testing your code. You
task here is to add one more test case that covers more than one table. You may follow the similar structure and operations of the
existing test, but modify it to use two different tables.
We will test your code using more complex cases so you are encouraged to use this code as a starting point and vary as many
parameters as possible to test your code.
4. Submission
You need to do two things to submit your solution:
Add a CONTRIBUTIONS Qle that documents each group member‘s contribution to your solution. If you are doing the project
alone, you may just indicate this in the CONTRIBUTIONS Qle.
Check in (commit and push!) your code and the CONTRIBUTIONS Qle to your project repo by the deadline.
There is no need to submit anything to CourSys (grades will be posted there, though). Make sure you are familiar with the course
policies. Especially, we do not accept late submissions or submissions by means other than speciQed here. You can get partial
marks for coding style if your code does not compile. You can (and should) also continue to work on your solutions throughout the
semester to possibly get bonus marks in the end of the semester. Sample solutions will not be provided for course project.

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]

微信:codinghelp

原文地址:https://www.cnblogs.com/cibc/p/11011512.html

时间: 2024-10-18 09:54:22

CMPT 454 Project Milestone的相关文章

Team Foundation Server 2013 with Update 3 Install LOG

[Info   @10:14:58.155] ====================================================================[Info   @10:14:58.163] Team Foundation Server Administration Log[Info   @10:14:58.175] Version  : 12.0.30723.0[Info   @10:14:58.175] DateTime : 10/03/2014 18:1

大话软件测试

大话软件测试(不扭曲,不变形,不晦涩,不忽悠,明晰软件测试,从哪里来,到哪里去.大鸟和小白为您洞见软件架构底层,诠释软件测试的设计哲学.) 欧立奇 何金池 等 编著   ISBN 978-7-121-24097-3 2014年9月出版 定价:45.00元 280页 16开 编辑推荐 本书用完整严密的知识体系和诙谐幽默的语言,为您在软件测试的道路上打好坚实的基础:培养读者敏锐的洞察力以及优秀的测试素养,提高自身功力,从容面对软件开发/测试. 内容提要 <大话软件测试>通过小白与大鸟的趣味情景对话

《深入理解Java7核心技术与最佳实践》读书笔记(1.1)---Project Coin介绍

OpenJDK中的Coin项目(Project Coin)的目的就是为了收集对Java语言的语法进行增强的建议.在Coin项目开始之初,曾经广泛地向社区征求提议.在短短的一个月时间内就收到将近70条提议.最后又9条提议被列入考虑之中.在这9条提议中,有6条成为Java7的一部分,剩下的2条提议会在Java8中重新考虑,还有1条提议被移到其它项目中实现.这6条被采纳提议的语法新特性涉及switch语句中使用字符串.整数字面量的改进.异常处理的优化.泛型创建简化.try-with-resources

WindowsForm如何实现类似微软project软件的甘特图?

在管理软件研发过程中,特别是涉及项目管理或者生产计划方面,都需要一款类似微软project的控件对项目下的分解任务进行图形展示(甘特图).下面介绍一下在WindowsForm下如何实现类似微软project软件的甘特图?最终的效果如下所示: 1.VS2012创建一个Windows应用程序GanttChartControl,并添加甘特图控件库,结构如下: (注:此处甘特图控件是一款开源库,源码可从网上自行下载) 2.自定义任务类和资源类,代码如下: 1 #region 自定义任务和资源类 2 //

A Guide to Creating a Quality Project Schedule

Successful projects start with a good quality project schedule. Creating a schedule is one of the first tasks you should do when given a project to manage. There is often a temptation to get on with the work and worry about the schedule later, but th

Project Management Process

Project Management ProcessDescription .......................................................................................................................................................................................1STAGE/STEP/TASK SUMMARY LIST

The &quot;Real&quot; Project Plan

"I need a project plan by tomorrow morning." As project managers, that's what we hear. But we know that what the boss usually means is that s/he wants a project schedule. There is a problem though, how can you come up with a schedule without hav

OpenCV300 CMake生成project在项目过程中的问题

2015年6一个月4日本.OpenCV官网上面给出了最新版本号OpenCV.这是:3.0.0版本号,http://opencv.org/ 使用CMake它产生VS2010project流程.我遇到了一个奇怪的问题: CMake Error at 3rdparty/ippicv/downloader.cmake:97 (message): ICV: Failed to unpack ICV package from D:/Program Files/opencv/sources/3rdparty/

(转载)解决AndroidStudio导入项目在 Building gradle project info 一直卡住

源地址http://blog.csdn.net/yyh352091626/article/details/51490976 Android Studio导入项目的时候,一直卡在Building gradle project info这一步,主要原因还是因为被墙的结果.gradle官网虽然可以访问,但是速度连蜗牛都赶不上... 解决办法主要有两种,一是直接下载gradle离线包,二是修改项目的gradle-wrapper.properties里的gradle版本为自己电脑已有的版本. 离线包下载导