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

DOC: Modify examples for the set document #321

Merged
merged 1 commit into from
Dec 6, 2024
Merged

Conversation

ing-eoking
Copy link
Collaborator

๐Ÿ”— Related Issue

โŒจ๏ธ What I did

  • set ์•„์ดํ…œ ๊ด€๋ จ API ๋ฌธ์„œ๋ฅผ list์™€ ์œ ์‚ฌํ•œ ํ˜•์‹์œผ๋กœ ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๋‹ค์Œ PR์—์„œ๋Š” Map๊ณผ Btree API ์ˆ˜์ •์ด ์ˆœ์ฐจ์ ์œผ๋กœ ์ง„ํ–‰๋  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.
    • ์ž‘์—…์„ ๋”ฐ๋กœ ์ง„ํ–‰ํ•˜๋Š” ์ด์œ ๋Š” ๊ฐ ํƒ€์ž…๋งˆ๋‹ค ์ œ๊ณตํ•˜๋Š” API๊ฐ€ ์กฐ๊ธˆ์”ฉ ๋‹ค๋ฅด๊ณ , ์ผ๋ถ€ ๋‚ด์šฉ์€ ์•„์ง ํ™•์ธ์ด ์™„๋ฃŒ๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

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.

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

docs/05-set-API.md Show resolved Hide resolved
return -1;
}

