欢迎光临散文网 会员登陆 & 注册

RookieDB_SetUp

2023-02-10 14:26 作者:CodeSnake  | 我要投稿

Tips💁‍♂:本文是RookieDB项目的初始环节,我们需要配置本地的开发环节,并初步使用test任务进行某个任务修改开发测试提交的过程,同时我们将需要实现一个非常简单的bug修改。add 🛢!

1. getting-started

Logistics

后勤

This assignment is due Monday, 8/29/2022 at 11:59PM PDT (GMT-7). It is worth 0% of your overall grade, but failure to complete it may result in being administratively dropped from the class.

本作业应于星期一,2022年8月29日11:59PM PDT(GMT-7)。它占你总成绩的0%,但如果没有完成它,可能会导致你被行政上的退学。

Prerequisites

先决条件

No lectures are required to work through this assignment.

在完成这项任务时,不需要讲课。

git and GitHub

git is a version control system, that helps developers like you track different versions of your code, synchronize them across different machines, and collaborate with others. If you don't already have git on your machine you can follow the instructions here to install it.

git是一个版本控制系统,它帮助像你这样的开发者跟踪你的代码的不同版本,在不同的机器上同步它们,并与其他人协作。如果你的机器上还没有git,你可以按照说明这里来安装它。git是一个版本控制系统,它帮助像你这样的开发者跟踪你的代码的不同版本,在不同的机器上同步它们,并与其他人协作。如果你的机器上还没有git,你可以按照说明这里来安装它。

GitHub is a site which supports this system, hosting it as a service. In order to get a copies of the skeleton code to work on during the semester you'll need to create an account.

GitHub是一个支持这个系统的网站,将其作为一项服务来托管。为了获得骨架代码的副本,以便在本学期工作,你需要创建一个账户。

We will be using git and GitHub to pass out assignments in this course. If you don't know much about git, that isn't a problem: you will need to use it only in very simple ways that we will show you in order to keep up with class assignments.

我们将使用git和GitHub来传授本课程的作业。如果你对git了解不多,那也不是问题:你只需要以非常简单的方式使用它,我们会告诉你,以便跟上课堂作业。

If you'd like to use git for managing your own code versioning, there are many guides to using git online -- this is a good one.

如果你想用git来管理你自己的代码版本,网上有很多使用git的指南 -- 这是一个很好的指南。

Fetching the released code

获取已发布的代码

For each project, we will provide a GitHub Classroom link. Follow the link to create a GitHub repository with the starter code for the project you are working on. Use git clone to get a local copy of the newly created repository. For example, if your GitHub username is oski after being assigned your repo through GitHub Classroom you would run:

git clone https://github.com/cs186-student/fa22-proj0-oski

对于每个项目,我们将提供一个GitHub教室的链接。按照该链接,为你正在进行的项目创建一个带有启动代码的GitHub仓库。使用git clone来获取新创建的仓库的本地拷贝。例如,如果你的GitHub用户名是oski,在通过GitHub教室分配给你的仓库后,你可以运行。

The GitHub Classroom link for this project is provided in the project release post on Edstem.

本项目的GitHub教室链接在Edstem上的项目发布帖中提供。

Debugging Issues with GitHub Classroom

调试GitHub课堂的问题

Feel free to skip this section if you don't have any issues with GitHub Classroom. If you are having issues (i.e. the page froze or some error message appeared), first check if you have access to your repo at https://github.com/cs186-student/fa22-proj0-username, replacing username with your GitHub username. If you have access to your repo and the starter code is there, then you can proceed as usual.

如果你对GitHub教室没有任何问题,请随意跳过这一部分。如果你有问题(即页面冻结或出现一些错误信息),首先检查你是否可以访问你的 repo,地址是https://github.com/cs186-student/fa22-proj0-username,用你的GitHub用户名替换username。如果你能访问你的 repo,并且启动代码也在那里,那么你可以像往常一样继续。

