fix: null bitmap error

This commit is contained in:
slzhou 2023-03-09 20:27:08 +08:00
parent a39ada58a5
commit c10e32eb6a
2 changed files with 15 additions and 12 deletions

View File

@ -149,6 +149,8 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
allocCapacity *= UDF_MEMORY_EXP_GROWTH; allocCapacity *= UDF_MEMORY_EXP_GROWTH;
} }
int32_t existedRows = data->numOfRows;
if (IS_VAR_DATA_TYPE(meta->type)) { if (IS_VAR_DATA_TYPE(meta->type)) {
char *tmp = (char *)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); char *tmp = (char *)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity);
if (tmp == NULL) { if (tmp == NULL) {
@ -156,6 +158,7 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
} }
data->varLenCol.varOffsets = (int32_t *)tmp; data->varLenCol.varOffsets = (int32_t *)tmp;
data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity; data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity;
memset(&data->varLenCol.varOffsets[existedRows], 0, sizeof(int32_t) * (allocCapacity - existedRows));
// for payload, add data in udfColDataAppend // for payload, add data in udfColDataAppend
} else { } else {
char *tmp = (char *)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); char *tmp = (char *)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity));
@ -164,6 +167,9 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
} }
data->fixLenCol.nullBitmap = tmp; data->fixLenCol.nullBitmap = tmp;
data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity); data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity);
int32_t oldLen = BitmapLen(existedRows);
memset(&data->fixLenCol.nullBitmap[oldLen], 0, BitmapLen(allocCapacity) - oldLen);
if (meta->type == TSDB_DATA_TYPE_NULL) { if (meta->type == TSDB_DATA_TYPE_NULL) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -260,24 +266,21 @@ typedef int32_t (*TUdfAggMergeFunc)(SUdfInterBuf *inputBuf1, SUdfInterBuf *input
typedef int32_t (*TUdfAggFinishFunc)(SUdfInterBuf *buf, SUdfInterBuf *resultData); typedef int32_t (*TUdfAggFinishFunc)(SUdfInterBuf *buf, SUdfInterBuf *resultData);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct SScriptUdfEnvItem{ typedef struct SScriptUdfEnvItem {
const char *name; const char *name;
const char *value; const char *value;
} SScriptUdfEnvItem; } SScriptUdfEnvItem;
typedef enum EUdfFuncType { typedef enum EUdfFuncType { UDF_FUNC_TYPE_SCALAR = 1, UDF_FUNC_TYPE_AGG = 2 } EUdfFuncType;
UDF_FUNC_TYPE_SCALAR = 1,
UDF_FUNC_TYPE_AGG = 2
} EUdfFuncType;
typedef struct SScriptUdfInfo { typedef struct SScriptUdfInfo {
const char *name; const char *name;
EUdfFuncType funcType; EUdfFuncType funcType;
int8_t scriptType; int8_t scriptType;
int8_t outputType; int8_t outputType;
int32_t outputLen; int32_t outputLen;
int32_t bufSize; int32_t bufSize;
const char *path; const char *path;
} SScriptUdfInfo; } SScriptUdfInfo;
@ -294,7 +297,7 @@ typedef int32_t (*TScriptUdfInitFunc)(SScriptUdfInfo *info, void **pUdfCtx);
typedef int32_t (*TScriptUdfDestoryFunc)(void *udfCtx); typedef int32_t (*TScriptUdfDestoryFunc)(void *udfCtx);
// the following function is for open/close script plugin. // the following function is for open/close script plugin.
typedef int32_t (*TScriptOpenFunc)(SScriptUdfEnvItem* items, int numItems); typedef int32_t (*TScriptOpenFunc)(SScriptUdfEnvItem *items, int numItems);
typedef int32_t (*TScriptCloseFunc)(); typedef int32_t (*TScriptCloseFunc)();
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -372,7 +372,7 @@ int32_t udfdInitializePythonPlugin(SUdfScriptPlugin *plugin) {
snprintf(pythonPath, lenPythonPath, "%s:%s", tsTempDir, tsUdfdLdLibPath); snprintf(pythonPath, lenPythonPath, "%s:%s", tsTempDir, tsUdfdLdLibPath);
#endif #endif
SScriptUdfEnvItem items[] = {{"PYTHONPATH", pythonPath}, {"LOGDIR", tsLogDir}}; SScriptUdfEnvItem items[] = {{"PYTHONPATH", pythonPath}, {"LOGDIR", tsLogDir}};
err = plugin->openFunc(items, 1); err = plugin->openFunc(items, 2);
taosMemoryFree(pythonPath); taosMemoryFree(pythonPath);
} }
if (err != 0) { if (err != 0) {