if (piped_rc == MEMCACHED_ALL_NOT_EXIST) {
Copy link
Contributor

Choose a reason for hiding this comment

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

์ด๊ฒŒ failure์— ํ•ด๋‹น๋˜๋‚˜์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

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.

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

docs/05-set-API.md Show resolved Hide resolved
// ์กฐํšŒ ๊ฒฐ๊ณผ๋ฅผ ์‚ญ์ œํ•œ๋‹ค.
memcached_coll_result_free(result);
const char *key= "set:a_key";
size_t count= 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

์ด ๊ฐ’์„ 0์œผ๋กœ ํ•˜๋ฉด ์ „์ฒด element ์กฐํšŒ์ธ ๊ฒƒ์ด์ฃ ?
์ „์ฒด element ์กฐํšŒ๊ฐ€ ๋งž๋‹ค๋ฉด, 0์œผ๋กœ ์„ค์ •ํ•ฉ์‹œ๋‹ค.

๊ทธ๋ฆฌ๊ณ , memcached_sop_get์˜ count ์ธ์ž ์„ค๋ช…์„ ๋ณด๊ฐ•ํ•ด ์ฃผ์„ธ์š”.
key ์ธ์ž๋„ ์ถ”๊ฐ€ํ•ด ์ฃผ์‹œ๊ณ ์š”.

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.

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

docs/05-set-API.md Show resolved Hide resolved
docs/05-set-API.md Show resolved Hide resolved
for (size_t i=0; i<number_of_values; i++) {
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) {
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n",
key, values[i], results[i], memcached_strerror(memc, results[i]));
Copy link
Contributor

Choose a reason for hiding this comment

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

์ด ๊ฒฝ์šฐ์˜ results[i] ๊ฐ’์œผ๋กœ ์–ด๋–ค ๊ฐ’์ด ์žˆ๋‚˜์š”?

Copy link
Collaborator Author

@ing-eoking ing-eoking Dec 5, 2024

Choose a reason for hiding this comment

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

์—๋Ÿฌ์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’์ด ๋ชจ๋‘ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
(ex. CONNECTION_FAILURE, SERVER_ERROR ๋“ฑ๋“ฑ)

Copy link
Contributor

Choose a reason for hiding this comment

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

PIPE_ERROR ๊ฐ™์€ ๊ฒฝ์šฐ์—๋„
ํ•ญ์ƒ number_of_values ๊ฐœ์˜ result๊ฐ€ ๋‹ด๊ธฐ๋‚˜์š”?

Copy link
Contributor

Choose a reason for hiding this comment

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

์œ„์˜ ์—๋Ÿฌ ์‘๋‹ต๋„ ์žฌ ์ •๋ฆฌํ•ด ์ฃผ์‹œ๊ณ ์š”.

Copy link
Contributor

Choose a reason for hiding this comment

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

java client ์˜ˆ์‹œ์—์„œ๋Š”
get ํ•˜๊ธฐ ์ „์— insert ํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” ์ง€๋ฅผ ํ™•์ธํ•˜๊ณ  ์•Œ๋ ค์ฃผ์„ธ์š”.

Copy link
Collaborator Author

@ing-eoking ing-eoking Dec 5, 2024

Choose a reason for hiding this comment

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

PIPE_ERROR ๊ฐ™์€ ๊ฒฝ์šฐ์—๋„
ํ•ญ์ƒ number_of_values ๊ฐœ์˜ result๊ฐ€ ๋‹ด๊ธฐ๋‚˜์š”?

๋„ค ํ•ญ์ƒ number_of_values ๊ฐฏ์ˆ˜๋งŒํผ result๊ฐ€ ๋‹ด๊ธฐ๋ฉฐ, ๋งŒ์•ฝ PIPE_ERROR๋กœ ์ธํ•˜์—ฌ ์ˆ˜ํ–‰๋˜์ง€ ์•Š์€ ์ผ๋ถ€๋Š” MEMCACHED_MAXIMUM_RETURN์œผ๋กœ ์ฑ„์›Œ์ง‘๋‹ˆ๋‹ค.

์œ„์˜ ์—๋Ÿฌ ์‘๋‹ต๋„ ์žฌ ์ •๋ฆฌํ•ด ์ฃผ์‹œ๊ณ ์š”.

์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ๋ฌธ์„œ์—์„œ MEMCACHED_SOME_SUCCESS, MEMCACHED_ALL_FAILURE ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

java client ์˜ˆ์‹œ์—์„œ๋Š”
get ํ•˜๊ธฐ ์ „์— insert ํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” ์ง€๋ฅผ ํ™•์ธํ•˜๊ณ  ์•Œ๋ ค์ฃผ์„ธ์š”.

์—†์Šต๋‹ˆ๋‹ค.

String key = "Sample:Set";
int count = 10;
boolean withDelete = false;
boolean dropIfEmpty = false;

CollectionFuture<Set<Object>> future = null;

try {
    future = client.asyncSopGet(key, count, withDelete, dropIfEmpty); // (1)
} catch (IllegalStateException e) {
    // handle exception
}

if (future == null)
    return;

try {
    Set<Object> result = future.get(1000L, TimeUnit.MILLISECONDS); // (2)
    System.out.println(result);
    System.out.println(future.getOperationStatus().getResponse()); // (3)
} catch (TimeoutException e) {
    future.cancel(true);
} catch (InterruptedException e) {
    future.cancel(true);
} catch (ExecutionException e) {
    future.cancel(true);
}

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.

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

for (size_t i=0; i<number_of_values; i++) {
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) {
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n",
key, values[i], results[i], memcached_strerror(memc, results[i]));
Copy link
Contributor

Choose a reason for hiding this comment

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

PIPE_ERROR ๊ฐ™์€ ๊ฒฝ์šฐ์—๋„
ํ•ญ์ƒ number_of_values ๊ฐœ์˜ result๊ฐ€ ๋‹ด๊ธฐ๋‚˜์š”?

for (size_t i=0; i<number_of_values; i++) {
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) {
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n",
key, values[i], results[i], memcached_strerror(memc, results[i]));
Copy link
Contributor

Choose a reason for hiding this comment

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

์œ„์˜ ์—๋Ÿฌ ์‘๋‹ต๋„ ์žฌ ์ •๋ฆฌํ•ด ์ฃผ์‹œ๊ณ ์š”.

bool drop_if_empty = false;
memcached_coll_result_st result;
memcached_return_t rc;

Copy link
Contributor

Choose a reason for hiding this comment

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

result create

Copy link
Contributor

Choose a reason for hiding this comment

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

result create;

do {
  if (fail) {
      break;
  }

} while(0);

result free;

Copy link
Collaborator Author

@ing-eoking ing-eoking Dec 5, 2024

Choose a reason for hiding this comment

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

์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค. (list๋Š” ๋‹ค์Œ PR๋กœ ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.)

result์˜ ์ผ๋ถ€ ๊ฐ’์— ๋Œ€ํ•ด์„œ๋งŒ malloc์ด ์„ฑ๊ณตํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.
(์˜ˆ: values ๊ณต๊ฐ„์„ ์ƒ์„ฑํ•˜๋Š” ๋„์ค‘ ์ผ๋ถ€๋Š” ์„ฑ๊ณตํ•˜๊ณ  ์ผ๋ถ€๋Š” ์‹คํŒจํ•˜๋Š” ๊ฒฝ์šฐ, ์ด ๊ฒฝ์šฐ์—๋Š” ๋ณ„๋„์˜ ํ•ธ๋“ค๋ง ์—†์ด ๋ฐ”๋กœ ์—๋Ÿฌ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.)

for (size_t i=0; i<number_of_values; i++) {
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) {
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n",
key, values[i], results[i], memcached_strerror(memc, results[i]));
Copy link
Contributor

Choose a reason for hiding this comment

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

java client ์˜ˆ์‹œ์—์„œ๋Š”
get ํ•˜๊ธฐ ์ „์— insert ํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” ์ง€๋ฅผ ํ™•์ธํ•˜๊ณ  ์•Œ๋ ค์ฃผ์„ธ์š”.

Copy link
Collaborator Author

@ing-eoking ing-eoking left a comment

Choose a reason for hiding this comment

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

์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

bool drop_if_empty = false;
memcached_coll_result_st result;
memcached_return_t rc;

Copy link
Collaborator Author

@ing-eoking ing-eoking Dec 5, 2024

Choose a reason for hiding this comment

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

์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค. (list๋Š” ๋‹ค์Œ PR๋กœ ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.)

result์˜ ์ผ๋ถ€ ๊ฐ’์— ๋Œ€ํ•ด์„œ๋งŒ malloc์ด ์„ฑ๊ณตํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.
(์˜ˆ: values ๊ณต๊ฐ„์„ ์ƒ์„ฑํ•˜๋Š” ๋„์ค‘ ์ผ๋ถ€๋Š” ์„ฑ๊ณตํ•˜๊ณ  ์ผ๋ถ€๋Š” ์‹คํŒจํ•˜๋Š” ๊ฒฝ์šฐ, ์ด ๊ฒฝ์šฐ์—๋Š” ๋ณ„๋„์˜ ํ•ธ๋“ค๋ง ์—†์ด ๋ฐ”๋กœ ์—๋Ÿฌ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.)

for (size_t i=0; i<number_of_values; i++) {
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) {
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n",
key, values[i], results[i], memcached_strerror(memc, results[i]));
Copy link
Collaborator Author

@ing-eoking ing-eoking Dec 5, 2024

Choose a reason for hiding this comment

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

PIPE_ERROR ๊ฐ™์€ ๊ฒฝ์šฐ์—๋„
ํ•ญ์ƒ number_of_values ๊ฐœ์˜ result๊ฐ€ ๋‹ด๊ธฐ๋‚˜์š”?

๋„ค ํ•ญ์ƒ number_of_values ๊ฐฏ์ˆ˜๋งŒํผ result๊ฐ€ ๋‹ด๊ธฐ๋ฉฐ, ๋งŒ์•ฝ PIPE_ERROR๋กœ ์ธํ•˜์—ฌ ์ˆ˜ํ–‰๋˜์ง€ ์•Š์€ ์ผ๋ถ€๋Š” MEMCACHED_MAXIMUM_RETURN์œผ๋กœ ์ฑ„์›Œ์ง‘๋‹ˆ๋‹ค.

์œ„์˜ ์—๋Ÿฌ ์‘๋‹ต๋„ ์žฌ ์ •๋ฆฌํ•ด ์ฃผ์‹œ๊ณ ์š”.

์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ๋ฌธ์„œ์—์„œ MEMCACHED_SOME_SUCCESS, MEMCACHED_ALL_FAILURE ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

java client ์˜ˆ์‹œ์—์„œ๋Š”
get ํ•˜๊ธฐ ์ „์— insert ํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” ์ง€๋ฅผ ํ™•์ธํ•˜๊ณ  ์•Œ๋ ค์ฃผ์„ธ์š”.

์—†์Šต๋‹ˆ๋‹ค.

String key = "Sample:Set";
int count = 10;
boolean withDelete = false;
boolean dropIfEmpty = false;

CollectionFuture<Set<Object>> future = null;

try {
    future = client.asyncSopGet(key, count, withDelete, dropIfEmpty); // (1)
} catch (IllegalStateException e) {
    // handle exception
}

if (future == null)
    return;

try {
    Set<Object> result = future.get(1000L, TimeUnit.MILLISECONDS); // (2)
    System.out.println(result);
    System.out.println(future.getOperationStatus().getResponse()); // (3)
} catch (TimeoutException e) {
    future.cancel(true);
} catch (InterruptedException e) {
    future.cancel(true);
} catch (ExecutionException e) {
    future.cancel(true);
}

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.

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

// ์กฐํšŒ ๊ฒฐ๊ณผ๋ฅผ ์‚ญ์ œํ•œ๋‹ค.
memcached_coll_result_free(result);
memcached_coll_result_free(&result);
return return_value;
Copy link
Contributor

Choose a reason for hiding this comment

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

return_value ๋ณ€์ˆ˜๋ฅผ ๋‘์ง€ ์•Š๊ณ , ์•„๋ž˜์™€ ๊ฐ™์ด ์ฒ˜๋ฆฌํ•˜์‹œ์ฃ .

return (rc == MEMCACHED_SUCCESS) ? 0 : -1;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

const char* value= memcached_coll_result_get_value(&result, i);
fprintf(stdout, "memcached_sop_get: %s : %s\n", key, value);
}
} while(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

while(0) ๋‹ค์Œ์— ;(์ฝœ๋ก )์„ ์ถ”๊ฐ€ํ•ฉ์‹œ๋‹ค.

Copy link
Collaborator Author

@ing-eoking ing-eoking left a comment

Choose a reason for hiding this comment

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

์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

// ์กฐํšŒ ๊ฒฐ๊ณผ๋ฅผ ์‚ญ์ œํ•œ๋‹ค.
memcached_coll_result_free(result);
memcached_coll_result_free(&result);
return return_value;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

@jhpark816 jhpark816 merged commit 1504516 into naver:develop Dec 6, 2024
1 check passed
@ing-eoking ing-eoking deleted the set branch December 6, 2024 01:55
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.

2 participants