feat: add lru to index
This commit is contained in:
parent
ca7ca2f1e3
commit
de495eb7ec
|
@ -75,7 +75,7 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
|
||||||
|
|
||||||
if (h) {
|
if (h) {
|
||||||
SDataBlock* blk = taosLRUCacheValue(ctx->lru, h);
|
SDataBlock* blk = taosLRUCacheValue(ctx->lru, h);
|
||||||
nread = MIN(blkLeft, len);
|
nread = TMIN(blkLeft, len);
|
||||||
memcpy(buf + total, blk->buf + blkOffset, nread);
|
memcpy(buf + total, blk->buf + blkOffset, nread);
|
||||||
taosLRUCacheRelease(ctx->lru, h, false);
|
taosLRUCacheRelease(ctx->lru, h, false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -85,7 +85,7 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
|
||||||
blk->blockId = blkId;
|
blk->blockId = blkId;
|
||||||
blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize);
|
blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize);
|
||||||
assert(blk->nread <= kBlockSize);
|
assert(blk->nread <= kBlockSize);
|
||||||
nread = MIN(blkLeft, len);
|
nread = TMIN(blkLeft, len);
|
||||||
|
|
||||||
if (blk->nread < kBlockSize && blk->nread < len) {
|
if (blk->nread < kBlockSize && blk->nread < len) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue