From a97de8dc9d1b29f4b92b4344ecc8de95e385df0e Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 27 Apr 2021 11:01:25 +0800 Subject: [PATCH] demo new requirement --- src/query/inc/qUdf.h | 2 -- tests/script/sh/demo.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/query/inc/qUdf.h b/src/query/inc/qUdf.h index c66ca5a21b..26573cb743 100644 --- a/src/query/inc/qUdf.h +++ b/src/query/inc/qUdf.h @@ -51,8 +51,6 @@ typedef struct SUdfInfo { SUdfInit init; char *content; char *path; - - bool cloned; } SUdfInfo; //script diff --git a/tests/script/sh/demo.c b/tests/script/sh/demo.c index a506014a9e..23d2174448 100644 --- a/tests/script/sh/demo.c +++ b/tests/script/sh/demo.c @@ -16,6 +16,10 @@ typedef struct SDemo{ short otype; }SDemo; +#define FLOAT_NULL 0x7FF00000 // it is an NAN +#define DOUBLE_NULL 0x7FFFFF0000000000L // it is an NAN + + void demo(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf) { int i; @@ -75,10 +79,18 @@ void demo_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* SDemo *p = (SDemo *)interBuf; printf("demo_finalize interbuf:%p, numOfOutput:%p, buf:%p, sum:%f, num:%d\n", interBuf, numOfOutput, buf, p->sum, p->num); if (p->otype == 6) { - *(float *)dataOutput = (float)(p->sum / p->num); + if (p->num != 30000) { + *(unsigned int *)dataOutput = FLOAT_NULL; + } else { + *(float *)dataOutput = (float)(p->sum / p->num); + } printf("finalize values:%f\n", *(float *)dataOutput); } else if (p->otype == 7) { - *(double *)dataOutput = (double)(p->sum / p->num); + if (p->num != 30000) { + *(unsigned long long *)dataOutput = DOUBLE_NULL; + } else { + *(double *)dataOutput = (double)(p->sum / p->num); + } printf("finalize values:%f\n", *(double *)dataOutput); } -- GitLab