From 6538f86e5fb09c510d9ffe1a34dc08d56db76379 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 8 Nov 2021 10:58:46 +0800 Subject: [PATCH] more --- include/common/trequest.h | 16 ++++++++++++++++ source/dnode/vnode/impl/src/vnodeWrite.c | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/common/trequest.h b/include/common/trequest.h index d9e5bf9a92..6932122bc9 100644 --- a/include/common/trequest.h +++ b/include/common/trequest.h @@ -20,10 +20,26 @@ extern "C" { #endif +/* ------------------------ TYPES EXPOSED ------------------------ */ typedef struct SRequest SRequest; typedef struct SReqBatch SReqBatch; typedef struct SReqBatchIter SReqBatchIter; +// SRequest + +// SReqBatch + +// SReqBatchIter +void tdInitRBIter(SReqBatchIter *pIter, SReqBatch *pReqBatch); +const SRequest *tdRBIterNext(SReqBatchIter *pIter); +void tdClearRBIter(SReqBatchIter *pIter); + +/* ------------------------ TYPES DEFINITION ------------------------ */ +struct SReqBatchIter { + int iReq; + SReqBatch *pReqBatch; +}; + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/impl/src/vnodeWrite.c b/source/dnode/vnode/impl/src/vnodeWrite.c index d4acadd695..179ff42cd9 100644 --- a/source/dnode/vnode/impl/src/vnodeWrite.c +++ b/source/dnode/vnode/impl/src/vnodeWrite.c @@ -15,12 +15,36 @@ #include "vnodeDef.h" +static int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest); + int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) { /* TODO */ return 0; } int vnodeApplyWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) { + SReqBatchIter rbIter; + + tdInitRBIter(&rbIter, pReqBatch); + + for (;;) { + const SRequest *pReq = tdRBIterNext(&rbIter); + if (pReq == NULL) { + break; + } + + if (vnodeApplyWriteRequest(pVnode, pReq) < 0) { + // TODO + } + } + + tdClearRBIter(&rbIter); + + return 0; +} + +/* ------------------------ STATIC METHODS ------------------------ */ +static int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) { /* TODO */ return 0; } \ No newline at end of file