提交 b73cf23c 编写于 作者: C Cary Xu

fix: adapt the code according to large or small offset

上级 a9226df1
...@@ -574,20 +574,52 @@ static void debugPrintTagVal(int8_t type, const void *val, int32_t vlen, const c ...@@ -574,20 +574,52 @@ static void debugPrintTagVal(int8_t type, const void *val, int32_t vlen, const c
} }
} }
// if (isLarge) {
// p = (uint8_t *)&((int16_t *)pTag->idx)[pTag->nTag];
// } else {
// p = (uint8_t *)&pTag->idx[pTag->nTag];
// }
// (*ppArray) = taosArrayInit(pTag->nTag + 1, sizeof(STagVal));
// if (*ppArray == NULL) {
// code = TSDB_CODE_OUT_OF_MEMORY;
// goto _err;
// }
// for (int16_t iTag = 0; iTag < pTag->nTag; iTag++) {
// if (isLarge) {
// offset = ((int16_t *)pTag->idx)[iTag];
// } else {
// offset = pTag->idx[iTag];
// }
void debugPrintSTag(STag *pTag, const char *tag, int32_t ln) { void debugPrintSTag(STag *pTag, const char *tag, int32_t ln) {
printf("%s:%d >>> STAG === isJson:%s, len: %d, nTag: %d, sver:%d\n", tag, ln, pTag->isJson ? "true" : "false", int8_t isJson = pTag->flags & TD_TAG_JSON;
(int32_t)pTag->len, (int32_t)pTag->nTag, pTag->ver); int8_t isLarge = pTag->flags & TD_TAG_LARGE;
char *p = (char *)&pTag->idx[pTag->nTag]; uint8_t *p = NULL;
int16_t offset = 0;
if (isLarge) {
p = (uint8_t *)&((int16_t *)pTag->idx)[pTag->nTag];
} else {
p = (uint8_t *)&pTag->idx[pTag->nTag];
}
printf("%s:%d >>> STAG === %s:%s, len: %d, nTag: %d, sver:%d\n", tag, ln, isJson ? "json" : "normal",
isLarge ? "large" : "small", (int32_t)pTag->len, (int32_t)pTag->nTag, pTag->ver);
for (uint16_t n = 0; n < pTag->nTag; ++n) { for (uint16_t n = 0; n < pTag->nTag; ++n) {
int16_t *pIdx = pTag->idx + n; if (isLarge) {
STagVal tagVal = {0}; offset = ((int16_t *)pTag->idx)[n];
if (pTag->isJson) { } else {
tagVal.pKey = (char *)POINTER_SHIFT(p, *pIdx); offset = pTag->idx[n];
}
STagVal tagVal = {0};
if (isJson) {
tagVal.pKey = (char *)POINTER_SHIFT(p, offset);
} else { } else {
tagVal.cid = *(int16_t *)POINTER_SHIFT(p, *pIdx); tagVal.cid = *(int16_t *)POINTER_SHIFT(p, offset);
} }
printf("%s:%d loop[%d-%d] offset=%d\n", __func__, __LINE__, (int32_t)pTag->nTag, (int32_t)n, *pIdx); printf("%s:%d loop[%d-%d] offset=%d\n", __func__, __LINE__, (int32_t)pTag->nTag, (int32_t)n, (int32_t)offset);
tGetTagVal(p, &tagVal, pTag->isJson); tGetTagVal(p, &tagVal, isJson);
debugPrintTagVal(tagVal.type, tagVal.pData, tagVal.nData, __func__, __LINE__); debugPrintTagVal(tagVal.type, tagVal.pData, tagVal.nData, __func__, __LINE__);
} }
printf("\n"); printf("\n");
...@@ -771,8 +803,16 @@ int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) { return tDecodeBinary(pDec ...@@ -771,8 +803,16 @@ int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) { return tDecodeBinary(pDec
int32_t tTagToValArray(const STag *pTag, SArray **ppArray) { int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
int32_t code = 0; int32_t code = 0;
uint8_t *p = (uint8_t *)&pTag->idx[pTag->nTag]; uint8_t *p = NULL;
STagVal tv; STagVal tv = {0};
int8_t isLarge = pTag->flags & TD_TAG_LARGE;
int16_t offset = 0;
if (isLarge) {
p = (uint8_t *)&((int16_t *)pTag->idx)[pTag->nTag];
} else {
p = (uint8_t *)&pTag->idx[pTag->nTag];
}
(*ppArray) = taosArrayInit(pTag->nTag + 1, sizeof(STagVal)); (*ppArray) = taosArrayInit(pTag->nTag + 1, sizeof(STagVal));
if (*ppArray == NULL) { if (*ppArray == NULL) {
...@@ -781,7 +821,12 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) { ...@@ -781,7 +821,12 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
} }
for (int16_t iTag = 0; iTag < pTag->nTag; iTag++) { for (int16_t iTag = 0; iTag < pTag->nTag; iTag++) {
tGetTagVal(p + pTag->idx[iTag], &tv, pTag->flags & TD_TAG_JSON); if (isLarge) {
offset = ((int16_t *)pTag->idx)[iTag];
} else {
offset = pTag->idx[iTag];
}
tGetTagVal(p + offset, &tv, pTag->flags & TD_TAG_JSON);
taosArrayPush(*ppArray, &tv); taosArrayPush(*ppArray, &tv);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册