提交 82fcd221 编写于 作者: X Xiaoyu Wang

enh: add binary serialization method to node structure

上级 f40d838f
......@@ -237,6 +237,11 @@ static int32_t tlvDecodeCStr(STlv* pTlv, char* pValue) {
return TSDB_CODE_SUCCESS;
}
static int32_t tlvDecodeCStrP(STlv* pTlv, char** pValue) {
*pValue = strndup(pTlv->value, pTlv->len);
return NULL == *pValue ? TSDB_CODE_OUT_OF_MEMORY : TSDB_CODE_SUCCESS;
}
static int32_t tlvDecodeDynBinary(STlv* pTlv, void** pValue) {
*pValue = taosMemoryMalloc(pTlv->len);
if (NULL == *pValue) {
......@@ -461,7 +466,7 @@ static int32_t msgToColumnNode(STlvDecoder* pDecoder, void* pObj) {
return code;
}
enum { VALUE_CODE_EXPR_BASE = 1, VALUE_CODE_IS_NULL, VALUE_CODE_DATUM };
enum { VALUE_CODE_EXPR_BASE = 1, VALUE_CODE_LITERAL, VALUE_CODE_IS_NULL, VALUE_CODE_DATUM };
static int32_t datumToMsg(const void* pObj, STlvEncoder* pEncoder) {
const SValueNode* pNode = (const SValueNode*)pObj;
......@@ -512,6 +517,9 @@ static int32_t valueNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
const SValueNode* pNode = (const SValueNode*)pObj;
int32_t code = tlvEncodeObj(pEncoder, VALUE_CODE_EXPR_BASE, exprNodeToMsg, pNode);
if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeCStr(pEncoder, VALUE_CODE_LITERAL, pNode->literal);
}
if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeBool(pEncoder, VALUE_CODE_IS_NULL, pNode->isNull);
}
......@@ -608,6 +616,9 @@ static int32_t msgToValueNode(STlvDecoder* pDecoder, void* pObj) {
case VALUE_CODE_EXPR_BASE:
code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
break;
case VALUE_CODE_LITERAL:
code = tlvDecodeCStrP(pTlv, &pNode->literal);
break;
case VALUE_CODE_IS_NULL:
code = tlvDecodeBool(pTlv, &pNode->isNull);
break;
......
......@@ -487,6 +487,7 @@ class PlannerTestBaseImpl {
DO_WITH_THROW(nodesNodeToString, pNode, false, &pNewStr, &newlen)
cout << "new node: " << pNewStr << endl;
}
nodesDestroyNode(pNode);
taosMemoryFreeClear(pNewStr);
string str(pStr, len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册