Skip to content
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

INTERNAL: add a function to generate a bkey string #326

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

ing-eoking
Copy link
Collaborator

๐Ÿ”— Related Issue

  • jam2in/arcus-works#655

โŒจ๏ธ What I did

  • bkey string์„ ์ƒ์„ฑํ•˜๋Š” ๊ณตํ†ต๋œ ๋กœ์ง์„ ํ•˜๋‚˜์˜ ํ•จ์ˆ˜๋กœ ๋„ฃ์–ด ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
    • Invalid query type์˜ ๊ฒฝ์šฐ, -1์„ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค.

@jhpark816 jhpark816 requested a review from uhm0311 December 12, 2024 03:22
@ing-eoking ing-eoking marked this pull request as draft December 12, 2024 05:13
@ing-eoking ing-eoking force-pushed the bkey branch 2 times, most recently from 82010a6 to 8a2737c Compare December 12, 2024 06:01
@jhpark816 jhpark816 requested review from namsic and removed request for uhm0311 December 12, 2024 06:35
@ing-eoking ing-eoking force-pushed the bkey branch 2 times, most recently from 562cf42 to efe58d1 Compare December 12, 2024 08:00
@ing-eoking ing-eoking marked this pull request as ready for review December 12, 2024 08:02
libmemcached/collection.cc Show resolved Hide resolved
libmemcached/collection.cc Outdated Show resolved Hide resolved
libmemcached/collection.cc Outdated Show resolved Hide resolved
@ing-eoking ing-eoking force-pushed the bkey branch 2 times, most recently from bd943db to 76b7318 Compare December 16, 2024 01:26
Copy link
Contributor

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ผ๋ถ€ ๋ฆฌ๋ทฐ

@@ -215,6 +215,59 @@ static inline bool space_separated_keys_is_supported(memcached_server_write_inst
return false;
}

static int generate_str_bkey_from_query(memcached_coll_query_st *query,
char *buffer, const int buffer_length,
bool support_range, bool *is_descending)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_descending ์ธ์ž๋ฅผ ์ œ๊ฑฐํ•ฉ์‹œ๋‹ค.

smget ๋กœ์ง์„ ๋ณด๋‹ˆ, result ๊ฐ์ฒด๋ฅผ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•œ ์šฉ๋„์ธ ๋ฐ,
์ด ๋ถ€๋ถ„์„ ๋‹ค๋ฃจ๋Š” ๋ณ„๋„ ํ•จ์ˆ˜๋ฅผ ๋‘๋Š” ๊ฒƒ์ด ๋‚˜์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋กœ, result ๊ฐ์ฒด๋ฅผ ์„ค์ •ํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ๋จผ์ € ๋ฆฌํŒฉํ† ๋งํ•ด์•ผ
ํ˜„์žฌ์˜ PR์„ ๋ฐ˜์˜ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

libmemcached/collection.cc Show resolved Hide resolved
@ing-eoking ing-eoking marked this pull request as draft December 16, 2024 07:05
Copy link
Contributor

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

libmemcached/collection.cc Show resolved Hide resolved
@jhpark816
Copy link
Contributor

jhpark816 commented Dec 26, 2024

@ing-eoking ๋ฆฌ๋ทฐํ•ด์•ผ ํ•˜๋Š” ์ƒํƒœ๊ฐ€ ๋˜๋ฉด, noti ์ฝ”๋ฉ˜ํŠธ๋ฅผ ๋‚จ๊ฒจ์ฃผ์„ธ์š”.

Copy link
Contributor

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ผ๋ถ€ ๋ฆฌ๋ทฐ

}
else if (MEMCACHED_COLL_QUERY_BOP_EXT == query->type)
write_length= generate_str_bkey_from_query(query, buffer, buffer_length, false, rc);
if (rc != MEMCACHED_SUCCESS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋ž˜์™€ ๊ฐ™์ด write_length ๊ฐ’์œผ๋กœ ์‹คํŒจ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.
๊ทธ๋ฆฌ๊ณ , ์–ด๋–ค ์˜ค๋ฅ˜๋“  ์„ค์ •ํ•ด ๋‘๋Š” ๊ฒƒ๋„ ๊ดœ์ฐฎ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

if (write_length < 0)
{
    return memcached_set_error(*ptr, rc, MEMCACHED_AT,
                               memcached_literal_param("Invalid bkey query.\n"));
}

์ฐธ๊ณ ๋กœ, ๋ฆฌํ„ด ๊ฐ’์ด rc ์˜€๋‹ค๋ฉด, ์•„๋ž˜ ํ˜•ํƒœ์˜ ์กฐ๊ฑด์ด ์ข‹์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

if (rc != MEMCACHED_SUCCESS)

Copy link
Contributor

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

bkey_str, MEMCACHED_COLL_MAX_BYTE_STRING_LENGTH);

