提交 76fc259b 编写于 作者: S shenglian zhou

increase memory allocation by 1.5 during parse sml kv pairs

上级 83a66e1e
...@@ -1400,7 +1400,7 @@ static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, ...@@ -1400,7 +1400,7 @@ static int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
if (ret) { if (ret) {
return ret; return ret;
} }
tscDebug("Timestamp after conversion:%"PRId64"\n", tsVal); tscDebug("Timestamp after conversion:%"PRId64, tsVal);
pVal->type = TSDB_DATA_TYPE_TIMESTAMP; pVal->type = TSDB_DATA_TYPE_TIMESTAMP;
pVal->length = (int16_t)tDataTypes[pVal->type].bytes; pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
...@@ -1582,14 +1582,16 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, ...@@ -1582,14 +1582,16 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
TAOS_SML_KV *pkv; TAOS_SML_KV *pkv;
bool is_last_kv = false; bool is_last_kv = false;
int32_t capacity = 0;
if (isField) { if (isField) {
//leave space for timestamp capacity = 64;
*pKVs = calloc(2, sizeof(TAOS_SML_KV)); *pKVs = calloc(capacity, sizeof(TAOS_SML_KV));
// leave space for timestamp;
pkv = *pKVs; pkv = *pKVs;
pkv++; pkv++;
} } else {
else { capacity = 8;
*pKVs = calloc(1, sizeof(TAOS_SML_KV)); *pKVs = calloc(capacity, sizeof(TAOS_SML_KV));
pkv = *pKVs; pkv = *pKVs;
} }
...@@ -1613,11 +1615,19 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, ...@@ -1613,11 +1615,19 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
//reallocate addtional memory for more kvs //reallocate addtional memory for more kvs
TAOS_SML_KV *more_kvs = NULL; TAOS_SML_KV *more_kvs = NULL;
if (isField) { if (isField) {
more_kvs = realloc(*pKVs, (*num_kvs + 2) * sizeof(TAOS_SML_KV)); if ((*num_kvs + 2) > capacity) {
capacity *= 3; capacity /= 2;
}
more_kvs = realloc(*pKVs, capacity * sizeof(TAOS_SML_KV));
} else { } else {
more_kvs = realloc(*pKVs, (*num_kvs + 1) * sizeof(TAOS_SML_KV)); if ((*num_kvs + 1) > capacity) {
capacity *= 3; capacity /= 2;
} }
more_kvs = realloc(*pKVs, capacity * sizeof(TAOS_SML_KV));
}
if (!more_kvs) { if (!more_kvs) {
goto error; goto error;
} }
...@@ -1631,10 +1641,10 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs, ...@@ -1631,10 +1641,10 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
} }
goto done; goto done;
error: error:
free(*pKVs); free(*pKVs);
return ret; return ret;
done: done:
*index = cur; *index = cur;
return ret; return ret;
} }
...@@ -1707,6 +1717,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData) { ...@@ -1707,6 +1717,7 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData) {
tscDebug("No child table name in tags"); tscDebug("No child table name in tags");
} }
removeChildTableNameFromTags(&smlData); removeChildTableNameFromTags(&smlData);
} }
tscDebug("Parse tags finished, num of tags:%d", smlData->tagNum); tscDebug("Parse tags finished, num of tags:%d", smlData->tagNum);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册