support bigint

This commit is contained in:
wpan 2021-07-05 10:37:00 +08:00
parent a97f80070a
commit aa81373fed
1 changed files with 15 additions and 14 deletions

View File

@ -10,33 +10,34 @@ typedef struct SUdfInit{
int const_item; /* 0 if result is independent of arguments */ int const_item; /* 0 if result is independent of arguments */
} SUdfInit; } SUdfInit;
#define TSDB_DATA_INT_NULL 0x80000000L
#define TSDB_DATA_INT_NULL 0x80000000L
#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L
void abs_max(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, void abs_max(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* numOfOutput, short otype, short obytes, SUdfInit* buf) {
int i; int i;
int r = 0; int r = 0;
printf("abs_max input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); printf("abs_max input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf);
if (itype == 4) { if (itype == 5) {
r=*(int *)dataOutput; r=*(long *)dataOutput;
*numOfOutput=0; *numOfOutput=0;
for(i=0;i<numOfRows;++i) { for(i=0;i<numOfRows;++i) {
if (*((int *)data + i) == TSDB_DATA_INT_NULL) { if (*((long *)data + i) == TSDB_DATA_BIGINT_NULL) {
continue; continue;
} }
*numOfOutput=1; *numOfOutput=1;
int v = abs(*((int *)data + i)); long v = abs(*((long *)data + i));
if (v > r) { if (v > r) {
r = v; r = v;
} }
} }
*(int *)dataOutput=r; *(long *)dataOutput=r;
printf("abs_max out, dataoutput:%d, numOfOutput:%d\n", *(int *)dataOutput, *numOfOutput); printf("abs_max out, dataoutput:%ld, numOfOutput:%d\n", *(long *)dataOutput, *numOfOutput);
} }
} }
@ -47,31 +48,31 @@ void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfIn
int r = 0; int r = 0;
printf("abs_max_finalize dataoutput:%p:%d, numOfOutput:%d, buf:%p\n", dataOutput, *dataOutput, *numOfOutput, buf); printf("abs_max_finalize dataoutput:%p:%d, numOfOutput:%d, buf:%p\n", dataOutput, *dataOutput, *numOfOutput, buf);
*numOfOutput=1; *numOfOutput=1;
printf("abs_max finalize, dataoutput:%d, numOfOutput:%d\n", *(int *)dataOutput, *numOfOutput); printf("abs_max finalize, dataoutput:%ld, numOfOutput:%d\n", *(long *)dataOutput, *numOfOutput);
} }
void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) { void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) {
int r = 0; int r = 0;
if (numOfRows > 0) { if (numOfRows > 0) {
r = *((int*)data); r = *((long *)data);
} }
printf("abs_max_merge numOfRows:%d, dataoutput:%p, buf:%p\n", numOfRows, dataOutput, buf); printf("abs_max_merge numOfRows:%d, dataoutput:%p, buf:%p\n", numOfRows, dataOutput, buf);
for (int i = 1; i < numOfRows; ++i) { for (int i = 1; i < numOfRows; ++i) {
printf("abs_max_merge %d - %d\n", i, *((int*)data + i)); printf("abs_max_merge %d - %ld\n", i, *((long *)data + i));
if (*((int*)data + i) > r) { if (*((long*)data + i) > r) {
r= *((int*)data + i); r= *((long*)data + i);
} }
} }
*(int*)dataOutput=r; *(long*)dataOutput=r;
if (numOfRows > 0) { if (numOfRows > 0) {
*numOfOutput=1; *numOfOutput=1;
} else { } else {
*numOfOutput=0; *numOfOutput=0;
} }
printf("abs_max_merge, dataoutput:%d, numOfOutput:%d\n", *(int *)dataOutput, *numOfOutput); printf("abs_max_merge, dataoutput:%ld, numOfOutput:%d\n", *(long *)dataOutput, *numOfOutput);
} }