opti:logic in parse raw line & make log more specific

This commit is contained in:
wangmm0220 2023-12-18 19:21:02 +08:00
parent 7f8479f953
commit ef621a06a7
1 changed files with 8 additions and 8 deletions

View File

@ -1640,25 +1640,25 @@ int32_t smlClearForRerun(SSmlHandle *info) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static bool getLine(SSmlHandle *info, char *lines[], char *rawLine, char *rawLineEnd, static bool getLine(SSmlHandle *info, char *lines[], char **rawLine, char *rawLineEnd,
int numLines, int i, char** tmp, int *len){ int numLines, int i, char** tmp, int *len){
if (lines) { if (lines) {
*tmp = lines[i]; *tmp = lines[i];
*len = strlen(*tmp); *len = strlen(*tmp);
} else if (rawLine) { } else if (*rawLine) {
*tmp = rawLine; *tmp = *rawLine;
while (rawLine < rawLineEnd) { while (*rawLine < rawLineEnd) {
if (*(rawLine++) == '\n') { if (*((*rawLine)++) == '\n') {
break; break;
} }
(*len)++; (*len)++;
} }
if (info->protocol == TSDB_SML_LINE_PROTOCOL && (*tmp)[0] == '#') { // this line is comment if (info->protocol == TSDB_SML_LINE_PROTOCOL && (*tmp)[0] == '#') { // this line is comment
false; return false;
} }
} }
if(rawLine != NULL){ if(*rawLine != NULL){
char* print = taosMemoryCalloc(*len + 1, 1); char* print = taosMemoryCalloc(*len + 1, 1);
memcpy(print, *tmp, *len); memcpy(print, *tmp, *len);
uDebug("SML:0x%" PRIx64 " smlParseLine is raw, numLines:%d, protocol:%d, len:%d, data:%s", info->id, uDebug("SML:0x%" PRIx64 " smlParseLine is raw, numLines:%d, protocol:%d, len:%d, data:%s", info->id,
@ -1692,7 +1692,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
while (i < numLines) { while (i < numLines) {
char *tmp = NULL; char *tmp = NULL;
int len = 0; int len = 0;
if(!getLine(info, lines, rawLine, rawLineEnd, numLines, i, &tmp, &len)){ if(!getLine(info, lines, &rawLine, rawLineEnd, numLines, i, &tmp, &len)){
continue; continue;
} }
if (info->protocol == TSDB_SML_LINE_PROTOCOL) { if (info->protocol == TSDB_SML_LINE_PROTOCOL) {