From 1f7a9e6764f57d34b548ac8249b3ad8b050beea7 Mon Sep 17 00:00:00 2001 From: localvar Date: Sat, 18 Jan 2020 16:16:49 +0800 Subject: [PATCH] subscribe: minor improvement revise progress persistent file format to reduce file size. example: print out number of rows consumed --- src/client/src/tscSub.c | 4 ++-- tests/examples/c/subscribe.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 69d8fc447e..8a2c8ae44e 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -265,7 +265,7 @@ static int tscLoadSubscriptionProgress(SSub* pSub) { return 0; } int64_t uid, key; - sscanf(buf, "uid=%" SCNd64 ",progress=%" SCNd64, &uid, &key); + sscanf(buf, "%" SCNd64 ":%" SCNd64, &uid, &key); progress[i].uid = uid; progress[i].key = key; } @@ -300,7 +300,7 @@ void tscSaveSubscriptionProgress(void* sub) { for (int i = 0; i < pSub->numOfMeters; i++) { int64_t uid = pSub->progress[i].uid; TSKEY key = pSub->progress[i].key; - fprintf(fp, "uid=%" PRId64 ",progress=%" PRId64 "\n", uid, key); + fprintf(fp, "%" PRId64 ":%" PRId64 "\n", uid, key); } fclose(fp); diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c index 88ff223d7f..0bf93f6f2d 100644 --- a/tests/examples/c/subscribe.c +++ b/tests/examples/c/subscribe.c @@ -11,9 +11,10 @@ void print_result(TAOS_RES* res, int blockFetch) { TAOS_ROW row = NULL; int num_fields = taos_num_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res); + int nRows = 0; if (blockFetch) { - int nRows = taos_fetch_block(res, &row); + nRows = taos_fetch_block(res, &row); for (int i = 0; i < nRows; i++) { char temp[256]; taos_print_row(temp, row + i, fields, num_fields); @@ -24,8 +25,11 @@ void print_result(TAOS_RES* res, int blockFetch) { char temp[256]; taos_print_row(temp, row, fields, num_fields); puts(temp); + nRows++; } } + + printf("%d rows consumed.\n", nRows); } -- GitLab