write_length= snprintf(buffer, buffer_length, " 0x%s", bkey_str);
if (rc == MEMCACHED_INVALID_ARGUMENTS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEMCACHED_INVALID_ARGUMENTS ์˜ค๋ฅ˜๋งŒ ๋กœ๊ทธ๋ฅผ ๋‚จ๊ธธ ํ•„์š”๊ฐ€ ์žˆ๋‚˜์š”?
๋‘˜ ๋‹ค ๋‚จ๊ธฐ๊ฑฐ๋‚˜ ๋‘˜ ๋‹ค ๋‚จ๊ธฐ์ง€ ์•Š๋Š” ๊ฒƒ์ด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

Copy link
Contributor

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ถ”๊ฐ€ ๋ฆฌ๋ทฐ

libmemcached/collection.cc Show resolved Hide resolved
@jhpark816
Copy link
Contributor

jhpark816 commented Dec 27, 2024

์œ„์˜ PR (#331) ์ด merge๋œ ์ƒํƒœ์ด๋ฏ€๋กœ,
์ตœ์‹  code ๊ธฐ์ค€์œผ๋กœ rebase ํ•ด ์ฃผ์„ธ์š”.

@@ -215,6 +215,60 @@ static inline bool space_separated_keys_is_supported(memcached_server_write_inst
return false;
}

static int generate_str_bkey_from_query(memcached_coll_query_st *query,
char *buffer, const int buffer_length,
bool support_range, memcached_return_t &rc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rc pointer type ์‚ฌ์šฉํ•˜๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

char *buffer, const int buffer_length,
bool support_range, memcached_return_t *rc)
{
int write_length= -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—๋Ÿฌ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜์„ ๋•Œ๋„ rc ๊ฐ’์„ ์„ค์ •ํ•ด ์ฃผ๋Š” ๊ฒƒ์ด ๋งž์•„ ๋ณด์ž…๋‹ˆ๋‹ค.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate_str_bkey_from_query๋Š” ๋‚ด๋ถ€ ํ•จ์ˆ˜์ด๋ฉฐ, rc ๊ฐ’์ด ์ด๋ฏธ ํŠน์ •๊ฐ’์œผ๋กœ ์„ค์ •๋˜์—ˆ์Œ์„ ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.
๊ธฐ์กด์— ์„ค์ •๋œ rc ๊ฐ’์„ ๋‹ค์‹œ ์„ค์ •ํ•  ํ•„์š”๋Š” ์—†์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๋ฏธ ์„ค์ •๋œ rc ํŠน์ •๊ฐ’์€ ๋ฌด์—‡์ธ๊ฐ€์š”?

์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜๋Š”๋ฐ ๊ธฐ ์„ค์ •๋œ rc๊ฐ’์„ ๋ฎ์–ด์“ฐ๊ฒŒ ๋˜๋ฉด ๋ฌธ์ œ๊ฐ€ ์žˆ๊ณ ,
์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ๋Š” ๊ธฐ์กด rc๊ฐ’์„ ๋ฌด์‹œํ•˜๊ณ  ์ƒˆ๋กœ์šด ๊ฐ’์œผ๋กœ ๋ณ€๊ฒฝํ•ด๋„ ๋ฌธ์ œ๊ฐ€ ์—†๋Š” ๊ฒƒ์ธ๊ฐ€์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rc ๊ฐ’์„ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์ง€๋งŒ, generate_str_bkey_from_query ํ•จ์ˆ˜๋Š” ๊ฐ€์žฅ ์ดˆ๊ธฐ์— ํ˜ธ์ถœ๋˜๋Š” ํ•จ์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ฏ€๋กœ, ์ด ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋  ๋•Œ rc ๊ฐ’์€ ์ด๋ฏธ ์ดˆ๊ธฐํ™”๋˜์–ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
์—๋Ÿฌ ๋ฐœ์ƒ ์—ฌ๋ถ€๋Š” ๋ฆฌํ„ด๊ฐ’์ด -1์ธ์ง€๋ฅผ ํ†ตํ•ด ํ™•์ธํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, rc ๊ฐ’์€ ์—๋Ÿฌ์˜ ๋” ๊ตฌ์ฒด์ ์ธ ์›์ธ์„ ์ œ๊ณตํ•˜๋Š” ์šฉ๋„๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ, ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์€ ์ƒํ™ฉ์—์„œ rc ๊ฐ’์„ ๋‹ค์‹œ ์„ค์ •ํ•  ํ•„์š”๋Š” ์—†๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ write_length์™€ rc ๋‘ ๊ฐ’์„ generate_str_bkey_from_query ํ•จ์ˆ˜์˜ ๋ฆฌํ„ด๊ฐ’์œผ๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค๊ณ  ๋ณธ๋‹ค๋ฉด, ์˜คํžˆ๋ ค rc๋ฅผ ๋ฆฌํ„ดํ•˜๊ณ  write_length๋ฅผ ํฌ์ธํ„ฐ ์ธ์ž๋กœ ๋ฐ›๋Š” ๋ฐฉ์‹์ด ๋” ๊น”๋”ํ–ˆ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

rc๋ผ๋Š” ์šฉ์–ด๋Š” ํ˜ผ๋™์„ ์ผ์œผํ‚ฌ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ์ด๋ฅผ error๋ผ๋Š” ์šฉ์–ด๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ํŽธ์ด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

@jhpark816 jhpark816 merged commit e205daa into naver:develop Dec 30, 2024
1 check passed
@ing-eoking ing-eoking deleted the bkey branch December 30, 2024 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants