From 6e7df831ce5e383c0226961bf854412ba57aba25 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 22 Dec 2021 23:58:38 +0800 Subject: [PATCH] update tindex reader --- source/libs/index/src/index_tfile.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/libs/index/src/index_tfile.c b/source/libs/index/src/index_tfile.c index 4b38f12e1f..ecacdcd13c 100644 --- a/source/libs/index/src/index_tfile.c +++ b/source/libs/index/src/index_tfile.c @@ -386,16 +386,19 @@ static int tfileReadLoadFst(TFileReader* reader) { static int tfileReadLoadTableIds(TFileReader* reader, int32_t offset, SArray* result) { int32_t nid; WriterCtx* ctx = reader->ctx; - int32_t nread = ctx->readFrom(ctx, (char*)&nid, sizeof(nid), offset); + + int32_t nread = ctx->readFrom(ctx, (char*)&nid, sizeof(nid), offset); assert(sizeof(nid) == nread); - char* buf = calloc(1, sizeof(uint64_t) * nid); + int32_t total = sizeof(uint64_t) * nid; + char* buf = calloc(1, total); if (buf == NULL) { return -1; } - nread = ctx->read(ctx, buf, sizeof(uint64_t) * nid); - uint64_t* ids = (uint64_t*)buf; + nread = ctx->read(ctx, buf, total); + assert(total == nread); + for (int32_t i = 0; i < nid; i++) { - taosArrayPush(result, ids + i); + taosArrayPush(result, (uint64_t*)buf + i); } free(buf); return 0;