์์ฑ 2026. 6. 12.ยท์์ 2026. 6. 12.
- ์ด๋ฒ ๊ณผ์ ์ ๋ชฉํ: ๋ค์ ๋ ๊ฐ์ง B+ tree ๊ตฌํ
- Normal B+ tree
- ๊ฐ์ ๋ฐ ์ค์ต์์ ๋ค๋ฃฌ ๊ธฐ๋ฅ์ ๊ฐ์ง B+ tree ๊ตฌํ
- Logical Deletion Applied B+ tree
- ๋ ์ฝ๋ ์ญ์ ์ฟผ๋ฆฌ ์, ์ค์ ์ญ์ ๋์ '์ญ์ ๋จ'์ผ๋ก ํ์
- ํด๋น ๋ ์ฝ๋๋ ๊ฒ์๋์ง ์์์ผ ํจ
- B+tree application ์ข
๋ฃ ์, ์ค์ ๋ ์ฝ๋ ์ญ์ ๋ฐ ๋จ์ ๋ ์ฝ๋๋ก B+tree ์ฌ๊ตฌ์ฑ
- ์ค์ ๋ ์ฝ๋ ์ญ์ ๋ฐ B+tree ์ฌ๊ตฌ์ฑ์ ์ํ ํจ์จ์ ์ธ ๋ฐฉ๋ฒ ๊ณ ์ ๋ฐ ๊ตฌํ
- B+ tree์ ๋
ธ๋ ํ๋๋ฅผ ํ ํ์ด์ง(4KB)์ ์ ์ฅํ๋ ๋ฐฉ์์ผ๋ก B+ tree ์ ์ฒด๋ฅผ ํ ํ์ผ์ ์ ์ฅ
- ํ์ผ์ Disk์ ์ ์ฅ๋๋ฏ๋ก, B+tree management ํ๋ก๊ทธ๋จ์ด ์ข
๋ฃ๋์ด๋ B+tree ๊ตฌ์กฐ์ ๋ด์ฉ ์ ์ง
- Data file์ Header Page, Internal Page, Leaf Page, Free Page ๋ฑ์ผ๋ก ๊ตฌ์ฑ๋จ (์ฌ๋ผ์ด๋ 4 ๋ค์ด์ด๊ทธ๋จ ์ฐธ์กฐ)
main.c๋ ๋ค์ ๊ธฐ๋ฅ์ ์ํํ๋๋ก ๊ตฌํ๋จ open: pathname์ ์ฌ์ฉํ์ฌ ๊ธฐ์กด data file์ ์ด๊ฑฐ๋, ์์ผ๋ฉด ์๋ก ์์ฑ. (์ดํ command ์ฒ๋ฆฌ)insert <key> <value>: 'key/value' (record)๋ฅผ data file์ ์ฌ๋ฐ๋ฅธ ์์น์ ์ฝ์
(์ค๋ณต key ๋ถ๊ฐ)find <key>: ์
๋ ฅ 'key'๋ฅผ ํฌํจํ๋ record๋ฅผ ์ฐพ์ ์ผ์นํ๋ 'value' ๋ฐํdelete <key>: ์ผ์นํ๋ record๋ฅผ ์ฐพ์ ๋ฐ๊ฒฌ ์ ์ญ์
libbpt.a ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ๋ค์ API service ์ ๊ณต int open_table (char *pathname); (์ด๋ฏธ ๊ตฌํ๋จ) - Data file ์ด๊ธฐ/์์ฑ, ์ฑ๊ณต ์ unique
table_id ๋ฐํ, ์คํจ ์ ์์ ๋ฐํ
int db_insert (int64_t key, char * value);- 'key/value' record ์ฝ์
, ์ฑ๊ณต ์ 0, ์คํจ ์ non-zero ๋ฐํ
char* db_find (int64_t key);- 'key'๋ฅผ ํฌํจํ๋ record ๊ฒ์
- (์ค๋ช
) ์ผ์น 'key' ๋ฐ๊ฒฌ ์,
ret_val์ 'value' ๋ฌธ์์ด ์ ์ฅ ํ 0 ๋ฐํ - (์ค๋ช
) ์คํจ ์ non-zero ๊ฐ ๋ฐํ
int db_delete (int64_t key);- ์ผ์น record ์ญ์ , ์ฑ๊ณต ์ 0, ์คํจ ์ non-zero ๋ฐํ
- ๋ชจ๋ update operation (
insert / delete)์ operation unit์ผ๋ก data file์ ์ ์ฉ๋์ด์ผ ํจ - ๋ค๋ฅธ ํ์์ data file๊ณผ๋ ํธํ๋์ด์ผ ํ๋ฏ๋ก data file layout ์ค์
- On-disk page size:
4096 Bytes (๊ณ ์ ) - Record (key + value) size:
128 Bytes (8B key + 120B value) (๊ณ ์ ) - Page ์ข
๋ฅ: Header, Free, Leaf, Internal
- Header Page (Offset
0-4095) - Metadata ํฌํจ
- Free page number [0-7]: ์ฒซ free page (์์ผ๋ฉด
0) - Root page number [8-15]: Root page ์์น
- Number of pages [16-23]: ์ด ํ์ด์ง ์
- Free Page
- Free page list๋ก ์ฐ๊ฒฐ (Header page๊ฐ head)
- Next Free Page Number [0-7]
- Page Header (Leaf/Internal ๊ณตํต,
128 Bytes) - (
include/bpt.h์ node structure ์ฐธ์กฐ) - Parent page number [0-7]
- Is Leaf [8-11]: (
0: Internal, 1: Leaf) - Number of keys [12-15]
- Leaf Page
- Key/value record ํฌํจ (key ์ ๋ ฌ๋จ)
- ์: k1โv1โย ,k2โv2โย ,โฆย ,k31โv31โ
- Record 128B, Page ๋น ์ต๋
31๊ฐ record (Order 32) - Page Header ๋ด [120-127]: Right Sibling Page Number (๊ฐ์ฅ ์ค๋ฅธ์ชฝ์
0)
- Internal Page
- 120B value ๋์ 8B page number (internal ๋๋ leaf) ์ ์ฅ
- Page Header ๋ด [120-127]: One More Page Number (์ถ๊ฐ page number)
- Branching factor (order) = 249 (์ต๋ 248 entries, (4096 - 128) / (8+8) = 248)
- Key ๋ฒ์ ํด์ ์: A<k1โ, k1โโคB<k2โ, โฆย ,knโโคX
db_reorganize() ํจ์ ๊ตฌํ ํ์bptree2/main.c์ switch-case ๋ฌธ 'q' case ๋ด๋ถ์์ ํธ์ถ๋จbpt.h์ ์ ์ธํ๊ณ bpt.c์ ์ ์- ํ์ํ input parameters๋ ์์ ๋กญ๊ฒ ์ ์ ๊ฐ๋ฅ
db_reorganize ํจ์์ ์ ์๋ performance์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋ฉฐ, ์คํ ์๋๊ฐ ๋น ๋ฅผ์๋ก ๋์ ์ ์ ํ๋- Logical Deletion B+ tree์ Leaf Page:
- Reserved space๋ฅผ ์ญ์ ๋ record ํ์์ ํ์ฉ ๊ฐ๋ฅ
- Page layout alignment (์ ์ฒด ํ์ด์ง ํฌ๊ธฐ, record ์์ offset ๋ฑ)์ ์ ์
- ์ ๊ณต๋ ๋งํฌ์ repository๋ฅผ ์ฌ์ฉํ์ฌ ๊ณผ์ ์ํ ํ github์ push
bptree1 ํด๋: Normal B+ tree ๊ตฌํbptree2 ํด๋: Logical deletion applied B+ tree ๊ตฌํREADME.md ํ์ผ์ ํ๋ฒ๊ณผ ์ด๋ฆ ๋ฐ๋์ ๊ธฐ์
- Github repository ์ด๋ฆ:
Assignment3_[ํ๋ฒ] - Wiki๋ LMS ๊ณผ์ ํญ์
assignment3_[ํ๋ฒ]_[์ด๋ฆ].pdf ํ์ผ๋ก ์ ์ถ - ์ ์ถ ๊ธฐํ: 2025๋
11์ 20์ผ 23์ 59๋ถ
- ์ง์ฐ ์ ์ถ ์ 3์๊ฐ๋ง๋ค ์ ์ฒด ๋์ ์์ 5% ๊ฐ์ (์: 1๋ถ~3์๊ฐ ์ง์ฐ ์ 95์ ๋ถํฐ ์์)
- ์ ์ถ ๊ธฐํ 60์๊ฐ ์ดํ ์ ์ถ ์ 0์
- Assignment 3 Quiz๋ 11์ 21์ผ ์ค์ ์์ (๋ณ๊ฒฝ ์ ๊ณต์ง)
Makefile์ ์ ๋ ์์ ๊ธ์งmain.c์ open_table ์ธ์๋ฅผ "test.db"์์ "DB[ํ๋ฒ].db"๋ก ์์ ํ์ฌ ์ ์ถmain.c์ ๋ค๋ฅธ ๋ถ๋ถ์ ์ ๋ ์์ ๊ธ์งbpt.c์ ์ ์ ํ ๋ด์ฉ์ ์ถ๊ฐ/์์ ํ์ฌ ๊ณผ์ ์ํ- ์ ๊ณต๋ Disk read/write API ํ์ฉ ๊ฐ๋ฅ
- ๊ณผ์ ์ํ์ ํ์ํ ๋ค๋ฅธ ํจ์๋ ์ง์ ์ ์ํ์ฌ ์ฌ์ฉ
- Normal B+ tree ๊ตฌํ ์ฝ๋๋ฅผ Logical Deletion Applied B+ tree์ ํ์ฉ ๊ฐ๋ฅ
- ์ ๊ณต๋ in-memory B+tree ์ฝ๋๋ฅผ ์ฐธ๊ณ
- ์ฑ์ ํ๊ฒฝ (Default Version)
gcc (Ubuntu 11.4.0-1ubuntu1~22.04.1) 11.4.0GNU Make 4.3
- Version ์ฐจ์ด๋ก ์ธํ ๋ฌธ์ ๋ ์ฑ
์์ง์ง ์์
- ๋น๋ ๋๋ ์คํ์ด ๋์ง ์์ ๊ฒฝ์ฐ 0์ ์ฒ๋ฆฌ
- ๊ณผ์ ์ํ ์ ์ต๋ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์
1MiB๋ก ์ ํ - ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ด
1MiB๋ฅผ ์ด๊ณผํ๋ ๊ฒฝ์ฐ ํฐ ๊ฐ์ ๋ถ์ฌ ๊ฐ๋ฅ
- Code
- Completeness: ๋ช
์ธ์ ์๊ตฌ ์กฐ๊ฑด์ ๋ชจ๋ ์ฌ๋ฐ๋ฅด๊ฒ ๊ตฌํ
- Defensiveness: ๋ฐ์ ๊ฐ๋ฅํ ์์ธ ์ํฉ์ ๋์ฒ
- Comment: ์ฝ๋์ ๋ฐ๋์ ์ฃผ์ ํฌํจ
- Wiki
- Design: ์๊ตฌ ์กฐ๊ฑด ๊ตฌํ ๊ณํ, ์๋ฃ๊ตฌ์กฐ, ์๊ณ ๋ฆฌ์ฆ, ์ด๋ก ์ ์ฉ ๋ฐฉ์ ์์
- Implement: ์๋กญ๊ฒ ๊ตฌํ/์์ ํ ๋ถ๋ถ์ ๋ชฉ์ ๊ณผ ๊ธฐ์กด๊ณผ์ ์ฐจ์ด์ ์์ (์ฝ๋ ๋ณต์ฌ ๊ธ์ง)
- Result: ์ ์ ๋์ ์คํ ๊ฒฐ๊ณผ ์ฒจ๋ถ ๋ฐ ๋์ ๊ณผ์ ์ค๋ช
- Trouble shooting: ๊ณผ์ ์ํ ์ค ๊ฒช์ ๋ฌธ์ ์ ํด๊ฒฐ ๊ณผ์ ์์ (๋ฏธํด๊ฒฐ ์, ๋ฌธ์ ๋ด์ฉ๊ณผ ํด๊ฒฐ ์๋ ์์ )
db_reorganize์ ๋ํ ๊ณ ์ฐฐ: db_reorganize ์ฑ๋ฅ ํฅ์์ ์ํด ๊ณ ์ํ ๋ด์ฉ ์์ธ ์์