404 Not Found

If you're getting a 404 not found page when trying to access your repo, make sure you've set up your repo using the GitHub Classroom link in the Project 0 release post on Edstem.

如果你在试图访问你的 repo 时得到一个 404 not found 页面,请确保你已经使用 Edstem 上项目 0 发布帖子中的 GitHub 教室链接设置了你的 repo。

If you don't have access to your repo at all after following these steps, feel free to contact the course staff on Edstem.

Setting up your local development environment

配置你的本地开发环境

You are free to use any text editor or IDE to complete the assignments, but we will build and test your code in a Docker container with Maven.

你可以自由地使用任何文本编辑器或IDE来完成作业,但我们将在Docker容器中用Maven构建和测试你的代码。

We recommend setting up a local development environment by installing Java 11 locally (the version our Docker container runs) and using an IDE such as IntelliJ. (Please make sure you have at least Intellij 2019 version, some of the issues from previous semesters are from a too old Intellij)

我们建议通过在本地安装Java 11(我们的Docker容器运行的版本)和使用IntelliJ等IDE来建立一个本地开发环境。(请确保你至少有Intellij 2019版本,前几个学期的一些问题是由太老的Intellij引起的)

Java 11 downloads (or alternatively, you're free to use OpenJDK)

Java 11下载 (或者,你可以自由使用OpenJDK)

To import the project into IntelliJ, click Open, and select the pom.xml file when importing. pom.xml is what stores the configuration and dependencies you need for the project. Once it is scanned, Maven will use the information in it to build the project for you!

要把项目导入IntelliJ,请点击打开,导入时选择pom.xml文件。pom.xml是存储项目所需配置和依赖关系的文件。一旦扫描到该文件,Maven就会使用其中的信息为你构建该项目。

After hitting Open, navigate to the pom.xml file, open it, and then select "Open as Project"

If launching IntelliJ takes you to an existing workspace instead of showing you the popup above you can open the project by navigating to File -> New -> Project From Existing Sources and then select the pom.xml file and click "OK". "Trust" the project if you are prompted.

如果启动 IntelliJ 会把你带到一个现有的工作区,而不是显示上面的弹出窗口,你可以通过导航到文件 -> 新建 -> 从现有资源中的项目,然后选择 pom.xml 文件并点击 "确定 "来打开该项目。如果有提示,请 "信任 "该项目。

If you previously had used other versions of Java to build project, you can change to Java 11 by File -> Project Structure... -> Change Project SDK to the one you want to use.

如果你以前使用其他版本的Java来构建项目,你可以通过文件->项目结构...改变为Java 11。-> 改变项目SDK到你想使用的版本。

Running tests in IntelliJ

在IntelliJ中运行tests

If you are using IntelliJ and wish to run the tests for a given assignment follow the instructions below.

  1. Navigate to one of the test files for the project. For example, for Project 2 navigate to src/java/test/.../index/TestBPlusNode.java.

  2. Navigate to one of the tests (as shown below). Click on the green arrow and run the test (it should fail).

如果你使用IntelliJ,并希望为一个特定的任务运行测试,请按照下面的说明进行。

  1. 导航到项目的一个测试文件。例如,对于项目2,导航到 src/java/test/.../index/TestBPlusNode.java.&#x20。

  2. 导航到其中一个测试(如下图所示)。点击绿色箭头并运行测试(应该会失败)。

If the green arrow does not appear or you're unable to run the test, follow the steps below.

  1. Open up Run/Debug Configurations with Run > Edit Configurations.

  2. Click the + button in the top left to create a new configuration, and choose JUnit from the dropdown. Fill in the configurations as shown below and click ok. Make sure to click Modify Options > Search for tests > In whole project.

Your interface may look different depending on your version of IntelliJ.

如果绿色箭头没有出现或者你无法运行测试,请按照以下步骤操作。

  1. 用Run > Edit Configurations打开Run/Debug Configurations。

  2. 点击左上角的+按钮,创建一个新的配置,并从下拉菜单中选择JUnit。如下图所示填写配置,然后点击确定。确保点击修改选项>搜索测试>在整个项目中。

You should now see Project 2 tests in the dropdown in the top right. You can run/debug this configuration to run all the Project 2 tests.

现在你应该在右上方的下拉菜单中看到项目2的测试。你可以运行/调试这个配置来运行所有项目2的测试。

image-20230102174601432

If for some reason you still cannot run the tests, it's likely that you had one of the steps above wrong. At this time, the best thing to do is to re-clone the project and go through the setting up again. Some students may try re-importing the pom.xml file, but there could be some configuration being polluted, so the safest option is to re-clone the project and import the pom.xml file again.

如果由于某种原因,你仍然不能运行测试,很可能是你在上面的某个步骤中出了问题。这时,最好的办法是重新克隆项目并重新进行设置。有些学生可能会尝试重新导入pom.xml文件,但可能有一些配置被污染了,所以最安全的选择是重新克隆项目并再次导入pom.xml文件。

Once you have a copy of the released code, head to the next section "Your Tasks" and begin working on the assignment.

一旦你有了一份已发布的代码,就前往下一节 "你的任务",并开始进行作业。


2.tasks

任务列表

For this assignment you will get acquainted with running RookieDB's command line interface and make a small change to one file to get things working properly.

在这个作业中,你将熟悉运行RookieDB的命令行界面,并对一个文件进行小的修改,使其正常工作。

Task 1: Running the CLI

任务1:运行命令行界面

Most databases provide a command line interface (CLI) to send and view the results of queries. To run the CLI in IntelliJ navigate to the file:

src/main/java/edu/berkeley/cs186/database/cli/CommandLineInterface

大多数数据库提供了一个命令行界面(CLI)来发送和查看查询的结果。要在IntelliJ中运行CLI,请导航到文件。

It's okay if you don't understand most of the code here right now, we just want to run it. Locate the arrow next to the class declaration click on it to start the CLI.

Note: If you see the warning

如果你现在不理解这里的大部分代码也没关系,我们只是想运行它。找到类声明旁边的箭头,点击它来启动CLI。

注意:如果你看到警告

Required type: List <edu.berkeley.cs186.database.table.Record>
Provided: List <Record>

It is because you are using a very new version of Java. If you find it concerning to see the red line in Intellij, follow the steps in the previous page to change the Java SDK

这是因为你正在使用一个非常新的Java版本。如果你发现在Intellij中看到的红线令人担忧,请按照前一页的步骤来改变Java SDK。

Click the arrow to run the CLI

This should open a new panel in IntelliJ resembling the following image:

这应该在IntelliJ中打开一个新的面板,类似于下面的图片。

Click on this panel and try typing in the following query and hitting enter:

SELECT * FROM Courses LIMIT 5;

You should get something similar to the following output:

点击这个面板,试着输入以下查询并点击回车键。

SELECT * FROM Courses LIMIT 5;

你应该得到类似于下面的输出。

Hmm, that doesn't look quite right! Follow the instructions in the next task to get the proper output. To exit the CLI just type in exit and hit enter.

嗯,这看起来不大对劲! 按照下一个任务中的指示来获得正确的输出。要退出CLI,只需键入exit并点击回车。


Task 2: Welcome to CS186!

任务2:欢迎来到CS186

Open up src/main/java/edu/berkeley/cs186/database/databox/StringDataBox.java. It's okay if you do not understand most of the code right now.

The toString method currently looks like:

打开 src/main/java/edu/berkeley/cs186/database/databox/StringDataBox.java。如果你现在不理解大部分的代码,也没关系。

toString方法目前看起来如下:

  


Follow the instructions in the TODO(proj0) comment to fix the return statement.

Navigate tosrc/test/java/edu/berkeley/cs186/database/databox/TestWelcome.java and try running the test in the file, which should now be passing. Now you can run through Task 1 again to see what the proper output should be.

(If you see anything highlighted in red in the test file, its likely that JUnit wasn't automatically added to the classpath. If this is the case, find the first failed import and hover over the portion marked in red. This should bring up a tooltip with the option "Add JUnit to classpath". Select this option. Afterwards, no errors should appear in the file.)

按照TODO(proj0)注释中的指示来修复返回语句。

导航到src/test/java/edu/berkeley/cs186/database/databox/TestWelcome.java并尝试运行文件中的测试,现在应该是通过的。现在你可以再次运行任务1,看看正确的输出应该是什么。

(如果你在测试文件中看到任何以红色突出显示的东西,它可能是JUnit没有自动添加到classpath中。如果是这种情况,找到第一个失败的导入,将鼠标悬停在标为红色的部分。这应该会弹出一个工具提示,上面有 "将JUnit添加到classpath "的选项。选择这个选项。之后,文件中不应该出现任何错误)。


Task 3: Debugging Exercise

任务3:调试练习

In this course, a majority of the projects are written in Java and involve modifying a large codebase. Knowing how to effectively utilize the IntelliJ debugger will be important in identifying errors with your code. Let's cover the basics of using the IntelliJ debugger!

在这个课程中,大部分项目都是用Java编写的,涉及到修改一个大型代码库。知道如何有效地利用IntelliJ调试器,对于识别代码中的错误非常重要。让我们来介绍一下使用IntelliJ调试器的基本知识吧!

As you follow along with the steps below, please submit your answers to this Gradescope assignment. You must complete this for full credit.

Let's start by navigating to src/java/test/.../index/TestBPlusNode.java.

当你按照下面的步骤进行操作时,请将你的答案提交给这个Gradescope作业。你必须完成这个任务以获得全额学分。

让我们开始浏览 src/java/test/.../index/TestBPlusNode.java.


Breakpoints

断点

Place a breakpoint as shown below. Breakpoints allow you to select locations in your code where you want the debugger to pause.

放置一个断点,如下图所示。断点允许你在代码中选择你希望调试器暂停的位置。


Running the debugger

运行调试器

Select the green arrow next to the function header for testFromBytes. In the dropdown menu, click debug. This will open a debugging console at the bottom. The code is currently paused at the line we placed a breakpoint on.

选择testFromBytes的函数标题旁边的绿色箭头。在下拉菜单中,点击debug。这将在底部打开一个调试控制台。目前,代码在我们放置断点的那一行暂停了。


Inspecting variables

检查变量

The debugger allows you to inspect relevant variables in the code

Question 1: What is the current size of 'leafKeys'?

问题1:"leafKeys "的当前大小是多少?


Step into

单步执行

Click on the button shown below to step into the LeafNode constructor.

点击下面的按钮,进入LeafNode构造函数。

Step over

step over:在单步执行时,在函数内遇到子函数时不会进入子函数内单步执行,而是将子函数整个执行完再停止,也就是把子函数整个作为一步。有一点,经过我们简单的调试,在不存在子函数的情况下是和step into效果一样的(简而言之,越过子函数,但子函数会执行)。

Click on the button shown below to step forward one line.

点击下图所示的按钮,向前走一行。

Question 2: What is the current size of 'rids'? 问题2:目前 "rids"的数量是多少?


Resume execution

恢复执行

This button allows you to resume execution of your program until it reaches another breakpoint. Don't worry if testFromBytes fails after resuming execution. You won't pass this test until project 2.

这个按钮允许你恢复程序的执行,直到它到达另一个断点。如果恢复执行后testFromBytes失败,请不要担心。在项目2之前,你不会通过这个测试。

You're done!


RookieDB_SetUp的评论 (共 条)

分享到微博请遵守国家法律