-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: add set offset command #813
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฝ๋ ํฌ๋งท ์์ฃผ๋ก 1์ฐจ ๋ฆฌ๋ทฐํฉ๋๋ค.
commit message ๋ถ๋ฅ(FEATURE:
)๋ ๋๋ฌธ์๋ก ์์ฑํ๋ฉด ์ข๊ฒ ์ต๋๋ค.
if (strcmp(tokens[read_ntokens+rest_ntokens-1].value, "delete")==0 || | ||
strcmp(tokens[read_ntokens+rest_ntokens-1].value, "drop")==0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ ํ๋ ๊น์ ์ฝ๋ ์คํ์ผ๋ ํจ๊ป ์ ๋ฆฌํด๋๋ฉด ์ข๊ฒ ์ต๋๋ค.
if (strcmp(tokens[read_ntokens+rest_ntokens-1].value, "delete")==0 || | |
strcmp(tokens[read_ntokens+rest_ntokens-1].value, "drop")==0) { | |
if (strcmp(tokens[read_ntokens+rest_ntokens-1].value, "delete") == 0 || | |
strcmp(tokens[read_ntokens+rest_ntokens-1].value, "drop") == 0) { |
@@ -288,11 +287,14 @@ static ENGINE_ERROR_CODE do_set_elem_link(set_meta_info *info, set_elem_item *el | |||
set_hash_node *node = info->root; | |||
set_elem_item *find; | |||
int hidx = -1; | |||
set_hash_node *parents[100]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100์ ๋ฌด์์ ๊ธฐ์ค์ผ๋ก ํ ํฌ๊ธฐ์ธ๊ฐ์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฝ๋์์ ํด์ ํธ๋ฆฌ์ ์ต๋ ๊น์ด์ ๋ํ ์ ๋ณด๊ฐ ์์ด์ ์ ๋นํ ๋๋ํ ๊ฐ์ผ๋ก 100์ ์ค์ ํ์ต๋๋ค.
Collection ํ๋์ ์ต๋ ํฌ๊ธฐ๊ฐ 1,000,000์ผ๋ก ์ค์ ํ ์ ์๋๋ฐ ๊ณ ๋ฅด๊ฒ ๋ถํฌ ๋๋ค๋ ๊ฐ์ ํ์ ํ ๋
ธ๋์ 1024๊ฐ์ element ๊ฐ ์ ์ฅ๋ฉ๋๋ค. ์ด๋, ํ ๋
ธ๋์๋ 16๊ฐ์ bucket์ด ์๊ธฐ ๋๋ฌธ์ ํธ๋ฆฌ์ ๊น์ด๊ฐ 10์ด๋ผ๊ณ ํ ๋ 1024*(16^10) ์ ๋ ์ ์ฅ๋ฉ๋๋ค. ์ด๋ 1,000,000๋ณด๋ค ํจ์ฌ ํฌ๊ธฐ๋ ํ๊ณ worst case๋ฅผ ๊ณ ๋ คํด์ ์ ๋นํ ํฐ ์์ธ depth ๋ฅผ 100์ผ๋ก ์ค์ ํ์ต๋๋ค.
๋ค๋ฅธ ์ฝ๋์์ ํด์ ํธ๋ฆฌ์ ๊น์ด์ ๋ํ ์ ๋ณด๊ฐ ์์ผ๋ฉด ์กฐ์ ํ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
@@ -517,8 +548,17 @@ static int do_set_elem_traverse_dfs(set_meta_info *info, set_hash_node *node, | |||
|
|||
for (hidx = 0; hidx < SET_HASHTAB_SIZE; hidx++) { | |||
if (node->hcnt[hidx] > 0) { | |||
if (offset && ((*skip_cnt + node->hcnt[hidx]) <= offset)) { | |||
(*skip_cnt) += node->hcnt[hidx]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋์์ *skip_cnt += 1;
ํ๊ณ ์๋๋ฐ, ์ฌ๊ธฐ์๋ ๊ดํธ ์์ด๋ ๋์ฃ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ค. ์์ด๋ ๋๋๋ฐ ๊ฐ๋ ์ฑ๊ณผ ํต์ผ์ฑ์ ์ํด์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
if (info->root->tot_hash_cnt == 0 && info->root->tot_elem_cnt == 0) { | ||
do_set_node_unlink(info, NULL, 0); | ||
} | ||
} | ||
return fcnt; | ||
} | ||
|
||
static uint32_t do_set_elem_get(set_meta_info *info, | ||
static uint32_t do_set_elem_get(set_meta_info *info, const uint32_t offset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offset๊ณผ count๋ ๊ฐ์ line์ ์์นํ๋๋ก ํ๋ฉด ์ข๊ฒ ์ต๋๋ค.
btree ์ฐธ๊ณ ๋ฐ๋๋๋ค.
static uint32_t do_btree_elem_get(btree_meta_info *info,
const int bkrtype, const bkey_range *bkrange,
const eflag_filter *efilter,
const uint32_t offset, const uint32_t count, const bool delete,
btree_elem_item **elem_array,
uint32_t *opcost, bool *potentialbkeytrim)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tot_elem_cnt
๋ฅผ ์์ ๋ ธ๋๊น์ง ํฌํจํ subtree์ element ๊ฐ์๋ก ๋ณ๊ฒฝํ์ต๋๋ค.
๊ธฐ์กด์๋ ํ์ฌ ๋ ธ๋์ element ๊ฐ์๋ง ์ ์ฅํ์ต๋๋ค.
tot_elem_cnt
๋ map collection์์๋ ๋์ผํ ์ด๋ฆ/๋ชฉ์ ์ผ๋ก ์ฌ์ฉํ๋ ํ๋์ธ๋ฐ,
set collection์์๋ง ๊ทธ ์๋ฏธ๊ฐ ๋ฌ๋ผ์ง๋ฉด ํผ๋์ด ์๊ธธ ์ ์์ด ๋ณด์
๋๋ค.
map collection์๋ ๋์ผํ ๋ณ๊ฒฝ์ ์ ์ฉํ๊ฑฐ๋, tot_elem_cnt
๋ณ๊ฒฝํ์ง ์๋ ๊ตฌํ ๋ฐฉ์์ด๋ฉด ์ข๊ฒ ์ต๋๋ค.
int sum_of_children = 0; | ||
for (int i = 0; i < SET_HASHTAB_SIZE; i++) { | ||
if (node->hcnt[i] == -1) { | ||
set_hash_node *child = (set_hash_node *)node->htab[i]; | ||
sum_of_children += (int)child->tot_elem_cnt; | ||
} | ||
} | ||
int local_elem_cnt = node->tot_elem_cnt - sum_of_children; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tot_elem_cnt
์ ์๋ฏธ๊ฐ ๋ณ๊ฒฝ๋๋ฉด์ ์ด์ ์ ์๋ loop๊ฐ ์ถ๊ฐ๋์์ต๋๋ค.
offset ์ธ์๋ฅผ ์ง์ ํ๋ ๊ฒฝ์ฐ๋ณด๋ค default ๊ฐ(0)์ผ๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๊ฐ ๋ ๋ง์ ๊ฒ์ด๋ฏ๋ก,
offset ๊ธฐ๋ฅ์ ์ต์ ํํ๊ธฐ ์ํด ๋ค๋ฅธ ๊ตฌํ์์ ์ถ๊ฐ ๋น์ฉ์ ์ง๋ถํ๋ ํํ๋ ํผํ์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค.
ํ์ฌ PR๊ณผ ๊ฐ์ ๊ตฌํ์ด ์๋๋ฉด offset ๊ธฐ๋ฅ์ด ํฌ๊ฒ ๋นํจ์จ์ ์ผ๋ก ๋์ํ๊ฒ ๋๋์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํ์ฌ ๊ตฌํ์ ๋
ธ๋(์๋ธํธ๋ฆฌ) ๋จ์์์๋ ์คํตํ ์ ์๋๋ก tot_elem_cnt
์ ์๋ฏธ๋ฅผ โ์๋ธํธ๋ฆฌ element ์ ์ฒด ๊ฐ์โ๋ก ๋ณ๊ฒฝํ์ต๋๋ค.
๊ทธ๋ฌ๋ค๋ณด๋ ์์ ๊ฐ์ด ํ์ฌ ๋
ธ๋์ element ๊ฐ์๋ฅผ ์์์ผ ํ๋ ์ฝ๋๊ฐ ์ถ๊ฐ๋์์ต๋๋ค.
์ด ๋๋ฌธ์ ์ถ๊ฐ ๋ฃจํ ๋น์ฉ์ด ์๊ธฐ๋๋ฐ, ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
tot_elem_cnt
๋ฅผ ์๋๋๋ก ๋๊ณ , ์ ๋ณ์tree_elem_cnt
๋ฅผ ๋ง๋ค์ด ์๋ธํธ๋ฆฌ element ๊ฐ์๋ฅผ ๊ด๋ฆฌ- ์ฅ์ : ๋ ธ๋(์๋ธํธ๋ฆฌ) ๋จ์ ์คํต ๊ฐ๋ฅ
- ๋จ์ : ์๋ก์ด ๋ณ์ ๊ด๋ฆฌ
- ๋
ธ๋ ๋จ์ ์คํต์ ํ์ง ์๊ณ ํด์ ๋ฒํท(์ฒด์ธ) ๋จ์์์๋ง ์คํต (
tot_elem_cnt
๋ฅผ ๊ทธ๋๋ก ์ ์ง)- ์ฅ์ : ์ถ๊ฐ ๋ณ์ ์์
- ๋จ์ : offset ํ์์ด ๋๋ ค์ง
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ์๊ฐ์๋ 2๋ฒ๊ณผ ๊ฐ์ด ๊ตฌํํ๋ ๊ฒ์ผ๋ก ์ถฉ๋ถํด ๋ณด์ ๋๋ค.
๋ฌผ๋ก ๋ถ๋ชจ hash_node ์์ค์์ ๊ฑด๋๋ฐ๋ ๊ฒ๋ณด๋ค๋ ๋๋ฆฌ๊ฒ ์ง๋ง,
์ต์ํ ๊ธฐ์กด์ ๋ชจ๋ ๋
ธ๋๋ฅผ ํ์ํ๋ ๊ฒ๋ณด๋ค๋ ํจ์จ์ ์ผ๋ก ๋์ํ ๊ฒ์ด๊ณ ,
์๋ง 2๋ฒ ๋ฐฉ์์์๋ ๊ธฐ์กด ๋ก์ง์ ๊ฑฐ์ ์์ ํ์ง ์๊ณ ์ต์ํ์ ์์ ์ผ๋ก offset ๊ธฐ๋ฅ ๊ตฌํ์ด ๊ฐ๋ฅํ ๊ฒ์
๋๋ค.
f1317fc
to
a5d99ee
Compare
๐ Related Issue
โจ๏ธ What I did
๊ตฌํ๋ฐฉ๋ฒ
Offset ํ์ ๋ฐฉ์
tot_elem_cnt
๋ฅผ ์์ ๋ ธ๋๊น์ง ํฌํจํ subtree์ element ๊ฐ์๋ก ๋ณ๊ฒฝํ์ต๋๋ค.Offset์ผ๋ก ํ์ ์:
tot_elem_cnt
๋ฅผ ๋ ธ๋๋ณ๋ก ์ ์งํ๊ธฐ ์ํด:node pointer
๋ฅผ ์ ์ฅํ์ฌ ์ฝ์ ์ด ์ ์์ ์ผ๋ก ์๋ํ๋ฉด ๊ฐฑ์ ํฉ๋๋ค.tot_elem_cnt
๋ฅผ ๊ฐฑ์ ํฉ๋๋ค.(tot_elem_cnt) - (์์ ๋ ธ๋๋ค์ tot_elem_cnt ํฉ)
์ผ๋ก ๊ณ์ฐํ์ฌ ์ฌ์ฉํฉ๋๋ค.์์ธ์ฒ๋ฆฌ
offset
๊ฐ์ดccnt
๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ์ผ๋ฉด NOT_FOUND_ELEMENT ์ฒ๋ฆฌํฉ๋๋ค.์ฌ์ฉ ์์