Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
GlimmerBase
DataBaseContest
Commits
cb5ca988
Commit
cb5ca988
authored
10 months ago
by
liamy
Browse files
Options
Download
Plain Diff
Merge branch 'liam_debug' into noah_debug
parents
bd0268b0
f0190dcd
main
liam_debug
noah_debug
push_branch
zyw
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
Makefile
+1
-1
Makefile
rmdb_client/main.cpp
+1
-1
rmdb_client/main.cpp
src/execution/executor_seq_scan.h
+1
-0
src/execution/executor_seq_scan.h
src/record/rm_scan.cpp
+14
-6
src/record/rm_scan.cpp
src/rmdb.cpp
+1
-1
src/rmdb.cpp
src/test/insert_test1.sql
+1
-0
src/test/insert_test1.sql
with
19 additions
and
9 deletions
+19
-9
Makefile
+
1
−
1
View file @
cb5ca988
...
...
@@ -9,7 +9,7 @@ client:
cd
rmdb_client
# rm -rf build
# mkdir build
cd
rmdb_client/build
cmake
..
&&
make
rmdb_client
-j8
&&
cd
..
&&
cd
..
cd
rmdb_client/build
&&
cmake
..
&&
make
rmdb_client
-j8
&&
cd
..
&&
cd
..
unit_test
:
cd
build
&&
cmake ..
&&
make rmdb
-j8
&&
make unit_test
-j8
...
...
This diff is collapsed.
Click to expand it.
rmdb_client/main.cpp
+
1
−
1
View file @
cb5ca988
...
...
@@ -15,7 +15,7 @@
#include
<string>
#define MAX_MEM_BUFFER_SIZE 8192
#define PORT_DEFAULT 876
5
#define PORT_DEFAULT 876
3
bool
is_exit_command
(
std
::
string
&
cmd
)
{
return
cmd
==
"exit"
||
cmd
==
"exit;"
||
cmd
==
"bye"
||
cmd
==
"bye;"
;
}
...
...
This diff is collapsed.
Click to expand it.
src/execution/executor_seq_scan.h
+
1
−
0
View file @
cb5ca988
...
...
@@ -60,6 +60,7 @@ class SeqScanExecutor : public AbstractExecutor {
// 重写父类的beginTuple函数
// 1. 生成一个RecordScan对象
scan_
=
std
::
make_unique
<
RmScan
>
(
fh_
);
// fix by liamY
}
// done by noah:重写父类函数
...
...
This diff is collapsed.
Click to expand it.
src/record/rm_scan.cpp
+
14
−
6
View file @
cb5ca988
...
...
@@ -46,8 +46,13 @@ RmScan::RmScan(const RmFileHandle *file_handle) : file_handle_(file_handle) {
// // } else {
// // rid_ = Rid{0, 0};
// // }
// fix by liamY
rid_
=
Rid
{
1
,
-
1
};
next
();
if
(
file_handle_
->
file_hdr_
.
num_pages
==
1
)
{
rid_
=
Rid
{
0
,
0
};
}
else
{
next
();
}
// }
}
...
...
@@ -70,7 +75,7 @@ void RmScan::next() {
// 说明下一条记录不在当前页面,寻找下一个页面
rid_
.
page_no
++
;
// fix by noah:页面增加之后已经越界,需要直接退出循环
if
(
is_end
()){
if
(
is_end
())
{
break
;
}
page_handle
=
file_handle_
->
fetch_page_handle
(
rid_
.
page_no
);
...
...
@@ -93,11 +98,14 @@ bool RmScan::is_end() const {
// RmPageHandle page_handle = file_handle_->fetch_page_handle(rid_.page_no);
// int next_bit =Bitmap::next_bit(true, page_handle.bitmap,
// file_handle_->file_hdr_.num_records_per_page,
// rid_.slot_no);
// fix by noah:这里只需要判断page_no >= .num_pages。因为文件头页算在num_pages中,但是不算在page_no中。如果这个条件为真就表示页号越界了。
// 原来的处理方式会导致page_no越界,而如果判断的是page_no >= num_pages-1 又会导致当前scan中的rid还是有效的,但是被判定为已经到文件末尾
// rid_.slot_no);
// fix by noah:这里只需要判断page_no >=
// .num_pages。因为文件头页算在num_pages中,但是不算在page_no中。如果这个条件为真就表示页号越界了。
// 原来的处理方式会导致page_no越界,而如果判断的是page_no >= num_pages-1
// 又会导致当前scan中的rid还是有效的,但是被判定为已经到文件末尾
// 所以这里就只能通过next函数的配合来解决这个问题。最后一次next的时候需要将ridd的page_no额外增加一次
if
(
rid_
.
page_no
>=
file_handle_
->
file_hdr_
.
num_pages
)
{
// add fix by liamY: rid_.page_no == 0 means there is no page
if
(
rid_
.
page_no
==
0
||
rid_
.
page_no
>=
file_handle_
->
file_hdr_
.
num_pages
)
{
return
true
;
}
return
false
;
...
...
This diff is collapsed.
Click to expand it.
src/rmdb.cpp
+
1
−
1
View file @
cb5ca988
...
...
@@ -24,7 +24,7 @@ See the Mulan PSL v2 for more details. */
#include
"portal.h"
#include
"analyze/analyze.h"
#define SOCK_PORT 876
5
#define SOCK_PORT 876
3
#define MAX_CONN_LIMIT 8
static
bool
should_exit
=
false
;
...
...
This diff is collapsed.
Click to expand it.
src/test/insert_test1.sql
+
1
−
0
View file @
cb5ca988
create
table
grade
(
name
char
(
20
),
id
int
,
score
float
);
select
*
from
grade
;
insert
into
grade
values
(
'Data Structure'
,
1
,
90
.
5
);
insert
into
grade
values
(
'Data Structure'
,
2
,
95
.
0
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets