提交 5cee5bc4 编写于 作者: H Hongze Cheng

more code

上级 25ec924c
...@@ -3232,10 +3232,9 @@ typedef struct { ...@@ -3232,10 +3232,9 @@ typedef struct {
SArray* aCreateTbRsp; // SArray<SVCreateTbRsp> SArray* aCreateTbRsp; // SArray<SVCreateTbRsp>
} SSubmitRsp2; } SSubmitRsp2;
int32_t tCreateSSubmitRsp2(SSubmitRsp2** ppRsp);
void tDestroySSubmitRsp2(SSubmitRsp2* pRsp, int32_t flag);
int32_t tEncodeSSubmitRsp2(SEncoder* pCoder, const SSubmitRsp2* pRsp); int32_t tEncodeSSubmitRsp2(SEncoder* pCoder, const SSubmitRsp2* pRsp);
int32_t tDecodeSSubmitRsp2(SDecoder* pCoder, SSubmitRsp2* pRsp); int32_t tDecodeSSubmitRsp2(SDecoder* pCoder, SSubmitRsp2* pRsp);
void tDestroySSubmitRsp2(SSubmitRsp2* pRsp, int32_t flag);
#define TSDB_MSG_FLG_ENCODE 0x1 #define TSDB_MSG_FLG_ENCODE 0x1
#define TSDB_MSG_FLG_DECODE 0x2 #define TSDB_MSG_FLG_DECODE 0x2
......
...@@ -6835,7 +6835,8 @@ int32_t tEncodeSSubmitRsp2(SEncoder *pCoder, const SSubmitRsp2 *pRsp) { ...@@ -6835,7 +6835,8 @@ int32_t tEncodeSSubmitRsp2(SEncoder *pCoder, const SSubmitRsp2 *pRsp) {
if (tEncodeI32v(pCoder, pRsp->code) < 0) return -1; if (tEncodeI32v(pCoder, pRsp->code) < 0) return -1;
if (tEncodeI32v(pCoder, pRsp->affectedRows) < 0) return -1; if (tEncodeI32v(pCoder, pRsp->affectedRows) < 0) return -1;
if (tEncodeI32v(pCoder, taosArrayGetSize(pRsp->aCreateTbRsp)) < 0) return -1;
if (tEncodeU64v(pCoder, taosArrayGetSize(pRsp->aCreateTbRsp)) < 0) return -1;
for (int32_t i = 0; i < taosArrayGetSize(pRsp->aCreateTbRsp); ++i) { for (int32_t i = 0; i < taosArrayGetSize(pRsp->aCreateTbRsp); ++i) {
if (tEncodeSVCreateTbRsp(pCoder, taosArrayGet(pRsp->aCreateTbRsp, i)) < 0) return -1; if (tEncodeSVCreateTbRsp(pCoder, taosArrayGet(pRsp->aCreateTbRsp, i)) < 0) return -1;
} }
...@@ -6865,12 +6866,13 @@ int32_t tDecodeSSubmitRsp2(SDecoder *pCoder, SSubmitRsp2 *pRsp) { ...@@ -6865,12 +6866,13 @@ int32_t tDecodeSSubmitRsp2(SDecoder *pCoder, SSubmitRsp2 *pRsp) {
goto _exit; goto _exit;
} }
int32_t nCreateTbRsp; uint64_t nCreateTbRsp;
if (tDecodeI32v(pCoder, &nCreateTbRsp) < 0) { if (tDecodeU64v(pCoder, &nCreateTbRsp) < 0) {
code = TSDB_CODE_INVALID_MSG; code = TSDB_CODE_INVALID_MSG;
goto _exit; goto _exit;
} }
if (nCreateTbRsp) {
pRsp->aCreateTbRsp = taosArrayInit(nCreateTbRsp, sizeof(SVCreateTbRsp)); pRsp->aCreateTbRsp = taosArrayInit(nCreateTbRsp, sizeof(SVCreateTbRsp));
if (pRsp->aCreateTbRsp == NULL) { if (pRsp->aCreateTbRsp == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
...@@ -6884,6 +6886,7 @@ int32_t tDecodeSSubmitRsp2(SDecoder *pCoder, SSubmitRsp2 *pRsp) { ...@@ -6884,6 +6886,7 @@ int32_t tDecodeSSubmitRsp2(SDecoder *pCoder, SSubmitRsp2 *pRsp) {
goto _exit; goto _exit;
} }
} }
}
tEndDecode(pCoder); tEndDecode(pCoder);
...@@ -6896,37 +6899,20 @@ _exit: ...@@ -6896,37 +6899,20 @@ _exit:
return code; return code;
} }
int32_t tCreateSSubmitRsp2(SSubmitRsp2 **ppRsp) { void tDestroySSubmitRsp2(SSubmitRsp2 *pRsp, int32_t flag) {
int32_t code = 0; if (TSDB_MSG_FLG_ENCODE) {
if (pRsp->aCreateTbRsp) {
SSubmitRsp2 *pRsp = (SSubmitRsp2 *)taosMemoryCalloc(1, sizeof(*pRsp)); int32_t nCreateTbRsp = TARRAY_SIZE(pRsp->aCreateTbRsp);
if (pRsp == NULL) { SVCreateTbRsp *aCreateTbRsp = TARRAY_DATA(pRsp->aCreateTbRsp);
code = TSDB_CODE_OUT_OF_MEMORY; for (int32_t i = 0; i < nCreateTbRsp; ++i) {
goto _exit; if (aCreateTbRsp[i].pMeta) {
} taosMemoryFree(aCreateTbRsp[i].pMeta);
pRsp->aCreateTbRsp = taosArrayInit(16, sizeof(SVCreateTbRsp));
if (pRsp->aCreateTbRsp == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
} }
_exit:
if (code) {
*ppRsp = NULL;
if (pRsp) {
if (pRsp->aCreateTbRsp) taosArrayDestroy(pRsp->aCreateTbRsp);
taosMemoryFree(pRsp);
} }
} else { taosArrayDestroy(pRsp->aCreateTbRsp);
*ppRsp = pRsp;
} }
return code; } else if (TSDB_MSG_FLG_DECODE) {
} // TODO
taosArrayDestroy(pRsp->aCreateTbRsp);
void tDestroySSubmitRsp2(SSubmitRsp2 *pRsp, int32_t flag) {
if (pRsp) {
taosArrayDestroyEx(pRsp->aCreateTbRsp, NULL /* TODO: set according to flag */);
taosMemoryFree(pRsp);
} }
} }
...@@ -968,10 +968,18 @@ _exit: ...@@ -968,10 +968,18 @@ _exit:
tEncodeSSubmitRsp2(&ec, pSubmitRsp); tEncodeSSubmitRsp2(&ec, pSubmitRsp);
tEncoderClear(&ec); tEncoderClear(&ec);
// update statistics
atomic_add_fetch_64(&pVnode->statis.nInsert, pSubmitRsp->affectedRows);
atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows);
atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1);
if (code == 0) {
atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1);
}
// clear // clear
taosArrayDestroy(newTbUids); taosArrayDestroy(newTbUids);
tDestroySSubmitReq2(pSubmitReq); tDestroySSubmitReq2(pSubmitReq);
tDestroySSubmitRsp2(pSubmitRsp); tDestroySSubmitRsp2(pSubmitRsp, TSDB_MSG_FLG_ENCODE);
return code; return code;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册