diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 30ff0ee564..7242c51933 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -19,6 +19,7 @@ #include "os.h" #include "talgo.h" #include "tarray.h" +#include "tbuffer.h" #include "tencode.h" #include "ttypes.h" #include "tutil.h" @@ -27,19 +28,21 @@ extern "C" { #endif -typedef struct SBuffer SBuffer; -typedef struct SSchema SSchema; +typedef struct SSchema SSchema; +typedef struct SSchema2 SSchema2; typedef struct SSchemaExt SSchemaExt; -typedef struct SSchema2 SSchema2; -typedef struct STColumn STColumn; -typedef struct STSchema STSchema; -typedef struct SValue SValue; -typedef struct SColVal SColVal; -typedef struct SRow SRow; -typedef struct SRowIter SRowIter; -typedef struct STagVal STagVal; -typedef struct STag STag; -typedef struct SColData SColData; +typedef struct STColumn STColumn; +typedef struct STSchema STSchema; +typedef struct SValue SValue; +typedef struct SColVal SColVal; +typedef struct SRow SRow; +typedef struct SRowIter SRowIter; +typedef struct STagVal STagVal; +typedef struct STag STag; +typedef struct SColData SColData; + +typedef struct SRowKey SRowKey; +typedef struct SValueColumn SValueColumn; #define HAS_NONE ((uint8_t)0x1) #define HAS_NULL ((uint8_t)0x2) @@ -54,9 +57,9 @@ const static uint8_t BIT2_MAP[4] = {0b11111100, 0b11110011, 0b11001111, 0b001111 #define ONE ((uint8_t)1) #define THREE ((uint8_t)3) #define DIV_8(i) ((i) >> 3) -#define MOD_8(i) ((i)&7) +#define MOD_8(i) ((i) & 7) #define DIV_4(i) ((i) >> 2) -#define MOD_4(i) ((i)&3) +#define MOD_4(i) ((i) & 3) #define MOD_4_TIME_2(i) (MOD_4(i) << 1) #define BIT1_SIZE(n) (DIV_8((n)-1) + 1) #define BIT2_SIZE(n) (DIV_4((n)-1) + 1) @@ -79,32 +82,42 @@ const static uint8_t BIT2_MAP[4] = {0b11111100, 0b11110011, 0b11001111, 0b001111 } while (0) #define GET_BIT2(p, i) (((p)[DIV_4(i)] >> MOD_4_TIME_2(i)) & THREE) -// SBuffer ================================ -struct SBuffer { - int64_t nBuf; - uint8_t *pBuf; -}; - -#define tBufferCreate() \ - (SBuffer) { .nBuf = 0, .pBuf = NULL } -void tBufferDestroy(SBuffer *pBuffer); -int32_t tBufferInit(SBuffer *pBuffer, int64_t size); -int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData); -int32_t tBufferReserve(SBuffer *pBuffer, int64_t nData, void **ppData); - // SColVal ================================ #define CV_FLAG_VALUE ((int8_t)0x0) #define CV_FLAG_NONE ((int8_t)0x1) #define CV_FLAG_NULL ((int8_t)0x2) -#define COL_VAL_NONE(CID, TYPE) ((SColVal){.cid = (CID), .type = (TYPE), .flag = CV_FLAG_NONE}) -#define COL_VAL_NULL(CID, TYPE) ((SColVal){.cid = (CID), .type = (TYPE), .flag = CV_FLAG_NULL}) -#define COL_VAL_VALUE(CID, TYPE, V) ((SColVal){.cid = (CID), .type = (TYPE), .value = (V)}) +#define COL_VAL_NONE(CID, TYPE) ((SColVal){.cid = (CID), .flag = CV_FLAG_NONE, .value = {.type = (TYPE)}}) +#define COL_VAL_NULL(CID, TYPE) ((SColVal){.cid = (CID), .flag = CV_FLAG_NULL, .value = {.type = (TYPE)}}) +#define COL_VAL_VALUE(CID, V) ((SColVal){.cid = (CID), .flag = CV_FLAG_VALUE, .value = (V)}) #define COL_VAL_IS_NONE(CV) ((CV)->flag == CV_FLAG_NONE) #define COL_VAL_IS_NULL(CV) ((CV)->flag == CV_FLAG_NULL) #define COL_VAL_IS_VALUE(CV) ((CV)->flag == CV_FLAG_VALUE) +// SValueColumn ================================ +typedef struct { + int8_t cmprAlg; // filled by caller + int8_t type; + int32_t dataOriginalSize; + int32_t dataCompressedSize; + int32_t offsetOriginalSize; + int32_t offsetCompressedSize; +} SValueColumnCompressInfo; + +int32_t tValueColumnInit(SValueColumn *valCol); +int32_t tValueColumnDestroy(SValueColumn *valCol); +int32_t tValueColumnClear(SValueColumn *valCol); +int32_t tValueColumnAppend(SValueColumn *valCol, const SValue *value); +int32_t tValueColumnUpdate(SValueColumn *valCol, int32_t idx, const SValue *value); +int32_t tValueColumnGet(SValueColumn *valCol, int32_t idx, SValue *value); +int32_t tValueColumnCompress(SValueColumn *valCol, SValueColumnCompressInfo *info, SBuffer *output, SBuffer *assist); +int32_t tValueColumnDecompress(void *input, const SValueColumnCompressInfo *compressInfo, SValueColumn *valCol, + SBuffer *buffer); +int32_t tValueColumnCompressInfoEncode(const SValueColumnCompressInfo *compressInfo, SBuffer *buffer); +int32_t tValueColumnCompressInfoDecode(SBufferReader *reader, SValueColumnCompressInfo *compressInfo); +int32_t tValueCompare(const SValue *tv1, const SValue *tv2); + // SRow ================================ int32_t tRowBuild(SArray *aColVal, const STSchema *pTSchema, SRow **ppRow); int32_t tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal); @@ -112,6 +125,8 @@ void tRowDestroy(SRow *pRow); int32_t tRowSort(SArray *aRowP); int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag); int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag); +void tRowGetKey(SRow *pRow, SRowKey *key); +int32_t tRowKeyCompare(const void *p1, const void *p2); // SRowIter ================================ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter); @@ -133,9 +148,25 @@ void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remov int32_t parseJsontoTagData(const char *json, SArray *pTagVals, STag **ppTag, void *pMsgBuf); // SColData ================================ +typedef struct { + int8_t cmprAlg; // filled by caller + int8_t columnFlag; + int8_t flag; + int8_t dataType; + int16_t columnId; + int32_t numOfData; + int32_t bitmapOriginalSize; + int32_t bitmapCompressedSize; + int32_t offsetOriginalSize; + int32_t offsetCompressedSize; + int32_t dataOriginalSize; + int32_t dataCompressedSize; +} SColDataCompressInfo; + typedef void *(*xMallocFn)(void *, int32_t); + void tColDataDestroy(void *ph); -void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn); +void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t cflag); void tColDataClear(SColData *pColData); void tColDataDeepClear(SColData *pColData); int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal); @@ -143,8 +174,12 @@ int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward); void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal); uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal); int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg); + extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull); +int32_t tColDataCompress(SColData *colData, SColDataCompressInfo *info, SBuffer *output, SBuffer *assist); +int32_t tColDataDecompress(void *input, SColDataCompressInfo *info, SColData *colData, SBuffer *assist); + // for stmt bind int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind, int32_t buffMaxLen); void tColDataSortMerge(SArray *colDataArr); @@ -173,28 +208,47 @@ struct STSchema { STColumn columns[]; }; +/* + * 1. Tuple format: + * SRow + [(type, offset) * numOfPKs +] [bit map +] fix-length data + [var-length data] + * + * 2. K-V format: + * SRow + [(type, offset) * numOfPKs +] offset array + ([-]cid [+ data]) * numColsNotNone + */ struct SRow { uint8_t flag; - uint8_t rsv; + uint8_t numOfPKs; uint16_t sver; uint32_t len; TSKEY ts; uint8_t data[]; }; +typedef struct { + int8_t type; + uint32_t offset; +} SPrimaryKeyIndex; + struct SValue { + int8_t type; union { int64_t val; struct { - uint32_t nData; uint8_t *pData; + uint32_t nData; }; }; }; +#define TD_MAX_PK_COLS 2 +struct SRowKey { + TSKEY ts; + uint8_t numOfPKs; + SValue pks[TD_MAX_PK_COLS]; +}; + struct SColVal { int16_t cid; - int8_t type; int8_t flag; SValue value; }; @@ -202,7 +256,7 @@ struct SColVal { struct SColData { int16_t cid; int8_t type; - int8_t smaOn; + int8_t cflag; int32_t numOfNone; // # of none int32_t numOfNull; // # of null int32_t numOfValue; // # of vale @@ -274,6 +328,36 @@ STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version); pTSchema = NULL; \ } \ } while (0) +const STColumn *tTSchemaSearchColumn(const STSchema *pTSchema, int16_t cid); + +struct SValueColumn { + int8_t type; + uint32_t numOfValues; + SBuffer data; + SBuffer offsets; +}; + +typedef struct { + int8_t dataType; // filled by caller + int8_t cmprAlg; // filled by caller + int32_t originalSize; // filled by caller + int32_t compressedSize; +} SCompressInfo; + +int32_t tCompressData(void *input, // input + SCompressInfo *info, // compress info + void *output, // output + int32_t outputSize, // output size + SBuffer *buffer // assistant buffer provided by caller, can be NULL +); +int32_t tDecompressData(void *input, // input + const SCompressInfo *info, // compress info + void *output, // output + int32_t outputSize, // output size + SBuffer *buffer // assistant buffer provided by caller, can be NULL +); +int32_t tCompressDataToBuffer(void *input, SCompressInfo *info, SBuffer *output, SBuffer *assist); +int32_t tDecompressDataToBuffer(void *input, SCompressInfo *info, SBuffer *output, SBuffer *assist); #endif diff --git a/include/common/tmsg.h b/include/common/tmsg.h index dd363b3321..e714dc1522 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -622,6 +622,7 @@ void tFreeSSubmitRsp(SSubmitRsp* pRsp); #define COL_SMA_ON ((int8_t)0x1) #define COL_IDX_ON ((int8_t)0x2) +#define COL_IS_KEY ((int8_t)0x4) #define COL_SET_NULL ((int8_t)0x10) #define COL_SET_VAL ((int8_t)0x20) #define COL_IS_SYSINFO ((int8_t)0x40) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 0f2ec16cf7..a335a5029a 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -16,7 +16,6 @@ #ifndef _TD_COMMON_TOKEN_H_ #define _TD_COMMON_TOKEN_H_ - #define TK_OR 1 #define TK_AND 2 #define TK_UNION 3 @@ -367,9 +366,10 @@ #define TK_VALUES 348 #define TK_VARIABLE 349 #define TK_WAL 350 -#define TK_ENCODE 351 -#define TK_COMPRESS 352 -#define TK_LEVEL 353 +#define TK_PRIMARY 351 +#define TK_ENCODE 352 +#define TK_COMPRESS 353 +#define TK_LEVEL 354 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index a0097374f4..60850936ad 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -171,6 +171,7 @@ typedef struct SColumnOptions { char encode[TSDB_CL_COMPRESS_OPTION_LEN]; char compress[TSDB_CL_COMPRESS_OPTION_LEN]; char compressLevel[TSDB_CL_COMPRESS_OPTION_LEN]; + bool bPrimaryKey; } SColumnOptions; typedef struct SColumnDefNode { ENodeType type; @@ -179,6 +180,7 @@ typedef struct SColumnDefNode { char comments[TSDB_TB_COMMENT_LEN]; SColumnOptions* pOptions; bool sma; + bool is_pk; } SColumnDefNode; typedef struct SCreateTableStmt { diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 938b99cc5c..c9c0298a83 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -761,6 +761,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_VIEW_CONFLICT_WITH_TABLE TAOS_DEF_ERROR_CODE(0, 0x266E) #define TSDB_CODE_PAR_ORDERBY_AMBIGUOUS TAOS_DEF_ERROR_CODE(0, 0x266F) #define TSDB_CODE_PAR_NOT_SUPPORT_MULTI_RESULT TAOS_DEF_ERROR_CODE(0, 0x2670) +#define TSDB_CODE_PAR_TAG_IS_PRIMARY_KEY TAOS_DEF_ERROR_CODE(0, 0x2671) +#define TSDB_CODE_PAR_SECOND_COL_PK TAOS_DEF_ERROR_CODE(0, 0x2672) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h new file mode 100644 index 0000000000..094d0e37ba --- /dev/null +++ b/include/util/tbuffer.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "os.h" + +#ifndef __TD_BUFFER_H__ +#define __TD_BUFFER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SBuffer SBuffer; +typedef struct SBufferReader SBufferReader; + +// SBuffer +#define BUFFER_INITIALIZER ((SBuffer){0, 0, NULL}) +static int32_t tBufferInit(SBuffer *buffer); +static int32_t tBufferDestroy(SBuffer *buffer); +static int32_t tBufferClear(SBuffer *buffer); +static int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity); +static int32_t tBufferPut(SBuffer *buffer, const void *data, uint32_t size); +static int32_t tBufferPutAt(SBuffer *buffer, uint32_t offset, const void *data, uint32_t size); +static int32_t tBufferPutI8(SBuffer *buffer, int8_t value); +static int32_t tBufferPutI16(SBuffer *buffer, int16_t value); +static int32_t tBufferPutI32(SBuffer *buffer, int32_t value); +static int32_t tBufferPutI64(SBuffer *buffer, int64_t value); +static int32_t tBufferPutU8(SBuffer *buffer, uint8_t value); +static int32_t tBufferPutU16(SBuffer *buffer, uint16_t value); +static int32_t tBufferPutU32(SBuffer *buffer, uint32_t value); +static int32_t tBufferPutU64(SBuffer *buffer, uint64_t value); +static int32_t tBufferPutI16v(SBuffer *buffer, int16_t value); +static int32_t tBufferPutI32v(SBuffer *buffer, int32_t value); +static int32_t tBufferPutI64v(SBuffer *buffer, int64_t value); +static int32_t tBufferPutU16v(SBuffer *buffer, uint16_t value); +static int32_t tBufferPutU32v(SBuffer *buffer, uint32_t value); +static int32_t tBufferPutU64v(SBuffer *buffer, uint64_t value); +static int32_t tBufferPutBinary(SBuffer *buffer, const void *data, uint32_t size); +static int32_t tBufferPutCStr(SBuffer *buffer, const char *str); +static int32_t tBufferPutF32(SBuffer *buffer, float value); +static int32_t tBufferPutF64(SBuffer *buffer, double value); + +#define tBufferGetSize(buffer) ((buffer)->size) +#define tBufferGetCapacity(buffer) ((buffer)->capacity) +#define tBufferGetData(buffer) ((buffer)->data) +#define tBufferGetDataAt(buffer, offset) ((char *)(buffer)->data + (offset)) +#define tBufferGetDataEnd(buffer) ((char *)(buffer)->data + (buffer)->size) + +// SBufferReader +#define BUFFER_READER_INITIALIZER(offset, buffer) ((SBufferReader){offset, buffer}) +#define BR_PTR(br) tBufferGetDataAt((br)->buffer, (br)->offset) +#define tBufferReaderDestroy(reader) ((void)0) +#define tBufferReaderGetOffset(reader) ((reader)->offset) +static int32_t tBufferGet(SBufferReader *reader, uint32_t size, void *data); +static int32_t tBufferReaderInit(SBufferReader *reader, uint32_t offset, SBuffer *buffer); +static int32_t tBufferGetI8(SBufferReader *reader, int8_t *value); +static int32_t tBufferGetI16(SBufferReader *reader, int16_t *value); +static int32_t tBufferGetI32(SBufferReader *reader, int32_t *value); +static int32_t tBufferGetI64(SBufferReader *reader, int64_t *value); +static int32_t tBufferGetU8(SBufferReader *reader, uint8_t *value); +static int32_t tBufferGetU16(SBufferReader *reader, uint16_t *value); +static int32_t tBufferGetU32(SBufferReader *reader, uint32_t *value); +static int32_t tBufferGetU64(SBufferReader *reader, uint64_t *value); +static int32_t tBufferGetI16v(SBufferReader *reader, int16_t *value); +static int32_t tBufferGetI32v(SBufferReader *reader, int32_t *value); +static int32_t tBufferGetI64v(SBufferReader *reader, int64_t *value); +static int32_t tBufferGetU16v(SBufferReader *reader, uint16_t *value); +static int32_t tBufferGetU32v(SBufferReader *reader, uint32_t *value); +static int32_t tBufferGetU64v(SBufferReader *reader, uint64_t *value); +static int32_t tBufferGetBinary(SBufferReader *reader, const void **data, uint32_t *size); +static int32_t tBufferGetCStr(SBufferReader *reader, const char **str); +static int32_t tBufferGetF32(SBufferReader *reader, float *value); +static int32_t tBufferGetF64(SBufferReader *reader, double *value); + +#include "tbuffer.inc" + +#ifdef __cplusplus +} +#endif + +#endif /*__TD_BUFFER_H__*/ \ No newline at end of file diff --git a/include/util/tbuffer.inc b/include/util/tbuffer.inc new file mode 100644 index 0000000000..f0137ee978 --- /dev/null +++ b/include/util/tbuffer.inc @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "taoserror.h" +#include "tcoding.h" + +struct SBuffer { + uint32_t size; + uint32_t capacity; + void *data; +}; + +struct SBufferReader { + uint32_t offset; + SBuffer *buffer; +}; + +// SBuffer +static FORCE_INLINE int32_t tBufferInit(SBuffer *buffer) { + buffer->size = 0; + buffer->capacity = 0; + buffer->data = NULL; + return 0; +} + +static FORCE_INLINE int32_t tBufferDestroy(SBuffer *buffer) { + buffer->size = 0; + buffer->capacity = 0; + if (buffer->data) { + taosMemoryFree(buffer->data); + buffer->data = NULL; + } + return 0; +} + +static FORCE_INLINE int32_t tBufferClear(SBuffer *buffer) { + buffer->size = 0; + return 0; +} + +static FORCE_INLINE int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity) { + if (buffer->capacity < capacity) { + uint32_t newCapacity = (buffer->capacity > 0) ? (buffer->capacity << 1) : 1024; + while (newCapacity < capacity) { + newCapacity <<= 1; + } + void *newData = taosMemoryRealloc(buffer->data, newCapacity); + if (newData == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + buffer->data = newData; + buffer->capacity = newCapacity; + } + return 0; +} + +static FORCE_INLINE int32_t tBufferPut(SBuffer *buffer, const void *data, uint32_t size) { + int32_t code = tBufferEnsureCapacity(buffer, buffer->size + size); + if (code) return code; + memcpy((char *)buffer->data + buffer->size, data, size); + buffer->size += size; + return 0; +} + +static int32_t tBufferPutAt(SBuffer *buffer, uint32_t offset, const void *data, uint32_t size) { + if (offset + size > buffer->size) { + return TSDB_CODE_OUT_OF_RANGE; + } + memcpy((char *)buffer->data + offset, data, size); + return 0; +} + +static FORCE_INLINE int32_t tBufferPutI8(SBuffer *buffer, int8_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutI16(SBuffer *buffer, int16_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutI32(SBuffer *buffer, int32_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutI64(SBuffer *buffer, int64_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutU8(SBuffer *buffer, uint8_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutU16(SBuffer *buffer, uint16_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutU32(SBuffer *buffer, uint32_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutU64(SBuffer *buffer, uint64_t value) { + return tBufferPut(buffer, &value, sizeof(value)); +} + +static FORCE_INLINE int32_t tBufferPutU16v(SBuffer *buffer, uint16_t value) { return tBufferPutU64v(buffer, value); } + +static FORCE_INLINE int32_t tBufferPutU32v(SBuffer *buffer, uint32_t value) { return tBufferPutU64v(buffer, value); } + +static FORCE_INLINE int32_t tBufferPutU64v(SBuffer *buffer, uint64_t value) { + int32_t code; + while (value >= 0x80) { + code = tBufferPutU8(buffer, (value & 0x7F) | 0x80); + if (code) return code; + value >>= 7; + } + return tBufferPutU8(buffer, value); +} + +static FORCE_INLINE int32_t tBufferPutI16v(SBuffer *buffer, int16_t value) { + return tBufferPutU64v(buffer, ZIGZAGE(int16_t, value)); +} + +static FORCE_INLINE int32_t tBufferPutI32v(SBuffer *buffer, int32_t value) { + return tBufferPutU64v(buffer, ZIGZAGE(int32_t, value)); +} + +static FORCE_INLINE int32_t tBufferPutI64v(SBuffer *buffer, int64_t value) { + return tBufferPutU64v(buffer, ZIGZAGE(int64_t, value)); +} + +static FORCE_INLINE int32_t tBufferPutBinary(SBuffer *buffer, const void *data, uint32_t size) { + int32_t code = tBufferPutU32v(buffer, size); + if (code) return code; + return tBufferPut(buffer, data, size); +} + +static FORCE_INLINE int32_t tBufferPutCStr(SBuffer *buffer, const char *str) { + return tBufferPutBinary(buffer, str, str ? strlen(str) + 1 : 0); +} + +static FORCE_INLINE int32_t tBufferPutF32(SBuffer *buffer, float value) { + union { + float f; + uint32_t u; + } u; + u.f = value; + return tBufferPutU32(buffer, u.u); +} + +static FORCE_INLINE int32_t tBufferPutF64(SBuffer *buffer, double value) { + union { + double f; + uint64_t u; + } u; + u.f = value; + return tBufferPutU64(buffer, u.u); +} + +// reader +// SBufferReader +static int32_t tBufferReaderInit(SBufferReader *reader, uint32_t offset, SBuffer *buffer) { + reader->offset = offset; + reader->buffer = buffer; + return 0; +} + +static FORCE_INLINE int32_t tBufferGet(SBufferReader *reader, uint32_t size, void *data) { + if (reader->offset < 0 || reader->offset + size > reader->buffer->size) { + return TSDB_CODE_OUT_OF_RANGE; + } + if (data) { + memcpy(data, BR_PTR(reader), size); + } + reader->offset += size; + return 0; +} + +static int32_t tBufferGetI8(SBufferReader *reader, int8_t *value) { return tBufferGet(reader, sizeof(*value), value); } + +static int32_t tBufferGetI16(SBufferReader *reader, int16_t *value) { + return tBufferGet(reader, sizeof(*value), value); +} + +static int32_t tBufferGetI32(SBufferReader *reader, int32_t *value) { + return tBufferGet(reader, sizeof(*value), value); +} + +static int32_t tBufferGetI64(SBufferReader *reader, int64_t *value) { + return tBufferGet(reader, sizeof(*value), value); +} + +static int32_t tBufferGetU8(SBufferReader *reader, uint8_t *value) { return tBufferGet(reader, sizeof(*value), value); } + +static int32_t tBufferGetU16(SBufferReader *reader, uint16_t *value) { + return tBufferGet(reader, sizeof(*value), value); +} + +static int32_t tBufferGetU32(SBufferReader *reader, uint32_t *value) { + return tBufferGet(reader, sizeof(*value), value); +} + +static int32_t tBufferGetU64(SBufferReader *reader, uint64_t *value) { + return tBufferGet(reader, sizeof(*value), value); +} + +static int32_t tBufferGetU64v(SBufferReader *reader, uint64_t *value) { + uint8_t byte; + int32_t code; + uint64_t u64 = 0; + + for (int32_t i = 0;; i++) { + code = tBufferGetU8(reader, &byte); + if (code) return code; + + u64 |= (((uint64_t)(byte & 0x7F)) << (i * 7)); + + if (byte < 0x80) { + break; + } + } + + if (value) { + *value = u64; + } + + return 0; +} + +static int32_t tBufferGetU16v(SBufferReader *reader, uint16_t *value) { + uint64_t u64; + int32_t code = tBufferGetU64v(reader, &u64); + if (code) return code; + if (value) { + *value = (uint16_t)u64; + } + return 0; +} + +static int32_t tBufferGetU32v(SBufferReader *reader, uint32_t *value) { + uint64_t u64; + int32_t code = tBufferGetU64v(reader, &u64); + if (code) return code; + if (value) { + *value = (uint32_t)u64; + } + return 0; +} + +static int32_t tBufferGetI16v(SBufferReader *reader, int16_t *value) { + uint16_t u16; + int32_t code = tBufferGetU16v(reader, &u16); + if (code) return code; + if (value) { + *value = ZIGZAGD(int16_t, u16); + } + return 0; +} + +static int32_t tBufferGetI32v(SBufferReader *reader, int32_t *value) { + uint32_t u32; + int32_t code = tBufferGetU32v(reader, &u32); + if (code) return code; + if (value) { + *value = ZIGZAGD(int32_t, u32); + } + return 0; +} + +static int32_t tBufferGetI64v(SBufferReader *reader, int64_t *value) { + uint64_t u64; + int32_t code = tBufferGetU64v(reader, &u64); + if (code) return code; + if (value) { + *value = ZIGZAGD(int64_t, u64); + } + return 0; +} + +static int32_t tBufferGetBinary(SBufferReader *reader, const void **data, uint32_t *size) { + uint32_t tmpSize; + int32_t code; + + // size + code = tBufferGetU32v(reader, &tmpSize); + if (code) return code; + if (size) { + *size = tmpSize; + } + + // data + if (tmpSize > 0) { + if (reader->offset + tmpSize > reader->buffer->size) { + return TSDB_CODE_OUT_OF_RANGE; + } + if (data) { + *data = BR_PTR(reader); + } + reader->offset += tmpSize; + } else if (data) { + *data = NULL; + } + + return 0; +} + +static int32_t tBufferGetCStr(SBufferReader *reader, const char **str) { + return tBufferGetBinary(reader, (const void **)str, NULL); +} + +static int32_t tBufferGetF32(SBufferReader *reader, float *value) { + union { + float f; + uint32_t u; + } u; + int32_t code = tBufferGetU32(reader, &u.u); + if (code) return code; + if (value) { + *value = u.f; + } + return 0; +} + +static int32_t tBufferGetF64(SBufferReader *reader, double *value) { + union { + double f; + uint64_t u; + } u; + int32_t code = tBufferGetU64(reader, &u.u); + if (code) return code; + if (value) { + *value = u.f; + } + return 0; +} diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index f4455be206..f0ecf2365c 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -258,7 +258,7 @@ void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, memset(&BMCharPos(pColumnInfoData->nullbitmap, currentRow + i), 0xFF, (numOfRows - i) / sizeof(char)); i += (numOfRows - i) / sizeof(char) * sizeof(char); - + for (; i < numOfRows; ++i) { colDataSetNull_f(pColumnInfoData->nullbitmap, currentRow + i); } @@ -266,23 +266,24 @@ void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, } } -int32_t colDataCopyAndReassign(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows) { +int32_t colDataCopyAndReassign(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, + uint32_t numOfRows) { int32_t code = colDataSetVal(pColumnInfoData, currentRow, pData, false); if (code) { return code; } - + if (numOfRows > 1) { int32_t* pOffset = pColumnInfoData->varmeta.offset; memset(&pOffset[currentRow + 1], pOffset[currentRow], sizeof(pOffset[0]) * (numOfRows - 1)); - pColumnInfoData->reassigned = true; + pColumnInfoData->reassigned = true; } return TSDB_CODE_SUCCESS; } -int32_t colDataCopyNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, - uint32_t numOfRows, bool isNull) { +int32_t colDataCopyNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows, + bool isNull) { int32_t len = pColumnInfoData->info.bytes; if (isNull) { colDataSetNItemsNull(pColumnInfoData, currentRow, numOfRows); @@ -293,18 +294,18 @@ int32_t colDataCopyNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { return colDataCopyAndReassign(pColumnInfoData, currentRow, pData, numOfRows); } else { - int32_t colBytes = pColumnInfoData->info.bytes; - int32_t colOffset = currentRow * colBytes; + int32_t colBytes = pColumnInfoData->info.bytes; + int32_t colOffset = currentRow * colBytes; uint32_t num = 1; void* pStart = pColumnInfoData->pData + colOffset; memcpy(pStart, pData, colBytes); colOffset += num * colBytes; - + while (num < numOfRows) { int32_t maxNum = num << 1; int32_t tnum = maxNum > numOfRows ? (numOfRows - num) : num; - + memcpy(pColumnInfoData->pData + colOffset, pStart, tnum * colBytes); colOffset += tnum * colBytes; num += tnum; @@ -868,8 +869,8 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) { size_t blockDataGetSerialMetaSize(uint32_t numOfCols) { // | version | total length | total rows | blankFull | total columns | flag seg| block group id | column schema // | each column length | - return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(bool) + sizeof(int32_t) + sizeof(int32_t) + sizeof(uint64_t) + - numOfCols * (sizeof(int8_t) + sizeof(int32_t)) + numOfCols * sizeof(int32_t); + return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(bool) + sizeof(int32_t) + sizeof(int32_t) + + sizeof(uint64_t) + numOfCols * (sizeof(int8_t) + sizeof(int32_t)) + numOfCols * sizeof(int32_t); } double blockDataGetSerialRowSize(const SSDataBlock* pBlock) { @@ -1878,10 +1879,10 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf, int32_t rows = pDataBlock->info.rows; int32_t len = 0; len += snprintf(dumpBuf + len, size - len, - "%s===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64 - "|rows:%" PRId64 "|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n", - taskIdStr, flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.id.groupId, - pDataBlock->info.id.uid, pDataBlock->info.rows, pDataBlock->info.version, + "%s===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64 "|rows:%" PRId64 + "|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n", + taskIdStr, flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, + pDataBlock->info.id.groupId, pDataBlock->info.id.uid, pDataBlock->info.rows, pDataBlock->info.version, pDataBlock->info.calWin.skey, pDataBlock->info.calWin.ekey, pDataBlock->info.parTbName); if (len >= size - 1) return dumpBuf; @@ -2039,13 +2040,13 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat if (!isStartKey) { isStartKey = true; ASSERT(PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId); - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, (SValue){.val = *(TSKEY*)var}); + SColVal cv = COL_VAL_VALUE(pCol->colId, ((SValue){.type = pCol->type, .val = *(TSKEY*)var})); taosArrayPush(pVals, &cv); } else if (colDataIsNull_s(pColInfoData, j)) { SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); taosArrayPush(pVals, &cv); } else { - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, (SValue){.val = *(int64_t*)var}); + SColVal cv = COL_VAL_VALUE(pCol->colId, ((SValue){.type = pCol->type, .val = *(int64_t*)var})); taosArrayPush(pVals, &cv); } break; @@ -2057,9 +2058,10 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); taosArrayPush(pVals, &cv); } else { - void* data = colDataGetVarData(pColInfoData, j); - SValue sv = (SValue){.nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); + void* data = colDataGetVarData(pColInfoData, j); + SValue sv = (SValue){ + .type = pCol->type, .nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value + SColVal cv = COL_VAL_VALUE(pCol->colId, sv); taosArrayPush(pVals, &cv); } break; @@ -2077,7 +2079,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); // should use pCol->type taosArrayPush(pVals, &cv); } else { - SValue sv; + SValue sv = {.type = pCol->type}; if (pCol->type == pColInfoData->info.type) { memcpy(&sv.val, var, tDataTypes[pCol->type].bytes); } else { @@ -2105,7 +2107,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat } memcpy(&sv.val, tv, tDataTypes[pCol->type].bytes); } - SColVal cv = COL_VAL_VALUE(pCol->colId, pColInfoData->info.type, sv); + SColVal cv = COL_VAL_VALUE(pCol->colId, sv); taosArrayPush(pVals, &cv); } } else { @@ -2141,9 +2143,9 @@ _end: return TSDB_CODE_SUCCESS; } -void buildCtbNameAddGroupId(char* ctbName, uint64_t groupId){ +void buildCtbNameAddGroupId(char* ctbName, uint64_t groupId) { char tmp[TSDB_TABLE_NAME_LEN] = {0}; - snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%"PRIu64, groupId); + snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%" PRIu64, groupId); ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put groupId to the end strcat(ctbName, tmp); } @@ -2199,7 +2201,7 @@ int32_t buildCtbNameByGroupIdImpl(const char* stbFullName, uint64_t groupId, cha int8_t type = TSDB_DATA_TYPE_UBIGINT; const char* name = "group_id"; int32_t len = strlen(name); - SSmlKv pTag = { .key = name, .keyLen = len, .type = type, .u = groupId, .length = sizeof(uint64_t)}; + SSmlKv pTag = {.key = name, .keyLen = len, .type = type, .u = groupId, .length = sizeof(uint64_t)}; taosArrayPush(tags, &pTag); RandTableName rname = { @@ -2581,7 +2583,7 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo) { pOrder->compFn = getKeyComparFunc(pOrder->pColData->info.type, pOrder->order); } SSDataBlockSortHelper sortHelper = {.orderInfo = pOrderInfo, .pDataBlock = pDataBlock}; - int32_t rowIdx = 0, nextRowIdx = 1; + int32_t rowIdx = 0, nextRowIdx = 1; for (; rowIdx < pDataBlock->info.rows && nextRowIdx < pDataBlock->info.rows; ++rowIdx, ++nextRowIdx) { if (dataBlockCompar(&nextRowIdx, &rowIdx, &sortHelper) < 0) { break; diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index b98c89542a..af124f7a02 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -16,54 +16,19 @@ #define _DEFAULT_SOURCE #include "tdataformat.h" #include "tRealloc.h" -#include "tcoding.h" #include "tdatablock.h" #include "tlog.h" static int32_t (*tColDataAppendValueImpl[8][3])(SColData *pColData, uint8_t *pData, uint32_t nData); static int32_t (*tColDataUpdateValueImpl[8][3])(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward); -// SBuffer ================================ -#ifdef BUILD_NO_CALL -void tBufferDestroy(SBuffer *pBuffer) { - tFree(pBuffer->pBuf); - pBuffer->pBuf = NULL; -} - -int32_t tBufferInit(SBuffer *pBuffer, int64_t size) { - pBuffer->nBuf = 0; - return tRealloc(&pBuffer->pBuf, size); -} - -int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData) { - int32_t code = 0; - - code = tRealloc(&pBuffer->pBuf, pBuffer->nBuf + nData); - if (code) return code; - - memcpy(pBuffer->pBuf + pBuffer->nBuf, pData, nData); - pBuffer->nBuf += nData; - - return code; -} - -int32_t tBufferReserve(SBuffer *pBuffer, int64_t nData, void **ppData) { - int32_t code = tRealloc(&pBuffer->pBuf, pBuffer->nBuf + nData); - if (code) return code; - - *ppData = pBuffer->pBuf + pBuffer->nBuf; - pBuffer->nBuf += nData; - - return code; -} -#endif // ================================ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson); // SRow ======================================================================== #define KV_FLG_LIT ((uint8_t)0x10) #define KV_FLG_MID ((uint8_t)0x20) -#define KV_FLG_BIG ((uint8_t)0x30) +#define KV_FLG_BIG ((uint8_t)0x40) #define BIT_FLG_NONE ((uint8_t)0x0) #define BIT_FLG_NULL ((uint8_t)0x1) @@ -72,308 +37,385 @@ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson); #pragma pack(push, 1) typedef struct { int16_t nCol; - char idx[]; // uint8_t * | uint16_t * | uint32_t * + uint8_t idx[]; // uint8_t * | uint16_t * | uint32_t * } SKVIdx; #pragma pack(pop) -#define ROW_SET_BITMAP(PB, FLAG, IDX, VAL) \ - do { \ - if (PB) { \ - switch (FLAG) { \ - case (HAS_NULL | HAS_NONE): \ - SET_BIT1(PB, IDX, VAL); \ - break; \ - case (HAS_VALUE | HAS_NONE): \ - SET_BIT1(PB, IDX, (VAL) ? (VAL)-1 : 0); \ - break; \ - case (HAS_VALUE | HAS_NULL): \ - SET_BIT1(PB, IDX, (VAL)-1); \ - break; \ - case (HAS_VALUE | HAS_NULL | HAS_NONE): \ - SET_BIT2(PB, IDX, VAL); \ - break; \ - default: \ - ASSERT(0); \ - break; \ - } \ - } \ +#define ROW_SET_BITMAP(PB, FLAG, IDX, VAL) \ + do { \ + switch (FLAG) { \ + case (HAS_NULL | HAS_NONE): \ + SET_BIT1(PB, IDX, VAL); \ + break; \ + case (HAS_VALUE | HAS_NONE): \ + SET_BIT1(PB, IDX, (VAL) ? (VAL)-1 : 0); \ + break; \ + case (HAS_VALUE | HAS_NULL): \ + SET_BIT1(PB, IDX, (VAL)-1); \ + break; \ + case (HAS_VALUE | HAS_NULL | HAS_NONE): \ + SET_BIT2(PB, IDX, VAL); \ + break; \ + default: \ + break; \ + } \ } while (0) -int32_t tRowBuild(SArray *aColVal, const STSchema *pTSchema, SRow **ppRow) { - int32_t code = 0; +static int32_t tPutPrimaryKeyIndex(uint8_t *p, const SPrimaryKeyIndex *index) { + int32_t n = 0; + n += tPutI8(p ? p + n : p, index->type); + n += tPutU32v(p ? p + n : p, index->offset); + return n; +} - ASSERT(TARRAY_SIZE(aColVal) > 0); - ASSERT(((SColVal *)aColVal->pData)[0].cid == PRIMARYKEY_TIMESTAMP_COL_ID); - ASSERT(((SColVal *)aColVal->pData)[0].type == TSDB_DATA_TYPE_TIMESTAMP); +static int32_t tGetPrimaryKeyIndex(uint8_t *p, SPrimaryKeyIndex *index) { + int32_t n = 0; + n += tGetI8(p + n, &index->type); + n += tGetU32v(p + n, &index->offset); + return n; +} - // scan --------------- - SRow *pRow = NULL; - SColVal *colVals = (SColVal *)TARRAY_DATA(aColVal); - uint8_t flag = 0; - int32_t iColVal = 1; - const int32_t nColVal = TARRAY_SIZE(aColVal); - SColVal *pColVal = (iColVal < nColVal) ? &colVals[iColVal] : NULL; - int32_t iTColumn = 1; - const STColumn *pTColumn = pTSchema->columns + iTColumn; - int32_t ntp = 0; - int32_t nkv = 0; - int32_t maxIdx = 0; - int32_t nIdx = 0; - while (pTColumn) { - if (pColVal) { - if (pColVal->cid == pTColumn->colId) { - if (COL_VAL_IS_VALUE(pColVal)) { // VALUE - flag |= HAS_VALUE; - maxIdx = nkv; - if (IS_VAR_DATA_TYPE(pTColumn->type)) { - ntp = ntp + tPutU32v(NULL, pColVal->value.nData) + pColVal->value.nData; - nkv = nkv + tPutI16v(NULL, pTColumn->colId) + tPutU32v(NULL, pColVal->value.nData) + pColVal->value.nData; - } else { - nkv = nkv + tPutI16v(NULL, pTColumn->colId) + pTColumn->bytes; - } - nIdx++; - } else if (COL_VAL_IS_NONE(pColVal)) { // NONE - flag |= HAS_NONE; - } else if (COL_VAL_IS_NULL(pColVal)) { // NULL - flag |= HAS_NULL; - maxIdx = nkv; - nkv += tPutI16v(NULL, -pTColumn->colId); - nIdx++; - } else { - if (ASSERTS(0, "invalid input")) { - code = TSDB_CODE_INVALID_PARA; - goto _exit; - } +typedef struct { + int32_t numOfNone; + int32_t numOfNull; + int32_t numOfValue; + int32_t numOfPKs; + int8_t flag; + + // tuple + int8_t tupleFlag; + SPrimaryKeyIndex tupleIndices[TD_MAX_PK_COLS]; + int32_t tuplePKSize; // primary key size + int32_t tupleBitmapSize; // bitmap size + int32_t tupleFixedSize; // fixed part size + int32_t tupleVarSize; // var part size + int32_t tupleRowSize; + + // key-value + int8_t kvFlag; + SPrimaryKeyIndex kvIndices[TD_MAX_PK_COLS]; + int32_t kvMaxOffset; + int32_t kvPKSize; // primary key size + int32_t kvIndexSize; // offset array size + int32_t kvPayloadSize; // payload size + int32_t kvRowSize; +} SRowBuildScanInfo; + +static FORCE_INLINE void tRowBuildScanAddNone(SRowBuildScanInfo *sinfo, const STColumn *pTColumn) { + ASSERT((pTColumn->flags & COL_IS_KEY) == 0); + sinfo->numOfNone++; +} + +static FORCE_INLINE void tRowBuildScanAddNull(SRowBuildScanInfo *sinfo, const STColumn *pTColumn) { + ASSERT((pTColumn->flags & COL_IS_KEY) == 0); + sinfo->numOfNull++; + sinfo->kvMaxOffset = sinfo->kvPayloadSize; + sinfo->kvPayloadSize += tPutI16v(NULL, -pTColumn->colId); +} + +static FORCE_INLINE void tRowBuildScanAddValue(SRowBuildScanInfo *sinfo, SColVal *colVal, const STColumn *pTColumn) { + bool isPK = ((pTColumn->flags & COL_IS_KEY) != 0); + + if (isPK) { + ASSERTS(sinfo->numOfPKs < TD_MAX_PK_COLS, "too many primary keys"); + sinfo->tupleIndices[sinfo->numOfPKs].type = colVal->value.type; + sinfo->tupleIndices[sinfo->numOfPKs].offset = + IS_VAR_DATA_TYPE(pTColumn->type) ? sinfo->tupleVarSize + sinfo->tupleFixedSize : pTColumn->offset; + sinfo->kvIndices[sinfo->numOfPKs].type = colVal->value.type; + sinfo->kvIndices[sinfo->numOfPKs].offset = sinfo->kvPayloadSize; + sinfo->numOfPKs++; + } + + sinfo->kvMaxOffset = sinfo->kvPayloadSize; + if (IS_VAR_DATA_TYPE(colVal->value.type)) { + sinfo->tupleVarSize += tPutU32v(NULL, colVal->value.nData) // size + + colVal->value.nData; // value + + sinfo->kvPayloadSize += tPutI16v(NULL, colVal->cid) // colId + + tPutU32v(NULL, colVal->value.nData) // size + + colVal->value.nData; // value + } else { + sinfo->kvPayloadSize += tPutI16v(NULL, colVal->cid) // colId + + tDataTypes[colVal->value.type].bytes; // value + } + sinfo->numOfValue++; +} + +static int32_t tRowBuildScan(SArray *colVals, const STSchema *schema, SRowBuildScanInfo *sinfo) { + int32_t colValIndex = 1; + int32_t numOfColVals = TARRAY_SIZE(colVals); + SColVal *colValArray = (SColVal *)TARRAY_DATA(colVals); + + ASSERT(numOfColVals > 0); + ASSERT(colValArray[0].cid == PRIMARYKEY_TIMESTAMP_COL_ID); + ASSERT(colValArray[0].value.type == TSDB_DATA_TYPE_TIMESTAMP); + + *sinfo = (SRowBuildScanInfo){ + .tupleFixedSize = schema->flen, + }; + + // loop scan + for (int32_t i = 1; i < schema->numOfCols; i++) { + for (;;) { + if (colValIndex >= numOfColVals) { + tRowBuildScanAddNone(sinfo, schema->columns + i); + break; + } + + if (colValArray[colValIndex].cid == schema->columns[i].colId) { + ASSERT(colValArray[colValIndex].value.type == schema->columns[i].type); + + if (COL_VAL_IS_VALUE(&colValArray[colValIndex])) { + tRowBuildScanAddValue(sinfo, &colValArray[colValIndex], schema->columns + i); + } else if (COL_VAL_IS_NULL(&colValArray[colValIndex])) { + tRowBuildScanAddNull(sinfo, schema->columns + i); + } else if (COL_VAL_IS_NONE(&colValArray[colValIndex])) { + tRowBuildScanAddNone(sinfo, schema->columns + i); } - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; - pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; - } else if (pColVal->cid > pTColumn->colId) { // NONE - flag |= HAS_NONE; - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; - } else { - pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; + colValIndex++; + break; + } else if (colValArray[colValIndex].cid > schema->columns[i].colId) { + tRowBuildScanAddNone(sinfo, schema->columns + i); + break; + } else { // skip useless value + colValIndex++; } - } else { // NONE - flag |= HAS_NONE; - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; } } - // compare --------------- - switch (flag) { + if (sinfo->numOfNone) { + sinfo->flag |= HAS_NONE; + } + if (sinfo->numOfNull) { + sinfo->flag |= HAS_NULL; + } + if (sinfo->numOfValue) { + sinfo->flag |= HAS_VALUE; + } + + // Tuple + sinfo->tupleFlag = sinfo->flag; + switch (sinfo->flag) { case HAS_NONE: case HAS_NULL: - ntp = sizeof(SRow); + sinfo->tupleBitmapSize = 0; + sinfo->tupleFixedSize = 0; break; case HAS_VALUE: - ntp = sizeof(SRow) + pTSchema->flen + ntp; + sinfo->tupleBitmapSize = 0; + sinfo->tupleFixedSize = schema->flen; break; - case (HAS_NULL | HAS_NONE): - ntp = sizeof(SRow) + BIT1_SIZE(pTSchema->numOfCols - 1); + case (HAS_NONE | HAS_NULL): + sinfo->tupleBitmapSize = BIT1_SIZE(schema->numOfCols - 1); + sinfo->tupleFixedSize = 0; break; - case (HAS_VALUE | HAS_NONE): - case (HAS_VALUE | HAS_NULL): - ntp = sizeof(SRow) + BIT1_SIZE(pTSchema->numOfCols - 1) + pTSchema->flen + ntp; + case (HAS_NONE | HAS_VALUE): + case (HAS_NULL | HAS_VALUE): + sinfo->tupleBitmapSize = BIT1_SIZE(schema->numOfCols - 1); + sinfo->tupleFixedSize = schema->flen; break; - case (HAS_VALUE | HAS_NULL | HAS_NONE): - ntp = sizeof(SRow) + BIT2_SIZE(pTSchema->numOfCols - 1) + pTSchema->flen + ntp; + case (HAS_NONE | HAS_NULL | HAS_VALUE): + sinfo->tupleBitmapSize = BIT2_SIZE(schema->numOfCols - 1); + sinfo->tupleFixedSize = schema->flen; break; - default: - if (ASSERTS(0, "impossible")) { - code = TSDB_CODE_INVALID_PARA; - goto _exit; + } + for (int32_t i = 0; i < sinfo->numOfPKs; i++) { + sinfo->tupleIndices[i].offset += sinfo->tupleBitmapSize; + sinfo->tuplePKSize += tPutPrimaryKeyIndex(NULL, sinfo->tupleIndices + i); + } + sinfo->tupleRowSize = sizeof(SRow) // SRow + + sinfo->tuplePKSize // primary keys + + sinfo->tupleBitmapSize // bitmap + + sinfo->tupleFixedSize // fixed part + + sinfo->tupleVarSize; // var part + + // Key-Value + if (sinfo->kvMaxOffset <= UINT8_MAX) { + sinfo->kvFlag = (KV_FLG_LIT | sinfo->flag); + sinfo->kvIndexSize = sizeof(SKVIdx) + (sinfo->numOfNull + sinfo->numOfValue) * sizeof(uint8_t); + } else if (sinfo->kvMaxOffset <= UINT16_MAX) { + sinfo->kvFlag = (KV_FLG_MID | sinfo->flag); + sinfo->kvIndexSize = sizeof(SKVIdx) + (sinfo->numOfNull + sinfo->numOfValue) * sizeof(uint16_t); + } else { + sinfo->kvFlag = (KV_FLG_BIG | sinfo->flag); + sinfo->kvIndexSize = sizeof(SKVIdx) + (sinfo->numOfNull + sinfo->numOfValue) * sizeof(uint32_t); + } + for (int32_t i = 0; i < sinfo->numOfPKs; i++) { + sinfo->kvIndices[i].offset += sinfo->kvIndexSize; + sinfo->kvPKSize += tPutPrimaryKeyIndex(NULL, sinfo->kvIndices + i); + } + sinfo->kvRowSize = sizeof(SRow) // SRow + + sinfo->kvPKSize // primary keys + + sinfo->kvIndexSize // index array + + sinfo->kvPayloadSize; // payload + + return 0; +} + +static int32_t tRowBuildTupleRow(SArray *aColVal, const SRowBuildScanInfo *sinfo, const STSchema *schema, + SRow **ppRow) { + SColVal *colValArray = (SColVal *)TARRAY_DATA(aColVal); + + *ppRow = (SRow *)taosMemoryCalloc(1, sinfo->tupleRowSize); + if (*ppRow == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (*ppRow)->flag = sinfo->tupleFlag; + (*ppRow)->numOfPKs = sinfo->numOfPKs; + (*ppRow)->sver = schema->version; + (*ppRow)->len = sinfo->tupleRowSize; + (*ppRow)->ts = colValArray[0].value.val; + + if (sinfo->tupleFlag == HAS_NONE || sinfo->tupleFlag == HAS_NULL) { + ASSERT(sinfo->tupleRowSize == sizeof(SRow)); + return 0; + } + + uint8_t *primaryKeys = (*ppRow)->data; + uint8_t *bitmap = primaryKeys + sinfo->tuplePKSize; + uint8_t *fixed = bitmap + sinfo->tupleBitmapSize; + uint8_t *varlen = fixed + sinfo->tupleFixedSize; + + // primary keys + for (int32_t i = 0; i < sinfo->numOfPKs; i++) { + primaryKeys += tPutPrimaryKeyIndex(primaryKeys, sinfo->tupleIndices + i); + } + ASSERT(primaryKeys == bitmap); + + // bitmap + fixed + varlen + int32_t numOfColVals = TARRAY_SIZE(aColVal); + int32_t colValIndex = 1; + for (int32_t i = 1; i < schema->numOfCols; i++) { + for (;;) { + if (colValIndex >= numOfColVals) { // NONE + ROW_SET_BITMAP(bitmap, sinfo->tupleFlag, i - 1, BIT_FLG_NONE); + break; } - } - if (maxIdx <= UINT8_MAX) { - nkv = sizeof(SRow) + sizeof(SKVIdx) + nIdx + nkv; - flag |= KV_FLG_LIT; - } else if (maxIdx <= UINT16_MAX) { - nkv = sizeof(SRow) + sizeof(SKVIdx) + (nIdx << 1) + nkv; - flag |= KV_FLG_MID; - } else { - nkv = sizeof(SRow) + sizeof(SKVIdx) + (nIdx << 2) + nkv; - flag |= KV_FLG_BIG; - } - int32_t nRow; - if (nkv < ntp) { - nRow = nkv; - } else { - nRow = ntp; - flag &= ((uint8_t)0x0f); - } - // alloc -------------- - pRow = taosMemoryMalloc(nRow); - if (NULL == pRow) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + if (colValArray[colValIndex].cid == schema->columns[i].colId) { + if (COL_VAL_IS_VALUE(&colValArray[colValIndex])) { // value + ROW_SET_BITMAP(bitmap, sinfo->tupleFlag, i - 1, BIT_FLG_VALUE); - // build -------------- - pColVal = &colVals[0]; - - pRow->flag = flag; - pRow->rsv = 0; - pRow->sver = pTSchema->version; - pRow->len = nRow; - memcpy(&pRow->ts, &pColVal->value.val, sizeof(TSKEY)); - - if (flag == HAS_NONE || flag == HAS_NULL) { - goto _exit; - } - - iColVal = 1; - pColVal = (iColVal < nColVal) ? &colVals[iColVal] : NULL; - iTColumn = 1; - pTColumn = pTSchema->columns + iTColumn; - if (flag >> 4) { // KV - SKVIdx *pIdx = (SKVIdx *)pRow->data; - int32_t iIdx = 0; - int32_t nv = 0; - uint8_t *pv = NULL; - if (flag & KV_FLG_LIT) { - pv = pIdx->idx + nIdx; - } else if (flag & KV_FLG_MID) { - pv = pIdx->idx + (nIdx << 1); - } else { - pv = pIdx->idx + (nIdx << 2); - } - pIdx->nCol = nIdx; - - while (pTColumn) { - if (pColVal) { - if (pColVal->cid == pTColumn->colId) { - if (COL_VAL_IS_VALUE(pColVal)) { - if (flag & KV_FLG_LIT) { - ((uint8_t *)pIdx->idx)[iIdx] = (uint8_t)nv; - } else if (flag & KV_FLG_MID) { - ((uint16_t *)pIdx->idx)[iIdx] = (uint16_t)nv; - } else { - ((uint32_t *)pIdx->idx)[iIdx] = (uint32_t)nv; + if (IS_VAR_DATA_TYPE(schema->columns[i].type)) { + *(int32_t *)(fixed + schema->columns[i].offset) = varlen - fixed - sinfo->tupleFixedSize; + varlen += tPutU32v(varlen, colValArray[colValIndex].value.nData); + if (colValArray[colValIndex].value.nData) { + memcpy(varlen, colValArray[colValIndex].value.pData, colValArray[colValIndex].value.nData); + varlen += colValArray[colValIndex].value.nData; } - iIdx++; - - nv += tPutI16v(pv + nv, pTColumn->colId); - if (IS_VAR_DATA_TYPE(pTColumn->type)) { - nv += tPutU32v(pv + nv, pColVal->value.nData); - memcpy(pv + nv, pColVal->value.pData, pColVal->value.nData); - nv += pColVal->value.nData; - } else { - memcpy(pv + nv, &pColVal->value.val, pTColumn->bytes); - nv += pTColumn->bytes; - } - } else if (COL_VAL_IS_NULL(pColVal)) { - if (flag & KV_FLG_LIT) { - ((uint8_t *)pIdx->idx)[iIdx] = (uint8_t)nv; - } else if (flag & KV_FLG_MID) { - ((uint16_t *)pIdx->idx)[iIdx] = (uint16_t)nv; - } else { - ((uint32_t *)pIdx->idx)[iIdx] = (uint32_t)nv; - } - iIdx++; - nv += tPutI16v(pv + nv, -pTColumn->colId); + } else { + memcpy(fixed + schema->columns[i].offset, &colValArray[colValIndex].value.val, + tDataTypes[schema->columns[i].type].bytes); } - - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; - pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; - } else if (pColVal->cid > pTColumn->colId) { // NONE - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; - } else { - pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; + } else if (COL_VAL_IS_NULL(&colValArray[colValIndex])) { // NULL + ROW_SET_BITMAP(bitmap, sinfo->tupleFlag, i - 1, BIT_FLG_NULL); + } else if (COL_VAL_IS_NONE(&colValArray[colValIndex])) { // NONE + ROW_SET_BITMAP(bitmap, sinfo->tupleFlag, i - 1, BIT_FLG_NONE); } - } else { // NONE - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; - } - } - } else { // TUPLE - uint8_t *pb = NULL; - uint8_t *pf = NULL; - uint8_t *pv = NULL; - int32_t nv = 0; - switch (flag) { - case (HAS_NULL | HAS_NONE): - pb = pRow->data; + colValIndex++; break; - case HAS_VALUE: - pf = pRow->data; - pv = pf + pTSchema->flen; + } else if (colValArray[colValIndex].cid > schema->columns[i].colId) { // NONE + ROW_SET_BITMAP(bitmap, sinfo->tupleFlag, i - 1, BIT_FLG_NONE); break; - case (HAS_VALUE | HAS_NONE): - case (HAS_VALUE | HAS_NULL): - pb = pRow->data; - pf = pb + BIT1_SIZE(pTSchema->numOfCols - 1); - pv = pf + pTSchema->flen; - break; - case (HAS_VALUE | HAS_NULL | HAS_NONE): - pb = pRow->data; - pf = pb + BIT2_SIZE(pTSchema->numOfCols - 1); - pv = pf + pTSchema->flen; - break; - default: - if (ASSERTS(0, "impossible")) { - code = TSDB_CODE_INVALID_PARA; - goto _exit; - } - } - - if (pb) { - if (flag == (HAS_VALUE | HAS_NULL | HAS_NONE)) { - memset(pb, 0, BIT2_SIZE(pTSchema->numOfCols - 1)); } else { - memset(pb, 0, BIT1_SIZE(pTSchema->numOfCols - 1)); - } - } - - // build impl - while (pTColumn) { - if (pColVal) { - if (pColVal->cid == pTColumn->colId) { - if (COL_VAL_IS_VALUE(pColVal)) { // VALUE - ROW_SET_BITMAP(pb, flag, iTColumn - 1, BIT_FLG_VALUE); - - if (IS_VAR_DATA_TYPE(pTColumn->type)) { - *(int32_t *)(pf + pTColumn->offset) = nv; - nv += tPutU32v(pv + nv, pColVal->value.nData); - if (pColVal->value.nData) { - memcpy(pv + nv, pColVal->value.pData, pColVal->value.nData); - nv += pColVal->value.nData; - } - } else { - memcpy(pf + pTColumn->offset, &pColVal->value.val, TYPE_BYTES[pTColumn->type]); - } - } else if (COL_VAL_IS_NONE(pColVal)) { // NONE - ROW_SET_BITMAP(pb, flag, iTColumn - 1, BIT_FLG_NONE); - if (pf) memset(pf + pTColumn->offset, 0, TYPE_BYTES[pTColumn->type]); - } else { // NULL - ROW_SET_BITMAP(pb, flag, iTColumn - 1, BIT_FLG_NULL); - if (pf) memset(pf + pTColumn->offset, 0, TYPE_BYTES[pTColumn->type]); - } - - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; - pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; - } else if (pColVal->cid > pTColumn->colId) { // NONE - ROW_SET_BITMAP(pb, flag, iTColumn - 1, BIT_FLG_NONE); - if (pf) memset(pf + pTColumn->offset, 0, TYPE_BYTES[pTColumn->type]); - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; - } else { - pColVal = (++iColVal < nColVal) ? &colVals[iColVal] : NULL; - } - } else { // NONE - ROW_SET_BITMAP(pb, flag, iTColumn - 1, BIT_FLG_NONE); - if (pf) memset(pf + pTColumn->offset, 0, TYPE_BYTES[pTColumn->type]); - pTColumn = (++iTColumn < pTSchema->numOfCols) ? pTSchema->columns + iTColumn : NULL; + colValIndex++; } } } -_exit: - if (code) { - *ppRow = NULL; - tRowDestroy(pRow); + return 0; +} + +static FORCE_INLINE void tRowBuildKVRowSetIndex(uint8_t flag, SKVIdx *indices, uint32_t offset) { + if (flag & KV_FLG_LIT) { + ((uint8_t *)indices->idx)[indices->nCol] = (uint8_t)offset; + } else if (flag & KV_FLG_MID) { + ((uint16_t *)indices->idx)[indices->nCol] = (uint16_t)offset; } else { - *ppRow = pRow; + ((uint32_t *)indices->idx)[indices->nCol] = (uint32_t)offset; + } + indices->nCol++; +} + +static int32_t tRowBuildKVRow(SArray *aColVal, const SRowBuildScanInfo *sinfo, const STSchema *schema, SRow **ppRow) { + SColVal *colValArray = (SColVal *)TARRAY_DATA(aColVal); + + *ppRow = (SRow *)taosMemoryCalloc(1, sinfo->kvRowSize); + if (*ppRow == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (*ppRow)->flag = sinfo->kvFlag; + (*ppRow)->numOfPKs = sinfo->numOfPKs; + (*ppRow)->sver = schema->version; + (*ppRow)->len = sinfo->kvRowSize; + (*ppRow)->ts = colValArray[0].value.val; + + ASSERT(sinfo->flag != HAS_NONE && sinfo->flag != HAS_NULL); + + uint8_t *primaryKeys = (*ppRow)->data; + SKVIdx *indices = (SKVIdx *)(primaryKeys + sinfo->kvPKSize); + uint8_t *payload = primaryKeys + sinfo->kvPKSize + sinfo->kvIndexSize; + uint32_t payloadSize = 0; + + // primary keys + for (int32_t i = 0; i < sinfo->numOfPKs; i++) { + primaryKeys += tPutPrimaryKeyIndex(primaryKeys, sinfo->kvIndices + i); + } + ASSERT(primaryKeys == (uint8_t *)indices); + + int32_t numOfColVals = TARRAY_SIZE(aColVal); + int32_t colValIndex = 1; + for (int32_t i = 1; i < schema->numOfCols; i++) { + for (;;) { + if (colValIndex >= numOfColVals) { // NONE + break; + } + + if (colValArray[colValIndex].cid == schema->columns[i].colId) { + if (COL_VAL_IS_VALUE(&colValArray[colValIndex])) { // value + tRowBuildKVRowSetIndex(sinfo->kvFlag, indices, payloadSize); + if (IS_VAR_DATA_TYPE(schema->columns[i].type)) { + payloadSize += tPutI16v(payload + payloadSize, colValArray[colValIndex].cid); + payloadSize += tPutU32v(payload + payloadSize, colValArray[colValIndex].value.nData); + memcpy(payload + payloadSize, colValArray[colValIndex].value.pData, colValArray[colValIndex].value.nData); + payloadSize += colValArray[colValIndex].value.nData; + } else { + payloadSize += tPutI16v(payload + payloadSize, colValArray[colValIndex].cid); + memcpy(payload + payloadSize, &colValArray[colValIndex].value.val, + tDataTypes[schema->columns[i].type].bytes); + payloadSize += tDataTypes[schema->columns[i].type].bytes; + } + } else if (COL_VAL_IS_NULL(&colValArray[colValIndex])) { // NULL + tRowBuildKVRowSetIndex(sinfo->kvFlag, indices, payloadSize); + payloadSize += tPutI16v(payload + payloadSize, -schema->columns[i].colId); + } + + colValIndex++; + break; + } else if (colValArray[colValIndex].cid > schema->columns[i].colId) { // NONE + break; + } else { + colValIndex++; + } + } + } + + return 0; +} + +int32_t tRowBuild(SArray *aColVal, const STSchema *pTSchema, SRow **ppRow) { + int32_t code; + SRowBuildScanInfo sinfo; + + code = tRowBuildScan(aColVal, pTSchema, &sinfo); + if (code) return code; + + if (sinfo.tupleRowSize <= sinfo.kvRowSize) { + code = tRowBuildTupleRow(aColVal, &sinfo, pTSchema, ppRow); + } else { + code = tRowBuildKVRow(aColVal, &sinfo, pTSchema, ppRow); } return code; } @@ -386,7 +428,7 @@ int32_t tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) if (iCol == 0) { pColVal->cid = pTColumn->colId; - pColVal->type = pTColumn->type; + pColVal->value.type = pTColumn->type; pColVal->flag = CV_FLAG_VALUE; memcpy(&pColVal->value.val, &pRow->ts, sizeof(TSKEY)); return 0; @@ -402,9 +444,16 @@ int32_t tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) return 0; } + SPrimaryKeyIndex index; + uint8_t *data = pRow->data; + for (int32_t i = 0; i < pRow->numOfPKs; i++) { + data += tGetPrimaryKeyIndex(data, &index); + } + if (pRow->flag >> 4) { // KV Row - SKVIdx *pIdx = (SKVIdx *)pRow->data; + SKVIdx *pIdx = (SKVIdx *)data; uint8_t *pv = NULL; + if (pRow->flag & KV_FLG_LIT) { pv = pIdx->idx + pIdx->nCol; } else if (pRow->flag & KV_FLG_MID) { @@ -434,7 +483,7 @@ int32_t tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) *pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type); } else { pColVal->cid = pTColumn->colId; - pColVal->type = pTColumn->type; + pColVal->value.type = pTColumn->type; pColVal->flag = CV_FLAG_VALUE; if (IS_VAR_DATA_TYPE(pTColumn->type)) { @@ -458,74 +507,45 @@ int32_t tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) *pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type); } else { // Tuple Row + uint8_t *bitmap = data; + uint8_t *fixed; + uint8_t *varlen; + uint8_t bit; + if (pRow->flag == HAS_VALUE) { - pColVal->cid = pTColumn->colId; - pColVal->type = pTColumn->type; - pColVal->flag = CV_FLAG_VALUE; - if (IS_VAR_DATA_TYPE(pTColumn->type)) { - uint8_t *pData = pRow->data + pTSchema->flen + *(int32_t *)(pRow->data + pTColumn->offset); - pData += tGetU32v(pData, &pColVal->value.nData); - if (pColVal->value.nData) { - pColVal->value.pData = pData; - } else { - pColVal->value.pData = NULL; - } - } else { - memcpy(&pColVal->value.val, pRow->data + pTColumn->offset, TYPE_BYTES[pTColumn->type]); - } + fixed = bitmap; + bit = BIT_FLG_VALUE; + } else if (pRow->flag == (HAS_NONE | HAS_NULL | HAS_VALUE)) { + fixed = BIT2_SIZE(pTSchema->numOfCols - 1) + bitmap; + bit = GET_BIT2(bitmap, iCol - 1); } else { - uint8_t *pf; - uint8_t *pv; - uint8_t bv = BIT_FLG_VALUE; + fixed = BIT1_SIZE(pTSchema->numOfCols - 1) + bitmap; + bit = GET_BIT1(bitmap, iCol - 1); - switch (pRow->flag) { - case (HAS_NULL | HAS_NONE): - bv = GET_BIT1(pRow->data, iCol - 1); - break; - case (HAS_VALUE | HAS_NONE): - bv = GET_BIT1(pRow->data, iCol - 1); - if (bv) bv++; - pf = pRow->data + BIT1_SIZE(pTSchema->numOfCols - 1); - pv = pf + pTSchema->flen; - break; - case (HAS_VALUE | HAS_NULL): - bv = GET_BIT1(pRow->data, iCol - 1); - bv++; - pf = pRow->data + BIT1_SIZE(pTSchema->numOfCols - 1); - pv = pf + pTSchema->flen; - break; - case (HAS_VALUE | HAS_NULL | HAS_NONE): - bv = GET_BIT2(pRow->data, iCol - 1); - pf = pRow->data + BIT2_SIZE(pTSchema->numOfCols - 1); - pv = pf + pTSchema->flen; - break; - default: - ASSERTS(0, "invalid row format"); - return TSDB_CODE_INVALID_DATA_FMT; + if (pRow->flag == (HAS_NONE | HAS_VALUE)) { + if (bit) bit++; + } else if (pRow->flag == (HAS_NULL | HAS_VALUE)) { + bit++; } + } + varlen = fixed + pTSchema->flen; - if (bv == BIT_FLG_NONE) { - *pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type); - return 0; - } else if (bv == BIT_FLG_NULL) { - *pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type); - return 0; - } + if (bit == BIT_FLG_NONE) { + *pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type); + return 0; + } else if (bit == BIT_FLG_NULL) { + *pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type); + return 0; + } - pColVal->cid = pTColumn->colId; - pColVal->type = pTColumn->type; - pColVal->flag = CV_FLAG_VALUE; - if (IS_VAR_DATA_TYPE(pTColumn->type)) { - uint8_t *pData = pv + *(int32_t *)(pf + pTColumn->offset); - pData += tGetU32v(pData, &pColVal->value.nData); - if (pColVal->value.nData) { - pColVal->value.pData = pData; - } else { - pColVal->value.pData = NULL; - } - } else { - memcpy(&pColVal->value.val, pf + pTColumn->offset, TYPE_BYTES[pTColumn->type]); - } + pColVal->cid = pTColumn->colId; + pColVal->value.type = pTColumn->type; + pColVal->flag = CV_FLAG_VALUE; + if (IS_VAR_DATA_TYPE(pTColumn->type)) { + pColVal->value.pData = varlen + *(int32_t *)(fixed + pTColumn->offset); + pColVal->value.pData += tGetU32v(pColVal->value.pData, &pColVal->value.nData); + } else { + memcpy(&pColVal->value.val, fixed + pTColumn->offset, TYPE_BYTES[pTColumn->type]); } } @@ -685,9 +705,15 @@ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) { if (pRow->flag == HAS_NONE || pRow->flag == HAS_NULL) goto _exit; + uint8_t *data = pRow->data; + SPrimaryKeyIndex index; + for (int32_t i = 0; i < pRow->numOfPKs; i++) { + data += tGetPrimaryKeyIndex(data, &index); + } + if (pRow->flag >> 4) { pIter->iCol = 0; - pIter->pIdx = (SKVIdx *)pRow->data; + pIter->pIdx = (SKVIdx *)data; if (pRow->flag & KV_FLG_LIT) { pIter->pv = pIter->pIdx->idx + pIter->pIdx->nCol; } else if (pRow->flag & KV_FLG_MID) { @@ -698,21 +724,21 @@ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) { } else { switch (pRow->flag) { case (HAS_NULL | HAS_NONE): - pIter->pb = pRow->data; + pIter->pb = data; break; case HAS_VALUE: - pIter->pf = pRow->data; + pIter->pf = data; pIter->pv = pIter->pf + pTSchema->flen; break; case (HAS_VALUE | HAS_NONE): case (HAS_VALUE | HAS_NULL): - pIter->pb = pRow->data; - pIter->pf = pRow->data + BIT1_SIZE(pTSchema->numOfCols - 1); + pIter->pb = data; + pIter->pf = data + BIT1_SIZE(pTSchema->numOfCols - 1); pIter->pv = pIter->pf + pTSchema->flen; break; case (HAS_VALUE | HAS_NULL | HAS_NONE): - pIter->pb = pRow->data; - pIter->pf = pRow->data + BIT2_SIZE(pTSchema->numOfCols - 1); + pIter->pb = data; + pIter->pf = data + BIT2_SIZE(pTSchema->numOfCols - 1); pIter->pv = pIter->pf + pTSchema->flen; break; default: @@ -748,7 +774,7 @@ SColVal *tRowIterNext(SRowIter *pIter) { // timestamp if (0 == pIter->iTColumn) { pIter->cv.cid = pTColumn->colId; - pIter->cv.type = pTColumn->type; + pIter->cv.value.type = pTColumn->type; pIter->cv.flag = CV_FLAG_VALUE; memcpy(&pIter->cv.value.val, &pIter->pRow->ts, sizeof(TSKEY)); goto _exit; @@ -784,7 +810,7 @@ SColVal *tRowIterNext(SRowIter *pIter) { pIter->cv = COL_VAL_NULL(pTColumn->colId, pTColumn->type); } else { pIter->cv.cid = pTColumn->colId; - pIter->cv.type = pTColumn->type; + pIter->cv.value.type = pTColumn->type; pIter->cv.flag = CV_FLAG_VALUE; if (IS_VAR_DATA_TYPE(pTColumn->type)) { @@ -843,7 +869,7 @@ SColVal *tRowIterNext(SRowIter *pIter) { } pIter->cv.cid = pTColumn->colId; - pIter->cv.type = pTColumn->type; + pIter->cv.value.type = pTColumn->type; pIter->cv.flag = CV_FLAG_VALUE; if (IS_VAR_DATA_TYPE(pTColumn->type)) { uint8_t *pData = pIter->pv + *(int32_t *)(pIter->pf + pTColumn->offset); @@ -920,24 +946,29 @@ static int32_t tRowTupleUpsertColData(SRow *pRow, STSchema *pTSchema, SColData * int32_t iTColumn = 1; STColumn *pTColumn = &pTSchema->columns[iTColumn]; - uint8_t *pb = NULL, *pf = NULL, *pv = NULL; + uint8_t *pb = NULL, *pf = NULL, *pv = NULL; + SPrimaryKeyIndex index; + uint8_t *data = pRow->data; + for (int32_t i = 0; i < pRow->numOfPKs; i++) { + data += tGetPrimaryKeyIndex(data, &index); + } switch (pRow->flag) { case HAS_VALUE: - pf = pRow->data; + pf = data; // TODO: fix here pv = pf + pTSchema->flen; break; case (HAS_NULL | HAS_NONE): - pb = pRow->data; + pb = data; break; case (HAS_VALUE | HAS_NONE): case (HAS_VALUE | HAS_NULL): - pb = pRow->data; + pb = data; pf = pb + BIT1_SIZE(pTSchema->numOfCols - 1); pv = pf + pTSchema->flen; break; case (HAS_VALUE | HAS_NULL | HAS_NONE): - pb = pRow->data; + pb = data; pf = pb + BIT2_SIZE(pTSchema->numOfCols - 1); pv = pf + pTSchema->flen; break; @@ -1135,6 +1166,124 @@ int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, in } } +void tRowGetKey(SRow *row, SRowKey *key) { + key->ts = row->ts; + key->numOfPKs = row->numOfPKs; + + if (key->numOfPKs == 0) { + return; + } + + ASSERT(row->numOfPKs <= TD_MAX_PK_COLS); + + SPrimaryKeyIndex indices[TD_MAX_PK_COLS]; + + uint8_t *data = row->data; + + for (int32_t i = 0; i < row->numOfPKs; i++) { + data += tGetPrimaryKeyIndex(data, &indices[i]); + } + + // primary keys + for (int32_t i = 0; i < row->numOfPKs; i++) { + key->pks[i].type = indices[i].type; + + if (IS_VAR_DATA_TYPE(indices[i].type)) { + key->pks[i].pData = data + indices[i].offset; + key->pks[i].pData += tGetU32v(key->pks[i].pData, &key->pks[i].nData); + } else { + memcpy(&key->pks[i].val, data + indices[i].offset, tDataTypes[indices[i].type].bytes); + } + } +} + +#define T_COMPARE_SCALAR_VALUE(TYPE, V1, V2) \ + do { \ + if (*(TYPE *)(V1) < *(TYPE *)(V2)) { \ + return -1; \ + } else if (*(TYPE *)(V1) > *(TYPE *)(V2)) { \ + return 1; \ + } else { \ + return 0; \ + } \ + } while (0) + +int32_t tValueCompare(const SValue *tv1, const SValue *tv2) { + ASSERT(tv1->type == tv2->type); + + switch (tv1->type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + T_COMPARE_SCALAR_VALUE(int8_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_SMALLINT: + T_COMPARE_SCALAR_VALUE(int16_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_INT: + T_COMPARE_SCALAR_VALUE(int32_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_TIMESTAMP: + T_COMPARE_SCALAR_VALUE(int64_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_FLOAT: + T_COMPARE_SCALAR_VALUE(float, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_DOUBLE: + T_COMPARE_SCALAR_VALUE(double, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_UTINYINT: + T_COMPARE_SCALAR_VALUE(uint8_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_USMALLINT: + T_COMPARE_SCALAR_VALUE(uint16_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_UINT: + T_COMPARE_SCALAR_VALUE(uint32_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_UBIGINT: + T_COMPARE_SCALAR_VALUE(uint64_t, &tv1->val, &tv2->val); + case TSDB_DATA_TYPE_GEOMETRY: + case TSDB_DATA_TYPE_BINARY: { + return strcmp((const char *)tv1->pData, (const char *)tv2->pData); + } + case TSDB_DATA_TYPE_NCHAR: { + int32_t ret = tasoUcs4Compare((TdUcs4 *)tv1->pData, (TdUcs4 *)tv2->pData, + tv1->nData < tv2->nData ? tv1->nData : tv2->nData); + return ret ? ret : (tv1->nData < tv2->nData ? -1 : (tv1->nData > tv2->nData ? 1 : 0)); + } + case TSDB_DATA_TYPE_VARBINARY: { + int32_t ret = memcmp(tv1->pData, tv2->pData, tv1->nData < tv2->nData ? tv1->nData : tv2->nData); + return ret ? ret : (tv1->nData < tv2->nData ? -1 : (tv1->nData > tv2->nData ? 1 : 0)); + } + case TSDB_DATA_TYPE_DECIMAL: + ASSERT(0); + break; + default: + ASSERT(0); + } + + return 0; +} + +// NOTE: +// set key->numOfPKs to 0 as the smallest key with ts +// set key->numOfPKs to (TD_MAX_PK_COLS + 1) as the largest key with ts +int32_t tRowKeyCompare(const void *p1, const void *p2) { + SRowKey *key1 = (SRowKey *)p1; + SRowKey *key2 = (SRowKey *)p2; + + if (key1->ts < key2->ts) { + return -1; + } else if (key1->ts > key2->ts) { + return 1; + } + + if (key1->numOfPKs == key2->numOfPKs) { + for (uint8_t iKey = 0; iKey < key1->numOfPKs; iKey++) { + int32_t ret = tValueCompare(&key1->pks[iKey], &key2->pks[iKey]); + if (ret) return ret; + } + } else if (key1->numOfPKs < key2->numOfPKs) { + return -1; + } else { + return 1; + } + + return 0; +} + // STag ======================================== static int tTagValCmprFn(const void *p1, const void *p2) { if (((STagVal *)p1)->cid < ((STagVal *)p2)->cid) { @@ -1563,6 +1712,24 @@ STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version) { return pTSchema; } +static int32_t tTColumnCompare(const void *p1, const void *p2) { + if (((STColumn *)p1)->colId < ((STColumn *)p2)->colId) { + return -1; + } else if (((STColumn *)p1)->colId > ((STColumn *)p2)->colId) { + return 1; + } + + return 0; +} + +const STColumn *tTSchemaSearchColumn(const STSchema *pTSchema, int16_t cid) { + STColumn tcol = { + .colId = cid, + }; + + return taosbsearch(&tcol, pTSchema->columns, pTSchema->numOfCols, sizeof(STColumn), tTColumnCompare, TD_EQ); +} + // SColData ======================================== void tColDataDestroy(void *ph) { if (ph) { @@ -1574,10 +1741,10 @@ void tColDataDestroy(void *ph) { } } -void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn) { +void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t cflag) { pColData->cid = cid; pColData->type = type; - pColData->smaOn = smaOn; + pColData->cflag = cflag; tColDataClear(pColData); } @@ -1962,7 +2129,7 @@ static int32_t (*tColDataAppendValueImpl[8][3])(SColData *pColData, uint8_t *pDa // VALUE NONE NULL }; int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal) { - ASSERT(pColData->cid == pColVal->cid && pColData->type == pColVal->type); + ASSERT(pColData->cid == pColVal->cid && pColData->type == pColVal->value.type); return tColDataAppendValueImpl[pColData->flag][pColVal->flag]( pColData, IS_VAR_DATA_TYPE(pColData->type) ? pColVal->value.pData : (uint8_t *)&pColVal->value.val, pColVal->value.nData); @@ -2272,7 +2439,7 @@ static int32_t (*tColDataUpdateValueImpl[8][3])(SColData *pColData, uint8_t *pDa // VALUE NONE NULL }; int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward) { - ASSERT(pColData->cid == pColVal->cid && pColData->type == pColVal->type); + ASSERT(pColData->cid == pColVal->cid && pColData->type == pColVal->value.type); ASSERT(pColData->nVal > 0); if (tColDataUpdateValueImpl[pColData->flag][pColVal->flag] == NULL) return 0; @@ -2302,7 +2469,7 @@ static FORCE_INLINE void tColDataGetValue3(SColData *pColData, int32_t iVal, } } static FORCE_INLINE void tColDataGetValue4(SColData *pColData, int32_t iVal, SColVal *pColVal) { // HAS_VALUE - SValue value; + SValue value = {.type = pColData->type}; if (IS_VAR_DATA_TYPE(pColData->type)) { if (iVal + 1 < pColData->nVal) { value.nData = pColData->aOffset[iVal + 1] - pColData->aOffset[iVal]; @@ -2313,7 +2480,7 @@ static FORCE_INLINE void tColDataGetValue4(SColData *pColData, int32_t iVal, SCo } else { memcpy(&value.val, pColData->pData + tDataTypes[pColData->type].bytes * iVal, tDataTypes[pColData->type].bytes); } - *pColVal = COL_VAL_VALUE(pColData->cid, pColData->type, value); + *pColVal = COL_VAL_VALUE(pColData->cid, value); } static FORCE_INLINE void tColDataGetValue5(SColData *pColData, int32_t iVal, SColVal *pColVal) { // HAS_VALUE|HAS_NONE @@ -2453,6 +2620,226 @@ _exit: return code; } +int32_t tColDataCompress(SColData *colData, SColDataCompressInfo *info, SBuffer *output, SBuffer *assist) { + int32_t code; + SBuffer local; + + ASSERT(colData->nVal > 0); + + (*info) = (SColDataCompressInfo){ + .cmprAlg = info->cmprAlg, + .columnFlag = colData->cflag, + .flag = colData->flag, + .dataType = colData->type, + .columnId = colData->cid, + .numOfData = colData->nVal, + }; + + if (colData->flag == HAS_NONE || colData->flag == HAS_NULL) { + return 0; + } + + tBufferInit(&local); + if (assist == NULL) { + assist = &local; + } + + // bitmap + if (colData->flag != HAS_VALUE) { + if (colData->flag == (HAS_NONE | HAS_NULL | HAS_VALUE)) { + info->bitmapOriginalSize = BIT2_SIZE(colData->nVal); + } else { + info->bitmapOriginalSize = BIT1_SIZE(colData->nVal); + } + + SCompressInfo cinfo = { + .dataType = TSDB_DATA_TYPE_TINYINT, + .cmprAlg = info->cmprAlg, + .originalSize = info->bitmapOriginalSize, + }; + + code = tCompressDataToBuffer(colData->pBitMap, &cinfo, output, assist); + if (code) { + tBufferDestroy(&local); + return code; + } + + info->bitmapCompressedSize = cinfo.compressedSize; + } + + if (colData->flag == (HAS_NONE | HAS_NULL)) { + tBufferDestroy(&local); + return 0; + } + + // offset + if (IS_VAR_DATA_TYPE(colData->type)) { + info->offsetOriginalSize = sizeof(int32_t) * info->numOfData; + + SCompressInfo cinfo = { + .dataType = TSDB_DATA_TYPE_INT, + .cmprAlg = info->cmprAlg, + .originalSize = info->offsetOriginalSize, + }; + + code = tCompressDataToBuffer(colData->aOffset, &cinfo, output, assist); + if (code) { + tBufferDestroy(&local); + return code; + } + + info->offsetCompressedSize = cinfo.compressedSize; + } + + // data + if (colData->nData > 0) { + info->dataOriginalSize = colData->nData; + + SCompressInfo cinfo = { + .dataType = colData->type, + .cmprAlg = info->cmprAlg, + .originalSize = info->dataOriginalSize, + }; + + code = tCompressDataToBuffer(colData->pData, &cinfo, output, assist); + if (code) { + tBufferDestroy(&local); + return code; + } + + info->dataCompressedSize = cinfo.compressedSize; + } + + tBufferDestroy(&local); + return 0; +} + +int32_t tColDataDecompress(void *input, SColDataCompressInfo *info, SColData *colData, SBuffer *assist) { + int32_t code; + SBuffer local; + uint8_t *data = (uint8_t *)input; + + tBufferInit(&local); + if (assist == NULL) { + assist = &local; + } + + tColDataClear(colData); + colData->cid = info->columnId; + colData->type = info->dataType; + colData->cflag = info->columnFlag; + colData->nVal = info->numOfData; + colData->flag = info->flag; + + if (info->flag == HAS_NONE || info->flag == HAS_NULL) { + goto _exit; + } + + // bitmap + if (info->bitmapOriginalSize > 0) { + SCompressInfo cinfo = { + .dataType = TSDB_DATA_TYPE_TINYINT, + .cmprAlg = info->cmprAlg, + .originalSize = info->bitmapOriginalSize, + .compressedSize = info->bitmapCompressedSize, + }; + + code = tRealloc(&colData->pBitMap, cinfo.originalSize); + if (code) { + tBufferDestroy(&local); + return code; + } + + code = tDecompressData(data, &cinfo, colData->pBitMap, cinfo.originalSize, assist); + if (code) { + tBufferDestroy(&local); + return code; + } + + data += cinfo.compressedSize; + } + + if (info->flag == (HAS_NONE | HAS_NULL)) { + goto _exit; + } + + // offset + if (info->offsetOriginalSize > 0) { + SCompressInfo cinfo = { + .cmprAlg = info->cmprAlg, + .dataType = TSDB_DATA_TYPE_INT, + .originalSize = info->offsetOriginalSize, + .compressedSize = info->offsetCompressedSize, + }; + + code = tRealloc((uint8_t **)&colData->aOffset, cinfo.originalSize); + if (code) { + tBufferDestroy(&local); + return code; + } + + code = tDecompressData(data, &cinfo, colData->aOffset, cinfo.originalSize, assist); + if (code) { + tBufferDestroy(&local); + return code; + } + + data += cinfo.compressedSize; + } + + // data + if (info->dataOriginalSize > 0) { + colData->nData = info->dataOriginalSize; + + SCompressInfo cinfo = { + .cmprAlg = info->cmprAlg, + .dataType = colData->type, + .originalSize = info->dataOriginalSize, + .compressedSize = info->dataCompressedSize, + }; + + code = tRealloc((uint8_t **)&colData->pData, cinfo.originalSize); + if (code) { + tBufferDestroy(&local); + return code; + } + + code = tDecompressData(data, &cinfo, colData->pData, cinfo.originalSize, assist); + if (code) { + tBufferDestroy(&local); + return code; + } + + data += cinfo.compressedSize; + } + +_exit: + switch (colData->flag) { + case HAS_NONE: + colData->numOfNone = colData->nVal; + break; + case HAS_NULL: + colData->numOfNull = colData->nVal; + break; + case HAS_VALUE: + colData->numOfValue = colData->nVal; + break; + default: + for (int32_t i = 0; i < colData->nVal; i++) { + uint8_t bitValue = tColDataGetBitValue(colData, i); + if (bitValue == 0) { + colData->numOfNone++; + } else if (bitValue == 1) { + colData->numOfNull++; + } else { + colData->numOfValue++; + } + } + } + tBufferDestroy(&local); + return 0; +} + int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap, char *data) { int32_t code = 0; @@ -2756,7 +3143,7 @@ static int32_t tColDataMergeSortMerge(SColData *aColData, int32_t start, int32_t if (end > start) { aDstColData = taosMemoryCalloc(1, sizeof(SColData) * nColData); for (int c = 0; c < nColData; ++c) { - tColDataInit(&aDstColData[c], aColData[c].cid, aColData[c].type, aColData[c].smaOn); + tColDataInit(&aDstColData[c], aColData[c].cid, aColData[c].type, aColData[c].cflag); } if (aDstColData == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -3602,3 +3989,361 @@ void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_ NULL, // TSDB_DATA_TYPE_MEDIUMBLOB tColDataCalcSMAVarType // TSDB_DATA_TYPE_GEOMETRY }; + +// SValueColumn ================================ +int32_t tValueColumnInit(SValueColumn *valCol) { + valCol->type = TSDB_DATA_TYPE_NULL; + valCol->numOfValues = 0; + tBufferInit(&valCol->data); + tBufferInit(&valCol->offsets); + return 0; +} + +int32_t tValueColumnDestroy(SValueColumn *valCol) { + valCol->type = TSDB_DATA_TYPE_NULL; + valCol->numOfValues = 0; + tBufferDestroy(&valCol->data); + tBufferDestroy(&valCol->offsets); + return 0; +} + +int32_t tValueColumnClear(SValueColumn *valCol) { + valCol->type = TSDB_DATA_TYPE_NULL; + valCol->numOfValues = 0; + tBufferClear(&valCol->data); + tBufferClear(&valCol->offsets); + return 0; +} + +int32_t tValueColumnAppend(SValueColumn *valCol, const SValue *value) { + int32_t code; + + if (valCol->numOfValues == 0) { + valCol->type = value->type; + } + + ASSERT(value->type == valCol->type); + + if (IS_VAR_DATA_TYPE(value->type)) { + if ((code = tBufferPutI32(&valCol->offsets, tBufferGetSize(&valCol->data)))) { + return code; + } + if ((code = tBufferPut(&valCol->data, value->pData, value->nData))) { + return code; + } + } else { + code = tBufferPut(&valCol->data, &value->val, tDataTypes[value->type].bytes); + if (code) return code; + } + valCol->numOfValues++; + + return 0; +} + +int32_t tValueColumnUpdate(SValueColumn *valCol, int32_t idx, const SValue *value) { + int32_t code; + + if (idx < 0 || idx >= valCol->numOfValues) { + return TSDB_CODE_OUT_OF_RANGE; + } + + if (IS_VAR_DATA_TYPE(valCol->type)) { + int32_t *offsets = (int32_t *)tBufferGetData(&valCol->offsets); + int32_t nextOffset = (idx == valCol->numOfValues - 1) ? tBufferGetSize(&valCol->data) : offsets[idx + 1]; + int32_t oldDataSize = nextOffset - offsets[idx]; + int32_t bytesAdded = value->nData - oldDataSize; + + if (bytesAdded != 0) { + if ((code = tBufferEnsureCapacity(&valCol->data, tBufferGetSize(&valCol->data) + bytesAdded))) return code; + memmove(tBufferGetDataAt(&valCol->data, nextOffset + bytesAdded), tBufferGetDataAt(&valCol->data, nextOffset), + tBufferGetSize(&valCol->data) - nextOffset); + valCol->data.size += bytesAdded; + + for (int32_t i = idx + 1; i < valCol->numOfValues; i++) { + offsets[i] += bytesAdded; + } + } + return tBufferPutAt(&valCol->data, offsets[idx], value->pData, value->nData); + } else { + return tBufferPutAt(&valCol->data, idx * tDataTypes[valCol->type].bytes, &value->val, + tDataTypes[valCol->type].bytes); + } + return 0; +} + +int32_t tValueColumnGet(SValueColumn *valCol, int32_t idx, SValue *value) { + if (idx < 0 || idx >= valCol->numOfValues) { + return TSDB_CODE_OUT_OF_RANGE; + } + + value->type = valCol->type; + if (IS_VAR_DATA_TYPE(value->type)) { + int32_t offset, nextOffset; + SBufferReader reader = BUFFER_READER_INITIALIZER(idx * sizeof(offset), &valCol->offsets); + + tBufferGetI32(&reader, &offset); + if (idx == valCol->numOfValues - 1) { + nextOffset = tBufferGetSize(&valCol->data); + } else { + tBufferGetI32(&reader, &nextOffset); + } + value->nData = nextOffset - offset; + value->pData = (uint8_t *)tBufferGetDataAt(&valCol->data, offset); + } else { + SBufferReader reader = BUFFER_READER_INITIALIZER(idx * tDataTypes[value->type].bytes, &valCol->data); + tBufferGet(&reader, tDataTypes[value->type].bytes, &value->val); + } + return 0; +} + +int32_t tValueColumnCompress(SValueColumn *valCol, SValueColumnCompressInfo *info, SBuffer *output, SBuffer *assist) { + int32_t code; + + ASSERT(valCol->numOfValues > 0); + + (*info) = (SValueColumnCompressInfo){ + .cmprAlg = info->cmprAlg, + .type = valCol->type, + }; + + // offset + if (IS_VAR_DATA_TYPE(valCol->type)) { + SCompressInfo cinfo = { + .cmprAlg = info->cmprAlg, + .dataType = TSDB_DATA_TYPE_INT, + .originalSize = valCol->offsets.size, + }; + + code = tCompressDataToBuffer(valCol->offsets.data, &cinfo, output, assist); + if (code) return code; + + info->offsetOriginalSize = cinfo.originalSize; + info->offsetCompressedSize = cinfo.compressedSize; + } + + // data + SCompressInfo cinfo = { + .cmprAlg = info->cmprAlg, + .dataType = valCol->type, + .originalSize = valCol->data.size, + }; + + code = tCompressDataToBuffer(valCol->data.data, &cinfo, output, assist); + if (code) return code; + + info->dataOriginalSize = cinfo.originalSize; + info->dataCompressedSize = cinfo.compressedSize; + + return 0; +} + +int32_t tValueColumnDecompress(void *input, const SValueColumnCompressInfo *info, SValueColumn *valCol, + SBuffer *assist) { + int32_t code; + + tValueColumnClear(valCol); + valCol->type = info->type; + // offset + if (IS_VAR_DATA_TYPE(valCol->type)) { + valCol->numOfValues = info->offsetOriginalSize / tDataTypes[TSDB_DATA_TYPE_INT].bytes; + + SCompressInfo cinfo = { + .dataType = TSDB_DATA_TYPE_INT, + .cmprAlg = info->cmprAlg, + .originalSize = info->offsetOriginalSize, + .compressedSize = info->offsetCompressedSize, + }; + + code = tDecompressDataToBuffer(input, &cinfo, &valCol->offsets, assist); + if (code) { + return code; + } + } else { + valCol->numOfValues = info->dataOriginalSize / tDataTypes[valCol->type].bytes; + } + + // data + SCompressInfo cinfo = { + .dataType = valCol->type, + .cmprAlg = info->cmprAlg, + .originalSize = info->dataOriginalSize, + .compressedSize = info->dataCompressedSize, + }; + + code = tDecompressDataToBuffer((char *)input + info->offsetCompressedSize, &cinfo, &valCol->data, assist); + if (code) { + return code; + } + + return 0; +} + +int32_t tValueColumnCompressInfoEncode(const SValueColumnCompressInfo *info, SBuffer *buffer) { + int32_t code; + uint8_t fmtVer = 0; + + if ((code = tBufferPutU8(buffer, fmtVer))) return code; + if ((code = tBufferPutI8(buffer, info->cmprAlg))) return code; + if ((code = tBufferPutI8(buffer, info->type))) return code; + if (IS_VAR_DATA_TYPE(info->type)) { + if ((code = tBufferPutI32v(buffer, info->offsetOriginalSize))) return code; + if ((code = tBufferPutI32v(buffer, info->offsetCompressedSize))) return code; + } + if ((code = tBufferPutI32v(buffer, info->dataOriginalSize))) return code; + if ((code = tBufferPutI32v(buffer, info->dataCompressedSize))) return code; + + return 0; +} + +int32_t tValueColumnCompressInfoDecode(SBufferReader *reader, SValueColumnCompressInfo *info) { + int32_t code; + uint8_t fmtVer; + + if ((code = tBufferGetU8(reader, &fmtVer))) return code; + if (fmtVer == 0) { + if ((code = tBufferGetI8(reader, &info->cmprAlg))) return code; + if ((code = tBufferGetI8(reader, &info->type))) return code; + if (IS_VAR_DATA_TYPE(info->type)) { + if ((code = tBufferGetI32v(reader, &info->offsetOriginalSize))) return code; + if ((code = tBufferGetI32v(reader, &info->offsetCompressedSize))) return code; + } else { + info->offsetOriginalSize = 0; + info->offsetCompressedSize = 0; + } + if ((code = tBufferGetI32v(reader, &info->dataOriginalSize))) return code; + if ((code = tBufferGetI32v(reader, &info->dataCompressedSize))) return code; + } else { + ASSERT(0); + } + + return 0; +} + +int32_t tCompressData(void *input, // input + SCompressInfo *info, // compress info + void *output, // output + int32_t outputSize, // output size + SBuffer *buffer // assistant buffer provided by caller, can be NULL +) { + int32_t extraSizeNeeded; + int32_t code; + + extraSizeNeeded = (info->cmprAlg == NO_COMPRESSION) ? info->originalSize : info->originalSize + COMP_OVERFLOW_BYTES; + ASSERT(outputSize >= extraSizeNeeded); + + if (info->cmprAlg == NO_COMPRESSION) { + memcpy(output, input, info->originalSize); + info->compressedSize = info->originalSize; + } else { + SBuffer local; + + tBufferInit(&local); + if (buffer == NULL) { + buffer = &local; + } + + if (info->cmprAlg == TWO_STAGE_COMP) { + code = tBufferEnsureCapacity(buffer, extraSizeNeeded); + if (code) { + tBufferDestroy(&local); + return code; + } + } + + info->compressedSize = tDataTypes[info->dataType].compFunc( // + input, // input + info->originalSize, // input size + info->originalSize / tDataTypes[info->dataType].bytes, // number of elements + output, // output + outputSize, // output size + info->cmprAlg, // compression algorithm + buffer->data, // buffer + buffer->capacity // buffer size + ); + if (info->compressedSize < 0) { + tBufferDestroy(&local); + return TSDB_CODE_COMPRESS_ERROR; + } + + tBufferDestroy(&local); + } + + return 0; +} + +int32_t tDecompressData(void *input, // input + const SCompressInfo *info, // compress info + void *output, // output + int32_t outputSize, // output size + SBuffer *buffer // assistant buffer provided by caller, can be NULL +) { + int32_t code; + + ASSERT(outputSize >= info->originalSize); + + if (info->cmprAlg == NO_COMPRESSION) { + ASSERT(info->compressedSize == info->originalSize); + memcpy(output, input, info->compressedSize); + } else { + SBuffer local; + + tBufferInit(&local); + if (buffer == NULL) { + buffer = &local; + } + + if (info->cmprAlg == TWO_STAGE_COMP) { + code = tBufferEnsureCapacity(buffer, info->originalSize + COMP_OVERFLOW_BYTES); + if (code) { + tBufferDestroy(&local); + return code; + } + } + + int32_t decompressedSize = tDataTypes[info->dataType].decompFunc( + input, // input + info->compressedSize, // inputSize + info->originalSize / tDataTypes[info->dataType].bytes, // number of elements + output, // output + outputSize, // output size + info->cmprAlg, // compression algorithm + buffer->data, // helper buffer + buffer->capacity // extra buffer size + ); + if (decompressedSize < 0) { + tBufferDestroy(&local); + return TSDB_CODE_COMPRESS_ERROR; + } + + ASSERT(decompressedSize == info->originalSize); + tBufferDestroy(&local); + } + + return 0; +} + +int32_t tCompressDataToBuffer(void *input, SCompressInfo *info, SBuffer *output, SBuffer *assist) { + int32_t code; + + code = tBufferEnsureCapacity(output, output->size + info->originalSize + COMP_OVERFLOW_BYTES); + if (code) return code; + + code = tCompressData(input, info, tBufferGetDataEnd(output), output->capacity - output->size, assist); + if (code) return code; + + output->size += info->compressedSize; + return 0; +} + +int32_t tDecompressDataToBuffer(void *input, SCompressInfo *info, SBuffer *output, SBuffer *assist) { + int32_t code; + + code = tBufferEnsureCapacity(output, output->size + info->originalSize); + if (code) return code; + + code = tDecompressData(input, info, tBufferGetDataEnd(output), output->capacity - output->size, assist); + if (code) return code; + + output->size += info->originalSize; + return 0; +} diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index ecf11857ad..73140952a2 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -573,8 +573,6 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; if (tEncodeCStr(&encoder, pField->name) < 0) return -1; if (tEncodeU32(&encoder, pField->compress) < 0) return -1; - // XSDEBUG - printf("column: %s, compress: %0x.\n", pField->name, pField->compress); } for (int32_t i = 0; i < pReq->numOfTags; ++i) { diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 6e9278c630..3c38c89e7f 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -510,9 +510,9 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r rowTotalLen = sizeof(STSRow) + sizeof(col_id_t) + varDataLen + nonVarDataLen + (nBound - 1) * sizeof(SKvRowIdx) + TD_BITMAP_BYTES(nBound - 1); } - if (!(*ppRow)) { - *ppRow = (STSRow *)taosMemoryCalloc(1, rowTotalLen); - isAlloc = true; + if (!(*ppRow)) { + *ppRow = (STSRow *)taosMemoryCalloc(1, rowTotalLen); + isAlloc = true; } if (!(*ppRow)) { @@ -1106,7 +1106,7 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV *pColVal = COL_VAL_NULL(pTColumn->colId, pTColumn->type); } else { pColVal->cid = pTColumn->colId; - pColVal->type = pTColumn->type; + pColVal->value.type = pTColumn->type; pColVal->flag = CV_FLAG_VALUE; if (IS_VAR_DATA_TYPE(pTColumn->type)) { diff --git a/source/common/test/dataformatTest.cpp b/source/common/test/dataformatTest.cpp index 8bc7d47ebf..2dfa706728 100644 --- a/source/common/test/dataformatTest.cpp +++ b/source/common/test/dataformatTest.cpp @@ -143,73 +143,73 @@ static int32_t genTestData(const char **data, int16_t nCols, SArray **pArray) { } switch (i) { case 0: - colVal.type = TSDB_DATA_TYPE_TIMESTAMP; + colVal.value.type = TSDB_DATA_TYPE_TIMESTAMP; sscanf(data[i], "%" PRIi64, &colVal.value.val); break; case 1: - colVal.type = TSDB_DATA_TYPE_INT; + colVal.value.type = TSDB_DATA_TYPE_INT; sscanf(data[i], "%" PRIi32, (int32_t *)&colVal.value.val); break; case 2: - colVal.type = TSDB_DATA_TYPE_BIGINT; + colVal.value.type = TSDB_DATA_TYPE_BIGINT; sscanf(data[i], "%" PRIi64, &colVal.value.val); break; case 3: - colVal.type = TSDB_DATA_TYPE_FLOAT; + colVal.value.type = TSDB_DATA_TYPE_FLOAT; sscanf(data[i], "%f", (float *)&colVal.value.val); break; case 4: - colVal.type = TSDB_DATA_TYPE_DOUBLE; + colVal.value.type = TSDB_DATA_TYPE_DOUBLE; sscanf(data[i], "%lf", (double *)&colVal.value.val); break; case 5: { - colVal.type = TSDB_DATA_TYPE_BINARY; + colVal.value.type = TSDB_DATA_TYPE_BINARY; int16_t dataLen = strlen(data[i]) + 1; colVal.value.nData = dataLen < 10 ? dataLen : 10; colVal.value.pData = (uint8_t *)data[i]; } break; case 6: { - colVal.type = TSDB_DATA_TYPE_NCHAR; + colVal.value.type = TSDB_DATA_TYPE_NCHAR; int16_t dataLen = strlen(data[i]) + 1; colVal.value.nData = dataLen < 40 ? dataLen : 40; colVal.value.pData = (uint8_t *)data[i]; // just for test, not real nchar } break; case 7: { - colVal.type = TSDB_DATA_TYPE_TINYINT; + colVal.value.type = TSDB_DATA_TYPE_TINYINT; int32_t d8; sscanf(data[i], "%" PRId32, &d8); colVal.value.val = (int8_t)d8; } case 8: { - colVal.type = TSDB_DATA_TYPE_SMALLINT; + colVal.value.type = TSDB_DATA_TYPE_SMALLINT; int32_t d16; sscanf(data[i], "%" PRId32, &d16); colVal.value.val = (int16_t)d16; } break; case 9: { - colVal.type = TSDB_DATA_TYPE_BOOL; + colVal.value.type = TSDB_DATA_TYPE_BOOL; int32_t d8; sscanf(data[i], "%" PRId32, &d8); colVal.value.val = (int8_t)d8; } break; case 10: { - colVal.type = TSDB_DATA_TYPE_UTINYINT; + colVal.value.type = TSDB_DATA_TYPE_UTINYINT; uint32_t u8; sscanf(data[i], "%" PRId32, &u8); colVal.value.val = (uint8_t)u8; } break; case 11: { - colVal.type = TSDB_DATA_TYPE_USMALLINT; + colVal.value.type = TSDB_DATA_TYPE_USMALLINT; uint32_t u16; sscanf(data[i], "%" PRId32, &u16); colVal.value.val = (uint16_t)u16; } break; case 12: { - colVal.type = TSDB_DATA_TYPE_UINT; + colVal.value.type = TSDB_DATA_TYPE_UINT; sscanf(data[i], "%" PRIu32, (uint32_t *)&colVal.value.val); } break; case 13: { - colVal.type = TSDB_DATA_TYPE_UBIGINT; + colVal.value.type = TSDB_DATA_TYPE_UBIGINT; sscanf(data[i], "%" PRIu64, (uint64_t *)&colVal.value.val); } break; default: @@ -430,7 +430,7 @@ static void checkTSRow(const char **data, STSRow *row, STSchema *pTSchema) { } colVal.cid = pCol->colId; - colVal.type = pCol->type; + colVal.value.type = pCol->type; if (tdValTypeIsNone(cv.valType)) { colVal.flag = CV_FLAG_NONE; } else if (tdValTypeIsNull(cv.valType)) { diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 7a5cacc015..53aa59f1e0 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1137,10 +1137,6 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { goto _OVER; } - // todo xsdebug - // terrno = TSDB_CODE_OPS_NOT_SUPPORT; - // goto _OVER; - mInfo("stb:%s, start to create", createReq.name); if (mndCheckCreateStbReq(&createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index cac3be9ee3..cf4392e51c 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -75,6 +75,7 @@ typedef struct SBlkInfo SBlkInfo; typedef struct STsdbDataIter2 STsdbDataIter2; typedef struct STsdbFilterInfo STsdbFilterInfo; typedef struct STFileSystem STFileSystem; +typedef struct STsdbRowKey STsdbRowKey; #define TSDBROW_ROW_FMT ((int8_t)0x0) #define TSDBROW_COL_FMT ((int8_t)0x1) @@ -93,7 +94,7 @@ typedef struct STFileSystem STFileSystem; #define PAGE_CONTENT_SIZE(PAGE) ((PAGE) - sizeof(TSCKSUM)) #define LOGIC_TO_FILE_OFFSET(LOFFSET, PAGE) \ ((LOFFSET) / PAGE_CONTENT_SIZE(PAGE) * (PAGE) + (LOFFSET) % PAGE_CONTENT_SIZE(PAGE)) -#define FILE_TO_LOGIC_OFFSET(OFFSET, PAGE) ((OFFSET) / (PAGE)*PAGE_CONTENT_SIZE(PAGE) + (OFFSET) % (PAGE)) +#define FILE_TO_LOGIC_OFFSET(OFFSET, PAGE) ((OFFSET) / (PAGE) * PAGE_CONTENT_SIZE(PAGE) + (OFFSET) % (PAGE)) #define PAGE_OFFSET(PGNO, PAGE) (((PGNO)-1) * (PAGE)) #define OFFSET_PGNO(OFFSET, PAGE) ((OFFSET) / (PAGE) + 1) @@ -120,7 +121,10 @@ static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) { ((TSDBROW){.type = TSDBROW_COL_FMT, .pBlockData = (BLOCKDATA), .iRow = (IROW)}) void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal); -int32_t tsdbRowCmprFn(const void *p1, const void *p2); +int32_t tsdbRowCompare(const void *p1, const void *p2); +int32_t tsdbRowCompareWithoutVersion(const void *p1, const void *p2); +int32_t tsdbRowKeyCmpr(const STsdbRowKey *key1, const STsdbRowKey *key2); +void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key); // STSDBRowIter int32_t tsdbRowIterOpen(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema); void tsdbRowClose(STSDBRowIter *pIter); @@ -139,8 +143,8 @@ int32_t tTABLEIDCmprFn(const void *p1, const void *p2); #define MIN_TSDBKEY(KEY1, KEY2) ((tsdbKeyCmprFn(&(KEY1), &(KEY2)) < 0) ? (KEY1) : (KEY2)) #define MAX_TSDBKEY(KEY1, KEY2) ((tsdbKeyCmprFn(&(KEY1), &(KEY2)) > 0) ? (KEY1) : (KEY2)) // SBlockCol -int32_t tPutBlockCol(uint8_t *p, void *ph); -int32_t tGetBlockCol(uint8_t *p, void *ph); +int32_t tPutBlockCol(SBuffer *buffer, const SBlockCol *pBlockCol); +int32_t tGetBlockCol(SBufferReader *br, SBlockCol *pBlockCol); int32_t tBlockColCmprFn(const void *p1, const void *p2); // SDataBlk void tDataBlkReset(SDataBlk *pBlock); @@ -172,13 +176,17 @@ int32_t tBlockDataUpdateRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t uid); int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid); void tBlockDataClear(SBlockData *pBlockData); -void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData); -int32_t tCmprBlockData(SBlockData *pBlockData, int8_t cmprAlg, uint8_t **ppOut, int32_t *szOut, uint8_t *aBuf[], - int32_t aBufN[]); -int32_t tDecmprBlockData(uint8_t *pIn, int32_t szIn, SBlockData *pBlockData, uint8_t *aBuf[]); +int32_t tBlockDataCompress(SBlockData *bData, int8_t cmprAlg, SBuffer *buffers, SBuffer *assist); +int32_t tBlockDataDecompress(SBufferReader *br, SBlockData *blockData, SBuffer *assist); +int32_t tBlockDataDecompressKeyPart(const SDiskDataHdr *hdr, SBufferReader *br, SBlockData *blockData, SBuffer *assist); +int32_t tBlockDataDecompressColData(const SDiskDataHdr *hdr, const SBlockCol *blockCol, SBufferReader *br, + SBlockData *blockData, SBuffer *assist); + +SColData *tBlockDataGetColData(SBlockData *pBlockData, int16_t cid); +int32_t tBlockDataAddColData(SBlockData *pBlockData, int16_t cid, int8_t type, int8_t cflag, SColData **ppColData); // SDiskDataHdr -int32_t tPutDiskDataHdr(uint8_t *p, const SDiskDataHdr *pHdr); -int32_t tGetDiskDataHdr(uint8_t *p, void *ph); +int32_t tPutDiskDataHdr(SBuffer *buffer, const SDiskDataHdr *pHdr); +int32_t tGetDiskDataHdr(SBufferReader *br, SDiskDataHdr *pHdr); // SDelIdx int32_t tPutDelIdx(uint8_t *p, void *ph); int32_t tGetDelIdx(uint8_t *p, void *ph); @@ -204,16 +212,8 @@ int32_t tsdbKeyFid(TSKEY key, int32_t minutes, int8_t precision); void tsdbFidKeyRange(int32_t fid, int32_t minutes, int8_t precision, TSKEY *minKey, TSKEY *maxKey); int32_t tsdbFidLevel(int32_t fid, STsdbKeepCfg *pKeepCfg, int64_t nowSec); int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SArray *aSkyline); -int32_t tPutColumnDataAgg(uint8_t *p, SColumnDataAgg *pColAgg); -int32_t tGetColumnDataAgg(uint8_t *p, SColumnDataAgg *pColAgg); -int32_t tsdbCmprData(uint8_t *pIn, int32_t szIn, int8_t type, int8_t cmprAlg, uint8_t **ppOut, int32_t nOut, - int32_t *szOut, uint8_t **ppBuf); -int32_t tsdbDecmprData(uint8_t *pIn, int32_t szIn, int8_t type, int8_t cmprAlg, uint8_t **ppOut, int32_t szOut, - uint8_t **ppBuf); -int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol, uint8_t **ppOut, int32_t nOut, - uint8_t **ppBuf); -int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, int32_t nVal, SColData *pColData, - uint8_t **ppBuf); +int32_t tPutColumnDataAgg(SBuffer *buffer, SColumnDataAgg *pColAgg); +int32_t tGetColumnDataAgg(SBufferReader *br, SColumnDataAgg *pColAgg); int32_t tRowInfoCmprFn(const void *p1, const void *p2); // tsdbMemTable ============================================================================================== // SMemTable @@ -224,9 +224,9 @@ int32_t tsdbRefMemTable(SMemTable *pMemTable, SQueryNode *pQNode); int32_t tsdbUnrefMemTable(SMemTable *pMemTable, SQueryNode *pNode, bool proactive); SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable); // STbDataIter -int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter); +int32_t tsdbTbDataIterCreate(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter **ppIter); void *tsdbTbDataIterDestroy(STbDataIter *pIter); -void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter *pIter); +void tsdbTbDataIterOpen(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter *pIter); bool tsdbTbDataIterNext(STbDataIter *pIter); void tsdbMemTableCountRows(SMemTable *pMemTable, SSHashObj *pTableMap, int64_t *rowsNum); @@ -264,11 +264,6 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader); int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx); int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *mDataBlk); int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk); -int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pBlock, SArray *aColumnDataAgg); -int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pBlock, SBlockData *pBlockData); -int32_t tsdbReadDataBlockEx(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData); -int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData); -int32_t tsdbReadSttBlockEx(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData); // SDelFReader int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb); int32_t tsdbDelFReaderClose(SDelFReader **ppReader); @@ -279,7 +274,7 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx); // tsdbRead.c ============================================================================================== int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STsdbReadSnap **ppSnap); void tsdbUntakeReadSnap2(STsdbReader *pReader, STsdbReadSnap *pSnap, bool proactive); -int32_t tsdbGetTableSchema(SMeta* pMeta, int64_t uid, STSchema** pSchema, int64_t* suid); +int32_t tsdbGetTableSchema(SMeta *pMeta, int64_t uid, STSchema **pSchema, int64_t *suid); // tsdbMerge.c ============================================================================================== typedef struct { @@ -289,14 +284,6 @@ typedef struct { int32_t tsdbMerge(void *arg); -// tsdbDiskData ============================================================================================== -int32_t tDiskDataBuilderCreate(SDiskDataBuilder **ppBuilder); -void *tDiskDataBuilderDestroy(SDiskDataBuilder *pBuilder); -int32_t tDiskDataBuilderInit(SDiskDataBuilder *pBuilder, STSchema *pTSchema, TABLEID *pId, uint8_t cmprAlg, - uint8_t calcSma); -int32_t tDiskDataBuilderClear(SDiskDataBuilder *pBuilder); -int32_t tDiskDataAddRow(SDiskDataBuilder *pBuilder, TSDBROW *pRow, STSchema *pTSchema, TABLEID *pId); -int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData, const SBlkInfo **ppBlkInfo); // tsdbDataIter.c ============================================================================================== #define TSDB_MEM_TABLE_DATA_ITER 0 #define TSDB_DATA_FILE_DATA_ITER 1 @@ -375,15 +362,6 @@ struct TSDBKEY { }; typedef struct SMemSkipListNode SMemSkipListNode; -struct SMemSkipListNode { - int8_t level; - int8_t flag; // TSDBROW_ROW_FMT for row format, TSDBROW_COL_FMT for col format - int32_t iRow; - int64_t version; - void *pData; - SMemSkipListNode *forwards[0]; -}; - typedef struct SMemSkipList { int64_t size; uint32_t seed; @@ -437,6 +415,17 @@ struct TSDBROW { }; }; +struct SMemSkipListNode { + int8_t level; + TSDBROW row; + SMemSkipListNode *forwards[0]; +}; + +struct STsdbRowKey { + SRowKey key; + int64_t version; +}; + struct SBlockIdx { int64_t suid; int64_t uid; @@ -454,7 +443,7 @@ struct SMapData { struct SBlockCol { int16_t cid; int8_t type; - int8_t smaOn; + int8_t cflag; int8_t flag; // HAS_NONE|HAS_NULL|HAS_VALUE int32_t szOrigin; // original column value size (only save for variant data type) int32_t szBitmap; // bitmap size, 0 only for flag == HAS_VAL @@ -562,6 +551,10 @@ struct SDiskDataHdr { int32_t szBlkCol; int32_t nRow; int8_t cmprAlg; + + // fmtVer == 1 + int8_t numOfPKs; + SBlockCol primaryBlockCols[TD_MAX_PK_COLS]; }; struct SDelFile { @@ -942,34 +935,7 @@ static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) { // #define SL_NODE_FORWARD(n, l) ((n)->forwards[l]) // #define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)]) -static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) { - if (pIter == NULL) return NULL; - - if (pIter->pRow) { - return pIter->pRow; - } - - if (pIter->backward) { - if (pIter->pNode == pIter->pTbData->sl.pHead) { - return NULL; - } - } else { - if (pIter->pNode == pIter->pTbData->sl.pTail) { - return NULL; - } - } - - pIter->pRow = &pIter->row; - if (pIter->pNode->flag == TSDBROW_ROW_FMT) { - pIter->row = tsdbRowFromTSRow(pIter->pNode->version, pIter->pNode->pData); - } else if (pIter->pNode->flag == TSDBROW_COL_FMT) { - pIter->row = tsdbRowFromBlockData(pIter->pNode->pData, pIter->pNode->iRow); - } else { - ASSERT(0); - } - - return pIter->pRow; -} +TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter); typedef struct { int64_t suid; diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 110cac152d..a99caa3323 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -578,7 +578,7 @@ static int32_t buildResSDataBlock(SSDataBlock* pBlock, SSchemaWrapper* pSchema, static int32_t doSetVal(SColumnInfoData* pColumnInfoData, int32_t rowIndex, SColVal* pColVal) { int32_t code = TSDB_CODE_SUCCESS; - if (IS_STR_DATA_TYPE(pColVal->type)) { + if (IS_STR_DATA_TYPE(pColVal->value.type)) { char val[65535 + 2] = {0}; if (COL_VAL_IS_VALUE(pColVal)) { if (pColVal->value.pData != NULL) { diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index 9ff4e3ba62..a7dbdd9a48 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -567,13 +567,14 @@ int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDat void* colData = colDataGetData(pColData, j); if (IS_STR_DATA_TYPE(pCol->type)) { // address copy, no value - SValue sv = (SValue){.nData = varDataLen(colData), .pData = (uint8_t*)varDataVal(colData)}; - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); + SValue sv = + (SValue){.type = pCol->type, .nData = varDataLen(colData), .pData = (uint8_t*)varDataVal(colData)}; + SColVal cv = COL_VAL_VALUE(pCol->colId, sv); taosArrayPush(pVals, &cv); } else { - SValue sv; + SValue sv = {.type = pCol->type}; memcpy(&sv.val, colData, tDataTypes[pCol->type].bytes); - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); + SColVal cv = COL_VAL_VALUE(pCol->colId, sv); taosArrayPush(pVals, &cv); } dataIndex++; diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 0848fd0076..5c6c6c3e9d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -329,7 +329,7 @@ static SLastCol *tsdbCacheDeserialize(char const *value) { SLastCol *pLastCol = (SLastCol *)value; SColVal *pColVal = &pLastCol->colVal; - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { if (pColVal->value.nData > 0) { pColVal->value.pData = (char *)value + sizeof(*pLastCol); } else { @@ -343,13 +343,13 @@ static SLastCol *tsdbCacheDeserialize(char const *value) { static void tsdbCacheSerialize(SLastCol *pLastCol, char **value, size_t *size) { SColVal *pColVal = &pLastCol->colVal; size_t length = sizeof(*pLastCol); - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { length += pColVal->value.nData; } *value = taosMemoryMalloc(length); *(SLastCol *)(*value) = *pLastCol; - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { uint8_t *pVal = pColVal->value.pData; SColVal *pDColVal = &((SLastCol *)(*value))->colVal; pDColVal->value.pData = *value + sizeof(*pLastCol); @@ -434,7 +434,7 @@ int32_t tsdbCacheCommit(STsdb *pTsdb) { } static void reallocVarData(SColVal *pColVal) { - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { uint8_t *pVal = pColVal->value.pData; if (pColVal->value.nData > 0) { pColVal->value.pData = taosMemoryMalloc(pColVal->value.nData); @@ -452,7 +452,7 @@ static void tsdbCacheDeleter(const void *key, size_t klen, void *value, void *ud tsdbCachePutBatch(pLastCol, key, klen, (SCacheFlushState *)ud); } - if (IS_VAR_DATA_TYPE(pLastCol->colVal.type) /* && pLastCol->colVal.value.nData > 0*/) { + if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type) /* && pLastCol->colVal.value.nData > 0*/) { taosMemoryFree(pLastCol->colVal.value.pData); } @@ -473,7 +473,7 @@ static int32_t tsdbCacheNewTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, i reallocVarData(&pLastCol->colVal); size_t charge = sizeof(*pLastCol); - if (IS_VAR_DATA_TYPE(pLastCol->colVal.type)) { + if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) { charge += pLastCol->colVal.value.nData; } @@ -839,12 +839,12 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow if (pLastCol->ts <= keyTs) { uint8_t *pVal = NULL; int nData = pLastCol->colVal.value.nData; - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { pVal = pLastCol->colVal.value.pData; } pLastCol->ts = keyTs; pLastCol->colVal = *pColVal; - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { if (nData < pColVal->value.nData) { taosMemoryFree(pVal); pLastCol->colVal.value.pData = taosMemoryCalloc(1, pColVal->value.nData); @@ -878,12 +878,12 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow if (pLastCol->ts <= keyTs) { uint8_t *pVal = NULL; int nData = pLastCol->colVal.value.nData; - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { pVal = pLastCol->colVal.value.pData; } pLastCol->ts = keyTs; pLastCol->colVal = *pColVal; - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { if (nData < pColVal->value.nData) { taosMemoryFree(pVal); pLastCol->colVal.value.pData = taosMemoryCalloc(1, pColVal->value.nData); @@ -962,7 +962,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow reallocVarData(&pLastCol->colVal); size_t charge = sizeof(*pLastCol); - if (IS_VAR_DATA_TYPE(pLastCol->colVal.type)) { + if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) { charge += pLastCol->colVal.value.nData; } @@ -994,7 +994,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow reallocVarData(&pLastCol->colVal); size_t charge = sizeof(*pLastCol); - if (IS_VAR_DATA_TYPE(pLastCol->colVal.type)) { + if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) { charge += pLastCol->colVal.value.nData; } @@ -1310,7 +1310,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr reallocVarData(&pLastCol->colVal); size_t charge = sizeof(*pLastCol); - if (IS_VAR_DATA_TYPE(pLastCol->colVal.type)) { + if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) { charge += pLastCol->colVal.value.nData; } @@ -1394,7 +1394,7 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA reallocVarData(&pLastCol->colVal); size_t charge = sizeof(*pLastCol); - if (IS_VAR_DATA_TYPE(pLastCol->colVal.type)) { + if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) { charge += pLastCol->colVal.value.nData; } @@ -2175,7 +2175,7 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea STombRecord record = {0}; bool finished = false; - for (int32_t k = 0; k < TARRAY2_SIZE(block.suid); ++k) { + for (int32_t k = 0; k < TOMB_BLOCK_SIZE(&block); ++k) { code = tTombBlockGet(&block, k, &record); if (code != TSDB_CODE_SUCCESS) { finished = true; @@ -2551,7 +2551,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie goto _err; } - state->iBrinRecord = BRIN_BLOCK_SIZE(&state->brinBlock) - 1; + state->iBrinRecord = state->brinBlock.numOfRecords - 1; state->state = SFSNEXTROW_BRINBLOCK; } @@ -3185,14 +3185,14 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC if (slotIds[iCol] == 0) { STColumn *pTColumn = &pTSchema->columns[0]; - *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = rowTs}); + *pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs})); taosArraySet(pColArray, 0, &(SLastCol){.ts = rowTs, .colVal = *pColVal}); continue; } tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal); *pCol = (SLastCol){.ts = rowTs, .colVal = *pColVal}; - if (IS_VAR_DATA_TYPE(pColVal->type) /*&& pColVal->value.nData > 0*/) { + if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) { if (pColVal->value.nData > 0) { pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData); if (pCol->colVal.value.pData == NULL) { @@ -3242,7 +3242,7 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal); if (!COL_VAL_IS_VALUE(tColVal) && COL_VAL_IS_VALUE(pColVal)) { SLastCol lastCol = {.ts = rowTs, .colVal = *pColVal}; - if (IS_VAR_DATA_TYPE(pColVal->type) /* && pColVal->value.nData > 0 */) { + if (IS_VAR_DATA_TYPE(pColVal->value.type) /* && pColVal->value.nData > 0 */) { SLastCol *pLastCol = (SLastCol *)taosArrayGet(pColArray, iCol); taosMemoryFree(pLastCol->colVal.value.pData); @@ -3364,14 +3364,14 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, if (slotIds[iCol] == 0) { STColumn *pTColumn = &pTSchema->columns[0]; - *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = rowTs}); + *pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs})); taosArraySet(pColArray, 0, &(SLastCol){.ts = rowTs, .colVal = *pColVal}); continue; } tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal); *pCol = (SLastCol){.ts = rowTs, .colVal = *pColVal}; - if (IS_VAR_DATA_TYPE(pColVal->type) /*&& pColVal->value.nData > 0*/) { + if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) { if (pColVal->value.nData > 0) { pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData); if (pCol->colVal.value.pData == NULL) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index d05e184fd8..b7fe92c2c5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -24,7 +24,7 @@ #define HASTYPE(_type, _t) (((_type) & (_t)) == (_t)) static void setFirstLastResColToNull(SColumnInfoData* pCol, int32_t row) { - char *buf = taosMemoryCalloc(1, pCol->info.bytes); + char* buf = taosMemoryCalloc(1, pCol->info.bytes); SFirstLastRes* pRes = (SFirstLastRes*)((char*)buf + VARSTR_HEADER_SIZE); pRes->bytes = 0; pRes->hasResult = true; @@ -36,10 +36,10 @@ static void setFirstLastResColToNull(SColumnInfoData* pCol, int32_t row) { static void saveOneRowForLastRaw(SLastCol* pColVal, SCacheRowsReader* pReader, const int32_t slotId, SColumnInfoData* pColInfoData, int32_t numOfRows) { - SColVal* pVal = &pColVal->colVal; + SColVal* pVal = &pColVal->colVal; // allNullRow = false; - if (IS_VAR_DATA_TYPE(pColVal->colVal.type)) { + if (IS_VAR_DATA_TYPE(pColVal->colVal.value.type)) { if (!COL_VAL_IS_VALUE(&pColVal->colVal)) { colDataSetNULL(pColInfoData, numOfRows); } else { @@ -60,15 +60,14 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p // bool allNullRow = true; if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) { - - uint64_t ts = TSKEY_MIN; + uint64_t ts = TSKEY_MIN; SFirstLastRes* p = NULL; - col_id_t colId = -1; + col_id_t colId = -1; SArray* funcTypeBlockArray = taosArrayInit(pReader->numOfCols, sizeof(int32_t)); for (int32_t i = 0; i < pReader->numOfCols; ++i) { SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotIds[i]); - int32_t funcType = FUNCTION_TYPE_CACHE_LAST; + int32_t funcType = FUNCTION_TYPE_CACHE_LAST; if (pReader->pFuncTypeList != NULL && taosArrayGetSize(pReader->pFuncTypeList) > i) { funcType = *(int32_t*)taosArrayGet(pReader->pFuncTypeList, i); } @@ -98,13 +97,13 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p p->isNull = !COL_VAL_IS_VALUE(&pColVal->colVal); // allNullRow = p->isNull & allNullRow; if (!p->isNull) { - if (IS_VAR_DATA_TYPE(pColVal->colVal.type)) { + if (IS_VAR_DATA_TYPE(pColVal->colVal.value.type)) { varDataSetLen(p->buf, pColVal->colVal.value.nData); memcpy(varDataVal(p->buf), pColVal->colVal.value.pData, pColVal->colVal.value.nData); p->bytes = pColVal->colVal.value.nData + VARSTR_HEADER_SIZE; // binary needs to plus the header size } else { - memcpy(p->buf, &pColVal->colVal.value, pReader->pSchema->columns[slotId].bytes); + memcpy(p->buf, &pColVal->colVal.value.val, pReader->pSchema->columns[slotId].bytes); p->bytes = pReader->pSchema->columns[slotId].bytes; } } @@ -117,7 +116,7 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p for (int32_t idx = 0; idx < taosArrayGetSize(pBlock->pDataBlock); ++idx) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, idx); if (idx < funcTypeBlockArray->size) { - int32_t funcType = *(int32_t*)taosArrayGet(funcTypeBlockArray, idx); + int32_t funcType = *(int32_t*)taosArrayGet(funcTypeBlockArray, idx); if (FUNCTION_TYPE_CACHE_LAST_ROW == funcType) { continue; } @@ -146,7 +145,7 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p for (int32_t i = 0; i < pReader->numOfCols; ++i) { SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotIds[i]); - int32_t slotId = slotIds[i]; + int32_t slotId = slotIds[i]; if (slotId == -1) { colDataSetNULL(pColInfoData, numOfRows); continue; @@ -315,7 +314,7 @@ void* tsdbCacherowsReaderClose(void* pReader) { static void freeItem(void* pItem) { SLastCol* pCol = (SLastCol*)pItem; - if (IS_VAR_DATA_TYPE(pCol->colVal.type) && pCol->colVal.value.pData) { + if (IS_VAR_DATA_TYPE(pCol->colVal.value.type) && pCol->colVal.value.pData) { taosMemoryFree(pCol->colVal.value.pData); } } @@ -388,14 +387,14 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 } for (int32_t i = 0; i < pr->numOfCols; ++i) { - int32_t slotId = slotIds[i]; + int32_t slotId = slotIds[i]; if (slotId == -1) { - SLastCol p = {.ts = INT64_MIN, .colVal.type = TSDB_DATA_TYPE_BOOL, .colVal.flag = CV_FLAG_NULL}; + SLastCol p = {.ts = INT64_MIN, .colVal.value.type = TSDB_DATA_TYPE_BOOL, .colVal.flag = CV_FLAG_NULL}; taosArrayPush(pLastCols, &p); continue; } struct STColumn* pCol = &pr->pSchema->columns[slotId]; - SLastCol p = {.ts = INT64_MIN, .colVal.type = pCol->type, .colVal.flag = CV_FLAG_NULL}; + SLastCol p = {.ts = INT64_MIN, .colVal.value.type = pCol->type, .colVal.flag = CV_FLAG_NULL}; if (IS_VAR_DATA_TYPE(pCol->type)) { p.colVal.value.pData = taosMemoryCalloc(pCol->bytes, sizeof(char)); @@ -427,7 +426,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 if (!COL_VAL_IS_VALUE(&p->colVal)) { hasNotNullRow = false; } - // For all of cols is null, the last null col of last table will be save + // For all of cols is null, the last null col of last table will be save if (i != pr->numOfTables - 1 || k != pr->numOfCols - 1 || hasRes) { continue; } @@ -447,7 +446,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 singleTableLastTs = pColVal->ts; } - if (!IS_VAR_DATA_TYPE(pColVal->colVal.type)) { + if (!IS_VAR_DATA_TYPE(pColVal->colVal.value.type)) { p->colVal = pColVal->colVal; } else { if (COL_VAL_IS_VALUE(&pColVal->colVal)) { @@ -455,7 +454,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 } p->colVal.value.nData = pColVal->colVal.value.nData; - p->colVal.type = pColVal->colVal.type; + p->colVal.value.type = pColVal->colVal.value.type; p->colVal.flag = pColVal->colVal.flag; p->colVal.cid = pColVal->colVal.cid; } diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 37413ef920..f9a464b3bf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -31,7 +31,7 @@ int32_t tRowInfoCmprFn(const void *p1, const void *p2) { return 1; } - return tsdbRowCmprFn(&pInfo1->row, &pInfo2->row); + return tsdbRowCompare(&pInfo1->row, &pInfo2->row); } int32_t tsdbBegin(STsdb *pTsdb) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 32abbfdb3b..4c38cabcf3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -300,8 +300,11 @@ static int32_t tsdbCommitOpenIter(SCommitter2 *committer) { // mem data iter config.type = TSDB_ITER_TYPE_MEMT; config.memt = committer->tsdb->imem; - config.from->ts = committer->ctx->minKey; config.from->version = VERSION_MIN; + config.from->key = (SRowKey){ + .ts = committer->ctx->minKey, + .numOfPKs = 0, // TODO: support multiple primary keys + }; code = tsdbIterOpen(&config, &iter); TSDB_CHECK_CODE(code, lino, _exit); diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c index 9afa4bbcf1..17b420e83a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c @@ -19,7 +19,8 @@ struct SDataFileReader { SDataFileReaderConfig config[1]; - uint8_t *bufArr[5]; + SBuffer local[10]; + SBuffer *buffers; struct { bool headFooterLoaded; @@ -89,9 +90,14 @@ int32_t tsdbDataFileReaderOpen(const char *fname[], const SDataFileReaderConfig TSDB_CHECK_CODE(code, lino, _exit); } + for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->local); i++) { + tBufferInit(reader[0]->local + i); + } + reader[0]->config[0] = config[0]; - if (reader[0]->config->bufArr == NULL) { - reader[0]->config->bufArr = reader[0]->bufArr; + reader[0]->buffers = config->buffers; + if (reader[0]->buffers == NULL) { + reader[0]->buffers = reader[0]->local; } if (fname) { @@ -125,19 +131,14 @@ int32_t tsdbDataFileReaderClose(SDataFileReader **reader) { TARRAY2_DESTROY(reader[0]->tombBlkArray, NULL); TARRAY2_DESTROY(reader[0]->brinBlkArray, NULL); -#if 0 - TARRAY2_DESTROY(reader[0]->dataBlkArray, NULL); - TARRAY2_DESTROY(reader[0]->blockIdxArray, NULL); -#endif - for (int32_t i = 0; i < TSDB_FTYPE_MAX; ++i) { if (reader[0]->fd[i]) { tsdbCloseFile(&reader[0]->fd[i]); } } - for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->bufArr); ++i) { - tFree(reader[0]->bufArr[i]); + for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->local); ++i) { + tBufferDestroy(reader[0]->local + i); } taosMemoryFree(reader[0]); @@ -188,37 +189,76 @@ int32_t tsdbDataFileReadBrinBlock(SDataFileReader *reader, const SBrinBlk *brinB int32_t code = 0; int32_t lino = 0; - code = tRealloc(&reader->config->bufArr[0], brinBlk->dp->size); + SBuffer *buffer = reader->buffers + 0; + SBuffer *assist = reader->buffers + 1; + + // load data + tBufferClear(buffer); + code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_HEAD], brinBlk->dp->offset, brinBlk->dp->size, buffer, 0); TSDB_CHECK_CODE(code, lino, _exit); - code = - tsdbReadFile(reader->fd[TSDB_FTYPE_HEAD], brinBlk->dp->offset, reader->config->bufArr[0], brinBlk->dp->size, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - int32_t size = 0; + // decode brin block + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer); tBrinBlockClear(brinBlock); - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr1); i++) { - code = tsdbDecmprData(reader->config->bufArr[0] + size, brinBlk->size[i], TSDB_DATA_TYPE_BIGINT, brinBlk->cmprAlg, - &reader->config->bufArr[1], brinBlk->numRec * sizeof(int64_t), &reader->config->bufArr[2]); + brinBlock->numOfPKs = brinBlk->numOfPKs; + brinBlock->numOfRecords = brinBlk->numRec; + for (int32_t i = 0; i < 10; i++) { // int64_t + SCompressInfo cinfo = { + .cmprAlg = brinBlk->cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .compressedSize = brinBlk->size[i], + .originalSize = brinBlk->numRec * sizeof(int64_t), + }; + code = tDecompressDataToBuffer(BR_PTR(&br), &cinfo, brinBlock->buffers + i, assist); TSDB_CHECK_CODE(code, lino, _exit); - - code = TARRAY2_APPEND_BATCH(&brinBlock->dataArr1[i], reader->config->bufArr[1], brinBlk->numRec); - TSDB_CHECK_CODE(code, lino, _exit); - - size += brinBlk->size[i]; + br.offset += brinBlk->size[i]; } - for (int32_t i = 0, j = ARRAY_SIZE(brinBlock->dataArr1); i < ARRAY_SIZE(brinBlock->dataArr2); i++, j++) { - code = tsdbDecmprData(reader->config->bufArr[0] + size, brinBlk->size[j], TSDB_DATA_TYPE_INT, brinBlk->cmprAlg, - &reader->config->bufArr[1], brinBlk->numRec * sizeof(int32_t), &reader->config->bufArr[2]); + for (int32_t i = 10; i < 15; i++) { // int32_t + SCompressInfo cinfo = { + .cmprAlg = brinBlk->cmprAlg, + .dataType = TSDB_DATA_TYPE_INT, + .compressedSize = brinBlk->size[i], + .originalSize = brinBlk->numRec * sizeof(int32_t), + }; + code = tDecompressDataToBuffer(BR_PTR(&br), &cinfo, brinBlock->buffers + i, assist); TSDB_CHECK_CODE(code, lino, _exit); - - code = TARRAY2_APPEND_BATCH(&brinBlock->dataArr2[i], reader->config->bufArr[1], brinBlk->numRec); - TSDB_CHECK_CODE(code, lino, _exit); - - size += brinBlk->size[j]; + br.offset += brinBlk->size[i]; } + // primary keys + if (brinBlk->numOfPKs > 0) { // decode the primary keys + SValueColumnCompressInfo firstInfos[TD_MAX_PK_COLS]; + SValueColumnCompressInfo lastInfos[TD_MAX_PK_COLS]; + + for (int32_t i = 0; i < brinBlk->numOfPKs; i++) { + code = tValueColumnCompressInfoDecode(&br, firstInfos + i); + TSDB_CHECK_CODE(code, lino, _exit); + } + for (int32_t i = 0; i < brinBlk->numOfPKs; i++) { + code = tValueColumnCompressInfoDecode(&br, lastInfos + i); + TSDB_CHECK_CODE(code, lino, _exit); + } + + for (int32_t i = 0; i < brinBlk->numOfPKs; i++) { + SValueColumnCompressInfo *info = firstInfos + i; + + code = tValueColumnDecompress(BR_PTR(&br), info, brinBlock->firstKeyPKs + i, assist); + TSDB_CHECK_CODE(code, lino, _exit); + br.offset += (info->offsetCompressedSize + info->dataCompressedSize); + } + + for (int32_t i = 0; i < brinBlk->numOfPKs; i++) { + SValueColumnCompressInfo *info = lastInfos + i; + + code = tValueColumnDecompress(BR_PTR(&br), info, brinBlock->lastKeyPKs + i, assist); + TSDB_CHECK_CODE(code, lino, _exit); + br.offset += (info->offsetCompressedSize + info->dataCompressedSize); + } + } + + ASSERT(br.offset == br.buffer->size); + _exit: if (code) { TSDB_ERROR_LOG(TD_VID(reader->config->tsdb->pVnode), lino, code); @@ -226,19 +266,25 @@ _exit: return code; } +extern int32_t tBlockDataDecompress(SBufferReader *br, SBlockData *blockData, SBuffer *assist); + int32_t tsdbDataFileReadBlockData(SDataFileReader *reader, const SBrinRecord *record, SBlockData *bData) { int32_t code = 0; int32_t lino = 0; - code = tRealloc(&reader->config->bufArr[0], record->blockSize); + SBuffer *buffer = reader->buffers + 0; + SBuffer *assist = reader->buffers + 1; + + // load data + tBufferClear(buffer); + code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, record->blockSize, buffer, 0); TSDB_CHECK_CODE(code, lino, _exit); - code = - tsdbReadFile(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, reader->config->bufArr[0], record->blockSize, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tDecmprBlockData(reader->config->bufArr[0], record->blockSize, bData, &reader->config->bufArr[1]); + // decompress + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer); + code = tBlockDataDecompress(&br, bData, assist); TSDB_CHECK_CODE(code, lino, _exit); + ASSERT(br.offset == buffer->size); _exit: if (code) { @@ -252,138 +298,101 @@ int32_t tsdbDataFileReadBlockDataByColumn(SDataFileReader *reader, const SBrinRe int32_t code = 0; int32_t lino = 0; - code = tBlockDataInit(bData, (TABLEID *)record, pTSchema, cids, ncid); + SDiskDataHdr hdr; + SBuffer *buffer0 = reader->buffers + 0; + SBuffer *buffer1 = reader->buffers + 1; + SBuffer *assist = reader->buffers + 2; + + // load key part + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, record->blockKeySize, buffer0, 0); TSDB_CHECK_CODE(code, lino, _exit); - // uid + version + tskey - code = tRealloc(&reader->config->bufArr[0], record->blockKeySize); + // SDiskDataHdr + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); + code = tGetDiskDataHdr(&br, &hdr); TSDB_CHECK_CODE(code, lino, _exit); - code = tsdbReadFile(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, reader->config->bufArr[0], record->blockKeySize, - 0); + ASSERT(hdr.delimiter == TSDB_FILE_DLMT); + + tBlockDataReset(bData); + bData->suid = hdr.suid; + bData->uid = hdr.uid; + bData->nRow = hdr.nRow; + + // Key part + code = tBlockDataDecompressKeyPart(&hdr, &br, bData, assist); + TSDB_CHECK_CODE(code, lino, _exit); + ASSERT(br.offset == buffer0->size); + + bool loadExtra = false; + for (int i = 0; i < ncid; i++) { + if (tBlockDataGetColData(bData, cids[i]) == NULL) { + loadExtra = true; + break; + } + } + + if (!loadExtra) { + goto _exit; + } + + // load SBlockCol part + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset + record->blockKeySize, hdr.szBlkCol, + buffer0, 0); TSDB_CHECK_CODE(code, lino, _exit); - // hdr - SDiskDataHdr hdr[1]; - int32_t size = 0; + // load each column + SBlockCol blockCol = { + .cid = 0, + }; + br = BUFFER_READER_INITIALIZER(0, buffer0); + for (int32_t i = 0; i < ncid; i++) { + int16_t cid = cids[i]; - size += tGetDiskDataHdr(reader->config->bufArr[0] + size, hdr); + if (tBlockDataGetColData(bData, cid)) { // already loaded + continue; + } - ASSERT(hdr->delimiter == TSDB_FILE_DLMT); - ASSERT(record->uid == hdr->uid); + while (cid > blockCol.cid) { + if (br.offset >= buffer0->size) { + blockCol.cid = INT16_MAX; + break; + } - bData->nRow = hdr->nRow; - - // uid - ASSERT(hdr->uid); - - // version - code = tsdbDecmprData(reader->config->bufArr[0] + size, hdr->szVer, TSDB_DATA_TYPE_BIGINT, hdr->cmprAlg, - (uint8_t **)&bData->aVersion, sizeof(int64_t) * hdr->nRow, &reader->config->bufArr[1]); - TSDB_CHECK_CODE(code, lino, _exit); - size += hdr->szVer; - - // ts - code = tsdbDecmprData(reader->config->bufArr[0] + size, hdr->szKey, TSDB_DATA_TYPE_TIMESTAMP, hdr->cmprAlg, - (uint8_t **)&bData->aTSKEY, sizeof(TSKEY) * hdr->nRow, &reader->config->bufArr[1]); - TSDB_CHECK_CODE(code, lino, _exit); - size += hdr->szKey; - - ASSERT(size == record->blockKeySize); - - // other columns - if (bData->nColData > 0) { - if (hdr->szBlkCol > 0) { - code = tRealloc(&reader->config->bufArr[0], hdr->szBlkCol); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tsdbReadFile(reader->fd[TSDB_FTYPE_DATA], record->blockOffset + record->blockKeySize, - reader->config->bufArr[0], hdr->szBlkCol, 0); + code = tGetBlockCol(&br, &blockCol); TSDB_CHECK_CODE(code, lino, _exit); } - int64_t szHint = 0; - if (bData->nColData > 3) { - int64_t offset = 0; - SBlockCol bc = {.cid = 0}; - SBlockCol *blockCol = &bc; + if (cid < blockCol.cid) { + const STColumn *tcol = tTSchemaSearchColumn(pTSchema, cid); + ASSERT(tcol); + SBlockCol none = { + .cid = cid, + .type = tcol->type, + .cflag = tcol->flags, + .flag = HAS_NONE, + .szOrigin = 0, + .szBitmap = 0, + .szOffset = 0, + .szValue = 0, + .offset = 0, + }; + code = tBlockDataDecompressColData(&hdr, &none, &br, bData, assist); + TSDB_CHECK_CODE(code, lino, _exit); + } else if (cid == blockCol.cid) { + // load from file + tBufferClear(buffer1); + code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], + record->blockOffset + record->blockKeySize + hdr.szBlkCol + blockCol.offset, + blockCol.szBitmap + blockCol.szOffset + blockCol.szValue, buffer1, 0); + TSDB_CHECK_CODE(code, lino, _exit); - size = 0; - SColData *colData = tBlockDataGetColDataByIdx(bData, 0); - while (blockCol && blockCol->cid < colData->cid) { - if (size < hdr->szBlkCol) { - size += tGetBlockCol(reader->config->bufArr[0] + size, blockCol); - } else { - ASSERT(size == hdr->szBlkCol); - blockCol = NULL; - } - } - - if (blockCol && blockCol->flag == HAS_VALUE) { - offset = blockCol->offset; - - SColData *colDataEnd = tBlockDataGetColDataByIdx(bData, bData->nColData - 1); - while (blockCol && blockCol->cid < colDataEnd->cid) { - if (size < hdr->szBlkCol) { - size += tGetBlockCol(reader->config->bufArr[0] + size, blockCol); - } else { - ASSERT(size == hdr->szBlkCol); - blockCol = NULL; - } - } - - if (blockCol && blockCol->flag == HAS_VALUE) { - szHint = blockCol->offset + blockCol->szBitmap + blockCol->szOffset + blockCol->szValue - offset; - } - } - } - - SBlockCol bc[1] = {{.cid = 0}}; - SBlockCol *blockCol = bc; - - size = 0; - for (int32_t i = 0; i < bData->nColData; i++) { - SColData *colData = tBlockDataGetColDataByIdx(bData, i); - - while (blockCol && blockCol->cid < colData->cid) { - if (size < hdr->szBlkCol) { - size += tGetBlockCol(reader->config->bufArr[0] + size, blockCol); - } else { - ASSERT(size == hdr->szBlkCol); - blockCol = NULL; - } - } - - if (blockCol == NULL || blockCol->cid > colData->cid) { - for (int32_t iRow = 0; iRow < hdr->nRow; iRow++) { - code = tColDataAppendValue(colData, &COL_VAL_NONE(colData->cid, colData->type)); - TSDB_CHECK_CODE(code, lino, _exit); - } - } else { - ASSERT(blockCol->type == colData->type); - ASSERT(blockCol->flag && blockCol->flag != HAS_NONE); - - if (blockCol->flag == HAS_NULL) { - for (int32_t iRow = 0; iRow < hdr->nRow; iRow++) { - code = tColDataAppendValue(colData, &COL_VAL_NULL(blockCol->cid, blockCol->type)); - TSDB_CHECK_CODE(code, lino, _exit); - } - } else { - int32_t size1 = blockCol->szBitmap + blockCol->szOffset + blockCol->szValue; - - code = tRealloc(&reader->config->bufArr[1], size1); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tsdbReadFile(reader->fd[TSDB_FTYPE_DATA], - record->blockOffset + record->blockKeySize + hdr->szBlkCol + blockCol->offset, - reader->config->bufArr[1], size1, i > 0 ? 0 : szHint); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tsdbDecmprColData(reader->config->bufArr[1], blockCol, hdr->cmprAlg, hdr->nRow, colData, - &reader->config->bufArr[2]); - TSDB_CHECK_CODE(code, lino, _exit); - } - } + // decode the buffer + SBufferReader br1 = BUFFER_READER_INITIALIZER(0, buffer1); + code = tBlockDataDecompressColData(&hdr, &blockCol, &br1, bData, assist); + TSDB_CHECK_CODE(code, lino, _exit); } } @@ -396,28 +405,28 @@ _exit: int32_t tsdbDataFileReadBlockSma(SDataFileReader *reader, const SBrinRecord *record, TColumnDataAggArray *columnDataAggArray) { - int32_t code = 0; - int32_t lino = 0; + int32_t code = 0; + int32_t lino = 0; + SBuffer *buffer = reader->buffers + 0; TARRAY2_CLEAR(columnDataAggArray, NULL); if (record->smaSize > 0) { - code = tRealloc(&reader->config->bufArr[0], record->smaSize); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tsdbReadFile(reader->fd[TSDB_FTYPE_SMA], record->smaOffset, reader->config->bufArr[0], record->smaSize, 0); + tBufferClear(buffer); + code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_SMA], record->smaOffset, record->smaSize, buffer, 0); TSDB_CHECK_CODE(code, lino, _exit); // decode sma data - int32_t size = 0; - while (size < record->smaSize) { + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer); + while (br.offset < record->smaSize) { SColumnDataAgg sma[1]; - size += tGetColumnDataAgg(reader->config->bufArr[0] + size, sma); + code = tGetColumnDataAgg(&br, sma); + TSDB_CHECK_CODE(code, lino, _exit); code = TARRAY2_APPEND_PTR(columnDataAggArray, sma); TSDB_CHECK_CODE(code, lino, _exit); } - ASSERT(size == record->smaSize); + ASSERT(br.offset == record->smaSize); } _exit: @@ -470,26 +479,28 @@ int32_t tsdbDataFileReadTombBlock(SDataFileReader *reader, const STombBlk *tombB int32_t code = 0; int32_t lino = 0; - code = tRealloc(&reader->config->bufArr[0], tombBlk->dp->size); + SBuffer *buffer0 = reader->buffers + 0; + SBuffer *assist = reader->buffers + 1; + + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_TOMB], tombBlk->dp->offset, tombBlk->dp->size, buffer0, 0); TSDB_CHECK_CODE(code, lino, _exit); - code = - tsdbReadFile(reader->fd[TSDB_FTYPE_TOMB], tombBlk->dp->offset, reader->config->bufArr[0], tombBlk->dp->size, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - int32_t size = 0; + int32_t size = 0; + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); tTombBlockClear(tData); - for (int32_t i = 0; i < ARRAY_SIZE(tData->dataArr); ++i) { - code = tsdbDecmprData(reader->config->bufArr[0] + size, tombBlk->size[i], TSDB_DATA_TYPE_BIGINT, tombBlk->cmprAlg, - &reader->config->bufArr[1], sizeof(int64_t) * tombBlk->numRec, &reader->config->bufArr[2]); + tData->numOfRecords = tombBlk->numRec; + for (int32_t i = 0; i < ARRAY_SIZE(tData->buffers); ++i) { + SCompressInfo cinfo = { + .cmprAlg = tombBlk->cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .originalSize = tombBlk->numRec * sizeof(int64_t), + .compressedSize = tombBlk->size[i], + }; + code = tDecompressDataToBuffer(BR_PTR(&br), &cinfo, tData->buffers + i, assist); TSDB_CHECK_CODE(code, lino, _exit); - - code = TARRAY2_APPEND_BATCH(&tData->dataArr[i], reader->config->bufArr[1], tombBlk->numRec); - TSDB_CHECK_CODE(code, lino, _exit); - - size += tombBlk->size[i]; + br.offset += tombBlk->size[i]; } - ASSERT(size == tombBlk->dp->size); _exit: if (code) { @@ -504,7 +515,8 @@ struct SDataFileWriter { SSkmInfo skmTb[1]; SSkmInfo skmRow[1]; - uint8_t *bufArr[5]; + SBuffer local[10]; + SBuffer *buffers; struct { bool opened; @@ -565,8 +577,8 @@ static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) { tBlockDataDestroy(writer->ctx->blockData); tBrinBlockDestroy(writer->ctx->brinBlock); - for (int32_t i = 0; i < ARRAY_SIZE(writer->bufArr); ++i) { - tFree(writer->bufArr[i]); + for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) { + tBufferDestroy(writer->local + i); } tDestroyTSchema(writer->skmRow->pTSchema); @@ -583,7 +595,7 @@ static int32_t tsdbDataFileWriterDoOpenReader(SDataFileWriter *writer) { SDataFileReaderConfig config[1] = {{ .tsdb = writer->config->tsdb, .szPage = writer->config->szPage, - .bufArr = writer->config->bufArr, + .buffers = writer->buffers, }}; for (int32_t i = 0; i < TSDB_FTYPE_MAX; ++i) { @@ -613,7 +625,10 @@ static int32_t tsdbDataFileWriterDoOpen(SDataFileWriter *writer) { if (!writer->config->skmTb) writer->config->skmTb = writer->skmTb; if (!writer->config->skmRow) writer->config->skmRow = writer->skmRow; - if (!writer->config->bufArr) writer->config->bufArr = writer->bufArr; + writer->buffers = writer->config->buffers; + if (writer->buffers == NULL) { + writer->buffers = writer->local; + } // open reader code = tsdbDataFileWriterDoOpenReader(writer); @@ -695,83 +710,110 @@ int32_t tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxV } int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, int8_t cmprAlg, int64_t *fileSize, - TBrinBlkArray *brinBlkArray, uint8_t **bufArr, SVersionRange *range) { - if (BRIN_BLOCK_SIZE(brinBlock) == 0) return 0; + TBrinBlkArray *brinBlkArray, SBuffer *buffers, SVersionRange *range) { + if (brinBlock->numOfRecords == 0) return 0; - int32_t code; + int32_t code; + SBuffer *buffer0 = buffers + 0; + SBuffer *buffer1 = buffers + 1; + SBuffer *assist = buffers + 2; - // get SBrinBlk - SBrinBlk brinBlk[1] = { - { - .dp[0] = - { - .offset = *fileSize, - .size = 0, - }, - .minTbid = - { - .suid = TARRAY2_FIRST(brinBlock->suid), - .uid = TARRAY2_FIRST(brinBlock->uid), - }, - .maxTbid = - { - .suid = TARRAY2_LAST(brinBlock->suid), - .uid = TARRAY2_LAST(brinBlock->uid), - }, - .minVer = TARRAY2_FIRST(brinBlock->minVer), - .maxVer = TARRAY2_FIRST(brinBlock->minVer), - .numRec = BRIN_BLOCK_SIZE(brinBlock), - .cmprAlg = cmprAlg, - }, + SBrinBlk brinBlk = { + .dp[0] = + { + .offset = *fileSize, + .size = 0, + }, + .numRec = brinBlock->numOfRecords, + .numOfPKs = brinBlock->numOfPKs, + .cmprAlg = cmprAlg, }; + for (int i = 0; i < brinBlock->numOfRecords; i++) { + SBrinRecord record; - for (int32_t i = 1; i < BRIN_BLOCK_SIZE(brinBlock); i++) { - if (brinBlk->minVer > TARRAY2_GET(brinBlock->minVer, i)) { - brinBlk->minVer = TARRAY2_GET(brinBlock->minVer, i); + tBrinBlockGet(brinBlock, i, &record); + if (i == 0) { + brinBlk.minTbid.suid = record.suid; + brinBlk.minTbid.uid = record.uid; + brinBlk.minVer = record.minVer; + brinBlk.maxVer = record.maxVer; } - if (brinBlk->maxVer < TARRAY2_GET(brinBlock->maxVer, i)) { - brinBlk->maxVer = TARRAY2_GET(brinBlock->maxVer, i); + if (i == brinBlock->numOfRecords - 1) { + brinBlk.maxTbid.suid = record.suid; + brinBlk.maxTbid.uid = record.uid; + } + if (record.minVer < brinBlk.minVer) { + brinBlk.minVer = record.minVer; + } + if (record.maxVer > brinBlk.maxVer) { + brinBlk.maxVer = record.maxVer; } } - tsdbWriterUpdVerRange(range, brinBlk->minVer, brinBlk->maxVer); + tsdbWriterUpdVerRange(range, brinBlk.minVer, brinBlk.maxVer); // write to file - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr1); i++) { - code = tsdbCmprData((uint8_t *)TARRAY2_DATA(brinBlock->dataArr1 + i), TARRAY2_DATA_LEN(brinBlock->dataArr1 + i), - TSDB_DATA_TYPE_BIGINT, brinBlk->cmprAlg, &bufArr[0], 0, &brinBlk->size[i], &bufArr[1]); - if (code) return code; + for (int32_t i = 0; i < 10; ++i) { + SCompressInfo info = { + .cmprAlg = cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .originalSize = brinBlock->buffers[i].size, + }; - code = tsdbWriteFile(fd, *fileSize, bufArr[0], brinBlk->size[i]); + tBufferClear(buffer0); + code = tCompressDataToBuffer(brinBlock->buffers[i].data, &info, buffer0, assist); if (code) return code; + code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size); + if (code) return code; + brinBlk.size[i] = info.compressedSize; + brinBlk.dp->size += info.compressedSize; + *fileSize += info.compressedSize; + } + for (int32_t i = 10; i < 15; ++i) { + SCompressInfo info = { + .cmprAlg = cmprAlg, + .dataType = TSDB_DATA_TYPE_INT, + .originalSize = brinBlock->buffers[i].size, + }; - brinBlk->dp->size += brinBlk->size[i]; - *fileSize += brinBlk->size[i]; + tBufferClear(buffer0); + code = tCompressDataToBuffer(brinBlock->buffers[i].data, &info, buffer0, assist); + if (code) return code; + code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size); + if (code) return code; + brinBlk.size[i] = info.compressedSize; + brinBlk.dp->size += info.compressedSize; + *fileSize += info.compressedSize; } - for (int32_t i = 0, j = ARRAY_SIZE(brinBlock->dataArr1); i < ARRAY_SIZE(brinBlock->dataArr2); i++, j++) { - code = tsdbCmprData((uint8_t *)TARRAY2_DATA(brinBlock->dataArr2 + i), TARRAY2_DATA_LEN(brinBlock->dataArr2 + i), - TSDB_DATA_TYPE_INT, brinBlk->cmprAlg, &bufArr[0], 0, &brinBlk->size[j], &bufArr[1]); - if (code) return code; + // write primary keys to file + if (brinBlock->numOfPKs > 0) { + tBufferClear(buffer0); + tBufferClear(buffer1); - code = tsdbWriteFile(fd, *fileSize, bufArr[0], brinBlk->size[j]); - if (code) return code; + // encode + for (int i = 0; i < brinBlock->numOfPKs; i++) { + SValueColumnCompressInfo info = {.cmprAlg = cmprAlg}; + if ((code = tValueColumnCompress(&brinBlock->firstKeyPKs[i], &info, buffer1, assist))) return code; + if ((code = tValueColumnCompressInfoEncode(&info, buffer0))) return code; + } + for (int i = 0; i < brinBlock->numOfPKs; i++) { + SValueColumnCompressInfo info = {.cmprAlg = cmprAlg}; + if ((code = tValueColumnCompress(&brinBlock->lastKeyPKs[i], &info, buffer1, assist))) return code; + if ((code = tValueColumnCompressInfoEncode(&info, buffer0))) return code; + } - brinBlk->dp->size += brinBlk->size[j]; - *fileSize += brinBlk->size[j]; + // write to file + if ((code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size))) return code; + *fileSize += buffer0->size; + brinBlk.dp->size += buffer0->size; + if ((code = tsdbWriteFile(fd, *fileSize, buffer1->data, buffer1->size))) return code; + *fileSize += buffer1->size; + brinBlk.dp->size += buffer1->size; } -#if 0 - SBrinRecord record; - for (int32_t i = 0; i < BRIN_BLOCK_SIZE(brinBlock); i++) { - tBrinBlockGet(brinBlock, i, &record); - tsdbInfo("write brin block, block num:%04d, idx:%04d suid:%ld, uid:%ld, offset:%ld, numRow:%d, count:%d", - TARRAY2_SIZE(brinBlkArray), i, record.suid, record.uid, record.blockOffset, record.numRow, record.count); - } -#endif - // append to brinBlkArray - code = TARRAY2_APPEND_PTR(brinBlkArray, brinBlk); + code = TARRAY2_APPEND_PTR(brinBlkArray, &brinBlk); if (code) return code; tBrinBlockClear(brinBlock); @@ -780,13 +822,13 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, int8_t cmprAl } static int32_t tsdbDataFileWriteBrinBlock(SDataFileWriter *writer) { - if (BRIN_BLOCK_SIZE(writer->brinBlock) == 0) return 0; + if (writer->brinBlock->numOfRecords == 0) return 0; int32_t code = 0; int32_t lino = 0; code = tsdbFileWriteBrinBlock(writer->fd[TSDB_FTYPE_HEAD], writer->brinBlock, writer->config->cmprAlg, - &writer->files[TSDB_FTYPE_HEAD].size, writer->brinBlkArray, writer->config->bufArr, + &writer->files[TSDB_FTYPE_HEAD].size, writer->brinBlkArray, writer->buffers, &writer->ctx->range); TSDB_CHECK_CODE(code, lino, _exit); @@ -801,10 +843,20 @@ static int32_t tsdbDataFileWriteBrinRecord(SDataFileWriter *writer, const SBrinR int32_t code = 0; int32_t lino = 0; - code = tBrinBlockPut(writer->brinBlock, record); - TSDB_CHECK_CODE(code, lino, _exit); + for (;;) { + code = tBrinBlockPut(writer->brinBlock, record); + if (code == TSDB_CODE_INVALID_PARA) { + // different records with different primary keys + code = tsdbDataFileWriteBrinBlock(writer); + TSDB_CHECK_CODE(code, lino, _exit); + continue; + } else { + TSDB_CHECK_CODE(code, lino, _exit); + } + break; + } - if (BRIN_BLOCK_SIZE(writer->brinBlock) >= writer->config->maxRow) { + if ((writer->brinBlock->numOfRecords) >= writer->config->maxRow) { code = tsdbDataFileWriteBrinBlock(writer); TSDB_CHECK_CODE(code, lino, _exit); } @@ -821,16 +873,14 @@ static int32_t tsdbDataFileDoWriteBlockData(SDataFileWriter *writer, SBlockData ASSERT(bData->uid); - int32_t code = 0; - int32_t lino = 0; + int32_t code = 0; + int32_t lino = 0; + SBuffer *buffers = writer->buffers; + SBuffer *assist = writer->buffers + 4; SBrinRecord record[1] = {{ .suid = bData->suid, .uid = bData->uid, - .firstKey = bData->aTSKEY[0], - .firstKeyVer = bData->aVersion[0], - .lastKey = bData->aTSKEY[bData->nRow - 1], - .lastKeyVer = bData->aVersion[bData->nRow - 1], .minVer = bData->aVersion[0], .maxVer = bData->aVersion[0], .blockOffset = writer->files[TSDB_FTYPE_DATA].size, @@ -843,8 +893,11 @@ static int32_t tsdbDataFileDoWriteBlockData(SDataFileWriter *writer, SBlockData }}; + tsdbRowGetKey(&tsdbRowFromBlockData(bData, 0), &record->firstKey); + tsdbRowGetKey(&tsdbRowFromBlockData(bData, bData->nRow - 1), &record->lastKey); + for (int32_t i = 1; i < bData->nRow; ++i) { - if (bData->aTSKEY[i] != bData->aTSKEY[i - 1]) { + if (tsdbRowCompareWithoutVersion(&tsdbRowFromBlockData(bData, i - 1), &tsdbRowFromBlockData(bData, i)) != 0) { record->count++; } if (bData->aVersion[i] < record->minVer) { @@ -858,42 +911,35 @@ static int32_t tsdbDataFileDoWriteBlockData(SDataFileWriter *writer, SBlockData tsdbWriterUpdVerRange(&writer->ctx->range, record->minVer, record->maxVer); // to .data file - int32_t sizeArr[5] = {0}; - - code = tCmprBlockData(bData, writer->config->cmprAlg, NULL, NULL, writer->config->bufArr, sizeArr); + code = tBlockDataCompress(bData, writer->config->cmprAlg, buffers, assist); TSDB_CHECK_CODE(code, lino, _exit); - record->blockKeySize = sizeArr[3] + sizeArr[2]; - record->blockSize = sizeArr[0] + sizeArr[1] + record->blockKeySize; + record->blockKeySize = buffers[0].size + buffers[1].size; + record->blockSize = record->blockKeySize + buffers[2].size + buffers[3].size; - for (int32_t i = 3; i >= 0; --i) { - if (sizeArr[i]) { - code = tsdbWriteFile(writer->fd[TSDB_FTYPE_DATA], writer->files[TSDB_FTYPE_DATA].size, writer->config->bufArr[i], - sizeArr[i]); - TSDB_CHECK_CODE(code, lino, _exit); - writer->files[TSDB_FTYPE_DATA].size += sizeArr[i]; - } + for (int i = 0; i < 4; i++) { + code = tsdbWriteFile(writer->fd[TSDB_FTYPE_DATA], writer->files[TSDB_FTYPE_DATA].size, buffers[i].data, + buffers[i].size); + TSDB_CHECK_CODE(code, lino, _exit); + writer->files[TSDB_FTYPE_DATA].size += buffers[i].size; } // to .sma file + tBufferClear(&buffers[0]); for (int32_t i = 0; i < bData->nColData; ++i) { SColData *colData = bData->aColData + i; - if ((!colData->smaOn) || ((colData->flag & HAS_VALUE) == 0)) continue; + if ((colData->cflag & COL_SMA_ON) == 0 || ((colData->flag & HAS_VALUE) == 0)) continue; SColumnDataAgg sma[1] = {{.colId = colData->cid}}; tColDataCalcSMA[colData->type](colData, &sma->sum, &sma->max, &sma->min, &sma->numOfNull); - int32_t size = tPutColumnDataAgg(NULL, sma); - - code = tRealloc(&writer->config->bufArr[0], record->smaSize + size); + code = tPutColumnDataAgg(&buffers[0], sma); TSDB_CHECK_CODE(code, lino, _exit); - - tPutColumnDataAgg(writer->config->bufArr[0] + record->smaSize, sma); - record->smaSize += size; } + record->smaSize = buffers[0].size; if (record->smaSize > 0) { - code = tsdbWriteFile(writer->fd[TSDB_FTYPE_SMA], record->smaOffset, writer->config->bufArr[0], record->smaSize); + code = tsdbWriteFile(writer->fd[TSDB_FTYPE_SMA], record->smaOffset, buffers[0].data, record->smaSize); TSDB_CHECK_CODE(code, lino, _exit); writer->files[TSDB_FTYPE_SMA].size += record->smaSize; } @@ -911,32 +957,6 @@ _exit: return code; } -static int32_t tsdbDataFileWriteDataBlk(SDataFileWriter *writer, const TDataBlkArray *dataBlkArray) { - if (TARRAY2_SIZE(dataBlkArray) == 0) return 0; - - int32_t code = 0; - int32_t lino = 0; - - int32_t ftype = TSDB_FTYPE_HEAD; - SBlockIdx blockIdx[1] = {{ - .suid = writer->ctx->tbid->suid, - .uid = writer->ctx->tbid->uid, - .offset = writer->files[ftype].size, - .size = TARRAY2_DATA_LEN(dataBlkArray), - }}; - - code = - tsdbWriteFile(writer->fd[ftype], blockIdx->offset, (const uint8_t *)TARRAY2_DATA(dataBlkArray), blockIdx->size); - TSDB_CHECK_CODE(code, lino, _exit); - writer->files[ftype].size += blockIdx->size; - -_exit: - if (code) { - TSDB_ERROR_LOG(TD_VID(writer->config->tsdb->pVnode), lino, code); - } - return code; -} - static int32_t tsdbDataFileDoWriteTSRow(SDataFileWriter *writer, TSDBROW *row) { int32_t code = 0; int32_t lino = 0; @@ -947,17 +967,10 @@ static int32_t tsdbDataFileDoWriteTSRow(SDataFileWriter *writer, TSDBROW *row) { TSDB_CHECK_CODE(code, lino, _exit); } - TSDBKEY key[1]; - if (row->type == TSDBROW_ROW_FMT) { - key->ts = row->pTSRow->ts; - key->version = row->version; - } else { - key->ts = row->pBlockData->aTSKEY[row->iRow]; - key->version = row->pBlockData->aVersion[row->iRow]; - } - if (key->version <= writer->config->compactVersion // - && writer->blockData->nRow > 0 // - && writer->blockData->aTSKEY[writer->blockData->nRow - 1] == key->ts // + if (TSDBROW_VERSION(row) <= writer->config->compactVersion // + && writer->blockData->nRow > 0 // + && + tsdbRowCompareWithoutVersion(row, &tsdbRowFromBlockData(writer->blockData, writer->blockData->nRow - 1)) == 0 // ) { code = tBlockDataUpdateRow(writer->blockData, row, writer->config->skmRow->pTSchema); TSDB_CHECK_CODE(code, lino, _exit); @@ -978,46 +991,57 @@ _exit: return code; } -static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const TSDBKEY *key) { +static FORCE_INLINE int32_t tsdbRowKeyCmprNullAsLargest(const STsdbRowKey *key1, const STsdbRowKey *key2) { + if (key1 == NULL) { + return 1; + } else if (key2 == NULL) { + return -1; + } else { + return tsdbRowKeyCmpr(key1, key2); + } +} + +static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const STsdbRowKey *key) { if (writer->ctx->tbHasOldData == false) return 0; - int32_t code = 0; - int32_t lino = 0; + int32_t code = 0; + int32_t lino = 0; + STsdbRowKey rowKey; for (;;) { for (;;) { // SBlockData for (; writer->ctx->blockDataIdx < writer->ctx->blockData->nRow; writer->ctx->blockDataIdx++) { - if (key->ts < writer->ctx->blockData->aTSKEY[writer->ctx->blockDataIdx] // - || (key->ts == writer->ctx->blockData->aTSKEY[writer->ctx->blockDataIdx] && - key->version < writer->ctx->blockData->aVersion[writer->ctx->blockDataIdx])) { - goto _exit; - } else { - TSDBROW row = tsdbRowFromBlockData(writer->ctx->blockData, writer->ctx->blockDataIdx); + TSDBROW row = tsdbRowFromBlockData(writer->ctx->blockData, writer->ctx->blockDataIdx); + + tsdbRowGetKey(&row, &rowKey); + if (tsdbRowKeyCmprNullAsLargest(&rowKey, key) < 0) { // key <= rowKey code = tsdbDataFileDoWriteTSRow(writer, &row); TSDB_CHECK_CODE(code, lino, _exit); + } else { + goto _exit; } } // SBrinBlock - if (writer->ctx->brinBlockIdx >= BRIN_BLOCK_SIZE(writer->ctx->brinBlock)) { + if (writer->ctx->brinBlockIdx >= writer->ctx->brinBlock->numOfRecords) { break; } - for (; writer->ctx->brinBlockIdx < BRIN_BLOCK_SIZE(writer->ctx->brinBlock); writer->ctx->brinBlockIdx++) { - if (TARRAY2_GET(writer->ctx->brinBlock->uid, writer->ctx->brinBlockIdx) != writer->ctx->tbid->uid) { + for (; writer->ctx->brinBlockIdx < writer->ctx->brinBlock->numOfRecords; writer->ctx->brinBlockIdx++) { + SBrinRecord record; + tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record); + if (record.uid != writer->ctx->tbid->uid) { writer->ctx->tbHasOldData = false; goto _exit; } - if (key->ts < TARRAY2_GET(writer->ctx->brinBlock->firstKey, writer->ctx->brinBlockIdx) // - || (key->ts == TARRAY2_GET(writer->ctx->brinBlock->firstKey, writer->ctx->brinBlockIdx) && - key->version < TARRAY2_GET(writer->ctx->brinBlock->firstKeyVer, writer->ctx->brinBlockIdx))) { + if (tsdbRowKeyCmprNullAsLargest(key, &record.firstKey) < 0) { // key < record->firstKey goto _exit; } else { SBrinRecord record[1]; tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record); - if (key->ts > record->lastKey || (key->ts == record->lastKey && key->version > record->maxVer)) { + if (tsdbRowKeyCmprNullAsLargest(key, &record->lastKey) > 0) { // key > record->lastKey if (writer->blockData->nRow > 0) { code = tsdbDataFileDoWriteBlockData(writer, writer->blockData); TSDB_CHECK_CODE(code, lino, _exit); @@ -1070,16 +1094,10 @@ static int32_t tsdbDataFileDoWriteTSData(SDataFileWriter *writer, TSDBROW *row) int32_t lino = 0; if (writer->ctx->tbHasOldData) { - TSDBKEY key[1]; - if (row->type == TSDBROW_ROW_FMT) { - key->ts = row->pTSRow->ts; - key->version = row->version; - } else { - key->ts = row->pBlockData->aTSKEY[row->iRow]; - key->version = row->pBlockData->aVersion[row->iRow]; - } + STsdbRowKey key; + tsdbRowGetKey(row, &key); - code = tsdbDataFileDoWriteTableOldData(writer, key); + code = tsdbDataFileDoWriteTableOldData(writer, &key); TSDB_CHECK_CODE(code, lino, _exit); } @@ -1100,12 +1118,7 @@ static int32_t tsdbDataFileWriteTableDataEnd(SDataFileWriter *writer) { int32_t lino = 0; if (writer->ctx->tbHasOldData) { - TSDBKEY key = { - .ts = TSKEY_MAX, - .version = VERSION_MAX, - }; - - code = tsdbDataFileDoWriteTableOldData(writer, &key); + code = tsdbDataFileDoWriteTableOldData(writer, NULL /* as the largest key */); TSDB_CHECK_CODE(code, lino, _exit); ASSERT(writer->ctx->tbHasOldData == false); @@ -1133,35 +1146,32 @@ static int32_t tsdbDataFileWriteTableDataBegin(SDataFileWriter *writer, const TA TABLEID tbid1[1]; writer->ctx->tbHasOldData = false; while (writer->ctx->brinBlkArray) { // skip data of previous table - for (; writer->ctx->brinBlockIdx < BRIN_BLOCK_SIZE(writer->ctx->brinBlock); writer->ctx->brinBlockIdx++) { - TABLEID tbid2[1] = {{ - .suid = TARRAY2_GET(writer->ctx->brinBlock->suid, writer->ctx->brinBlockIdx), - .uid = TARRAY2_GET(writer->ctx->brinBlock->uid, writer->ctx->brinBlockIdx), - }}; + for (; writer->ctx->brinBlockIdx < writer->ctx->brinBlock->numOfRecords; writer->ctx->brinBlockIdx++) { + SBrinRecord record; + tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record); - if (tbid2->uid == tbid->uid) { + if (record.uid == tbid->uid) { writer->ctx->tbHasOldData = true; goto _begin; - } else if (tbid2->suid > tbid->suid || (tbid2->suid == tbid->suid && tbid2->uid > tbid->uid)) { + } else if (record.suid > tbid->suid || (record.suid == tbid->suid && record.uid > tbid->uid)) { goto _begin; } else { - if (tbid2->uid != writer->ctx->tbid->uid) { - if (drop && tbid1->uid == tbid2->uid) { + if (record.uid != writer->ctx->tbid->uid) { + if (drop && tbid1->uid == record.uid) { continue; - } else if (metaGetInfo(writer->config->tsdb->pVnode->pMeta, tbid2->uid, &info, NULL) != 0) { + } else if (metaGetInfo(writer->config->tsdb->pVnode->pMeta, record.uid, &info, NULL) != 0) { drop = true; - *tbid1 = *tbid2; + tbid1->suid = record.suid; + tbid1->uid = record.uid; continue; } else { drop = false; - writer->ctx->tbid[0] = *tbid2; + writer->ctx->tbid->suid = record.suid; + writer->ctx->tbid->uid = record.uid; } } - SBrinRecord record[1]; - tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record); - - code = tsdbDataFileWriteBrinRecord(writer, record); + code = tsdbDataFileWriteBrinRecord(writer, &record); TSDB_CHECK_CODE(code, lino, _exit); } } @@ -1206,57 +1216,67 @@ int32_t tsdbFileWriteHeadFooter(STsdbFD *fd, int64_t *fileSize, const SHeadFoote } int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAlg, int64_t *fileSize, - TTombBlkArray *tombBlkArray, uint8_t **bufArr, SVersionRange *range) { + TTombBlkArray *tombBlkArray, SBuffer *buffers, SVersionRange *range) { int32_t code; if (TOMB_BLOCK_SIZE(tombBlock) == 0) return 0; - STombBlk tombBlk[1] = {{ + SBuffer *buffer0 = buffers + 0; + SBuffer *assist = buffers + 1; + + STombBlk tombBlk = { .dp[0] = { .offset = *fileSize, .size = 0, }, - .minTbid = - { - .suid = TARRAY2_FIRST(tombBlock->suid), - .uid = TARRAY2_FIRST(tombBlock->uid), - }, - .maxTbid = - { - .suid = TARRAY2_LAST(tombBlock->suid), - .uid = TARRAY2_LAST(tombBlock->uid), - }, - .minVer = TARRAY2_FIRST(tombBlock->version), - .maxVer = TARRAY2_FIRST(tombBlock->version), .numRec = TOMB_BLOCK_SIZE(tombBlock), .cmprAlg = cmprAlg, - }}; + }; + for (int i = 0; i < TOMB_BLOCK_SIZE(tombBlock); i++) { + STombRecord record; + tTombBlockGet(tombBlock, i, &record); - for (int32_t i = 1; i < TOMB_BLOCK_SIZE(tombBlock); i++) { - if (tombBlk->minVer > TARRAY2_GET(tombBlock->version, i)) { - tombBlk->minVer = TARRAY2_GET(tombBlock->version, i); + if (i == 0) { + tombBlk.minTbid.suid = record.suid; + tombBlk.minTbid.uid = record.uid; + tombBlk.minVer = record.version; + tombBlk.maxVer = record.version; } - if (tombBlk->maxVer < TARRAY2_GET(tombBlock->version, i)) { - tombBlk->maxVer = TARRAY2_GET(tombBlock->version, i); + if (i == TOMB_BLOCK_SIZE(tombBlock) - 1) { + tombBlk.maxTbid.suid = record.suid; + tombBlk.maxTbid.uid = record.uid; + } + if (record.version < tombBlk.minVer) { + tombBlk.minVer = record.version; + } + if (record.version > tombBlk.maxVer) { + tombBlk.maxVer = record.version; } } - tsdbWriterUpdVerRange(range, tombBlk->minVer, tombBlk->maxVer); + tsdbWriterUpdVerRange(range, tombBlk.minVer, tombBlk.maxVer); - for (int32_t i = 0; i < ARRAY_SIZE(tombBlock->dataArr); i++) { - code = tsdbCmprData((uint8_t *)TARRAY2_DATA(&tombBlock->dataArr[i]), TARRAY2_DATA_LEN(&tombBlock->dataArr[i]), - TSDB_DATA_TYPE_BIGINT, tombBlk->cmprAlg, &bufArr[0], 0, &tombBlk->size[i], &bufArr[1]); + for (int32_t i = 0; i < ARRAY_SIZE(tombBlock->buffers); i++) { + tBufferClear(buffer0); + + SCompressInfo cinfo = { + .cmprAlg = cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .originalSize = tombBlock->buffers[i].size, + }; + code = tCompressDataToBuffer(tombBlock->buffers[i].data, &cinfo, buffer0, assist); if (code) return code; - code = tsdbWriteFile(fd, *fileSize, bufArr[0], tombBlk->size[i]); + code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size); if (code) return code; - tombBlk->dp->size += tombBlk->size[i]; - *fileSize += tombBlk->size[i]; + tombBlk.size[i] = cinfo.compressedSize; + tombBlk.dp->size += tombBlk.size[i]; + *fileSize += tombBlk.size[i]; } - code = TARRAY2_APPEND_PTR(tombBlkArray, tombBlk); + code = TARRAY2_APPEND_PTR(tombBlkArray, &tombBlk); if (code) return code; tTombBlockClear(tombBlock); @@ -1284,7 +1304,7 @@ static int32_t tsdbDataFileDoWriteTombBlock(SDataFileWriter *writer) { int32_t lino = 0; code = tsdbFileWriteTombBlock(writer->fd[TSDB_FTYPE_TOMB], writer->tombBlock, writer->config->cmprAlg, - &writer->files[TSDB_FTYPE_TOMB].size, writer->tombBlkArray, writer->config->bufArr, + &writer->files[TSDB_FTYPE_TOMB].size, writer->tombBlkArray, writer->buffers, &writer->ctx->tombRange); TSDB_CHECK_CODE(code, lino, _exit); @@ -1740,11 +1760,9 @@ int32_t tsdbDataFileWriteBlockData(SDataFileWriter *writer, SBlockData *bData) { } if (writer->ctx->tbHasOldData) { - TSDBKEY key = { - .ts = bData->aTSKEY[0], - .version = bData->aVersion[0], - }; + STsdbRowKey key; + tsdbRowGetKey(&tsdbRowFromBlockData(bData, 0), &key); code = tsdbDataFileDoWriteTableOldData(writer, &key); TSDB_CHECK_CODE(code, lino, _exit); } diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.h b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.h index becb395836..ce879247bf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.h +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.h @@ -25,18 +25,16 @@ extern "C" { #endif -typedef TARRAY2(SBlockIdx) TBlockIdxArray; -typedef TARRAY2(SDataBlk) TDataBlkArray; typedef TARRAY2(SColumnDataAgg) TColumnDataAggArray; typedef struct { SFDataPtr brinBlkPtr[1]; - SFDataPtr rsrvd[2]; + char rsrvd[32]; } SHeadFooter; typedef struct { SFDataPtr tombBlkPtr[1]; - SFDataPtr rsrvd[2]; + char rsrvd[32]; } STombFooter; // SDataFileReader ============================================= @@ -48,7 +46,7 @@ typedef struct SDataFileReaderConfig { bool exist; STFile file; } files[TSDB_FTYPE_MAX]; - uint8_t **bufArr; + SBuffer *buffers; } SDataFileReaderConfig; int32_t tsdbDataFileReaderOpen(const char *fname[/* TSDB_FTYPE_MAX */], const SDataFileReaderConfig *config, @@ -86,7 +84,7 @@ typedef struct SDataFileWriterConfig { SSkmInfo *skmTb; SSkmInfo *skmRow; SHashObj *pColCmpr; - uint8_t **bufArr; + SBuffer *buffers; } SDataFileWriterConfig; int32_t tsdbDataFileWriterOpen(const SDataFileWriterConfig *config, SDataFileWriter **writer); @@ -98,14 +96,14 @@ int32_t tsdbDataFileFlush(SDataFileWriter *writer); // head int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, int8_t cmprAlg, int64_t *fileSize, - TBrinBlkArray *brinBlkArray, uint8_t **bufArr, SVersionRange *range); + TBrinBlkArray *brinBlkArray, SBuffer *buffers, SVersionRange *range); int32_t tsdbFileWriteBrinBlk(STsdbFD *fd, TBrinBlkArray *brinBlkArray, SFDataPtr *ptr, int64_t *fileSize); int32_t tsdbFileWriteHeadFooter(STsdbFD *fd, int64_t *fileSize, const SHeadFooter *footer); // tomb int32_t tsdbDataFileWriteTombRecord(SDataFileWriter *writer, const STombRecord *record); int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAlg, int64_t *fileSize, - TTombBlkArray *tombBlkArray, uint8_t **bufArr, SVersionRange *range); + TTombBlkArray *tombBlkArray, SBuffer *buffers, SVersionRange *range); int32_t tsdbFileWriteTombBlk(STsdbFD *fd, const TTombBlkArray *tombBlkArray, SFDataPtr *ptr, int64_t *fileSize); int32_t tsdbFileWriteTombFooter(STsdbFD *fd, const STombFooter *footer, int64_t *fileSize); diff --git a/source/dnode/vnode/src/tsdb/tsdbDataIter.c b/source/dnode/vnode/src/tsdb/tsdbDataIter.c deleted file mode 100644 index e1e6bd5f1f..0000000000 --- a/source/dnode/vnode/src/tsdb/tsdbDataIter.c +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "tsdb.h" -#include "vnodeInt.h" - -#ifdef BUILD_NO_CALL -// STsdbDataIter2 -/* open */ -int32_t tsdbOpenDataFileDataIter(SDataFReader* pReader, STsdbDataIter2** ppIter) { - int32_t code = 0; - int32_t lino = 0; - - // create handle - STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter)); - if (pIter == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - - pIter->type = TSDB_DATA_FILE_DATA_ITER; - pIter->dIter.pReader = pReader; - if ((pIter->dIter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx))) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - - code = tBlockDataCreate(&pIter->dIter.bData); - TSDB_CHECK_CODE(code, lino, _exit); - - pIter->dIter.iBlockIdx = 0; - pIter->dIter.iDataBlk = 0; - pIter->dIter.iRow = 0; - - // read data - code = tsdbReadBlockIdx(pReader, pIter->dIter.aBlockIdx); - TSDB_CHECK_CODE(code, lino, _exit); - - if (taosArrayGetSize(pIter->dIter.aBlockIdx) == 0) goto _clear; - -_exit: - if (code) { - if (pIter) { - _clear: - tBlockDataDestroy(&pIter->dIter.bData); - taosArrayDestroy(pIter->dIter.aBlockIdx); - taosMemoryFree(pIter); - pIter = NULL; - } - } - *ppIter = pIter; - return code; -} - -int32_t tsdbOpenSttFileDataIter(SDataFReader* pReader, int32_t iStt, STsdbDataIter2** ppIter) { - int32_t code = 0; - int32_t lino = 0; - - // create handle - STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter)); - if (pIter == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - - pIter->type = TSDB_STT_FILE_DATA_ITER; - pIter->sIter.pReader = pReader; - pIter->sIter.iStt = iStt; - pIter->sIter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk)); - if (pIter->sIter.aSttBlk == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - - code = tBlockDataCreate(&pIter->sIter.bData); - TSDB_CHECK_CODE(code, lino, _exit); - - pIter->sIter.iSttBlk = 0; - pIter->sIter.iRow = 0; - - // read data - code = tsdbReadSttBlk(pReader, iStt, pIter->sIter.aSttBlk); - TSDB_CHECK_CODE(code, lino, _exit); - - if (taosArrayGetSize(pIter->sIter.aSttBlk) == 0) goto _clear; - -_exit: - if (code) { - if (pIter) { - _clear: - taosArrayDestroy(pIter->sIter.aSttBlk); - tBlockDataDestroy(&pIter->sIter.bData); - taosMemoryFree(pIter); - pIter = NULL; - } - } - *ppIter = pIter; - return code; -} - -int32_t tsdbOpenTombFileDataIter(SDelFReader* pReader, STsdbDataIter2** ppIter) { - int32_t code = 0; - int32_t lino = 0; - - STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter)); - if (pIter == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - pIter->type = TSDB_TOMB_FILE_DATA_ITER; - - pIter->tIter.pReader = pReader; - if ((pIter->tIter.aDelIdx = taosArrayInit(0, sizeof(SDelIdx))) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - if ((pIter->tIter.aDelData = taosArrayInit(0, sizeof(SDelData))) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - - code = tsdbReadDelIdx(pReader, pIter->tIter.aDelIdx); - TSDB_CHECK_CODE(code, lino, _exit); - - if (taosArrayGetSize(pIter->tIter.aDelIdx) == 0) goto _clear; - - pIter->tIter.iDelIdx = 0; - pIter->tIter.iDelData = 0; - -_exit: - if (code) { - if (pIter) { - _clear: - taosArrayDestroy(pIter->tIter.aDelIdx); - taosArrayDestroy(pIter->tIter.aDelData); - taosMemoryFree(pIter); - pIter = NULL; - } - } - *ppIter = pIter; - return code; -} - -/* close */ -static void tsdbCloseDataFileDataIter(STsdbDataIter2* pIter) { - tBlockDataDestroy(&pIter->dIter.bData); - tMapDataClear(&pIter->dIter.mDataBlk); - taosArrayDestroy(pIter->dIter.aBlockIdx); - taosMemoryFree(pIter); -} - -static void tsdbCloseSttFileDataIter(STsdbDataIter2* pIter) { - tBlockDataDestroy(&pIter->sIter.bData); - taosArrayDestroy(pIter->sIter.aSttBlk); - taosMemoryFree(pIter); -} - -static void tsdbCloseTombFileDataIter(STsdbDataIter2* pIter) { - taosArrayDestroy(pIter->tIter.aDelData); - taosArrayDestroy(pIter->tIter.aDelIdx); - taosMemoryFree(pIter); -} - -void tsdbCloseDataIter2(STsdbDataIter2* pIter) { - if (pIter->type == TSDB_MEM_TABLE_DATA_ITER) { - ASSERT(0); - } else if (pIter->type == TSDB_DATA_FILE_DATA_ITER) { - tsdbCloseDataFileDataIter(pIter); - } else if (pIter->type == TSDB_STT_FILE_DATA_ITER) { - tsdbCloseSttFileDataIter(pIter); - } else if (pIter->type == TSDB_TOMB_FILE_DATA_ITER) { - tsdbCloseTombFileDataIter(pIter); - } else { - ASSERT(0); - } -} - -/* cmpr */ -int32_t tsdbDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pNode2) { - STsdbDataIter2* pIter1 = TSDB_RBTN_TO_DATA_ITER(pNode1); - STsdbDataIter2* pIter2 = TSDB_RBTN_TO_DATA_ITER(pNode2); - return tRowInfoCmprFn(&pIter1->rowInfo, &pIter2->rowInfo); -} - -/* seek */ - -/* iter next */ -static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { - int32_t code = 0; - int32_t lino = 0; - - for (;;) { - while (pIter->dIter.iRow < pIter->dIter.bData.nRow) { - if (pFilterInfo) { - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { - if (pIter->dIter.bData.aVersion[pIter->dIter.iRow] < pFilterInfo->sver || - pIter->dIter.bData.aVersion[pIter->dIter.iRow] > pFilterInfo->ever) { - pIter->dIter.iRow++; - continue; - } - } - } - - ASSERT(pIter->rowInfo.suid == pIter->dIter.bData.suid); - ASSERT(pIter->rowInfo.uid == pIter->dIter.bData.uid); - pIter->rowInfo.row = tsdbRowFromBlockData(&pIter->dIter.bData, pIter->dIter.iRow); - pIter->dIter.iRow++; - goto _exit; - } - - for (;;) { - while (pIter->dIter.iDataBlk < pIter->dIter.mDataBlk.nItem) { - SDataBlk dataBlk; - tMapDataGetItemByIdx(&pIter->dIter.mDataBlk, pIter->dIter.iDataBlk, &dataBlk, tGetDataBlk); - - // filter - if (pFilterInfo) { - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { - if (pFilterInfo->sver > dataBlk.maxVer || pFilterInfo->ever < dataBlk.minVer) { - pIter->dIter.iDataBlk++; - continue; - } - } - } - - code = tsdbReadDataBlockEx(pIter->dIter.pReader, &dataBlk, &pIter->dIter.bData); - TSDB_CHECK_CODE(code, lino, _exit); - - pIter->dIter.iDataBlk++; - pIter->dIter.iRow = 0; - - break; - } - - if (pIter->dIter.iRow < pIter->dIter.bData.nRow) break; - - for (;;) { - if (pIter->dIter.iBlockIdx < taosArrayGetSize(pIter->dIter.aBlockIdx)) { - SBlockIdx* pBlockIdx = taosArrayGet(pIter->dIter.aBlockIdx, pIter->dIter.iBlockIdx); - - if (pFilterInfo) { - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) { - int32_t c = tTABLEIDCmprFn(pBlockIdx, &pFilterInfo->tbid); - if (c == 0) { - pIter->dIter.iBlockIdx++; - continue; - } else if (c < 0) { - ASSERT(0); - } - } - - if (pFilterInfo->flag & TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE) { - SMetaInfo info; - if (metaGetInfo(pIter->dIter.pReader->pTsdb->pVnode->pMeta, pBlockIdx->uid, &info, NULL)) { - pIter->dIter.iBlockIdx++; - continue; - } - } - } - - code = tsdbReadDataBlk(pIter->dIter.pReader, pBlockIdx, &pIter->dIter.mDataBlk); - TSDB_CHECK_CODE(code, lino, _exit); - - pIter->rowInfo.suid = pBlockIdx->suid; - pIter->rowInfo.uid = pBlockIdx->uid; - - pIter->dIter.iBlockIdx++; - pIter->dIter.iDataBlk = 0; - - break; - } else { - pIter->rowInfo = (SRowInfo){0}; - goto _exit; - } - } - } - } - -_exit: - if (code) { - tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - } - return code; -} - -static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { - int32_t code = 0; - int32_t lino = 0; - - for (;;) { - while (pIter->sIter.iRow < pIter->sIter.bData.nRow) { - if (pFilterInfo) { - int64_t uid = pIter->sIter.bData.uid ? pIter->sIter.bData.uid : pIter->sIter.bData.aUid[pIter->sIter.iRow]; - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) { - if (pFilterInfo->tbid.uid == uid) { - pIter->sIter.iRow++; - continue; - } - } - - if (pFilterInfo->flag & TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE) { - if (pIter->rowInfo.uid != uid) { - SMetaInfo info; - if (metaGetInfo(pIter->sIter.pReader->pTsdb->pVnode->pMeta, uid, &info, NULL)) { - pIter->sIter.iRow++; - continue; - } - } - } - - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { - if (pFilterInfo->sver > pIter->sIter.bData.aVersion[pIter->sIter.iRow] || - pFilterInfo->ever < pIter->sIter.bData.aVersion[pIter->sIter.iRow]) { - pIter->sIter.iRow++; - continue; - } - } - } - - pIter->rowInfo.suid = pIter->sIter.bData.suid; - pIter->rowInfo.uid = pIter->sIter.bData.uid ? pIter->sIter.bData.uid : pIter->sIter.bData.aUid[pIter->sIter.iRow]; - pIter->rowInfo.row = tsdbRowFromBlockData(&pIter->sIter.bData, pIter->sIter.iRow); - pIter->sIter.iRow++; - goto _exit; - } - - for (;;) { - if (pIter->sIter.iSttBlk < taosArrayGetSize(pIter->sIter.aSttBlk)) { - SSttBlk* pSttBlk = taosArrayGet(pIter->sIter.aSttBlk, pIter->sIter.iSttBlk); - - if (pFilterInfo) { - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) { - if (pSttBlk->suid == pFilterInfo->tbid.suid && pSttBlk->minUid == pFilterInfo->tbid.uid && - pSttBlk->maxUid == pFilterInfo->tbid.uid) { - pIter->sIter.iSttBlk++; - continue; - } - } - - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { - if (pFilterInfo->sver > pSttBlk->maxVer || pFilterInfo->ever < pSttBlk->minVer) { - pIter->sIter.iSttBlk++; - continue; - } - } - } - - code = tsdbReadSttBlockEx(pIter->sIter.pReader, pIter->sIter.iStt, pSttBlk, &pIter->sIter.bData); - TSDB_CHECK_CODE(code, lino, _exit); - - pIter->sIter.iRow = 0; - pIter->sIter.iSttBlk++; - break; - } else { - pIter->rowInfo = (SRowInfo){0}; - goto _exit; - } - } - } - -_exit: - if (code) { - tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - } - return code; -} - -static int32_t tsdbTombFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { - int32_t code = 0; - int32_t lino = 0; - - for (;;) { - while (pIter->tIter.iDelData < taosArrayGetSize(pIter->tIter.aDelData)) { - SDelData* pDelData = taosArrayGet(pIter->tIter.aDelData, pIter->tIter.iDelData); - - if (pFilterInfo) { - if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { - if (pFilterInfo->sver > pDelData->version || pFilterInfo->ever < pDelData->version) { - pIter->tIter.iDelData++; - continue; - } - } - } - - pIter->delInfo.delData = *pDelData; - pIter->tIter.iDelData++; - goto _exit; - } - - for (;;) { - if (pIter->tIter.iDelIdx < taosArrayGetSize(pIter->tIter.aDelIdx)) { - SDelIdx* pDelIdx = taosArrayGet(pIter->tIter.aDelIdx, pIter->tIter.iDelIdx); - - if (pFilterInfo) { - if (pFilterInfo->flag & TSDB_FILTER_FLAG_IGNORE_DROPPED_TABLE) { - SMetaInfo info; - if (metaGetInfo(pIter->dIter.pReader->pTsdb->pVnode->pMeta, pDelIdx->uid, &info, NULL)) { - pIter->tIter.iDelIdx++; - continue; - } - } - } - - code = tsdbReadDelDatav1(pIter->tIter.pReader, pDelIdx, pIter->tIter.aDelData, INT64_MAX); - TSDB_CHECK_CODE(code, lino, _exit); - - pIter->delInfo.suid = pDelIdx->suid; - pIter->delInfo.uid = pDelIdx->uid; - pIter->tIter.iDelData = 0; - pIter->tIter.iDelIdx++; - break; - } else { - pIter->delInfo = (SDelInfo){0}; - goto _exit; - } - } - } - -_exit: - if (code) { - tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - } - return code; -} - -int32_t tsdbDataIterNext2(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { - int32_t code = 0; - - if (pIter->type == TSDB_MEM_TABLE_DATA_ITER) { - ASSERT(0); - return code; - } else if (pIter->type == TSDB_DATA_FILE_DATA_ITER) { - return tsdbDataFileDataIterNext(pIter, pFilterInfo); - } else if (pIter->type == TSDB_STT_FILE_DATA_ITER) { - return tsdbSttFileDataIterNext(pIter, pFilterInfo); - } else if (pIter->type == TSDB_TOMB_FILE_DATA_ITER) { - return tsdbTombFileDataIterNext(pIter, pFilterInfo); - } else { - ASSERT(0); - return code; - } -} -#endif - -/* get */ - -// STsdbFSetIter -typedef struct STsdbFSetDataIter { - STsdb* pTsdb; - int32_t flags; - - /* tombstone */ - SDelFReader* pDelFReader; - SArray* aDelIdx; // SArray - SArray* aDelData; // SArray - SArray* aSkeyLine; // SArray - int32_t iDelIdx; - int32_t iSkyLine; - - /* time-series data */ - SDataFReader* pReader; - STsdbDataIter2* iterList; - STsdbDataIter2* pIter; - SRBTree rbt; -} STsdbFSetDataIter; diff --git a/source/dnode/vnode/src/tsdb/tsdbDef.h b/source/dnode/vnode/src/tsdb/tsdbDef.h index 0f512e1306..0eaf3e68a6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDef.h +++ b/source/dnode/vnode/src/tsdb/tsdbDef.h @@ -35,6 +35,7 @@ extern int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbF extern void tsdbCloseFile(STsdbFD **ppFD); extern int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size); extern int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint); +extern int32_t tsdbReadFileToBuffer(STsdbFD *pFD, int64_t offset, int64_t size, SBuffer *buffer, int64_t szHint); extern int32_t tsdbFsyncFile(STsdbFD *pFD); #ifdef __cplusplus diff --git a/source/dnode/vnode/src/tsdb/tsdbDiskData.c b/source/dnode/vnode/src/tsdb/tsdbDiskData.c deleted file mode 100644 index ae9af11f5a..0000000000 --- a/source/dnode/vnode/src/tsdb/tsdbDiskData.c +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "tsdb.h" - -typedef struct SDiskColBuilder SDiskColBuilder; - -struct SDiskColBuilder { - int16_t cid; - int8_t type; - uint8_t cmprAlg; - uint8_t calcSma; - int8_t flag; - int32_t nVal; - uint8_t *pBitMap; - int32_t offset; - SCompressor *pOffC; - SCompressor *pValC; - SColumnDataAgg sma; - uint8_t minSet; - uint8_t maxSet; - uint8_t *aBuf[2]; -}; - -// SDiskData ================================================ -static int32_t tDiskDataDestroy(SDiskData *pDiskData) { - int32_t code = 0; - pDiskData->aDiskCol = taosArrayDestroy(pDiskData->aDiskCol); - return code; -} - -// SDiskColBuilder ================================================ -#define tDiskColBuilderCreate() \ - (SDiskColBuilder) { 0 } - -static int32_t tDiskColBuilderDestroy(SDiskColBuilder *pBuilder) { - int32_t code = 0; - - tFree(pBuilder->pBitMap); - if (pBuilder->pOffC) tCompressorDestroy(pBuilder->pOffC); - if (pBuilder->pValC) tCompressorDestroy(pBuilder->pValC); - for (int32_t iBuf = 0; iBuf < sizeof(pBuilder->aBuf) / sizeof(pBuilder->aBuf[0]); iBuf++) { - tFree(pBuilder->aBuf[iBuf]); - } - - return code; -} - -static int32_t tDiskColBuilderInit(SDiskColBuilder *pBuilder, int16_t cid, int8_t type, uint8_t cmprAlg, - uint8_t calcSma) { - int32_t code = 0; - - pBuilder->cid = cid; - pBuilder->type = type; - pBuilder->cmprAlg = cmprAlg; - pBuilder->calcSma = IS_VAR_DATA_TYPE(type) ? 0 : calcSma; - pBuilder->flag = 0; - pBuilder->nVal = 0; - pBuilder->offset = 0; - - if (IS_VAR_DATA_TYPE(type)) { - if (pBuilder->pOffC == NULL && (code = tCompressorCreate(&pBuilder->pOffC))) return code; - code = tCompressStart(pBuilder->pOffC, TSDB_DATA_TYPE_INT, cmprAlg); - if (code) return code; - } - - if (pBuilder->pValC == NULL && (code = tCompressorCreate(&pBuilder->pValC))) return code; - code = tCompressStart(pBuilder->pValC, type, cmprAlg); - if (code) return code; - - if (pBuilder->calcSma) { - pBuilder->sma = (SColumnDataAgg){.colId = cid}; - pBuilder->minSet = 0; - pBuilder->maxSet = 0; - } - - return code; -} - -static int32_t tGnrtDiskCol(SDiskColBuilder *pBuilder, SDiskCol *pDiskCol) { - int32_t code = 0; - - ASSERT(pBuilder->flag && pBuilder->flag != HAS_NONE); - - *pDiskCol = (SDiskCol){(SBlockCol){.cid = pBuilder->cid, - .type = pBuilder->type, - .smaOn = pBuilder->calcSma, - .flag = pBuilder->flag, - .szOrigin = 0, - .szBitmap = 0, - .szOffset = 0, - .szValue = 0, - .offset = 0}, - .pBit = NULL, .pOff = NULL, .pVal = NULL, .agg = pBuilder->sma}; - - if (pBuilder->flag == HAS_NULL) return code; - - // BITMAP - if (pBuilder->flag != HAS_VALUE) { - int32_t nBit; - if (pBuilder->flag == (HAS_VALUE | HAS_NULL | HAS_NONE)) { - nBit = BIT2_SIZE(pBuilder->nVal); - } else { - nBit = BIT1_SIZE(pBuilder->nVal); - } - - code = tRealloc(&pBuilder->aBuf[0], nBit + COMP_OVERFLOW_BYTES); - if (code) return code; - - code = tRealloc(&pBuilder->aBuf[1], nBit + COMP_OVERFLOW_BYTES); - if (code) return code; - - pDiskCol->bCol.szBitmap = - tsCompressTinyint(pBuilder->pBitMap, nBit, nBit, pBuilder->aBuf[0], nBit + COMP_OVERFLOW_BYTES, - pBuilder->cmprAlg, pBuilder->aBuf[1], nBit + COMP_OVERFLOW_BYTES); - pDiskCol->pBit = pBuilder->aBuf[0]; - } - - // OFFSET - if (IS_VAR_DATA_TYPE(pBuilder->type)) { - code = tCompressEnd(pBuilder->pOffC, &pDiskCol->pOff, &pDiskCol->bCol.szOffset, NULL); - if (code) return code; - } - - // VALUE - if (pBuilder->flag != (HAS_NULL | HAS_NONE)) { - code = tCompressEnd(pBuilder->pValC, &pDiskCol->pVal, &pDiskCol->bCol.szValue, &pDiskCol->bCol.szOrigin); - if (code) return code; - } - - return code; -} - -static FORCE_INLINE int32_t tDiskColPutValue(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - if (IS_VAR_DATA_TYPE(pColVal->type)) { - code = tCompress(pBuilder->pOffC, &pBuilder->offset, sizeof(int32_t)); - if (code) return code; - pBuilder->offset += pColVal->value.nData; - - code = tCompress(pBuilder->pValC, pColVal->value.pData, pColVal->value.nData); - if (code) return code; - } else { - code = tCompress(pBuilder->pValC, &pColVal->value.val, tDataTypes[pColVal->type].bytes); - if (code) return code; - } - - return code; -} -static FORCE_INLINE int32_t tDiskColAddVal00(SDiskColBuilder *pBuilder, SColVal *pColVal) { - pBuilder->flag = HAS_VALUE; - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal01(SDiskColBuilder *pBuilder, SColVal *pColVal) { - pBuilder->flag = HAS_NONE; - return 0; -} -static FORCE_INLINE int32_t tDiskColAddVal02(SDiskColBuilder *pBuilder, SColVal *pColVal) { - pBuilder->flag = HAS_NULL; - return 0; -} -static FORCE_INLINE int32_t tDiskColAddVal10(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - // bit map - int32_t nBit = BIT1_SIZE(pBuilder->nVal + 1); - code = tRealloc(&pBuilder->pBitMap, nBit); - if (code) return code; - - memset(pBuilder->pBitMap, 0, nBit); - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 1); - - // value - pBuilder->flag |= HAS_VALUE; - - SColVal cv = COL_VAL_VALUE(pColVal->cid, pColVal->type, (SValue){0}); - for (int32_t iVal = 0; iVal < pBuilder->nVal; iVal++) { - code = tDiskColPutValue(pBuilder, &cv); - if (code) return code; - } - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal12(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - int32_t nBit = BIT1_SIZE(pBuilder->nVal + 1); - code = tRealloc(&pBuilder->pBitMap, nBit); - if (code) return code; - - memset(pBuilder->pBitMap, 0, nBit); - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 1); - - pBuilder->flag |= HAS_NULL; - - return code; -} -static FORCE_INLINE int32_t tDiskColAddVal20(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - int32_t nBit = BIT1_SIZE(pBuilder->nVal + 1); - code = tRealloc(&pBuilder->pBitMap, nBit); - if (code) return code; - - pBuilder->flag |= HAS_VALUE; - - memset(pBuilder->pBitMap, 0, nBit); - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 1); - - SColVal cv = COL_VAL_VALUE(pColVal->cid, pColVal->type, (SValue){0}); - for (int32_t iVal = 0; iVal < pBuilder->nVal; iVal++) { - code = tDiskColPutValue(pBuilder, &cv); - if (code) return code; - } - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal21(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - int32_t nBit = BIT1_SIZE(pBuilder->nVal + 1); - code = tRealloc(&pBuilder->pBitMap, nBit); - if (code) return code; - - pBuilder->flag |= HAS_NONE; - - memset(pBuilder->pBitMap, 255, nBit); - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 0); - - return code; -} -static FORCE_INLINE int32_t tDiskColAddVal30(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - pBuilder->flag |= HAS_VALUE; - - uint8_t *pBitMap = NULL; - code = tRealloc(&pBitMap, BIT2_SIZE(pBuilder->nVal + 1)); - if (code) return code; - - for (int32_t iVal = 0; iVal < pBuilder->nVal; iVal++) { - SET_BIT2(pBitMap, iVal, GET_BIT1(pBuilder->pBitMap, iVal)); - } - SET_BIT2(pBitMap, pBuilder->nVal, 2); - - tFree(pBuilder->pBitMap); - pBuilder->pBitMap = pBitMap; - - SColVal cv = COL_VAL_VALUE(pColVal->cid, pColVal->type, (SValue){0}); - for (int32_t iVal = 0; iVal < pBuilder->nVal; iVal++) { - code = tDiskColPutValue(pBuilder, &cv); - if (code) return code; - } - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal31(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT1_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 0); - - return code; -} -static FORCE_INLINE int32_t tDiskColAddVal32(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT1_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 1); - - return code; -} -static FORCE_INLINE int32_t tDiskColAddVal40(SDiskColBuilder *pBuilder, SColVal *pColVal) { - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal41(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - pBuilder->flag |= HAS_NONE; - - int32_t nBit = BIT1_SIZE(pBuilder->nVal + 1); - code = tRealloc(&pBuilder->pBitMap, nBit); - if (code) return code; - - memset(pBuilder->pBitMap, 255, nBit); - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 0); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal42(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - pBuilder->flag |= HAS_NULL; - - int32_t nBit = BIT1_SIZE(pBuilder->nVal + 1); - code = tRealloc(&pBuilder->pBitMap, nBit); - if (code) return code; - - memset(pBuilder->pBitMap, 255, nBit); - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 0); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal50(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT1_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 1); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal51(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT1_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 0); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal52(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - pBuilder->flag |= HAS_NULL; - - uint8_t *pBitMap = NULL; - code = tRealloc(&pBitMap, BIT2_SIZE(pBuilder->nVal + 1)); - if (code) return code; - - for (int32_t iVal = 0; iVal < pBuilder->nVal; iVal++) { - SET_BIT2(pBitMap, iVal, GET_BIT1(pBuilder->pBitMap, iVal) ? 2 : 0); - } - SET_BIT2(pBitMap, pBuilder->nVal, 1); - - tFree(pBuilder->pBitMap); - pBuilder->pBitMap = pBitMap; - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal60(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT1_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 1); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal61(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - pBuilder->flag |= HAS_NONE; - - uint8_t *pBitMap = NULL; - code = tRealloc(&pBitMap, BIT2_SIZE(pBuilder->nVal + 1)); - if (code) return code; - - for (int32_t iVal = 0; iVal < pBuilder->nVal; iVal++) { - SET_BIT2(pBitMap, iVal, GET_BIT1(pBuilder->pBitMap, iVal) ? 2 : 1); - } - SET_BIT2(pBitMap, pBuilder->nVal, 0); - - tFree(pBuilder->pBitMap); - pBuilder->pBitMap = pBitMap; - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal62(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT1_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT1(pBuilder->pBitMap, pBuilder->nVal, 0); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal70(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT2_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT2(pBuilder->pBitMap, pBuilder->nVal, 2); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal71(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT2_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT2(pBuilder->pBitMap, pBuilder->nVal, 0); - - return tDiskColPutValue(pBuilder, pColVal); -} -static FORCE_INLINE int32_t tDiskColAddVal72(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - code = tRealloc(&pBuilder->pBitMap, BIT2_SIZE(pBuilder->nVal + 1)); - if (code) return code; - SET_BIT2(pBuilder->pBitMap, pBuilder->nVal, 1); - - return tDiskColPutValue(pBuilder, pColVal); -} -static int32_t (*tDiskColAddValImpl[8][3])(SDiskColBuilder *pBuilder, SColVal *pColVal) = { - {tDiskColAddVal00, tDiskColAddVal01, tDiskColAddVal02}, // 0 - {tDiskColAddVal10, NULL, tDiskColAddVal12}, // HAS_NONE - {tDiskColAddVal20, tDiskColAddVal21, NULL}, // HAS_NULL - {tDiskColAddVal30, tDiskColAddVal31, tDiskColAddVal32}, // HAS_NULL|HAS_NONE - {tDiskColAddVal40, tDiskColAddVal41, tDiskColAddVal42}, // HAS_VALUE - {tDiskColAddVal50, tDiskColAddVal51, tDiskColAddVal52}, // HAS_VALUE|HAS_NONE - {tDiskColAddVal60, tDiskColAddVal61, tDiskColAddVal62}, // HAS_VALUE|HAS_NULL - {tDiskColAddVal70, tDiskColAddVal71, tDiskColAddVal72} // HAS_VALUE|HAS_NULL|HAS_NONE -}; -// extern void (*tSmaUpdateImpl[])(SColumnDataAgg *pColAgg, SColVal *pColVal, uint8_t *minSet, uint8_t *maxSet); -static int32_t tDiskColAddVal(SDiskColBuilder *pBuilder, SColVal *pColVal) { - int32_t code = 0; - - if (pBuilder->calcSma) { - if (COL_VAL_IS_VALUE(pColVal)) { - // tSmaUpdateImpl[pBuilder->type](&pBuilder->sma, pColVal, &pBuilder->minSet, &pBuilder->maxSet); - } else { - pBuilder->sma.numOfNull++; - } - } - - if (tDiskColAddValImpl[pBuilder->flag][pColVal->flag]) { - code = tDiskColAddValImpl[pBuilder->flag][pColVal->flag](pBuilder, pColVal); - if (code) return code; - } - - pBuilder->nVal++; - - return code; -} - -// SDiskDataBuilder ================================================ -int32_t tDiskDataBuilderCreate(SDiskDataBuilder **ppBuilder) { - int32_t code = 0; - - *ppBuilder = (SDiskDataBuilder *)taosMemoryCalloc(1, sizeof(SDiskDataBuilder)); - if (*ppBuilder == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - return code; - } - - return code; -} - -void *tDiskDataBuilderDestroy(SDiskDataBuilder *pBuilder) { - if (pBuilder == NULL) return NULL; - - if (pBuilder->pUidC) tCompressorDestroy(pBuilder->pUidC); - if (pBuilder->pVerC) tCompressorDestroy(pBuilder->pVerC); - if (pBuilder->pKeyC) tCompressorDestroy(pBuilder->pKeyC); - - if (pBuilder->aBuilder) { - for (int32_t iBuilder = 0; iBuilder < taosArrayGetSize(pBuilder->aBuilder); iBuilder++) { - SDiskColBuilder *pDCBuilder = (SDiskColBuilder *)taosArrayGet(pBuilder->aBuilder, iBuilder); - tDiskColBuilderDestroy(pDCBuilder); - } - taosArrayDestroy(pBuilder->aBuilder); - } - for (int32_t iBuf = 0; iBuf < sizeof(pBuilder->aBuf) / sizeof(pBuilder->aBuf[0]); iBuf++) { - tFree(pBuilder->aBuf[iBuf]); - } - tDiskDataDestroy(&pBuilder->dd); - taosMemoryFree(pBuilder); - - return NULL; -} - -int32_t tDiskDataBuilderInit(SDiskDataBuilder *pBuilder, STSchema *pTSchema, TABLEID *pId, uint8_t cmprAlg, - uint8_t calcSma) { - int32_t code = 0; - - ASSERT(pId->suid || pId->uid); - - pBuilder->suid = pId->suid; - pBuilder->uid = pId->uid; - pBuilder->nRow = 0; - pBuilder->cmprAlg = cmprAlg; - pBuilder->calcSma = calcSma; - pBuilder->bi = (SBlkInfo){.minUid = INT64_MAX, - .maxUid = INT64_MIN, - .minKey = TSKEY_MAX, - .maxKey = TSKEY_MIN, - .minVer = VERSION_MAX, - .maxVer = VERSION_MIN, - .minTKey = TSDBKEY_MAX, - .maxTKey = TSDBKEY_MIN}; - - if (pBuilder->pUidC == NULL && (code = tCompressorCreate(&pBuilder->pUidC))) return code; - code = tCompressStart(pBuilder->pUidC, TSDB_DATA_TYPE_BIGINT, cmprAlg); - if (code) return code; - - if (pBuilder->pVerC == NULL && (code = tCompressorCreate(&pBuilder->pVerC))) return code; - code = tCompressStart(pBuilder->pVerC, TSDB_DATA_TYPE_BIGINT, cmprAlg); - if (code) return code; - - if (pBuilder->pKeyC == NULL && (code = tCompressorCreate(&pBuilder->pKeyC))) return code; - code = tCompressStart(pBuilder->pKeyC, TSDB_DATA_TYPE_TIMESTAMP, cmprAlg); - if (code) return code; - - if (pBuilder->aBuilder == NULL) { - pBuilder->aBuilder = taosArrayInit(pTSchema->numOfCols - 1, sizeof(SDiskColBuilder)); - if (pBuilder->aBuilder == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - return code; - } - } - - pBuilder->nBuilder = 0; - for (int32_t iCol = 1; iCol < pTSchema->numOfCols; iCol++) { - STColumn *pTColumn = &pTSchema->columns[iCol]; - - if (pBuilder->nBuilder >= taosArrayGetSize(pBuilder->aBuilder)) { - SDiskColBuilder dc = tDiskColBuilderCreate(); - if (taosArrayPush(pBuilder->aBuilder, &dc) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - return code; - } - } - - SDiskColBuilder *pDCBuilder = (SDiskColBuilder *)taosArrayGet(pBuilder->aBuilder, pBuilder->nBuilder); - - code = tDiskColBuilderInit(pDCBuilder, pTColumn->colId, pTColumn->type, cmprAlg, - (calcSma && (pTColumn->flags & COL_SMA_ON))); - if (code) return code; - - pBuilder->nBuilder++; - } - - return code; -} - -int32_t tDiskDataBuilderClear(SDiskDataBuilder *pBuilder) { - int32_t code = 0; - pBuilder->suid = 0; - pBuilder->uid = 0; - pBuilder->nRow = 0; - return code; -} - -int32_t tDiskDataAddRow(SDiskDataBuilder *pBuilder, TSDBROW *pRow, STSchema *pTSchema, TABLEID *pId) { - int32_t code = 0; - - ASSERT(pBuilder->suid || pBuilder->uid); - ASSERT(pId->suid == pBuilder->suid); - - TSDBKEY kRow = TSDBROW_KEY(pRow); - if (tsdbKeyCmprFn(&pBuilder->bi.minTKey, &kRow) > 0) pBuilder->bi.minTKey = kRow; - if (tsdbKeyCmprFn(&pBuilder->bi.maxTKey, &kRow) < 0) pBuilder->bi.maxTKey = kRow; - - // uid - if (pBuilder->uid && pBuilder->uid != pId->uid) { - ASSERT(pBuilder->suid); - for (int32_t iRow = 0; iRow < pBuilder->nRow; iRow++) { - code = tCompress(pBuilder->pUidC, &pBuilder->uid, sizeof(int64_t)); - if (code) return code; - } - pBuilder->uid = 0; - } - if (pBuilder->uid == 0) { - code = tCompress(pBuilder->pUidC, &pId->uid, sizeof(int64_t)); - if (code) return code; - } - if (pBuilder->bi.minUid > pId->uid) pBuilder->bi.minUid = pId->uid; - if (pBuilder->bi.maxUid < pId->uid) pBuilder->bi.maxUid = pId->uid; - - // version - code = tCompress(pBuilder->pVerC, &kRow.version, sizeof(int64_t)); - if (code) return code; - if (pBuilder->bi.minVer > kRow.version) pBuilder->bi.minVer = kRow.version; - if (pBuilder->bi.maxVer < kRow.version) pBuilder->bi.maxVer = kRow.version; - - // TSKEY - code = tCompress(pBuilder->pKeyC, &kRow.ts, sizeof(int64_t)); - if (code) return code; - if (pBuilder->bi.minKey > kRow.ts) pBuilder->bi.minKey = kRow.ts; - if (pBuilder->bi.maxKey < kRow.ts) pBuilder->bi.maxKey = kRow.ts; - - STSDBRowIter iter = {0}; - tsdbRowIterOpen(&iter, pRow, pTSchema); - - SColVal *pColVal = tsdbRowIterNext(&iter); - for (int32_t iBuilder = 0; iBuilder < pBuilder->nBuilder; iBuilder++) { - SDiskColBuilder *pDCBuilder = (SDiskColBuilder *)taosArrayGet(pBuilder->aBuilder, iBuilder); - - while (pColVal && pColVal->cid < pDCBuilder->cid) { - pColVal = tsdbRowIterNext(&iter); - } - - if (pColVal && pColVal->cid == pDCBuilder->cid) { - code = tDiskColAddVal(pDCBuilder, pColVal); - if (code) return code; - pColVal = tsdbRowIterNext(&iter); - } else { - code = tDiskColAddVal(pDCBuilder, &COL_VAL_NONE(pDCBuilder->cid, pDCBuilder->type)); - if (code) return code; - } - } - pBuilder->nRow++; - - return code; -} - -int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData, const SBlkInfo **ppBlkInfo) { - int32_t code = 0; - - ASSERT(pBuilder->nRow); - - *ppDiskData = NULL; - *ppBlkInfo = NULL; - - SDiskData *pDiskData = &pBuilder->dd; - // reset SDiskData - pDiskData->hdr = (SDiskDataHdr){.delimiter = TSDB_FILE_DLMT, - .fmtVer = 0, - .suid = pBuilder->suid, - .uid = pBuilder->uid, - .szUid = 0, - .szVer = 0, - .szKey = 0, - .szBlkCol = 0, - .nRow = pBuilder->nRow, - .cmprAlg = pBuilder->cmprAlg}; - pDiskData->pUid = NULL; - pDiskData->pVer = NULL; - pDiskData->pKey = NULL; - - // UID - if (pBuilder->uid == 0) { - code = tCompressEnd(pBuilder->pUidC, &pDiskData->pUid, &pDiskData->hdr.szUid, NULL); - if (code) return code; - } - - // VERSION - code = tCompressEnd(pBuilder->pVerC, &pDiskData->pVer, &pDiskData->hdr.szVer, NULL); - if (code) return code; - - // TSKEY - code = tCompressEnd(pBuilder->pKeyC, &pDiskData->pKey, &pDiskData->hdr.szKey, NULL); - if (code) return code; - - // aDiskCol - if (pDiskData->aDiskCol) { - taosArrayClear(pDiskData->aDiskCol); - } else { - pDiskData->aDiskCol = taosArrayInit(pBuilder->nBuilder, sizeof(SDiskCol)); - if (pDiskData->aDiskCol == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - return code; - } - } - - int32_t offset = 0; - for (int32_t iBuilder = 0; iBuilder < pBuilder->nBuilder; iBuilder++) { - SDiskColBuilder *pDCBuilder = (SDiskColBuilder *)taosArrayGet(pBuilder->aBuilder, iBuilder); - - if (pDCBuilder->flag == HAS_NONE) continue; - - SDiskCol dCol; - - code = tGnrtDiskCol(pDCBuilder, &dCol); - if (code) return code; - - dCol.bCol.offset = offset; - offset = offset + dCol.bCol.szBitmap + dCol.bCol.szOffset + dCol.bCol.szValue; - - if (taosArrayPush(pDiskData->aDiskCol, &dCol) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - return code; - } - - pDiskData->hdr.szBlkCol += tPutBlockCol(NULL, &dCol.bCol); - } - - *ppDiskData = pDiskData; - *ppBlkInfo = &pBuilder->bi; - return code; -} diff --git a/source/dnode/vnode/src/tsdb/tsdbFSetRW.c b/source/dnode/vnode/src/tsdb/tsdbFSetRW.c index e524d6874e..b0917cceb0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSetRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSetRW.c @@ -22,7 +22,7 @@ struct SFSetWriter { SSkmInfo skmTb[1]; SSkmInfo skmRow[1]; - uint8_t *bufArr[10]; + SBuffer buffers[10]; struct { TABLEID tbid[1]; @@ -152,7 +152,7 @@ int32_t tsdbFSetWriterOpen(SFSetWriterConfig *config, SFSetWriter **writer) { .compactVersion = config->compactVersion, .skmTb = writer[0]->skmTb, .skmRow = writer[0]->skmRow, - .bufArr = writer[0]->bufArr, + .buffers = writer[0]->buffers, }; for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX; ++ftype) { dataWriterConfig.files[ftype].exist = config->files[ftype].exist; @@ -176,7 +176,8 @@ int32_t tsdbFSetWriterOpen(SFSetWriterConfig *config, SFSetWriter **writer) { .level = config->level, .skmTb = writer[0]->skmTb, .skmRow = writer[0]->skmRow, - .bufArr = writer[0]->bufArr, + .buffers = writer[0]->buffers, + }; code = tsdbSttFileWriterOpen(&sttWriterConfig, &writer[0]->sttWriter); TSDB_CHECK_CODE(code, lino, _exit); @@ -212,8 +213,8 @@ int32_t tsdbFSetWriterClose(SFSetWriter **writer, bool abort, TFileOpArray *fopA for (int32_t i = 0; i < ARRAY_SIZE(writer[0]->blockData); i++) { tBlockDataDestroy(&writer[0]->blockData[i]); } - for (int32_t i = 0; i < ARRAY_SIZE(writer[0]->bufArr); i++) { - tFree(writer[0]->bufArr[i]); + for (int32_t i = 0; i < ARRAY_SIZE(writer[0]->buffers); i++) { + tBufferDestroy(&writer[0]->buffers[i]); } tDestroyTSchema(writer[0]->skmRow->pTSchema); tDestroyTSchema(writer[0]->skmTb->pTSchema); @@ -248,10 +249,11 @@ int32_t tsdbFSetWriteRow(SFSetWriter *writer, SRowInfo *row) { TSDB_CHECK_CODE(code, lino, _exit); } - TSDBKEY key = TSDBROW_KEY(&row->row); - if (key.version <= writer->config->compactVersion // - && writer->blockData[writer->blockDataIdx].nRow > 0 // - && key.ts == writer->blockData[writer->blockDataIdx].aTSKEY[writer->blockData[writer->blockDataIdx].nRow - 1]) { + if (TSDBROW_VERSION(&row->row) <= writer->config->compactVersion // + && writer->blockData[writer->blockDataIdx].nRow > 0 // + && tsdbRowCompareWithoutVersion(&row->row, + &tsdbRowFromBlockData(&writer->blockData[writer->blockDataIdx], + writer->blockData[writer->blockDataIdx].nRow - 1)) == 0) { code = tBlockDataUpdateRow(&writer->blockData[writer->blockDataIdx], &row->row, writer->skmRow->pTSchema); TSDB_CHECK_CODE(code, lino, _exit); } else { diff --git a/source/dnode/vnode/src/tsdb/tsdbIter.c b/source/dnode/vnode/src/tsdb/tsdbIter.c index 447832108d..42afe1cdc0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbIter.c +++ b/source/dnode/vnode/src/tsdb/tsdbIter.c @@ -45,7 +45,7 @@ struct STsdbIter { } dataData[1]; struct { SMemTable *memt; - TSDBKEY from[1]; + STsdbRowKey from[1]; SRBTreeIter iter[1]; STbData *tbData; STbDataIter tbIter[1]; @@ -147,12 +147,11 @@ static int32_t tsdbDataIterNext(STsdbIter *iter, const TABLEID *tbid) { } // SBrinBlock - if (iter->dataData->brinBlockIdx >= BRIN_BLOCK_SIZE(iter->dataData->brinBlock)) { + if (iter->dataData->brinBlockIdx >= iter->dataData->brinBlock->numOfRecords) { break; } - for (; iter->dataData->brinBlockIdx < BRIN_BLOCK_SIZE(iter->dataData->brinBlock); - iter->dataData->brinBlockIdx++) { + for (; iter->dataData->brinBlockIdx < iter->dataData->brinBlock->numOfRecords; iter->dataData->brinBlockIdx++) { SBrinRecord record[1]; tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record); @@ -255,9 +254,7 @@ _exit: static int32_t tsdbDataTombIterNext(STsdbIter *iter, const TABLEID *tbid) { while (!iter->noMoreData) { for (; iter->dataTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->dataTomb->tombBlock); iter->dataTomb->tombBlockIdx++) { - iter->record->suid = TARRAY2_GET(iter->dataTomb->tombBlock->suid, iter->dataTomb->tombBlockIdx); - iter->record->uid = TARRAY2_GET(iter->dataTomb->tombBlock->uid, iter->dataTomb->tombBlockIdx); - iter->record->version = TARRAY2_GET(iter->dataTomb->tombBlock->version, iter->dataTomb->tombBlockIdx); + tTombBlockGet(iter->dataTomb->tombBlock, iter->dataTomb->tombBlockIdx, iter->record); if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) { continue; @@ -266,9 +263,6 @@ static int32_t tsdbDataTombIterNext(STsdbIter *iter, const TABLEID *tbid) { if (tbid && iter->record->suid == tbid->suid && iter->record->uid == tbid->uid) { continue; } - - iter->record->skey = TARRAY2_GET(iter->dataTomb->tombBlock->skey, iter->dataTomb->tombBlockIdx); - iter->record->ekey = TARRAY2_GET(iter->dataTomb->tombBlock->ekey, iter->dataTomb->tombBlockIdx); iter->dataTomb->tombBlockIdx++; goto _exit; } @@ -445,9 +439,7 @@ static int32_t tsdbMemTableIterClose(STsdbIter *iter) { return 0; } static int32_t tsdbSttTombIterNext(STsdbIter *iter, const TABLEID *tbid) { while (!iter->noMoreData) { for (; iter->sttTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->sttTomb->tombBlock); iter->sttTomb->tombBlockIdx++) { - iter->record->suid = TARRAY2_GET(iter->sttTomb->tombBlock->suid, iter->sttTomb->tombBlockIdx); - iter->record->uid = TARRAY2_GET(iter->sttTomb->tombBlock->uid, iter->sttTomb->tombBlockIdx); - iter->record->version = TARRAY2_GET(iter->sttTomb->tombBlock->version, iter->sttTomb->tombBlockIdx); + tTombBlockGet(iter->sttTomb->tombBlock, iter->sttTomb->tombBlockIdx, iter->record); if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) { continue; @@ -457,8 +449,6 @@ static int32_t tsdbSttTombIterNext(STsdbIter *iter, const TABLEID *tbid) { continue; } - iter->record->skey = TARRAY2_GET(iter->sttTomb->tombBlock->skey, iter->sttTomb->tombBlockIdx); - iter->record->ekey = TARRAY2_GET(iter->sttTomb->tombBlock->ekey, iter->sttTomb->tombBlockIdx); iter->sttTomb->tombBlockIdx++; goto _exit; } diff --git a/source/dnode/vnode/src/tsdb/tsdbIter.h b/source/dnode/vnode/src/tsdb/tsdbIter.h index 367901bd84..05449d2042 100644 --- a/source/dnode/vnode/src/tsdb/tsdbIter.h +++ b/source/dnode/vnode/src/tsdb/tsdbIter.h @@ -44,8 +44,8 @@ typedef struct { SSttFileReader *sttReader; // TSDB_ITER_TYPE_STT || TSDB_ITER_TYPE_STT_TOMB SDataFileReader *dataReader; // TSDB_ITER_TYPE_DATA || TSDB_ITER_TYPE_DATA_TOMB struct { - SMemTable *memt; // TSDB_ITER_TYPE_MEMT_TOMB - TSDBKEY from[1]; + SMemTable *memt; // TSDB_ITER_TYPE_MEMT_TOMB + STsdbRowKey from[1]; }; // TSDB_ITER_TYPE_MEMT }; bool filterByVersion; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 4657b60f62..8be8fa5bd7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -31,7 +31,7 @@ #define SL_MOVE_BACKWARD 0x1 #define SL_MOVE_FROM_POS 0x2 -static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *pKey, int32_t flags); +static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, STsdbRowKey *pKey, int32_t flags); static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, STbData **ppTbData); static int32_t tsdbInsertRowDataToTable(SMemTable *pMemTable, STbData *pTbData, int64_t version, SSubmitTbData *pSubmitTbData, int32_t *affectedRows); @@ -219,7 +219,7 @@ _err: return code; } -int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter **ppIter) { +int32_t tsdbTbDataIterCreate(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter **ppIter) { int32_t code = 0; (*ppIter) = (STbDataIter *)taosMemoryCalloc(1, sizeof(STbDataIter)); @@ -241,7 +241,7 @@ void *tsdbTbDataIterDestroy(STbDataIter *pIter) { return NULL; } -void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter *pIter) { +void tsdbTbDataIterOpen(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter *pIter) { SMemSkipListNode *pos[SL_MAX_LEVEL]; SMemSkipListNode *pHead; SMemSkipListNode *pTail; @@ -433,10 +433,10 @@ _err: return code; } -static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *pKey, int32_t flags) { +static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, STsdbRowKey *pKey, int32_t flags) { SMemSkipListNode *px; SMemSkipListNode *pn; - TSDBKEY tKey = {0}; + STsdbRowKey tKey; int32_t backward = flags & SL_MOVE_BACKWARD; int32_t fromPos = flags & SL_MOVE_FROM_POS; @@ -455,15 +455,9 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p for (int8_t iLevel = pTbData->sl.level - 1; iLevel >= 0; iLevel--) { pn = SL_GET_NODE_BACKWARD(px, iLevel); while (pn != pTbData->sl.pHead) { - if (pn->flag == TSDBROW_ROW_FMT) { - tKey.version = pn->version; - tKey.ts = ((SRow *)pn->pData)->ts; - } else if (pn->flag == TSDBROW_COL_FMT) { - tKey.version = ((SBlockData *)pn->pData)->aVersion[pn->iRow]; - tKey.ts = ((SBlockData *)pn->pData)->aTSKEY[pn->iRow]; - } + tsdbRowGetKey(&pn->row, &tKey); - int32_t c = tsdbKeyCmprFn(&tKey, pKey); + int32_t c = tsdbRowKeyCmpr(&tKey, pKey); if (c <= 0) { break; } else { @@ -490,15 +484,9 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p for (int8_t iLevel = pTbData->sl.level - 1; iLevel >= 0; iLevel--) { pn = SL_GET_NODE_FORWARD(px, iLevel); while (pn != pTbData->sl.pTail) { - if (pn->flag == TSDBROW_ROW_FMT) { - tKey.version = pn->version; - tKey.ts = ((SRow *)pn->pData)->ts; - } else if (pn->flag == TSDBROW_COL_FMT) { - tKey.version = ((SBlockData *)pn->pData)->aVersion[pn->iRow]; - tKey.ts = ((SBlockData *)pn->pData)->aTSKEY[pn->iRow]; - } + tsdbRowGetKey(&pn->row, &tKey); - int32_t c = tsdbKeyCmprFn(&tKey, pKey); + int32_t c = tsdbRowKeyCmpr(&tKey, pKey); if (c >= 0) { break; } else { @@ -547,16 +535,10 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN } pNode->level = level; - pNode->flag = pRow->type; + pNode->row = *pRow; if (pRow->type == TSDBROW_ROW_FMT) { - pNode->version = pRow->version; - pNode->pData = (char *)pNode + nSize; - memcpy(pNode->pData, pRow->pTSRow, pRow->pTSRow->len); - } else if (pRow->type == TSDBROW_COL_FMT) { - pNode->iRow = pRow->iRow; - pNode->pData = pRow->pBlockData; - } else { - ASSERT(0); + pNode->row.pTSRow = (SRow *)((char *)pNode + nSize); + memcpy(pNode->row.pTSRow, pRow->pTSRow, pRow->pTSRow->len); } // set node @@ -656,13 +638,14 @@ static int32_t tsdbInsertColDataToTable(SMemTable *pMemTable, STbData *pTbData, // loop to add each row to the skiplist SMemSkipListNode *pos[SL_MAX_LEVEL]; TSDBROW tRow = tsdbRowFromBlockData(pBlockData, 0); - TSDBKEY key = {.version = version, .ts = pBlockData->aTSKEY[0]}; + STsdbRowKey key; TSDBROW lRow; // last row // first row + tsdbRowGetKey(&tRow, &key); tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_BACKWARD); if ((code = tbDataDoPut(pMemTable, pTbData, pos, &tRow, 0))) goto _exit; - pTbData->minKey = TMIN(pTbData->minKey, key.ts); + pTbData->minKey = TMIN(pTbData->minKey, key.key.ts); lRow = tRow; // remain row @@ -673,7 +656,7 @@ static int32_t tsdbInsertColDataToTable(SMemTable *pMemTable, STbData *pTbData, } while (tRow.iRow < pBlockData->nRow) { - key.ts = pBlockData->aTSKEY[tRow.iRow]; + tsdbRowGetKey(&tRow, &key); if (SL_NODE_FORWARD(pos[0], 0) != pTbData->sl.pTail) { tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_FROM_POS); @@ -686,8 +669,8 @@ static int32_t tsdbInsertColDataToTable(SMemTable *pMemTable, STbData *pTbData, } } - if (key.ts >= pTbData->maxKey) { - pTbData->maxKey = key.ts; + if (key.key.ts >= pTbData->maxKey) { + pTbData->maxKey = key.key.ts; } if (!TSDB_CACHE_NO(pMemTable->pTsdb->pVnode->config)) { @@ -711,7 +694,7 @@ static int32_t tsdbInsertRowDataToTable(SMemTable *pMemTable, STbData *pTbData, int32_t nRow = TARRAY_SIZE(pSubmitTbData->aRowP); SRow **aRow = (SRow **)TARRAY_DATA(pSubmitTbData->aRowP); - TSDBKEY key = {.version = version}; + STsdbRowKey key; SMemSkipListNode *pos[SL_MAX_LEVEL]; TSDBROW tRow = {.type = TSDBROW_ROW_FMT, .version = version}; int32_t iRow = 0; @@ -719,13 +702,13 @@ static int32_t tsdbInsertRowDataToTable(SMemTable *pMemTable, STbData *pTbData, // backward put first data tRow.pTSRow = aRow[iRow++]; - key.ts = tRow.pTSRow->ts; + tsdbRowGetKey(&tRow, &key); tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_BACKWARD); code = tbDataDoPut(pMemTable, pTbData, pos, &tRow, 0); if (code) goto _exit; lRow = tRow; - pTbData->minKey = TMIN(pTbData->minKey, key.ts); + pTbData->minKey = TMIN(pTbData->minKey, key.key.ts); // forward put rest data if (iRow < nRow) { @@ -735,7 +718,7 @@ static int32_t tsdbInsertRowDataToTable(SMemTable *pMemTable, STbData *pTbData, while (iRow < nRow) { tRow.pTSRow = aRow[iRow]; - key.ts = tRow.pTSRow->ts; + tsdbRowGetKey(&tRow, &key); if (SL_NODE_FORWARD(pos[0], 0) != pTbData->sl.pTail) { tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_FROM_POS); @@ -750,8 +733,8 @@ static int32_t tsdbInsertRowDataToTable(SMemTable *pMemTable, STbData *pTbData, } } - if (key.ts >= pTbData->maxKey) { - pTbData->maxKey = key.ts; + if (key.key.ts >= pTbData->maxKey) { + pTbData->maxKey = key.key.ts; } if (!TSDB_CACHE_NO(pMemTable->pTsdb->pVnode->config)) { tsdbCacheUpdate(pMemTable->pTsdb, pTbData->suid, pTbData->uid, &lRow); @@ -833,3 +816,26 @@ SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable) { _exit: return aTbDataP; } + +TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) { + if (pIter == NULL) return NULL; + + if (pIter->pRow) { + return pIter->pRow; + } + + if (pIter->backward) { + if (pIter->pNode == pIter->pTbData->sl.pHead) { + return NULL; + } + } else { + if (pIter->pNode == pIter->pTbData->sl.pTail) { + return NULL; + } + } + + pIter->pRow = &pIter->row; + pIter->row = pIter->pNode->row; + + return pIter->pRow; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 0b86cae1be..ee6f0a8c84 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -15,10 +15,10 @@ #include "tsdb.h" #include "tsdbFSet2.h" -#include "tsdbUtil2.h" #include "tsdbMerge.h" #include "tsdbReadUtil.h" #include "tsdbSttFileRW.h" +#include "tsdbUtil2.h" static void tLDataIterClose2(SLDataIter *pIter); @@ -60,7 +60,7 @@ void *destroySttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) { pLoadInfo->currentLoadBlockIndex = 1; - SBlockDataInfo* pInfo = &pLoadInfo->blockData[0]; + SBlockDataInfo *pInfo = &pLoadInfo->blockData[0]; tBlockDataDestroy(&pInfo->data); pInfo->sttBlockIndex = -1; pInfo->pin = false; @@ -88,7 +88,7 @@ void destroyLDataIter(SLDataIter *pIter) { taosMemoryFree(pIter); } -void *destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo* pLoadCost) { +void *destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoadCost) { if (pLDataIterArray == NULL) { return NULL; } @@ -115,7 +115,7 @@ void *destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo* pLoa } // choose the unpinned slot to load next data block -static void updateBlockLoadSlot(SSttBlockLoadInfo* pLoadInfo) { +static void updateBlockLoadSlot(SSttBlockLoadInfo *pLoadInfo) { int32_t nextSlotIndex = pLoadInfo->currentLoadBlockIndex ^ 1; if (pLoadInfo->blockData[nextSlotIndex].pin) { nextSlotIndex = nextSlotIndex ^ 1; @@ -180,7 +180,7 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) { pInfo->blockData[1].sttBlockIndex, pIter->iRow, idStr); return &pInfo->blockData[pInfo->currentLoadBlockIndex].data; - _exit: +_exit: if (code != TSDB_CODE_SUCCESS) { terrno = code; } @@ -325,7 +325,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl } int32_t startIndex = 0; - while((startIndex < numOfBlocks) && (pStatisBlkArray->data[startIndex].maxTbid.suid < suid)) { + while ((startIndex < numOfBlocks) && (pStatisBlkArray->data[startIndex].maxTbid.suid < suid)) { ++startIndex; } @@ -334,7 +334,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl } int32_t endIndex = startIndex; - while(endIndex < numOfBlocks && pStatisBlkArray->data[endIndex].minTbid.suid <= suid) { + while (endIndex < numOfBlocks && pStatisBlkArray->data[endIndex].minTbid.suid <= suid) { ++endIndex; } @@ -346,12 +346,12 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl int64_t st = taosGetTimestampUs(); - for(int32_t k = startIndex; k < endIndex; ++k) { + for (int32_t k = startIndex; k < endIndex; ++k) { tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block); int32_t i = 0; - int32_t rows = TARRAY2_SIZE(block.suid); - while (i < rows && block.suid->data[i] != suid) { + int32_t rows = block.numOfRecords; + while (i < rows && ((int64_t *)block.suids.data)[i] != suid) { ++i; } @@ -365,16 +365,24 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl } if (pStatisBlkArray->data[k].maxTbid.suid == suid) { - taosArrayAddBatch(pBlockLoadInfo->info.pUid, &block.uid->data[i], rows - i); - taosArrayAddBatch(pBlockLoadInfo->info.pFirstKey, &block.firstKey->data[i], rows - i); - taosArrayAddBatch(pBlockLoadInfo->info.pLastKey, &block.lastKey->data[i], rows - i); - taosArrayAddBatch(pBlockLoadInfo->info.pCount, &block.count->data[i], rows - i); + taosArrayAddBatch(pBlockLoadInfo->info.pUid, tBufferGetDataAt(&block.suids, i * sizeof(int64_t)), rows - i); + taosArrayAddBatch(pBlockLoadInfo->info.pFirstKey, + tBufferGetDataAt(&block.firstKeyTimestamps, i * sizeof(int64_t)), rows - i); + taosArrayAddBatch(pBlockLoadInfo->info.pLastKey, + tBufferGetDataAt(&block.lastKeyTimestamps, i * sizeof(int64_t)), rows - i); + taosArrayAddBatch(pBlockLoadInfo->info.pCount, tBufferGetDataAt(&block.counts, i * sizeof(int64_t)), rows - i); } else { - while (i < rows && block.suid->data[i] == suid) { - taosArrayPush(pBlockLoadInfo->info.pUid, &block.uid->data[i]); - taosArrayPush(pBlockLoadInfo->info.pFirstKey, &block.firstKey->data[i]); - taosArrayPush(pBlockLoadInfo->info.pLastKey, &block.lastKey->data[i]); - taosArrayPush(pBlockLoadInfo->info.pCount, &block.count->data[i]); + STbStatisRecord record; + while (i < rows) { + tStatisBlockGet(&block, i, &record); + if (record.suid != suid) { + break; + } + + taosArrayPush(pBlockLoadInfo->info.pUid, &record.uid); + taosArrayPush(pBlockLoadInfo->info.pFirstKey, &record.firstKey.ts); + taosArrayPush(pBlockLoadInfo->info.pLastKey, &record.lastKey.ts); + taosArrayPush(pBlockLoadInfo->info.pCount, &record.count); i += 1; } } @@ -411,6 +419,7 @@ static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter * return code; } +#if 0 // load stt statistics block for all stt-blocks, to decide if the data of queried table exists in current stt file TStatisBlkArray *pStatisBlkArray = NULL; code = tsdbSttFileReadStatisBlk(pIter->pReader, (const TStatisBlkArray **)&pStatisBlkArray); @@ -425,6 +434,7 @@ static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter * tsdbError("failed to load stt statistics block data, code:%s, %s", tstrerror(code), idStr); return code; } +#endif code = loadTombFn(pReader1, pIter->pReader, pIter->pBlockLoadInfo); @@ -433,14 +443,14 @@ static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter * return code; } -static int32_t uidComparFn(const void* p1, const void* p2) { +static int32_t uidComparFn(const void *p1, const void *p2) { const uint64_t *pFirst = p1; const uint64_t *pVal = p2; if (*pFirst == *pVal) { return 0; } else { - return *pFirst < *pVal? -1:1; + return *pFirst < *pVal ? -1 : 1; } } @@ -455,7 +465,7 @@ static void setSttInfoForCurrentTable(SSttBlockLoadInfo *pLoadInfo, uint64_t uid pTimeWindow->skey = *(int64_t *)taosArrayGet(pLoadInfo->info.pFirstKey, index); pTimeWindow->ekey = *(int64_t *)taosArrayGet(pLoadInfo->info.pLastKey, index); - *numOfRows += *(int64_t*) taosArrayGet(pLoadInfo->info.pCount, index); + *numOfRows += *(int64_t *)taosArrayGet(pLoadInfo->info.pCount, index); } } @@ -709,7 +719,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) { pIter->rInfo.uid = pBlockData->uid; pIter->rInfo.row = tsdbRowFromBlockData(pBlockData, pIter->iRow); - _exit: +_exit: return (terrno == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL) && (pBlockData != NULL); } @@ -740,7 +750,7 @@ static FORCE_INLINE int32_t tLDataIterDescCmprFn(const SRBTreeNode *p1, const SR return -1 * tLDataIterCmprFn(p1, p2); } -int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoForTable* pSttDataInfo) { +int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoForTable *pSttDataInfo) { int32_t code = TSDB_CODE_SUCCESS; pMTree->pIter = NULL; @@ -765,12 +775,12 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF for (int32_t j = 0; j < numOfLevels; ++j) { SSttLvl *pSttLevel = ((STFileSet *)pConf->pCurrentFileset)->lvlArr->data[j]; - SArray * pList = taosArrayGetP(pConf->pSttFileBlockIterArray, j); + SArray *pList = taosArrayGetP(pConf->pSttFileBlockIterArray, j); for (int32_t i = 0; i < TARRAY2_SIZE(pSttLevel->fobjArr); ++i) { // open all last file SLDataIter *pIter = taosArrayGetP(pList, i); - SSttFileReader * pSttFileReader = pIter->pReader; + SSttFileReader *pSttFileReader = pIter->pReader; SSttBlockLoadInfo *pLoadInfo = pIter->pBlockLoadInfo; // open stt file reader if not opened yet @@ -796,7 +806,8 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF int64_t numOfRows = 0; int64_t cid = pSttLevel->fobjArr->data[i]->f->cid; - code = tLDataIterOpen2(pIter, pSttFileReader, cid, pMTree->backward, pConf, pLoadInfo, &w, &numOfRows, pMTree->idStr); + code = tLDataIterOpen2(pIter, pSttFileReader, cid, pMTree->backward, pConf, pLoadInfo, &w, &numOfRows, + pMTree->idStr); if (code != TSDB_CODE_SUCCESS) { goto _end; } @@ -820,7 +831,7 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF return code; - _end: +_end: tMergeTreeClose(pMTree); return code; } @@ -829,8 +840,8 @@ void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { tRBTreePut(&pMTr bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree) { return pMTree->ignoreEarlierTs; } -static void tLDataIterPinSttBlock(SLDataIter* pIter, const char* id) { - SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo; +static void tLDataIterPinSttBlock(SLDataIter *pIter, const char *id) { + SSttBlockLoadInfo *pInfo = pIter->pBlockLoadInfo; if (pInfo->blockData[0].sttBlockIndex == pIter->iSttBlk) { pInfo->blockData[0].pin = true; @@ -842,15 +853,15 @@ static void tLDataIterPinSttBlock(SLDataIter* pIter, const char* id) { if (pInfo->blockData[1].sttBlockIndex == pIter->iSttBlk) { pInfo->blockData[1].pin = true; ASSERT(!pInfo->blockData[0].pin); - tsdbTrace("pin stt-block, blockIndex:%d, stt-fileVer:%"PRId64" %s", pIter->iSttBlk, pIter->cid, id); + tsdbTrace("pin stt-block, blockIndex:%d, stt-fileVer:%" PRId64 " %s", pIter->iSttBlk, pIter->cid, id); return; } - tsdbError("failed to pin any stt block, sttBlock:%d stt-fileVer:%"PRId64" %s", pIter->iSttBlk, pIter->cid, id); + tsdbError("failed to pin any stt block, sttBlock:%d stt-fileVer:%" PRId64 " %s", pIter->iSttBlk, pIter->cid, id); } -static void tLDataIterUnpinSttBlock(SLDataIter* pIter, const char* id) { - SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo; +static void tLDataIterUnpinSttBlock(SLDataIter *pIter, const char *id) { + SSttBlockLoadInfo *pInfo = pIter->pBlockLoadInfo; if (pInfo->blockData[0].pin) { ASSERT(!pInfo->blockData[1].pin); pInfo->blockData[0].pin = false; @@ -883,7 +894,7 @@ void tMergeTreeUnpinSttBlock(SMergeTree *pMTree) { return; } - SLDataIter* pIter = pMTree->pPinnedBlockIter; + SLDataIter *pIter = pMTree->pPinnedBlockIter; pMTree->pPinnedBlockIter = NULL; tLDataIterUnpinSttBlock(pIter, pMTree->idStr); } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index d740f9491c..55633854ac 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -42,7 +42,8 @@ static TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbRe static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader); static int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts, SRowMerger* pMerger, SVersionRange* pVerRange, const char* id); -static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, STsdbReader* pReader); +static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, STsdbRowKey* pKey, SArray* pDelList, + STsdbReader* pReader); static int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, SRow* pTSRow, STableBlockScanInfo* pScanInfo); static int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData, @@ -79,6 +80,32 @@ static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWi static void resetPreFilesetMemTableListIndex(SReaderStatus* pStatus); +static int32_t pkComp(STsdbReader* pReader, TSDBROW* p1, TSDBROW* p2) { + STsdbRowKey k1 = {0}, k2 = {0}; + + if (pReader->pkComparFn == NULL) { + ASSERT(TSDBROW_TS(p1) != TSDBROW_TS(p2)); + ASSERT(pReader->pkChecked); + return 0; + } + + tsdbRowGetKey(p1, &k1); + tsdbRowGetKey(p2, &k2); + return pReader->pkComparFn(&k1.key.pks[0].val, &k2.key.pks[0].val); +} + +static int32_t pkComp1(STsdbReader* pReader, STsdbRowKey* p1, TSDBROW* p2) { + if (pReader->pkComparFn == NULL) { + ASSERT(p1->key.ts != TSDBROW_TS(p2)); + ASSERT(pReader->pkChecked); + return 0; + } + + STsdbRowKey k2 = {0}; + tsdbRowGetKey(p2, &k2); + return pReader->pkComparFn(&p1->key.pks[0].val, &k2.key.pks[0].val); +} + static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pCols, const int32_t* pSlotIdList, int32_t numOfCols) { pSupInfo->smaValid = true; @@ -591,7 +618,7 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN } // 1. time range check - if (pRecord->firstKey > w.ekey || pRecord->lastKey < w.skey) { + if (pRecord->firstKey.key.ts > w.ekey || pRecord->lastKey.key.ts < w.skey) { continue; } @@ -609,11 +636,11 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN return TSDB_CODE_OUT_OF_MEMORY; } - if (pScanInfo->filesetWindow.skey > pRecord->firstKey) { - pScanInfo->filesetWindow.skey = pRecord->firstKey; + if (pScanInfo->filesetWindow.skey > pRecord->firstKey.key.ts) { + pScanInfo->filesetWindow.skey = pRecord->firstKey.key.ts; } - if (pScanInfo->filesetWindow.ekey < pRecord->lastKey) { - pScanInfo->filesetWindow.ekey = pRecord->lastKey; + if (pScanInfo->filesetWindow.ekey < pRecord->lastKey.key.ts) { + pScanInfo->filesetWindow.ekey = pRecord->lastKey.key.ts; } pBlockNum->numOfBlocks += 1; @@ -653,7 +680,7 @@ static void setBlockAllDumped(SFileBlockDumpInfo* pDumpInfo, int64_t maxKey, int static int32_t doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_t colIndex, SColVal* pColVal, SBlockLoadSuppInfo* pSup) { - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { if (!COL_VAL_IS_VALUE(pColVal)) { colDataSetNULL(pColInfoData, rowIndex); } else { @@ -671,7 +698,7 @@ static int32_t doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int colDataSetVal(pColInfoData, rowIndex, pSup->buildBuf[colIndex], false); } } else { - colDataSetVal(pColInfoData, rowIndex, (const char*)&pColVal->value, !COL_VAL_IS_VALUE(pColVal)); + colDataSetVal(pColInfoData, rowIndex, (const char*)&pColVal->value.val, !COL_VAL_IS_VALUE(pColVal)); } return TSDB_CODE_SUCCESS; @@ -745,9 +772,9 @@ static int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData int32_t endPos = -1; bool asc = ASCENDING_TRAVERSE(pReader->info.order); - if (asc && pReader->info.window.ekey >= pRecord->lastKey) { + if (asc && pReader->info.window.ekey >= pRecord->lastKey.key.ts) { endPos = pRecord->numRow - 1; - } else if (!asc && pReader->info.window.skey <= pRecord->firstKey) { + } else if (!asc && pReader->info.window.skey <= pRecord->firstKey.key.ts) { endPos = 0; } else { int64_t key = asc ? pReader->info.window.ekey : pReader->info.window.skey; @@ -888,10 +915,14 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo } } -static void blockInfoToRecord(SBrinRecord* record, SFileDataBlockInfo* pBlockInfo){ +static void blockInfoToRecord(SBrinRecord* record, SFileDataBlockInfo* pBlockInfo) { record->uid = pBlockInfo->uid; - record->firstKey = pBlockInfo->firstKey; - record->lastKey = pBlockInfo->lastKey; + record->firstKey = (STsdbRowKey){ + .key = {.ts = pBlockInfo->firstKey, .numOfPKs = 0}, + }; + record->lastKey = (STsdbRowKey){ + .key = {.ts = pBlockInfo->lastKey, .numOfPKs = 0}, + }; record->minVer = pBlockInfo->minVer; record->maxVer = pBlockInfo->maxVer; record->blockOffset = pBlockInfo->blockOffset; @@ -934,9 +965,10 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { // row index of dump info remain the initial position, let's find the appropriate start position. if ((pDumpInfo->rowIndex == 0 && asc) || (pDumpInfo->rowIndex == pRecord->numRow - 1 && (!asc))) { - if (asc && pReader->info.window.skey <= pRecord->firstKey && pReader->info.verRange.minVer <= pRecord->minVer) { + if (asc && pReader->info.window.skey <= pRecord->firstKey.key.ts && + pReader->info.verRange.minVer <= pRecord->minVer) { // pDumpInfo->rowIndex = 0; - } else if (!asc && pReader->info.window.ekey >= pRecord->lastKey && + } else if (!asc && pReader->info.window.ekey >= pRecord->lastKey.key.ts && pReader->info.verRange.maxVer >= pRecord->maxVer) { // pDumpInfo->rowIndex = pRecord->numRow - 1; } else { // find the appropriate the start position in current block, and set it to be the current rowIndex @@ -949,8 +981,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { tsdbError( "%p failed to locate the start position in current block, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 ", minVer:%" PRId64 ", maxVer:%" PRId64 " %s", - pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pRecord->firstKey, pRecord->lastKey, pRecord->minVer, - pRecord->maxVer, pReader->idStr); + pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pRecord->firstKey.key.ts, pRecord->lastKey.key.ts, + pRecord->minVer, pRecord->maxVer, pReader->idStr); return TSDB_CODE_INVALID_PARA; } @@ -1059,7 +1091,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { setBlockAllDumped(pDumpInfo, ts, pReader->info.order); } } else { - int64_t ts = asc ? pRecord->lastKey : pRecord->firstKey; + int64_t ts = asc ? pRecord->lastKey.key.ts : pRecord->firstKey.key.ts; setBlockAllDumped(pDumpInfo, ts, pReader->info.order); } @@ -1069,8 +1101,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { int32_t unDumpedRows = asc ? pRecord->numRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1; tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", uid:%" PRIu64 " elapsed time:%.2f ms, %s", - pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pRecord->firstKey, pRecord->lastKey, dumpedRows, - unDumpedRows, pRecord->minVer, pRecord->maxVer, pBlockInfo->uid, elapsedTime, pReader->idStr); + pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pRecord->firstKey.key.ts, pRecord->lastKey.key.ts, + dumpedRows, unDumpedRows, pRecord->minVer, pRecord->maxVer, pBlockInfo->uid, elapsedTime, pReader->idStr); return TSDB_CODE_SUCCESS; } @@ -1123,8 +1155,8 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI if (code != TSDB_CODE_SUCCESS) { tsdbError("%p error occurs in loading file block, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, code:%s %s", - pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlockInfo->firstKey, - pBlockInfo->lastKey, pBlockInfo->numRow, tstrerror(code), pReader->idStr); + pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlockInfo->firstKey, pBlockInfo->lastKey, + pBlockInfo->numRow, tstrerror(code), pReader->idStr); return code; } @@ -1132,8 +1164,8 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI tsdbDebug("%p load file block into buffer, global index:%d, index in table block list:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s", - pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pRecord->firstKey, pRecord->lastKey, pRecord->numRow, - pRecord->minVer, pRecord->maxVer, elapsedTime, pReader->idStr); + pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pRecord->firstKey.key.ts, pRecord->lastKey.key.ts, + pRecord->numRow, pRecord->minVer, pRecord->maxVer, elapsedTime, pReader->idStr); pReader->cost.blockLoadTime += elapsedTime; pDumpInfo->allDumped = false; @@ -1236,9 +1268,9 @@ static int32_t setFileBlockActiveInBlockIter(STsdbReader* pReader, SDataBlockIte static bool overlapWithNeighborBlock2(SFileDataBlockInfo* pBlock, SBrinRecord* pRec, int32_t order) { // it is the last block in current file, no chance to overlap with neighbor blocks. if (ASCENDING_TRAVERSE(order)) { - return pBlock->lastKey == pRec->firstKey; + return pBlock->lastKey == pRec->firstKey.key.ts; } else { - return pBlock->firstKey == pRec->lastKey; + return pBlock->firstKey == pRec->lastKey.key.ts; } } @@ -1266,8 +1298,8 @@ static bool bufferDataInFileBlockGap(TSDBKEY keyInBuf, SFileDataBlockInfo* pBloc } static bool keyOverlapFileBlock(TSDBKEY key, SFileDataBlockInfo* pBlock, SVersionRange* pVerRange) { - return (key.ts >= pBlock->firstKey && key.ts <= pBlock->lastKey) && - (pBlock->maxVer >= pVerRange->minVer) && (pBlock->minVer <= pVerRange->maxVer); + return (key.ts >= pBlock->firstKey && key.ts <= pBlock->lastKey) && (pBlock->maxVer >= pVerRange->minVer) && + (pBlock->minVer <= pVerRange->maxVer); } static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo* pBlockInfo, @@ -1292,8 +1324,7 @@ static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo* ASSERT(pScanInfo->sttKeyInfo.status != STT_FILE_READER_UNINIT); if (pScanInfo->sttKeyInfo.status == STT_FILE_HAS_DATA) { int64_t nextProcKeyInStt = pScanInfo->sttKeyInfo.nextProcKey; - pInfo->overlapWithSttBlock = - !(pBlockInfo->lastKey < nextProcKeyInStt || pBlockInfo->firstKey > nextProcKeyInStt); + pInfo->overlapWithSttBlock = !(pBlockInfo->lastKey < nextProcKeyInStt || pBlockInfo->firstKey > nextProcKeyInStt); } pInfo->moreThanCapcity = pBlockInfo->numRow > pReader->resBlockInfo.capacity; @@ -1500,7 +1531,9 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* tsLast = getCurrentKeyInSttBlock(pSttBlockReader); } - TSDBKEY k = TSDBROW_KEY(pRow); + STsdbRowKey k; + tsdbRowGetKey(pRow, &k); + TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); // merge is not initialized yet, due to the fact that the pReader->info.pSchema is not initialized @@ -1519,8 +1552,8 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* minKey = tsLast; } - if (minKey > k.ts) { - minKey = k.ts; + if (minKey > k.key.ts) { + minKey = k.key.ts; } if (minKey > key && hasDataInFileBlock(pBlockData, pDumpInfo)) { @@ -1532,8 +1565,8 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* minKey = tsLast; } - if (minKey < k.ts) { - minKey = k.ts; + if (minKey < k.key.ts) { + minKey = k.key.ts; } if (minKey < key && hasDataInFileBlock(pBlockData, pDumpInfo)) { @@ -1561,7 +1594,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, tsLast, pMerger, &pReader->info.verRange, pReader->idStr); } - if (minKey == k.ts) { + if (minKey == k.key.ts) { STSchema* pTSchema = NULL; if (pRow->type == TSDBROW_ROW_FMT) { pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); @@ -1575,13 +1608,13 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } } } else { - if (minKey == k.ts) { + if (minKey == k.key.ts) { STSchema* pTSchema = NULL; if (pRow->type == TSDBROW_ROW_FMT) { pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); @@ -1595,7 +1628,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS || pMerger->pTSchema == NULL) { return code; } @@ -1743,8 +1776,9 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* int64_t key = hasDataInFileBlock(pBlockData, pDumpInfo) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN; - TSDBKEY k = TSDBROW_KEY(pRow); - TSDBKEY ik = TSDBROW_KEY(piRow); + STsdbRowKey k, ik; + tsdbRowGetKey(pRow, &k); + tsdbRowGetKey(piRow, &ik); STSchema* pSchema = NULL; if (pRow->type == TSDBROW_ROW_FMT) { @@ -1774,12 +1808,12 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* int64_t minKey = 0; if (ASCENDING_TRAVERSE(pReader->info.order)) { minKey = INT64_MAX; // let's find the minimum - if (minKey > k.ts) { - minKey = k.ts; + if (minKey > k.key.ts) { + minKey = k.key.ts; } - if (minKey > ik.ts) { - minKey = ik.ts; + if (minKey > ik.key.ts) { + minKey = ik.key.ts; } if (minKey > key && hasDataInFileBlock(pBlockData, pDumpInfo)) { @@ -1791,12 +1825,12 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* } } else { minKey = INT64_MIN; // let find the maximum ts value - if (minKey < k.ts) { - minKey = k.ts; + if (minKey < k.key.ts) { + minKey = k.key.ts; } - if (minKey < ik.ts) { - minKey = ik.ts; + if (minKey < ik.key.ts) { + minKey = ik.key.ts; } if (minKey < key && hasDataInFileBlock(pBlockData, pDumpInfo)) { @@ -1831,49 +1865,49 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, tsLast, pMerger, &pReader->info.verRange, pReader->idStr); } - if (minKey == ik.ts) { + if (minKey == ik.key.ts) { code = tsdbRowMergerAdd(pMerger, piRow, piSchema); if (code != TSDB_CODE_SUCCESS) { return code; } - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, ik.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } } - if (minKey == k.ts) { + if (minKey == k.key.ts) { code = tsdbRowMergerAdd(pMerger, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } } } else { - if (minKey == k.ts) { + if (minKey == k.key.ts) { code = tsdbRowMergerAdd(pMerger, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } } - if (minKey == ik.ts) { + if (minKey == ik.key.ts) { code = tsdbRowMergerAdd(pMerger, piRow, piSchema); if (code != TSDB_CODE_SUCCESS) { return code; } - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, ik.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1912,7 +1946,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* return code; } -int32_t doInitMemDataIter(STsdbReader* pReader, STbData** pData, STableBlockScanInfo* pBlockScanInfo, TSDBKEY* pKey, +int32_t doInitMemDataIter(STsdbReader* pReader, STbData** pData, STableBlockScanInfo* pBlockScanInfo, STsdbRowKey* pKey, SMemTable* pMem, SIterInfo* pIter, const char* type) { int32_t code = TSDB_CODE_SUCCESS; int32_t backward = (!ASCENDING_TRAVERSE(pReader->info.order)); @@ -1928,8 +1962,8 @@ int32_t doInitMemDataIter(STsdbReader* pReader, STbData** pData, STableBlockScan tsdbDebug("%p uid:%" PRIu64 ", check data in %s from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64 "-%" PRId64 " %s", - pReader, pBlockScanInfo->uid, type, pKey->ts, pReader->info.order, (*pData)->minKey, (*pData)->maxKey, - pReader->idStr); + pReader, pBlockScanInfo->uid, type, pKey->key.ts, pReader->info.order, (*pData)->minKey, + (*pData)->maxKey, pReader->idStr); } else { tsdbError("%p uid:%" PRIu64 ", failed to create iterator for %s, code:%s, %s", pReader, pBlockScanInfo->uid, type, tstrerror(code), pReader->idStr); @@ -1948,12 +1982,20 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea return TSDB_CODE_SUCCESS; } - STbData* d = NULL; - TSDBKEY startKey = {0}; + STbData* d = NULL; + STsdbRowKey startKey = {0}; if (ASCENDING_TRAVERSE(pReader->info.order)) { - startKey = (TSDBKEY){.ts = pBlockScanInfo->lastProcKey + 1, .version = pReader->info.verRange.minVer}; + startKey = (STsdbRowKey){.version = pReader->info.verRange.minVer, + .key = { + .ts = pBlockScanInfo->lastProcKey + 1, + .numOfPKs = 0, // TODO: change here if multi-key is supported + }}; } else { - startKey = (TSDBKEY){.ts = pBlockScanInfo->lastProcKey - 1, .version = pReader->info.verRange.maxVer}; + startKey = (STsdbRowKey){.version = pReader->info.verRange.maxVer, + .key = { + .ts = pBlockScanInfo->lastProcKey - 1, + .numOfPKs = 0, // TODO: change here if multi-key is supported + }}; } int32_t code = @@ -2001,8 +2043,8 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, int32_t rowIndex, STable } if (pBlockScanInfo->delSkyline != NULL && TARRAY_SIZE(pBlockScanInfo->delSkyline) > 0) { - bool dropped = hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->fileDelIndex, ts, ver, - pInfo->order, &pInfo->verRange); + bool dropped = hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->fileDelIndex, ts, ver, pInfo->order, + &pInfo->verRange); if (dropped) { return false; } @@ -2069,7 +2111,7 @@ static bool initSttBlockReader(SSttBlockReader* pSttBlockReader, STableBlockScan initMemDataIterator(pScanInfo, pReader); initDelSkylineIterator(pScanInfo, pReader->info.order, &pReader->cost); - if (conf.rspRows) { + if (0 /*conf.rspRows*/) { pScanInfo->cleanSttBlocks = isCleanSttBlock(info.pTimeWindowList, &pReader->info.window, pScanInfo, pReader->info.order); @@ -2094,14 +2136,14 @@ static bool initSttBlockReader(SSttBlockReader* pSttBlockReader, STableBlockScan pScanInfo->sttKeyInfo.nextProcKey = ASCENDING_TRAVERSE(pReader->info.order) ? pScanInfo->sttWindow.skey : pScanInfo->sttWindow.ekey; hasData = true; - } else { // not clean stt blocks - INIT_TIMEWINDOW(&pScanInfo->sttWindow); //reset the time window + } else { // not clean stt blocks + INIT_TIMEWINDOW(&pScanInfo->sttWindow); // reset the time window pScanInfo->sttBlockReturned = false; hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, &pReader->info.verRange); } } else { pScanInfo->cleanSttBlocks = false; - INIT_TIMEWINDOW(&pScanInfo->sttWindow); //reset the time window + INIT_TIMEWINDOW(&pScanInfo->sttWindow); // reset the time window pScanInfo->sttBlockReturned = false; hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, &pReader->info.verRange); } @@ -2675,7 +2717,8 @@ static void buildCleanBlockFromDataFiles(STsdbReader* pReader, STableBlockScanIn // update the last key for the corresponding table pScanInfo->lastProcKey = asc ? pInfo->window.ekey : pInfo->window.skey; - tsdbDebug("%p uid:%" PRIu64 " clean file block retrieved from file, global index:%d, " + tsdbDebug("%p uid:%" PRIu64 + " clean file block retrieved from file, global index:%d, " "table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s", pReader, pScanInfo->uid, blockIndex, pBlockInfo->tbBlockIdx, pBlockInfo->numRow, pBlockInfo->firstKey, pBlockInfo->lastKey, pReader->idStr); @@ -3327,9 +3370,18 @@ TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* p return NULL; } - TSDBROW* pRow = tsdbTbDataIterGet(pIter->iter); - TSDBKEY key = TSDBROW_KEY(pRow); int32_t order = pReader->info.order; + TSDBROW* pRow = tsdbTbDataIterGet(pIter->iter); + + if (!pReader->pkChecked) { + STsdbRowKey k; + tsdbRowGetKey(pRow, &k); + + pReader->pkComparFn = getComparFunc(k.key.pks[0].type, 0); + pReader->pkChecked = true; + } + + TSDBKEY key = TSDBROW_KEY(pRow); if (outOfTimeWindow(key.ts, &pReader->info.window)) { pIter->hasVal = false; return NULL; @@ -3374,7 +3426,7 @@ TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* p } } -int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, STsdbReader* pReader) { +int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, STsdbRowKey *pCurKey, SArray* pDelList, STsdbReader* pReader) { SRowMerger* pMerger = &pReader->status.merger; while (1) { @@ -3390,8 +3442,11 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDe } // ts is not identical, quit - TSDBKEY k = TSDBROW_KEY(pRow); - if (k.ts != ts) { + if (TSDBROW_TS(pRow) != pCurKey->key.ts) { + break; + } + + if (pkComp1(pReader, pCurKey, pRow) != 0) { break; } @@ -3512,6 +3567,9 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, TSDBROW* pNextRow = NULL; TSDBROW current = *pRow; + STsdbRowKey curKey = {0}; + tsdbRowGetKey(¤t, &curKey); + { // if the timestamp of the next valid row has a different ts, return current row directly pIter->hasVal = tsdbTbDataIterNext(pIter->iter); @@ -3527,7 +3585,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, return TSDB_CODE_SUCCESS; } - if (TSDBROW_TS(¤t) != TSDBROW_TS(pNextRow)) { + if (TSDBROW_TS(¤t) != TSDBROW_TS(pNextRow) || (pkComp1(pReader, &curKey, pNextRow) != 0)) { *pResRow = current; *freeTSRow = false; return TSDB_CODE_SUCCESS; @@ -3565,7 +3623,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, return code; } - code = doMergeRowsInBuf(pIter, uid, TSDBROW_TS(¤t), pDelList, pReader); + code = doMergeRowsInBuf(pIter, uid, &curKey, pDelList, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3586,8 +3644,9 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p SRow** pTSRow) { SRowMerger* pMerger = &pReader->status.merger; - TSDBKEY k = TSDBROW_KEY(pRow); - TSDBKEY ik = TSDBROW_KEY(piRow); + STsdbRowKey k, ik; + tsdbRowGetKey(pRow, &k); + tsdbRowGetKey(piRow, &ik); STSchema* pSchema = NULL; if (pRow->type == TSDBROW_ROW_FMT) { @@ -3611,13 +3670,13 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p return code; } - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, ik.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } tsdbRowMergerAdd(&pReader->status.merger, pRow, pSchema); - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3628,13 +3687,13 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p return code; } - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } tsdbRowMergerAdd(&pReader->status.merger, piRow, piSchema); - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, ik.ts, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3673,7 +3732,7 @@ static int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbRea TSDBKEY ik = TSDBROW_KEY(piRow); int32_t code = TSDB_CODE_SUCCESS; - if (ik.ts != k.ts) { + if (ik.ts != k.ts || (pkComp(pReader, pRow, piRow) != 0)) { if (((ik.ts < k.ts) && asc) || ((ik.ts > k.ts) && (!asc))) { // ik.ts < k.ts code = doMergeMemTableMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, pResRow, pReader, freeTSRow); } else if (((k.ts < ik.ts) && asc) || ((k.ts > ik.ts) && (!asc))) { @@ -3692,8 +3751,7 @@ static int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbRea } if (pBlockScanInfo->iter.hasVal && pRow != NULL) { - return doMergeMemTableMultiRows(pRow, pBlockScanInfo->uid, &pBlockScanInfo->iter, pDelList, pResRow, pReader, - freeTSRow); + return doMergeMemTableMultiRows(pRow, uid, &pBlockScanInfo->iter, pDelList, pResRow, pReader, freeTSRow); } if (pBlockScanInfo->iiter.hasVal && piRow != NULL) { diff --git a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c index 33604d21de..4c742c0572 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c @@ -14,7 +14,6 @@ */ #include "tsdbReadUtil.h" -#include "osDef.h" #include "tsdb.h" #include "tsdbDataFileRW.h" #include "tsdbFS2.h" @@ -281,7 +280,7 @@ void initBrinRecordIter(SBrinRecordIter* pIter, SDataFileReader* pReader, SArray } SBrinRecord* getNextBrinRecord(SBrinRecordIter* pIter) { - if (pIter->blockIndex == -1 || (pIter->recordIndex + 1) >= TARRAY2_SIZE(pIter->block.numRow)) { + if (pIter->blockIndex == -1 || (pIter->recordIndex + 1) >= pIter->block.numOfRecords) { pIter->blockIndex += 1; if (pIter->blockIndex >= taosArrayGetSize(pIter->pBrinBlockList)) { return NULL; @@ -356,10 +355,10 @@ static int32_t fileDataBlockOrderCompar(const void* pLeft, const void* pRight, v return pLeftBlock->offset > pRightBlock->offset ? 1 : -1; } -static void recordToBlockInfo(SFileDataBlockInfo* pBlockInfo, SBrinRecord* record){ +static void recordToBlockInfo(SFileDataBlockInfo* pBlockInfo, SBrinRecord* record) { pBlockInfo->uid = record->uid; - pBlockInfo->firstKey = record->firstKey; - pBlockInfo->lastKey = record->lastKey; + pBlockInfo->firstKey = record->firstKey.key.ts; + pBlockInfo->lastKey = record->lastKey.key.ts; pBlockInfo->minVer = record->minVer; pBlockInfo->maxVer = record->maxVer; pBlockInfo->blockOffset = record->blockOffset; @@ -429,7 +428,7 @@ int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIter, int3 } for (int32_t i = 0; i < numOfBlocks; ++i) { SFileDataBlockInfo blockInfo = {.tbBlockIdx = i}; - SBrinRecord* record = (SBrinRecord*)taosArrayGet(sup.pDataBlockInfo[0][i].pInfo->pBlockList, i); + SBrinRecord* record = (SBrinRecord*)taosArrayGet(sup.pDataBlockInfo[0][i].pInfo->pBlockList, i); recordToBlockInfo(&blockInfo, record); taosArrayPush(pBlockIter->blockList, &blockInfo); @@ -464,7 +463,7 @@ int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIter, int3 int32_t index = sup.indexPerTable[pos]++; SFileDataBlockInfo blockInfo = {.tbBlockIdx = index}; - SBrinRecord* record = (SBrinRecord*)taosArrayGet(sup.pDataBlockInfo[pos][index].pInfo->pBlockList, index); + SBrinRecord* record = (SBrinRecord*)taosArrayGet(sup.pDataBlockInfo[pos][index].pInfo->pBlockList, index); recordToBlockInfo(&blockInfo, record); taosArrayPush(pBlockIter->blockList, &blockInfo); @@ -529,7 +528,7 @@ static int32_t doCheckTombBlock(STombBlock* pBlock, STsdbReader* pReader, int32_ pScanInfo->pFileDelData = taosArrayInit(4, sizeof(SDelData)); } - for (int32_t k = 0; k < TARRAY2_SIZE(pBlock->suid); ++k) { + for (int32_t k = 0; k < pBlock->numOfRecords; ++k) { code = tTombBlockGet(pBlock, k, &record); if (code != TSDB_CODE_SUCCESS) { *pRet = BLK_CHECK_QUIT; @@ -722,11 +721,11 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo pBlockLoadInfo->cost.statisElapsedTime += el; int32_t index = 0; - while (index < TARRAY2_SIZE(pStatisBlock->suid) && pStatisBlock->suid->data[index] < suid) { + while (index < pStatisBlock->numOfRecords && ((int64_t*)pStatisBlock->suids.data)[index] < suid) { ++index; } - if (index >= TARRAY2_SIZE(pStatisBlock->suid)) { + if (index >= pStatisBlock->numOfRecords) { tStatisBlockDestroy(pStatisBlock); taosMemoryFreeClear(pStatisBlock); return num; @@ -744,14 +743,14 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo uint64_t uid = pUidList[uidIndex]; - if (pStatisBlock->uid->data[j] == uid) { - num += pStatisBlock->count->data[j]; + if (((int64_t*)pStatisBlock->uids.data)[j] == uid) { + num += ((int64_t*)pStatisBlock->counts.data)[j]; uidIndex += 1; j += 1; - loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->suid->size, &i, &j); - } else if (pStatisBlock->uid->data[j] < uid) { + loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->numOfRecords, &i, &j); + } else if (((int64_t*)pStatisBlock->uids.data)[j] < uid) { j += 1; - loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->suid->size, &i, &j); + loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->numOfRecords, &i, &j); } else { uidIndex += 1; } @@ -962,15 +961,15 @@ static bool doCheckDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const S for (int32_t i = startIndex; i < num; i += 1) { TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i); - if (p->ts >= pRecord->firstKey && p->ts <= pRecord->lastKey) { + if (p->ts >= pRecord->firstKey.key.ts && p->ts <= pRecord->lastKey.key.ts) { if (p->version >= pRecord->minVer) { return true; } - } else if (p->ts < pRecord->firstKey) { // p->ts < pBlock->minKey.ts + } else if (p->ts < pRecord->firstKey.key.ts) { // p->ts < pBlock->minKey.ts if (p->version >= pRecord->minVer) { if (i < num - 1) { TSDBKEY* pnext = taosArrayGet(pBlockScanInfo->delSkyline, i + 1); - if (pnext->ts >= pRecord->firstKey) { + if (pnext->ts >= pRecord->firstKey.key.ts) { return true; } } else { // it must be the last point @@ -991,12 +990,12 @@ static bool doCheckDatablockOverlapWithoutVersion(STableBlockScanInfo* pBlockSca for (int32_t i = startIndex; i < num; i += 1) { TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i); - if (p->ts >= pRecord->firstKey && p->ts <= pRecord->lastKey) { + if (p->ts >= pRecord->firstKey.key.ts && p->ts <= pRecord->lastKey.key.ts) { return true; - } else if (p->ts < pRecord->firstKey) { // p->ts < pBlock->minKey.ts + } else if (p->ts < pRecord->firstKey.key.ts) { // p->ts < pBlock->minKey.ts if (i < num - 1) { TSDBKEY* pnext = taosArrayGet(pBlockScanInfo->delSkyline, i + 1); - if (pnext->ts >= pRecord->firstKey) { + if (pnext->ts >= pRecord->firstKey.key.ts) { return true; } } @@ -1016,7 +1015,7 @@ bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBrinRecor // ts is not overlap TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0); TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline); - if (pRecord->firstKey > pLast->ts || pRecord->lastKey < pFirst->ts) { + if (pRecord->firstKey.key.ts > pLast->ts || pRecord->lastKey.key.ts < pFirst->ts) { return false; } @@ -1027,10 +1026,10 @@ bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBrinRecor int32_t index = pBlockScanInfo->fileDelIndex; while (1) { TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, index); - if (p->ts > pRecord->firstKey && index > 0) { + if (p->ts > pRecord->firstKey.key.ts && index > 0) { index -= 1; } else { // find the first point that is smaller than the minKey.ts of dataBlock. - if (p->ts == pRecord->firstKey && p->version < pRecord->maxVer && index > 0) { + if (p->ts == pRecord->firstKey.key.ts && p->version < pRecord->maxVer && index > 0) { index -= 1; } break; @@ -1049,7 +1048,7 @@ bool overlapWithDelSkylineWithoutVer(STableBlockScanInfo* pBlockScanInfo, const // ts is not overlap TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0); TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline); - if (pRecord->firstKey > pLast->ts || pRecord->lastKey < pFirst->ts) { + if (pRecord->firstKey.key.ts > pLast->ts || pRecord->lastKey.key.ts < pFirst->ts) { return false; } @@ -1060,10 +1059,10 @@ bool overlapWithDelSkylineWithoutVer(STableBlockScanInfo* pBlockScanInfo, const int32_t index = pBlockScanInfo->fileDelIndex; while (1) { TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, index); - if (p->ts > pRecord->firstKey && index > 0) { + if (p->ts > pRecord->firstKey.key.ts && index > 0) { index -= 1; } else { // find the first point that is smaller than the minKey.ts of dataBlock. - if (p->ts == pRecord->firstKey && index > 0) { + if (p->ts == pRecord->firstKey.key.ts && index > 0) { index -= 1; } break; diff --git a/source/dnode/vnode/src/tsdb/tsdbReadUtil.h b/source/dnode/vnode/src/tsdb/tsdbReadUtil.h index c27e9ebe04..7966a87500 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadUtil.h +++ b/source/dnode/vnode/src/tsdb/tsdbReadUtil.h @@ -266,7 +266,9 @@ struct STsdbReader { STsdbReader* innerReader[2]; bool bFilesetDelimited; // duration by duration output TsdReaderNotifyCbFn notifyFn; - void* notifyParam; + void* notifyParam; + __compar_fn_t pkComparFn; + bool pkChecked; }; typedef struct SBrinRecordIter { diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index babf8c75fb..76a8ee0e2a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -414,6 +414,18 @@ _exit: return code; } +int32_t tsdbReadFileToBuffer(STsdbFD *pFD, int64_t offset, int64_t size, SBuffer *buffer, int64_t szHint) { + int32_t code; + + code = tBufferEnsureCapacity(buffer, buffer->size + size); + if (code) return code; + code = tsdbReadFile(pFD, offset, (uint8_t *)tBufferGetDataEnd(buffer), size, szHint); + if (code) return code; + buffer->size += size; + + return code; +} + int32_t tsdbFsyncFile(STsdbFD *pFD) { int32_t code = 0; @@ -620,235 +632,6 @@ _err: return code; } -int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pDataBlk, SArray *aColumnDataAgg) { - int32_t code = 0; - SSmaInfo *pSmaInfo = &pDataBlk->smaInfo; - - ASSERT(pSmaInfo->size > 0); - - taosArrayClear(aColumnDataAgg); - - // alloc - code = tRealloc(&pReader->aBuf[0], pSmaInfo->size); - if (code) goto _err; - - // read - code = tsdbReadFile(pReader->pSmaFD, pSmaInfo->offset, pReader->aBuf[0], pSmaInfo->size, 0); - if (code) goto _err; - - // decode - int32_t n = 0; - while (n < pSmaInfo->size) { - SColumnDataAgg sma; - n += tGetColumnDataAgg(pReader->aBuf[0] + n, &sma); - - if (taosArrayPush(aColumnDataAgg, &sma) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - } - ASSERT(n == pSmaInfo->size); - return code; - -_err: - tsdbError("vgId:%d, tsdb read block sma failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); - return code; -} - -static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo, SBlockData *pBlockData, - int32_t iStt) { - int32_t code = 0; - - tBlockDataClear(pBlockData); - - STsdbFD *pFD = (iStt < 0) ? pReader->pDataFD : pReader->aSttFD[iStt]; - - // uid + version + tskey - code = tRealloc(&pReader->aBuf[0], pBlkInfo->szKey); - if (code) goto _err; - - code = tsdbReadFile(pFD, pBlkInfo->offset, pReader->aBuf[0], pBlkInfo->szKey, 0); - if (code) goto _err; - - SDiskDataHdr hdr; - uint8_t *p = pReader->aBuf[0] + tGetDiskDataHdr(pReader->aBuf[0], &hdr); - - ASSERT(hdr.delimiter == TSDB_FILE_DLMT); - ASSERT(pBlockData->suid == hdr.suid); - - pBlockData->uid = hdr.uid; - pBlockData->nRow = hdr.nRow; - - // uid - if (hdr.uid == 0) { - ASSERT(hdr.szUid); - code = tsdbDecmprData(p, hdr.szUid, TSDB_DATA_TYPE_BIGINT, hdr.cmprAlg, (uint8_t **)&pBlockData->aUid, - sizeof(int64_t) * hdr.nRow, &pReader->aBuf[1]); - if (code) goto _err; - } else { - ASSERT(!hdr.szUid); - } - p += hdr.szUid; - - // version - code = tsdbDecmprData(p, hdr.szVer, TSDB_DATA_TYPE_BIGINT, hdr.cmprAlg, (uint8_t **)&pBlockData->aVersion, - sizeof(int64_t) * hdr.nRow, &pReader->aBuf[1]); - if (code) goto _err; - p += hdr.szVer; - - // TSKEY - code = tsdbDecmprData(p, hdr.szKey, TSDB_DATA_TYPE_TIMESTAMP, hdr.cmprAlg, (uint8_t **)&pBlockData->aTSKEY, - sizeof(TSKEY) * hdr.nRow, &pReader->aBuf[1]); - if (code) goto _err; - p += hdr.szKey; - - ASSERT(p - pReader->aBuf[0] == pBlkInfo->szKey); - - // read and decode columns - if (pBlockData->nColData == 0) goto _exit; - - if (hdr.szBlkCol > 0) { - int64_t offset = pBlkInfo->offset + pBlkInfo->szKey; - - code = tRealloc(&pReader->aBuf[0], hdr.szBlkCol); - if (code) goto _err; - - code = tsdbReadFile(pFD, offset, pReader->aBuf[0], hdr.szBlkCol, 0); - if (code) goto _err; - } - - SBlockCol blockCol = {.cid = 0}; - SBlockCol *pBlockCol = &blockCol; - int32_t n = 0; - - for (int32_t iColData = 0; iColData < pBlockData->nColData; iColData++) { - SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iColData); - - while (pBlockCol && pBlockCol->cid < pColData->cid) { - if (n < hdr.szBlkCol) { - n += tGetBlockCol(pReader->aBuf[0] + n, pBlockCol); - } else { - ASSERT(n == hdr.szBlkCol); - pBlockCol = NULL; - } - } - - if (pBlockCol == NULL || pBlockCol->cid > pColData->cid) { - // add a lot of NONE - for (int32_t iRow = 0; iRow < hdr.nRow; iRow++) { - code = tColDataAppendValue(pColData, &COL_VAL_NONE(pColData->cid, pColData->type)); - if (code) goto _err; - } - } else { - ASSERT(pBlockCol->type == pColData->type); - ASSERT(pBlockCol->flag && pBlockCol->flag != HAS_NONE); - - if (pBlockCol->flag == HAS_NULL) { - // add a lot of NULL - for (int32_t iRow = 0; iRow < hdr.nRow; iRow++) { - code = tColDataAppendValue(pColData, &COL_VAL_NULL(pBlockCol->cid, pBlockCol->type)); - if (code) goto _err; - } - } else { - // decode from binary - int64_t offset = pBlkInfo->offset + pBlkInfo->szKey + hdr.szBlkCol + pBlockCol->offset; - int32_t size = pBlockCol->szBitmap + pBlockCol->szOffset + pBlockCol->szValue; - - code = tRealloc(&pReader->aBuf[1], size); - if (code) goto _err; - - code = tsdbReadFile(pFD, offset, pReader->aBuf[1], size, 0); - if (code) goto _err; - - code = tsdbDecmprColData(pReader->aBuf[1], pBlockCol, hdr.cmprAlg, hdr.nRow, pColData, &pReader->aBuf[2]); - if (code) goto _err; - } - } - } - -_exit: - return code; - -_err: - tsdbError("vgId:%d, tsdb read block data impl failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); - return code; -} - -int32_t tsdbReadDataBlockEx(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData) { - int32_t code = 0; - SBlockInfo *pBlockInfo = &pDataBlk->aSubBlock[0]; - - // alloc - code = tRealloc(&pReader->aBuf[0], pBlockInfo->szBlock); - if (code) goto _err; - - // read - code = tsdbReadFile(pReader->pDataFD, pBlockInfo->offset, pReader->aBuf[0], pBlockInfo->szBlock, 0); - if (code) goto _err; - - // decmpr - code = tDecmprBlockData(pReader->aBuf[0], pBlockInfo->szBlock, pBlockData, &pReader->aBuf[1]); - if (code) goto _err; - - return code; - -_err: - tsdbError("vgId:%d, tsdb read data block ex failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); - return code; -} - -int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData) { - int32_t code = 0; - - code = tsdbReadBlockDataImpl(pReader, &pDataBlk->aSubBlock[0], pBlockData, -1); - if (code) goto _err; - - ASSERT(pDataBlk->nSubBlock == 1); - - return code; - -_err: - tsdbError("vgId:%d, tsdb read data block failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); - return code; -} - -int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData) { - int32_t code = 0; - int32_t lino = 0; - - code = tsdbReadBlockDataImpl(pReader, &pSttBlk->bInfo, pBlockData, iStt); - TSDB_CHECK_CODE(code, lino, _exit); - -_exit: - if (code) { - tsdbError("vgId:%d, %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); - } - return code; -} - -int32_t tsdbReadSttBlockEx(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData) { - int32_t code = 0; - int32_t lino = 0; - - // alloc - code = tRealloc(&pReader->aBuf[0], pSttBlk->bInfo.szBlock); - TSDB_CHECK_CODE(code, lino, _exit); - - // read - code = tsdbReadFile(pReader->aSttFD[iStt], pSttBlk->bInfo.offset, pReader->aBuf[0], pSttBlk->bInfo.szBlock, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - // decmpr - code = tDecmprBlockData(pReader->aBuf[0], pSttBlk->bInfo.szBlock, pBlockData, &pReader->aBuf[1]); - TSDB_CHECK_CODE(code, lino, _exit); - -_exit: - if (code) { - tsdbError("vgId:%d, %s failed at %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); - } - return code; -} - // SDelFReader ==================================================== struct SDelFReader { STsdb *pTsdb; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 81a136a0e3..dece1c7b98 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -29,17 +29,17 @@ struct STsdbSnapReader { int64_t ever; int8_t type; - uint8_t* aBuf[5]; + SBuffer buffers[10]; SSkmInfo skmTb[1]; TFileSetRangeArray* fsrArr; // context struct { - int32_t fsrArrIdx; + int32_t fsrArrIdx; STFileSetRange* fsr; - bool isDataDone; - bool isTombDone; + bool isDataDone; + bool isTombDone; } ctx[1]; // reader @@ -68,7 +68,7 @@ static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) { SDataFileReaderConfig config = { .tsdb = reader->tsdb, .szPage = reader->tsdb->pVnode->config.tsdbPageSize, - .bufArr = reader->aBuf, + .buffers = reader->buffers, }; bool hasDataFile = false; for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX; ftype++) { @@ -94,7 +94,7 @@ static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) { .tsdb = reader->tsdb, .szPage = reader->tsdb->pVnode->config.tsdbPageSize, .file = fobj->f[0], - .bufArr = reader->aBuf, + .buffers = reader->buffers, }; code = tsdbSttFileReaderOpen(fobj->fname, &config, &sttReader); @@ -247,11 +247,14 @@ static int32_t tsdbSnapCmprData(STsdbSnapReader* reader, uint8_t** data) { int32_t code = 0; int32_t lino = 0; - int32_t aBufN[5] = {0}; - code = tCmprBlockData(reader->blockData, NO_COMPRESSION, NULL, NULL, reader->aBuf, aBufN); + code = tBlockDataCompress(reader->blockData, NO_COMPRESSION, reader->buffers, reader->buffers + 4); TSDB_CHECK_CODE(code, lino, _exit); + // TSDB_CHECK_CODE(code, lino, _exit); - int32_t size = aBufN[0] + aBufN[1] + aBufN[2] + aBufN[3]; + int32_t size = 0; + for (int i = 0; i < 4; i++) { + size += reader->buffers[i].size; + } *data = taosMemoryMalloc(sizeof(SSnapDataHdr) + size); if (*data == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -259,16 +262,13 @@ static int32_t tsdbSnapCmprData(STsdbSnapReader* reader, uint8_t** data) { } SSnapDataHdr* pHdr = (SSnapDataHdr*)*data; + uint8_t* pBuf = pHdr->data; + pHdr->type = reader->type; pHdr->size = size; - - memcpy(pHdr->data, reader->aBuf[3], aBufN[3]); - memcpy(pHdr->data + aBufN[3], reader->aBuf[2], aBufN[2]); - if (aBufN[1]) { - memcpy(pHdr->data + aBufN[3] + aBufN[2], reader->aBuf[1], aBufN[1]); - } - if (aBufN[0]) { - memcpy(pHdr->data + aBufN[3] + aBufN[2] + aBufN[1], reader->aBuf[0], aBufN[0]); + for (int i = 0; i < 4; i++) { + memcpy(pBuf, reader->buffers[i].data, reader->buffers[i].size); + pBuf += reader->buffers[i].size; } _exit: @@ -355,8 +355,8 @@ static int32_t tsdbSnapCmprTombData(STsdbSnapReader* reader, uint8_t** data) { int32_t lino = 0; int64_t size = 0; - for (int32_t i = 0; i < ARRAY_SIZE(reader->tombBlock->dataArr); i++) { - size += TARRAY2_DATA_LEN(reader->tombBlock->dataArr + i); + for (int32_t i = 0; i < ARRAY_SIZE(reader->tombBlock->buffers); i++) { + size += reader->tombBlock->buffers[i].size; } data[0] = taosMemoryMalloc(size + sizeof(SSnapDataHdr)); @@ -370,9 +370,9 @@ static int32_t tsdbSnapCmprTombData(STsdbSnapReader* reader, uint8_t** data) { hdr->size = size; uint8_t* tdata = hdr->data; - for (int32_t i = 0; i < ARRAY_SIZE(reader->tombBlock->dataArr); i++) { - memcpy(tdata, TARRAY2_DATA(reader->tombBlock->dataArr + i), TARRAY2_DATA_LEN(reader->tombBlock->dataArr + i)); - tdata += TARRAY2_DATA_LEN(reader->tombBlock->dataArr + i); + for (int32_t i = 0; i < ARRAY_SIZE(reader->tombBlock->buffers); i++) { + memcpy(tdata, reader->tombBlock->buffers[i].data, reader->tombBlock->buffers[i].size); + tdata += reader->tombBlock->buffers[i].size; } _exit: @@ -475,8 +475,8 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** reader) { tsdbFSDestroyRefRangedSnapshot(&reader[0]->fsrArr); tDestroyTSchema(reader[0]->skmTb->pTSchema); - for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->aBuf); ++i) { - tFree(reader[0]->aBuf[i]); + for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->buffers); ++i) { + tBufferDestroy(reader[0]->buffers + i); } taosMemoryFree(reader[0]); @@ -542,19 +542,19 @@ _exit: // STsdbSnapWriter ======================================== struct STsdbSnapWriter { - STsdb* tsdb; - int64_t sver; - int64_t ever; - int32_t minutes; - int8_t precision; - int32_t minRow; - int32_t maxRow; - int8_t cmprAlg; - int64_t commitID; - int32_t szPage; - int64_t compactVersion; - int64_t now; - uint8_t* aBuf[5]; + STsdb* tsdb; + int64_t sver; + int64_t ever; + int32_t minutes; + int8_t precision; + int32_t minRow; + int32_t maxRow; + int8_t cmprAlg; + int64_t commitID; + int32_t szPage; + int64_t compactVersion; + int64_t now; + SBuffer buffers[10]; TFileSetArray* fsetArr; TFileOpArray fopArr[1]; @@ -632,7 +632,7 @@ static int32_t tsdbSnapWriteFileSetOpenReader(STsdbSnapWriter* writer) { // open data reader SDataFileReaderConfig dataFileReaderConfig = { .tsdb = writer->tsdb, - .bufArr = writer->aBuf, + .buffers = writer->buffers, .szPage = writer->szPage, }; @@ -666,7 +666,7 @@ static int32_t tsdbSnapWriteFileSetOpenReader(STsdbSnapWriter* writer) { SSttFileReaderConfig sttFileReaderConfig = { .tsdb = writer->tsdb, .szPage = writer->szPage, - .bufArr = writer->aBuf, + .buffers = writer->buffers, .file = fobj->f[0], }; @@ -939,7 +939,14 @@ static int32_t tsdbSnapWriteTimeSeriesData(STsdbSnapWriter* writer, SSnapDataHdr SBlockData blockData[1] = {0}; - code = tDecmprBlockData(hdr->data, hdr->size - sizeof(*hdr), blockData, writer->aBuf); + SBuffer buffer = { + .capacity = hdr->size, + .data = hdr->data, + .size = hdr->size, + }; + SBufferReader br = BUFFER_READER_INITIALIZER(0, &buffer); + + code = tBlockDataDecompress(&br, blockData, &writer->buffers[0]); TSDB_CHECK_CODE(code, lino, _exit); int32_t fid = tsdbKeyFid(blockData->aTSKEY[0], writer->minutes, writer->precision); @@ -977,15 +984,19 @@ static int32_t tsdbSnapWriteDecmprTombBlock(SSnapDataHdr* hdr, STombBlock* tombB int32_t code = 0; int32_t lino = 0; + tTombBlockClear(tombBlock); + int64_t size = hdr->size; ASSERT(size % TOMB_RECORD_ELEM_NUM == 0); size = size / TOMB_RECORD_ELEM_NUM; - ASSERT(size % sizeof(int64_t) == 0); + tombBlock->numOfRecords = size / sizeof(int64_t); - int64_t* data = (int64_t*)hdr->data; + // int64_t* data = (int64_t*)hdr->data; + uint8_t* data = hdr->data; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - code = TARRAY2_APPEND_BATCH(&tombBlock->dataArr[i], hdr->data + i * size, size / sizeof(int64_t)); + code = tBufferPut(tombBlock->buffers + i, data, size); TSDB_CHECK_CODE(code, lino, _exit); + data += size; } _exit: @@ -1061,7 +1072,8 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, void* pRang writer[0]->compactVersion = INT64_MAX; writer[0]->now = taosGetTimestampMs(); - code = tsdbFSCreateCopyRangedSnapshot(pTsdb->pFS, (TFileSetRangeArray*)pRanges, &writer[0]->fsetArr, writer[0]->fopArr); + code = + tsdbFSCreateCopyRangedSnapshot(pTsdb->pFS, (TFileSetRangeArray*)pRanges, &writer[0]->fsetArr, writer[0]->fopArr); TSDB_CHECK_CODE(code, lino, _exit); _exit: @@ -1127,8 +1139,8 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** writer, int8_t rollback) { TARRAY2_DESTROY(writer[0]->fopArr, NULL); tsdbFSDestroyCopyRangedSnapshot(&writer[0]->fsetArr); - for (int32_t i = 0; i < ARRAY_SIZE(writer[0]->aBuf); ++i) { - tFree(writer[0]->aBuf[i]); + for (int32_t i = 0; i < ARRAY_SIZE(writer[0]->buffers); ++i) { + tBufferDestroy(writer[0]->buffers + i); } taosMemoryFree(writer[0]); diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c index f26c6540df..c8b2cf3adf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -29,7 +29,8 @@ struct SSttFileReader { TSttBlkArray sttBlkArray[1]; TStatisBlkArray statisBlkArray[1]; TTombBlkArray tombBlkArray[1]; - uint8_t *bufArr[5]; + SBuffer local[10]; + SBuffer *buffers; }; // SSttFileReader @@ -41,8 +42,9 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con if (reader[0] == NULL) return TSDB_CODE_OUT_OF_MEMORY; reader[0]->config[0] = config[0]; - if (reader[0]->config->bufArr == NULL) { - reader[0]->config->bufArr = reader[0]->bufArr; + reader[0]->buffers = config->buffers; + if (reader[0]->buffers == NULL) { + reader[0]->buffers = reader[0]->local; } // open file @@ -73,8 +75,8 @@ _exit: int32_t tsdbSttFileReaderClose(SSttFileReader **reader) { if (reader[0]) { - for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->bufArr); ++i) { - tFree(reader[0]->bufArr[i]); + for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->local); ++i) { + tBufferDestroy(reader[0]->local + i); } tsdbCloseFile(&reader[0]->fd); TARRAY2_DESTROY(reader[0]->tombBlkArray, NULL); @@ -175,13 +177,16 @@ int32_t tsdbSttFileReadBlockData(SSttFileReader *reader, const SSttBlk *sttBlk, int32_t code = 0; int32_t lino = 0; - code = tRealloc(&reader->config->bufArr[0], sttBlk->bInfo.szBlock); + SBuffer *buffer0 = reader->buffers + 0; + SBuffer *assist = reader->buffers + 1; + + // load data + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset, sttBlk->bInfo.szBlock, buffer0, 0); TSDB_CHECK_CODE(code, lino, _exit); - code = tsdbReadFile(reader->fd, sttBlk->bInfo.offset, reader->config->bufArr[0], sttBlk->bInfo.szBlock, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tDecmprBlockData(reader->config->bufArr[0], sttBlk->bInfo.szBlock, bData, &reader->config->bufArr[1]); + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); + code = tBlockDataDecompress(&br, bData, assist); TSDB_CHECK_CODE(code, lino, _exit); _exit: @@ -196,115 +201,101 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk * int32_t code = 0; int32_t lino = 0; - TABLEID tbid = {.suid = sttBlk->suid}; - if (tbid.suid == 0) { - tbid.uid = sttBlk->minUid; - } else { - tbid.uid = 0; + SDiskDataHdr hdr; + SBuffer *buffer0 = reader->buffers + 0; + SBuffer *buffer1 = reader->buffers + 1; + SBuffer *assist = reader->buffers + 2; + + // load key part + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset, sttBlk->bInfo.szKey, buffer0, 0); + TSDB_CHECK_CODE(code, lino, _exit); + + // decode header + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); + code = tGetDiskDataHdr(&br, &hdr); + TSDB_CHECK_CODE(code, lino, _exit); + + ASSERT(hdr.delimiter == TSDB_FILE_DLMT); + + // set data container + tBlockDataReset(bData); + bData->suid = hdr.suid; + bData->uid = (sttBlk->suid == 0) ? sttBlk->minUid : 0; + bData->nRow = hdr.nRow; + + // key part + code = tBlockDataDecompressKeyPart(&hdr, &br, bData, assist); + TSDB_CHECK_CODE(code, lino, _exit); + ASSERT(br.offset == buffer0->size); + + bool loadExtra = false; + for (int i = 0; i < ncid; i++) { + if (tBlockDataGetColData(bData, cids[i]) == NULL) { + loadExtra = true; + break; + } } - code = tBlockDataInit(bData, &tbid, pTSchema, cids, ncid); - TSDB_CHECK_CODE(code, lino, _exit); - - // uid + version + tskey - code = tRealloc(&reader->config->bufArr[0], sttBlk->bInfo.szKey); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tsdbReadFile(reader->fd, sttBlk->bInfo.offset, reader->config->bufArr[0], sttBlk->bInfo.szKey, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - // hdr - SDiskDataHdr hdr[1]; - int32_t size = 0; - - size += tGetDiskDataHdr(reader->config->bufArr[0] + size, hdr); - - ASSERT(hdr->delimiter == TSDB_FILE_DLMT); - - bData->nRow = hdr->nRow; - bData->uid = hdr->uid; - - // uid - if (hdr->uid == 0) { - ASSERT(hdr->szUid); - code = tsdbDecmprData(reader->config->bufArr[0] + size, hdr->szUid, TSDB_DATA_TYPE_BIGINT, hdr->cmprAlg, - (uint8_t **)&bData->aUid, sizeof(int64_t) * hdr->nRow, &reader->config->bufArr[1]); - TSDB_CHECK_CODE(code, lino, _exit); - } else { - ASSERT(hdr->szUid == 0); + if (!loadExtra) { + goto _exit; } - size += hdr->szUid; - // version - code = tsdbDecmprData(reader->config->bufArr[0] + size, hdr->szVer, TSDB_DATA_TYPE_BIGINT, hdr->cmprAlg, - (uint8_t **)&bData->aVersion, sizeof(int64_t) * hdr->nRow, &reader->config->bufArr[1]); + // load SBlockCol part + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey, hdr.szBlkCol, buffer0, 0); TSDB_CHECK_CODE(code, lino, _exit); - size += hdr->szVer; - // ts - code = tsdbDecmprData(reader->config->bufArr[0] + size, hdr->szKey, TSDB_DATA_TYPE_TIMESTAMP, hdr->cmprAlg, - (uint8_t **)&bData->aTSKEY, sizeof(TSKEY) * hdr->nRow, &reader->config->bufArr[1]); - TSDB_CHECK_CODE(code, lino, _exit); - size += hdr->szKey; + // load each column + SBlockCol blockCol = { + .cid = 0, + }; + br = BUFFER_READER_INITIALIZER(0, buffer0); + for (int32_t i = 0; i < ncid; i++) { + int16_t cid = cids[i]; - ASSERT(size == sttBlk->bInfo.szKey); + if (tBlockDataGetColData(bData, cid)) { // already loaded + continue; + } - // other columns - if (bData->nColData > 0) { - if (hdr->szBlkCol > 0) { - code = tRealloc(&reader->config->bufArr[0], hdr->szBlkCol); - TSDB_CHECK_CODE(code, lino, _exit); + while (cid > blockCol.cid) { + if (br.offset >= buffer0->size) { + blockCol.cid = INT16_MAX; + break; + } - code = tsdbReadFile(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey, reader->config->bufArr[0], - hdr->szBlkCol, 0); + code = tGetBlockCol(&br, &blockCol); TSDB_CHECK_CODE(code, lino, _exit); } - SBlockCol bc[1] = {{.cid = 0}}; - SBlockCol *blockCol = bc; + if (cid < blockCol.cid) { + const STColumn *tcol = tTSchemaSearchColumn(pTSchema, cid); + ASSERT(tcol); + SBlockCol none = { + .cid = cid, + .type = tcol->type, + .cflag = tcol->flags, + .flag = HAS_NONE, + .szOrigin = 0, + .szBitmap = 0, + .szOffset = 0, + .szValue = 0, + .offset = 0, + }; + code = tBlockDataDecompressColData(&hdr, &none, &br, bData, assist); + TSDB_CHECK_CODE(code, lino, _exit); + } else if (cid == blockCol.cid) { + // load from file + tBufferClear(buffer1); + code = + tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey + hdr.szBlkCol + blockCol.offset, + blockCol.szBitmap + blockCol.szOffset + blockCol.szValue, buffer1, 0); + TSDB_CHECK_CODE(code, lino, _exit); - size = 0; - for (int32_t i = 0; i < bData->nColData; i++) { - SColData *colData = tBlockDataGetColDataByIdx(bData, i); - - while (blockCol && blockCol->cid < colData->cid) { - if (size < hdr->szBlkCol) { - size += tGetBlockCol(reader->config->bufArr[0] + size, blockCol); - } else { - ASSERT(size == hdr->szBlkCol); - blockCol = NULL; - } - } - - if (blockCol == NULL || blockCol->cid > colData->cid) { - for (int32_t iRow = 0; iRow < hdr->nRow; iRow++) { - code = tColDataAppendValue(colData, &COL_VAL_NONE(colData->cid, colData->type)); - TSDB_CHECK_CODE(code, lino, _exit); - } - } else { - ASSERT(blockCol->type == colData->type); - ASSERT(blockCol->flag && blockCol->flag != HAS_NONE); - - if (blockCol->flag == HAS_NULL) { - for (int32_t iRow = 0; iRow < hdr->nRow; iRow++) { - code = tColDataAppendValue(colData, &COL_VAL_NULL(blockCol->cid, blockCol->type)); - TSDB_CHECK_CODE(code, lino, _exit); - } - } else { - int32_t size1 = blockCol->szBitmap + blockCol->szOffset + blockCol->szValue; - - code = tRealloc(&reader->config->bufArr[1], size1); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tsdbReadFile(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey + hdr->szBlkCol + blockCol->offset, - reader->config->bufArr[1], size1, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tsdbDecmprColData(reader->config->bufArr[1], blockCol, hdr->cmprAlg, hdr->nRow, colData, - &reader->config->bufArr[2]); - TSDB_CHECK_CODE(code, lino, _exit); - } - } + // decode the buffer + SBufferReader br1 = BUFFER_READER_INITIALIZER(0, buffer1); + code = tBlockDataDecompressColData(&hdr, &blockCol, &br1, bData, assist); + TSDB_CHECK_CODE(code, lino, _exit); } } @@ -319,26 +310,32 @@ int32_t tsdbSttFileReadTombBlock(SSttFileReader *reader, const STombBlk *tombBlk int32_t code = 0; int32_t lino = 0; - code = tRealloc(&reader->config->bufArr[0], tombBlk->dp->size); + SBuffer *buffer0 = reader->buffers + 0; + SBuffer *assist = reader->buffers + 1; + + // load + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd, tombBlk->dp->offset, tombBlk->dp->size, buffer0, 0); TSDB_CHECK_CODE(code, lino, _exit); - code = tsdbReadFile(reader->fd, tombBlk->dp->offset, reader->config->bufArr[0], tombBlk->dp->size, 0); - if (code) TSDB_CHECK_CODE(code, lino, _exit); - - int64_t size = 0; + // decode + int32_t size = 0; + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); tTombBlockClear(tombBlock); - for (int32_t i = 0; i < ARRAY_SIZE(tombBlock->dataArr); ++i) { - code = tsdbDecmprData(reader->config->bufArr[0] + size, tombBlk->size[i], TSDB_DATA_TYPE_BIGINT, tombBlk->cmprAlg, - &reader->config->bufArr[1], sizeof(int64_t) * tombBlk->numRec, &reader->config->bufArr[2]); + tombBlock->numOfRecords = tombBlk->numRec; + for (int32_t i = 0; i < ARRAY_SIZE(tombBlock->buffers); ++i) { + SCompressInfo cinfo = { + .cmprAlg = tombBlk->cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .originalSize = tombBlk->numRec * sizeof(int64_t), + .compressedSize = tombBlk->size[i], + }; + code = tDecompressDataToBuffer(BR_PTR(&br), &cinfo, tombBlock->buffers + i, assist); TSDB_CHECK_CODE(code, lino, _exit); - - code = TARRAY2_APPEND_BATCH(&tombBlock->dataArr[i], reader->config->bufArr[1], tombBlk->numRec); - TSDB_CHECK_CODE(code, lino, _exit); - - size += tombBlk->size[i]; + br.offset += tombBlk->size[i]; } - ASSERT(size == tombBlk->dp->size); + ASSERT(br.offset == tombBlk->dp->size); _exit: if (code) { TSDB_ERROR_LOG(TD_VID(reader->config->tsdb->pVnode), lino, code); @@ -350,27 +347,62 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta int32_t code = 0; int32_t lino = 0; - code = tRealloc(&reader->config->bufArr[0], statisBlk->dp->size); + SBuffer *buffer0 = reader->buffers + 0; + SBuffer *assist = reader->buffers + 1; + + // load data + tBufferClear(buffer0); + code = tsdbReadFileToBuffer(reader->fd, statisBlk->dp->offset, statisBlk->dp->size, buffer0, 0); TSDB_CHECK_CODE(code, lino, _exit); - code = tsdbReadFile(reader->fd, statisBlk->dp->offset, reader->config->bufArr[0], statisBlk->dp->size, 0); - TSDB_CHECK_CODE(code, lino, _exit); - - int64_t size = 0; + // decode data tStatisBlockClear(statisBlock); - for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->dataArr); ++i) { - code = - tsdbDecmprData(reader->config->bufArr[0] + size, statisBlk->size[i], TSDB_DATA_TYPE_BIGINT, statisBlk->cmprAlg, - &reader->config->bufArr[1], sizeof(int64_t) * statisBlk->numRec, &reader->config->bufArr[2]); - TSDB_CHECK_CODE(code, lino, _exit); + statisBlock->numOfPKs = statisBlk->numOfPKs; + statisBlock->numOfRecords = statisBlk->numRec; + SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); + for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { + SCompressInfo info = { + .dataType = TSDB_DATA_TYPE_BIGINT, + .cmprAlg = statisBlk->cmprAlg, + .compressedSize = statisBlk->size[i], + .originalSize = statisBlk->numRec * sizeof(int64_t), + }; - code = TARRAY2_APPEND_BATCH(statisBlock->dataArr + i, reader->config->bufArr[1], statisBlk->numRec); + code = tDecompressDataToBuffer(BR_PTR(&br), &info, &statisBlock->buffers[i], assist); TSDB_CHECK_CODE(code, lino, _exit); - - size += statisBlk->size[i]; + br.offset += statisBlk->size[i]; } - ASSERT(size == statisBlk->dp->size); + if (statisBlk->numOfPKs > 0) { + SValueColumnCompressInfo firstKeyInfos[TD_MAX_PK_COLS]; + SValueColumnCompressInfo lastKeyInfos[TD_MAX_PK_COLS]; + + // decode compress info + for (int32_t i = 0; i < statisBlk->numOfPKs; i++) { + code = tValueColumnCompressInfoDecode(&br, &firstKeyInfos[i]); + TSDB_CHECK_CODE(code, lino, _exit); + } + + for (int32_t i = 0; i < statisBlk->numOfPKs; i++) { + code = tValueColumnCompressInfoDecode(&br, &lastKeyInfos[i]); + TSDB_CHECK_CODE(code, lino, _exit); + } + + // decode value columns + for (int32_t i = 0; i < statisBlk->numOfPKs; i++) { + code = tValueColumnDecompress(BR_PTR(&br), firstKeyInfos + i, &statisBlock->firstKeyPKs[i], assist); + TSDB_CHECK_CODE(code, lino, _exit); + br.offset += (firstKeyInfos[i].dataCompressedSize + firstKeyInfos[i].offsetCompressedSize); + } + + for (int32_t i = 0; i < statisBlk->numOfPKs; i++) { + code = tValueColumnDecompress(BR_PTR(&br), &lastKeyInfos[i], &statisBlock->lastKeyPKs[i], assist); + TSDB_CHECK_CODE(code, lino, _exit); + br.offset += (lastKeyInfos[i].dataCompressedSize + lastKeyInfos[i].offsetCompressedSize); + } + } + + ASSERT(br.offset == buffer0->size); _exit: if (code) { @@ -402,11 +434,12 @@ struct SSttFileWriter { // helper data SSkmInfo skmTb[1]; SSkmInfo skmRow[1]; - uint8_t *bufArr[5]; + SBuffer local[10]; + SBuffer *buffers; }; static int32_t tsdbFileDoWriteSttBlockData(STsdbFD *fd, SBlockData *blockData, int8_t cmprAlg, int64_t *fileSize, - TSttBlkArray *sttBlkArray, uint8_t **bufArr, SVersionRange *range) { + TSttBlkArray *sttBlkArray, SBuffer *buffers, SVersionRange *range) { if (blockData->nRow == 0) return 0; int32_t code = 0; @@ -431,19 +464,17 @@ static int32_t tsdbFileDoWriteSttBlockData(STsdbFD *fd, SBlockData *blockData, i tsdbWriterUpdVerRange(range, sttBlk->minVer, sttBlk->maxVer); - int32_t sizeArr[5] = {0}; - code = tCmprBlockData(blockData, cmprAlg, NULL, NULL, bufArr, sizeArr); + code = tBlockDataCompress(blockData, cmprAlg, buffers, buffers + 4); if (code) return code; - sttBlk->bInfo.offset = *fileSize; - sttBlk->bInfo.szKey = sizeArr[2] + sizeArr[3]; - sttBlk->bInfo.szBlock = sizeArr[0] + sizeArr[1] + sttBlk->bInfo.szKey; + sttBlk->bInfo.szKey = buffers[0].size + buffers[1].size; + sttBlk->bInfo.szBlock = buffers[2].size + buffers[3].size + sttBlk->bInfo.szKey; - for (int32_t i = 3; i >= 0; i--) { - if (sizeArr[i]) { - code = tsdbWriteFile(fd, *fileSize, bufArr[i], sizeArr[i]); + for (int i = 0; i < 4; i++) { + if (buffers[i].size) { + code = tsdbWriteFile(fd, *fileSize, buffers[i].data, buffers[i].size); if (code) return code; - *fileSize += sizeArr[i]; + *fileSize += buffers[i].size; } } @@ -462,7 +493,7 @@ static int32_t tsdbSttFileDoWriteBlockData(SSttFileWriter *writer) { int32_t lino = 0; code = tsdbFileDoWriteSttBlockData(writer->fd, writer->blockData, writer->config->cmprAlg, &writer->file->size, - writer->sttBlkArray, writer->config->bufArr, &writer->ctx->range); + writer->sttBlkArray, writer->buffers, &writer->ctx->range); TSDB_CHECK_CODE(code, lino, _exit); _exit: @@ -473,45 +504,86 @@ _exit: } static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) { - if (STATIS_BLOCK_SIZE(writer->staticBlock) == 0) return 0; + if (writer->staticBlock->numOfRecords == 0) return 0; int32_t code = 0; int32_t lino = 0; - SStatisBlk statisBlk[1] = {{ - .dp[0] = - { - .offset = writer->file->size, - .size = 0, - }, - .minTbid = - { - .suid = TARRAY2_FIRST(writer->staticBlock->suid), - .uid = TARRAY2_FIRST(writer->staticBlock->uid), - }, - .maxTbid = - { - .suid = TARRAY2_LAST(writer->staticBlock->suid), - .uid = TARRAY2_LAST(writer->staticBlock->uid), - }, - .numRec = STATIS_BLOCK_SIZE(writer->staticBlock), - .cmprAlg = writer->config->cmprAlg, - }}; + SBuffer *buffer0 = writer->buffers + 0; + SBuffer *buffer1 = writer->buffers + 1; + SBuffer *assist = writer->buffers + 2; - for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; i++) { - code = tsdbCmprData((uint8_t *)TARRAY2_DATA(writer->staticBlock->dataArr + i), - TARRAY2_DATA_LEN(&writer->staticBlock->dataArr[i]), TSDB_DATA_TYPE_BIGINT, statisBlk->cmprAlg, - &writer->config->bufArr[0], 0, &statisBlk->size[i], &writer->config->bufArr[1]); + STbStatisRecord record; + STbStatisBlock *statisBlock = writer->staticBlock; + SStatisBlk statisBlk = {0}; + + statisBlk.dp->offset = writer->file->size; + statisBlk.dp->size = 0; + statisBlk.numRec = statisBlock->numOfRecords; + statisBlk.cmprAlg = writer->config->cmprAlg; + statisBlk.numOfPKs = statisBlock->numOfPKs; + + tStatisBlockGet(statisBlock, 0, &record); + statisBlk.minTbid.suid = record.suid; + statisBlk.minTbid.uid = record.uid; + + tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record); + statisBlk.maxTbid.suid = record.suid; + statisBlk.maxTbid.uid = record.uid; + + // compress each column + for (int32_t i = 0; i < ARRAY_SIZE(statisBlk.size); i++) { + SCompressInfo info = { + .dataType = TSDB_DATA_TYPE_BIGINT, + .cmprAlg = statisBlk.cmprAlg, + .originalSize = statisBlock->buffers[i].size, + }; + + tBufferClear(buffer0); + code = tCompressDataToBuffer(statisBlock->buffers[i].data, &info, buffer0, assist); TSDB_CHECK_CODE(code, lino, _exit); - code = tsdbWriteFile(writer->fd, writer->file->size, writer->config->bufArr[0], statisBlk->size[i]); + code = tsdbWriteFile(writer->fd, writer->file->size, buffer0->data, info.compressedSize); TSDB_CHECK_CODE(code, lino, _exit); - statisBlk->dp->size += statisBlk->size[i]; - writer->file->size += statisBlk->size[i]; + statisBlk.size[i] = info.compressedSize; + statisBlk.dp->size += info.compressedSize; + writer->file->size += info.compressedSize; } - code = TARRAY2_APPEND_PTR(writer->statisBlkArray, statisBlk); + // compress primary keys + if (statisBlk.numOfPKs > 0) { + SValueColumnCompressInfo compressInfo = {.cmprAlg = statisBlk.cmprAlg}; + + tBufferClear(buffer0); + tBufferClear(buffer0); + + for (int32_t i = 0; i < statisBlk.numOfPKs; i++) { + code = tValueColumnCompress(&statisBlock->firstKeyPKs[i], &compressInfo, buffer1, assist); + TSDB_CHECK_CODE(code, lino, _exit); + code = tValueColumnCompressInfoEncode(&compressInfo, buffer0); + TSDB_CHECK_CODE(code, lino, _exit); + } + + for (int32_t i = 0; i < statisBlk.numOfPKs; i++) { + code = tValueColumnCompress(&statisBlock->lastKeyPKs[i], &compressInfo, buffer1, assist); + TSDB_CHECK_CODE(code, lino, _exit); + code = tValueColumnCompressInfoEncode(&compressInfo, buffer0); + TSDB_CHECK_CODE(code, lino, _exit); + } + + code = tsdbWriteFile(writer->fd, writer->file->size, buffer0->data, buffer0->size); + TSDB_CHECK_CODE(code, lino, _exit); + writer->file->size += buffer0->size; + statisBlk.dp->size += buffer0->size; + + code = tsdbWriteFile(writer->fd, writer->file->size, buffer1->data, buffer1->size); + TSDB_CHECK_CODE(code, lino, _exit); + writer->file->size += buffer1->size; + statisBlk.dp->size += buffer1->size; + } + + code = TARRAY2_APPEND_PTR(writer->statisBlkArray, &statisBlk); TSDB_CHECK_CODE(code, lino, _exit); tStatisBlockClear(writer->staticBlock); @@ -530,7 +602,7 @@ static int32_t tsdbSttFileDoWriteTombBlock(SSttFileWriter *writer) { int32_t lino = 0; code = tsdbFileWriteTombBlock(writer->fd, writer->tombBlock, writer->config->cmprAlg, &writer->file->size, - writer->tombBlkArray, writer->config->bufArr, &writer->ctx->range); + writer->tombBlkArray, writer->buffers, &writer->ctx->range); TSDB_CHECK_CODE(code, lino, _exit); _exit: @@ -621,7 +693,10 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) { // set if (!writer->config->skmTb) writer->config->skmTb = writer->skmTb; if (!writer->config->skmRow) writer->config->skmRow = writer->skmRow; - if (!writer->config->bufArr) writer->config->bufArr = writer->bufArr; + writer->buffers = writer->config->buffers; + if (writer->buffers == NULL) { + writer->buffers = writer->local; + } writer->file[0] = (STFile){ .type = TSDB_FTYPE_STT, @@ -665,8 +740,8 @@ _exit: static void tsdbSttFWriterDoClose(SSttFileWriter *writer) { ASSERT(writer->fd == NULL); - for (int32_t i = 0; i < ARRAY_SIZE(writer->bufArr); ++i) { - tFree(writer->bufArr[i]); + for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) { + tBufferDestroy(writer->local + i); } tDestroyTSchema(writer->skmRow->pTSchema); tDestroyTSchema(writer->skmTb->pTSchema); @@ -796,40 +871,24 @@ int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row) { TSDB_CHECK_CODE(code, lino, _exit); } - TSDBKEY key[1]; - if (row->row.type == TSDBROW_ROW_FMT) { - key->ts = row->row.pTSRow->ts; - key->version = row->row.version; - } else { - key->ts = row->row.pBlockData->aTSKEY[row->row.iRow]; - key->version = row->row.pBlockData->aVersion[row->row.iRow]; - } - if (writer->ctx->tbid->uid != row->uid) { writer->ctx->tbid->suid = row->suid; writer->ctx->tbid->uid = row->uid; + } - if (STATIS_BLOCK_SIZE(writer->staticBlock) >= writer->config->maxRow) { + STsdbRowKey key; + tsdbRowGetKey(&row->row, &key); + + for (;;) { + code = tStatisBlockPut(writer->staticBlock, row, writer->config->maxRow); + if (code == TSDB_CODE_INVALID_PARA) { code = tsdbSttFileDoWriteStatisBlock(writer); TSDB_CHECK_CODE(code, lino, _exit); + continue; + } else { + TSDB_CHECK_CODE(code, lino, _exit); } - - STbStatisRecord record = { - .suid = row->suid, - .uid = row->uid, - .firstKey = key->ts, - .lastKey = key->ts, - .count = 1, - }; - code = tStatisBlockPut(writer->staticBlock, &record); - TSDB_CHECK_CODE(code, lino, _exit); - } else { - ASSERT(key->ts >= TARRAY2_LAST(writer->staticBlock->lastKey)); - - if (key->ts > TARRAY2_LAST(writer->staticBlock->lastKey)) { - TARRAY2_LAST(writer->staticBlock->count)++; - TARRAY2_LAST(writer->staticBlock->lastKey) = key->ts; - } + break; } if (row->row.type == TSDBROW_ROW_FMT) { @@ -839,12 +898,13 @@ int32_t tsdbSttFileWriteRow(SSttFileWriter *writer, SRowInfo *row) { } // row to col conversion - if (key->version <= writer->config->compactVersion // + if (key.version <= writer->config->compactVersion // && writer->blockData->nRow > 0 // - && writer->blockData->aTSKEY[writer->blockData->nRow - 1] == key->ts // && (writer->blockData->uid // ? writer->blockData->uid // : writer->blockData->aUid[writer->blockData->nRow - 1]) == row->uid // + && tsdbRowCompareWithoutVersion(&row->row, + &tsdbRowFromBlockData(writer->blockData, writer->blockData->nRow - 1)) == 0 // ) { code = tBlockDataUpdateRow(writer->blockData, &row->row, writer->config->skmRow->pTSchema); TSDB_CHECK_CODE(code, lino, _exit); diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h index 0051a6cd92..066e0c3498 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h @@ -54,10 +54,10 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta int32_t tsdbSttFileReadTombBlock(SSttFileReader *reader, const STombBlk *delBlk, STombBlock *dData); struct SSttFileReaderConfig { - STsdb *tsdb; - int32_t szPage; - STFile file[1]; - uint8_t **bufArr; + STsdb *tsdb; + int32_t szPage; + STFile file[1]; + SBuffer *buffers; }; // SSttFileWriter ========================================== @@ -86,7 +86,7 @@ struct SSttFileWriterConfig { int32_t level; SSkmInfo *skmTb; SSkmInfo *skmRow; - uint8_t **bufArr; + SBuffer *buffers; }; #ifdef __cplusplus diff --git a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c index 876c0df4a0..b8f8e14b21 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c +++ b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c @@ -33,10 +33,10 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader * // init struct { // config - int32_t maxRow; - int8_t cmprAlg; - int32_t szPage; - uint8_t *bufArr[8]; + int32_t maxRow; + int8_t cmprAlg; + int32_t szPage; + SBuffer buffers[10]; // reader SArray *aBlockIdx; SMapData mDataBlk[1]; @@ -97,10 +97,24 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader * SBrinRecord record = { .suid = pBlockIdx->suid, .uid = pBlockIdx->uid, - .firstKey = dataBlk->minKey.ts, - .firstKeyVer = dataBlk->minKey.version, - .lastKey = dataBlk->maxKey.ts, - .lastKeyVer = dataBlk->maxKey.version, + .firstKey = + (STsdbRowKey){ + .key = + (SRowKey){ + .ts = dataBlk->minKey.ts, + .numOfPKs = 0, + }, + .version = dataBlk->minKey.version, + }, + .lastKey = + (STsdbRowKey){ + .key = + (SRowKey){ + .ts = dataBlk->maxKey.ts, + .numOfPKs = 0, + }, + .version = dataBlk->maxKey.version, + }, .minVer = dataBlk->minVer, .maxVer = dataBlk->maxVer, .blockOffset = dataBlk->aSubBlock->offset, @@ -119,19 +133,19 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader * code = tBrinBlockPut(ctx->brinBlock, &record); TSDB_CHECK_CODE(code, lino, _exit); - if (BRIN_BLOCK_SIZE(ctx->brinBlock) >= ctx->maxRow) { + if (ctx->brinBlock->numOfRecords >= ctx->maxRow) { SVersionRange range = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN}; code = tsdbFileWriteBrinBlock(ctx->fd, ctx->brinBlock, ctx->cmprAlg, &fset->farr[TSDB_FTYPE_HEAD]->f->size, - ctx->brinBlkArray, ctx->bufArr, &range); + ctx->brinBlkArray, ctx->buffers, &range); TSDB_CHECK_CODE(code, lino, _exit); } } } - if (BRIN_BLOCK_SIZE(ctx->brinBlock) > 0) { + if (ctx->brinBlock->numOfRecords > 0) { SVersionRange range = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN}; code = tsdbFileWriteBrinBlock(ctx->fd, ctx->brinBlock, ctx->cmprAlg, &fset->farr[TSDB_FTYPE_HEAD]->f->size, - ctx->brinBlkArray, ctx->bufArr, &range); + ctx->brinBlkArray, ctx->buffers, &range); TSDB_CHECK_CODE(code, lino, _exit); } @@ -157,8 +171,8 @@ _exit: tBlockDataDestroy(ctx->blockData); tMapDataClear(ctx->mDataBlk); taosArrayDestroy(ctx->aBlockIdx); - for (int32_t i = 0; i < ARRAY_SIZE(ctx->bufArr); ++i) { - tFree(ctx->bufArr[i]); + for (int32_t i = 0; i < ARRAY_SIZE(ctx->buffers); ++i) { + tBufferDestroy(ctx->buffers + i); } return code; } @@ -434,12 +448,12 @@ static int32_t tsdbDumpTombDataToFSet(STsdb *tsdb, SDelFReader *reader, SArray * struct { // context - bool toStt; - int8_t cmprAlg; - int32_t maxRow; - int64_t minKey; - int64_t maxKey; - uint8_t *bufArr[8]; + bool toStt; + int8_t cmprAlg; + int32_t maxRow; + int64_t minKey; + int64_t maxKey; + SBuffer buffers[10]; // reader SArray *aDelData; // writer @@ -488,7 +502,7 @@ static int32_t tsdbDumpTombDataToFSet(STsdb *tsdb, SDelFReader *reader, SArray * } SVersionRange tombRange = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN}; code = tsdbFileWriteTombBlock(ctx->fd, ctx->tombBlock, ctx->cmprAlg, &ctx->fobj->f->size, ctx->tombBlkArray, - ctx->bufArr, &tombRange); + ctx->buffers, &tombRange); TSDB_CHECK_CODE(code, lino, _exit); } } @@ -501,7 +515,7 @@ static int32_t tsdbDumpTombDataToFSet(STsdb *tsdb, SDelFReader *reader, SArray * } SVersionRange tombRange = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN}; code = tsdbFileWriteTombBlock(ctx->fd, ctx->tombBlock, ctx->cmprAlg, &ctx->fobj->f->size, ctx->tombBlkArray, - ctx->bufArr, &tombRange); + ctx->buffers, &tombRange); TSDB_CHECK_CODE(code, lino, _exit); } @@ -530,8 +544,8 @@ _exit: if (code) { TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code); } - for (int32_t i = 0; i < ARRAY_SIZE(ctx->bufArr); i++) { - tFree(ctx->bufArr[i]); + for (int32_t i = 0; i < ARRAY_SIZE(ctx->buffers); i++) { + tBufferDestroy(ctx->buffers + i); } TARRAY2_DESTROY(ctx->tombBlkArray, NULL); tTombBlockDestroy(ctx->tombBlock); diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 44621bf4e6..f708700b1a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -16,6 +16,8 @@ #include "tdataformat.h" #include "tsdb.h" +static int32_t tBlockDataCompressKeyPart(SBlockData *bData, SDiskDataHdr *hdr, SBuffer *buffer, SBuffer *assist); + // SMapData ======================================================================= void tMapDataReset(SMapData *pMapData) { pMapData->nItem = 0; @@ -380,47 +382,44 @@ int32_t tGetSttBlk(uint8_t *p, void *ph) { } // SBlockCol ====================================================== -int32_t tPutBlockCol(uint8_t *p, void *ph) { - int32_t n = 0; - SBlockCol *pBlockCol = (SBlockCol *)ph; +int32_t tPutBlockCol(SBuffer *buffer, const SBlockCol *pBlockCol) { + int32_t code; ASSERT(pBlockCol->flag && (pBlockCol->flag != HAS_NONE)); - n += tPutI16v(p ? p + n : p, pBlockCol->cid); - n += tPutI8(p ? p + n : p, pBlockCol->type); - n += tPutI8(p ? p + n : p, pBlockCol->smaOn); - n += tPutI8(p ? p + n : p, pBlockCol->flag); - n += tPutI32v(p ? p + n : p, pBlockCol->szOrigin); + if ((code = tBufferPutI16v(buffer, pBlockCol->cid))) return code; + if ((code = tBufferPutI8(buffer, pBlockCol->type))) return code; + if ((code = tBufferPutI8(buffer, pBlockCol->cflag))) return code; + if ((code = tBufferPutI8(buffer, pBlockCol->flag))) return code; + if ((code = tBufferPutI32v(buffer, pBlockCol->szOrigin))) return code; if (pBlockCol->flag != HAS_NULL) { if (pBlockCol->flag != HAS_VALUE) { - n += tPutI32v(p ? p + n : p, pBlockCol->szBitmap); + if ((code = tBufferPutI32v(buffer, pBlockCol->szBitmap))) return code; } if (IS_VAR_DATA_TYPE(pBlockCol->type)) { - n += tPutI32v(p ? p + n : p, pBlockCol->szOffset); + if ((code = tBufferPutI32v(buffer, pBlockCol->szOffset))) return code; } if (pBlockCol->flag != (HAS_NULL | HAS_NONE)) { - n += tPutI32v(p ? p + n : p, pBlockCol->szValue); + if ((code = tBufferPutI32v(buffer, pBlockCol->szValue))) return code; } - n += tPutI32v(p ? p + n : p, pBlockCol->offset); + if ((code = tBufferPutI32v(buffer, pBlockCol->offset))) return code; } -_exit: - return n; + return 0; } -int32_t tGetBlockCol(uint8_t *p, void *ph) { - int32_t n = 0; - SBlockCol *pBlockCol = (SBlockCol *)ph; +int32_t tGetBlockCol(SBufferReader *br, SBlockCol *pBlockCol) { + int32_t code; - n += tGetI16v(p + n, &pBlockCol->cid); - n += tGetI8(p + n, &pBlockCol->type); - n += tGetI8(p + n, &pBlockCol->smaOn); - n += tGetI8(p + n, &pBlockCol->flag); - n += tGetI32v(p + n, &pBlockCol->szOrigin); + if ((code = tBufferGetI16v(br, &pBlockCol->cid))) return code; + if ((code = tBufferGetI8(br, &pBlockCol->type))) return code; + if ((code = tBufferGetI8(br, &pBlockCol->cflag))) return code; + if ((code = tBufferGetI8(br, &pBlockCol->flag))) return code; + if ((code = tBufferGetI32v(br, &pBlockCol->szOrigin))) return code; ASSERT(pBlockCol->flag && (pBlockCol->flag != HAS_NONE)); @@ -431,21 +430,21 @@ int32_t tGetBlockCol(uint8_t *p, void *ph) { if (pBlockCol->flag != HAS_NULL) { if (pBlockCol->flag != HAS_VALUE) { - n += tGetI32v(p + n, &pBlockCol->szBitmap); + if ((code = tBufferGetI32v(br, &pBlockCol->szBitmap))) return code; } if (IS_VAR_DATA_TYPE(pBlockCol->type)) { - n += tGetI32v(p + n, &pBlockCol->szOffset); + if ((code = tBufferGetI32v(br, &pBlockCol->szOffset))) return code; } if (pBlockCol->flag != (HAS_NULL | HAS_NONE)) { - n += tGetI32v(p + n, &pBlockCol->szValue); + if ((code = tBufferGetI32v(br, &pBlockCol->szValue))) return code; } - n += tGetI32v(p + n, &pBlockCol->offset); + if ((code = tBufferGetI32v(br, &pBlockCol->offset))) return code; } - return n; + return 0; } #ifdef BUILD_NO_CALL @@ -589,9 +588,7 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal * if (pRow->type == TSDBROW_ROW_FMT) { tRowGet(pRow->pTSRow, pTSchema, iCol, pColVal); } else if (pRow->type == TSDBROW_COL_FMT) { - SColData *pColData; - - tBlockDataGetColData(pRow->pBlockData, pTColumn->colId, &pColData); + SColData *pColData = tBlockDataGetColData(pRow->pBlockData, pTColumn->colId); if (pColData) { tColDataGetValue(pColData, pRow->iRow, pColVal); @@ -603,8 +600,58 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal * } } -int32_t tsdbRowCmprFn(const void *p1, const void *p2) { - return tsdbKeyCmprFn(&TSDBROW_KEY((TSDBROW *)p1), &TSDBROW_KEY((TSDBROW *)p2)); +void tsdbRowGetKey(TSDBROW *row, STsdbRowKey *key) { + if (row->type == TSDBROW_ROW_FMT) { + key->version = row->version; + tRowGetKey(row->pTSRow, &key->key); + } else { + key->version = row->pBlockData->aVersion[row->iRow]; + key->key.ts = row->pBlockData->aTSKEY[row->iRow]; + key->key.numOfPKs = 0; + for (int32_t i = 0; i < row->pBlockData->nColData; i++) { + SColData *pColData = &row->pBlockData->aColData[i]; + if (pColData->cflag & COL_IS_KEY) { + SColVal cv; + tColDataGetValue(pColData, row->iRow, &cv); + ASSERT(COL_VAL_IS_VALUE(&cv)); + key->key.pks[key->key.numOfPKs] = cv.value; + key->key.numOfPKs++; + } else { + break; + } + } + } +} + +int32_t tsdbRowKeyCmpr(const STsdbRowKey *key1, const STsdbRowKey *key2) { + int32_t c = tRowKeyCompare(&key1->key, &key2->key); + + if (c) { + return c; + } + + if (key1->version < key2->version) { + return -1; + } else if (key1->version > key2->version) { + return 1; + } + return 0; +} + +int32_t tsdbRowCompare(const void *p1, const void *p2) { + STsdbRowKey key1, key2; + + tsdbRowGetKey((TSDBROW *)p1, &key1); + tsdbRowGetKey((TSDBROW *)p2, &key2); + return tsdbRowKeyCmpr(&key1, &key2); +} + +int32_t tsdbRowCompareWithoutVersion(const void *p1, const void *p2) { + STsdbRowKey key1, key2; + + tsdbRowGetKey((TSDBROW *)p1, &key1); + tsdbRowGetKey((TSDBROW *)p2, &key2); + return tRowKeyCompare(&key1.key, &key2.key); } // STSDBRowIter ====================================================== @@ -636,8 +683,9 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) { return tRowIterNext(pIter->pIter); } else if (pIter->pRow->type == TSDBROW_COL_FMT) { if (pIter->iColData == 0) { - pIter->cv = COL_VAL_VALUE(PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP, - (SValue){.val = pIter->pRow->pBlockData->aTSKEY[pIter->pRow->iRow]}); + pIter->cv = COL_VAL_VALUE( + PRIMARYKEY_TIMESTAMP_COL_ID, + ((SValue){.type = TSDB_DATA_TYPE_TIMESTAMP, .val = pIter->pRow->pBlockData->aTSKEY[pIter->pRow->iRow]})); ++pIter->iColData; return &pIter->cv; } @@ -674,7 +722,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) ASSERT(pTColumn->type == TSDB_DATA_TYPE_TIMESTAMP); - *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.val = key.ts}); + *pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = key.ts})); if (taosArrayPush(pMerger->pArray, pColVal) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; return code; @@ -694,7 +742,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) } tsdbRowGetColVal(pRow, pTSchema, jCol++, pColVal); - if ((!COL_VAL_IS_NONE(pColVal)) && (!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->type)) { + if ((!COL_VAL_IS_NONE(pColVal)) && (!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->value.type)) { uint8_t *pVal = pColVal->value.pData; pColVal->value.pData = NULL; @@ -738,7 +786,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) if (key.version > pMerger->version) { if (!COL_VAL_IS_NONE(pColVal)) { - if (IS_VAR_DATA_TYPE(pColVal->type)) { + if (IS_VAR_DATA_TYPE(pColVal->value.type)) { SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol); if (!COL_VAL_IS_NULL(pColVal)) { code = tRealloc(&pTColVal->value.pData, pColVal->value.nData); @@ -760,7 +808,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) } else if (key.version < pMerger->version) { SColVal *tColVal = (SColVal *)taosArrayGet(pMerger->pArray, iCol); if (COL_VAL_IS_NONE(tColVal) && !COL_VAL_IS_NONE(pColVal)) { - if ((!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->type)) { + if ((!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->value.type)) { code = tRealloc(&tColVal->value.pData, pColVal->value.nData); if (code) return code; @@ -796,7 +844,7 @@ int32_t tsdbRowMergerInit(SRowMerger *pMerger, STSchema *pSchema) { void tsdbRowMergerClear(SRowMerger *pMerger) { for (int32_t iCol = 1; iCol < pMerger->pTSchema->numOfCols; iCol++) { SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol); - if (IS_VAR_DATA_TYPE(pTColVal->type)) { + if (IS_VAR_DATA_TYPE(pTColVal->value.type)) { tFree(pTColVal->value.pData); } } @@ -808,7 +856,7 @@ void tsdbRowMergerCleanup(SRowMerger *pMerger) { int32_t numOfCols = taosArrayGetSize(pMerger->pArray); for (int32_t iCol = 1; iCol < numOfCols; iCol++) { SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol); - if (IS_VAR_DATA_TYPE(pTColVal->type)) { + if (IS_VAR_DATA_TYPE(pTColVal->value.type)) { tFree(pTColVal->value.pData); } } @@ -1140,8 +1188,7 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema, continue; } - tColDataInit(&pBlockData->aColData[iCid], pTColumn->colId, pTColumn->type, - (pTColumn->flags & COL_SMA_ON) ? 1 : 0); + tColDataInit(&pBlockData->aColData[iCid], pTColumn->colId, pTColumn->type, pTColumn->flags); iColumn++; pTColumn = (iColumn < pTSchema->numOfCols) ? &pTSchema->columns[iColumn] : NULL; @@ -1152,8 +1199,7 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema, for (int32_t iColData = 0; iColData < pBlockData->nColData; iColData++) { STColumn *pTColumn = &pTSchema->columns[iColData + 1]; - tColDataInit(&pBlockData->aColData[iColData], pTColumn->colId, pTColumn->type, - (pTColumn->flags & COL_SMA_ON) ? 1 : 0); + tColDataInit(&pBlockData->aColData[iColData], pTColumn->colId, pTColumn->type, pTColumn->flags); } } @@ -1181,6 +1227,24 @@ void tBlockDataClear(SBlockData *pBlockData) { } } +int32_t tBlockDataAddColData(SBlockData *pBlockData, int16_t cid, int8_t type, int8_t cflag, SColData **ppColData) { + ASSERT(pBlockData->nColData == 0 || pBlockData->aColData[pBlockData->nColData - 1].cid < cid); + + SColData *newColData = taosMemoryRealloc(pBlockData->aColData, sizeof(SColData) * (pBlockData->nColData + 1)); + if (newColData == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pBlockData->aColData = newColData; + pBlockData->nColData++; + + *ppColData = &pBlockData->aColData[pBlockData->nColData - 1]; + memset(*ppColData, 0, sizeof(SColData)); + tColDataInit(*ppColData, cid, type, cflag); + + return 0; +} + /* flag > 0: forward update * flag == 0: insert * flag < 0: backward update @@ -1303,7 +1367,7 @@ int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS } #endif -void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData) { +SColData *tBlockDataGetColData(SBlockData *pBlockData, int16_t cid) { ASSERT(cid != PRIMARYKEY_TIMESTAMP_COL_ID); int32_t lidx = 0; int32_t ridx = pBlockData->nColData - 1; @@ -1314,8 +1378,7 @@ void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColD int32_t c = (pColData->cid == cid) ? 0 : ((pColData->cid > cid) ? 1 : -1); if (c == 0) { - *ppColData = pColData; - return; + return pColData; } else if (c < 0) { lidx = midx + 1; } else { @@ -1323,170 +1386,112 @@ void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColD } } - *ppColData = NULL; + return NULL; } -int32_t tCmprBlockData(SBlockData *pBlockData, int8_t cmprAlg, uint8_t **ppOut, int32_t *szOut, uint8_t *aBuf[], - int32_t aBufN[]) { +/* buffers[0]: SDiskDataHdr + * buffers[1]: key part: uid + version + ts + primary keys + * buffers[2]: SBlockCol part + * buffers[3]: regular column part + */ +int32_t tBlockDataCompress(SBlockData *bData, int8_t cmprAlg, SBuffer *buffers, SBuffer *assist) { int32_t code = 0; + int32_t lino = 0; - SDiskDataHdr hdr = {.delimiter = TSDB_FILE_DLMT, - .fmtVer = 0, - .suid = pBlockData->suid, - .uid = pBlockData->uid, - .nRow = pBlockData->nRow, - .cmprAlg = cmprAlg}; + SDiskDataHdr hdr = { + .delimiter = TSDB_FILE_DLMT, + .fmtVer = 1, + .suid = bData->suid, + .uid = bData->uid, + .szUid = 0, // filled by compress key + .szVer = 0, // filled by compress key + .szKey = 0, // filled by compress key + .szBlkCol = 0, // filled by this func + .nRow = bData->nRow, + .cmprAlg = cmprAlg, + .numOfPKs = 0, // filled by compress key + }; - // encode ================= - // columns AND SBlockCol - aBufN[0] = 0; - for (int32_t iColData = 0; iColData < pBlockData->nColData; iColData++) { - SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iColData); + // Key part + tBufferClear(&buffers[1]); + code = tBlockDataCompressKeyPart(bData, &hdr, &buffers[1], assist); + TSDB_CHECK_CODE(code, lino, _exit); - ASSERT(pColData->flag); + // Regulart column part + tBufferClear(&buffers[2]); + tBufferClear(&buffers[3]); + for (int i = 0; i < bData->nColData; i++) { + SColData *colData = tBlockDataGetColDataByIdx(bData, i); - if (pColData->flag == HAS_NONE) continue; - - SBlockCol blockCol = {.cid = pColData->cid, - .type = pColData->type, - .smaOn = pColData->smaOn, - .flag = pColData->flag, - .szOrigin = pColData->nData}; - - if (pColData->flag != HAS_NULL) { - code = tsdbCmprColData(pColData, cmprAlg, &blockCol, &aBuf[0], aBufN[0], &aBuf[2]); - if (code) goto _exit; - - blockCol.offset = aBufN[0]; - aBufN[0] = aBufN[0] + blockCol.szBitmap + blockCol.szOffset + blockCol.szValue; + if (colData->cflag & COL_IS_KEY) { + continue; + } + if (colData->flag == HAS_NONE) { + continue; } - code = tRealloc(&aBuf[1], hdr.szBlkCol + tPutBlockCol(NULL, &blockCol)); - if (code) goto _exit; - hdr.szBlkCol += tPutBlockCol(aBuf[1] + hdr.szBlkCol, &blockCol); + SColDataCompressInfo cinfo = { + .cmprAlg = cmprAlg, + }; + int32_t offset = buffers[3].size; + code = tColDataCompress(colData, &cinfo, &buffers[3], assist); + TSDB_CHECK_CODE(code, lino, _exit); + + SBlockCol blockCol = (SBlockCol){ + .cid = cinfo.columnId, + .type = cinfo.dataType, + .cflag = cinfo.columnFlag, + .flag = cinfo.flag, + .szOrigin = cinfo.dataOriginalSize, + .szBitmap = cinfo.bitmapCompressedSize, + .szOffset = cinfo.offsetCompressedSize, + .szValue = cinfo.dataCompressedSize, + .offset = offset, + }; + + code = tPutBlockCol(&buffers[2], &blockCol); + TSDB_CHECK_CODE(code, lino, _exit); } + hdr.szBlkCol = buffers[2].size; - // SBlockCol - aBufN[1] = hdr.szBlkCol; - - // uid + version + tskey - aBufN[2] = 0; - if (pBlockData->uid == 0) { - code = tsdbCmprData((uint8_t *)pBlockData->aUid, sizeof(int64_t) * pBlockData->nRow, TSDB_DATA_TYPE_BIGINT, cmprAlg, - &aBuf[2], aBufN[2], &hdr.szUid, &aBuf[3]); - if (code) goto _exit; - } - aBufN[2] += hdr.szUid; - - code = tsdbCmprData((uint8_t *)pBlockData->aVersion, sizeof(int64_t) * pBlockData->nRow, TSDB_DATA_TYPE_BIGINT, - cmprAlg, &aBuf[2], aBufN[2], &hdr.szVer, &aBuf[3]); - if (code) goto _exit; - aBufN[2] += hdr.szVer; - - code = tsdbCmprData((uint8_t *)pBlockData->aTSKEY, sizeof(TSKEY) * pBlockData->nRow, TSDB_DATA_TYPE_TIMESTAMP, - cmprAlg, &aBuf[2], aBufN[2], &hdr.szKey, &aBuf[3]); - if (code) goto _exit; - aBufN[2] += hdr.szKey; - - // hdr - aBufN[3] = tPutDiskDataHdr(NULL, &hdr); - code = tRealloc(&aBuf[3], aBufN[3]); - if (code) goto _exit; - tPutDiskDataHdr(aBuf[3], &hdr); - - // aggragate - if (ppOut) { - *szOut = aBufN[0] + aBufN[1] + aBufN[2] + aBufN[3]; - code = tRealloc(ppOut, *szOut); - if (code) goto _exit; - - memcpy(*ppOut, aBuf[3], aBufN[3]); - memcpy(*ppOut + aBufN[3], aBuf[2], aBufN[2]); - if (aBufN[1]) { - memcpy(*ppOut + aBufN[3] + aBufN[2], aBuf[1], aBufN[1]); - } - if (aBufN[0]) { - memcpy(*ppOut + aBufN[3] + aBufN[2] + aBufN[1], aBuf[0], aBufN[0]); - } - } + // SDiskDataHdr part + tBufferClear(&buffers[0]); + code = tPutDiskDataHdr(&buffers[0], &hdr); + TSDB_CHECK_CODE(code, lino, _exit); _exit: return code; } -int32_t tDecmprBlockData(uint8_t *pIn, int32_t szIn, SBlockData *pBlockData, uint8_t *aBuf[]) { - int32_t code = 0; - - tBlockDataReset(pBlockData); - - int32_t n = 0; - SDiskDataHdr hdr = {0}; +int32_t tBlockDataDecompress(SBufferReader *br, SBlockData *blockData, SBuffer *assist) { + int32_t code = 0; + int32_t lino = 0; + SDiskDataHdr hdr = {0}; + SCompressInfo cinfo; // SDiskDataHdr - n += tGetDiskDataHdr(pIn + n, &hdr); - ASSERT(hdr.delimiter == TSDB_FILE_DLMT); + code = tGetDiskDataHdr(br, &hdr); + TSDB_CHECK_CODE(code, lino, _exit); - pBlockData->suid = hdr.suid; - pBlockData->uid = hdr.uid; - pBlockData->nRow = hdr.nRow; + tBlockDataReset(blockData); + blockData->suid = hdr.suid; + blockData->uid = hdr.uid; + blockData->nRow = hdr.nRow; - // uid - if (hdr.uid == 0) { - ASSERT(hdr.szUid); - code = tsdbDecmprData(pIn + n, hdr.szUid, TSDB_DATA_TYPE_BIGINT, hdr.cmprAlg, (uint8_t **)&pBlockData->aUid, - sizeof(int64_t) * hdr.nRow, &aBuf[0]); - if (code) goto _exit; - } else { - ASSERT(!hdr.szUid); - } - n += hdr.szUid; + // Key part + code = tBlockDataDecompressKeyPart(&hdr, br, blockData, assist); + TSDB_CHECK_CODE(code, lino, _exit); - // version - code = tsdbDecmprData(pIn + n, hdr.szVer, TSDB_DATA_TYPE_BIGINT, hdr.cmprAlg, (uint8_t **)&pBlockData->aVersion, - sizeof(int64_t) * hdr.nRow, &aBuf[0]); - if (code) goto _exit; - n += hdr.szVer; + // Column part + SBufferReader br2 = *br; + br->offset += hdr.szBlkCol; + for (uint32_t startOffset = br2.offset; br2.offset - startOffset < hdr.szBlkCol;) { + SBlockCol blockCol; - // TSKEY - code = tsdbDecmprData(pIn + n, hdr.szKey, TSDB_DATA_TYPE_TIMESTAMP, hdr.cmprAlg, (uint8_t **)&pBlockData->aTSKEY, - sizeof(TSKEY) * hdr.nRow, &aBuf[0]); - if (code) goto _exit; - n += hdr.szKey; - - // loop to decode each column data - if (hdr.szBlkCol == 0) goto _exit; - - int32_t nColData = 0; - int32_t nt = 0; - while (nt < hdr.szBlkCol) { - SBlockCol blockCol = {0}; - nt += tGetBlockCol(pIn + n + nt, &blockCol); - ++nColData; - } - ASSERT(nt == hdr.szBlkCol); - - code = tBlockDataAdjustColData(pBlockData, nColData); - if (code) goto _exit; - - nt = 0; - int32_t iColData = 0; - while (nt < hdr.szBlkCol) { - SBlockCol blockCol = {0}; - nt += tGetBlockCol(pIn + n + nt, &blockCol); - - SColData *pColData = &pBlockData->aColData[iColData++]; - - tColDataInit(pColData, blockCol.cid, blockCol.type, blockCol.smaOn); - if (blockCol.flag == HAS_NULL) { - for (int32_t iRow = 0; iRow < hdr.nRow; iRow++) { - code = tColDataAppendValue(pColData, &COL_VAL_NULL(blockCol.cid, blockCol.type)); - if (code) goto _exit; - } - } else { - code = tsdbDecmprColData(pIn + n + hdr.szBlkCol + blockCol.offset, &blockCol, hdr.cmprAlg, hdr.nRow, pColData, - &aBuf[0]); - if (code) goto _exit; - } + code = tGetBlockCol(&br2, &blockCol); + TSDB_CHECK_CODE(code, lino, _exit); + code = tBlockDataDecompressColData(&hdr, &blockCol, br, blockData, assist); + TSDB_CHECK_CODE(code, lino, _exit); } _exit: @@ -1494,219 +1499,255 @@ _exit: } // SDiskDataHdr ============================== -int32_t tPutDiskDataHdr(uint8_t *p, const SDiskDataHdr *pHdr) { - int32_t n = 0; +int32_t tPutDiskDataHdr(SBuffer *buffer, const SDiskDataHdr *pHdr) { + int32_t code; - n += tPutU32(p ? p + n : p, pHdr->delimiter); - n += tPutU32v(p ? p + n : p, pHdr->fmtVer); - n += tPutI64(p ? p + n : p, pHdr->suid); - n += tPutI64(p ? p + n : p, pHdr->uid); - n += tPutI32v(p ? p + n : p, pHdr->szUid); - n += tPutI32v(p ? p + n : p, pHdr->szVer); - n += tPutI32v(p ? p + n : p, pHdr->szKey); - n += tPutI32v(p ? p + n : p, pHdr->szBlkCol); - n += tPutI32v(p ? p + n : p, pHdr->nRow); - n += tPutI8(p ? p + n : p, pHdr->cmprAlg); + if ((code = tBufferPutU32(buffer, pHdr->delimiter))) return code; + if ((code = tBufferPutU32v(buffer, pHdr->fmtVer))) return code; + if ((code = tBufferPutI64(buffer, pHdr->suid))) return code; + if ((code = tBufferPutI64(buffer, pHdr->uid))) return code; + if ((code = tBufferPutI32v(buffer, pHdr->szUid))) return code; + if ((code = tBufferPutI32v(buffer, pHdr->szVer))) return code; + if ((code = tBufferPutI32v(buffer, pHdr->szKey))) return code; + if ((code = tBufferPutI32v(buffer, pHdr->szBlkCol))) return code; + if ((code = tBufferPutI32v(buffer, pHdr->nRow))) return code; + if ((code = tBufferPutI8(buffer, pHdr->cmprAlg))) return code; + if (pHdr->fmtVer == 1) { + if ((code = tBufferPutI8(buffer, pHdr->numOfPKs))) return code; + for (int i = 0; i < pHdr->numOfPKs; i++) { + if ((code = tPutBlockCol(buffer, &pHdr->primaryBlockCols[i]))) return code; + } + } - return n; + return 0; } -int32_t tGetDiskDataHdr(uint8_t *p, void *ph) { - int32_t n = 0; - SDiskDataHdr *pHdr = (SDiskDataHdr *)ph; +int32_t tGetDiskDataHdr(SBufferReader *br, SDiskDataHdr *pHdr) { + int32_t code; - n += tGetU32(p + n, &pHdr->delimiter); - n += tGetU32v(p + n, &pHdr->fmtVer); - n += tGetI64(p + n, &pHdr->suid); - n += tGetI64(p + n, &pHdr->uid); - n += tGetI32v(p + n, &pHdr->szUid); - n += tGetI32v(p + n, &pHdr->szVer); - n += tGetI32v(p + n, &pHdr->szKey); - n += tGetI32v(p + n, &pHdr->szBlkCol); - n += tGetI32v(p + n, &pHdr->nRow); - n += tGetI8(p + n, &pHdr->cmprAlg); + if ((code = tBufferGetU32(br, &pHdr->delimiter))) return code; + if ((code = tBufferGetU32v(br, &pHdr->fmtVer))) return code; + if ((code = tBufferGetI64(br, &pHdr->suid))) return code; + if ((code = tBufferGetI64(br, &pHdr->uid))) return code; + if ((code = tBufferGetI32v(br, &pHdr->szUid))) return code; + if ((code = tBufferGetI32v(br, &pHdr->szVer))) return code; + if ((code = tBufferGetI32v(br, &pHdr->szKey))) return code; + if ((code = tBufferGetI32v(br, &pHdr->szBlkCol))) return code; + if ((code = tBufferGetI32v(br, &pHdr->nRow))) return code; + if ((code = tBufferGetI8(br, &pHdr->cmprAlg))) return code; + if (pHdr->fmtVer == 1) { + if ((code = tBufferGetI8(br, &pHdr->numOfPKs))) return code; + for (int i = 0; i < pHdr->numOfPKs; i++) { + if ((code = tGetBlockCol(br, &pHdr->primaryBlockCols[i]))) return code; + } + } else { + pHdr->numOfPKs = 0; + } - return n; + return 0; } // ALGORITHM ============================== -int32_t tPutColumnDataAgg(uint8_t *p, SColumnDataAgg *pColAgg) { - int32_t n = 0; +int32_t tPutColumnDataAgg(SBuffer *buffer, SColumnDataAgg *pColAgg) { + int32_t code; - n += tPutI16v(p ? p + n : p, pColAgg->colId); - n += tPutI16v(p ? p + n : p, pColAgg->numOfNull); - n += tPutI64(p ? p + n : p, pColAgg->sum); - n += tPutI64(p ? p + n : p, pColAgg->max); - n += tPutI64(p ? p + n : p, pColAgg->min); + if ((code = tBufferPutI16v(buffer, pColAgg->colId))) return code; + if ((code = tBufferPutI16v(buffer, pColAgg->numOfNull))) return code; + if ((code = tBufferPutI64(buffer, pColAgg->sum))) return code; + if ((code = tBufferPutI64(buffer, pColAgg->max))) return code; + if ((code = tBufferPutI64(buffer, pColAgg->min))) return code; - return n; + return 0; } -int32_t tGetColumnDataAgg(uint8_t *p, SColumnDataAgg *pColAgg) { - int32_t n = 0; +int32_t tGetColumnDataAgg(SBufferReader *br, SColumnDataAgg *pColAgg) { + int32_t code; - n += tGetI16v(p + n, &pColAgg->colId); - n += tGetI16v(p + n, &pColAgg->numOfNull); - n += tGetI64(p + n, &pColAgg->sum); - n += tGetI64(p + n, &pColAgg->max); - n += tGetI64(p + n, &pColAgg->min); + if ((code = tBufferGetI16v(br, &pColAgg->colId))) return code; + if ((code = tBufferGetI16v(br, &pColAgg->numOfNull))) return code; + if ((code = tBufferGetI64(br, &pColAgg->sum))) return code; + if ((code = tBufferGetI64(br, &pColAgg->max))) return code; + if ((code = tBufferGetI64(br, &pColAgg->min))) return code; - return n; + return 0; } -int32_t tsdbCmprData(uint8_t *pIn, int32_t szIn, int8_t type, int8_t cmprAlg, uint8_t **ppOut, int32_t nOut, - int32_t *szOut, uint8_t **ppBuf) { - int32_t code = 0; +static int32_t tBlockDataCompressKeyPart(SBlockData *bData, SDiskDataHdr *hdr, SBuffer *buffer, SBuffer *assist) { + int32_t code = 0; + int32_t lino = 0; + SCompressInfo cinfo; - ASSERT(szIn > 0 && ppOut); + // uid + if (bData->uid == 0) { + cinfo = (SCompressInfo){ + .cmprAlg = hdr->cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .originalSize = sizeof(int64_t) * bData->nRow, + }; + code = tCompressDataToBuffer(bData->aUid, &cinfo, buffer, assist); + TSDB_CHECK_CODE(code, lino, _exit); + hdr->szUid = cinfo.compressedSize; + } - if (cmprAlg == NO_COMPRESSION) { - code = tRealloc(ppOut, nOut + szIn); - if (code) goto _exit; + // version + cinfo = (SCompressInfo){ + .cmprAlg = hdr->cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .originalSize = sizeof(int64_t) * bData->nRow, + }; + code = tCompressDataToBuffer((uint8_t *)bData->aVersion, &cinfo, buffer, assist); + TSDB_CHECK_CODE(code, lino, _exit); + hdr->szVer = cinfo.compressedSize; - memcpy(*ppOut + nOut, pIn, szIn); - *szOut = szIn; - } else { - int32_t size = szIn + COMP_OVERFLOW_BYTES; + // ts + cinfo = (SCompressInfo){ + .cmprAlg = hdr->cmprAlg, + .dataType = TSDB_DATA_TYPE_TIMESTAMP, + .originalSize = sizeof(TSKEY) * bData->nRow, + }; + code = tCompressDataToBuffer((uint8_t *)bData->aTSKEY, &cinfo, buffer, assist); + TSDB_CHECK_CODE(code, lino, _exit); + hdr->szKey = cinfo.compressedSize; - code = tRealloc(ppOut, nOut + size); - if (code) goto _exit; + // primary keys + for (hdr->numOfPKs = 0; hdr->numOfPKs < bData->nColData; hdr->numOfPKs++) { + ASSERT(hdr->numOfPKs <= TD_MAX_PK_COLS); - if (cmprAlg == TWO_STAGE_COMP) { - ASSERT(ppBuf); - code = tRealloc(ppBuf, size); - if (code) goto _exit; + SBlockCol *blockCol = &hdr->primaryBlockCols[hdr->numOfPKs]; + SColData *colData = tBlockDataGetColDataByIdx(bData, hdr->numOfPKs); + + if ((colData->cflag & COL_IS_KEY) == 0) { + break; } - *szOut = - tDataTypes[type].compFunc(pIn, szIn, szIn / tDataTypes[type].bytes, *ppOut + nOut, size, cmprAlg, *ppBuf, size); - if (*szOut <= 0) { - code = TSDB_CODE_COMPRESS_ERROR; - goto _exit; - } + SColDataCompressInfo info = { + .cmprAlg = hdr->cmprAlg, + }; + code = tColDataCompress(colData, &info, buffer, assist); + TSDB_CHECK_CODE(code, lino, _exit); + + *blockCol = (SBlockCol){ + .cid = info.columnId, + .type = info.dataType, + .cflag = info.columnFlag, + .flag = info.flag, + .szOrigin = info.dataOriginalSize, + .szBitmap = info.bitmapCompressedSize, + .szOffset = info.offsetCompressedSize, + .szValue = info.dataCompressedSize, + .offset = 0, + }; } _exit: return code; } -int32_t tsdbDecmprData(uint8_t *pIn, int32_t szIn, int8_t type, int8_t cmprAlg, uint8_t **ppOut, int32_t szOut, - uint8_t **ppBuf) { +int32_t tBlockDataDecompressColData(const SDiskDataHdr *hdr, const SBlockCol *blockCol, SBufferReader *br, + SBlockData *blockData, SBuffer *assist) { int32_t code = 0; + int32_t lino = 0; - code = tRealloc(ppOut, szOut); - if (code) goto _exit; + SColData *colData; - if (cmprAlg == NO_COMPRESSION) { - ASSERT(szIn == szOut); - memcpy(*ppOut, pIn, szOut); - } else { - if (cmprAlg == TWO_STAGE_COMP) { - code = tRealloc(ppBuf, szOut + COMP_OVERFLOW_BYTES); - if (code) goto _exit; - } + code = tBlockDataAddColData(blockData, blockCol->cid, blockCol->type, blockCol->cflag, &colData); + TSDB_CHECK_CODE(code, lino, _exit); - int32_t size = tDataTypes[type].decompFunc(pIn, szIn, szOut / tDataTypes[type].bytes, *ppOut, szOut, cmprAlg, - *ppBuf, szOut + COMP_OVERFLOW_BYTES); - if (size <= 0) { - code = TSDB_CODE_COMPRESS_ERROR; - goto _exit; - } + // ASSERT(blockCol->flag != HAS_NONE); - ASSERT(size == szOut); + SColDataCompressInfo info = { + .cmprAlg = hdr->cmprAlg, + .columnFlag = blockCol->cflag, + .flag = blockCol->flag, + .dataType = blockCol->type, + .columnId = blockCol->cid, + .numOfData = hdr->nRow, + .bitmapOriginalSize = 0, + .bitmapCompressedSize = blockCol->szBitmap, + .offsetOriginalSize = blockCol->szOffset ? sizeof(int32_t) * hdr->nRow : 0, + .offsetCompressedSize = blockCol->szOffset, + .dataOriginalSize = blockCol->szOrigin, + .dataCompressedSize = blockCol->szValue, + }; + + switch (blockCol->flag) { + case (HAS_NONE | HAS_NULL | HAS_VALUE): + info.bitmapOriginalSize = BIT2_SIZE(hdr->nRow); + break; + case (HAS_NONE | HAS_NULL): + case (HAS_NONE | HAS_VALUE): + case (HAS_NULL | HAS_VALUE): + info.bitmapOriginalSize = BIT1_SIZE(hdr->nRow); + break; } + code = tColDataDecompress(BR_PTR(br), &info, colData, assist); + TSDB_CHECK_CODE(code, lino, _exit); + br->offset += blockCol->szBitmap + blockCol->szOffset + blockCol->szValue; + _exit: return code; } -int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol, uint8_t **ppOut, int32_t nOut, - uint8_t **ppBuf) { - int32_t code = 0; +int32_t tBlockDataDecompressKeyPart(const SDiskDataHdr *hdr, SBufferReader *br, SBlockData *blockData, + SBuffer *assist) { + int32_t code = 0; + int32_t lino = 0; + SCompressInfo cinfo; - ASSERT(pColData->flag && (pColData->flag != HAS_NONE) && (pColData->flag != HAS_NULL)); + // uid + if (hdr->szUid > 0) { + cinfo = (SCompressInfo){ + .cmprAlg = hdr->cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .compressedSize = hdr->szUid, + .originalSize = sizeof(int64_t) * hdr->nRow, + }; - pBlockCol->szBitmap = 0; - pBlockCol->szOffset = 0; - pBlockCol->szValue = 0; - - int32_t size = 0; - // bitmap - if (pColData->flag != HAS_VALUE) { - int32_t szBitMap; - if (pColData->flag == (HAS_VALUE | HAS_NULL | HAS_NONE)) { - szBitMap = BIT2_SIZE(pColData->nVal); - } else { - szBitMap = BIT1_SIZE(pColData->nVal); - } - - code = tsdbCmprData(pColData->pBitMap, szBitMap, TSDB_DATA_TYPE_TINYINT, cmprAlg, ppOut, nOut + size, - &pBlockCol->szBitmap, ppBuf); - if (code) goto _exit; + code = tRealloc((uint8_t **)&blockData->aUid, cinfo.originalSize); + TSDB_CHECK_CODE(code, lino, _exit); + code = tDecompressData(BR_PTR(br), &cinfo, blockData->aUid, cinfo.originalSize, assist); + TSDB_CHECK_CODE(code, lino, _exit); + br->offset += cinfo.compressedSize; } - size += pBlockCol->szBitmap; - // offset - if (IS_VAR_DATA_TYPE(pColData->type) && pColData->flag != (HAS_NULL | HAS_NONE)) { - code = tsdbCmprData((uint8_t *)pColData->aOffset, sizeof(int32_t) * pColData->nVal, TSDB_DATA_TYPE_INT, cmprAlg, - ppOut, nOut + size, &pBlockCol->szOffset, ppBuf); - if (code) goto _exit; - } - size += pBlockCol->szOffset; + // version + cinfo = (SCompressInfo){ + .cmprAlg = hdr->cmprAlg, + .dataType = TSDB_DATA_TYPE_BIGINT, + .compressedSize = hdr->szVer, + .originalSize = sizeof(int64_t) * hdr->nRow, + }; + code = tRealloc((uint8_t **)&blockData->aVersion, cinfo.originalSize); + TSDB_CHECK_CODE(code, lino, _exit); + code = tDecompressData(BR_PTR(br), &cinfo, blockData->aVersion, cinfo.originalSize, assist); + TSDB_CHECK_CODE(code, lino, _exit); + br->offset += cinfo.compressedSize; - // value - if ((pColData->flag != (HAS_NULL | HAS_NONE)) && pColData->nData) { - code = tsdbCmprData((uint8_t *)pColData->pData, pColData->nData, pColData->type, cmprAlg, ppOut, nOut + size, - &pBlockCol->szValue, ppBuf); - if (code) goto _exit; + // ts + cinfo = (SCompressInfo){ + .cmprAlg = hdr->cmprAlg, + .dataType = TSDB_DATA_TYPE_TIMESTAMP, + .compressedSize = hdr->szKey, + .originalSize = sizeof(TSKEY) * hdr->nRow, + }; + code = tRealloc((uint8_t **)&blockData->aTSKEY, cinfo.originalSize); + TSDB_CHECK_CODE(code, lino, _exit); + code = tDecompressData(BR_PTR(br), &cinfo, blockData->aTSKEY, cinfo.originalSize, assist); + TSDB_CHECK_CODE(code, lino, _exit); + br->offset += cinfo.compressedSize; + + // primary keys + for (int i = 0; i < hdr->numOfPKs; i++) { + const SBlockCol *blockCol = &hdr->primaryBlockCols[i]; + + ASSERT(blockCol->flag == HAS_VALUE); + ASSERT(blockCol->cflag & COL_IS_KEY); + + code = tBlockDataDecompressColData(hdr, blockCol, br, blockData, assist); + TSDB_CHECK_CODE(code, lino, _exit); } - size += pBlockCol->szValue; _exit: return code; -} - -int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, int32_t nVal, SColData *pColData, - uint8_t **ppBuf) { - int32_t code = 0; - - ASSERT(pColData->cid == pBlockCol->cid); - ASSERT(pColData->type == pBlockCol->type); - pColData->smaOn = pBlockCol->smaOn; - pColData->flag = pBlockCol->flag; - pColData->nVal = nVal; - pColData->nData = pBlockCol->szOrigin; - - uint8_t *p = pIn; - // bitmap - if (pBlockCol->szBitmap) { - int32_t szBitMap; - if (pColData->flag == (HAS_VALUE | HAS_NULL | HAS_NONE)) { - szBitMap = BIT2_SIZE(pColData->nVal); - } else { - szBitMap = BIT1_SIZE(pColData->nVal); - } - - code = tsdbDecmprData(p, pBlockCol->szBitmap, TSDB_DATA_TYPE_TINYINT, cmprAlg, &pColData->pBitMap, szBitMap, ppBuf); - if (code) goto _exit; - } - p += pBlockCol->szBitmap; - - // offset - if (pBlockCol->szOffset) { - code = tsdbDecmprData(p, pBlockCol->szOffset, TSDB_DATA_TYPE_INT, cmprAlg, (uint8_t **)&pColData->aOffset, - sizeof(int32_t) * pColData->nVal, ppBuf); - if (code) goto _exit; - } - p += pBlockCol->szOffset; - - // value - if (pBlockCol->szValue) { - code = tsdbDecmprData(p, pBlockCol->szValue, pColData->type, cmprAlg, &pColData->pData, pColData->nData, ppBuf); - if (code) goto _exit; - } - p += pBlockCol->szValue; - -_exit: - return code; -} +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil2.c b/source/dnode/vnode/src/tsdb/tsdbUtil2.c index fe9d71fcc6..d8e93cbe7c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil2.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil2.c @@ -17,39 +17,46 @@ // SDelBlock ---------- int32_t tTombBlockInit(STombBlock *tombBlock) { + tombBlock->numOfRecords = 0; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - TARRAY2_INIT(&tombBlock->dataArr[i]); + tBufferInit(&tombBlock->buffers[i]); } return 0; } int32_t tTombBlockDestroy(STombBlock *tombBlock) { + tombBlock->numOfRecords = 0; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - TARRAY2_DESTROY(&tombBlock->dataArr[i], NULL); + tBufferDestroy(&tombBlock->buffers[i]); } return 0; } int32_t tTombBlockClear(STombBlock *tombBlock) { + tombBlock->numOfRecords = 0; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - TARRAY2_CLEAR(&tombBlock->dataArr[i], NULL); + tBufferClear(&tombBlock->buffers[i]); } return 0; } int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) { - int32_t code; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - code = TARRAY2_APPEND(&tombBlock->dataArr[i], record->dataArr[i]); + int32_t code = tBufferPutI64(&tombBlock->buffers[i], record->data[i]); if (code) return code; } + tombBlock->numOfRecords++; return 0; } int32_t tTombBlockGet(STombBlock *tombBlock, int32_t idx, STombRecord *record) { - if (idx >= TOMB_BLOCK_SIZE(tombBlock)) return TSDB_CODE_OUT_OF_RANGE; + if (idx < 0 || idx >= tombBlock->numOfRecords) { + return TSDB_CODE_OUT_OF_RANGE; + } + for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - record->dataArr[i] = TARRAY2_GET(&tombBlock->dataArr[i], idx); + SBufferReader br = BUFFER_READER_INITIALIZER(sizeof(int64_t) * idx, &tombBlock->buffers[i]); + tBufferGetI64(&br, &record->data[i]); } return 0; } @@ -66,95 +73,374 @@ int32_t tTombRecordCompare(const STombRecord *r1, const STombRecord *r2) { // STbStatisBlock ---------- int32_t tStatisBlockInit(STbStatisBlock *statisBlock) { - for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) { - TARRAY2_INIT(&statisBlock->dataArr[i]); + statisBlock->numOfPKs = 0; + statisBlock->numOfRecords = 0; + for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { + tBufferInit(&statisBlock->buffers[i]); + } + for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { + tValueColumnInit(&statisBlock->firstKeyPKs[i]); + tValueColumnInit(&statisBlock->lastKeyPKs[i]); } return 0; } int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock) { - for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) { - TARRAY2_DESTROY(&statisBlock->dataArr[i], NULL); + statisBlock->numOfPKs = 0; + statisBlock->numOfRecords = 0; + for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { + tBufferDestroy(&statisBlock->buffers[i]); + } + for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { + tValueColumnDestroy(&statisBlock->firstKeyPKs[i]); + tValueColumnDestroy(&statisBlock->lastKeyPKs[i]); } return 0; } int32_t tStatisBlockClear(STbStatisBlock *statisBlock) { - for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) { - TARRAY2_CLEAR(&statisBlock->dataArr[i], NULL); + statisBlock->numOfPKs = 0; + statisBlock->numOfRecords = 0; + for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { + tBufferClear(&statisBlock->buffers[i]); + } + for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { + tValueColumnClear(&statisBlock->firstKeyPKs[i]); + tValueColumnClear(&statisBlock->lastKeyPKs[i]); } return 0; } -int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *record) { - int32_t code; - for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) { - code = TARRAY2_APPEND(&statisBlock->dataArr[i], record->dataArr[i]); - if (code) return code; +static int32_t tStatisBlockAppend(STbStatisBlock *block, SRowInfo *row) { + int32_t code; + STsdbRowKey key; + + tsdbRowGetKey(&row->row, &key); + if (block->numOfRecords == 0) { + block->numOfPKs = key.key.numOfPKs; + } else if (block->numOfPKs != key.key.numOfPKs) { + return TSDB_CODE_INVALID_PARA; + } else { + for (int i = 0; i < block->numOfPKs; i++) { + if (key.key.pks[i].type != block->firstKeyPKs[i].type) { + return TSDB_CODE_INVALID_PARA; + } + } } + + if ((code = tBufferPutI64(&block->suids, row->suid))) return code; + if ((code = tBufferPutI64(&block->uids, row->uid))) return code; + if ((code = tBufferPutI64(&block->firstKeyTimestamps, key.key.ts))) return code; + if ((code = tBufferPutI64(&block->lastKeyTimestamps, key.key.ts))) return code; + if ((code = tBufferPutI64(&block->counts, 1))) return code; + for (int32_t i = 0; i < block->numOfPKs; ++i) { + if ((code = tValueColumnAppend(block->firstKeyPKs + i, key.key.pks + i))) return code; + if ((code = tValueColumnAppend(block->lastKeyPKs + i, key.key.pks + i))) return code; + } + + block->numOfRecords++; return 0; } +static int32_t tStatisBlockUpdate(STbStatisBlock *block, SRowInfo *row) { + STbStatisRecord record; + STsdbRowKey key; + int32_t c; + int32_t code; + + tStatisBlockGet(block, block->numOfRecords - 1, &record); + tsdbRowGetKey(&row->row, &key); + + c = tRowKeyCompare(&record.lastKey, &key.key); + if (c == 0) { + return 0; + } else if (c < 0) { + // last ts + code = tBufferPutAt(&block->lastKeyTimestamps, (block->numOfRecords - 1) * sizeof(record.lastKey.ts), &key.key.ts, + sizeof(key.key.ts)); + if (code) return code; + + // last primary keys + for (int i = 0; i < block->numOfPKs; i++) { + code = tValueColumnUpdate(&block->lastKeyPKs[i], block->numOfRecords - 1, &key.key.pks[i]); + if (code) return code; + } + + // count + record.count++; + code = tBufferPutAt(&block->counts, (block->numOfRecords - 1) * sizeof(record.count), &record.count, + sizeof(record.count)); + if (code) return code; + } else { + ASSERT(0); + } + + return 0; +} + +int32_t tStatisBlockPut(STbStatisBlock *block, SRowInfo *row, int32_t maxRecords) { + if (block->numOfRecords > 0) { + int64_t lastUid; + SBufferReader br = BUFFER_READER_INITIALIZER(sizeof(int64_t) * (block->numOfRecords - 1), &block->uids); + tBufferGetI64(&br, &lastUid); + + if (lastUid == row->uid) { + return tStatisBlockUpdate(block, row); + } else if (block->numOfRecords >= maxRecords) { + return TSDB_CODE_INVALID_PARA; + } + } + return tStatisBlockAppend(block, row); +} + int32_t tStatisBlockGet(STbStatisBlock *statisBlock, int32_t idx, STbStatisRecord *record) { - if (idx >= STATIS_BLOCK_SIZE(statisBlock)) return TSDB_CODE_OUT_OF_RANGE; - for (int32_t i = 0; i < STATIS_RECORD_NUM_ELEM; ++i) { - record->dataArr[i] = TARRAY2_GET(&statisBlock->dataArr[i], idx); + int32_t code; + SBufferReader reader; + + if (idx < 0 || idx >= statisBlock->numOfRecords) { + return TSDB_CODE_OUT_OF_RANGE; } + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->suid), &statisBlock->suids); + code = tBufferGetI64(&reader, &record->suid); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->uid), &statisBlock->uids); + code = tBufferGetI64(&reader, &record->uid); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->firstKey.ts), &statisBlock->firstKeyTimestamps); + code = tBufferGetI64(&reader, &record->firstKey.ts); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->lastKey.ts), &statisBlock->lastKeyTimestamps); + code = tBufferGetI64(&reader, &record->lastKey.ts); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(record->count), &statisBlock->counts); + code = tBufferGetI64(&reader, &record->count); + if (code) return code; + + // primary keys + for (record->firstKey.numOfPKs = 0; record->firstKey.numOfPKs < statisBlock->numOfPKs; record->firstKey.numOfPKs++) { + code = tValueColumnGet(&statisBlock->firstKeyPKs[record->firstKey.numOfPKs], idx, + &record->firstKey.pks[record->firstKey.numOfPKs]); + if (code) return code; + } + + for (record->lastKey.numOfPKs = 0; record->lastKey.numOfPKs < statisBlock->numOfPKs; record->lastKey.numOfPKs++) { + code = tValueColumnGet(&statisBlock->lastKeyPKs[record->lastKey.numOfPKs], idx, + &record->lastKey.pks[record->lastKey.numOfPKs]); + if (code) return code; + } + return 0; } // SBrinRecord ---------- int32_t tBrinBlockInit(SBrinBlock *brinBlock) { - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr1); ++i) { - TARRAY2_INIT(&brinBlock->dataArr1[i]); + brinBlock->numOfPKs = 0; + brinBlock->numOfRecords = 0; + for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) { + tBufferInit(&brinBlock->buffers[i]); } - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr2); ++i) { - TARRAY2_INIT(&brinBlock->dataArr2[i]); + for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { + tValueColumnInit(&brinBlock->firstKeyPKs[i]); + tValueColumnInit(&brinBlock->lastKeyPKs[i]); } return 0; } int32_t tBrinBlockDestroy(SBrinBlock *brinBlock) { - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr1); ++i) { - TARRAY2_DESTROY(&brinBlock->dataArr1[i], NULL); + brinBlock->numOfPKs = 0; + brinBlock->numOfRecords = 0; + for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) { + tBufferDestroy(&brinBlock->buffers[i]); } - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr2); ++i) { - TARRAY2_DESTROY(&brinBlock->dataArr2[i], NULL); + for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { + tValueColumnDestroy(&brinBlock->firstKeyPKs[i]); + tValueColumnDestroy(&brinBlock->lastKeyPKs[i]); } return 0; } int32_t tBrinBlockClear(SBrinBlock *brinBlock) { - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr1); ++i) { - TARRAY2_CLEAR(&brinBlock->dataArr1[i], NULL); + brinBlock->numOfPKs = 0; + brinBlock->numOfRecords = 0; + for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) { + tBufferClear(&brinBlock->buffers[i]); } - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr2); ++i) { - TARRAY2_CLEAR(&brinBlock->dataArr2[i], NULL); + for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { + tValueColumnClear(&brinBlock->firstKeyPKs[i]); + tValueColumnClear(&brinBlock->lastKeyPKs[i]); } return 0; } int32_t tBrinBlockPut(SBrinBlock *brinBlock, const SBrinRecord *record) { int32_t code; - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr1); ++i) { - code = TARRAY2_APPEND(&brinBlock->dataArr1[i], record->dataArr1[i]); - if (code) return code; + + ASSERT(record->firstKey.key.numOfPKs == record->lastKey.key.numOfPKs); + + if (brinBlock->numOfRecords == 0) { // the first row + brinBlock->numOfPKs = record->firstKey.key.numOfPKs; + } else if (brinBlock->numOfPKs != record->firstKey.key.numOfPKs) { + // if the number of primary keys are not the same, + // return an error code and the caller should handle it + return TSDB_CODE_INVALID_PARA; + } else { + for (int i = 0; i < brinBlock->numOfPKs; i++) { + if (record->firstKey.key.pks[i].type != brinBlock->firstKeyPKs[i].type) { + return TSDB_CODE_INVALID_PARA; + } + } } - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr2); ++i) { - code = TARRAY2_APPEND(&brinBlock->dataArr2[i], record->dataArr2[i]); - if (code) return code; + + code = tBufferPutI64(&brinBlock->suids, record->suid); + if (code) return code; + + code = tBufferPutI64(&brinBlock->uids, record->uid); + if (code) return code; + + code = tBufferPutI64(&brinBlock->firstKeyTimestamps, record->firstKey.key.ts); + if (code) return code; + + code = tBufferPutI64(&brinBlock->firstKeyVersions, record->firstKey.version); + if (code) return code; + + code = tBufferPutI64(&brinBlock->lastKeyTimestamps, record->lastKey.key.ts); + if (code) return code; + + code = tBufferPutI64(&brinBlock->lastKeyVersions, record->lastKey.version); + if (code) return code; + + code = tBufferPutI64(&brinBlock->minVers, record->minVer); + if (code) return code; + + code = tBufferPutI64(&brinBlock->maxVers, record->maxVer); + if (code) return code; + + code = tBufferPutI64(&brinBlock->blockOffsets, record->blockOffset); + if (code) return code; + + code = tBufferPutI64(&brinBlock->smaOffsets, record->smaOffset); + if (code) return code; + + code = tBufferPutI32(&brinBlock->blockSizes, record->blockSize); + if (code) return code; + + code = tBufferPutI32(&brinBlock->blockKeySizes, record->blockKeySize); + if (code) return code; + + code = tBufferPutI32(&brinBlock->smaSizes, record->smaSize); + if (code) return code; + + code = tBufferPutI32(&brinBlock->numRows, record->numRow); + if (code) return code; + + code = tBufferPutI32(&brinBlock->counts, record->count); + if (code) return code; + + if (brinBlock->numOfPKs > 0) { + for (int32_t i = 0; i < brinBlock->numOfPKs; ++i) { + code = tValueColumnAppend(&brinBlock->firstKeyPKs[i], &record->firstKey.key.pks[i]); + if (code) return code; + } + + for (int32_t i = 0; i < brinBlock->numOfPKs; ++i) { + code = tValueColumnAppend(&brinBlock->lastKeyPKs[i], &record->lastKey.key.pks[i]); + if (code) return code; + } } + + brinBlock->numOfRecords++; + return 0; } int32_t tBrinBlockGet(SBrinBlock *brinBlock, int32_t idx, SBrinRecord *record) { - if (idx >= BRIN_BLOCK_SIZE(brinBlock)) return TSDB_CODE_OUT_OF_RANGE; - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr1); ++i) { - record->dataArr1[i] = TARRAY2_GET(&brinBlock->dataArr1[i], idx); + int32_t code; + SBufferReader reader; + + if (idx < 0 || idx >= brinBlock->numOfRecords) { + return TSDB_CODE_OUT_OF_RANGE; } - for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->dataArr2); ++i) { - record->dataArr2[i] = TARRAY2_GET(&brinBlock->dataArr2[i], idx); + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->suids); + code = tBufferGetI64(&reader, &record->suid); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->uids); + code = tBufferGetI64(&reader, &record->uid); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->firstKeyTimestamps); + code = tBufferGetI64(&reader, &record->firstKey.key.ts); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->firstKeyVersions); + code = tBufferGetI64(&reader, &record->firstKey.version); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->lastKeyTimestamps); + code = tBufferGetI64(&reader, &record->lastKey.key.ts); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->lastKeyVersions); + code = tBufferGetI64(&reader, &record->lastKey.version); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->minVers); + code = tBufferGetI64(&reader, &record->minVer); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->maxVers); + code = tBufferGetI64(&reader, &record->maxVer); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->blockOffsets); + code = tBufferGetI64(&reader, &record->blockOffset); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int64_t), &brinBlock->smaOffsets); + code = tBufferGetI64(&reader, &record->smaOffset); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->blockSizes); + code = tBufferGetI32(&reader, &record->blockSize); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->blockKeySizes); + code = tBufferGetI32(&reader, &record->blockKeySize); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->smaSizes); + code = tBufferGetI32(&reader, &record->smaSize); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->numRows); + code = tBufferGetI32(&reader, &record->numRow); + if (code) return code; + + reader = BUFFER_READER_INITIALIZER(idx * sizeof(int32_t), &brinBlock->counts); + code = tBufferGetI32(&reader, &record->count); + if (code) return code; + + // primary keys + for (record->firstKey.key.numOfPKs = 0; record->firstKey.key.numOfPKs < brinBlock->numOfPKs; + record->firstKey.key.numOfPKs++) { + code = tValueColumnGet(&brinBlock->firstKeyPKs[record->firstKey.key.numOfPKs], idx, + &record->firstKey.key.pks[record->firstKey.key.numOfPKs]); + if (code) return code; } + + for (record->lastKey.key.numOfPKs = 0; record->lastKey.key.numOfPKs < brinBlock->numOfPKs; + record->lastKey.key.numOfPKs++) { + code = tValueColumnGet(&brinBlock->lastKeyPKs[record->lastKey.key.numOfPKs], idx, + &record->lastKey.key.pks[record->lastKey.key.numOfPKs]); + if (code) return code; + } + return 0; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil2.h b/source/dnode/vnode/src/tsdb/tsdbUtil2.h index fa06368341..71f47a5f8e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil2.h +++ b/source/dnode/vnode/src/tsdb/tsdbUtil2.h @@ -25,7 +25,7 @@ extern "C" { // STombRecord ---------- #define TOMB_RECORD_ELEM_NUM 5 typedef union { - int64_t dataArr[TOMB_RECORD_ELEM_NUM]; + int64_t data[TOMB_RECORD_ELEM_NUM]; struct { int64_t suid; int64_t uid; @@ -35,14 +35,17 @@ typedef union { }; } STombRecord; -typedef union { - TARRAY2(int64_t) dataArr[TOMB_RECORD_ELEM_NUM]; - struct { - TARRAY2(int64_t) suid[1]; - TARRAY2(int64_t) uid[1]; - TARRAY2(int64_t) version[1]; - TARRAY2(int64_t) skey[1]; - TARRAY2(int64_t) ekey[1]; +typedef struct { + int32_t numOfRecords; + union { + SBuffer buffers[TOMB_RECORD_ELEM_NUM]; + struct { + SBuffer suids; + SBuffer uids; + SBuffer versions; + SBuffer skeys; + SBuffer ekeys; + }; }; } STombBlock; @@ -60,7 +63,7 @@ typedef struct { typedef TARRAY2(STombBlk) TTombBlkArray; -#define TOMB_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid) +#define TOMB_BLOCK_SIZE(db) ((db)->numOfRecords) int32_t tTombBlockInit(STombBlock *tombBlock); int32_t tTombBlockDestroy(STombBlock *tombBlock); @@ -70,27 +73,29 @@ int32_t tTombBlockGet(STombBlock *tombBlock, int32_t idx, STombRecord *record); int32_t tTombRecordCompare(const STombRecord *record1, const STombRecord *record2); // STbStatisRecord ---------- -#define STATIS_RECORD_NUM_ELEM 5 -typedef union { - int64_t dataArr[STATIS_RECORD_NUM_ELEM]; - struct { - int64_t suid; - int64_t uid; - int64_t firstKey; - int64_t lastKey; - int64_t count; - }; +typedef struct { + int64_t suid; + int64_t uid; + SRowKey firstKey; + SRowKey lastKey; + int64_t count; } STbStatisRecord; -typedef union { - TARRAY2(int64_t) dataArr[STATIS_RECORD_NUM_ELEM]; - struct { - TARRAY2(int64_t) suid[1]; - TARRAY2(int64_t) uid[1]; - TARRAY2(int64_t) firstKey[1]; - TARRAY2(int64_t) lastKey[1]; - TARRAY2(int64_t) count[1]; +typedef struct { + int8_t numOfPKs; + int32_t numOfRecords; + union { + SBuffer buffers[5]; + struct { + SBuffer suids; // int64_t + SBuffer uids; // int64_t + SBuffer firstKeyTimestamps; // int64_t + SBuffer lastKeyTimestamps; // int64_t + SBuffer counts; // int64_t + }; }; + SValueColumn firstKeyPKs[TD_MAX_PK_COLS]; + SValueColumn lastKeyPKs[TD_MAX_PK_COLS]; } STbStatisBlock; typedef struct { @@ -98,66 +103,62 @@ typedef struct { TABLEID minTbid; TABLEID maxTbid; int32_t numRec; - int32_t size[STATIS_RECORD_NUM_ELEM]; + int32_t size[5]; int8_t cmprAlg; - int8_t rsvd[7]; + int8_t numOfPKs; // number of primary keys + int8_t rsvd[6]; } SStatisBlk; -#define STATIS_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid) +#define STATIS_BLOCK_SIZE(db) ((db)->numOfRecords) int32_t tStatisBlockInit(STbStatisBlock *statisBlock); int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock); int32_t tStatisBlockClear(STbStatisBlock *statisBlock); -int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *record); +int32_t tStatisBlockPut(STbStatisBlock *statisBlock, SRowInfo *row, int32_t maxRecords); int32_t tStatisBlockGet(STbStatisBlock *statisBlock, int32_t idx, STbStatisRecord *record); // SBrinRecord ---------- -typedef union { - struct { - int64_t dataArr1[10]; - int32_t dataArr2[5]; - }; - struct { - int64_t suid; - int64_t uid; - int64_t firstKey; - int64_t firstKeyVer; - int64_t lastKey; - int64_t lastKeyVer; - int64_t minVer; - int64_t maxVer; - int64_t blockOffset; - int64_t smaOffset; - int32_t blockSize; - int32_t blockKeySize; - int32_t smaSize; - int32_t numRow; - int32_t count; - }; +typedef struct { + int64_t suid; + int64_t uid; + STsdbRowKey firstKey; + STsdbRowKey lastKey; + int64_t minVer; + int64_t maxVer; + int64_t blockOffset; + int64_t smaOffset; + int32_t blockSize; + int32_t blockKeySize; + int32_t smaSize; + int32_t numRow; + int32_t count; } SBrinRecord; -typedef union { - struct { - TARRAY2(int64_t) dataArr1[10]; - TARRAY2(int32_t) dataArr2[5]; - }; - struct { - TARRAY2(int64_t) suid[1]; - TARRAY2(int64_t) uid[1]; - TARRAY2(int64_t) firstKey[1]; - TARRAY2(int64_t) firstKeyVer[1]; - TARRAY2(int64_t) lastKey[1]; - TARRAY2(int64_t) lastKeyVer[1]; - TARRAY2(int64_t) minVer[1]; - TARRAY2(int64_t) maxVer[1]; - TARRAY2(int64_t) blockOffset[1]; - TARRAY2(int64_t) smaOffset[1]; - TARRAY2(int32_t) blockSize[1]; - TARRAY2(int32_t) blockKeySize[1]; - TARRAY2(int32_t) smaSize[1]; - TARRAY2(int32_t) numRow[1]; - TARRAY2(int32_t) count[1]; +typedef struct { + int8_t numOfPKs; + int32_t numOfRecords; + union { + SBuffer buffers[15]; + struct { + SBuffer suids; // int64_t + SBuffer uids; // int64_t + SBuffer firstKeyTimestamps; // int64_t + SBuffer firstKeyVersions; // int64_t + SBuffer lastKeyTimestamps; // int64_t + SBuffer lastKeyVersions; // int64_t + SBuffer minVers; // int64_t + SBuffer maxVers; // int64_t + SBuffer blockOffsets; // int64_t + SBuffer smaOffsets; // int64_t + SBuffer blockSizes; // int32_t + SBuffer blockKeySizes; // int32_t + SBuffer smaSizes; // int32_t + SBuffer numRows; // int32_t + SBuffer counts; // int32_t + }; }; + SValueColumn firstKeyPKs[TD_MAX_PK_COLS]; + SValueColumn lastKeyPKs[TD_MAX_PK_COLS]; } SBrinBlock; typedef struct { @@ -169,12 +170,13 @@ typedef struct { int32_t numRec; int32_t size[15]; int8_t cmprAlg; - int8_t rsvd[7]; + int8_t numOfPKs; // number of primary keys + int8_t rsvd[6]; } SBrinBlk; typedef TARRAY2(SBrinBlk) TBrinBlkArray; -#define BRIN_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid) +#define BRIN_BLOCK_SIZE(db) ((db)->numOfRecords) int32_t tBrinBlockInit(SBrinBlock *brinBlock); int32_t tBrinBlockDestroy(SBrinBlock *brinBlock); diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c index 00b58263e2..88fb60fc4c 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -220,9 +220,10 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); taosArrayPush(pVals, &cv); } else { - void* data = colDataGetVarData(pColInfoData, j); - SValue sv = (SValue){.nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); + void* data = colDataGetVarData(pColInfoData, j); + SValue sv = (SValue){ + .type = pCol->type, .nData = varDataLen(data), .pData = varDataVal(data)}; // address copy, no value + SColVal cv = COL_VAL_VALUE(pCol->colId, sv); taosArrayPush(pVals, &cv); } break; @@ -243,7 +244,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp terrno = TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL; goto _end; } - + SColVal cv = COL_VAL_NULL(pCol->colId, pCol->type); // should use pCol->type taosArrayPush(pVals, &cv); } else { @@ -257,9 +258,9 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp } } - SValue sv; + SValue sv = {.type = pCol->type}; memcpy(&sv.val, var, tDataTypes[pCol->type].bytes); - SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); + SColVal cv = COL_VAL_VALUE(pCol->colId, sv); taosArrayPush(pVals, &cv); } } else { @@ -288,7 +289,7 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp if (disorderTs) { if ((tRowSort(tbData.aRowP) != TSDB_CODE_SUCCESS) || - (terrno = tRowMerge(tbData.aRowP, (STSchema*)pTSchema, 0)) != 0) { + (terrno = tRowMerge(tbData.aRowP, (STSchema*)pTSchema, 0)) != 0) { goto _end; } } @@ -393,7 +394,7 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) { taosMemoryFree(pInserter->pParam); taosHashCleanup(pInserter->pCols); taosThreadMutexDestroy(&pInserter->mutex); - + taosMemoryFree(pInserter->pManager); return TSDB_CODE_SUCCESS; } @@ -475,6 +476,6 @@ _return: } else { taosMemoryFree(pManager); } - - return terrno; + + return terrno; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 7749e6a1d2..6ebf93dc19 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -4704,6 +4704,7 @@ static const char* jkColumnDefColName = "ColName"; static const char* jkColumnDefDataType = "DataType"; static const char* jkColumnDefComments = "Comments"; static const char* jkColumnDefSma = "Sma"; +static const char* jkColumnDefIsPK = "IsPK"; static int32_t columnDefNodeToJson(const void* pObj, SJson* pJson) { const SColumnDefNode* pNode = (const SColumnDefNode*)pObj; @@ -4718,6 +4719,9 @@ static int32_t columnDefNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkColumnDefSma, pNode->sma); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkColumnDefIsPK, pNode->is_pk); + } return code; } @@ -4735,7 +4739,9 @@ static int32_t jsonToColumnDefNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkColumnDefSma, &pNode->sma); } - + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkColumnDefIsPK, &pNode->is_pk); + } return code; } diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 9fc3034116..176aa9453f 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -82,6 +82,7 @@ typedef enum EColumnOptionType { COLUMN_OPTION_ENCODE, COLUMN_OPTION_COMPRESS, COLUMN_OPTION_LEVEL, + COLUMN_OPTION_PRIMARYKEY, } EColumnOptionType; typedef struct SAlterOption { diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index dc3625496e..c015d8e889 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -1286,6 +1286,7 @@ null_ordering_opt(A) ::= NULLS LAST. STRICT STRING TIMES VALUES VARIABLE VIEW WAL. column_options(A) ::= . { A = createDefaultColumnOptions(pCxt); } +column_options(A) ::= column_options(B) PRIMARY KEY. { A = setColumnOptions(pCxt, B, COLUMN_OPTION_PRIMARYKEY, NULL); } column_options(A) ::= column_options(B) ENCODE NK_STRING(C). { A = setColumnOptions(pCxt, B, COLUMN_OPTION_ENCODE, &C); } column_options(A) ::= column_options(B) COMPRESS NK_STRING(C). { A = setColumnOptions(pCxt, B, COLUMN_OPTION_COMPRESS, &C); } column_options(A) ::= column_options(B) LEVEL NK_STRING(C). { A = setColumnOptions(pCxt, B, COLUMN_OPTION_LEVEL, &C); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 4217f6a1d0..edeecbada9 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1503,6 +1503,7 @@ SNode* createDefaultColumnOptions(SAstCreateContext* pCxt) { SColumnOptions* pOptions = (SColumnOptions*)nodesMakeNode(QUERY_NODE_COLUMN_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->commentNull = true; + pOptions->bPrimaryKey = false; return (SNode*)pOptions; } @@ -1530,6 +1531,9 @@ SNode* setColumnOptions(SAstCreateContext* pCxt, SNode* pOptions, EColumnOptionT pCxt->errCode = TSDB_CODE_TSC_ENCODE_PARAM_ERROR; } break; + case COLUMN_OPTION_PRIMARYKEY: + ((SColumnOptions*)pOptions)->bPrimaryKey = true; + break; default: break; } @@ -1551,6 +1555,8 @@ SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType pCol->dataType = dataType; pCol->pOptions = (SColumnOptions*)pNode; pCol->sma = true; + // pNode equals to NULL means that the column is a tag. + pCol->is_pk = (SColumnOptions*)pNode ? ((SColumnOptions*)pNode)->bPrimaryKey : false; return (SNode*)pCol; } diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index 13c4431b62..c2ce77f02b 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -185,7 +185,8 @@ void clearColValArraySml(SArray* pCols) { int32_t num = taosArrayGetSize(pCols); for (int32_t i = 0; i < num; ++i) { SColVal* pCol = taosArrayGet(pCols, i); - if (TSDB_DATA_TYPE_NCHAR == pCol->type || TSDB_DATA_TYPE_GEOMETRY == pCol->type || TSDB_DATA_TYPE_VARBINARY == pCol->type) { + if (TSDB_DATA_TYPE_NCHAR == pCol->value.type || TSDB_DATA_TYPE_GEOMETRY == pCol->value.type || + TSDB_DATA_TYPE_VARBINARY == pCol->value.type) { taosMemoryFreeClear(pCol->value.pData); } pCol->flag = CV_FLAG_NONE; diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 7d10d1f2df..4d62f71b72 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -1661,7 +1661,7 @@ static void clearColValArray(SArray* pCols) { int32_t num = taosArrayGetSize(pCols); for (int32_t i = 0; i < num; ++i) { SColVal* pCol = taosArrayGet(pCols, i); - if (IS_VAR_DATA_TYPE(pCol->type)) { + if (IS_VAR_DATA_TYPE(pCol->value.type)) { taosMemoryFreeClear(pCol->value.pData); } } diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 808ab71b92..3f87f79301 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -350,7 +350,8 @@ int32_t insGetTableDataCxt(SHashObj* pHash, void* id, int32_t idLen, STableMeta* static void destroyColVal(void* p) { SColVal* pVal = p; - if (TSDB_DATA_TYPE_NCHAR == pVal->type || TSDB_DATA_TYPE_GEOMETRY == pVal->type || TSDB_DATA_TYPE_VARBINARY == pVal->type) { + if (TSDB_DATA_TYPE_NCHAR == pVal->value.type || TSDB_DATA_TYPE_GEOMETRY == pVal->value.type || + TSDB_DATA_TYPE_VARBINARY == pVal->value.type) { taosMemoryFreeClear(pVal->value.pData); } } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index da1fd5ef7b..6157aa1733 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -132,6 +132,7 @@ static SKeyword keywordTable[] = { {"JOIN", TK_JOIN}, {"JSON", TK_JSON}, {"KEEP", TK_KEEP}, + {"KEY", TK_KEY}, {"KILL", TK_KILL}, {"LANGUAGE", TK_LANGUAGE}, {"LAST", TK_LAST}, @@ -179,6 +180,7 @@ static SKeyword keywordTable[] = { {"PASS", TK_PASS}, {"PORT", TK_PORT}, {"PPS", TK_PPS}, + {"PRIMARY", TK_PRIMARY}, {"PRECISION", TK_PRECISION}, {"PREV", TK_PREV}, {"PRIVILEGES", TK_PRIVILEGES}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d7da14a949..601725e326 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5808,6 +5808,9 @@ static int32_t tagDefNodeToField(SNodeList* pList, SArray** pArray) { if (pCol->sma) { field.flags |= COL_SMA_ON; } + if (pCol->is_pk) { + field.flags |= COL_IS_KEY; + } taosArrayPush(*pArray, &field); } return TSDB_CODE_SUCCESS; @@ -5907,6 +5910,9 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN if (NULL != taosHashGet(pHash, pTag->colName, len)) { code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DUPLICATED_COLUMN); } + if (TSDB_CODE_SUCCESS == code && pTag->is_pk) { + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAG_IS_PRIMARY_KEY, pTag->colName); + } if (TSDB_CODE_SUCCESS == code && pTag->dataType.type == TSDB_DATA_TYPE_JSON && ntags > 1) { code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG); } @@ -5963,6 +5969,9 @@ static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, in code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FIRST_COLUMN); } } + if (TSDB_CODE_SUCCESS == code && pCol->is_pk && colIndex != 1) { + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SECOND_COL_PK); + } if (TSDB_CODE_SUCCESS == code && pCol->dataType.type == TSDB_DATA_TYPE_JSON) { code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COL_JSON); } @@ -6184,6 +6193,9 @@ static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchem if (pCol->sma) { flags |= COL_SMA_ON; } + if (pCol->is_pk) { + flags |= COL_IS_KEY; + } pSchema->colId = colId; pSchema->type = pCol->dataType.type; pSchema->bytes = calcTypeBytes(pCol->dataType); diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 2a458f7746..f638022ed8 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -195,6 +195,10 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "ORDER BY \"%s\" is ambiguous"; case TSDB_CODE_PAR_NOT_SUPPORT_MULTI_RESULT: return "Operator not supported multi result: %s"; + case TSDB_CODE_PAR_TAG_IS_PRIMARY_KEY: + return "tag %s can not be primary key"; + case TSDB_CODE_PAR_SECOND_COL_PK: + return "primary key column must be second column"; default: return "Unknown error"; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 6f4109d1c4..9dc5e2fb65 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -397,9 +397,10 @@ #define TK_VALUES 348 #define TK_VARIABLE 349 #define TK_WAL 350 -#define TK_ENCODE 351 -#define TK_COMPRESS 352 -#define TK_LEVEL 353 +#define TK_PRIMARY 351 +#define TK_ENCODE 352 +#define TK_COMPRESS 353 +#define TK_LEVEL 354 #endif /**************** End token definitions ***************************************/ @@ -459,29 +460,29 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 518 +#define YYNOCODE 519 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - STokenPair yy21; - int32_t yy396; - SNodeList* yy404; - EFillMode yy466; - SDataType yy504; - SAlterOption yy529; - ENullOrder yy669; - EJoinType yy680; - SToken yy701; - EShowKind yy705; - bool yy733; - EOperatorType yy884; - SNode* yy896; - int8_t yy915; - EOrder yy918; - int64_t yy949; - SShowTablesOption yy989; + EOperatorType yy2; + SDataType yy34; + int64_t yy57; + SShowTablesOption yy61; + SNode* yy110; + int8_t yy203; + EShowKind yy291; + int32_t yy376; + SAlterOption yy491; + EFillMode yy534; + EOrder yy596; + SNodeList* yy652; + EJoinType yy684; + STokenPair yy825; + SToken yy863; + ENullOrder yy991; + bool yy1019; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -497,18 +498,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 860 -#define YYNRULE 657 -#define YYNRULE_WITH_ACTION 657 -#define YYNTOKEN 354 -#define YY_MAX_SHIFT 859 -#define YY_MIN_SHIFTREDUCE 1269 -#define YY_MAX_SHIFTREDUCE 1925 -#define YY_ERROR_ACTION 1926 -#define YY_ACCEPT_ACTION 1927 -#define YY_NO_ACTION 1928 -#define YY_MIN_REDUCE 1929 -#define YY_MAX_REDUCE 2585 +#define YYNSTATE 861 +#define YYNRULE 658 +#define YYNRULE_WITH_ACTION 658 +#define YYNTOKEN 355 +#define YY_MAX_SHIFT 860 +#define YY_MIN_SHIFTREDUCE 1271 +#define YY_MAX_SHIFTREDUCE 1928 +#define YY_ERROR_ACTION 1929 +#define YY_ACCEPT_ACTION 1930 +#define YY_NO_ACTION 1931 +#define YY_MIN_REDUCE 1932 +#define YY_MAX_REDUCE 2589 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -575,825 +576,838 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2797) +#define YY_ACTTAB_COUNT (2854) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 2261, 742, 2120, 2109, 473, 742, 2120, 429, 2176, 472, - /* 10 */ 2169, 2171, 48, 46, 1843, 417, 404, 34, 2258, 729, - /* 20 */ 424, 210, 1684, 41, 40, 138, 2174, 47, 45, 44, - /* 30 */ 43, 42, 615, 36, 1840, 1769, 2015, 1682, 1709, 41, - /* 40 */ 40, 169, 2381, 47, 45, 44, 43, 42, 1712, 405, - /* 50 */ 427, 2122, 721, 147, 680, 724, 2176, 2552, 814, 2174, - /* 60 */ 112, 2080, 41, 40, 414, 1764, 47, 45, 44, 43, - /* 70 */ 42, 19, 186, 1927, 2174, 2558, 205, 148, 1690, 2557, - /* 80 */ 2553, 710, 2552, 2399, 41, 40, 2112, 30, 47, 45, - /* 90 */ 44, 43, 42, 47, 45, 44, 43, 42, 2347, 2242, - /* 100 */ 758, 2556, 396, 395, 856, 2553, 2555, 15, 577, 831, - /* 110 */ 830, 829, 828, 436, 574, 827, 826, 152, 821, 820, - /* 120 */ 819, 818, 817, 816, 815, 151, 809, 808, 807, 435, - /* 130 */ 434, 804, 803, 802, 185, 184, 801, 572, 704, 2380, - /* 140 */ 573, 1972, 2418, 1771, 1772, 114, 2382, 762, 2384, 2385, - /* 150 */ 757, 276, 752, 1710, 1335, 439, 1334, 188, 480, 2471, - /* 160 */ 438, 198, 1888, 420, 2467, 303, 2479, 720, 63, 139, - /* 170 */ 719, 143, 2552, 173, 394, 393, 2163, 617, 207, 1309, - /* 180 */ 1744, 1754, 427, 2122, 1887, 741, 2501, 1770, 1773, 1336, - /* 190 */ 708, 205, 161, 721, 147, 2553, 710, 2194, 1316, 619, - /* 200 */ 433, 432, 1685, 618, 1683, 680, 539, 537, 2552, 370, - /* 210 */ 305, 41, 40, 219, 457, 47, 45, 44, 43, 42, - /* 220 */ 664, 1311, 1314, 1315, 2381, 1691, 2558, 205, 225, 1652, - /* 230 */ 1653, 2553, 710, 741, 1688, 1689, 1741, 759, 1743, 1746, - /* 240 */ 1747, 1748, 1749, 1750, 1751, 1752, 1753, 754, 750, 1762, - /* 250 */ 1763, 1765, 1766, 1767, 1768, 2, 48, 46, 2381, 1929, - /* 260 */ 1710, 368, 1709, 1707, 424, 2399, 1684, 55, 186, 90, - /* 270 */ 523, 724, 89, 542, 381, 703, 1512, 1513, 541, 1769, - /* 280 */ 2347, 1682, 758, 137, 136, 135, 134, 133, 132, 131, - /* 290 */ 130, 129, 2331, 390, 503, 2241, 543, 582, 2300, 2399, - /* 300 */ 2340, 369, 505, 2399, 1839, 723, 203, 2479, 2480, 1764, - /* 310 */ 145, 2484, 483, 811, 2347, 19, 758, 2261, 1798, 240, - /* 320 */ 51, 2380, 1690, 575, 2418, 1980, 663, 114, 2382, 762, - /* 330 */ 2384, 2385, 757, 307, 752, 2259, 729, 150, 88, 157, - /* 340 */ 2442, 2471, 461, 446, 589, 420, 2467, 68, 856, 391, - /* 350 */ 680, 15, 741, 2552, 1741, 2380, 518, 517, 2418, 2357, - /* 360 */ 491, 114, 2382, 762, 2384, 2385, 757, 702, 752, 463, - /* 370 */ 459, 2558, 205, 188, 2111, 2471, 2553, 710, 813, 420, - /* 380 */ 2467, 699, 1799, 1603, 1604, 99, 2361, 1771, 1772, 1952, - /* 390 */ 2248, 2227, 1694, 530, 529, 528, 527, 522, 521, 520, - /* 400 */ 519, 372, 2502, 590, 2254, 509, 508, 507, 506, 500, - /* 410 */ 499, 498, 2557, 493, 492, 389, 1631, 742, 2120, 484, - /* 420 */ 1571, 1572, 1583, 1584, 1744, 1754, 1590, 1602, 1605, 1712, - /* 430 */ 2363, 1770, 1773, 588, 634, 633, 632, 138, 172, 51, - /* 440 */ 752, 624, 144, 628, 620, 2347, 1685, 627, 1683, 2126, - /* 450 */ 63, 1847, 626, 631, 398, 397, 580, 1709, 625, 573, - /* 460 */ 1972, 621, 37, 422, 1793, 1794, 1795, 1796, 1797, 1801, - /* 470 */ 1802, 1803, 1804, 705, 700, 693, 689, 52, 1688, 1689, - /* 480 */ 1741, 2486, 1743, 1746, 1747, 1748, 1749, 1750, 1751, 1752, - /* 490 */ 1753, 754, 750, 1762, 1763, 1765, 1766, 1767, 1768, 2, - /* 500 */ 12, 48, 46, 2381, 652, 489, 2237, 2483, 242, 424, - /* 510 */ 2210, 1684, 575, 592, 1980, 533, 759, 1911, 1982, 650, - /* 520 */ 1477, 648, 272, 271, 1769, 1709, 1682, 798, 163, 162, - /* 530 */ 795, 794, 793, 160, 1468, 790, 789, 788, 1472, 787, - /* 540 */ 1474, 1475, 786, 783, 2399, 1483, 780, 1485, 1486, 777, - /* 550 */ 774, 771, 38, 323, 1764, 2018, 1713, 221, 175, 2347, - /* 560 */ 19, 758, 44, 43, 42, 128, 2058, 1690, 127, 126, - /* 570 */ 125, 124, 123, 122, 121, 120, 119, 230, 742, 2120, - /* 580 */ 41, 40, 2381, 1779, 47, 45, 44, 43, 42, 1709, - /* 590 */ 664, 305, 1713, 856, 800, 759, 15, 2509, 56, 1428, - /* 600 */ 2380, 532, 229, 2418, 307, 661, 114, 2382, 762, 2384, - /* 610 */ 2385, 757, 63, 752, 1427, 307, 1318, 1745, 2572, 1335, - /* 620 */ 2471, 1334, 1708, 2399, 420, 2467, 495, 2237, 634, 633, - /* 630 */ 632, 418, 1771, 1772, 106, 624, 144, 628, 2347, 172, - /* 640 */ 758, 627, 307, 2095, 525, 2237, 626, 631, 398, 397, - /* 650 */ 2125, 176, 625, 1941, 1336, 621, 1876, 41, 40, 2381, - /* 660 */ 2113, 47, 45, 44, 43, 42, 12, 666, 2300, 1744, - /* 670 */ 1754, 516, 759, 1742, 2522, 515, 1770, 1773, 223, 2380, - /* 680 */ 2176, 544, 2418, 514, 1690, 114, 2382, 762, 2384, 2385, - /* 690 */ 757, 1685, 752, 1683, 742, 2120, 228, 2572, 728, 2471, - /* 700 */ 2399, 2170, 2171, 420, 2467, 1684, 696, 695, 1874, 1875, - /* 710 */ 1877, 1878, 1879, 800, 477, 2347, 63, 758, 721, 147, - /* 720 */ 1682, 2104, 375, 1688, 1689, 1741, 1713, 1743, 1746, 1747, - /* 730 */ 1748, 1749, 1750, 1751, 1752, 1753, 754, 750, 1762, 1763, - /* 740 */ 1765, 1766, 1767, 1768, 2, 48, 46, 1774, 3, 1745, - /* 750 */ 767, 766, 765, 424, 201, 1684, 2380, 1859, 2381, 2418, - /* 760 */ 54, 1690, 114, 2382, 762, 2384, 2385, 757, 1769, 752, - /* 770 */ 1682, 759, 1714, 691, 2572, 679, 2471, 307, 41, 40, - /* 780 */ 420, 2467, 47, 45, 44, 43, 42, 856, 2357, 2381, - /* 790 */ 314, 315, 95, 742, 2120, 313, 14, 13, 1764, 2399, - /* 800 */ 742, 2120, 759, 2365, 2545, 1742, 1338, 1339, 1714, 392, - /* 810 */ 471, 1690, 470, 478, 2347, 2361, 758, 41, 40, 2115, - /* 820 */ 497, 47, 45, 44, 43, 42, 2381, 1316, 742, 2120, - /* 830 */ 2399, 204, 2479, 2480, 1432, 145, 2484, 856, 791, 759, - /* 840 */ 49, 2490, 469, 2107, 1951, 2347, 275, 758, 510, 1431, - /* 850 */ 274, 1314, 1315, 611, 610, 2380, 1950, 1416, 2418, 2363, - /* 860 */ 421, 114, 2382, 762, 2384, 2385, 757, 2399, 752, 752, - /* 870 */ 742, 2120, 12, 2572, 10, 2471, 1771, 1772, 95, 420, - /* 880 */ 2467, 307, 2347, 2176, 758, 1685, 2380, 1683, 196, 2418, - /* 890 */ 511, 419, 114, 2382, 762, 2384, 2385, 757, 1418, 752, - /* 900 */ 2347, 2174, 2002, 1812, 2572, 2116, 2471, 61, 742, 2120, - /* 910 */ 420, 2467, 2347, 1744, 1754, 677, 546, 1688, 1689, 98, - /* 920 */ 1770, 1773, 376, 2380, 635, 403, 2418, 654, 512, 114, - /* 930 */ 2382, 762, 2384, 2385, 757, 1685, 752, 1683, 2328, 742, - /* 940 */ 2120, 2572, 1714, 2471, 2176, 742, 2120, 420, 2467, 1949, - /* 950 */ 41, 40, 428, 2381, 47, 45, 44, 43, 42, 591, - /* 960 */ 1713, 744, 2174, 2443, 1918, 2117, 759, 1688, 1689, 1741, - /* 970 */ 9, 1743, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, - /* 980 */ 754, 750, 1762, 1763, 1765, 1766, 1767, 1768, 2, 48, - /* 990 */ 46, 2381, 1930, 2096, 2399, 742, 2120, 424, 746, 1684, - /* 1000 */ 2443, 613, 612, 2557, 759, 2347, 2552, 630, 629, 2347, - /* 1010 */ 2176, 758, 1769, 128, 1682, 278, 127, 126, 125, 124, - /* 1020 */ 123, 122, 121, 120, 119, 2556, 1868, 2176, 737, 2553, - /* 1030 */ 2554, 569, 2399, 2094, 1948, 388, 1947, 1946, 825, 823, - /* 1040 */ 567, 1869, 1764, 563, 559, 2174, 1945, 2347, 2556, 758, - /* 1050 */ 2380, 1944, 2486, 2418, 430, 1690, 114, 2382, 762, 2384, - /* 1060 */ 2385, 757, 172, 752, 1800, 742, 2120, 1943, 2446, 1917, - /* 1070 */ 2471, 1957, 851, 2125, 420, 2467, 2491, 1832, 2482, 173, - /* 1080 */ 1709, 856, 1867, 709, 49, 286, 2552, 2381, 2380, 2123, - /* 1090 */ 2347, 2418, 2347, 2347, 114, 2382, 762, 2384, 2385, 757, - /* 1100 */ 759, 752, 2347, 1940, 708, 205, 2444, 2347, 2471, 2553, - /* 1110 */ 710, 1939, 420, 2467, 149, 709, 1709, 2442, 2552, 2220, - /* 1120 */ 1771, 1772, 200, 2347, 171, 2357, 742, 2120, 2399, 798, - /* 1130 */ 163, 162, 795, 794, 793, 160, 708, 205, 2176, 328, - /* 1140 */ 2366, 2553, 710, 2347, 35, 758, 727, 2381, 742, 2120, - /* 1150 */ 713, 1938, 2361, 2309, 1805, 2000, 2175, 1744, 1754, 2347, - /* 1160 */ 759, 487, 742, 2120, 1770, 1773, 212, 2347, 318, 798, - /* 1170 */ 163, 162, 795, 794, 793, 160, 1714, 637, 1991, 1685, - /* 1180 */ 1937, 1683, 739, 76, 2380, 716, 1936, 2418, 2399, 1935, - /* 1190 */ 114, 2382, 762, 2384, 2385, 757, 2363, 752, 792, 1832, - /* 1200 */ 639, 2167, 745, 2347, 2471, 758, 752, 2347, 420, 2467, - /* 1210 */ 277, 1688, 1689, 1741, 1934, 1743, 1746, 1747, 1748, 1749, - /* 1220 */ 1750, 1751, 1752, 1753, 754, 750, 1762, 1763, 1765, 1766, - /* 1230 */ 1767, 1768, 2, 48, 46, 87, 2347, 140, 1933, 2341, - /* 1240 */ 1745, 424, 2347, 1684, 2380, 2347, 641, 2418, 1932, 86, - /* 1250 */ 115, 2382, 762, 2384, 2385, 757, 1769, 752, 1682, 742, - /* 1260 */ 2120, 653, 742, 2120, 2471, 742, 2120, 161, 2470, 2467, - /* 1270 */ 2347, 796, 2486, 797, 2167, 2097, 2167, 273, 2381, 740, - /* 1280 */ 338, 263, 324, 2153, 261, 431, 1764, 265, 161, 680, - /* 1290 */ 264, 759, 2552, 644, 2347, 687, 1742, 622, 2481, 1690, - /* 1300 */ 638, 636, 619, 623, 2347, 287, 618, 270, 153, 267, - /* 1310 */ 2558, 205, 266, 1989, 749, 2553, 710, 269, 174, 2399, - /* 1320 */ 268, 1413, 656, 344, 655, 856, 2102, 1411, 15, 50, - /* 1330 */ 50, 189, 1742, 2381, 2347, 642, 758, 1920, 1921, 712, - /* 1340 */ 342, 74, 1647, 659, 73, 2124, 759, 161, 72, 100, - /* 1350 */ 283, 71, 2368, 111, 371, 1693, 50, 312, 14, 13, - /* 1360 */ 753, 337, 108, 1650, 1771, 1772, 238, 554, 552, 549, - /* 1370 */ 1863, 75, 158, 161, 2399, 2380, 66, 50, 2418, 199, - /* 1380 */ 408, 115, 2382, 762, 2384, 2385, 757, 1692, 752, 2347, - /* 1390 */ 2059, 758, 1942, 680, 2515, 2471, 2552, 805, 300, 747, - /* 1400 */ 2467, 1744, 1754, 50, 1873, 1872, 292, 63, 1770, 1773, - /* 1410 */ 2370, 769, 159, 714, 2558, 205, 697, 294, 161, 2553, - /* 1420 */ 710, 1390, 726, 1685, 142, 1683, 2400, 721, 147, 806, - /* 1430 */ 2380, 1600, 316, 2418, 141, 2056, 361, 2382, 762, 2384, - /* 1440 */ 2385, 757, 158, 752, 1371, 64, 734, 320, 1459, 1983, - /* 1450 */ 717, 1806, 1755, 1388, 2055, 1688, 1689, 1741, 2246, 1743, - /* 1460 */ 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 754, 750, - /* 1470 */ 1762, 1763, 1765, 1766, 1767, 1768, 2, 1790, 336, 2381, - /* 1480 */ 1973, 433, 432, 2505, 437, 1372, 1490, 1494, 694, 410, - /* 1490 */ 701, 1698, 759, 1501, 84, 83, 476, 406, 731, 218, - /* 1500 */ 2247, 849, 1979, 2164, 1769, 2381, 1691, 673, 2506, 1499, - /* 1510 */ 2516, 722, 468, 466, 302, 299, 306, 164, 756, 2081, - /* 1520 */ 2399, 445, 1696, 367, 5, 440, 455, 386, 453, 452, - /* 1530 */ 448, 444, 441, 469, 1764, 2347, 454, 758, 1717, 2381, - /* 1540 */ 206, 2479, 2480, 465, 145, 2484, 2399, 1690, 464, 467, - /* 1550 */ 213, 214, 759, 216, 1695, 1624, 481, 331, 1707, 1708, - /* 1560 */ 488, 2347, 2381, 758, 227, 490, 494, 496, 535, 501, - /* 1570 */ 513, 2239, 307, 748, 548, 759, 760, 531, 524, 2418, - /* 1580 */ 2399, 526, 115, 2382, 762, 2384, 2385, 757, 534, 752, - /* 1590 */ 547, 536, 545, 232, 233, 2347, 2471, 758, 550, 551, - /* 1600 */ 380, 2467, 2380, 2399, 235, 2418, 553, 555, 360, 2382, - /* 1610 */ 762, 2384, 2385, 757, 755, 752, 743, 2436, 2347, 1715, - /* 1620 */ 758, 570, 4, 571, 579, 578, 243, 581, 92, 665, - /* 1630 */ 1710, 583, 246, 1716, 1718, 584, 2380, 587, 585, 2418, - /* 1640 */ 1719, 614, 177, 2382, 762, 2384, 2385, 757, 249, 752, - /* 1650 */ 251, 2255, 93, 658, 94, 593, 256, 2318, 616, 2380, - /* 1660 */ 725, 645, 2418, 2110, 117, 177, 2382, 762, 2384, 2385, - /* 1670 */ 757, 1699, 752, 1694, 364, 260, 646, 97, 2106, 680, - /* 1680 */ 262, 166, 2552, 2381, 681, 2512, 116, 2108, 660, 2103, - /* 1690 */ 167, 168, 1711, 279, 2315, 154, 759, 669, 2314, 2381, - /* 1700 */ 2558, 205, 668, 1702, 1704, 2553, 710, 667, 2513, 332, - /* 1710 */ 680, 284, 759, 2552, 2301, 282, 675, 750, 1762, 1763, - /* 1720 */ 1765, 1766, 1767, 1768, 2399, 672, 698, 2521, 684, 732, - /* 1730 */ 289, 2558, 205, 291, 707, 8, 2553, 710, 2520, 2347, - /* 1740 */ 2399, 758, 674, 685, 683, 298, 411, 2493, 682, 295, - /* 1750 */ 293, 718, 1832, 180, 715, 2347, 2575, 758, 146, 2381, - /* 1760 */ 1712, 1837, 192, 296, 1835, 2487, 308, 297, 155, 730, - /* 1770 */ 735, 2269, 759, 2268, 2267, 416, 333, 334, 736, 301, - /* 1780 */ 2380, 2381, 156, 2418, 208, 2121, 178, 2382, 762, 2384, - /* 1790 */ 2385, 757, 335, 752, 759, 2381, 2380, 105, 2551, 2418, - /* 1800 */ 2399, 1, 115, 2382, 762, 2384, 2385, 757, 759, 752, - /* 1810 */ 62, 2452, 2168, 107, 2381, 2347, 2471, 758, 326, 1293, - /* 1820 */ 764, 2468, 2399, 853, 339, 850, 165, 759, 409, 855, - /* 1830 */ 363, 348, 377, 53, 385, 378, 2399, 2347, 341, 758, - /* 1840 */ 711, 2573, 343, 362, 2339, 352, 2338, 2337, 81, 2332, - /* 1850 */ 442, 2347, 443, 758, 447, 2399, 2380, 1675, 1676, 2418, - /* 1860 */ 211, 415, 354, 2382, 762, 2384, 2385, 757, 2330, 752, - /* 1870 */ 2347, 449, 758, 450, 451, 1674, 2329, 387, 2380, 2327, - /* 1880 */ 456, 2418, 2326, 2325, 361, 2382, 762, 2384, 2385, 757, - /* 1890 */ 458, 752, 2380, 2381, 460, 2418, 2324, 462, 178, 2382, - /* 1900 */ 762, 2384, 2385, 757, 1663, 752, 756, 2305, 706, 215, - /* 1910 */ 2304, 2380, 217, 1627, 2418, 82, 1626, 361, 2382, 762, - /* 1920 */ 2384, 2385, 757, 662, 752, 2282, 2281, 2280, 474, 475, - /* 1930 */ 2381, 2279, 2278, 2229, 2399, 479, 1570, 2226, 482, 258, - /* 1940 */ 2225, 859, 2219, 759, 486, 485, 2216, 220, 2215, 2347, - /* 1950 */ 85, 758, 2214, 2574, 2213, 181, 2218, 330, 222, 2217, - /* 1960 */ 2212, 2381, 2211, 2209, 609, 605, 601, 597, 226, 257, - /* 1970 */ 2208, 2399, 2207, 195, 759, 224, 502, 423, 2206, 504, - /* 1980 */ 2204, 2203, 847, 843, 839, 835, 2347, 327, 758, 2202, - /* 1990 */ 2380, 2201, 2224, 2418, 2200, 2199, 360, 2382, 762, 2384, - /* 2000 */ 2385, 757, 2399, 752, 2198, 2437, 2222, 2205, 425, 2197, - /* 2010 */ 96, 2196, 2195, 255, 2193, 2192, 2191, 2347, 2190, 758, - /* 2020 */ 2189, 2188, 2187, 2186, 91, 2185, 2184, 2380, 113, 2223, - /* 2030 */ 2418, 321, 2221, 361, 2382, 762, 2384, 2385, 757, 1576, - /* 2040 */ 752, 2381, 2183, 2182, 2181, 231, 2180, 538, 2179, 540, - /* 2050 */ 2178, 2177, 1429, 373, 759, 1433, 2021, 2020, 2380, 2019, - /* 2060 */ 374, 2418, 2381, 738, 361, 2382, 762, 2384, 2385, 757, - /* 2070 */ 234, 752, 1425, 236, 2017, 759, 2014, 556, 2381, 245, - /* 2080 */ 558, 2013, 2399, 562, 237, 557, 560, 561, 254, 247, - /* 2090 */ 2006, 759, 564, 1993, 566, 252, 586, 2347, 2381, 758, - /* 2100 */ 568, 1968, 187, 2399, 565, 239, 310, 78, 1317, 1967, - /* 2110 */ 2367, 759, 79, 309, 244, 197, 576, 2303, 2347, 2399, - /* 2120 */ 758, 241, 2299, 2289, 2277, 248, 250, 2276, 253, 2253, - /* 2130 */ 2098, 2016, 280, 2012, 2347, 594, 758, 595, 657, 2399, - /* 2140 */ 1364, 2418, 596, 2010, 356, 2382, 762, 2384, 2385, 757, - /* 2150 */ 598, 752, 600, 599, 2347, 2008, 758, 602, 2381, 2380, - /* 2160 */ 604, 2005, 2418, 603, 1988, 346, 2382, 762, 2384, 2385, - /* 2170 */ 757, 759, 752, 606, 2381, 2380, 607, 1986, 2418, 608, - /* 2180 */ 1987, 345, 2382, 762, 2384, 2385, 757, 759, 752, 1985, - /* 2190 */ 1964, 2100, 65, 259, 2381, 2380, 1506, 1505, 2418, 2399, - /* 2200 */ 2099, 347, 2382, 762, 2384, 2385, 757, 759, 752, 1415, - /* 2210 */ 1414, 1412, 822, 1410, 2347, 2399, 758, 2003, 1409, 1408, - /* 2220 */ 1407, 1406, 1403, 1402, 1401, 824, 399, 2001, 400, 1992, - /* 2230 */ 2347, 1400, 758, 401, 1990, 2399, 402, 1963, 643, 1962, - /* 2240 */ 640, 1961, 647, 1960, 649, 1959, 651, 2381, 118, 1657, - /* 2250 */ 2347, 29, 758, 1659, 1661, 2380, 1656, 2302, 2418, 69, - /* 2260 */ 759, 353, 2382, 762, 2384, 2385, 757, 57, 752, 281, - /* 2270 */ 2298, 2380, 2381, 58, 2418, 1633, 1635, 357, 2382, 762, - /* 2280 */ 2384, 2385, 757, 2288, 752, 759, 670, 170, 2399, 671, - /* 2290 */ 285, 2380, 2275, 1637, 2418, 2274, 1612, 349, 2382, 762, - /* 2300 */ 2384, 2385, 757, 2347, 752, 758, 2557, 2381, 1611, 20, - /* 2310 */ 676, 1890, 686, 2399, 17, 31, 288, 678, 1864, 407, - /* 2320 */ 759, 6, 7, 690, 692, 2381, 21, 22, 2347, 688, - /* 2330 */ 758, 290, 191, 1871, 1858, 202, 2368, 179, 759, 190, - /* 2340 */ 32, 33, 80, 2381, 2380, 67, 24, 2418, 2399, 23, - /* 2350 */ 358, 2382, 762, 2384, 2385, 757, 759, 752, 1910, 1911, - /* 2360 */ 1905, 1904, 412, 2347, 18, 758, 2399, 1909, 1908, 2380, - /* 2370 */ 413, 1829, 2418, 1828, 59, 350, 2382, 762, 2384, 2385, - /* 2380 */ 757, 2347, 752, 758, 2399, 304, 60, 182, 2273, 2252, - /* 2390 */ 102, 101, 25, 2251, 103, 193, 2381, 311, 1866, 2347, - /* 2400 */ 322, 758, 26, 317, 2380, 70, 11, 2418, 104, 759, - /* 2410 */ 359, 2382, 762, 2384, 2385, 757, 108, 752, 13, 1781, - /* 2420 */ 319, 2381, 2380, 1780, 1700, 2418, 733, 1791, 351, 2382, - /* 2430 */ 762, 2384, 2385, 757, 759, 752, 1759, 2399, 763, 2421, - /* 2440 */ 2380, 751, 39, 2418, 183, 1757, 365, 2382, 762, 2384, - /* 2450 */ 2385, 757, 2347, 752, 758, 1756, 2381, 16, 194, 1734, - /* 2460 */ 1925, 27, 2399, 1726, 28, 1924, 1923, 1491, 768, 759, - /* 2470 */ 426, 770, 772, 1488, 773, 776, 2381, 2347, 1487, 758, - /* 2480 */ 1484, 761, 775, 778, 779, 781, 1478, 782, 784, 759, - /* 2490 */ 1476, 785, 2381, 2380, 1482, 325, 2418, 2399, 109, 366, - /* 2500 */ 2382, 762, 2384, 2385, 757, 759, 752, 1481, 110, 1480, - /* 2510 */ 1500, 1479, 2347, 77, 758, 1496, 1397, 2399, 2380, 1362, - /* 2520 */ 799, 2418, 1394, 1393, 2393, 2382, 762, 2384, 2385, 757, - /* 2530 */ 1423, 752, 2347, 2399, 758, 1392, 1391, 1389, 1387, 1386, - /* 2540 */ 1385, 810, 1422, 812, 209, 1383, 1382, 1381, 2347, 1380, - /* 2550 */ 758, 1379, 2381, 2380, 1378, 1377, 2418, 1417, 1419, 2392, - /* 2560 */ 2382, 762, 2384, 2385, 757, 759, 752, 1374, 1373, 1370, - /* 2570 */ 1369, 1368, 2381, 2380, 1367, 2011, 2418, 832, 2009, 2391, - /* 2580 */ 2382, 762, 2384, 2385, 757, 759, 752, 833, 2381, 2380, - /* 2590 */ 834, 836, 2418, 2399, 837, 382, 2382, 762, 2384, 2385, - /* 2600 */ 757, 759, 752, 838, 2007, 840, 841, 842, 2347, 2004, - /* 2610 */ 758, 844, 846, 2399, 845, 1984, 848, 1306, 1958, 1294, - /* 2620 */ 852, 329, 854, 1928, 1686, 340, 857, 858, 2347, 2399, - /* 2630 */ 758, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, - /* 2640 */ 1928, 1928, 1928, 1928, 2347, 1928, 758, 1928, 1928, 2380, - /* 2650 */ 1928, 1928, 2418, 1928, 1928, 383, 2382, 762, 2384, 2385, - /* 2660 */ 757, 2381, 752, 1928, 1928, 1928, 1928, 1928, 1928, 2380, - /* 2670 */ 1928, 1928, 2418, 1928, 759, 379, 2382, 762, 2384, 2385, - /* 2680 */ 757, 1928, 752, 1928, 1928, 2380, 2381, 1928, 2418, 1928, - /* 2690 */ 1928, 384, 2382, 762, 2384, 2385, 757, 1928, 752, 759, - /* 2700 */ 1928, 1928, 2399, 1928, 1928, 1928, 1928, 1928, 1928, 1928, - /* 2710 */ 1928, 1928, 1928, 1928, 1928, 1928, 1928, 2347, 1928, 758, - /* 2720 */ 1928, 1928, 1928, 1928, 1928, 1928, 1928, 2399, 1928, 1928, - /* 2730 */ 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, - /* 2740 */ 1928, 1928, 2347, 1928, 758, 1928, 1928, 1928, 1928, 1928, - /* 2750 */ 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 760, 1928, - /* 2760 */ 1928, 2418, 1928, 1928, 356, 2382, 762, 2384, 2385, 757, - /* 2770 */ 1928, 752, 1928, 1928, 1928, 1928, 1928, 1928, 1928, 1928, - /* 2780 */ 1928, 1928, 1928, 2380, 1928, 1928, 2418, 1928, 1928, 355, - /* 2790 */ 2382, 762, 2384, 2385, 757, 1928, 752, + /* 0 */ 2264, 742, 2123, 2112, 473, 742, 2123, 429, 2179, 472, + /* 10 */ 2172, 2174, 48, 46, 1845, 417, 404, 34, 2261, 729, + /* 20 */ 424, 210, 1686, 41, 40, 138, 2177, 47, 45, 44, + /* 30 */ 43, 42, 615, 36, 95, 1771, 2018, 1684, 173, 41, + /* 40 */ 40, 169, 2384, 47, 45, 44, 43, 42, 2126, 405, + /* 50 */ 427, 2125, 721, 147, 680, 724, 2179, 2555, 1955, 2177, + /* 60 */ 112, 2119, 41, 40, 414, 1766, 47, 45, 44, 43, + /* 70 */ 42, 19, 186, 1930, 2177, 2561, 205, 148, 1692, 2560, + /* 80 */ 2556, 710, 2555, 2402, 41, 40, 2115, 30, 47, 45, + /* 90 */ 44, 43, 42, 47, 45, 44, 43, 42, 2350, 2245, + /* 100 */ 758, 2559, 396, 395, 857, 2556, 2558, 15, 2197, 832, + /* 110 */ 831, 830, 829, 436, 2350, 828, 827, 152, 822, 821, + /* 120 */ 820, 819, 818, 817, 816, 151, 810, 809, 808, 435, + /* 130 */ 434, 805, 804, 803, 185, 184, 802, 572, 704, 2383, + /* 140 */ 573, 1975, 2421, 1773, 1774, 114, 2385, 762, 2387, 2388, + /* 150 */ 757, 1715, 752, 1712, 1337, 439, 1336, 188, 480, 2474, + /* 160 */ 438, 198, 1890, 420, 2470, 303, 2482, 720, 63, 139, + /* 170 */ 719, 143, 2555, 173, 394, 393, 2166, 617, 207, 1311, + /* 180 */ 1746, 1756, 427, 2125, 1889, 3, 2504, 1772, 1775, 1338, + /* 190 */ 708, 205, 2098, 721, 147, 2556, 710, 54, 1318, 619, + /* 200 */ 433, 432, 1687, 618, 1685, 680, 539, 537, 2555, 370, + /* 210 */ 741, 41, 40, 219, 577, 47, 45, 44, 43, 42, + /* 220 */ 574, 1313, 1316, 1317, 2384, 1693, 2561, 205, 225, 38, + /* 230 */ 323, 2556, 710, 533, 1690, 1691, 1743, 759, 1745, 1748, + /* 240 */ 1749, 1750, 1751, 1752, 1753, 1754, 1755, 754, 750, 1764, + /* 250 */ 1765, 1767, 1768, 1769, 1770, 2, 48, 46, 2384, 1932, + /* 260 */ 1712, 368, 801, 1709, 424, 2402, 1686, 518, 517, 90, + /* 270 */ 523, 724, 89, 542, 382, 68, 1514, 1515, 541, 1771, + /* 280 */ 2350, 1684, 758, 137, 136, 135, 134, 133, 132, 131, + /* 290 */ 130, 129, 489, 2240, 503, 230, 543, 51, 186, 2402, + /* 300 */ 2343, 369, 505, 2107, 372, 723, 203, 2482, 2483, 1766, + /* 310 */ 145, 2487, 483, 196, 2350, 19, 758, 2264, 1800, 532, + /* 320 */ 229, 2383, 1692, 390, 2421, 2244, 664, 114, 2385, 762, + /* 330 */ 2387, 2388, 757, 307, 752, 2262, 729, 150, 88, 157, + /* 340 */ 2445, 2474, 741, 1711, 221, 420, 2470, 2213, 857, 391, + /* 350 */ 680, 15, 1715, 2555, 1743, 2383, 1954, 703, 2421, 2360, + /* 360 */ 491, 114, 2385, 762, 2387, 2388, 757, 1716, 752, 742, + /* 370 */ 2123, 2561, 205, 188, 2114, 2474, 2556, 710, 63, 420, + /* 380 */ 2470, 592, 1801, 1605, 1606, 2402, 2364, 1773, 1774, 56, + /* 390 */ 2251, 2230, 1696, 530, 529, 528, 527, 522, 521, 520, + /* 400 */ 519, 374, 2505, 582, 2303, 509, 508, 507, 506, 500, + /* 410 */ 499, 498, 2350, 493, 492, 389, 1711, 742, 2123, 484, + /* 420 */ 1573, 1574, 1842, 1711, 1746, 1756, 1592, 1604, 1607, 51, + /* 430 */ 2366, 1772, 1775, 52, 634, 633, 632, 138, 2173, 2174, + /* 440 */ 752, 624, 144, 628, 620, 801, 1687, 627, 1685, 702, + /* 450 */ 1849, 1781, 626, 631, 398, 397, 1711, 1711, 625, 2560, + /* 460 */ 664, 621, 37, 422, 1795, 1796, 1797, 1798, 1799, 1803, + /* 470 */ 1804, 1805, 1806, 176, 1711, 1944, 1714, 741, 1690, 1691, + /* 480 */ 1743, 1318, 1745, 1748, 1749, 1750, 1751, 1752, 1753, 1754, + /* 490 */ 1755, 754, 750, 1764, 1765, 1767, 1768, 1769, 1770, 2, + /* 500 */ 12, 48, 46, 2384, 1933, 1316, 1317, 457, 516, 424, + /* 510 */ 63, 1686, 515, 12, 200, 10, 759, 240, 1985, 1878, + /* 520 */ 514, 575, 1953, 1983, 1771, 128, 1684, 663, 127, 126, + /* 530 */ 125, 124, 123, 122, 121, 120, 119, 666, 2303, 2384, + /* 540 */ 661, 41, 40, 307, 2402, 47, 45, 44, 43, 42, + /* 550 */ 588, 2344, 759, 1715, 1766, 768, 767, 766, 765, 2350, + /* 560 */ 19, 758, 1340, 1341, 1913, 721, 147, 1692, 1716, 696, + /* 570 */ 695, 1876, 1877, 1879, 1880, 1881, 1585, 1586, 2350, 580, + /* 580 */ 2402, 128, 573, 1975, 127, 126, 125, 124, 123, 122, + /* 590 */ 121, 120, 119, 857, 307, 2350, 15, 758, 307, 2384, + /* 600 */ 2383, 680, 95, 2421, 2555, 1802, 114, 2385, 762, 2387, + /* 610 */ 2388, 757, 759, 752, 2512, 1686, 1747, 1747, 2575, 392, + /* 620 */ 2474, 12, 2561, 205, 420, 2470, 2005, 2556, 710, 2118, + /* 630 */ 1684, 2312, 1773, 1774, 1747, 461, 2383, 2360, 305, 2421, + /* 640 */ 2402, 622, 114, 2385, 762, 2387, 2388, 757, 635, 752, + /* 650 */ 611, 610, 2369, 589, 2449, 2350, 2474, 758, 495, 2240, + /* 660 */ 420, 2470, 463, 459, 2364, 1415, 2179, 525, 2240, 1746, + /* 670 */ 1756, 1692, 1744, 1744, 388, 307, 1772, 1775, 204, 2482, + /* 680 */ 2483, 175, 145, 2487, 2177, 35, 721, 147, 277, 2061, + /* 690 */ 1744, 1687, 1841, 1685, 242, 1807, 2383, 857, 575, 2421, + /* 700 */ 1983, 1692, 114, 2385, 762, 2387, 2388, 757, 2366, 752, + /* 710 */ 223, 172, 590, 2257, 2575, 201, 2474, 1952, 752, 228, + /* 720 */ 420, 2470, 2129, 1690, 1691, 1743, 792, 1745, 1748, 1749, + /* 730 */ 1750, 1751, 1752, 1753, 1754, 1755, 754, 750, 1764, 1765, + /* 740 */ 1767, 1768, 1769, 1770, 2, 48, 46, 1776, 2179, 2384, + /* 750 */ 2360, 742, 2123, 424, 709, 1686, 419, 2555, 328, 742, + /* 760 */ 2123, 1337, 759, 1336, 2525, 2368, 2177, 659, 1771, 1716, + /* 770 */ 1684, 477, 2110, 2350, 1870, 708, 205, 2364, 2384, 478, + /* 780 */ 2556, 710, 799, 163, 162, 796, 795, 794, 160, 1871, + /* 790 */ 2402, 759, 2099, 691, 1418, 1687, 1338, 1685, 1766, 206, + /* 800 */ 2482, 2483, 1951, 145, 2487, 2350, 1950, 758, 41, 40, + /* 810 */ 418, 1692, 47, 45, 44, 43, 42, 680, 172, 2402, + /* 820 */ 2555, 2366, 421, 2179, 2179, 742, 2123, 1690, 1691, 2128, + /* 830 */ 1869, 752, 428, 2105, 2350, 1420, 758, 857, 2561, 205, + /* 840 */ 49, 728, 2177, 2556, 710, 497, 2383, 2560, 2384, 2421, + /* 850 */ 2555, 1949, 114, 2385, 762, 2387, 2388, 757, 2350, 752, + /* 860 */ 2223, 759, 2350, 1948, 2575, 9, 2474, 742, 2123, 2559, + /* 870 */ 420, 2470, 2127, 2556, 2557, 2383, 1773, 1774, 2421, 652, + /* 880 */ 140, 114, 2385, 762, 2387, 2388, 757, 510, 752, 2402, + /* 890 */ 742, 2123, 86, 2575, 650, 2474, 648, 272, 271, 420, + /* 900 */ 2470, 1947, 487, 2384, 2350, 812, 758, 2350, 815, 1430, + /* 910 */ 511, 2083, 679, 1746, 1756, 2559, 759, 276, 2548, 2350, + /* 920 */ 1772, 1775, 742, 2123, 1429, 1714, 623, 569, 799, 163, + /* 930 */ 162, 796, 795, 794, 160, 1687, 567, 1685, 283, 563, + /* 940 */ 559, 430, 512, 199, 2402, 2383, 742, 2123, 2421, 172, + /* 950 */ 1413, 177, 2385, 762, 2387, 2388, 757, 2350, 752, 2350, + /* 960 */ 2128, 758, 44, 43, 42, 1946, 591, 1690, 1691, 1743, + /* 970 */ 814, 1745, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, + /* 980 */ 754, 750, 1764, 1765, 1767, 1768, 1769, 1770, 2, 48, + /* 990 */ 46, 544, 1943, 681, 2515, 1654, 1655, 424, 2179, 1686, + /* 1000 */ 2383, 1942, 2384, 2421, 753, 1941, 114, 2385, 762, 2387, + /* 1010 */ 2388, 757, 1771, 752, 1684, 756, 737, 1940, 2575, 337, + /* 1020 */ 2474, 2350, 41, 40, 420, 2470, 47, 45, 44, 43, + /* 1030 */ 42, 2097, 41, 40, 742, 2123, 47, 45, 44, 43, + /* 1040 */ 42, 1939, 1766, 2402, 61, 14, 13, 1715, 2350, 1479, + /* 1050 */ 149, 665, 677, 2445, 2120, 1692, 2021, 2350, 2350, 793, + /* 1060 */ 758, 2350, 2170, 1470, 791, 790, 789, 1474, 788, 1476, + /* 1070 */ 1477, 787, 784, 2350, 1485, 781, 1487, 1488, 778, 775, + /* 1080 */ 772, 857, 2062, 2384, 49, 41, 40, 305, 63, 47, + /* 1090 */ 45, 44, 43, 42, 1834, 1938, 759, 2350, 2493, 2383, + /* 1100 */ 2489, 680, 2421, 1434, 2555, 360, 2385, 762, 2387, 2388, + /* 1110 */ 757, 755, 752, 743, 2439, 742, 2123, 744, 1433, 2446, + /* 1120 */ 1773, 1774, 2561, 205, 2402, 725, 2486, 2556, 710, 634, + /* 1130 */ 633, 632, 1861, 630, 629, 278, 624, 144, 628, 2350, + /* 1140 */ 2489, 758, 627, 699, 613, 612, 1711, 626, 631, 398, + /* 1150 */ 397, 2350, 1814, 625, 742, 2123, 621, 1746, 1756, 746, + /* 1160 */ 1945, 2446, 826, 824, 1772, 1775, 2485, 799, 163, 162, + /* 1170 */ 796, 795, 794, 160, 286, 680, 1960, 852, 2555, 1687, + /* 1180 */ 2383, 1685, 471, 2421, 470, 546, 114, 2385, 762, 2387, + /* 1190 */ 2388, 757, 2179, 752, 314, 315, 2561, 205, 2575, 313, + /* 1200 */ 2474, 2556, 710, 275, 420, 2470, 712, 274, 1920, 1937, + /* 1210 */ 2178, 1690, 1691, 1743, 469, 1745, 1748, 1749, 1750, 1751, + /* 1220 */ 1752, 1753, 1754, 1755, 754, 750, 1764, 1765, 1767, 1768, + /* 1230 */ 1769, 1770, 2, 48, 46, 705, 700, 693, 689, 713, + /* 1240 */ 1936, 424, 2384, 1686, 106, 709, 1320, 1935, 2555, 742, + /* 1250 */ 2123, 797, 1710, 307, 2170, 759, 1771, 798, 1684, 171, + /* 1260 */ 2170, 742, 2123, 1716, 258, 2350, 708, 205, 2334, 727, + /* 1270 */ 2116, 2556, 710, 2494, 1834, 2384, 98, 742, 2123, 377, + /* 1280 */ 181, 318, 403, 2402, 654, 2489, 1766, 2331, 759, 609, + /* 1290 */ 605, 601, 597, 716, 257, 161, 2350, 739, 2350, 1692, + /* 1300 */ 758, 742, 2123, 2350, 742, 2123, 742, 2123, 76, 161, + /* 1310 */ 619, 2484, 338, 1919, 618, 2156, 2402, 2518, 174, 446, + /* 1320 */ 99, 740, 2100, 344, 324, 857, 431, 111, 15, 263, + /* 1330 */ 2384, 2350, 261, 758, 265, 96, 108, 264, 255, 2383, + /* 1340 */ 342, 74, 2421, 759, 73, 178, 2385, 762, 2387, 2388, + /* 1350 */ 757, 1633, 752, 267, 371, 153, 266, 656, 269, 655, + /* 1360 */ 87, 268, 1744, 697, 1773, 1774, 238, 554, 552, 549, + /* 1370 */ 55, 2402, 2383, 2003, 161, 2421, 1994, 1695, 114, 2385, + /* 1380 */ 762, 2387, 2388, 757, 1649, 752, 2350, 749, 758, 1992, + /* 1390 */ 2447, 300, 2474, 1922, 1923, 637, 420, 2470, 639, 711, + /* 1400 */ 2576, 1746, 1756, 687, 245, 50, 1986, 63, 1772, 1775, + /* 1410 */ 287, 642, 50, 254, 247, 189, 14, 13, 161, 142, + /* 1420 */ 252, 586, 294, 1687, 1694, 1685, 50, 2383, 312, 806, + /* 1430 */ 2421, 2403, 75, 115, 2385, 762, 2387, 2388, 757, 244, + /* 1440 */ 752, 158, 161, 66, 50, 64, 50, 2474, 2059, 1652, + /* 1450 */ 2371, 2473, 2470, 1392, 100, 1690, 1691, 1743, 850, 1745, + /* 1460 */ 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 754, 750, + /* 1470 */ 1764, 1765, 1767, 1768, 1769, 1770, 2, 2058, 1865, 2384, + /* 1480 */ 1875, 433, 432, 1976, 770, 159, 161, 1874, 694, 2249, + /* 1490 */ 292, 1700, 759, 726, 84, 83, 476, 1373, 807, 218, + /* 1500 */ 2508, 1602, 714, 316, 1771, 410, 1693, 734, 2373, 641, + /* 1510 */ 701, 406, 468, 466, 731, 212, 320, 1461, 1808, 1757, + /* 1520 */ 2402, 336, 1390, 367, 653, 437, 455, 141, 158, 452, + /* 1530 */ 448, 444, 441, 469, 1766, 2350, 2250, 758, 1374, 2384, + /* 1540 */ 273, 1982, 2167, 673, 1698, 2509, 2519, 1692, 722, 302, + /* 1550 */ 1792, 299, 759, 2084, 5, 306, 644, 445, 717, 1492, + /* 1560 */ 1496, 1503, 440, 638, 636, 386, 453, 454, 1719, 465, + /* 1570 */ 270, 464, 307, 748, 214, 2384, 2383, 213, 216, 2421, + /* 1580 */ 2402, 467, 114, 2385, 762, 2387, 2388, 757, 759, 752, + /* 1590 */ 1626, 1697, 331, 1709, 745, 2350, 2474, 758, 481, 1710, + /* 1600 */ 420, 2470, 1501, 164, 488, 227, 490, 494, 496, 535, + /* 1610 */ 501, 72, 513, 531, 71, 524, 2402, 2242, 534, 526, + /* 1620 */ 536, 547, 548, 545, 233, 550, 235, 232, 553, 555, + /* 1630 */ 551, 2350, 1717, 758, 570, 578, 2383, 4, 581, 2421, + /* 1640 */ 571, 579, 115, 2385, 762, 2387, 2388, 757, 243, 752, + /* 1650 */ 1712, 583, 1718, 584, 92, 1720, 2474, 2384, 587, 246, + /* 1660 */ 747, 2470, 585, 249, 251, 1721, 593, 2258, 93, 94, + /* 1670 */ 759, 1701, 760, 1696, 256, 2421, 614, 662, 115, 2385, + /* 1680 */ 762, 2387, 2388, 757, 117, 752, 645, 2384, 646, 364, + /* 1690 */ 616, 2113, 2474, 260, 660, 860, 381, 2470, 2402, 658, + /* 1700 */ 759, 2109, 262, 1704, 1706, 166, 116, 2111, 2106, 167, + /* 1710 */ 168, 330, 2321, 2350, 97, 758, 154, 750, 1764, 1765, + /* 1720 */ 1767, 1768, 1769, 1770, 279, 1713, 2318, 195, 2402, 2317, + /* 1730 */ 668, 332, 667, 672, 669, 284, 848, 844, 840, 836, + /* 1740 */ 732, 327, 2384, 2350, 675, 758, 684, 698, 707, 2304, + /* 1750 */ 282, 2524, 289, 2523, 2383, 759, 674, 2421, 2384, 8, + /* 1760 */ 115, 2385, 762, 2387, 2388, 757, 291, 752, 2496, 685, + /* 1770 */ 293, 759, 683, 682, 2474, 180, 298, 411, 718, 2471, + /* 1780 */ 295, 2578, 113, 2402, 2383, 321, 715, 2421, 297, 408, + /* 1790 */ 177, 2385, 762, 2387, 2388, 757, 146, 752, 2350, 2402, + /* 1800 */ 758, 1714, 1834, 2490, 1839, 409, 1837, 192, 308, 2554, + /* 1810 */ 155, 730, 208, 333, 2350, 2384, 758, 738, 2272, 296, + /* 1820 */ 334, 1, 735, 156, 736, 105, 2271, 335, 759, 62, + /* 1830 */ 301, 2384, 2270, 2516, 416, 2455, 2124, 107, 764, 2383, + /* 1840 */ 2171, 339, 2421, 326, 759, 361, 2385, 762, 2387, 2388, + /* 1850 */ 757, 1295, 752, 854, 851, 2383, 2402, 363, 2421, 856, + /* 1860 */ 310, 361, 2385, 762, 2387, 2388, 757, 309, 752, 53, + /* 1870 */ 378, 2350, 2402, 758, 165, 379, 348, 362, 341, 352, + /* 1880 */ 373, 2342, 343, 2341, 2340, 81, 280, 2350, 2384, 758, + /* 1890 */ 2335, 442, 443, 1677, 1678, 211, 447, 2333, 449, 450, + /* 1900 */ 451, 756, 1676, 2332, 387, 2330, 456, 2329, 458, 2328, + /* 1910 */ 460, 2384, 2383, 462, 1665, 2421, 2327, 2308, 354, 2385, + /* 1920 */ 762, 2387, 2388, 757, 759, 752, 215, 2307, 2383, 2402, + /* 1930 */ 217, 2421, 82, 1629, 178, 2385, 762, 2387, 2388, 757, + /* 1940 */ 1628, 752, 2285, 2384, 2350, 2284, 758, 2283, 474, 475, + /* 1950 */ 2282, 2281, 2402, 2232, 2229, 479, 759, 1572, 415, 482, + /* 1960 */ 2228, 2222, 485, 486, 706, 2219, 2218, 2350, 220, 758, + /* 1970 */ 222, 85, 2217, 2216, 2221, 2220, 2215, 2214, 2212, 2211, + /* 1980 */ 2210, 502, 224, 2209, 2402, 2383, 504, 2207, 2421, 2577, + /* 1990 */ 423, 360, 2385, 762, 2387, 2388, 757, 2206, 752, 2350, + /* 2000 */ 2440, 758, 2205, 2204, 2227, 2203, 2202, 2201, 2383, 2225, + /* 2010 */ 2208, 2421, 2200, 2199, 361, 2385, 762, 2387, 2388, 757, + /* 2020 */ 2384, 752, 2198, 2196, 2195, 2194, 2193, 2192, 2191, 2190, + /* 2030 */ 226, 91, 2384, 759, 2189, 2188, 2187, 2226, 2224, 2186, + /* 2040 */ 2383, 1578, 2184, 2421, 2384, 759, 361, 2385, 762, 2387, + /* 2050 */ 2388, 757, 2185, 752, 2183, 2182, 2384, 759, 231, 2181, + /* 2060 */ 540, 2402, 538, 2180, 375, 1431, 1435, 425, 376, 759, + /* 2070 */ 2024, 2023, 2022, 2402, 2020, 2017, 2350, 1427, 758, 2370, + /* 2080 */ 234, 236, 237, 556, 557, 2402, 2016, 558, 2350, 2009, + /* 2090 */ 758, 562, 566, 560, 564, 1996, 1971, 2402, 561, 565, + /* 2100 */ 2350, 568, 758, 239, 78, 1319, 187, 1970, 241, 197, + /* 2110 */ 576, 79, 2350, 250, 758, 2306, 2302, 2383, 2292, 2280, + /* 2120 */ 2421, 2279, 248, 361, 2385, 762, 2387, 2388, 757, 657, + /* 2130 */ 752, 253, 2421, 2384, 2256, 356, 2385, 762, 2387, 2388, + /* 2140 */ 757, 2383, 752, 2101, 2421, 2019, 759, 346, 2385, 762, + /* 2150 */ 2387, 2388, 757, 2383, 752, 1366, 2421, 2384, 2015, 345, + /* 2160 */ 2385, 762, 2387, 2388, 757, 594, 752, 596, 595, 2013, + /* 2170 */ 759, 599, 598, 2384, 2402, 600, 2011, 602, 603, 604, + /* 2180 */ 2008, 606, 607, 608, 1991, 1989, 759, 1990, 1988, 2350, + /* 2190 */ 1967, 758, 2103, 65, 259, 1507, 1508, 2102, 2402, 1417, + /* 2200 */ 1416, 1414, 1412, 1411, 1410, 1409, 2006, 1408, 823, 1405, + /* 2210 */ 825, 1404, 2004, 2350, 2402, 758, 1403, 399, 1402, 1995, + /* 2220 */ 400, 401, 1993, 402, 640, 1966, 643, 1965, 1964, 2350, + /* 2230 */ 2383, 758, 1963, 2421, 1962, 651, 347, 2385, 762, 2387, + /* 2240 */ 2388, 757, 647, 752, 649, 2384, 118, 1659, 1661, 2305, + /* 2250 */ 1663, 281, 1658, 29, 2383, 69, 2301, 2421, 759, 57, + /* 2260 */ 353, 2385, 762, 2387, 2388, 757, 58, 752, 1635, 1637, + /* 2270 */ 2383, 2384, 2291, 2421, 670, 1639, 357, 2385, 762, 2387, + /* 2280 */ 2388, 757, 671, 752, 759, 2278, 2402, 285, 2277, 2560, + /* 2290 */ 170, 1614, 676, 1613, 678, 20, 686, 17, 2384, 1892, + /* 2300 */ 31, 2350, 407, 758, 1866, 6, 21, 288, 7, 690, + /* 2310 */ 688, 759, 2402, 22, 191, 202, 290, 1873, 2371, 692, + /* 2320 */ 33, 67, 24, 304, 179, 190, 60, 2350, 2384, 758, + /* 2330 */ 32, 1907, 1860, 1906, 412, 1911, 80, 1910, 1912, 2402, + /* 2340 */ 413, 759, 2383, 1913, 23, 2421, 59, 1831, 349, 2385, + /* 2350 */ 762, 2387, 2388, 757, 2350, 752, 758, 182, 1830, 2384, + /* 2360 */ 2276, 2255, 102, 2254, 18, 311, 103, 101, 2383, 2402, + /* 2370 */ 25, 2421, 759, 26, 358, 2385, 762, 2387, 2388, 757, + /* 2380 */ 108, 752, 322, 1868, 2350, 193, 758, 11, 13, 317, + /* 2390 */ 70, 104, 1702, 183, 1793, 2383, 1783, 1782, 2421, 2384, + /* 2400 */ 2402, 350, 2385, 762, 2387, 2388, 757, 733, 752, 2424, + /* 2410 */ 1736, 751, 759, 1761, 1759, 2350, 39, 758, 1758, 16, + /* 2420 */ 319, 27, 194, 1728, 28, 2383, 1928, 1927, 2421, 1926, + /* 2430 */ 763, 359, 2385, 762, 2387, 2388, 757, 2384, 752, 1925, + /* 2440 */ 2402, 1498, 1493, 769, 771, 426, 1490, 773, 774, 776, + /* 2450 */ 759, 1489, 777, 779, 1486, 2350, 2383, 758, 780, 2421, + /* 2460 */ 1480, 782, 351, 2385, 762, 2387, 2388, 757, 785, 752, + /* 2470 */ 761, 2384, 783, 325, 1478, 786, 1484, 1425, 2402, 109, + /* 2480 */ 1502, 1483, 1482, 1481, 759, 110, 77, 1364, 800, 1399, + /* 2490 */ 1396, 1395, 1394, 2350, 1393, 758, 2383, 2384, 1391, 2421, + /* 2500 */ 1389, 1388, 365, 2385, 762, 2387, 2388, 757, 1387, 752, + /* 2510 */ 759, 2384, 2402, 1424, 811, 813, 209, 1385, 1384, 1383, + /* 2520 */ 1382, 1381, 1380, 1379, 759, 1421, 1419, 2350, 1376, 758, + /* 2530 */ 1375, 1372, 1371, 1370, 2383, 2014, 1369, 2421, 2402, 833, + /* 2540 */ 366, 2385, 762, 2387, 2388, 757, 835, 752, 834, 2012, + /* 2550 */ 837, 838, 2402, 2350, 839, 758, 2010, 841, 842, 843, + /* 2560 */ 2007, 845, 1987, 847, 849, 846, 1308, 2350, 2383, 758, + /* 2570 */ 1961, 2421, 2384, 1296, 2396, 2385, 762, 2387, 2388, 757, + /* 2580 */ 853, 752, 1931, 329, 855, 759, 1688, 340, 858, 859, + /* 2590 */ 1931, 1931, 1931, 1931, 2383, 1931, 2384, 2421, 1931, 1931, + /* 2600 */ 2395, 2385, 762, 2387, 2388, 757, 1931, 752, 2383, 759, + /* 2610 */ 1931, 2421, 1931, 2402, 2394, 2385, 762, 2387, 2388, 757, + /* 2620 */ 1931, 752, 1931, 1931, 1931, 1931, 1931, 1931, 2350, 2384, + /* 2630 */ 758, 1931, 1931, 1931, 1931, 1931, 1931, 2402, 1931, 1931, + /* 2640 */ 1931, 1931, 759, 1931, 1931, 1931, 1931, 1931, 1931, 1931, + /* 2650 */ 1931, 1931, 2350, 1931, 758, 1931, 1931, 1931, 1931, 1931, + /* 2660 */ 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 2383, + /* 2670 */ 2402, 1931, 2421, 1931, 1931, 383, 2385, 762, 2387, 2388, + /* 2680 */ 757, 1931, 752, 1931, 1931, 2350, 1931, 758, 1931, 1931, + /* 2690 */ 1931, 1931, 1931, 2383, 1931, 1931, 2421, 1931, 1931, 384, + /* 2700 */ 2385, 762, 2387, 2388, 757, 1931, 752, 2384, 1931, 1931, + /* 2710 */ 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, + /* 2720 */ 759, 1931, 1931, 1931, 1931, 1931, 2383, 2384, 1931, 2421, + /* 2730 */ 1931, 1931, 380, 2385, 762, 2387, 2388, 757, 1931, 752, + /* 2740 */ 759, 1931, 1931, 2384, 1931, 1931, 1931, 1931, 2402, 1931, + /* 2750 */ 1931, 1931, 1931, 1931, 1931, 1931, 759, 1931, 1931, 1931, + /* 2760 */ 1931, 1931, 1931, 2350, 1931, 758, 1931, 1931, 2402, 1931, + /* 2770 */ 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, + /* 2780 */ 1931, 1931, 1931, 2350, 2402, 758, 1931, 1931, 1931, 1931, + /* 2790 */ 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 1931, 2350, + /* 2800 */ 1931, 758, 1931, 1931, 2383, 1931, 1931, 2421, 1931, 1931, + /* 2810 */ 385, 2385, 762, 2387, 2388, 757, 1931, 752, 1931, 1931, + /* 2820 */ 1931, 1931, 1931, 1931, 760, 1931, 1931, 2421, 1931, 1931, + /* 2830 */ 356, 2385, 762, 2387, 2388, 757, 1931, 752, 1931, 1931, + /* 2840 */ 2383, 1931, 1931, 2421, 1931, 1931, 355, 2385, 762, 2387, + /* 2850 */ 2388, 757, 1931, 752, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 415, 369, 370, 399, 436, 369, 370, 411, 398, 441, - /* 10 */ 414, 415, 12, 13, 14, 430, 406, 2, 433, 434, - /* 20 */ 20, 389, 22, 8, 9, 389, 416, 12, 13, 14, - /* 30 */ 15, 16, 396, 2, 4, 35, 0, 37, 20, 8, - /* 40 */ 9, 398, 357, 12, 13, 14, 15, 16, 20, 406, - /* 50 */ 407, 408, 369, 370, 486, 370, 398, 489, 385, 416, - /* 60 */ 376, 388, 8, 9, 406, 65, 12, 13, 14, 15, - /* 70 */ 16, 71, 398, 354, 416, 507, 508, 393, 78, 486, - /* 80 */ 512, 513, 489, 398, 8, 9, 402, 33, 12, 13, - /* 90 */ 14, 15, 16, 12, 13, 14, 15, 16, 413, 425, - /* 100 */ 415, 508, 39, 40, 104, 512, 513, 107, 14, 73, - /* 110 */ 74, 75, 76, 77, 20, 79, 80, 81, 82, 83, + /* 0 */ 416, 370, 371, 400, 437, 370, 371, 412, 399, 442, + /* 10 */ 415, 416, 12, 13, 14, 431, 407, 2, 434, 435, + /* 20 */ 20, 390, 22, 8, 9, 390, 417, 12, 13, 14, + /* 30 */ 15, 16, 397, 2, 379, 35, 0, 37, 399, 8, + /* 40 */ 9, 399, 358, 12, 13, 14, 15, 16, 409, 407, + /* 50 */ 408, 409, 370, 371, 487, 371, 399, 490, 358, 417, + /* 60 */ 377, 406, 8, 9, 407, 65, 12, 13, 14, 15, + /* 70 */ 16, 71, 399, 355, 417, 508, 509, 394, 78, 487, + /* 80 */ 513, 514, 490, 399, 8, 9, 403, 33, 12, 13, + /* 90 */ 14, 15, 16, 12, 13, 14, 15, 16, 414, 426, + /* 100 */ 416, 509, 39, 40, 104, 513, 514, 107, 0, 73, + /* 110 */ 74, 75, 76, 77, 414, 79, 80, 81, 82, 83, /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - /* 130 */ 94, 95, 96, 97, 98, 99, 100, 364, 20, 454, - /* 140 */ 367, 368, 457, 143, 144, 460, 461, 462, 463, 464, - /* 150 */ 465, 137, 467, 20, 20, 436, 22, 472, 369, 474, - /* 160 */ 441, 397, 108, 478, 479, 482, 483, 484, 107, 486, - /* 170 */ 487, 37, 489, 398, 111, 112, 412, 114, 493, 4, - /* 180 */ 180, 181, 407, 408, 108, 20, 501, 187, 188, 55, - /* 190 */ 507, 508, 33, 369, 370, 512, 513, 0, 23, 136, - /* 200 */ 12, 13, 202, 140, 204, 486, 417, 418, 489, 420, - /* 210 */ 182, 8, 9, 424, 69, 12, 13, 14, 15, 16, - /* 220 */ 369, 46, 47, 48, 357, 37, 507, 508, 65, 215, - /* 230 */ 216, 512, 513, 20, 234, 235, 236, 370, 238, 239, + /* 130 */ 94, 95, 96, 97, 98, 99, 100, 365, 20, 455, + /* 140 */ 368, 369, 458, 143, 144, 461, 462, 463, 464, 465, + /* 150 */ 466, 20, 468, 20, 20, 437, 22, 473, 370, 475, + /* 160 */ 442, 398, 108, 479, 480, 483, 484, 485, 107, 487, + /* 170 */ 488, 37, 490, 399, 111, 112, 413, 114, 494, 4, + /* 180 */ 180, 181, 408, 409, 108, 33, 502, 187, 188, 55, + /* 190 */ 508, 509, 0, 370, 371, 513, 514, 45, 23, 136, + /* 200 */ 12, 13, 202, 140, 204, 487, 418, 419, 490, 421, + /* 210 */ 20, 8, 9, 425, 14, 12, 13, 14, 15, 16, + /* 220 */ 20, 46, 47, 48, 358, 37, 508, 509, 65, 476, + /* 230 */ 477, 513, 514, 87, 234, 235, 236, 371, 238, 239, /* 240 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - /* 250 */ 250, 251, 252, 253, 254, 255, 12, 13, 357, 0, - /* 260 */ 20, 18, 20, 20, 20, 398, 22, 108, 398, 106, - /* 270 */ 27, 370, 109, 30, 71, 370, 143, 144, 35, 35, - /* 280 */ 413, 37, 415, 24, 25, 26, 27, 28, 29, 30, - /* 290 */ 31, 32, 0, 423, 51, 425, 53, 446, 447, 398, - /* 300 */ 436, 58, 59, 398, 274, 481, 482, 483, 484, 65, - /* 310 */ 486, 487, 69, 13, 413, 71, 415, 415, 115, 365, - /* 320 */ 107, 454, 78, 369, 457, 371, 20, 460, 461, 462, - /* 330 */ 463, 464, 465, 272, 467, 433, 434, 470, 175, 472, - /* 340 */ 473, 474, 197, 51, 369, 478, 479, 4, 104, 106, - /* 350 */ 486, 107, 20, 489, 236, 454, 159, 160, 457, 386, - /* 360 */ 117, 460, 461, 462, 463, 464, 465, 462, 467, 224, - /* 370 */ 225, 507, 508, 472, 401, 474, 512, 513, 78, 478, - /* 380 */ 479, 186, 179, 143, 144, 175, 413, 143, 144, 357, + /* 250 */ 250, 251, 252, 253, 254, 255, 12, 13, 358, 0, + /* 260 */ 20, 18, 70, 20, 20, 399, 22, 159, 160, 106, + /* 270 */ 27, 371, 109, 30, 71, 4, 143, 144, 35, 35, + /* 280 */ 414, 37, 416, 24, 25, 26, 27, 28, 29, 30, + /* 290 */ 31, 32, 370, 371, 51, 149, 53, 107, 399, 399, + /* 300 */ 437, 58, 59, 400, 401, 482, 483, 484, 485, 65, + /* 310 */ 487, 488, 69, 182, 414, 71, 416, 416, 115, 173, + /* 320 */ 174, 455, 78, 424, 458, 426, 370, 461, 462, 463, + /* 330 */ 464, 465, 466, 272, 468, 434, 435, 471, 175, 473, + /* 340 */ 474, 475, 20, 20, 422, 479, 480, 0, 104, 106, + /* 350 */ 487, 107, 20, 490, 236, 455, 358, 371, 458, 387, + /* 360 */ 117, 461, 462, 463, 464, 465, 466, 236, 468, 370, + /* 370 */ 371, 508, 509, 473, 402, 475, 513, 514, 107, 479, + /* 380 */ 480, 70, 179, 143, 144, 399, 414, 143, 144, 390, /* 390 */ 147, 148, 204, 150, 151, 152, 153, 154, 155, 156, - /* 400 */ 157, 158, 501, 428, 429, 162, 163, 164, 165, 166, - /* 410 */ 167, 168, 3, 170, 171, 172, 206, 369, 370, 176, - /* 420 */ 177, 178, 180, 181, 180, 181, 183, 187, 188, 20, - /* 430 */ 457, 187, 188, 20, 73, 74, 75, 389, 398, 107, - /* 440 */ 467, 80, 81, 82, 396, 413, 202, 86, 204, 409, - /* 450 */ 107, 14, 91, 92, 93, 94, 364, 20, 97, 367, - /* 460 */ 368, 100, 259, 260, 261, 262, 263, 264, 265, 266, - /* 470 */ 267, 268, 269, 278, 279, 280, 281, 107, 234, 235, - /* 480 */ 236, 459, 238, 239, 240, 241, 242, 243, 244, 245, + /* 400 */ 157, 158, 502, 447, 448, 162, 163, 164, 165, 166, + /* 410 */ 167, 168, 414, 170, 171, 172, 20, 370, 371, 176, + /* 420 */ 177, 178, 4, 20, 180, 181, 183, 187, 188, 107, + /* 430 */ 458, 187, 188, 107, 73, 74, 75, 390, 415, 416, + /* 440 */ 468, 80, 81, 82, 397, 70, 202, 86, 204, 463, + /* 450 */ 14, 14, 91, 92, 93, 94, 20, 20, 97, 3, + /* 460 */ 370, 100, 259, 260, 261, 262, 263, 264, 265, 266, + /* 470 */ 267, 268, 269, 357, 20, 359, 20, 20, 234, 235, + /* 480 */ 236, 23, 238, 239, 240, 241, 242, 243, 244, 245, /* 490 */ 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, - /* 500 */ 256, 12, 13, 357, 21, 369, 370, 485, 365, 20, - /* 510 */ 0, 22, 369, 70, 371, 87, 370, 108, 372, 36, - /* 520 */ 104, 38, 39, 40, 35, 20, 37, 136, 137, 138, - /* 530 */ 139, 140, 141, 142, 118, 119, 120, 121, 122, 123, - /* 540 */ 124, 125, 126, 127, 398, 129, 130, 131, 132, 133, - /* 550 */ 134, 135, 475, 476, 65, 0, 20, 421, 379, 413, - /* 560 */ 71, 415, 14, 15, 16, 21, 387, 78, 24, 25, - /* 570 */ 26, 27, 28, 29, 30, 31, 32, 149, 369, 370, - /* 580 */ 8, 9, 357, 14, 12, 13, 14, 15, 16, 20, - /* 590 */ 369, 182, 20, 104, 70, 370, 107, 372, 389, 22, - /* 600 */ 454, 173, 174, 457, 272, 117, 460, 461, 462, 463, - /* 610 */ 464, 465, 107, 467, 37, 272, 14, 180, 472, 20, - /* 620 */ 474, 22, 20, 398, 478, 479, 369, 370, 73, 74, - /* 630 */ 75, 390, 143, 144, 376, 80, 81, 82, 413, 398, - /* 640 */ 415, 86, 272, 0, 369, 370, 91, 92, 93, 94, - /* 650 */ 409, 356, 97, 358, 55, 100, 234, 8, 9, 357, - /* 660 */ 402, 12, 13, 14, 15, 16, 256, 446, 447, 180, - /* 670 */ 181, 161, 370, 236, 372, 165, 187, 188, 421, 454, - /* 680 */ 398, 104, 457, 173, 78, 460, 461, 462, 463, 464, - /* 690 */ 465, 202, 467, 204, 369, 370, 421, 472, 416, 474, - /* 700 */ 398, 414, 415, 478, 479, 22, 284, 285, 286, 287, - /* 710 */ 288, 289, 290, 70, 389, 413, 107, 415, 369, 370, - /* 720 */ 37, 399, 400, 234, 235, 236, 20, 238, 239, 240, + /* 500 */ 256, 12, 13, 358, 0, 47, 48, 69, 161, 20, + /* 510 */ 107, 22, 165, 256, 182, 258, 371, 366, 373, 234, + /* 520 */ 173, 370, 358, 372, 35, 21, 37, 20, 24, 25, + /* 530 */ 26, 27, 28, 29, 30, 31, 32, 447, 448, 358, + /* 540 */ 117, 8, 9, 272, 399, 12, 13, 14, 15, 16, + /* 550 */ 20, 437, 371, 20, 65, 351, 352, 353, 354, 414, + /* 560 */ 71, 416, 56, 57, 108, 370, 371, 78, 236, 284, + /* 570 */ 285, 286, 287, 288, 289, 290, 180, 181, 414, 365, + /* 580 */ 399, 21, 368, 369, 24, 25, 26, 27, 28, 29, + /* 590 */ 30, 31, 32, 104, 272, 414, 107, 416, 272, 358, + /* 600 */ 455, 487, 379, 458, 490, 179, 461, 462, 463, 464, + /* 610 */ 465, 466, 371, 468, 373, 22, 180, 180, 473, 396, + /* 620 */ 475, 256, 508, 509, 479, 480, 0, 513, 514, 406, + /* 630 */ 37, 395, 143, 144, 180, 197, 455, 387, 182, 458, + /* 640 */ 399, 13, 461, 462, 463, 464, 465, 466, 22, 468, + /* 650 */ 375, 376, 402, 370, 473, 414, 475, 416, 370, 371, + /* 660 */ 479, 480, 224, 225, 414, 37, 399, 370, 371, 180, + /* 670 */ 181, 78, 236, 236, 407, 272, 187, 188, 483, 484, + /* 680 */ 485, 380, 487, 488, 417, 259, 370, 371, 452, 388, + /* 690 */ 236, 202, 274, 204, 366, 269, 455, 104, 370, 458, + /* 700 */ 372, 78, 461, 462, 463, 464, 465, 466, 458, 468, + /* 710 */ 422, 399, 429, 430, 473, 182, 475, 358, 468, 422, + /* 720 */ 479, 480, 410, 234, 235, 236, 117, 238, 239, 240, /* 730 */ 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, - /* 740 */ 251, 252, 253, 254, 255, 12, 13, 14, 33, 180, - /* 750 */ 351, 352, 353, 20, 182, 22, 454, 108, 357, 457, - /* 760 */ 45, 78, 460, 461, 462, 463, 464, 465, 35, 467, - /* 770 */ 37, 370, 236, 372, 472, 50, 474, 272, 8, 9, - /* 780 */ 478, 479, 12, 13, 14, 15, 16, 104, 386, 357, - /* 790 */ 137, 138, 378, 369, 370, 142, 1, 2, 65, 398, - /* 800 */ 369, 370, 370, 401, 372, 236, 56, 57, 236, 395, - /* 810 */ 201, 78, 203, 389, 413, 413, 415, 8, 9, 405, - /* 820 */ 389, 12, 13, 14, 15, 16, 357, 23, 369, 370, - /* 830 */ 398, 482, 483, 484, 22, 486, 487, 104, 117, 370, - /* 840 */ 107, 372, 233, 399, 357, 413, 138, 415, 389, 37, - /* 850 */ 142, 47, 48, 374, 375, 454, 357, 37, 457, 457, - /* 860 */ 458, 460, 461, 462, 463, 464, 465, 398, 467, 467, - /* 870 */ 369, 370, 256, 472, 258, 474, 143, 144, 378, 478, - /* 880 */ 479, 272, 413, 398, 415, 202, 454, 204, 182, 457, - /* 890 */ 389, 406, 460, 461, 462, 463, 464, 465, 78, 467, - /* 900 */ 413, 416, 0, 108, 472, 405, 474, 182, 369, 370, - /* 910 */ 478, 479, 413, 180, 181, 190, 104, 234, 235, 211, - /* 920 */ 187, 188, 214, 454, 22, 217, 457, 219, 389, 460, - /* 930 */ 461, 462, 463, 464, 465, 202, 467, 204, 0, 369, - /* 940 */ 370, 472, 236, 474, 398, 369, 370, 478, 479, 357, - /* 950 */ 8, 9, 406, 357, 12, 13, 14, 15, 16, 389, - /* 960 */ 20, 471, 416, 473, 194, 389, 370, 234, 235, 236, - /* 970 */ 42, 238, 239, 240, 241, 242, 243, 244, 245, 246, + /* 740 */ 251, 252, 253, 254, 255, 12, 13, 14, 399, 358, + /* 750 */ 387, 370, 371, 20, 487, 22, 407, 490, 34, 370, + /* 760 */ 371, 20, 371, 22, 373, 402, 417, 437, 35, 236, + /* 770 */ 37, 390, 400, 414, 22, 508, 509, 414, 358, 390, + /* 780 */ 513, 514, 136, 137, 138, 139, 140, 141, 142, 37, + /* 790 */ 399, 371, 0, 373, 37, 202, 55, 204, 65, 483, + /* 800 */ 484, 485, 358, 487, 488, 414, 358, 416, 8, 9, + /* 810 */ 391, 78, 12, 13, 14, 15, 16, 487, 399, 399, + /* 820 */ 490, 458, 459, 399, 399, 370, 371, 234, 235, 410, + /* 830 */ 78, 468, 407, 400, 414, 78, 416, 104, 508, 509, + /* 840 */ 107, 417, 417, 513, 514, 390, 455, 487, 358, 458, + /* 850 */ 490, 358, 461, 462, 463, 464, 465, 466, 414, 468, + /* 860 */ 0, 371, 414, 358, 473, 42, 475, 370, 371, 509, + /* 870 */ 479, 480, 400, 513, 514, 455, 143, 144, 458, 21, + /* 880 */ 33, 461, 462, 463, 464, 465, 466, 390, 468, 399, + /* 890 */ 370, 371, 45, 473, 36, 475, 38, 39, 40, 479, + /* 900 */ 480, 358, 42, 358, 414, 13, 416, 414, 386, 22, + /* 910 */ 390, 389, 50, 180, 181, 3, 371, 137, 373, 414, + /* 920 */ 187, 188, 370, 371, 37, 20, 13, 51, 136, 137, + /* 930 */ 138, 139, 140, 141, 142, 202, 60, 204, 400, 63, + /* 940 */ 64, 391, 390, 443, 399, 455, 370, 371, 458, 399, + /* 950 */ 37, 461, 462, 463, 464, 465, 466, 414, 468, 414, + /* 960 */ 410, 416, 14, 15, 16, 358, 390, 234, 235, 236, + /* 970 */ 78, 238, 239, 240, 241, 242, 243, 244, 245, 246, /* 980 */ 247, 248, 249, 250, 251, 252, 253, 254, 255, 12, - /* 990 */ 13, 357, 0, 0, 398, 369, 370, 20, 471, 22, - /* 1000 */ 473, 374, 375, 486, 370, 413, 489, 383, 384, 413, - /* 1010 */ 398, 415, 35, 21, 37, 389, 24, 25, 26, 27, - /* 1020 */ 28, 29, 30, 31, 32, 508, 22, 398, 416, 512, - /* 1030 */ 513, 51, 398, 0, 357, 406, 357, 357, 383, 384, - /* 1040 */ 60, 37, 65, 63, 64, 416, 357, 413, 3, 415, - /* 1050 */ 454, 357, 459, 457, 390, 78, 460, 461, 462, 463, - /* 1060 */ 464, 465, 398, 467, 179, 369, 370, 357, 472, 299, - /* 1070 */ 474, 360, 361, 409, 478, 479, 270, 271, 485, 398, - /* 1080 */ 20, 104, 78, 486, 107, 389, 489, 357, 454, 408, - /* 1090 */ 413, 457, 413, 413, 460, 461, 462, 463, 464, 465, - /* 1100 */ 370, 467, 413, 357, 507, 508, 472, 413, 474, 512, - /* 1110 */ 513, 357, 478, 479, 470, 486, 20, 473, 489, 0, - /* 1120 */ 143, 144, 182, 413, 182, 386, 369, 370, 398, 136, - /* 1130 */ 137, 138, 139, 140, 141, 142, 507, 508, 398, 34, - /* 1140 */ 401, 512, 513, 413, 259, 415, 389, 357, 369, 370, - /* 1150 */ 33, 357, 413, 394, 269, 0, 416, 180, 181, 413, - /* 1160 */ 370, 42, 369, 370, 187, 188, 228, 413, 389, 136, - /* 1170 */ 137, 138, 139, 140, 141, 142, 236, 22, 0, 202, - /* 1180 */ 357, 204, 389, 117, 454, 33, 357, 457, 398, 357, - /* 1190 */ 460, 461, 462, 463, 464, 465, 457, 467, 410, 271, - /* 1200 */ 22, 413, 472, 413, 474, 415, 467, 413, 478, 479, - /* 1210 */ 451, 234, 235, 236, 357, 238, 239, 240, 241, 242, + /* 990 */ 13, 104, 358, 503, 504, 215, 216, 20, 399, 22, + /* 1000 */ 455, 358, 358, 458, 400, 358, 461, 462, 463, 464, + /* 1010 */ 465, 466, 35, 468, 37, 371, 417, 358, 473, 400, + /* 1020 */ 475, 414, 8, 9, 479, 480, 12, 13, 14, 15, + /* 1030 */ 16, 0, 8, 9, 370, 371, 12, 13, 14, 15, + /* 1040 */ 16, 358, 65, 399, 182, 1, 2, 20, 414, 104, + /* 1050 */ 471, 437, 190, 474, 390, 78, 0, 414, 414, 411, + /* 1060 */ 416, 414, 414, 118, 119, 120, 121, 122, 123, 124, + /* 1070 */ 125, 126, 127, 414, 129, 130, 131, 132, 133, 134, + /* 1080 */ 135, 104, 388, 358, 107, 8, 9, 182, 107, 12, + /* 1090 */ 13, 14, 15, 16, 271, 358, 371, 414, 373, 455, + /* 1100 */ 460, 487, 458, 22, 490, 461, 462, 463, 464, 465, + /* 1110 */ 466, 467, 468, 469, 470, 370, 371, 472, 37, 474, + /* 1120 */ 143, 144, 508, 509, 399, 437, 486, 513, 514, 73, + /* 1130 */ 74, 75, 108, 384, 385, 390, 80, 81, 82, 414, + /* 1140 */ 460, 416, 86, 186, 375, 376, 20, 91, 92, 93, + /* 1150 */ 94, 414, 108, 97, 370, 371, 100, 180, 181, 472, + /* 1160 */ 359, 474, 384, 385, 187, 188, 486, 136, 137, 138, + /* 1170 */ 139, 140, 141, 142, 390, 487, 361, 362, 490, 202, + /* 1180 */ 455, 204, 201, 458, 203, 104, 461, 462, 463, 464, + /* 1190 */ 465, 466, 399, 468, 137, 138, 508, 509, 473, 142, + /* 1200 */ 475, 513, 514, 138, 479, 480, 294, 142, 194, 358, + /* 1210 */ 417, 234, 235, 236, 233, 238, 239, 240, 241, 242, /* 1220 */ 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, - /* 1230 */ 253, 254, 255, 12, 13, 169, 413, 33, 357, 436, - /* 1240 */ 180, 20, 413, 22, 454, 413, 4, 457, 357, 45, - /* 1250 */ 460, 461, 462, 463, 464, 465, 35, 467, 37, 369, - /* 1260 */ 370, 19, 369, 370, 474, 369, 370, 33, 478, 479, - /* 1270 */ 413, 410, 459, 410, 413, 0, 413, 35, 357, 389, - /* 1280 */ 391, 110, 389, 394, 113, 389, 65, 110, 33, 486, - /* 1290 */ 113, 370, 489, 51, 413, 33, 236, 13, 485, 78, - /* 1300 */ 58, 59, 136, 13, 413, 65, 140, 65, 33, 110, - /* 1310 */ 507, 508, 113, 0, 71, 512, 513, 110, 18, 398, - /* 1320 */ 113, 37, 218, 23, 220, 104, 399, 37, 107, 33, - /* 1330 */ 33, 33, 236, 357, 413, 22, 415, 143, 144, 294, - /* 1340 */ 40, 41, 108, 436, 44, 399, 370, 33, 106, 109, - /* 1350 */ 399, 109, 49, 107, 54, 37, 33, 33, 1, 2, - /* 1360 */ 399, 399, 116, 108, 143, 144, 66, 67, 68, 69, - /* 1370 */ 108, 33, 33, 33, 398, 454, 33, 33, 457, 442, - /* 1380 */ 404, 460, 461, 462, 463, 464, 465, 37, 467, 413, - /* 1390 */ 387, 415, 358, 486, 426, 474, 489, 13, 516, 478, - /* 1400 */ 479, 180, 181, 33, 108, 108, 108, 107, 187, 188, - /* 1410 */ 107, 33, 33, 296, 507, 508, 505, 498, 33, 512, - /* 1420 */ 513, 37, 108, 202, 373, 204, 398, 369, 370, 13, - /* 1430 */ 454, 108, 108, 457, 33, 386, 460, 461, 462, 463, - /* 1440 */ 464, 465, 33, 467, 37, 145, 108, 108, 108, 0, - /* 1450 */ 298, 108, 108, 37, 386, 234, 235, 236, 426, 238, + /* 1230 */ 253, 254, 255, 12, 13, 278, 279, 280, 281, 33, + /* 1240 */ 358, 20, 358, 22, 377, 487, 14, 358, 490, 370, + /* 1250 */ 371, 411, 20, 272, 414, 371, 35, 411, 37, 182, + /* 1260 */ 414, 370, 371, 236, 35, 414, 508, 509, 0, 390, + /* 1270 */ 403, 513, 514, 270, 271, 358, 211, 370, 371, 214, + /* 1280 */ 51, 390, 217, 399, 219, 460, 65, 0, 371, 60, + /* 1290 */ 61, 62, 63, 33, 65, 33, 414, 390, 414, 78, + /* 1300 */ 416, 370, 371, 414, 370, 371, 370, 371, 117, 33, + /* 1310 */ 136, 486, 392, 299, 140, 395, 399, 427, 18, 51, + /* 1320 */ 175, 390, 0, 23, 390, 104, 390, 107, 107, 110, + /* 1330 */ 358, 414, 113, 416, 110, 106, 116, 113, 109, 455, + /* 1340 */ 40, 41, 458, 371, 44, 461, 462, 463, 464, 465, + /* 1350 */ 466, 206, 468, 110, 54, 33, 113, 218, 110, 220, + /* 1360 */ 169, 113, 236, 506, 143, 144, 66, 67, 68, 69, + /* 1370 */ 108, 399, 455, 0, 33, 458, 0, 37, 461, 462, + /* 1380 */ 463, 464, 465, 466, 108, 468, 414, 71, 416, 0, + /* 1390 */ 473, 517, 475, 143, 144, 22, 479, 480, 22, 515, + /* 1400 */ 516, 180, 181, 33, 175, 33, 0, 107, 187, 188, + /* 1410 */ 65, 22, 33, 184, 185, 33, 1, 2, 33, 374, + /* 1420 */ 191, 192, 499, 202, 37, 204, 33, 455, 33, 13, + /* 1430 */ 458, 399, 33, 461, 462, 463, 464, 465, 466, 210, + /* 1440 */ 468, 33, 33, 33, 33, 145, 33, 475, 387, 108, + /* 1450 */ 49, 479, 480, 37, 109, 234, 235, 236, 52, 238, /* 1460 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1470 */ 249, 250, 251, 252, 253, 254, 255, 234, 108, 357, - /* 1480 */ 368, 12, 13, 426, 373, 78, 108, 108, 504, 504, - /* 1490 */ 504, 22, 370, 108, 194, 195, 196, 435, 504, 199, - /* 1500 */ 426, 52, 370, 412, 35, 357, 37, 443, 426, 108, - /* 1510 */ 426, 488, 212, 213, 509, 480, 491, 108, 370, 388, - /* 1520 */ 398, 51, 204, 223, 275, 437, 226, 456, 42, 229, - /* 1530 */ 230, 231, 232, 233, 65, 413, 455, 415, 20, 357, - /* 1540 */ 482, 483, 484, 448, 486, 487, 398, 78, 217, 448, - /* 1550 */ 453, 378, 370, 378, 204, 200, 369, 439, 20, 20, - /* 1560 */ 370, 413, 357, 415, 45, 422, 370, 422, 179, 419, - /* 1570 */ 369, 369, 272, 104, 382, 370, 454, 419, 370, 457, - /* 1580 */ 398, 422, 460, 461, 462, 463, 464, 465, 419, 467, - /* 1590 */ 105, 419, 103, 381, 369, 413, 474, 415, 102, 380, - /* 1600 */ 478, 479, 454, 398, 369, 457, 369, 369, 460, 461, - /* 1610 */ 462, 463, 464, 465, 466, 467, 468, 469, 413, 20, - /* 1620 */ 415, 362, 50, 366, 366, 362, 378, 448, 378, 436, - /* 1630 */ 20, 415, 378, 20, 20, 371, 454, 371, 438, 457, - /* 1640 */ 20, 362, 460, 461, 462, 463, 464, 465, 378, 467, - /* 1650 */ 378, 429, 378, 221, 378, 369, 378, 413, 398, 454, - /* 1660 */ 436, 360, 457, 398, 369, 460, 461, 462, 463, 464, - /* 1670 */ 465, 202, 467, 204, 362, 398, 360, 107, 398, 486, - /* 1680 */ 398, 398, 489, 357, 502, 503, 398, 398, 452, 398, - /* 1690 */ 398, 398, 20, 376, 413, 450, 370, 445, 413, 357, - /* 1700 */ 507, 508, 208, 234, 235, 512, 513, 207, 503, 448, - /* 1710 */ 486, 376, 370, 489, 447, 444, 369, 248, 249, 250, - /* 1720 */ 251, 252, 253, 254, 398, 415, 283, 497, 413, 282, - /* 1730 */ 431, 507, 508, 431, 193, 291, 512, 513, 497, 413, - /* 1740 */ 398, 415, 437, 293, 292, 437, 300, 500, 276, 496, - /* 1750 */ 499, 297, 271, 497, 295, 413, 517, 415, 370, 357, - /* 1760 */ 20, 117, 371, 495, 273, 459, 376, 494, 376, 413, - /* 1770 */ 185, 413, 370, 413, 413, 413, 431, 431, 427, 510, - /* 1780 */ 454, 357, 376, 457, 490, 370, 460, 461, 462, 463, - /* 1790 */ 464, 465, 394, 467, 370, 357, 454, 376, 511, 457, - /* 1800 */ 398, 492, 460, 461, 462, 463, 464, 465, 370, 467, - /* 1810 */ 107, 477, 413, 107, 357, 413, 474, 415, 376, 22, - /* 1820 */ 403, 479, 398, 359, 369, 38, 363, 370, 404, 362, - /* 1830 */ 449, 392, 432, 440, 400, 432, 398, 413, 377, 415, - /* 1840 */ 514, 515, 355, 392, 0, 392, 0, 0, 45, 0, - /* 1850 */ 37, 413, 227, 415, 227, 398, 454, 37, 37, 457, - /* 1860 */ 37, 404, 460, 461, 462, 463, 464, 465, 0, 467, - /* 1870 */ 413, 37, 415, 37, 227, 37, 0, 227, 454, 0, - /* 1880 */ 37, 457, 0, 0, 460, 461, 462, 463, 464, 465, - /* 1890 */ 37, 467, 454, 357, 22, 457, 0, 37, 460, 461, - /* 1900 */ 462, 463, 464, 465, 222, 467, 370, 0, 506, 210, - /* 1910 */ 0, 454, 210, 204, 457, 211, 202, 460, 461, 462, - /* 1920 */ 463, 464, 465, 1, 467, 0, 0, 0, 198, 197, - /* 1930 */ 357, 0, 0, 148, 398, 49, 49, 0, 37, 35, - /* 1940 */ 0, 19, 0, 370, 51, 37, 0, 49, 0, 413, - /* 1950 */ 45, 415, 0, 515, 0, 51, 0, 35, 49, 0, - /* 1960 */ 0, 357, 0, 0, 60, 61, 62, 63, 49, 65, - /* 1970 */ 0, 398, 0, 51, 370, 165, 37, 404, 0, 165, - /* 1980 */ 0, 0, 60, 61, 62, 63, 413, 65, 415, 0, - /* 1990 */ 454, 0, 0, 457, 0, 0, 460, 461, 462, 463, - /* 2000 */ 464, 465, 398, 467, 0, 469, 0, 0, 404, 0, - /* 2010 */ 106, 0, 0, 109, 0, 0, 0, 413, 0, 415, - /* 2020 */ 0, 0, 0, 0, 45, 0, 0, 454, 106, 0, - /* 2030 */ 457, 109, 0, 460, 461, 462, 463, 464, 465, 22, - /* 2040 */ 467, 357, 0, 0, 0, 148, 0, 147, 0, 146, - /* 2050 */ 0, 0, 22, 50, 370, 22, 0, 0, 454, 0, - /* 2060 */ 50, 457, 357, 141, 460, 461, 462, 463, 464, 465, - /* 2070 */ 65, 467, 37, 65, 0, 370, 0, 37, 357, 175, - /* 2080 */ 42, 0, 398, 42, 65, 51, 37, 51, 184, 185, - /* 2090 */ 0, 370, 37, 0, 42, 191, 192, 413, 357, 415, - /* 2100 */ 37, 0, 33, 398, 51, 45, 184, 42, 14, 0, - /* 2110 */ 49, 370, 42, 191, 210, 49, 49, 0, 413, 398, - /* 2120 */ 415, 43, 0, 0, 0, 42, 193, 0, 49, 0, - /* 2130 */ 0, 0, 210, 0, 413, 37, 415, 51, 454, 398, - /* 2140 */ 72, 457, 42, 0, 460, 461, 462, 463, 464, 465, - /* 2150 */ 37, 467, 42, 51, 413, 0, 415, 37, 357, 454, - /* 2160 */ 42, 0, 457, 51, 0, 460, 461, 462, 463, 464, - /* 2170 */ 465, 370, 467, 37, 357, 454, 51, 0, 457, 42, - /* 2180 */ 0, 460, 461, 462, 463, 464, 465, 370, 467, 0, - /* 2190 */ 0, 0, 115, 113, 357, 454, 37, 22, 457, 398, - /* 2200 */ 0, 460, 461, 462, 463, 464, 465, 370, 467, 37, - /* 2210 */ 37, 37, 33, 37, 413, 398, 415, 0, 37, 37, - /* 2220 */ 37, 37, 37, 37, 22, 33, 22, 0, 22, 0, - /* 2230 */ 413, 37, 415, 22, 0, 398, 22, 0, 37, 0, - /* 2240 */ 53, 0, 37, 0, 37, 0, 22, 357, 20, 37, - /* 2250 */ 413, 107, 415, 37, 108, 454, 37, 0, 457, 107, - /* 2260 */ 370, 460, 461, 462, 463, 464, 465, 182, 467, 49, - /* 2270 */ 0, 454, 357, 182, 457, 37, 22, 460, 461, 462, - /* 2280 */ 463, 464, 465, 0, 467, 370, 22, 205, 398, 182, - /* 2290 */ 185, 454, 0, 209, 457, 0, 182, 460, 461, 462, - /* 2300 */ 463, 464, 465, 413, 467, 415, 3, 357, 182, 33, - /* 2310 */ 189, 108, 37, 398, 277, 107, 107, 189, 108, 37, - /* 2320 */ 370, 50, 50, 105, 103, 357, 33, 33, 413, 107, - /* 2330 */ 415, 108, 33, 108, 108, 49, 49, 107, 370, 107, - /* 2340 */ 107, 33, 107, 357, 454, 3, 33, 457, 398, 277, - /* 2350 */ 460, 461, 462, 463, 464, 465, 370, 467, 108, 108, - /* 2360 */ 37, 37, 37, 413, 277, 415, 398, 37, 37, 454, - /* 2370 */ 37, 108, 457, 108, 270, 460, 461, 462, 463, 464, - /* 2380 */ 465, 413, 467, 415, 398, 49, 33, 49, 0, 0, - /* 2390 */ 42, 107, 107, 0, 42, 107, 357, 108, 108, 413, - /* 2400 */ 49, 415, 33, 107, 454, 107, 257, 457, 107, 370, - /* 2410 */ 460, 461, 462, 463, 464, 465, 116, 467, 2, 105, - /* 2420 */ 184, 357, 454, 105, 22, 457, 186, 234, 460, 461, - /* 2430 */ 462, 463, 464, 465, 370, 467, 108, 398, 117, 107, - /* 2440 */ 454, 107, 107, 457, 49, 108, 460, 461, 462, 463, - /* 2450 */ 464, 465, 413, 467, 415, 108, 357, 107, 49, 22, - /* 2460 */ 22, 107, 398, 108, 107, 22, 22, 108, 37, 370, - /* 2470 */ 37, 107, 37, 108, 107, 107, 357, 413, 108, 415, - /* 2480 */ 108, 237, 37, 37, 107, 37, 108, 107, 37, 370, - /* 2490 */ 108, 107, 357, 454, 128, 33, 457, 398, 107, 460, - /* 2500 */ 461, 462, 463, 464, 465, 370, 467, 128, 107, 128, - /* 2510 */ 37, 128, 413, 107, 415, 22, 37, 398, 454, 72, - /* 2520 */ 71, 457, 37, 37, 460, 461, 462, 463, 464, 465, - /* 2530 */ 78, 467, 413, 398, 415, 37, 37, 37, 37, 37, - /* 2540 */ 37, 101, 78, 101, 33, 37, 37, 37, 413, 22, - /* 2550 */ 415, 37, 357, 454, 37, 37, 457, 37, 78, 460, - /* 2560 */ 461, 462, 463, 464, 465, 370, 467, 37, 37, 37, - /* 2570 */ 37, 22, 357, 454, 37, 0, 457, 37, 0, 460, - /* 2580 */ 461, 462, 463, 464, 465, 370, 467, 51, 357, 454, - /* 2590 */ 42, 37, 457, 398, 51, 460, 461, 462, 463, 464, - /* 2600 */ 465, 370, 467, 42, 0, 37, 51, 42, 413, 0, - /* 2610 */ 415, 37, 42, 398, 51, 0, 37, 37, 0, 22, - /* 2620 */ 33, 22, 21, 518, 22, 22, 21, 20, 413, 398, - /* 2630 */ 415, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2640 */ 518, 518, 518, 518, 413, 518, 415, 518, 518, 454, - /* 2650 */ 518, 518, 457, 518, 518, 460, 461, 462, 463, 464, - /* 2660 */ 465, 357, 467, 518, 518, 518, 518, 518, 518, 454, - /* 2670 */ 518, 518, 457, 518, 370, 460, 461, 462, 463, 464, - /* 2680 */ 465, 518, 467, 518, 518, 454, 357, 518, 457, 518, - /* 2690 */ 518, 460, 461, 462, 463, 464, 465, 518, 467, 370, - /* 2700 */ 518, 518, 398, 518, 518, 518, 518, 518, 518, 518, - /* 2710 */ 518, 518, 518, 518, 518, 518, 518, 413, 518, 415, - /* 2720 */ 518, 518, 518, 518, 518, 518, 518, 398, 518, 518, - /* 2730 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2740 */ 518, 518, 413, 518, 415, 518, 518, 518, 518, 518, - /* 2750 */ 518, 518, 518, 518, 518, 518, 518, 518, 454, 518, - /* 2760 */ 518, 457, 518, 518, 460, 461, 462, 463, 464, 465, - /* 2770 */ 518, 467, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2780 */ 518, 518, 518, 454, 518, 518, 457, 518, 518, 460, - /* 2790 */ 461, 462, 463, 464, 465, 518, 467, 518, 518, 518, - /* 2800 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2810 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2820 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2830 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2840 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2850 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2860 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2870 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2880 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2890 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2900 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2910 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2920 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2930 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2940 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2950 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2960 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2970 */ 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, - /* 2980 */ 518, 518, 354, 354, 354, 354, 354, 354, 354, 354, - /* 2990 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3000 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3010 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3020 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3030 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3040 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3050 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3060 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3070 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3080 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3090 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3100 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3110 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3120 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3130 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3140 */ 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, - /* 3150 */ 354, + /* 1470 */ 249, 250, 251, 252, 253, 254, 255, 387, 108, 358, + /* 1480 */ 108, 12, 13, 369, 33, 33, 33, 108, 505, 427, + /* 1490 */ 108, 22, 371, 108, 194, 195, 196, 37, 13, 199, + /* 1500 */ 427, 108, 296, 108, 35, 505, 37, 108, 107, 4, + /* 1510 */ 505, 436, 212, 213, 505, 228, 108, 108, 108, 108, + /* 1520 */ 399, 108, 37, 223, 19, 374, 226, 33, 33, 229, + /* 1530 */ 230, 231, 232, 233, 65, 414, 427, 416, 78, 358, + /* 1540 */ 35, 371, 413, 444, 204, 427, 427, 78, 489, 510, + /* 1550 */ 234, 481, 371, 389, 275, 492, 51, 51, 298, 108, + /* 1560 */ 108, 108, 438, 58, 59, 457, 42, 456, 20, 449, + /* 1570 */ 65, 217, 272, 104, 379, 358, 455, 454, 379, 458, + /* 1580 */ 399, 449, 461, 462, 463, 464, 465, 466, 371, 468, + /* 1590 */ 200, 204, 440, 20, 473, 414, 475, 416, 370, 20, + /* 1600 */ 479, 480, 108, 108, 371, 45, 423, 371, 423, 179, + /* 1610 */ 420, 106, 370, 420, 109, 371, 399, 370, 420, 423, + /* 1620 */ 420, 105, 383, 103, 370, 102, 370, 382, 370, 370, + /* 1630 */ 381, 414, 20, 416, 363, 363, 455, 50, 449, 458, + /* 1640 */ 367, 367, 461, 462, 463, 464, 465, 466, 379, 468, + /* 1650 */ 20, 416, 20, 372, 379, 20, 475, 358, 372, 379, + /* 1660 */ 479, 480, 439, 379, 379, 20, 370, 430, 379, 379, + /* 1670 */ 371, 202, 455, 204, 379, 458, 363, 1, 461, 462, + /* 1680 */ 463, 464, 465, 466, 370, 468, 361, 358, 361, 363, + /* 1690 */ 399, 399, 475, 399, 453, 19, 479, 480, 399, 221, + /* 1700 */ 371, 399, 399, 234, 235, 399, 399, 399, 399, 399, + /* 1710 */ 399, 35, 414, 414, 107, 416, 451, 248, 249, 250, + /* 1720 */ 251, 252, 253, 254, 377, 20, 414, 51, 399, 414, + /* 1730 */ 208, 449, 207, 416, 446, 377, 60, 61, 62, 63, + /* 1740 */ 282, 65, 358, 414, 370, 416, 414, 283, 193, 448, + /* 1750 */ 445, 498, 432, 498, 455, 371, 438, 458, 358, 291, + /* 1760 */ 461, 462, 463, 464, 465, 466, 432, 468, 501, 293, + /* 1770 */ 500, 371, 292, 276, 475, 498, 438, 300, 297, 480, + /* 1780 */ 497, 518, 106, 399, 455, 109, 295, 458, 495, 405, + /* 1790 */ 461, 462, 463, 464, 465, 466, 371, 468, 414, 399, + /* 1800 */ 416, 20, 271, 460, 117, 405, 273, 372, 377, 512, + /* 1810 */ 377, 414, 491, 432, 414, 358, 416, 141, 414, 496, + /* 1820 */ 432, 493, 185, 377, 428, 377, 414, 395, 371, 107, + /* 1830 */ 511, 358, 414, 504, 414, 478, 371, 107, 404, 455, + /* 1840 */ 414, 370, 458, 377, 371, 461, 462, 463, 464, 465, + /* 1850 */ 466, 22, 468, 360, 38, 455, 399, 450, 458, 363, + /* 1860 */ 184, 461, 462, 463, 464, 465, 466, 191, 468, 441, + /* 1870 */ 433, 414, 399, 416, 364, 433, 393, 393, 378, 393, + /* 1880 */ 401, 0, 356, 0, 0, 45, 210, 414, 358, 416, + /* 1890 */ 0, 37, 227, 37, 37, 37, 227, 0, 37, 37, + /* 1900 */ 227, 371, 37, 0, 227, 0, 37, 0, 37, 0, + /* 1910 */ 22, 358, 455, 37, 222, 458, 0, 0, 461, 462, + /* 1920 */ 463, 464, 465, 466, 371, 468, 210, 0, 455, 399, + /* 1930 */ 210, 458, 211, 204, 461, 462, 463, 464, 465, 466, + /* 1940 */ 202, 468, 0, 358, 414, 0, 416, 0, 198, 197, + /* 1950 */ 0, 0, 399, 148, 0, 49, 371, 49, 405, 37, + /* 1960 */ 0, 0, 37, 51, 507, 0, 0, 414, 49, 416, + /* 1970 */ 49, 45, 0, 0, 0, 0, 0, 0, 0, 0, + /* 1980 */ 0, 37, 165, 0, 399, 455, 165, 0, 458, 516, + /* 1990 */ 405, 461, 462, 463, 464, 465, 466, 0, 468, 414, + /* 2000 */ 470, 416, 0, 0, 0, 0, 0, 0, 455, 0, + /* 2010 */ 0, 458, 0, 0, 461, 462, 463, 464, 465, 466, + /* 2020 */ 358, 468, 0, 0, 0, 0, 0, 0, 0, 0, + /* 2030 */ 49, 45, 358, 371, 0, 0, 0, 0, 0, 0, + /* 2040 */ 455, 22, 0, 458, 358, 371, 461, 462, 463, 464, + /* 2050 */ 465, 466, 0, 468, 0, 0, 358, 371, 148, 0, + /* 2060 */ 146, 399, 147, 0, 50, 22, 22, 405, 50, 371, + /* 2070 */ 0, 0, 0, 399, 0, 0, 414, 37, 416, 49, + /* 2080 */ 65, 65, 65, 37, 51, 399, 0, 42, 414, 0, + /* 2090 */ 416, 42, 42, 37, 37, 0, 0, 399, 51, 51, + /* 2100 */ 414, 37, 416, 45, 42, 14, 33, 0, 43, 49, + /* 2110 */ 49, 42, 414, 193, 416, 0, 0, 455, 0, 0, + /* 2120 */ 458, 0, 42, 461, 462, 463, 464, 465, 466, 455, + /* 2130 */ 468, 49, 458, 358, 0, 461, 462, 463, 464, 465, + /* 2140 */ 466, 455, 468, 0, 458, 0, 371, 461, 462, 463, + /* 2150 */ 464, 465, 466, 455, 468, 72, 458, 358, 0, 461, + /* 2160 */ 462, 463, 464, 465, 466, 37, 468, 42, 51, 0, + /* 2170 */ 371, 51, 37, 358, 399, 42, 0, 37, 51, 42, + /* 2180 */ 0, 37, 51, 42, 0, 0, 371, 0, 0, 414, + /* 2190 */ 0, 416, 0, 115, 113, 22, 37, 0, 399, 37, + /* 2200 */ 37, 37, 37, 37, 37, 37, 0, 37, 33, 37, + /* 2210 */ 33, 37, 0, 414, 399, 416, 22, 22, 37, 0, + /* 2220 */ 22, 22, 0, 22, 53, 0, 37, 0, 0, 414, + /* 2230 */ 455, 416, 0, 458, 0, 22, 461, 462, 463, 464, + /* 2240 */ 465, 466, 37, 468, 37, 358, 20, 37, 37, 0, + /* 2250 */ 108, 49, 37, 107, 455, 107, 0, 458, 371, 182, + /* 2260 */ 461, 462, 463, 464, 465, 466, 182, 468, 37, 22, + /* 2270 */ 455, 358, 0, 458, 22, 209, 461, 462, 463, 464, + /* 2280 */ 465, 466, 182, 468, 371, 0, 399, 185, 0, 3, + /* 2290 */ 205, 182, 189, 182, 189, 33, 37, 277, 358, 108, + /* 2300 */ 107, 414, 37, 416, 108, 50, 33, 107, 50, 105, + /* 2310 */ 107, 371, 399, 33, 33, 49, 108, 108, 49, 103, + /* 2320 */ 33, 3, 33, 49, 107, 107, 33, 414, 358, 416, + /* 2330 */ 107, 37, 108, 37, 37, 37, 107, 37, 108, 399, + /* 2340 */ 37, 371, 455, 108, 277, 458, 270, 108, 461, 462, + /* 2350 */ 463, 464, 465, 466, 414, 468, 416, 49, 108, 358, + /* 2360 */ 0, 0, 42, 0, 277, 108, 42, 107, 455, 399, + /* 2370 */ 107, 458, 371, 33, 461, 462, 463, 464, 465, 466, + /* 2380 */ 116, 468, 49, 108, 414, 107, 416, 257, 2, 107, + /* 2390 */ 107, 107, 22, 49, 234, 455, 105, 105, 458, 358, + /* 2400 */ 399, 461, 462, 463, 464, 465, 466, 186, 468, 107, + /* 2410 */ 22, 107, 371, 108, 108, 414, 107, 416, 108, 107, + /* 2420 */ 184, 107, 49, 108, 107, 455, 22, 22, 458, 22, + /* 2430 */ 117, 461, 462, 463, 464, 465, 466, 358, 468, 331, + /* 2440 */ 399, 22, 108, 37, 107, 37, 108, 37, 107, 37, + /* 2450 */ 371, 108, 107, 37, 108, 414, 455, 416, 107, 458, + /* 2460 */ 108, 37, 461, 462, 463, 464, 465, 466, 37, 468, + /* 2470 */ 237, 358, 107, 33, 108, 107, 128, 78, 399, 107, + /* 2480 */ 37, 128, 128, 128, 371, 107, 107, 72, 71, 37, + /* 2490 */ 37, 37, 37, 414, 37, 416, 455, 358, 37, 458, + /* 2500 */ 37, 37, 461, 462, 463, 464, 465, 466, 37, 468, + /* 2510 */ 371, 358, 399, 78, 101, 101, 33, 37, 37, 37, + /* 2520 */ 22, 37, 37, 37, 371, 78, 37, 414, 37, 416, + /* 2530 */ 37, 37, 37, 22, 455, 0, 37, 458, 399, 37, + /* 2540 */ 461, 462, 463, 464, 465, 466, 42, 468, 51, 0, + /* 2550 */ 37, 51, 399, 414, 42, 416, 0, 37, 51, 42, + /* 2560 */ 0, 37, 0, 42, 37, 51, 37, 414, 455, 416, + /* 2570 */ 0, 458, 358, 22, 461, 462, 463, 464, 465, 466, + /* 2580 */ 33, 468, 519, 22, 21, 371, 22, 22, 21, 20, + /* 2590 */ 519, 519, 519, 519, 455, 519, 358, 458, 519, 519, + /* 2600 */ 461, 462, 463, 464, 465, 466, 519, 468, 455, 371, + /* 2610 */ 519, 458, 519, 399, 461, 462, 463, 464, 465, 466, + /* 2620 */ 519, 468, 519, 519, 519, 519, 519, 519, 414, 358, + /* 2630 */ 416, 519, 519, 519, 519, 519, 519, 399, 519, 519, + /* 2640 */ 519, 519, 371, 519, 519, 519, 519, 519, 519, 519, + /* 2650 */ 519, 519, 414, 519, 416, 519, 519, 519, 519, 519, + /* 2660 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 455, + /* 2670 */ 399, 519, 458, 519, 519, 461, 462, 463, 464, 465, + /* 2680 */ 466, 519, 468, 519, 519, 414, 519, 416, 519, 519, + /* 2690 */ 519, 519, 519, 455, 519, 519, 458, 519, 519, 461, + /* 2700 */ 462, 463, 464, 465, 466, 519, 468, 358, 519, 519, + /* 2710 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2720 */ 371, 519, 519, 519, 519, 519, 455, 358, 519, 458, + /* 2730 */ 519, 519, 461, 462, 463, 464, 465, 466, 519, 468, + /* 2740 */ 371, 519, 519, 358, 519, 519, 519, 519, 399, 519, + /* 2750 */ 519, 519, 519, 519, 519, 519, 371, 519, 519, 519, + /* 2760 */ 519, 519, 519, 414, 519, 416, 519, 519, 399, 519, + /* 2770 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2780 */ 519, 519, 519, 414, 399, 416, 519, 519, 519, 519, + /* 2790 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 414, + /* 2800 */ 519, 416, 519, 519, 455, 519, 519, 458, 519, 519, + /* 2810 */ 461, 462, 463, 464, 465, 466, 519, 468, 519, 519, + /* 2820 */ 519, 519, 519, 519, 455, 519, 519, 458, 519, 519, + /* 2830 */ 461, 462, 463, 464, 465, 466, 519, 468, 519, 519, + /* 2840 */ 455, 519, 519, 458, 519, 519, 461, 462, 463, 464, + /* 2850 */ 465, 466, 519, 468, 519, 519, 519, 519, 519, 519, + /* 2860 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2870 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2880 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2890 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2900 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2910 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2920 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2930 */ 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, + /* 2940 */ 519, 519, 519, 519, 519, 355, 355, 355, 355, 355, + /* 2950 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 2960 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 2970 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 2980 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 2990 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3000 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3010 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3020 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3030 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3040 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3050 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3060 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3070 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3080 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3090 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3100 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3110 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3120 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3130 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3140 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3150 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3160 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3170 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3180 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3190 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3200 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, }; -#define YY_SHIFT_COUNT (859) +#define YY_SHIFT_COUNT (860) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2618) +#define YY_SHIFT_MAX (2570) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 1300, 0, 244, 0, 489, 489, 489, 489, 489, 489, /* 10 */ 489, 489, 489, 489, 489, 489, 733, 977, 977, 1221, /* 20 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 50 */ 977, 332, 505, 609, 213, 61, 370, 61, 61, 213, - /* 60 */ 213, 61, 1469, 61, 243, 1469, 1469, 343, 61, 18, - /* 70 */ 240, 165, 165, 175, 175, 240, 242, 133, 94, 94, - /* 80 */ 118, 165, 165, 165, 165, 165, 165, 165, 165, 165, - /* 90 */ 165, 165, 306, 413, 165, 165, 443, 18, 165, 306, - /* 100 */ 165, 18, 165, 165, 18, 165, 165, 18, 165, 18, - /* 110 */ 18, 18, 165, 524, 203, 203, 416, 361, 544, 683, - /* 120 */ 683, 683, 683, 683, 683, 683, 683, 683, 683, 683, - /* 130 */ 683, 683, 683, 683, 683, 683, 683, 683, 63, 409, - /* 140 */ 242, 133, 750, 750, 820, 28, 28, 28, 643, 616, - /* 150 */ 616, 300, 820, 443, 488, 18, 18, 410, 18, 18, - /* 160 */ 606, 18, 606, 606, 721, 1105, 416, 416, 416, 416, - /* 170 */ 416, 416, 416, 416, 1922, 555, 992, 572, 770, 422, - /* 180 */ 195, 134, 437, 569, 188, 188, 706, 804, 940, 1004, - /* 190 */ 1004, 1004, 725, 1004, 1060, 599, 536, 602, 1166, 210, - /* 200 */ 536, 536, 1096, 806, 928, 1045, 806, 715, 30, 300, - /* 210 */ 1249, 1470, 1486, 1518, 1331, 443, 1518, 443, 1355, 1538, - /* 220 */ 1539, 1519, 1539, 1519, 1389, 1538, 1539, 1538, 1519, 1389, - /* 230 */ 1389, 1389, 1485, 1489, 1538, 1496, 1538, 1538, 1538, 1599, - /* 240 */ 1572, 1599, 1572, 1518, 443, 443, 1610, 443, 1613, 1614, - /* 250 */ 443, 1613, 443, 1620, 443, 443, 1538, 443, 1599, 18, - /* 260 */ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - /* 270 */ 1538, 1105, 1105, 1599, 606, 606, 606, 1432, 1570, 1518, - /* 280 */ 524, 1672, 1494, 1500, 1610, 524, 1249, 1538, 606, 1443, - /* 290 */ 1447, 1443, 1447, 1444, 1541, 1443, 1450, 1452, 1472, 1249, - /* 300 */ 1446, 1454, 1459, 1481, 1539, 1740, 1644, 1491, 1613, 524, - /* 310 */ 524, 1447, 606, 606, 606, 606, 1447, 606, 1585, 524, - /* 320 */ 721, 524, 1539, 1703, 1706, 606, 1538, 524, 1797, 1787, - /* 330 */ 1599, 2797, 2797, 2797, 2797, 2797, 2797, 2797, 2797, 2797, - /* 340 */ 2797, 36, 1904, 259, 1242, 54, 76, 649, 993, 15, - /* 350 */ 31, 942, 1033, 809, 809, 809, 809, 809, 809, 809, - /* 360 */ 809, 809, 391, 708, 483, 81, 81, 145, 163, 510, - /* 370 */ 428, 980, 197, 577, 812, 399, 14, 653, 653, 548, - /* 380 */ 795, 885, 548, 548, 548, 399, 292, 938, 159, 1119, - /* 390 */ 1204, 1066, 1275, 1171, 1177, 1199, 1207, 1284, 1290, 902, - /* 400 */ 1155, 1178, 1313, 1104, 1234, 1255, 1240, 1262, 1296, 1297, - /* 410 */ 1298, 1194, 1117, 1152, 1314, 1323, 1324, 1338, 1339, 1340, - /* 420 */ 1357, 1343, 1243, 1344, 1303, 1370, 1378, 1379, 1385, 1401, - /* 430 */ 1409, 1246, 1318, 1350, 1384, 1416, 1407, 1449, 1844, 1846, - /* 440 */ 1847, 1803, 1849, 1813, 1625, 1820, 1821, 1823, 1627, 1868, - /* 450 */ 1834, 1836, 1647, 1838, 1876, 1650, 1879, 1843, 1882, 1853, - /* 460 */ 1883, 1872, 1896, 1860, 1682, 1907, 1699, 1910, 1702, 1704, - /* 470 */ 1709, 1714, 1925, 1926, 1927, 1730, 1732, 1931, 1932, 1785, - /* 480 */ 1886, 1887, 1937, 1901, 1940, 1942, 1908, 1893, 1946, 1898, - /* 490 */ 1948, 1905, 1952, 1954, 1956, 1909, 1959, 1960, 1962, 1963, - /* 500 */ 1970, 1972, 1810, 1939, 1978, 1814, 1980, 1981, 1989, 1991, - /* 510 */ 1992, 1994, 1995, 2004, 2006, 2007, 2009, 2011, 2012, 2014, - /* 520 */ 2015, 2016, 2018, 2020, 2021, 1919, 2022, 1979, 2023, 2025, - /* 530 */ 2026, 2029, 2032, 2042, 2043, 2017, 2044, 1897, 2046, 1900, - /* 540 */ 2048, 1903, 2050, 2051, 2030, 2003, 2033, 2010, 2056, 2005, - /* 550 */ 2035, 2057, 2008, 2059, 2019, 2074, 2076, 2040, 2034, 2038, - /* 560 */ 2081, 2049, 2036, 2041, 2090, 2055, 2053, 2052, 2093, 2063, - /* 570 */ 2101, 2060, 2065, 2069, 2061, 2066, 2094, 2067, 2109, 2078, - /* 580 */ 2070, 2117, 2122, 2123, 2124, 2083, 1933, 2127, 2061, 2079, - /* 590 */ 2129, 2130, 2068, 2131, 2133, 2098, 2086, 2100, 2143, 2113, - /* 600 */ 2102, 2110, 2155, 2120, 2112, 2118, 2161, 2136, 2125, 2137, - /* 610 */ 2164, 2177, 2180, 2189, 2190, 2191, 2077, 2080, 2159, 2175, - /* 620 */ 2200, 2172, 2173, 2174, 2176, 2181, 2182, 2183, 2184, 2179, - /* 630 */ 2192, 2185, 2186, 2202, 2194, 2217, 2204, 2227, 2206, 2229, - /* 640 */ 2211, 2187, 2234, 2214, 2201, 2237, 2239, 2241, 2205, 2243, - /* 650 */ 2207, 2245, 2224, 2228, 2212, 2216, 2219, 2146, 2144, 2257, - /* 660 */ 2085, 2152, 2084, 2061, 2220, 2270, 2091, 2238, 2254, 2283, - /* 670 */ 2082, 2264, 2107, 2105, 2292, 2295, 2114, 2121, 2126, 2128, - /* 680 */ 2303, 2276, 2037, 2208, 2203, 2209, 2210, 2275, 2282, 2222, - /* 690 */ 2271, 2218, 2272, 2221, 2223, 2293, 2294, 2225, 2230, 2232, - /* 700 */ 2233, 2226, 2299, 2286, 2287, 2235, 2308, 2072, 2250, 2251, - /* 710 */ 2342, 2313, 2087, 2323, 2324, 2325, 2330, 2331, 2333, 2263, - /* 720 */ 2265, 2336, 2104, 2353, 2338, 2388, 2389, 2284, 2348, 2285, - /* 730 */ 2289, 2290, 2288, 2296, 2240, 2298, 2393, 2352, 2236, 2301, - /* 740 */ 2300, 2061, 2351, 2369, 2314, 2149, 2318, 2416, 2402, 2193, - /* 750 */ 2332, 2328, 2334, 2337, 2335, 2347, 2395, 2350, 2354, 2409, - /* 760 */ 2355, 2437, 2244, 2357, 2321, 2438, 2443, 2444, 2359, 2431, - /* 770 */ 2433, 2364, 2365, 2435, 2367, 2370, 2445, 2368, 2372, 2446, - /* 780 */ 2377, 2378, 2448, 2380, 2382, 2451, 2384, 2366, 2379, 2381, - /* 790 */ 2383, 2391, 2462, 2401, 2473, 2406, 2462, 2462, 2493, 2447, - /* 800 */ 2449, 2479, 2485, 2486, 2498, 2499, 2500, 2501, 2502, 2503, - /* 810 */ 2452, 2440, 2464, 2442, 2511, 2508, 2509, 2510, 2527, 2514, - /* 820 */ 2517, 2518, 2480, 2179, 2520, 2192, 2530, 2531, 2532, 2533, - /* 830 */ 2549, 2537, 2575, 2540, 2536, 2548, 2578, 2554, 2543, 2561, - /* 840 */ 2604, 2568, 2555, 2565, 2609, 2574, 2563, 2570, 2615, 2579, - /* 850 */ 2580, 2618, 2597, 2587, 2599, 2601, 2602, 2603, 2605, 2607, + /* 50 */ 977, 322, 403, 981, 190, 61, 326, 61, 61, 190, + /* 60 */ 190, 61, 1469, 61, 243, 1469, 1469, 271, 61, 323, + /* 70 */ 240, 457, 457, 175, 175, 240, 396, 133, 200, 200, + /* 80 */ 118, 457, 457, 457, 457, 457, 457, 457, 457, 457, + /* 90 */ 457, 457, 507, 530, 457, 457, 311, 323, 457, 507, + /* 100 */ 457, 323, 457, 457, 323, 457, 457, 323, 457, 323, + /* 110 */ 323, 323, 457, 375, 203, 203, 945, 361, 560, 593, + /* 120 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593, + /* 130 */ 593, 593, 593, 593, 593, 593, 593, 593, 63, 456, + /* 140 */ 396, 133, 506, 506, 757, 905, 905, 905, 192, 257, + /* 150 */ 257, 892, 757, 311, 423, 323, 323, 365, 323, 323, + /* 160 */ 623, 323, 623, 623, 609, 724, 945, 945, 945, 945, + /* 170 */ 945, 945, 945, 945, 1676, 1056, 504, 533, 1014, 285, + /* 180 */ 957, 134, 436, 437, 188, 188, 131, 458, 332, 752, + /* 190 */ 752, 752, 862, 752, 454, 741, 1027, 1232, 1174, 1145, + /* 200 */ 1027, 1027, 1126, 1003, 823, 912, 1003, 152, 418, 892, + /* 210 */ 1279, 1506, 1524, 1548, 1354, 311, 1548, 311, 1390, 1573, + /* 220 */ 1579, 1560, 1579, 1560, 1430, 1573, 1579, 1573, 1560, 1430, + /* 230 */ 1430, 1430, 1516, 1520, 1573, 1523, 1573, 1573, 1573, 1612, + /* 240 */ 1587, 1612, 1587, 1548, 311, 311, 1630, 311, 1632, 1635, + /* 250 */ 311, 1632, 311, 1645, 311, 311, 1573, 311, 1612, 323, + /* 260 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, + /* 270 */ 1573, 724, 724, 1612, 623, 623, 623, 1478, 1607, 1548, + /* 280 */ 375, 1705, 1522, 1525, 1630, 375, 1279, 1573, 623, 1464, + /* 290 */ 1458, 1464, 1458, 1468, 1555, 1464, 1476, 1480, 1497, 1279, + /* 300 */ 1477, 1481, 1491, 1531, 1579, 1781, 1687, 1533, 1632, 375, + /* 310 */ 375, 1458, 623, 623, 623, 623, 1458, 623, 1637, 375, + /* 320 */ 609, 375, 1579, 1722, 1730, 623, 1573, 375, 1829, 1816, + /* 330 */ 1612, 2854, 2854, 2854, 2854, 2854, 2854, 2854, 2854, 2854, + /* 340 */ 2854, 36, 1229, 259, 1505, 54, 76, 1024, 792, 15, + /* 350 */ 31, 1077, 1031, 800, 800, 800, 800, 800, 800, 800, + /* 360 */ 800, 800, 646, 1065, 858, 81, 81, 438, 163, 347, + /* 370 */ 146, 876, 204, 204, 108, 887, 1081, 780, 1057, 1057, + /* 380 */ 948, 1044, 426, 948, 948, 948, 1268, 1287, 1262, 860, + /* 390 */ 847, 1191, 1322, 1219, 1224, 1243, 1248, 628, 913, 626, + /* 400 */ 1373, 1376, 1389, 1139, 1276, 1341, 1345, 1370, 1372, 1379, + /* 410 */ 1382, 1250, 1206, 1260, 1385, 1393, 1395, 1399, 1408, 1409, + /* 420 */ 1415, 1410, 1316, 1411, 1401, 1413, 1451, 1452, 1453, 1494, + /* 430 */ 1495, 1220, 1340, 1387, 1416, 1485, 1460, 1406, 1881, 1883, + /* 440 */ 1884, 1840, 1890, 1854, 1665, 1856, 1857, 1858, 1669, 1897, + /* 450 */ 1861, 1862, 1673, 1865, 1903, 1677, 1905, 1869, 1907, 1871, + /* 460 */ 1909, 1888, 1916, 1876, 1692, 1917, 1716, 1927, 1720, 1721, + /* 470 */ 1729, 1738, 1942, 1945, 1947, 1750, 1752, 1950, 1951, 1805, + /* 480 */ 1906, 1908, 1954, 1922, 1960, 1961, 1925, 1912, 1965, 1919, + /* 490 */ 1966, 1926, 1972, 1973, 1974, 1921, 1975, 1976, 1977, 1978, + /* 500 */ 1979, 1980, 1817, 1944, 1983, 1821, 1987, 1997, 2002, 2003, + /* 510 */ 2004, 2005, 2006, 2007, 2009, 2010, 2012, 2013, 2022, 2023, + /* 520 */ 2024, 2025, 2026, 2027, 2028, 1981, 2029, 1986, 2034, 2035, + /* 530 */ 2036, 2037, 2038, 2039, 2052, 2019, 2042, 1910, 2054, 1915, + /* 540 */ 2055, 1914, 2059, 2063, 2043, 2014, 2044, 2018, 2070, 2015, + /* 550 */ 2040, 2071, 2016, 2072, 2017, 2074, 2075, 2046, 2033, 2045, + /* 560 */ 2086, 2056, 2047, 2049, 2089, 2057, 2048, 2050, 2095, 2064, + /* 570 */ 2096, 2058, 2062, 2073, 2030, 2060, 2091, 2061, 2107, 2065, + /* 580 */ 2069, 2115, 2116, 2118, 2119, 2080, 1920, 2121, 2030, 2082, + /* 590 */ 2134, 2143, 2083, 2145, 2158, 2128, 2117, 2125, 2169, 2135, + /* 600 */ 2120, 2133, 2176, 2140, 2127, 2137, 2180, 2144, 2131, 2141, + /* 610 */ 2184, 2185, 2187, 2188, 2190, 2192, 2078, 2081, 2159, 2173, + /* 620 */ 2197, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2170, 2175, + /* 630 */ 2177, 2172, 2174, 2194, 2181, 2206, 2195, 2212, 2198, 2219, + /* 640 */ 2199, 2171, 2222, 2201, 2189, 2225, 2227, 2228, 2205, 2232, + /* 650 */ 2207, 2234, 2213, 2226, 2210, 2211, 2215, 2142, 2146, 2249, + /* 660 */ 2077, 2148, 2066, 2030, 2202, 2256, 2084, 2231, 2247, 2272, + /* 670 */ 2085, 2252, 2100, 2102, 2285, 2288, 2109, 2103, 2111, 2105, + /* 680 */ 2286, 2262, 2020, 2193, 2191, 2200, 2196, 2259, 2265, 2203, + /* 690 */ 2255, 2204, 2258, 2216, 2208, 2273, 2280, 2209, 2217, 2218, + /* 700 */ 2223, 2224, 2281, 2266, 2269, 2229, 2287, 2067, 2230, 2235, + /* 710 */ 2318, 2289, 2087, 2294, 2296, 2297, 2298, 2300, 2303, 2239, + /* 720 */ 2250, 2274, 2076, 2293, 2308, 2360, 2361, 2260, 2320, 2263, + /* 730 */ 2257, 2275, 2278, 2282, 2221, 2283, 2363, 2324, 2236, 2284, + /* 740 */ 2264, 2030, 2333, 2340, 2291, 2130, 2292, 2386, 2370, 2160, + /* 750 */ 2302, 2305, 2304, 2306, 2309, 2310, 2344, 2312, 2314, 2373, + /* 760 */ 2315, 2388, 2233, 2317, 2313, 2404, 2405, 2407, 2108, 2334, + /* 770 */ 2406, 2408, 2337, 2338, 2410, 2341, 2343, 2412, 2345, 2346, + /* 780 */ 2416, 2351, 2352, 2424, 2365, 2366, 2431, 2368, 2348, 2353, + /* 790 */ 2354, 2355, 2372, 2440, 2378, 2443, 2379, 2440, 2440, 2419, + /* 800 */ 2415, 2417, 2452, 2453, 2454, 2455, 2457, 2461, 2463, 2464, + /* 810 */ 2471, 2399, 2413, 2435, 2414, 2483, 2480, 2481, 2482, 2498, + /* 820 */ 2484, 2485, 2486, 2447, 2175, 2489, 2177, 2491, 2493, 2494, + /* 830 */ 2495, 2511, 2499, 2535, 2502, 2497, 2504, 2549, 2513, 2500, + /* 840 */ 2512, 2556, 2520, 2507, 2517, 2560, 2524, 2514, 2521, 2562, + /* 850 */ 2527, 2529, 2570, 2551, 2547, 2561, 2563, 2564, 2565, 2567, + /* 860 */ 2569, }; #define YY_REDUCE_COUNT (340) -#define YY_REDUCE_MIN (-432) -#define YY_REDUCE_MAX (2329) +#define YY_REDUCE_MIN (-433) +#define YY_REDUCE_MAX (2385) static const short yy_reduce_ofst[] = { - /* 0 */ -281, -315, -133, -99, 146, 225, 302, 401, 432, 469, - /* 10 */ 596, 634, 730, 790, 921, 1122, 1148, 1182, 1326, 1342, - /* 20 */ 1205, 976, 1424, 1402, 1438, 1457, 1536, 1573, 1604, 1684, - /* 30 */ 1705, 1721, 1741, 1801, 1817, 1837, 1890, 1915, 1950, 1968, - /* 40 */ 1986, 2039, 2064, 2099, 2119, 2135, 2195, 2215, 2231, 2304, - /* 50 */ 2329, -317, 629, -432, -176, -136, 803, 907, 1193, 349, - /* 60 */ 1058, 1224, 402, 597, -211, -27, 739, -407, 517, -357, - /* 70 */ -415, -364, 48, -227, 92, -98, -130, -404, -46, 143, - /* 80 */ -95, -368, 209, 325, 424, 136, 257, 431, 459, 501, - /* 90 */ 539, 275, -149, -25, 570, 576, 414, -390, 626, 221, - /* 100 */ 696, -342, 757, 779, 241, 793, 890, 485, 893, -225, - /* 110 */ 546, 664, 896, -316, 77, 77, 322, 179, 295, 32, - /* 120 */ 487, 499, 592, 677, 679, 680, 689, 694, 710, 746, - /* 130 */ 754, 794, 823, 829, 832, 857, 881, 891, -236, 22, - /* 140 */ -326, 287, 479, 627, 624, 22, 593, 813, 258, 490, - /* 150 */ 527, -327, 655, 500, 759, 282, 612, 644, 40, 681, - /* 160 */ 788, 740, 861, 863, 889, 711, -396, 444, 927, 946, - /* 170 */ 951, 961, 962, 946, 937, 1003, 1034, 968, 882, 911, - /* 180 */ 919, 1051, 1028, 1028, 1049, 1068, 1032, 1112, 1057, 984, - /* 190 */ 985, 986, 1062, 994, 1028, 1111, 1074, 1132, 1091, 1064, - /* 200 */ 1082, 1084, 1028, 1023, 1023, 1005, 1023, 1035, 1025, 1131, - /* 210 */ 1088, 1071, 1081, 1095, 1097, 1173, 1101, 1175, 1118, 1187, - /* 220 */ 1190, 1143, 1196, 1145, 1150, 1201, 1208, 1202, 1159, 1158, - /* 230 */ 1169, 1172, 1192, 1212, 1225, 1219, 1235, 1237, 1238, 1259, - /* 240 */ 1257, 1263, 1258, 1179, 1248, 1250, 1216, 1254, 1264, 1200, - /* 250 */ 1270, 1266, 1272, 1222, 1274, 1276, 1286, 1278, 1279, 1260, - /* 260 */ 1265, 1277, 1280, 1282, 1283, 1288, 1289, 1291, 1292, 1293, - /* 270 */ 1295, 1301, 1316, 1312, 1244, 1281, 1285, 1236, 1245, 1261, - /* 280 */ 1317, 1267, 1252, 1271, 1310, 1335, 1305, 1347, 1315, 1230, - /* 290 */ 1299, 1241, 1302, 1247, 1251, 1256, 1253, 1268, 1273, 1308, - /* 300 */ 1239, 1287, 1269, 1023, 1388, 1306, 1309, 1294, 1391, 1390, - /* 310 */ 1392, 1345, 1356, 1358, 1360, 1361, 1346, 1362, 1351, 1406, - /* 320 */ 1398, 1421, 1415, 1334, 1417, 1399, 1455, 1442, 1464, 1463, - /* 330 */ 1467, 1393, 1381, 1400, 1403, 1439, 1451, 1434, 1453, 1461, - /* 340 */ 1487, + /* 0 */ -282, -316, -134, -100, 145, 241, 391, 420, 545, 725, + /* 10 */ 181, 917, 1121, 972, 1181, 1217, 644, 490, 884, 1299, + /* 20 */ 1329, 1384, 1400, 1457, 1473, 1553, 1530, 1585, 1662, 1674, + /* 30 */ 1686, 1698, 1775, 1799, 1815, 1887, 1913, 1940, 1970, 2001, + /* 40 */ 2041, 2079, 2113, 2139, 2153, 2214, 2238, 2271, 2349, 2369, + /* 50 */ 2385, -318, 267, -433, -177, -137, 114, 330, 614, 195, + /* 60 */ 316, 688, 363, 758, -212, -28, 250, -408, 360, -358, + /* 70 */ -416, -365, 47, -228, 214, -99, -101, -405, 151, 328, + /* 80 */ -14, -369, -1, 381, 389, -78, 288, 455, 497, 520, + /* 90 */ 552, 297, -44, 283, 576, 664, 223, -391, 745, 90, + /* 100 */ 784, -343, 879, 891, 419, 907, 931, 349, 934, -226, + /* 110 */ 425, 550, 936, -317, -247, -247, -97, 301, 116, -300, + /* 120 */ -2, 164, 359, 444, 448, 493, 505, 543, 607, 634, + /* 130 */ 643, 647, 659, 683, 737, 851, 882, 889, -237, 640, + /* 140 */ -327, 23, 275, 769, 749, 640, 680, 825, 867, 645, + /* 150 */ 687, 522, 778, -345, 236, 424, 599, 579, 312, -361, + /* 160 */ 648, 793, 840, 846, 920, 815, -397, 372, 433, 472, + /* 170 */ 538, 604, 619, 472, 500, 694, 801, 890, 874, 857, + /* 180 */ 923, 1045, 1032, 1032, 1061, 1090, 1062, 1114, 1073, 983, + /* 190 */ 1000, 1005, 1075, 1009, 1032, 1151, 1109, 1170, 1129, 1099, + /* 200 */ 1118, 1119, 1032, 1059, 1059, 1039, 1059, 1070, 1063, 1164, + /* 210 */ 1124, 1108, 1111, 1120, 1123, 1195, 1132, 1199, 1152, 1228, + /* 220 */ 1233, 1183, 1236, 1185, 1190, 1242, 1244, 1247, 1196, 1193, + /* 230 */ 1198, 1200, 1239, 1245, 1254, 1249, 1256, 1258, 1259, 1271, + /* 240 */ 1273, 1272, 1274, 1189, 1269, 1275, 1235, 1280, 1281, 1223, + /* 250 */ 1284, 1286, 1285, 1237, 1289, 1290, 1296, 1295, 1313, 1291, + /* 260 */ 1292, 1294, 1302, 1303, 1306, 1307, 1308, 1309, 1310, 1311, + /* 270 */ 1314, 1325, 1327, 1326, 1298, 1312, 1315, 1241, 1265, 1282, + /* 280 */ 1347, 1301, 1288, 1305, 1317, 1358, 1318, 1374, 1332, 1253, + /* 290 */ 1320, 1255, 1334, 1267, 1270, 1277, 1283, 1323, 1293, 1338, + /* 300 */ 1263, 1297, 1319, 1059, 1425, 1343, 1328, 1321, 1435, 1431, + /* 310 */ 1433, 1381, 1397, 1404, 1412, 1418, 1388, 1420, 1396, 1446, + /* 320 */ 1432, 1448, 1465, 1357, 1434, 1426, 1471, 1466, 1493, 1510, + /* 330 */ 1496, 1428, 1407, 1437, 1442, 1483, 1484, 1479, 1486, 1500, + /* 340 */ 1526, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 10 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 20 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 30 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 40 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 50 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 60 */ 1926, 2270, 1926, 1926, 2233, 1926, 1926, 1926, 1926, 1926, - /* 70 */ 1926, 1926, 1926, 1926, 1926, 1926, 2240, 1926, 1926, 1926, - /* 80 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 90 */ 1926, 1926, 1926, 1926, 1926, 1926, 2025, 1926, 1926, 1926, - /* 100 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 110 */ 1926, 1926, 1926, 2023, 2473, 1926, 2582, 1926, 1926, 1926, - /* 120 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 130 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2485, - /* 140 */ 1926, 1926, 1997, 1997, 1926, 2485, 2485, 2485, 2023, 2445, - /* 150 */ 2445, 1926, 1926, 2025, 2308, 1926, 1926, 1926, 1926, 1926, - /* 160 */ 1926, 1926, 1926, 1926, 2152, 1956, 1926, 1926, 1926, 2176, - /* 170 */ 1926, 1926, 1926, 1926, 2296, 1926, 1926, 2514, 2576, 1926, - /* 180 */ 2517, 1926, 1926, 1926, 1926, 1926, 2245, 1926, 2504, 1926, - /* 190 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2101, 2290, - /* 200 */ 1926, 1926, 1926, 2477, 2491, 2560, 2478, 2475, 2498, 1926, - /* 210 */ 2508, 1926, 2333, 1926, 2322, 2025, 1926, 2025, 2283, 2228, - /* 220 */ 1926, 2238, 1926, 2238, 2235, 1926, 1926, 1926, 2238, 2235, - /* 230 */ 2235, 2235, 2090, 2086, 1926, 2084, 1926, 1926, 1926, 1926, - /* 240 */ 1981, 1926, 1981, 1926, 2025, 2025, 1926, 2025, 1926, 1926, - /* 250 */ 2025, 1926, 2025, 1926, 2025, 2025, 1926, 2025, 1926, 1926, - /* 260 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 270 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2320, 2306, 1926, - /* 280 */ 2023, 1926, 2294, 2292, 1926, 2023, 2508, 1926, 1926, 2530, - /* 290 */ 2525, 2530, 2525, 2544, 2540, 2530, 2549, 2546, 2510, 2508, - /* 300 */ 2579, 2566, 2562, 2491, 1926, 1926, 2496, 2494, 1926, 2023, - /* 310 */ 2023, 2525, 1926, 1926, 1926, 1926, 2525, 1926, 1926, 2023, - /* 320 */ 1926, 2023, 1926, 1926, 2118, 1926, 1926, 2023, 1926, 1965, - /* 330 */ 1926, 2285, 2311, 2266, 2266, 2155, 2155, 2582, 2155, 2026, - /* 340 */ 1931, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 350 */ 1926, 1926, 1926, 2543, 2542, 2398, 1926, 2449, 2448, 2447, - /* 360 */ 2438, 2397, 2114, 1926, 1926, 2396, 2395, 1926, 1926, 1926, - /* 370 */ 1926, 1926, 1926, 1926, 1926, 2105, 1926, 2257, 2256, 2389, - /* 380 */ 1926, 1926, 2390, 2388, 2387, 2127, 1926, 1926, 1926, 1926, - /* 390 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 400 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 410 */ 1926, 1926, 2563, 2567, 1926, 1926, 1926, 1926, 1926, 1926, - /* 420 */ 2474, 1926, 1926, 1926, 2369, 1926, 1926, 1926, 1926, 1926, - /* 430 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 440 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 450 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 460 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 470 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2234, - /* 480 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 490 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 500 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 510 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 520 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 530 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 540 */ 1926, 2249, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 550 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 560 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 570 */ 1926, 1926, 1926, 1970, 2376, 1926, 1926, 1926, 1926, 1926, - /* 580 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2379, 1926, - /* 590 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 600 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 610 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 620 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2065, - /* 630 */ 2064, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 640 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 650 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2380, 1926, 1926, - /* 660 */ 1926, 1926, 1926, 2371, 1926, 1926, 1926, 1926, 1926, 1926, - /* 670 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 680 */ 2559, 2511, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 690 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 700 */ 1926, 1926, 1926, 1926, 2369, 1926, 2541, 1926, 1926, 2557, - /* 710 */ 1926, 2561, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2484, - /* 720 */ 2480, 1926, 1926, 2476, 1926, 1926, 1926, 1926, 1926, 1926, - /* 730 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 740 */ 1926, 2368, 1926, 2435, 1926, 1926, 1926, 2469, 1926, 1926, - /* 750 */ 2420, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 760 */ 2380, 1926, 2383, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 770 */ 1926, 2149, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 780 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 2133, 2131, 2130, - /* 790 */ 2129, 1926, 2162, 1926, 1926, 1926, 2158, 2157, 1926, 1926, - /* 800 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 810 */ 1926, 1926, 1926, 1926, 2044, 1926, 1926, 1926, 1926, 1926, - /* 820 */ 1926, 1926, 1926, 2036, 1926, 2035, 1926, 1926, 1926, 1926, - /* 830 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 840 */ 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, 1926, - /* 850 */ 1926, 1926, 1926, 1955, 1926, 1926, 1926, 1926, 1926, 1926, + /* 0 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 10 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 20 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 30 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 40 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 50 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 60 */ 1929, 2273, 1929, 1929, 2236, 1929, 1929, 1929, 1929, 1929, + /* 70 */ 1929, 1929, 1929, 1929, 1929, 1929, 2243, 1929, 1929, 1929, + /* 80 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 90 */ 1929, 1929, 1929, 1929, 1929, 1929, 2028, 1929, 1929, 1929, + /* 100 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 110 */ 1929, 1929, 1929, 2026, 2476, 1929, 2585, 1929, 1929, 1929, + /* 120 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 130 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2488, + /* 140 */ 1929, 1929, 2000, 2000, 1929, 2488, 2488, 2488, 2026, 2448, + /* 150 */ 2448, 1929, 1929, 2028, 2311, 1929, 1929, 1929, 1929, 1929, + /* 160 */ 1929, 1929, 1929, 1929, 2155, 1959, 1929, 1929, 1929, 2179, + /* 170 */ 1929, 1929, 1929, 1929, 2299, 1929, 1929, 2517, 2579, 1929, + /* 180 */ 2520, 1929, 1929, 1929, 1929, 1929, 2248, 1929, 2507, 1929, + /* 190 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2104, 2293, + /* 200 */ 1929, 1929, 1929, 2480, 2494, 2563, 2481, 2478, 2501, 1929, + /* 210 */ 2511, 1929, 2336, 1929, 2325, 2028, 1929, 2028, 2286, 2231, + /* 220 */ 1929, 2241, 1929, 2241, 2238, 1929, 1929, 1929, 2241, 2238, + /* 230 */ 2238, 2238, 2093, 2089, 1929, 2087, 1929, 1929, 1929, 1929, + /* 240 */ 1984, 1929, 1984, 1929, 2028, 2028, 1929, 2028, 1929, 1929, + /* 250 */ 2028, 1929, 2028, 1929, 2028, 2028, 1929, 2028, 1929, 1929, + /* 260 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 270 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2323, 2309, 1929, + /* 280 */ 2026, 1929, 2297, 2295, 1929, 2026, 2511, 1929, 1929, 2533, + /* 290 */ 2528, 2533, 2528, 2547, 2543, 2533, 2552, 2549, 2513, 2511, + /* 300 */ 2582, 2569, 2565, 2494, 1929, 1929, 2499, 2497, 1929, 2026, + /* 310 */ 2026, 2528, 1929, 1929, 1929, 1929, 2528, 1929, 1929, 2026, + /* 320 */ 1929, 2026, 1929, 1929, 2121, 1929, 1929, 2026, 1929, 1968, + /* 330 */ 1929, 2288, 2314, 2269, 2269, 2158, 2158, 2585, 2158, 2029, + /* 340 */ 1934, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 350 */ 1929, 1929, 1929, 2546, 2545, 2401, 1929, 2452, 2451, 2450, + /* 360 */ 2441, 2400, 2117, 1929, 1929, 2399, 2398, 1929, 1929, 1929, + /* 370 */ 1929, 1929, 2108, 2130, 1929, 1929, 1929, 1929, 2260, 2259, + /* 380 */ 2392, 1929, 1929, 2393, 2391, 2390, 1929, 1929, 1929, 1929, + /* 390 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 400 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 410 */ 1929, 1929, 2566, 2570, 1929, 1929, 1929, 1929, 1929, 1929, + /* 420 */ 2477, 1929, 1929, 1929, 2372, 1929, 1929, 1929, 1929, 1929, + /* 430 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 440 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 450 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 460 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 470 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2237, + /* 480 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 490 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 500 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 510 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 520 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 530 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 540 */ 1929, 2252, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 550 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 560 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 570 */ 1929, 1929, 1929, 1973, 2379, 1929, 1929, 1929, 1929, 1929, + /* 580 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2382, 1929, + /* 590 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 600 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 610 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 620 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2068, + /* 630 */ 2067, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 640 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 650 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2383, 1929, 1929, + /* 660 */ 1929, 1929, 1929, 2374, 1929, 1929, 1929, 1929, 1929, 1929, + /* 670 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 680 */ 2562, 2514, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 690 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 700 */ 1929, 1929, 1929, 1929, 2372, 1929, 2544, 1929, 1929, 2560, + /* 710 */ 1929, 2564, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2487, + /* 720 */ 2483, 1929, 1929, 2479, 1929, 1929, 1929, 1929, 1929, 1929, + /* 730 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 740 */ 1929, 2371, 1929, 2438, 1929, 1929, 1929, 2472, 1929, 1929, + /* 750 */ 2423, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 760 */ 2383, 1929, 2386, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 770 */ 1929, 1929, 2152, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 780 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 2136, 2134, + /* 790 */ 2133, 2132, 1929, 2165, 1929, 1929, 1929, 2161, 2160, 1929, + /* 800 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 810 */ 1929, 1929, 1929, 1929, 1929, 2047, 1929, 1929, 1929, 1929, + /* 820 */ 1929, 1929, 1929, 1929, 2039, 1929, 2038, 1929, 1929, 1929, + /* 830 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 840 */ 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1929, + /* 850 */ 1929, 1929, 1929, 1929, 1958, 1929, 1929, 1929, 1929, 1929, + /* 860 */ 1929, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1764,6 +1778,7 @@ static const YYCODETYPE yyFallback[] = { 301, /* VALUES => ABORT */ 301, /* VARIABLE => ABORT */ 301, /* WAL => ABORT */ + 0, /* PRIMARY => nothing */ 0, /* ENCODE => nothing */ 0, /* COMPRESS => nothing */ 0, /* LEVEL => nothing */ @@ -2206,173 +2221,174 @@ static const char *const yyTokenName[] = { /* 348 */ "VALUES", /* 349 */ "VARIABLE", /* 350 */ "WAL", - /* 351 */ "ENCODE", - /* 352 */ "COMPRESS", - /* 353 */ "LEVEL", - /* 354 */ "cmd", - /* 355 */ "account_options", - /* 356 */ "alter_account_options", - /* 357 */ "literal", - /* 358 */ "alter_account_option", - /* 359 */ "ip_range_list", - /* 360 */ "white_list", - /* 361 */ "white_list_opt", - /* 362 */ "user_name", - /* 363 */ "sysinfo_opt", - /* 364 */ "privileges", - /* 365 */ "priv_level", - /* 366 */ "with_opt", - /* 367 */ "priv_type_list", - /* 368 */ "priv_type", - /* 369 */ "db_name", - /* 370 */ "table_name", - /* 371 */ "topic_name", - /* 372 */ "search_condition", - /* 373 */ "dnode_endpoint", - /* 374 */ "force_opt", - /* 375 */ "unsafe_opt", - /* 376 */ "not_exists_opt", - /* 377 */ "db_options", - /* 378 */ "exists_opt", - /* 379 */ "alter_db_options", - /* 380 */ "speed_opt", - /* 381 */ "start_opt", - /* 382 */ "end_opt", - /* 383 */ "integer_list", - /* 384 */ "variable_list", - /* 385 */ "retention_list", - /* 386 */ "signed", - /* 387 */ "alter_db_option", - /* 388 */ "retention", - /* 389 */ "full_table_name", - /* 390 */ "column_def_list", - /* 391 */ "tags_def_opt", - /* 392 */ "table_options", - /* 393 */ "multi_create_clause", - /* 394 */ "tags_def", - /* 395 */ "multi_drop_clause", - /* 396 */ "alter_table_clause", - /* 397 */ "alter_table_options", - /* 398 */ "column_name", - /* 399 */ "type_name", - /* 400 */ "column_options", - /* 401 */ "signed_literal", - /* 402 */ "create_subtable_clause", - /* 403 */ "specific_cols_opt", - /* 404 */ "expression_list", - /* 405 */ "drop_table_clause", - /* 406 */ "col_name_list", - /* 407 */ "tag_def_list", - /* 408 */ "tag_def", - /* 409 */ "column_def", - /* 410 */ "duration_list", - /* 411 */ "rollup_func_list", - /* 412 */ "alter_table_option", - /* 413 */ "duration_literal", - /* 414 */ "rollup_func_name", - /* 415 */ "function_name", - /* 416 */ "col_name", - /* 417 */ "db_kind_opt", - /* 418 */ "table_kind_db_name_cond_opt", - /* 419 */ "like_pattern_opt", - /* 420 */ "db_name_cond_opt", - /* 421 */ "table_name_cond", - /* 422 */ "from_db_opt", - /* 423 */ "tag_list_opt", - /* 424 */ "table_kind", - /* 425 */ "tag_item", - /* 426 */ "column_alias", - /* 427 */ "index_options", - /* 428 */ "full_index_name", - /* 429 */ "index_name", - /* 430 */ "func_list", - /* 431 */ "sliding_opt", - /* 432 */ "sma_stream_opt", - /* 433 */ "func", - /* 434 */ "sma_func_name", - /* 435 */ "with_meta", - /* 436 */ "query_or_subquery", - /* 437 */ "where_clause_opt", - /* 438 */ "cgroup_name", - /* 439 */ "analyze_opt", - /* 440 */ "explain_options", - /* 441 */ "insert_query", - /* 442 */ "or_replace_opt", - /* 443 */ "agg_func_opt", - /* 444 */ "bufsize_opt", - /* 445 */ "language_opt", - /* 446 */ "full_view_name", - /* 447 */ "view_name", - /* 448 */ "stream_name", - /* 449 */ "stream_options", - /* 450 */ "col_list_opt", - /* 451 */ "tag_def_or_ref_opt", - /* 452 */ "subtable_opt", - /* 453 */ "ignore_opt", - /* 454 */ "expression", - /* 455 */ "on_vgroup_id", - /* 456 */ "dnode_list", - /* 457 */ "literal_func", - /* 458 */ "literal_list", - /* 459 */ "table_alias", - /* 460 */ "expr_or_subquery", - /* 461 */ "pseudo_column", - /* 462 */ "column_reference", - /* 463 */ "function_expression", - /* 464 */ "case_when_expression", - /* 465 */ "star_func", - /* 466 */ "star_func_para_list", - /* 467 */ "noarg_func", - /* 468 */ "other_para_list", - /* 469 */ "star_func_para", - /* 470 */ "when_then_list", - /* 471 */ "case_when_else_opt", - /* 472 */ "common_expression", - /* 473 */ "when_then_expr", - /* 474 */ "predicate", - /* 475 */ "compare_op", - /* 476 */ "in_op", - /* 477 */ "in_predicate_value", - /* 478 */ "boolean_value_expression", - /* 479 */ "boolean_primary", - /* 480 */ "from_clause_opt", - /* 481 */ "table_reference_list", - /* 482 */ "table_reference", - /* 483 */ "table_primary", - /* 484 */ "joined_table", - /* 485 */ "alias_opt", - /* 486 */ "subquery", - /* 487 */ "parenthesized_joined_table", - /* 488 */ "join_type", - /* 489 */ "query_specification", - /* 490 */ "hint_list", - /* 491 */ "set_quantifier_opt", - /* 492 */ "tag_mode_opt", - /* 493 */ "select_list", - /* 494 */ "partition_by_clause_opt", - /* 495 */ "range_opt", - /* 496 */ "every_opt", - /* 497 */ "fill_opt", - /* 498 */ "twindow_clause_opt", - /* 499 */ "group_by_clause_opt", - /* 500 */ "having_clause_opt", - /* 501 */ "select_item", - /* 502 */ "partition_list", - /* 503 */ "partition_item", - /* 504 */ "interval_sliding_duration_literal", - /* 505 */ "fill_mode", - /* 506 */ "group_by_list", - /* 507 */ "query_expression", - /* 508 */ "query_simple", - /* 509 */ "order_by_clause_opt", - /* 510 */ "slimit_clause_opt", - /* 511 */ "limit_clause_opt", - /* 512 */ "union_query_expression", - /* 513 */ "query_simple_or_subquery", - /* 514 */ "sort_specification_list", - /* 515 */ "sort_specification", - /* 516 */ "ordering_specification_opt", - /* 517 */ "null_ordering_opt", + /* 351 */ "PRIMARY", + /* 352 */ "ENCODE", + /* 353 */ "COMPRESS", + /* 354 */ "LEVEL", + /* 355 */ "cmd", + /* 356 */ "account_options", + /* 357 */ "alter_account_options", + /* 358 */ "literal", + /* 359 */ "alter_account_option", + /* 360 */ "ip_range_list", + /* 361 */ "white_list", + /* 362 */ "white_list_opt", + /* 363 */ "user_name", + /* 364 */ "sysinfo_opt", + /* 365 */ "privileges", + /* 366 */ "priv_level", + /* 367 */ "with_opt", + /* 368 */ "priv_type_list", + /* 369 */ "priv_type", + /* 370 */ "db_name", + /* 371 */ "table_name", + /* 372 */ "topic_name", + /* 373 */ "search_condition", + /* 374 */ "dnode_endpoint", + /* 375 */ "force_opt", + /* 376 */ "unsafe_opt", + /* 377 */ "not_exists_opt", + /* 378 */ "db_options", + /* 379 */ "exists_opt", + /* 380 */ "alter_db_options", + /* 381 */ "speed_opt", + /* 382 */ "start_opt", + /* 383 */ "end_opt", + /* 384 */ "integer_list", + /* 385 */ "variable_list", + /* 386 */ "retention_list", + /* 387 */ "signed", + /* 388 */ "alter_db_option", + /* 389 */ "retention", + /* 390 */ "full_table_name", + /* 391 */ "column_def_list", + /* 392 */ "tags_def_opt", + /* 393 */ "table_options", + /* 394 */ "multi_create_clause", + /* 395 */ "tags_def", + /* 396 */ "multi_drop_clause", + /* 397 */ "alter_table_clause", + /* 398 */ "alter_table_options", + /* 399 */ "column_name", + /* 400 */ "type_name", + /* 401 */ "column_options", + /* 402 */ "signed_literal", + /* 403 */ "create_subtable_clause", + /* 404 */ "specific_cols_opt", + /* 405 */ "expression_list", + /* 406 */ "drop_table_clause", + /* 407 */ "col_name_list", + /* 408 */ "tag_def_list", + /* 409 */ "tag_def", + /* 410 */ "column_def", + /* 411 */ "duration_list", + /* 412 */ "rollup_func_list", + /* 413 */ "alter_table_option", + /* 414 */ "duration_literal", + /* 415 */ "rollup_func_name", + /* 416 */ "function_name", + /* 417 */ "col_name", + /* 418 */ "db_kind_opt", + /* 419 */ "table_kind_db_name_cond_opt", + /* 420 */ "like_pattern_opt", + /* 421 */ "db_name_cond_opt", + /* 422 */ "table_name_cond", + /* 423 */ "from_db_opt", + /* 424 */ "tag_list_opt", + /* 425 */ "table_kind", + /* 426 */ "tag_item", + /* 427 */ "column_alias", + /* 428 */ "index_options", + /* 429 */ "full_index_name", + /* 430 */ "index_name", + /* 431 */ "func_list", + /* 432 */ "sliding_opt", + /* 433 */ "sma_stream_opt", + /* 434 */ "func", + /* 435 */ "sma_func_name", + /* 436 */ "with_meta", + /* 437 */ "query_or_subquery", + /* 438 */ "where_clause_opt", + /* 439 */ "cgroup_name", + /* 440 */ "analyze_opt", + /* 441 */ "explain_options", + /* 442 */ "insert_query", + /* 443 */ "or_replace_opt", + /* 444 */ "agg_func_opt", + /* 445 */ "bufsize_opt", + /* 446 */ "language_opt", + /* 447 */ "full_view_name", + /* 448 */ "view_name", + /* 449 */ "stream_name", + /* 450 */ "stream_options", + /* 451 */ "col_list_opt", + /* 452 */ "tag_def_or_ref_opt", + /* 453 */ "subtable_opt", + /* 454 */ "ignore_opt", + /* 455 */ "expression", + /* 456 */ "on_vgroup_id", + /* 457 */ "dnode_list", + /* 458 */ "literal_func", + /* 459 */ "literal_list", + /* 460 */ "table_alias", + /* 461 */ "expr_or_subquery", + /* 462 */ "pseudo_column", + /* 463 */ "column_reference", + /* 464 */ "function_expression", + /* 465 */ "case_when_expression", + /* 466 */ "star_func", + /* 467 */ "star_func_para_list", + /* 468 */ "noarg_func", + /* 469 */ "other_para_list", + /* 470 */ "star_func_para", + /* 471 */ "when_then_list", + /* 472 */ "case_when_else_opt", + /* 473 */ "common_expression", + /* 474 */ "when_then_expr", + /* 475 */ "predicate", + /* 476 */ "compare_op", + /* 477 */ "in_op", + /* 478 */ "in_predicate_value", + /* 479 */ "boolean_value_expression", + /* 480 */ "boolean_primary", + /* 481 */ "from_clause_opt", + /* 482 */ "table_reference_list", + /* 483 */ "table_reference", + /* 484 */ "table_primary", + /* 485 */ "joined_table", + /* 486 */ "alias_opt", + /* 487 */ "subquery", + /* 488 */ "parenthesized_joined_table", + /* 489 */ "join_type", + /* 490 */ "query_specification", + /* 491 */ "hint_list", + /* 492 */ "set_quantifier_opt", + /* 493 */ "tag_mode_opt", + /* 494 */ "select_list", + /* 495 */ "partition_by_clause_opt", + /* 496 */ "range_opt", + /* 497 */ "every_opt", + /* 498 */ "fill_opt", + /* 499 */ "twindow_clause_opt", + /* 500 */ "group_by_clause_opt", + /* 501 */ "having_clause_opt", + /* 502 */ "select_item", + /* 503 */ "partition_list", + /* 504 */ "partition_item", + /* 505 */ "interval_sliding_duration_literal", + /* 506 */ "fill_mode", + /* 507 */ "group_by_list", + /* 508 */ "query_expression", + /* 509 */ "query_simple", + /* 510 */ "order_by_clause_opt", + /* 511 */ "slimit_clause_opt", + /* 512 */ "limit_clause_opt", + /* 513 */ "union_query_expression", + /* 514 */ "query_simple_or_subquery", + /* 515 */ "sort_specification_list", + /* 516 */ "sort_specification", + /* 517 */ "ordering_specification_opt", + /* 518 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -3034,9 +3050,10 @@ static const char *const yyRuleName[] = { /* 651 */ "null_ordering_opt ::= NULLS FIRST", /* 652 */ "null_ordering_opt ::= NULLS LAST", /* 653 */ "column_options ::=", - /* 654 */ "column_options ::= column_options ENCODE NK_STRING", - /* 655 */ "column_options ::= column_options COMPRESS NK_STRING", - /* 656 */ "column_options ::= column_options LEVEL NK_STRING", + /* 654 */ "column_options ::= column_options PRIMARY KEY", + /* 655 */ "column_options ::= column_options ENCODE NK_STRING", + /* 656 */ "column_options ::= column_options COMPRESS NK_STRING", + /* 657 */ "column_options ::= column_options LEVEL NK_STRING", }; #endif /* NDEBUG */ @@ -3163,270 +3180,270 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 354: /* cmd */ - case 357: /* literal */ - case 366: /* with_opt */ - case 372: /* search_condition */ - case 377: /* db_options */ - case 379: /* alter_db_options */ - case 381: /* start_opt */ - case 382: /* end_opt */ - case 386: /* signed */ - case 388: /* retention */ - case 389: /* full_table_name */ - case 392: /* table_options */ - case 396: /* alter_table_clause */ - case 397: /* alter_table_options */ - case 400: /* column_options */ - case 401: /* signed_literal */ - case 402: /* create_subtable_clause */ - case 405: /* drop_table_clause */ - case 408: /* tag_def */ - case 409: /* column_def */ - case 413: /* duration_literal */ - case 414: /* rollup_func_name */ - case 416: /* col_name */ - case 419: /* like_pattern_opt */ - case 420: /* db_name_cond_opt */ - case 421: /* table_name_cond */ - case 422: /* from_db_opt */ - case 425: /* tag_item */ - case 427: /* index_options */ - case 428: /* full_index_name */ - case 431: /* sliding_opt */ - case 432: /* sma_stream_opt */ - case 433: /* func */ - case 436: /* query_or_subquery */ - case 437: /* where_clause_opt */ - case 440: /* explain_options */ - case 441: /* insert_query */ - case 446: /* full_view_name */ - case 449: /* stream_options */ - case 452: /* subtable_opt */ - case 454: /* expression */ - case 457: /* literal_func */ - case 460: /* expr_or_subquery */ - case 461: /* pseudo_column */ - case 462: /* column_reference */ - case 463: /* function_expression */ - case 464: /* case_when_expression */ - case 469: /* star_func_para */ - case 471: /* case_when_else_opt */ - case 472: /* common_expression */ - case 473: /* when_then_expr */ - case 474: /* predicate */ - case 477: /* in_predicate_value */ - case 478: /* boolean_value_expression */ - case 479: /* boolean_primary */ - case 480: /* from_clause_opt */ - case 481: /* table_reference_list */ - case 482: /* table_reference */ - case 483: /* table_primary */ - case 484: /* joined_table */ - case 486: /* subquery */ - case 487: /* parenthesized_joined_table */ - case 489: /* query_specification */ - case 495: /* range_opt */ - case 496: /* every_opt */ - case 497: /* fill_opt */ - case 498: /* twindow_clause_opt */ - case 500: /* having_clause_opt */ - case 501: /* select_item */ - case 503: /* partition_item */ - case 504: /* interval_sliding_duration_literal */ - case 507: /* query_expression */ - case 508: /* query_simple */ - case 510: /* slimit_clause_opt */ - case 511: /* limit_clause_opt */ - case 512: /* union_query_expression */ - case 513: /* query_simple_or_subquery */ - case 515: /* sort_specification */ + case 355: /* cmd */ + case 358: /* literal */ + case 367: /* with_opt */ + case 373: /* search_condition */ + case 378: /* db_options */ + case 380: /* alter_db_options */ + case 382: /* start_opt */ + case 383: /* end_opt */ + case 387: /* signed */ + case 389: /* retention */ + case 390: /* full_table_name */ + case 393: /* table_options */ + case 397: /* alter_table_clause */ + case 398: /* alter_table_options */ + case 401: /* column_options */ + case 402: /* signed_literal */ + case 403: /* create_subtable_clause */ + case 406: /* drop_table_clause */ + case 409: /* tag_def */ + case 410: /* column_def */ + case 414: /* duration_literal */ + case 415: /* rollup_func_name */ + case 417: /* col_name */ + case 420: /* like_pattern_opt */ + case 421: /* db_name_cond_opt */ + case 422: /* table_name_cond */ + case 423: /* from_db_opt */ + case 426: /* tag_item */ + case 428: /* index_options */ + case 429: /* full_index_name */ + case 432: /* sliding_opt */ + case 433: /* sma_stream_opt */ + case 434: /* func */ + case 437: /* query_or_subquery */ + case 438: /* where_clause_opt */ + case 441: /* explain_options */ + case 442: /* insert_query */ + case 447: /* full_view_name */ + case 450: /* stream_options */ + case 453: /* subtable_opt */ + case 455: /* expression */ + case 458: /* literal_func */ + case 461: /* expr_or_subquery */ + case 462: /* pseudo_column */ + case 463: /* column_reference */ + case 464: /* function_expression */ + case 465: /* case_when_expression */ + case 470: /* star_func_para */ + case 472: /* case_when_else_opt */ + case 473: /* common_expression */ + case 474: /* when_then_expr */ + case 475: /* predicate */ + case 478: /* in_predicate_value */ + case 479: /* boolean_value_expression */ + case 480: /* boolean_primary */ + case 481: /* from_clause_opt */ + case 482: /* table_reference_list */ + case 483: /* table_reference */ + case 484: /* table_primary */ + case 485: /* joined_table */ + case 487: /* subquery */ + case 488: /* parenthesized_joined_table */ + case 490: /* query_specification */ + case 496: /* range_opt */ + case 497: /* every_opt */ + case 498: /* fill_opt */ + case 499: /* twindow_clause_opt */ + case 501: /* having_clause_opt */ + case 502: /* select_item */ + case 504: /* partition_item */ + case 505: /* interval_sliding_duration_literal */ + case 508: /* query_expression */ + case 509: /* query_simple */ + case 511: /* slimit_clause_opt */ + case 512: /* limit_clause_opt */ + case 513: /* union_query_expression */ + case 514: /* query_simple_or_subquery */ + case 516: /* sort_specification */ { #line 7 "sql.y" - nodesDestroyNode((yypminor->yy896)); -#line 3247 "sql.c" + nodesDestroyNode((yypminor->yy110)); +#line 3264 "sql.c" } break; - case 355: /* account_options */ - case 356: /* alter_account_options */ - case 358: /* alter_account_option */ - case 380: /* speed_opt */ - case 435: /* with_meta */ - case 444: /* bufsize_opt */ + case 356: /* account_options */ + case 357: /* alter_account_options */ + case 359: /* alter_account_option */ + case 381: /* speed_opt */ + case 436: /* with_meta */ + case 445: /* bufsize_opt */ { #line 54 "sql.y" -#line 3259 "sql.c" +#line 3276 "sql.c" } break; - case 359: /* ip_range_list */ - case 360: /* white_list */ - case 361: /* white_list_opt */ - case 383: /* integer_list */ - case 384: /* variable_list */ - case 385: /* retention_list */ - case 390: /* column_def_list */ - case 391: /* tags_def_opt */ - case 393: /* multi_create_clause */ - case 394: /* tags_def */ - case 395: /* multi_drop_clause */ - case 403: /* specific_cols_opt */ - case 404: /* expression_list */ - case 406: /* col_name_list */ - case 407: /* tag_def_list */ - case 410: /* duration_list */ - case 411: /* rollup_func_list */ - case 423: /* tag_list_opt */ - case 430: /* func_list */ - case 450: /* col_list_opt */ - case 451: /* tag_def_or_ref_opt */ - case 456: /* dnode_list */ - case 458: /* literal_list */ - case 466: /* star_func_para_list */ - case 468: /* other_para_list */ - case 470: /* when_then_list */ - case 490: /* hint_list */ - case 493: /* select_list */ - case 494: /* partition_by_clause_opt */ - case 499: /* group_by_clause_opt */ - case 502: /* partition_list */ - case 506: /* group_by_list */ - case 509: /* order_by_clause_opt */ - case 514: /* sort_specification_list */ + case 360: /* ip_range_list */ + case 361: /* white_list */ + case 362: /* white_list_opt */ + case 384: /* integer_list */ + case 385: /* variable_list */ + case 386: /* retention_list */ + case 391: /* column_def_list */ + case 392: /* tags_def_opt */ + case 394: /* multi_create_clause */ + case 395: /* tags_def */ + case 396: /* multi_drop_clause */ + case 404: /* specific_cols_opt */ + case 405: /* expression_list */ + case 407: /* col_name_list */ + case 408: /* tag_def_list */ + case 411: /* duration_list */ + case 412: /* rollup_func_list */ + case 424: /* tag_list_opt */ + case 431: /* func_list */ + case 451: /* col_list_opt */ + case 452: /* tag_def_or_ref_opt */ + case 457: /* dnode_list */ + case 459: /* literal_list */ + case 467: /* star_func_para_list */ + case 469: /* other_para_list */ + case 471: /* when_then_list */ + case 491: /* hint_list */ + case 494: /* select_list */ + case 495: /* partition_by_clause_opt */ + case 500: /* group_by_clause_opt */ + case 503: /* partition_list */ + case 507: /* group_by_list */ + case 510: /* order_by_clause_opt */ + case 515: /* sort_specification_list */ { #line 85 "sql.y" - nodesDestroyList((yypminor->yy404)); -#line 3299 "sql.c" + nodesDestroyList((yypminor->yy652)); +#line 3316 "sql.c" } break; - case 362: /* user_name */ - case 369: /* db_name */ - case 370: /* table_name */ - case 371: /* topic_name */ - case 373: /* dnode_endpoint */ - case 398: /* column_name */ - case 415: /* function_name */ - case 426: /* column_alias */ - case 429: /* index_name */ - case 434: /* sma_func_name */ - case 438: /* cgroup_name */ - case 445: /* language_opt */ - case 447: /* view_name */ - case 448: /* stream_name */ - case 455: /* on_vgroup_id */ - case 459: /* table_alias */ - case 465: /* star_func */ - case 467: /* noarg_func */ - case 485: /* alias_opt */ + case 363: /* user_name */ + case 370: /* db_name */ + case 371: /* table_name */ + case 372: /* topic_name */ + case 374: /* dnode_endpoint */ + case 399: /* column_name */ + case 416: /* function_name */ + case 427: /* column_alias */ + case 430: /* index_name */ + case 435: /* sma_func_name */ + case 439: /* cgroup_name */ + case 446: /* language_opt */ + case 448: /* view_name */ + case 449: /* stream_name */ + case 456: /* on_vgroup_id */ + case 460: /* table_alias */ + case 466: /* star_func */ + case 468: /* noarg_func */ + case 486: /* alias_opt */ { #line 827 "sql.y" -#line 3324 "sql.c" +#line 3341 "sql.c" } break; - case 363: /* sysinfo_opt */ + case 364: /* sysinfo_opt */ { #line 112 "sql.y" -#line 3331 "sql.c" +#line 3348 "sql.c" } break; - case 364: /* privileges */ - case 367: /* priv_type_list */ - case 368: /* priv_type */ + case 365: /* privileges */ + case 368: /* priv_type_list */ + case 369: /* priv_type */ { #line 121 "sql.y" -#line 3340 "sql.c" +#line 3357 "sql.c" } break; - case 365: /* priv_level */ + case 366: /* priv_level */ { #line 138 "sql.y" -#line 3347 "sql.c" +#line 3364 "sql.c" } break; - case 374: /* force_opt */ - case 375: /* unsafe_opt */ - case 376: /* not_exists_opt */ - case 378: /* exists_opt */ - case 439: /* analyze_opt */ - case 442: /* or_replace_opt */ - case 443: /* agg_func_opt */ - case 453: /* ignore_opt */ - case 491: /* set_quantifier_opt */ - case 492: /* tag_mode_opt */ + case 375: /* force_opt */ + case 376: /* unsafe_opt */ + case 377: /* not_exists_opt */ + case 379: /* exists_opt */ + case 440: /* analyze_opt */ + case 443: /* or_replace_opt */ + case 444: /* agg_func_opt */ + case 454: /* ignore_opt */ + case 492: /* set_quantifier_opt */ + case 493: /* tag_mode_opt */ { #line 167 "sql.y" -#line 3363 "sql.c" +#line 3380 "sql.c" } break; - case 387: /* alter_db_option */ - case 412: /* alter_table_option */ + case 388: /* alter_db_option */ + case 413: /* alter_table_option */ { #line 269 "sql.y" -#line 3371 "sql.c" +#line 3388 "sql.c" } break; - case 399: /* type_name */ + case 400: /* type_name */ { #line 400 "sql.y" -#line 3378 "sql.c" +#line 3395 "sql.c" } break; - case 417: /* db_kind_opt */ - case 424: /* table_kind */ + case 418: /* db_kind_opt */ + case 425: /* table_kind */ { #line 568 "sql.y" -#line 3386 "sql.c" +#line 3403 "sql.c" } break; - case 418: /* table_kind_db_name_cond_opt */ + case 419: /* table_kind_db_name_cond_opt */ { #line 533 "sql.y" -#line 3393 "sql.c" +#line 3410 "sql.c" } break; - case 475: /* compare_op */ - case 476: /* in_op */ + case 476: /* compare_op */ + case 477: /* in_op */ { #line 1017 "sql.y" -#line 3401 "sql.c" +#line 3418 "sql.c" } break; - case 488: /* join_type */ + case 489: /* join_type */ { #line 1093 "sql.y" -#line 3408 "sql.c" +#line 3425 "sql.c" } break; - case 505: /* fill_mode */ + case 506: /* fill_mode */ { #line 1188 "sql.y" -#line 3415 "sql.c" +#line 3432 "sql.c" } break; - case 516: /* ordering_specification_opt */ + case 517: /* ordering_specification_opt */ { #line 1273 "sql.y" -#line 3422 "sql.c" +#line 3439 "sql.c" } break; - case 517: /* null_ordering_opt */ + case 518: /* null_ordering_opt */ { #line 1279 "sql.y" -#line 3429 "sql.c" +#line 3446 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3715,663 +3732,664 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 354, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 354, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 355, /* (2) account_options ::= */ - 355, /* (3) account_options ::= account_options PPS literal */ - 355, /* (4) account_options ::= account_options TSERIES literal */ - 355, /* (5) account_options ::= account_options STORAGE literal */ - 355, /* (6) account_options ::= account_options STREAMS literal */ - 355, /* (7) account_options ::= account_options QTIME literal */ - 355, /* (8) account_options ::= account_options DBS literal */ - 355, /* (9) account_options ::= account_options USERS literal */ - 355, /* (10) account_options ::= account_options CONNS literal */ - 355, /* (11) account_options ::= account_options STATE literal */ - 356, /* (12) alter_account_options ::= alter_account_option */ - 356, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 358, /* (14) alter_account_option ::= PASS literal */ - 358, /* (15) alter_account_option ::= PPS literal */ - 358, /* (16) alter_account_option ::= TSERIES literal */ - 358, /* (17) alter_account_option ::= STORAGE literal */ - 358, /* (18) alter_account_option ::= STREAMS literal */ - 358, /* (19) alter_account_option ::= QTIME literal */ - 358, /* (20) alter_account_option ::= DBS literal */ - 358, /* (21) alter_account_option ::= USERS literal */ - 358, /* (22) alter_account_option ::= CONNS literal */ - 358, /* (23) alter_account_option ::= STATE literal */ - 359, /* (24) ip_range_list ::= NK_STRING */ - 359, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ - 360, /* (26) white_list ::= HOST ip_range_list */ - 361, /* (27) white_list_opt ::= */ - 361, /* (28) white_list_opt ::= white_list */ - 354, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ - 354, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ - 354, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - 354, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - 354, /* (33) cmd ::= ALTER USER user_name ADD white_list */ - 354, /* (34) cmd ::= ALTER USER user_name DROP white_list */ - 354, /* (35) cmd ::= DROP USER user_name */ - 363, /* (36) sysinfo_opt ::= */ - 363, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ - 354, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ - 354, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ - 364, /* (40) privileges ::= ALL */ - 364, /* (41) privileges ::= priv_type_list */ - 364, /* (42) privileges ::= SUBSCRIBE */ - 367, /* (43) priv_type_list ::= priv_type */ - 367, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - 368, /* (45) priv_type ::= READ */ - 368, /* (46) priv_type ::= WRITE */ - 368, /* (47) priv_type ::= ALTER */ - 365, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ - 365, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ - 365, /* (50) priv_level ::= db_name NK_DOT table_name */ - 365, /* (51) priv_level ::= topic_name */ - 366, /* (52) with_opt ::= */ - 366, /* (53) with_opt ::= WITH search_condition */ - 354, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ - 354, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - 354, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ - 354, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ - 354, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ - 354, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ - 354, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 354, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 354, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ - 354, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 354, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ - 373, /* (65) dnode_endpoint ::= NK_STRING */ - 373, /* (66) dnode_endpoint ::= NK_ID */ - 373, /* (67) dnode_endpoint ::= NK_IPTOKEN */ - 374, /* (68) force_opt ::= */ - 374, /* (69) force_opt ::= FORCE */ - 375, /* (70) unsafe_opt ::= UNSAFE */ - 354, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ - 354, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ - 354, /* (73) cmd ::= ALTER LOCAL NK_STRING */ - 354, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 354, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 354, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 354, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ - 354, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 354, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 354, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 354, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 354, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 354, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 354, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ - 354, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ - 354, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 354, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ - 354, /* (88) cmd ::= USE db_name */ - 354, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ - 354, /* (90) cmd ::= FLUSH DATABASE db_name */ - 354, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ - 354, /* (92) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - 376, /* (93) not_exists_opt ::= IF NOT EXISTS */ - 376, /* (94) not_exists_opt ::= */ - 378, /* (95) exists_opt ::= IF EXISTS */ - 378, /* (96) exists_opt ::= */ - 377, /* (97) db_options ::= */ - 377, /* (98) db_options ::= db_options BUFFER NK_INTEGER */ - 377, /* (99) db_options ::= db_options CACHEMODEL NK_STRING */ - 377, /* (100) db_options ::= db_options CACHESIZE NK_INTEGER */ - 377, /* (101) db_options ::= db_options COMP NK_INTEGER */ - 377, /* (102) db_options ::= db_options DURATION NK_INTEGER */ - 377, /* (103) db_options ::= db_options DURATION NK_VARIABLE */ - 377, /* (104) db_options ::= db_options MAXROWS NK_INTEGER */ - 377, /* (105) db_options ::= db_options MINROWS NK_INTEGER */ - 377, /* (106) db_options ::= db_options KEEP integer_list */ - 377, /* (107) db_options ::= db_options KEEP variable_list */ - 377, /* (108) db_options ::= db_options PAGES NK_INTEGER */ - 377, /* (109) db_options ::= db_options PAGESIZE NK_INTEGER */ - 377, /* (110) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - 377, /* (111) db_options ::= db_options PRECISION NK_STRING */ - 377, /* (112) db_options ::= db_options REPLICA NK_INTEGER */ - 377, /* (113) db_options ::= db_options VGROUPS NK_INTEGER */ - 377, /* (114) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 377, /* (115) db_options ::= db_options RETENTIONS retention_list */ - 377, /* (116) db_options ::= db_options SCHEMALESS NK_INTEGER */ - 377, /* (117) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - 377, /* (118) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - 377, /* (119) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - 377, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 377, /* (121) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - 377, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 377, /* (123) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - 377, /* (124) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - 377, /* (125) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - 377, /* (126) db_options ::= db_options TABLE_PREFIX signed */ - 377, /* (127) db_options ::= db_options TABLE_SUFFIX signed */ - 377, /* (128) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ - 379, /* (129) alter_db_options ::= alter_db_option */ - 379, /* (130) alter_db_options ::= alter_db_options alter_db_option */ - 387, /* (131) alter_db_option ::= BUFFER NK_INTEGER */ - 387, /* (132) alter_db_option ::= CACHEMODEL NK_STRING */ - 387, /* (133) alter_db_option ::= CACHESIZE NK_INTEGER */ - 387, /* (134) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - 387, /* (135) alter_db_option ::= KEEP integer_list */ - 387, /* (136) alter_db_option ::= KEEP variable_list */ - 387, /* (137) alter_db_option ::= PAGES NK_INTEGER */ - 387, /* (138) alter_db_option ::= REPLICA NK_INTEGER */ - 387, /* (139) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - 387, /* (140) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - 387, /* (141) alter_db_option ::= MINROWS NK_INTEGER */ - 387, /* (142) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ - 387, /* (143) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 387, /* (144) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ - 387, /* (145) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 387, /* (146) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ - 383, /* (147) integer_list ::= NK_INTEGER */ - 383, /* (148) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 384, /* (149) variable_list ::= NK_VARIABLE */ - 384, /* (150) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 385, /* (151) retention_list ::= retention */ - 385, /* (152) retention_list ::= retention_list NK_COMMA retention */ - 388, /* (153) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 388, /* (154) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ - 380, /* (155) speed_opt ::= */ - 380, /* (156) speed_opt ::= BWLIMIT NK_INTEGER */ - 381, /* (157) start_opt ::= */ - 381, /* (158) start_opt ::= START WITH NK_INTEGER */ - 381, /* (159) start_opt ::= START WITH NK_STRING */ - 381, /* (160) start_opt ::= START WITH TIMESTAMP NK_STRING */ - 382, /* (161) end_opt ::= */ - 382, /* (162) end_opt ::= END WITH NK_INTEGER */ - 382, /* (163) end_opt ::= END WITH NK_STRING */ - 382, /* (164) end_opt ::= END WITH TIMESTAMP NK_STRING */ - 354, /* (165) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 354, /* (166) cmd ::= CREATE TABLE multi_create_clause */ - 354, /* (167) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 354, /* (168) cmd ::= DROP TABLE multi_drop_clause */ - 354, /* (169) cmd ::= DROP STABLE exists_opt full_table_name */ - 354, /* (170) cmd ::= ALTER TABLE alter_table_clause */ - 354, /* (171) cmd ::= ALTER STABLE alter_table_clause */ - 396, /* (172) alter_table_clause ::= full_table_name alter_table_options */ - 396, /* (173) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 396, /* (174) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 396, /* (175) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 396, /* (176) alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ - 396, /* (177) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 396, /* (178) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 396, /* (179) alter_table_clause ::= full_table_name DROP TAG column_name */ - 396, /* (180) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 396, /* (181) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 396, /* (182) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - 393, /* (183) multi_create_clause ::= create_subtable_clause */ - 393, /* (184) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 402, /* (185) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - 395, /* (186) multi_drop_clause ::= drop_table_clause */ - 395, /* (187) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - 405, /* (188) drop_table_clause ::= exists_opt full_table_name */ - 403, /* (189) specific_cols_opt ::= */ - 403, /* (190) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - 389, /* (191) full_table_name ::= table_name */ - 389, /* (192) full_table_name ::= db_name NK_DOT table_name */ - 407, /* (193) tag_def_list ::= tag_def */ - 407, /* (194) tag_def_list ::= tag_def_list NK_COMMA tag_def */ - 408, /* (195) tag_def ::= column_name type_name */ - 390, /* (196) column_def_list ::= column_def */ - 390, /* (197) column_def_list ::= column_def_list NK_COMMA column_def */ - 409, /* (198) column_def ::= column_name type_name column_options */ - 399, /* (199) type_name ::= BOOL */ - 399, /* (200) type_name ::= TINYINT */ - 399, /* (201) type_name ::= SMALLINT */ - 399, /* (202) type_name ::= INT */ - 399, /* (203) type_name ::= INTEGER */ - 399, /* (204) type_name ::= BIGINT */ - 399, /* (205) type_name ::= FLOAT */ - 399, /* (206) type_name ::= DOUBLE */ - 399, /* (207) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 399, /* (208) type_name ::= TIMESTAMP */ - 399, /* (209) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 399, /* (210) type_name ::= TINYINT UNSIGNED */ - 399, /* (211) type_name ::= SMALLINT UNSIGNED */ - 399, /* (212) type_name ::= INT UNSIGNED */ - 399, /* (213) type_name ::= BIGINT UNSIGNED */ - 399, /* (214) type_name ::= JSON */ - 399, /* (215) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 399, /* (216) type_name ::= MEDIUMBLOB */ - 399, /* (217) type_name ::= BLOB */ - 399, /* (218) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 399, /* (219) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - 399, /* (220) type_name ::= DECIMAL */ - 399, /* (221) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 399, /* (222) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 391, /* (223) tags_def_opt ::= */ - 391, /* (224) tags_def_opt ::= tags_def */ - 394, /* (225) tags_def ::= TAGS NK_LP tag_def_list NK_RP */ - 392, /* (226) table_options ::= */ - 392, /* (227) table_options ::= table_options COMMENT NK_STRING */ - 392, /* (228) table_options ::= table_options MAX_DELAY duration_list */ - 392, /* (229) table_options ::= table_options WATERMARK duration_list */ - 392, /* (230) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - 392, /* (231) table_options ::= table_options TTL NK_INTEGER */ - 392, /* (232) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 392, /* (233) table_options ::= table_options DELETE_MARK duration_list */ - 397, /* (234) alter_table_options ::= alter_table_option */ - 397, /* (235) alter_table_options ::= alter_table_options alter_table_option */ - 412, /* (236) alter_table_option ::= COMMENT NK_STRING */ - 412, /* (237) alter_table_option ::= TTL NK_INTEGER */ - 410, /* (238) duration_list ::= duration_literal */ - 410, /* (239) duration_list ::= duration_list NK_COMMA duration_literal */ - 411, /* (240) rollup_func_list ::= rollup_func_name */ - 411, /* (241) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - 414, /* (242) rollup_func_name ::= function_name */ - 414, /* (243) rollup_func_name ::= FIRST */ - 414, /* (244) rollup_func_name ::= LAST */ - 406, /* (245) col_name_list ::= col_name */ - 406, /* (246) col_name_list ::= col_name_list NK_COMMA col_name */ - 416, /* (247) col_name ::= column_name */ - 354, /* (248) cmd ::= SHOW DNODES */ - 354, /* (249) cmd ::= SHOW USERS */ - 354, /* (250) cmd ::= SHOW USER PRIVILEGES */ - 354, /* (251) cmd ::= SHOW db_kind_opt DATABASES */ - 354, /* (252) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - 354, /* (253) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 354, /* (254) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 354, /* (255) cmd ::= SHOW MNODES */ - 354, /* (256) cmd ::= SHOW QNODES */ - 354, /* (257) cmd ::= SHOW FUNCTIONS */ - 354, /* (258) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 354, /* (259) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - 354, /* (260) cmd ::= SHOW STREAMS */ - 354, /* (261) cmd ::= SHOW ACCOUNTS */ - 354, /* (262) cmd ::= SHOW APPS */ - 354, /* (263) cmd ::= SHOW CONNECTIONS */ - 354, /* (264) cmd ::= SHOW LICENCES */ - 354, /* (265) cmd ::= SHOW GRANTS */ - 354, /* (266) cmd ::= SHOW GRANTS FULL */ - 354, /* (267) cmd ::= SHOW GRANTS LOGS */ - 354, /* (268) cmd ::= SHOW CLUSTER MACHINES */ - 354, /* (269) cmd ::= SHOW CREATE DATABASE db_name */ - 354, /* (270) cmd ::= SHOW CREATE TABLE full_table_name */ - 354, /* (271) cmd ::= SHOW CREATE STABLE full_table_name */ - 354, /* (272) cmd ::= SHOW QUERIES */ - 354, /* (273) cmd ::= SHOW SCORES */ - 354, /* (274) cmd ::= SHOW TOPICS */ - 354, /* (275) cmd ::= SHOW VARIABLES */ - 354, /* (276) cmd ::= SHOW CLUSTER VARIABLES */ - 354, /* (277) cmd ::= SHOW LOCAL VARIABLES */ - 354, /* (278) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - 354, /* (279) cmd ::= SHOW BNODES */ - 354, /* (280) cmd ::= SHOW SNODES */ - 354, /* (281) cmd ::= SHOW CLUSTER */ - 354, /* (282) cmd ::= SHOW TRANSACTIONS */ - 354, /* (283) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - 354, /* (284) cmd ::= SHOW CONSUMERS */ - 354, /* (285) cmd ::= SHOW SUBSCRIPTIONS */ - 354, /* (286) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - 354, /* (287) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - 354, /* (288) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - 354, /* (289) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - 354, /* (290) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - 354, /* (291) cmd ::= SHOW VNODES */ - 354, /* (292) cmd ::= SHOW db_name_cond_opt ALIVE */ - 354, /* (293) cmd ::= SHOW CLUSTER ALIVE */ - 354, /* (294) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ - 354, /* (295) cmd ::= SHOW CREATE VIEW full_table_name */ - 354, /* (296) cmd ::= SHOW COMPACTS */ - 354, /* (297) cmd ::= SHOW COMPACT NK_INTEGER */ - 418, /* (298) table_kind_db_name_cond_opt ::= */ - 418, /* (299) table_kind_db_name_cond_opt ::= table_kind */ - 418, /* (300) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - 418, /* (301) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - 424, /* (302) table_kind ::= NORMAL */ - 424, /* (303) table_kind ::= CHILD */ - 420, /* (304) db_name_cond_opt ::= */ - 420, /* (305) db_name_cond_opt ::= db_name NK_DOT */ - 419, /* (306) like_pattern_opt ::= */ - 419, /* (307) like_pattern_opt ::= LIKE NK_STRING */ - 421, /* (308) table_name_cond ::= table_name */ - 422, /* (309) from_db_opt ::= */ - 422, /* (310) from_db_opt ::= FROM db_name */ - 423, /* (311) tag_list_opt ::= */ - 423, /* (312) tag_list_opt ::= tag_item */ - 423, /* (313) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - 425, /* (314) tag_item ::= TBNAME */ - 425, /* (315) tag_item ::= QTAGS */ - 425, /* (316) tag_item ::= column_name */ - 425, /* (317) tag_item ::= column_name column_alias */ - 425, /* (318) tag_item ::= column_name AS column_alias */ - 417, /* (319) db_kind_opt ::= */ - 417, /* (320) db_kind_opt ::= USER */ - 417, /* (321) db_kind_opt ::= SYSTEM */ - 354, /* (322) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - 354, /* (323) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - 354, /* (324) cmd ::= DROP INDEX exists_opt full_index_name */ - 428, /* (325) full_index_name ::= index_name */ - 428, /* (326) full_index_name ::= db_name NK_DOT index_name */ - 427, /* (327) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - 427, /* (328) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - 430, /* (329) func_list ::= func */ - 430, /* (330) func_list ::= func_list NK_COMMA func */ - 433, /* (331) func ::= sma_func_name NK_LP expression_list NK_RP */ - 434, /* (332) sma_func_name ::= function_name */ - 434, /* (333) sma_func_name ::= COUNT */ - 434, /* (334) sma_func_name ::= FIRST */ - 434, /* (335) sma_func_name ::= LAST */ - 434, /* (336) sma_func_name ::= LAST_ROW */ - 432, /* (337) sma_stream_opt ::= */ - 432, /* (338) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - 432, /* (339) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - 432, /* (340) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - 435, /* (341) with_meta ::= AS */ - 435, /* (342) with_meta ::= WITH META AS */ - 435, /* (343) with_meta ::= ONLY META AS */ - 354, /* (344) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - 354, /* (345) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - 354, /* (346) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - 354, /* (347) cmd ::= DROP TOPIC exists_opt topic_name */ - 354, /* (348) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - 354, /* (349) cmd ::= DESC full_table_name */ - 354, /* (350) cmd ::= DESCRIBE full_table_name */ - 354, /* (351) cmd ::= RESET QUERY CACHE */ - 354, /* (352) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - 354, /* (353) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 439, /* (354) analyze_opt ::= */ - 439, /* (355) analyze_opt ::= ANALYZE */ - 440, /* (356) explain_options ::= */ - 440, /* (357) explain_options ::= explain_options VERBOSE NK_BOOL */ - 440, /* (358) explain_options ::= explain_options RATIO NK_FLOAT */ - 354, /* (359) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - 354, /* (360) cmd ::= DROP FUNCTION exists_opt function_name */ - 443, /* (361) agg_func_opt ::= */ - 443, /* (362) agg_func_opt ::= AGGREGATE */ - 444, /* (363) bufsize_opt ::= */ - 444, /* (364) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 445, /* (365) language_opt ::= */ - 445, /* (366) language_opt ::= LANGUAGE NK_STRING */ - 442, /* (367) or_replace_opt ::= */ - 442, /* (368) or_replace_opt ::= OR REPLACE */ - 354, /* (369) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - 354, /* (370) cmd ::= DROP VIEW exists_opt full_view_name */ - 446, /* (371) full_view_name ::= view_name */ - 446, /* (372) full_view_name ::= db_name NK_DOT view_name */ - 354, /* (373) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - 354, /* (374) cmd ::= DROP STREAM exists_opt stream_name */ - 354, /* (375) cmd ::= PAUSE STREAM exists_opt stream_name */ - 354, /* (376) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 450, /* (377) col_list_opt ::= */ - 450, /* (378) col_list_opt ::= NK_LP col_name_list NK_RP */ - 451, /* (379) tag_def_or_ref_opt ::= */ - 451, /* (380) tag_def_or_ref_opt ::= tags_def */ - 451, /* (381) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - 449, /* (382) stream_options ::= */ - 449, /* (383) stream_options ::= stream_options TRIGGER AT_ONCE */ - 449, /* (384) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - 449, /* (385) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - 449, /* (386) stream_options ::= stream_options WATERMARK duration_literal */ - 449, /* (387) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - 449, /* (388) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - 449, /* (389) stream_options ::= stream_options DELETE_MARK duration_literal */ - 449, /* (390) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 452, /* (391) subtable_opt ::= */ - 452, /* (392) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 453, /* (393) ignore_opt ::= */ - 453, /* (394) ignore_opt ::= IGNORE UNTREATED */ - 354, /* (395) cmd ::= KILL CONNECTION NK_INTEGER */ - 354, /* (396) cmd ::= KILL QUERY NK_STRING */ - 354, /* (397) cmd ::= KILL TRANSACTION NK_INTEGER */ - 354, /* (398) cmd ::= KILL COMPACT NK_INTEGER */ - 354, /* (399) cmd ::= BALANCE VGROUP */ - 354, /* (400) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - 354, /* (401) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 354, /* (402) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 354, /* (403) cmd ::= SPLIT VGROUP NK_INTEGER */ - 455, /* (404) on_vgroup_id ::= */ - 455, /* (405) on_vgroup_id ::= ON NK_INTEGER */ - 456, /* (406) dnode_list ::= DNODE NK_INTEGER */ - 456, /* (407) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 354, /* (408) cmd ::= DELETE FROM full_table_name where_clause_opt */ - 354, /* (409) cmd ::= query_or_subquery */ - 354, /* (410) cmd ::= insert_query */ - 441, /* (411) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - 441, /* (412) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - 357, /* (413) literal ::= NK_INTEGER */ - 357, /* (414) literal ::= NK_FLOAT */ - 357, /* (415) literal ::= NK_STRING */ - 357, /* (416) literal ::= NK_BOOL */ - 357, /* (417) literal ::= TIMESTAMP NK_STRING */ - 357, /* (418) literal ::= duration_literal */ - 357, /* (419) literal ::= NULL */ - 357, /* (420) literal ::= NK_QUESTION */ - 413, /* (421) duration_literal ::= NK_VARIABLE */ - 386, /* (422) signed ::= NK_INTEGER */ - 386, /* (423) signed ::= NK_PLUS NK_INTEGER */ - 386, /* (424) signed ::= NK_MINUS NK_INTEGER */ - 386, /* (425) signed ::= NK_FLOAT */ - 386, /* (426) signed ::= NK_PLUS NK_FLOAT */ - 386, /* (427) signed ::= NK_MINUS NK_FLOAT */ - 401, /* (428) signed_literal ::= signed */ - 401, /* (429) signed_literal ::= NK_STRING */ - 401, /* (430) signed_literal ::= NK_BOOL */ - 401, /* (431) signed_literal ::= TIMESTAMP NK_STRING */ - 401, /* (432) signed_literal ::= duration_literal */ - 401, /* (433) signed_literal ::= NULL */ - 401, /* (434) signed_literal ::= literal_func */ - 401, /* (435) signed_literal ::= NK_QUESTION */ - 458, /* (436) literal_list ::= signed_literal */ - 458, /* (437) literal_list ::= literal_list NK_COMMA signed_literal */ - 369, /* (438) db_name ::= NK_ID */ - 370, /* (439) table_name ::= NK_ID */ - 398, /* (440) column_name ::= NK_ID */ - 415, /* (441) function_name ::= NK_ID */ - 447, /* (442) view_name ::= NK_ID */ - 459, /* (443) table_alias ::= NK_ID */ - 426, /* (444) column_alias ::= NK_ID */ - 426, /* (445) column_alias ::= NK_ALIAS */ - 362, /* (446) user_name ::= NK_ID */ - 371, /* (447) topic_name ::= NK_ID */ - 448, /* (448) stream_name ::= NK_ID */ - 438, /* (449) cgroup_name ::= NK_ID */ - 429, /* (450) index_name ::= NK_ID */ - 460, /* (451) expr_or_subquery ::= expression */ - 454, /* (452) expression ::= literal */ - 454, /* (453) expression ::= pseudo_column */ - 454, /* (454) expression ::= column_reference */ - 454, /* (455) expression ::= function_expression */ - 454, /* (456) expression ::= case_when_expression */ - 454, /* (457) expression ::= NK_LP expression NK_RP */ - 454, /* (458) expression ::= NK_PLUS expr_or_subquery */ - 454, /* (459) expression ::= NK_MINUS expr_or_subquery */ - 454, /* (460) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - 454, /* (461) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - 454, /* (462) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - 454, /* (463) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - 454, /* (464) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - 454, /* (465) expression ::= column_reference NK_ARROW NK_STRING */ - 454, /* (466) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - 454, /* (467) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - 404, /* (468) expression_list ::= expr_or_subquery */ - 404, /* (469) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - 462, /* (470) column_reference ::= column_name */ - 462, /* (471) column_reference ::= table_name NK_DOT column_name */ - 462, /* (472) column_reference ::= NK_ALIAS */ - 462, /* (473) column_reference ::= table_name NK_DOT NK_ALIAS */ - 461, /* (474) pseudo_column ::= ROWTS */ - 461, /* (475) pseudo_column ::= TBNAME */ - 461, /* (476) pseudo_column ::= table_name NK_DOT TBNAME */ - 461, /* (477) pseudo_column ::= QSTART */ - 461, /* (478) pseudo_column ::= QEND */ - 461, /* (479) pseudo_column ::= QDURATION */ - 461, /* (480) pseudo_column ::= WSTART */ - 461, /* (481) pseudo_column ::= WEND */ - 461, /* (482) pseudo_column ::= WDURATION */ - 461, /* (483) pseudo_column ::= IROWTS */ - 461, /* (484) pseudo_column ::= ISFILLED */ - 461, /* (485) pseudo_column ::= QTAGS */ - 463, /* (486) function_expression ::= function_name NK_LP expression_list NK_RP */ - 463, /* (487) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - 463, /* (488) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - 463, /* (489) function_expression ::= literal_func */ - 457, /* (490) literal_func ::= noarg_func NK_LP NK_RP */ - 457, /* (491) literal_func ::= NOW */ - 467, /* (492) noarg_func ::= NOW */ - 467, /* (493) noarg_func ::= TODAY */ - 467, /* (494) noarg_func ::= TIMEZONE */ - 467, /* (495) noarg_func ::= DATABASE */ - 467, /* (496) noarg_func ::= CLIENT_VERSION */ - 467, /* (497) noarg_func ::= SERVER_VERSION */ - 467, /* (498) noarg_func ::= SERVER_STATUS */ - 467, /* (499) noarg_func ::= CURRENT_USER */ - 467, /* (500) noarg_func ::= USER */ - 465, /* (501) star_func ::= COUNT */ - 465, /* (502) star_func ::= FIRST */ - 465, /* (503) star_func ::= LAST */ - 465, /* (504) star_func ::= LAST_ROW */ - 466, /* (505) star_func_para_list ::= NK_STAR */ - 466, /* (506) star_func_para_list ::= other_para_list */ - 468, /* (507) other_para_list ::= star_func_para */ - 468, /* (508) other_para_list ::= other_para_list NK_COMMA star_func_para */ - 469, /* (509) star_func_para ::= expr_or_subquery */ - 469, /* (510) star_func_para ::= table_name NK_DOT NK_STAR */ - 464, /* (511) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - 464, /* (512) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - 470, /* (513) when_then_list ::= when_then_expr */ - 470, /* (514) when_then_list ::= when_then_list when_then_expr */ - 473, /* (515) when_then_expr ::= WHEN common_expression THEN common_expression */ - 471, /* (516) case_when_else_opt ::= */ - 471, /* (517) case_when_else_opt ::= ELSE common_expression */ - 474, /* (518) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - 474, /* (519) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - 474, /* (520) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - 474, /* (521) predicate ::= expr_or_subquery IS NULL */ - 474, /* (522) predicate ::= expr_or_subquery IS NOT NULL */ - 474, /* (523) predicate ::= expr_or_subquery in_op in_predicate_value */ - 475, /* (524) compare_op ::= NK_LT */ - 475, /* (525) compare_op ::= NK_GT */ - 475, /* (526) compare_op ::= NK_LE */ - 475, /* (527) compare_op ::= NK_GE */ - 475, /* (528) compare_op ::= NK_NE */ - 475, /* (529) compare_op ::= NK_EQ */ - 475, /* (530) compare_op ::= LIKE */ - 475, /* (531) compare_op ::= NOT LIKE */ - 475, /* (532) compare_op ::= MATCH */ - 475, /* (533) compare_op ::= NMATCH */ - 475, /* (534) compare_op ::= CONTAINS */ - 476, /* (535) in_op ::= IN */ - 476, /* (536) in_op ::= NOT IN */ - 477, /* (537) in_predicate_value ::= NK_LP literal_list NK_RP */ - 478, /* (538) boolean_value_expression ::= boolean_primary */ - 478, /* (539) boolean_value_expression ::= NOT boolean_primary */ - 478, /* (540) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 478, /* (541) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 479, /* (542) boolean_primary ::= predicate */ - 479, /* (543) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 472, /* (544) common_expression ::= expr_or_subquery */ - 472, /* (545) common_expression ::= boolean_value_expression */ - 480, /* (546) from_clause_opt ::= */ - 480, /* (547) from_clause_opt ::= FROM table_reference_list */ - 481, /* (548) table_reference_list ::= table_reference */ - 481, /* (549) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 482, /* (550) table_reference ::= table_primary */ - 482, /* (551) table_reference ::= joined_table */ - 483, /* (552) table_primary ::= table_name alias_opt */ - 483, /* (553) table_primary ::= db_name NK_DOT table_name alias_opt */ - 483, /* (554) table_primary ::= subquery alias_opt */ - 483, /* (555) table_primary ::= parenthesized_joined_table */ - 485, /* (556) alias_opt ::= */ - 485, /* (557) alias_opt ::= table_alias */ - 485, /* (558) alias_opt ::= AS table_alias */ - 487, /* (559) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 487, /* (560) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 484, /* (561) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 488, /* (562) join_type ::= */ - 488, /* (563) join_type ::= INNER */ - 489, /* (564) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 490, /* (565) hint_list ::= */ - 490, /* (566) hint_list ::= NK_HINT */ - 492, /* (567) tag_mode_opt ::= */ - 492, /* (568) tag_mode_opt ::= TAGS */ - 491, /* (569) set_quantifier_opt ::= */ - 491, /* (570) set_quantifier_opt ::= DISTINCT */ - 491, /* (571) set_quantifier_opt ::= ALL */ - 493, /* (572) select_list ::= select_item */ - 493, /* (573) select_list ::= select_list NK_COMMA select_item */ - 501, /* (574) select_item ::= NK_STAR */ - 501, /* (575) select_item ::= common_expression */ - 501, /* (576) select_item ::= common_expression column_alias */ - 501, /* (577) select_item ::= common_expression AS column_alias */ - 501, /* (578) select_item ::= table_name NK_DOT NK_STAR */ - 437, /* (579) where_clause_opt ::= */ - 437, /* (580) where_clause_opt ::= WHERE search_condition */ - 494, /* (581) partition_by_clause_opt ::= */ - 494, /* (582) partition_by_clause_opt ::= PARTITION BY partition_list */ - 502, /* (583) partition_list ::= partition_item */ - 502, /* (584) partition_list ::= partition_list NK_COMMA partition_item */ - 503, /* (585) partition_item ::= expr_or_subquery */ - 503, /* (586) partition_item ::= expr_or_subquery column_alias */ - 503, /* (587) partition_item ::= expr_or_subquery AS column_alias */ - 498, /* (588) twindow_clause_opt ::= */ - 498, /* (589) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - 498, /* (590) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - 498, /* (591) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 498, /* (592) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 498, /* (593) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 498, /* (594) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ - 498, /* (595) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 431, /* (596) sliding_opt ::= */ - 431, /* (597) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - 504, /* (598) interval_sliding_duration_literal ::= NK_VARIABLE */ - 504, /* (599) interval_sliding_duration_literal ::= NK_STRING */ - 504, /* (600) interval_sliding_duration_literal ::= NK_INTEGER */ - 497, /* (601) fill_opt ::= */ - 497, /* (602) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 497, /* (603) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - 497, /* (604) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - 505, /* (605) fill_mode ::= NONE */ - 505, /* (606) fill_mode ::= PREV */ - 505, /* (607) fill_mode ::= NULL */ - 505, /* (608) fill_mode ::= NULL_F */ - 505, /* (609) fill_mode ::= LINEAR */ - 505, /* (610) fill_mode ::= NEXT */ - 499, /* (611) group_by_clause_opt ::= */ - 499, /* (612) group_by_clause_opt ::= GROUP BY group_by_list */ - 506, /* (613) group_by_list ::= expr_or_subquery */ - 506, /* (614) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 500, /* (615) having_clause_opt ::= */ - 500, /* (616) having_clause_opt ::= HAVING search_condition */ - 495, /* (617) range_opt ::= */ - 495, /* (618) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - 495, /* (619) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 496, /* (620) every_opt ::= */ - 496, /* (621) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - 507, /* (622) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 508, /* (623) query_simple ::= query_specification */ - 508, /* (624) query_simple ::= union_query_expression */ - 512, /* (625) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - 512, /* (626) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - 513, /* (627) query_simple_or_subquery ::= query_simple */ - 513, /* (628) query_simple_or_subquery ::= subquery */ - 436, /* (629) query_or_subquery ::= query_expression */ - 436, /* (630) query_or_subquery ::= subquery */ - 509, /* (631) order_by_clause_opt ::= */ - 509, /* (632) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 510, /* (633) slimit_clause_opt ::= */ - 510, /* (634) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 510, /* (635) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 510, /* (636) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 511, /* (637) limit_clause_opt ::= */ - 511, /* (638) limit_clause_opt ::= LIMIT NK_INTEGER */ - 511, /* (639) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 511, /* (640) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 486, /* (641) subquery ::= NK_LP query_expression NK_RP */ - 486, /* (642) subquery ::= NK_LP subquery NK_RP */ - 372, /* (643) search_condition ::= common_expression */ - 514, /* (644) sort_specification_list ::= sort_specification */ - 514, /* (645) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 515, /* (646) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 516, /* (647) ordering_specification_opt ::= */ - 516, /* (648) ordering_specification_opt ::= ASC */ - 516, /* (649) ordering_specification_opt ::= DESC */ - 517, /* (650) null_ordering_opt ::= */ - 517, /* (651) null_ordering_opt ::= NULLS FIRST */ - 517, /* (652) null_ordering_opt ::= NULLS LAST */ - 400, /* (653) column_options ::= */ - 400, /* (654) column_options ::= column_options ENCODE NK_STRING */ - 400, /* (655) column_options ::= column_options COMPRESS NK_STRING */ - 400, /* (656) column_options ::= column_options LEVEL NK_STRING */ + 355, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 355, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 356, /* (2) account_options ::= */ + 356, /* (3) account_options ::= account_options PPS literal */ + 356, /* (4) account_options ::= account_options TSERIES literal */ + 356, /* (5) account_options ::= account_options STORAGE literal */ + 356, /* (6) account_options ::= account_options STREAMS literal */ + 356, /* (7) account_options ::= account_options QTIME literal */ + 356, /* (8) account_options ::= account_options DBS literal */ + 356, /* (9) account_options ::= account_options USERS literal */ + 356, /* (10) account_options ::= account_options CONNS literal */ + 356, /* (11) account_options ::= account_options STATE literal */ + 357, /* (12) alter_account_options ::= alter_account_option */ + 357, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 359, /* (14) alter_account_option ::= PASS literal */ + 359, /* (15) alter_account_option ::= PPS literal */ + 359, /* (16) alter_account_option ::= TSERIES literal */ + 359, /* (17) alter_account_option ::= STORAGE literal */ + 359, /* (18) alter_account_option ::= STREAMS literal */ + 359, /* (19) alter_account_option ::= QTIME literal */ + 359, /* (20) alter_account_option ::= DBS literal */ + 359, /* (21) alter_account_option ::= USERS literal */ + 359, /* (22) alter_account_option ::= CONNS literal */ + 359, /* (23) alter_account_option ::= STATE literal */ + 360, /* (24) ip_range_list ::= NK_STRING */ + 360, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ + 361, /* (26) white_list ::= HOST ip_range_list */ + 362, /* (27) white_list_opt ::= */ + 362, /* (28) white_list_opt ::= white_list */ + 355, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ + 355, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ + 355, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + 355, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + 355, /* (33) cmd ::= ALTER USER user_name ADD white_list */ + 355, /* (34) cmd ::= ALTER USER user_name DROP white_list */ + 355, /* (35) cmd ::= DROP USER user_name */ + 364, /* (36) sysinfo_opt ::= */ + 364, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ + 355, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ + 355, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ + 365, /* (40) privileges ::= ALL */ + 365, /* (41) privileges ::= priv_type_list */ + 365, /* (42) privileges ::= SUBSCRIBE */ + 368, /* (43) priv_type_list ::= priv_type */ + 368, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + 369, /* (45) priv_type ::= READ */ + 369, /* (46) priv_type ::= WRITE */ + 369, /* (47) priv_type ::= ALTER */ + 366, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + 366, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + 366, /* (50) priv_level ::= db_name NK_DOT table_name */ + 366, /* (51) priv_level ::= topic_name */ + 367, /* (52) with_opt ::= */ + 367, /* (53) with_opt ::= WITH search_condition */ + 355, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + 355, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + 355, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + 355, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + 355, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + 355, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + 355, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 355, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 355, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + 355, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 355, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + 374, /* (65) dnode_endpoint ::= NK_STRING */ + 374, /* (66) dnode_endpoint ::= NK_ID */ + 374, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 375, /* (68) force_opt ::= */ + 375, /* (69) force_opt ::= FORCE */ + 376, /* (70) unsafe_opt ::= UNSAFE */ + 355, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ + 355, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ + 355, /* (73) cmd ::= ALTER LOCAL NK_STRING */ + 355, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 355, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 355, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 355, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + 355, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 355, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 355, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 355, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 355, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 355, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 355, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + 355, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + 355, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 355, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ + 355, /* (88) cmd ::= USE db_name */ + 355, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ + 355, /* (90) cmd ::= FLUSH DATABASE db_name */ + 355, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ + 355, /* (92) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + 377, /* (93) not_exists_opt ::= IF NOT EXISTS */ + 377, /* (94) not_exists_opt ::= */ + 379, /* (95) exists_opt ::= IF EXISTS */ + 379, /* (96) exists_opt ::= */ + 378, /* (97) db_options ::= */ + 378, /* (98) db_options ::= db_options BUFFER NK_INTEGER */ + 378, /* (99) db_options ::= db_options CACHEMODEL NK_STRING */ + 378, /* (100) db_options ::= db_options CACHESIZE NK_INTEGER */ + 378, /* (101) db_options ::= db_options COMP NK_INTEGER */ + 378, /* (102) db_options ::= db_options DURATION NK_INTEGER */ + 378, /* (103) db_options ::= db_options DURATION NK_VARIABLE */ + 378, /* (104) db_options ::= db_options MAXROWS NK_INTEGER */ + 378, /* (105) db_options ::= db_options MINROWS NK_INTEGER */ + 378, /* (106) db_options ::= db_options KEEP integer_list */ + 378, /* (107) db_options ::= db_options KEEP variable_list */ + 378, /* (108) db_options ::= db_options PAGES NK_INTEGER */ + 378, /* (109) db_options ::= db_options PAGESIZE NK_INTEGER */ + 378, /* (110) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + 378, /* (111) db_options ::= db_options PRECISION NK_STRING */ + 378, /* (112) db_options ::= db_options REPLICA NK_INTEGER */ + 378, /* (113) db_options ::= db_options VGROUPS NK_INTEGER */ + 378, /* (114) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 378, /* (115) db_options ::= db_options RETENTIONS retention_list */ + 378, /* (116) db_options ::= db_options SCHEMALESS NK_INTEGER */ + 378, /* (117) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + 378, /* (118) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + 378, /* (119) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + 378, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 378, /* (121) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + 378, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 378, /* (123) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + 378, /* (124) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + 378, /* (125) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + 378, /* (126) db_options ::= db_options TABLE_PREFIX signed */ + 378, /* (127) db_options ::= db_options TABLE_SUFFIX signed */ + 378, /* (128) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + 380, /* (129) alter_db_options ::= alter_db_option */ + 380, /* (130) alter_db_options ::= alter_db_options alter_db_option */ + 388, /* (131) alter_db_option ::= BUFFER NK_INTEGER */ + 388, /* (132) alter_db_option ::= CACHEMODEL NK_STRING */ + 388, /* (133) alter_db_option ::= CACHESIZE NK_INTEGER */ + 388, /* (134) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + 388, /* (135) alter_db_option ::= KEEP integer_list */ + 388, /* (136) alter_db_option ::= KEEP variable_list */ + 388, /* (137) alter_db_option ::= PAGES NK_INTEGER */ + 388, /* (138) alter_db_option ::= REPLICA NK_INTEGER */ + 388, /* (139) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + 388, /* (140) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + 388, /* (141) alter_db_option ::= MINROWS NK_INTEGER */ + 388, /* (142) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + 388, /* (143) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 388, /* (144) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + 388, /* (145) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 388, /* (146) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + 384, /* (147) integer_list ::= NK_INTEGER */ + 384, /* (148) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 385, /* (149) variable_list ::= NK_VARIABLE */ + 385, /* (150) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 386, /* (151) retention_list ::= retention */ + 386, /* (152) retention_list ::= retention_list NK_COMMA retention */ + 389, /* (153) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 389, /* (154) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 381, /* (155) speed_opt ::= */ + 381, /* (156) speed_opt ::= BWLIMIT NK_INTEGER */ + 382, /* (157) start_opt ::= */ + 382, /* (158) start_opt ::= START WITH NK_INTEGER */ + 382, /* (159) start_opt ::= START WITH NK_STRING */ + 382, /* (160) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 383, /* (161) end_opt ::= */ + 383, /* (162) end_opt ::= END WITH NK_INTEGER */ + 383, /* (163) end_opt ::= END WITH NK_STRING */ + 383, /* (164) end_opt ::= END WITH TIMESTAMP NK_STRING */ + 355, /* (165) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 355, /* (166) cmd ::= CREATE TABLE multi_create_clause */ + 355, /* (167) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 355, /* (168) cmd ::= DROP TABLE multi_drop_clause */ + 355, /* (169) cmd ::= DROP STABLE exists_opt full_table_name */ + 355, /* (170) cmd ::= ALTER TABLE alter_table_clause */ + 355, /* (171) cmd ::= ALTER STABLE alter_table_clause */ + 397, /* (172) alter_table_clause ::= full_table_name alter_table_options */ + 397, /* (173) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 397, /* (174) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 397, /* (175) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 397, /* (176) alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ + 397, /* (177) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 397, /* (178) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 397, /* (179) alter_table_clause ::= full_table_name DROP TAG column_name */ + 397, /* (180) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 397, /* (181) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 397, /* (182) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + 394, /* (183) multi_create_clause ::= create_subtable_clause */ + 394, /* (184) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 403, /* (185) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + 396, /* (186) multi_drop_clause ::= drop_table_clause */ + 396, /* (187) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + 406, /* (188) drop_table_clause ::= exists_opt full_table_name */ + 404, /* (189) specific_cols_opt ::= */ + 404, /* (190) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + 390, /* (191) full_table_name ::= table_name */ + 390, /* (192) full_table_name ::= db_name NK_DOT table_name */ + 408, /* (193) tag_def_list ::= tag_def */ + 408, /* (194) tag_def_list ::= tag_def_list NK_COMMA tag_def */ + 409, /* (195) tag_def ::= column_name type_name */ + 391, /* (196) column_def_list ::= column_def */ + 391, /* (197) column_def_list ::= column_def_list NK_COMMA column_def */ + 410, /* (198) column_def ::= column_name type_name column_options */ + 400, /* (199) type_name ::= BOOL */ + 400, /* (200) type_name ::= TINYINT */ + 400, /* (201) type_name ::= SMALLINT */ + 400, /* (202) type_name ::= INT */ + 400, /* (203) type_name ::= INTEGER */ + 400, /* (204) type_name ::= BIGINT */ + 400, /* (205) type_name ::= FLOAT */ + 400, /* (206) type_name ::= DOUBLE */ + 400, /* (207) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 400, /* (208) type_name ::= TIMESTAMP */ + 400, /* (209) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 400, /* (210) type_name ::= TINYINT UNSIGNED */ + 400, /* (211) type_name ::= SMALLINT UNSIGNED */ + 400, /* (212) type_name ::= INT UNSIGNED */ + 400, /* (213) type_name ::= BIGINT UNSIGNED */ + 400, /* (214) type_name ::= JSON */ + 400, /* (215) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 400, /* (216) type_name ::= MEDIUMBLOB */ + 400, /* (217) type_name ::= BLOB */ + 400, /* (218) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 400, /* (219) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + 400, /* (220) type_name ::= DECIMAL */ + 400, /* (221) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 400, /* (222) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 392, /* (223) tags_def_opt ::= */ + 392, /* (224) tags_def_opt ::= tags_def */ + 395, /* (225) tags_def ::= TAGS NK_LP tag_def_list NK_RP */ + 393, /* (226) table_options ::= */ + 393, /* (227) table_options ::= table_options COMMENT NK_STRING */ + 393, /* (228) table_options ::= table_options MAX_DELAY duration_list */ + 393, /* (229) table_options ::= table_options WATERMARK duration_list */ + 393, /* (230) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + 393, /* (231) table_options ::= table_options TTL NK_INTEGER */ + 393, /* (232) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 393, /* (233) table_options ::= table_options DELETE_MARK duration_list */ + 398, /* (234) alter_table_options ::= alter_table_option */ + 398, /* (235) alter_table_options ::= alter_table_options alter_table_option */ + 413, /* (236) alter_table_option ::= COMMENT NK_STRING */ + 413, /* (237) alter_table_option ::= TTL NK_INTEGER */ + 411, /* (238) duration_list ::= duration_literal */ + 411, /* (239) duration_list ::= duration_list NK_COMMA duration_literal */ + 412, /* (240) rollup_func_list ::= rollup_func_name */ + 412, /* (241) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + 415, /* (242) rollup_func_name ::= function_name */ + 415, /* (243) rollup_func_name ::= FIRST */ + 415, /* (244) rollup_func_name ::= LAST */ + 407, /* (245) col_name_list ::= col_name */ + 407, /* (246) col_name_list ::= col_name_list NK_COMMA col_name */ + 417, /* (247) col_name ::= column_name */ + 355, /* (248) cmd ::= SHOW DNODES */ + 355, /* (249) cmd ::= SHOW USERS */ + 355, /* (250) cmd ::= SHOW USER PRIVILEGES */ + 355, /* (251) cmd ::= SHOW db_kind_opt DATABASES */ + 355, /* (252) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + 355, /* (253) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 355, /* (254) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 355, /* (255) cmd ::= SHOW MNODES */ + 355, /* (256) cmd ::= SHOW QNODES */ + 355, /* (257) cmd ::= SHOW FUNCTIONS */ + 355, /* (258) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 355, /* (259) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + 355, /* (260) cmd ::= SHOW STREAMS */ + 355, /* (261) cmd ::= SHOW ACCOUNTS */ + 355, /* (262) cmd ::= SHOW APPS */ + 355, /* (263) cmd ::= SHOW CONNECTIONS */ + 355, /* (264) cmd ::= SHOW LICENCES */ + 355, /* (265) cmd ::= SHOW GRANTS */ + 355, /* (266) cmd ::= SHOW GRANTS FULL */ + 355, /* (267) cmd ::= SHOW GRANTS LOGS */ + 355, /* (268) cmd ::= SHOW CLUSTER MACHINES */ + 355, /* (269) cmd ::= SHOW CREATE DATABASE db_name */ + 355, /* (270) cmd ::= SHOW CREATE TABLE full_table_name */ + 355, /* (271) cmd ::= SHOW CREATE STABLE full_table_name */ + 355, /* (272) cmd ::= SHOW QUERIES */ + 355, /* (273) cmd ::= SHOW SCORES */ + 355, /* (274) cmd ::= SHOW TOPICS */ + 355, /* (275) cmd ::= SHOW VARIABLES */ + 355, /* (276) cmd ::= SHOW CLUSTER VARIABLES */ + 355, /* (277) cmd ::= SHOW LOCAL VARIABLES */ + 355, /* (278) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + 355, /* (279) cmd ::= SHOW BNODES */ + 355, /* (280) cmd ::= SHOW SNODES */ + 355, /* (281) cmd ::= SHOW CLUSTER */ + 355, /* (282) cmd ::= SHOW TRANSACTIONS */ + 355, /* (283) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + 355, /* (284) cmd ::= SHOW CONSUMERS */ + 355, /* (285) cmd ::= SHOW SUBSCRIPTIONS */ + 355, /* (286) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + 355, /* (287) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + 355, /* (288) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + 355, /* (289) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + 355, /* (290) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + 355, /* (291) cmd ::= SHOW VNODES */ + 355, /* (292) cmd ::= SHOW db_name_cond_opt ALIVE */ + 355, /* (293) cmd ::= SHOW CLUSTER ALIVE */ + 355, /* (294) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ + 355, /* (295) cmd ::= SHOW CREATE VIEW full_table_name */ + 355, /* (296) cmd ::= SHOW COMPACTS */ + 355, /* (297) cmd ::= SHOW COMPACT NK_INTEGER */ + 419, /* (298) table_kind_db_name_cond_opt ::= */ + 419, /* (299) table_kind_db_name_cond_opt ::= table_kind */ + 419, /* (300) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + 419, /* (301) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + 425, /* (302) table_kind ::= NORMAL */ + 425, /* (303) table_kind ::= CHILD */ + 421, /* (304) db_name_cond_opt ::= */ + 421, /* (305) db_name_cond_opt ::= db_name NK_DOT */ + 420, /* (306) like_pattern_opt ::= */ + 420, /* (307) like_pattern_opt ::= LIKE NK_STRING */ + 422, /* (308) table_name_cond ::= table_name */ + 423, /* (309) from_db_opt ::= */ + 423, /* (310) from_db_opt ::= FROM db_name */ + 424, /* (311) tag_list_opt ::= */ + 424, /* (312) tag_list_opt ::= tag_item */ + 424, /* (313) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + 426, /* (314) tag_item ::= TBNAME */ + 426, /* (315) tag_item ::= QTAGS */ + 426, /* (316) tag_item ::= column_name */ + 426, /* (317) tag_item ::= column_name column_alias */ + 426, /* (318) tag_item ::= column_name AS column_alias */ + 418, /* (319) db_kind_opt ::= */ + 418, /* (320) db_kind_opt ::= USER */ + 418, /* (321) db_kind_opt ::= SYSTEM */ + 355, /* (322) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + 355, /* (323) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + 355, /* (324) cmd ::= DROP INDEX exists_opt full_index_name */ + 429, /* (325) full_index_name ::= index_name */ + 429, /* (326) full_index_name ::= db_name NK_DOT index_name */ + 428, /* (327) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + 428, /* (328) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + 431, /* (329) func_list ::= func */ + 431, /* (330) func_list ::= func_list NK_COMMA func */ + 434, /* (331) func ::= sma_func_name NK_LP expression_list NK_RP */ + 435, /* (332) sma_func_name ::= function_name */ + 435, /* (333) sma_func_name ::= COUNT */ + 435, /* (334) sma_func_name ::= FIRST */ + 435, /* (335) sma_func_name ::= LAST */ + 435, /* (336) sma_func_name ::= LAST_ROW */ + 433, /* (337) sma_stream_opt ::= */ + 433, /* (338) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + 433, /* (339) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + 433, /* (340) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + 436, /* (341) with_meta ::= AS */ + 436, /* (342) with_meta ::= WITH META AS */ + 436, /* (343) with_meta ::= ONLY META AS */ + 355, /* (344) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + 355, /* (345) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + 355, /* (346) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + 355, /* (347) cmd ::= DROP TOPIC exists_opt topic_name */ + 355, /* (348) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + 355, /* (349) cmd ::= DESC full_table_name */ + 355, /* (350) cmd ::= DESCRIBE full_table_name */ + 355, /* (351) cmd ::= RESET QUERY CACHE */ + 355, /* (352) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + 355, /* (353) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 440, /* (354) analyze_opt ::= */ + 440, /* (355) analyze_opt ::= ANALYZE */ + 441, /* (356) explain_options ::= */ + 441, /* (357) explain_options ::= explain_options VERBOSE NK_BOOL */ + 441, /* (358) explain_options ::= explain_options RATIO NK_FLOAT */ + 355, /* (359) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + 355, /* (360) cmd ::= DROP FUNCTION exists_opt function_name */ + 444, /* (361) agg_func_opt ::= */ + 444, /* (362) agg_func_opt ::= AGGREGATE */ + 445, /* (363) bufsize_opt ::= */ + 445, /* (364) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 446, /* (365) language_opt ::= */ + 446, /* (366) language_opt ::= LANGUAGE NK_STRING */ + 443, /* (367) or_replace_opt ::= */ + 443, /* (368) or_replace_opt ::= OR REPLACE */ + 355, /* (369) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + 355, /* (370) cmd ::= DROP VIEW exists_opt full_view_name */ + 447, /* (371) full_view_name ::= view_name */ + 447, /* (372) full_view_name ::= db_name NK_DOT view_name */ + 355, /* (373) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + 355, /* (374) cmd ::= DROP STREAM exists_opt stream_name */ + 355, /* (375) cmd ::= PAUSE STREAM exists_opt stream_name */ + 355, /* (376) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 451, /* (377) col_list_opt ::= */ + 451, /* (378) col_list_opt ::= NK_LP col_name_list NK_RP */ + 452, /* (379) tag_def_or_ref_opt ::= */ + 452, /* (380) tag_def_or_ref_opt ::= tags_def */ + 452, /* (381) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + 450, /* (382) stream_options ::= */ + 450, /* (383) stream_options ::= stream_options TRIGGER AT_ONCE */ + 450, /* (384) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 450, /* (385) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + 450, /* (386) stream_options ::= stream_options WATERMARK duration_literal */ + 450, /* (387) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + 450, /* (388) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + 450, /* (389) stream_options ::= stream_options DELETE_MARK duration_literal */ + 450, /* (390) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 453, /* (391) subtable_opt ::= */ + 453, /* (392) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 454, /* (393) ignore_opt ::= */ + 454, /* (394) ignore_opt ::= IGNORE UNTREATED */ + 355, /* (395) cmd ::= KILL CONNECTION NK_INTEGER */ + 355, /* (396) cmd ::= KILL QUERY NK_STRING */ + 355, /* (397) cmd ::= KILL TRANSACTION NK_INTEGER */ + 355, /* (398) cmd ::= KILL COMPACT NK_INTEGER */ + 355, /* (399) cmd ::= BALANCE VGROUP */ + 355, /* (400) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + 355, /* (401) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 355, /* (402) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 355, /* (403) cmd ::= SPLIT VGROUP NK_INTEGER */ + 456, /* (404) on_vgroup_id ::= */ + 456, /* (405) on_vgroup_id ::= ON NK_INTEGER */ + 457, /* (406) dnode_list ::= DNODE NK_INTEGER */ + 457, /* (407) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 355, /* (408) cmd ::= DELETE FROM full_table_name where_clause_opt */ + 355, /* (409) cmd ::= query_or_subquery */ + 355, /* (410) cmd ::= insert_query */ + 442, /* (411) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + 442, /* (412) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + 358, /* (413) literal ::= NK_INTEGER */ + 358, /* (414) literal ::= NK_FLOAT */ + 358, /* (415) literal ::= NK_STRING */ + 358, /* (416) literal ::= NK_BOOL */ + 358, /* (417) literal ::= TIMESTAMP NK_STRING */ + 358, /* (418) literal ::= duration_literal */ + 358, /* (419) literal ::= NULL */ + 358, /* (420) literal ::= NK_QUESTION */ + 414, /* (421) duration_literal ::= NK_VARIABLE */ + 387, /* (422) signed ::= NK_INTEGER */ + 387, /* (423) signed ::= NK_PLUS NK_INTEGER */ + 387, /* (424) signed ::= NK_MINUS NK_INTEGER */ + 387, /* (425) signed ::= NK_FLOAT */ + 387, /* (426) signed ::= NK_PLUS NK_FLOAT */ + 387, /* (427) signed ::= NK_MINUS NK_FLOAT */ + 402, /* (428) signed_literal ::= signed */ + 402, /* (429) signed_literal ::= NK_STRING */ + 402, /* (430) signed_literal ::= NK_BOOL */ + 402, /* (431) signed_literal ::= TIMESTAMP NK_STRING */ + 402, /* (432) signed_literal ::= duration_literal */ + 402, /* (433) signed_literal ::= NULL */ + 402, /* (434) signed_literal ::= literal_func */ + 402, /* (435) signed_literal ::= NK_QUESTION */ + 459, /* (436) literal_list ::= signed_literal */ + 459, /* (437) literal_list ::= literal_list NK_COMMA signed_literal */ + 370, /* (438) db_name ::= NK_ID */ + 371, /* (439) table_name ::= NK_ID */ + 399, /* (440) column_name ::= NK_ID */ + 416, /* (441) function_name ::= NK_ID */ + 448, /* (442) view_name ::= NK_ID */ + 460, /* (443) table_alias ::= NK_ID */ + 427, /* (444) column_alias ::= NK_ID */ + 427, /* (445) column_alias ::= NK_ALIAS */ + 363, /* (446) user_name ::= NK_ID */ + 372, /* (447) topic_name ::= NK_ID */ + 449, /* (448) stream_name ::= NK_ID */ + 439, /* (449) cgroup_name ::= NK_ID */ + 430, /* (450) index_name ::= NK_ID */ + 461, /* (451) expr_or_subquery ::= expression */ + 455, /* (452) expression ::= literal */ + 455, /* (453) expression ::= pseudo_column */ + 455, /* (454) expression ::= column_reference */ + 455, /* (455) expression ::= function_expression */ + 455, /* (456) expression ::= case_when_expression */ + 455, /* (457) expression ::= NK_LP expression NK_RP */ + 455, /* (458) expression ::= NK_PLUS expr_or_subquery */ + 455, /* (459) expression ::= NK_MINUS expr_or_subquery */ + 455, /* (460) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + 455, /* (461) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + 455, /* (462) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + 455, /* (463) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + 455, /* (464) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + 455, /* (465) expression ::= column_reference NK_ARROW NK_STRING */ + 455, /* (466) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + 455, /* (467) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + 405, /* (468) expression_list ::= expr_or_subquery */ + 405, /* (469) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + 463, /* (470) column_reference ::= column_name */ + 463, /* (471) column_reference ::= table_name NK_DOT column_name */ + 463, /* (472) column_reference ::= NK_ALIAS */ + 463, /* (473) column_reference ::= table_name NK_DOT NK_ALIAS */ + 462, /* (474) pseudo_column ::= ROWTS */ + 462, /* (475) pseudo_column ::= TBNAME */ + 462, /* (476) pseudo_column ::= table_name NK_DOT TBNAME */ + 462, /* (477) pseudo_column ::= QSTART */ + 462, /* (478) pseudo_column ::= QEND */ + 462, /* (479) pseudo_column ::= QDURATION */ + 462, /* (480) pseudo_column ::= WSTART */ + 462, /* (481) pseudo_column ::= WEND */ + 462, /* (482) pseudo_column ::= WDURATION */ + 462, /* (483) pseudo_column ::= IROWTS */ + 462, /* (484) pseudo_column ::= ISFILLED */ + 462, /* (485) pseudo_column ::= QTAGS */ + 464, /* (486) function_expression ::= function_name NK_LP expression_list NK_RP */ + 464, /* (487) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 464, /* (488) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + 464, /* (489) function_expression ::= literal_func */ + 458, /* (490) literal_func ::= noarg_func NK_LP NK_RP */ + 458, /* (491) literal_func ::= NOW */ + 468, /* (492) noarg_func ::= NOW */ + 468, /* (493) noarg_func ::= TODAY */ + 468, /* (494) noarg_func ::= TIMEZONE */ + 468, /* (495) noarg_func ::= DATABASE */ + 468, /* (496) noarg_func ::= CLIENT_VERSION */ + 468, /* (497) noarg_func ::= SERVER_VERSION */ + 468, /* (498) noarg_func ::= SERVER_STATUS */ + 468, /* (499) noarg_func ::= CURRENT_USER */ + 468, /* (500) noarg_func ::= USER */ + 466, /* (501) star_func ::= COUNT */ + 466, /* (502) star_func ::= FIRST */ + 466, /* (503) star_func ::= LAST */ + 466, /* (504) star_func ::= LAST_ROW */ + 467, /* (505) star_func_para_list ::= NK_STAR */ + 467, /* (506) star_func_para_list ::= other_para_list */ + 469, /* (507) other_para_list ::= star_func_para */ + 469, /* (508) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 470, /* (509) star_func_para ::= expr_or_subquery */ + 470, /* (510) star_func_para ::= table_name NK_DOT NK_STAR */ + 465, /* (511) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + 465, /* (512) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + 471, /* (513) when_then_list ::= when_then_expr */ + 471, /* (514) when_then_list ::= when_then_list when_then_expr */ + 474, /* (515) when_then_expr ::= WHEN common_expression THEN common_expression */ + 472, /* (516) case_when_else_opt ::= */ + 472, /* (517) case_when_else_opt ::= ELSE common_expression */ + 475, /* (518) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + 475, /* (519) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + 475, /* (520) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + 475, /* (521) predicate ::= expr_or_subquery IS NULL */ + 475, /* (522) predicate ::= expr_or_subquery IS NOT NULL */ + 475, /* (523) predicate ::= expr_or_subquery in_op in_predicate_value */ + 476, /* (524) compare_op ::= NK_LT */ + 476, /* (525) compare_op ::= NK_GT */ + 476, /* (526) compare_op ::= NK_LE */ + 476, /* (527) compare_op ::= NK_GE */ + 476, /* (528) compare_op ::= NK_NE */ + 476, /* (529) compare_op ::= NK_EQ */ + 476, /* (530) compare_op ::= LIKE */ + 476, /* (531) compare_op ::= NOT LIKE */ + 476, /* (532) compare_op ::= MATCH */ + 476, /* (533) compare_op ::= NMATCH */ + 476, /* (534) compare_op ::= CONTAINS */ + 477, /* (535) in_op ::= IN */ + 477, /* (536) in_op ::= NOT IN */ + 478, /* (537) in_predicate_value ::= NK_LP literal_list NK_RP */ + 479, /* (538) boolean_value_expression ::= boolean_primary */ + 479, /* (539) boolean_value_expression ::= NOT boolean_primary */ + 479, /* (540) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 479, /* (541) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 480, /* (542) boolean_primary ::= predicate */ + 480, /* (543) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 473, /* (544) common_expression ::= expr_or_subquery */ + 473, /* (545) common_expression ::= boolean_value_expression */ + 481, /* (546) from_clause_opt ::= */ + 481, /* (547) from_clause_opt ::= FROM table_reference_list */ + 482, /* (548) table_reference_list ::= table_reference */ + 482, /* (549) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 483, /* (550) table_reference ::= table_primary */ + 483, /* (551) table_reference ::= joined_table */ + 484, /* (552) table_primary ::= table_name alias_opt */ + 484, /* (553) table_primary ::= db_name NK_DOT table_name alias_opt */ + 484, /* (554) table_primary ::= subquery alias_opt */ + 484, /* (555) table_primary ::= parenthesized_joined_table */ + 486, /* (556) alias_opt ::= */ + 486, /* (557) alias_opt ::= table_alias */ + 486, /* (558) alias_opt ::= AS table_alias */ + 488, /* (559) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 488, /* (560) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 485, /* (561) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 489, /* (562) join_type ::= */ + 489, /* (563) join_type ::= INNER */ + 490, /* (564) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 491, /* (565) hint_list ::= */ + 491, /* (566) hint_list ::= NK_HINT */ + 493, /* (567) tag_mode_opt ::= */ + 493, /* (568) tag_mode_opt ::= TAGS */ + 492, /* (569) set_quantifier_opt ::= */ + 492, /* (570) set_quantifier_opt ::= DISTINCT */ + 492, /* (571) set_quantifier_opt ::= ALL */ + 494, /* (572) select_list ::= select_item */ + 494, /* (573) select_list ::= select_list NK_COMMA select_item */ + 502, /* (574) select_item ::= NK_STAR */ + 502, /* (575) select_item ::= common_expression */ + 502, /* (576) select_item ::= common_expression column_alias */ + 502, /* (577) select_item ::= common_expression AS column_alias */ + 502, /* (578) select_item ::= table_name NK_DOT NK_STAR */ + 438, /* (579) where_clause_opt ::= */ + 438, /* (580) where_clause_opt ::= WHERE search_condition */ + 495, /* (581) partition_by_clause_opt ::= */ + 495, /* (582) partition_by_clause_opt ::= PARTITION BY partition_list */ + 503, /* (583) partition_list ::= partition_item */ + 503, /* (584) partition_list ::= partition_list NK_COMMA partition_item */ + 504, /* (585) partition_item ::= expr_or_subquery */ + 504, /* (586) partition_item ::= expr_or_subquery column_alias */ + 504, /* (587) partition_item ::= expr_or_subquery AS column_alias */ + 499, /* (588) twindow_clause_opt ::= */ + 499, /* (589) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + 499, /* (590) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + 499, /* (591) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 499, /* (592) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 499, /* (593) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 499, /* (594) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + 499, /* (595) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 432, /* (596) sliding_opt ::= */ + 432, /* (597) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + 505, /* (598) interval_sliding_duration_literal ::= NK_VARIABLE */ + 505, /* (599) interval_sliding_duration_literal ::= NK_STRING */ + 505, /* (600) interval_sliding_duration_literal ::= NK_INTEGER */ + 498, /* (601) fill_opt ::= */ + 498, /* (602) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 498, /* (603) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + 498, /* (604) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + 506, /* (605) fill_mode ::= NONE */ + 506, /* (606) fill_mode ::= PREV */ + 506, /* (607) fill_mode ::= NULL */ + 506, /* (608) fill_mode ::= NULL_F */ + 506, /* (609) fill_mode ::= LINEAR */ + 506, /* (610) fill_mode ::= NEXT */ + 500, /* (611) group_by_clause_opt ::= */ + 500, /* (612) group_by_clause_opt ::= GROUP BY group_by_list */ + 507, /* (613) group_by_list ::= expr_or_subquery */ + 507, /* (614) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 501, /* (615) having_clause_opt ::= */ + 501, /* (616) having_clause_opt ::= HAVING search_condition */ + 496, /* (617) range_opt ::= */ + 496, /* (618) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + 496, /* (619) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 497, /* (620) every_opt ::= */ + 497, /* (621) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + 508, /* (622) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 509, /* (623) query_simple ::= query_specification */ + 509, /* (624) query_simple ::= union_query_expression */ + 513, /* (625) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + 513, /* (626) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + 514, /* (627) query_simple_or_subquery ::= query_simple */ + 514, /* (628) query_simple_or_subquery ::= subquery */ + 437, /* (629) query_or_subquery ::= query_expression */ + 437, /* (630) query_or_subquery ::= subquery */ + 510, /* (631) order_by_clause_opt ::= */ + 510, /* (632) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 511, /* (633) slimit_clause_opt ::= */ + 511, /* (634) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 511, /* (635) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 511, /* (636) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 512, /* (637) limit_clause_opt ::= */ + 512, /* (638) limit_clause_opt ::= LIMIT NK_INTEGER */ + 512, /* (639) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 512, /* (640) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 487, /* (641) subquery ::= NK_LP query_expression NK_RP */ + 487, /* (642) subquery ::= NK_LP subquery NK_RP */ + 373, /* (643) search_condition ::= common_expression */ + 515, /* (644) sort_specification_list ::= sort_specification */ + 515, /* (645) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 516, /* (646) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 517, /* (647) ordering_specification_opt ::= */ + 517, /* (648) ordering_specification_opt ::= ASC */ + 517, /* (649) ordering_specification_opt ::= DESC */ + 518, /* (650) null_ordering_opt ::= */ + 518, /* (651) null_ordering_opt ::= NULLS FIRST */ + 518, /* (652) null_ordering_opt ::= NULLS LAST */ + 401, /* (653) column_options ::= */ + 401, /* (654) column_options ::= column_options PRIMARY KEY */ + 401, /* (655) column_options ::= column_options ENCODE NK_STRING */ + 401, /* (656) column_options ::= column_options COMPRESS NK_STRING */ + 401, /* (657) column_options ::= column_options LEVEL NK_STRING */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -5031,9 +5049,10 @@ static const signed char yyRuleInfoNRhs[] = { -2, /* (651) null_ordering_opt ::= NULLS FIRST */ -2, /* (652) null_ordering_opt ::= NULLS LAST */ 0, /* (653) column_options ::= */ - -3, /* (654) column_options ::= column_options ENCODE NK_STRING */ - -3, /* (655) column_options ::= column_options COMPRESS NK_STRING */ - -3, /* (656) column_options ::= column_options LEVEL NK_STRING */ + -3, /* (654) column_options ::= column_options PRIMARY KEY */ + -3, /* (655) column_options ::= column_options ENCODE NK_STRING */ + -3, /* (656) column_options ::= column_options COMPRESS NK_STRING */ + -3, /* (657) column_options ::= column_options LEVEL NK_STRING */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -5078,19 +5097,19 @@ static YYACTIONTYPE yy_reduce( case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ #line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 5081 "sql.c" - yy_destructor(yypParser,355,&yymsp[0].minor); +#line 5100 "sql.c" + yy_destructor(yypParser,356,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ #line 51 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 5087 "sql.c" - yy_destructor(yypParser,356,&yymsp[0].minor); +#line 5106 "sql.c" + yy_destructor(yypParser,357,&yymsp[0].minor); break; case 2: /* account_options ::= */ #line 55 "sql.y" { } -#line 5093 "sql.c" +#line 5112 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -5101,26 +5120,26 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,355,&yymsp[-2].minor); +{ yy_destructor(yypParser,356,&yymsp[-2].minor); #line 56 "sql.y" { } -#line 5107 "sql.c" - yy_destructor(yypParser,357,&yymsp[0].minor); +#line 5126 "sql.c" + yy_destructor(yypParser,358,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,358,&yymsp[0].minor); +{ yy_destructor(yypParser,359,&yymsp[0].minor); #line 68 "sql.y" { } -#line 5115 "sql.c" +#line 5134 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,356,&yymsp[-1].minor); +{ yy_destructor(yypParser,357,&yymsp[-1].minor); #line 69 "sql.y" { } -#line 5122 "sql.c" - yy_destructor(yypParser,358,&yymsp[0].minor); +#line 5141 "sql.c" + yy_destructor(yypParser,359,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -5135,25 +5154,25 @@ static YYACTIONTYPE yy_reduce( case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); #line 73 "sql.y" { } -#line 5138 "sql.c" - yy_destructor(yypParser,357,&yymsp[0].minor); +#line 5157 "sql.c" + yy_destructor(yypParser,358,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ #line 86 "sql.y" -{ yylhsminor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5144 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5163 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ #line 87 "sql.y" -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5150 "sql.c" - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = addNodeToList(pCxt, yymsp[-2].minor.yy652, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5169 "sql.c" + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 26: /* white_list ::= HOST ip_range_list */ #line 91 "sql.y" -{ yymsp[-1].minor.yy404 = yymsp[0].minor.yy404; } -#line 5156 "sql.c" +{ yymsp[-1].minor.yy652 = yymsp[0].minor.yy652; } +#line 5175 "sql.c" break; case 27: /* white_list_opt ::= */ case 189: /* specific_cols_opt ::= */ yytestcase(yyruleno==189); @@ -5165,137 +5184,137 @@ static YYACTIONTYPE yy_reduce( case 611: /* group_by_clause_opt ::= */ yytestcase(yyruleno==611); case 631: /* order_by_clause_opt ::= */ yytestcase(yyruleno==631); #line 95 "sql.y" -{ yymsp[1].minor.yy404 = NULL; } -#line 5169 "sql.c" +{ yymsp[1].minor.yy652 = NULL; } +#line 5188 "sql.c" break; case 28: /* white_list_opt ::= white_list */ case 224: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==224); case 380: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==380); case 506: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==506); #line 96 "sql.y" -{ yylhsminor.yy404 = yymsp[0].minor.yy404; } -#line 5177 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = yymsp[0].minor.yy652; } +#line 5196 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ #line 100 "sql.y" { - pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy701, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy915); - pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy404); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy863, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy203); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy652); } -#line 5186 "sql.c" +#line 5205 "sql.c" break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ #line 104 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy701, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } -#line 5191 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy863, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 5210 "sql.c" break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ #line 105 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy701, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } -#line 5196 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy863, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 5215 "sql.c" break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ #line 106 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy701, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } -#line 5201 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy863, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 5220 "sql.c" break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ #line 107 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy701, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy404); } -#line 5206 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy863, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy652); } +#line 5225 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ #line 108 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy701, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy404); } -#line 5211 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy863, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy652); } +#line 5230 "sql.c" break; case 35: /* cmd ::= DROP USER user_name */ #line 109 "sql.y" -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy701); } -#line 5216 "sql.c" +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy863); } +#line 5235 "sql.c" break; case 36: /* sysinfo_opt ::= */ #line 113 "sql.y" -{ yymsp[1].minor.yy915 = 1; } -#line 5221 "sql.c" +{ yymsp[1].minor.yy203 = 1; } +#line 5240 "sql.c" break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ #line 114 "sql.y" -{ yymsp[-1].minor.yy915 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } -#line 5226 "sql.c" +{ yymsp[-1].minor.yy203 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5245 "sql.c" break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ #line 117 "sql.y" -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy949, &yymsp[-3].minor.yy21, &yymsp[0].minor.yy701, yymsp[-2].minor.yy896); } -#line 5231 "sql.c" +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy57, &yymsp[-3].minor.yy825, &yymsp[0].minor.yy863, yymsp[-2].minor.yy110); } +#line 5250 "sql.c" break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ #line 118 "sql.y" -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy949, &yymsp[-3].minor.yy21, &yymsp[0].minor.yy701, yymsp[-2].minor.yy896); } -#line 5236 "sql.c" +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy57, &yymsp[-3].minor.yy825, &yymsp[0].minor.yy863, yymsp[-2].minor.yy110); } +#line 5255 "sql.c" break; case 40: /* privileges ::= ALL */ #line 122 "sql.y" -{ yymsp[0].minor.yy949 = PRIVILEGE_TYPE_ALL; } -#line 5241 "sql.c" +{ yymsp[0].minor.yy57 = PRIVILEGE_TYPE_ALL; } +#line 5260 "sql.c" break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); #line 123 "sql.y" -{ yylhsminor.yy949 = yymsp[0].minor.yy949; } -#line 5247 "sql.c" - yymsp[0].minor.yy949 = yylhsminor.yy949; +{ yylhsminor.yy57 = yymsp[0].minor.yy57; } +#line 5266 "sql.c" + yymsp[0].minor.yy57 = yylhsminor.yy57; break; case 42: /* privileges ::= SUBSCRIBE */ #line 124 "sql.y" -{ yymsp[0].minor.yy949 = PRIVILEGE_TYPE_SUBSCRIBE; } -#line 5253 "sql.c" +{ yymsp[0].minor.yy57 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 5272 "sql.c" break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ #line 129 "sql.y" -{ yylhsminor.yy949 = yymsp[-2].minor.yy949 | yymsp[0].minor.yy949; } -#line 5258 "sql.c" - yymsp[-2].minor.yy949 = yylhsminor.yy949; +{ yylhsminor.yy57 = yymsp[-2].minor.yy57 | yymsp[0].minor.yy57; } +#line 5277 "sql.c" + yymsp[-2].minor.yy57 = yylhsminor.yy57; break; case 45: /* priv_type ::= READ */ #line 133 "sql.y" -{ yymsp[0].minor.yy949 = PRIVILEGE_TYPE_READ; } -#line 5264 "sql.c" +{ yymsp[0].minor.yy57 = PRIVILEGE_TYPE_READ; } +#line 5283 "sql.c" break; case 46: /* priv_type ::= WRITE */ #line 134 "sql.y" -{ yymsp[0].minor.yy949 = PRIVILEGE_TYPE_WRITE; } -#line 5269 "sql.c" +{ yymsp[0].minor.yy57 = PRIVILEGE_TYPE_WRITE; } +#line 5288 "sql.c" break; case 47: /* priv_type ::= ALTER */ #line 135 "sql.y" -{ yymsp[0].minor.yy949 = PRIVILEGE_TYPE_ALTER; } -#line 5274 "sql.c" +{ yymsp[0].minor.yy57 = PRIVILEGE_TYPE_ALTER; } +#line 5293 "sql.c" break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ #line 139 "sql.y" -{ yylhsminor.yy21.first = yymsp[-2].minor.yy0; yylhsminor.yy21.second = yymsp[0].minor.yy0; } -#line 5279 "sql.c" - yymsp[-2].minor.yy21 = yylhsminor.yy21; +{ yylhsminor.yy825.first = yymsp[-2].minor.yy0; yylhsminor.yy825.second = yymsp[0].minor.yy0; } +#line 5298 "sql.c" + yymsp[-2].minor.yy825 = yylhsminor.yy825; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ #line 140 "sql.y" -{ yylhsminor.yy21.first = yymsp[-2].minor.yy701; yylhsminor.yy21.second = yymsp[0].minor.yy0; } -#line 5285 "sql.c" - yymsp[-2].minor.yy21 = yylhsminor.yy21; +{ yylhsminor.yy825.first = yymsp[-2].minor.yy863; yylhsminor.yy825.second = yymsp[0].minor.yy0; } +#line 5304 "sql.c" + yymsp[-2].minor.yy825 = yylhsminor.yy825; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ #line 141 "sql.y" -{ yylhsminor.yy21.first = yymsp[-2].minor.yy701; yylhsminor.yy21.second = yymsp[0].minor.yy701; } -#line 5291 "sql.c" - yymsp[-2].minor.yy21 = yylhsminor.yy21; +{ yylhsminor.yy825.first = yymsp[-2].minor.yy863; yylhsminor.yy825.second = yymsp[0].minor.yy863; } +#line 5310 "sql.c" + yymsp[-2].minor.yy825 = yylhsminor.yy825; break; case 51: /* priv_level ::= topic_name */ #line 142 "sql.y" -{ yylhsminor.yy21.first = yymsp[0].minor.yy701; yylhsminor.yy21.second = nil_token; } -#line 5297 "sql.c" - yymsp[0].minor.yy21 = yylhsminor.yy21; +{ yylhsminor.yy825.first = yymsp[0].minor.yy863; yylhsminor.yy825.second = nil_token; } +#line 5316 "sql.c" + yymsp[0].minor.yy825 = yylhsminor.yy825; break; case 52: /* with_opt ::= */ case 157: /* start_opt ::= */ yytestcase(yyruleno==157); @@ -5314,71 +5333,71 @@ static YYACTIONTYPE yy_reduce( case 633: /* slimit_clause_opt ::= */ yytestcase(yyruleno==633); case 637: /* limit_clause_opt ::= */ yytestcase(yyruleno==637); #line 144 "sql.y" -{ yymsp[1].minor.yy896 = NULL; } -#line 5318 "sql.c" +{ yymsp[1].minor.yy110 = NULL; } +#line 5337 "sql.c" break; case 53: /* with_opt ::= WITH search_condition */ case 547: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==547); case 580: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==580); case 616: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==616); #line 145 "sql.y" -{ yymsp[-1].minor.yy896 = yymsp[0].minor.yy896; } -#line 5326 "sql.c" +{ yymsp[-1].minor.yy110 = yymsp[0].minor.yy110; } +#line 5345 "sql.c" break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ #line 148 "sql.y" -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy701, NULL); } -#line 5331 "sql.c" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy863, NULL); } +#line 5350 "sql.c" break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ #line 149 "sql.y" -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy0); } -#line 5336 "sql.c" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy0); } +#line 5355 "sql.c" break; case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ #line 150 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy733, false); } -#line 5341 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy1019, false); } +#line 5360 "sql.c" break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ #line 151 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy701, yymsp[0].minor.yy733, false); } -#line 5346 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy863, yymsp[0].minor.yy1019, false); } +#line 5365 "sql.c" break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ #line 152 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy733); } -#line 5351 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy1019); } +#line 5370 "sql.c" break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ #line 153 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy701, false, yymsp[0].minor.yy733); } -#line 5356 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy863, false, yymsp[0].minor.yy1019); } +#line 5375 "sql.c" break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ #line 154 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } -#line 5361 "sql.c" +#line 5380 "sql.c" break; case 61: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ #line 155 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5366 "sql.c" +#line 5385 "sql.c" break; case 62: /* cmd ::= ALTER ALL DNODES NK_STRING */ #line 156 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } -#line 5371 "sql.c" +#line 5390 "sql.c" break; case 63: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ #line 157 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5376 "sql.c" +#line 5395 "sql.c" break; case 64: /* cmd ::= RESTORE DNODE NK_INTEGER */ #line 158 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } -#line 5381 "sql.c" +#line 5400 "sql.c" break; case 65: /* dnode_endpoint ::= NK_STRING */ case 66: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==66); @@ -5414,9 +5433,9 @@ static YYACTIONTYPE yy_reduce( case 503: /* star_func ::= LAST */ yytestcase(yyruleno==503); case 504: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==504); #line 162 "sql.y" -{ yylhsminor.yy701 = yymsp[0].minor.yy0; } -#line 5418 "sql.c" - yymsp[0].minor.yy701 = yylhsminor.yy701; +{ yylhsminor.yy863 = yymsp[0].minor.yy0; } +#line 5437 "sql.c" + yymsp[0].minor.yy863 = yylhsminor.yy863; break; case 68: /* force_opt ::= */ case 94: /* not_exists_opt ::= */ yytestcase(yyruleno==94); @@ -5428,8 +5447,8 @@ static YYACTIONTYPE yy_reduce( case 567: /* tag_mode_opt ::= */ yytestcase(yyruleno==567); case 569: /* set_quantifier_opt ::= */ yytestcase(yyruleno==569); #line 168 "sql.y" -{ yymsp[1].minor.yy733 = false; } -#line 5432 "sql.c" +{ yymsp[1].minor.yy1019 = false; } +#line 5451 "sql.c" break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); @@ -5438,440 +5457,440 @@ static YYACTIONTYPE yy_reduce( case 568: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==568); case 570: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==570); #line 169 "sql.y" -{ yymsp[0].minor.yy733 = true; } -#line 5442 "sql.c" +{ yymsp[0].minor.yy1019 = true; } +#line 5461 "sql.c" break; case 71: /* cmd ::= ALTER CLUSTER NK_STRING */ #line 176 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 5447 "sql.c" +#line 5466 "sql.c" break; case 72: /* cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ #line 177 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5452 "sql.c" +#line 5471 "sql.c" break; case 73: /* cmd ::= ALTER LOCAL NK_STRING */ #line 180 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 5457 "sql.c" +#line 5476 "sql.c" break; case 74: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ #line 181 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5462 "sql.c" +#line 5481 "sql.c" break; case 75: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ #line 184 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5467 "sql.c" +#line 5486 "sql.c" break; case 76: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ #line 185 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5472 "sql.c" +#line 5491 "sql.c" break; case 77: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ #line 186 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5477 "sql.c" +#line 5496 "sql.c" break; case 78: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ #line 189 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 5482 "sql.c" +#line 5501 "sql.c" break; case 79: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ #line 190 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 5487 "sql.c" +#line 5506 "sql.c" break; case 80: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ #line 193 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 5492 "sql.c" +#line 5511 "sql.c" break; case 81: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ #line 194 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 5497 "sql.c" +#line 5516 "sql.c" break; case 82: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ #line 197 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5502 "sql.c" +#line 5521 "sql.c" break; case 83: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ #line 198 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5507 "sql.c" +#line 5526 "sql.c" break; case 84: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ #line 199 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5512 "sql.c" +#line 5531 "sql.c" break; case 85: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ #line 202 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } -#line 5517 "sql.c" +#line 5536 "sql.c" break; case 86: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ #line 205 "sql.y" -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy733, &yymsp[-1].minor.yy701, yymsp[0].minor.yy896); } -#line 5522 "sql.c" +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy1019, &yymsp[-1].minor.yy863, yymsp[0].minor.yy110); } +#line 5541 "sql.c" break; case 87: /* cmd ::= DROP DATABASE exists_opt db_name */ #line 206 "sql.y" -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy733, &yymsp[0].minor.yy701); } -#line 5527 "sql.c" +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy1019, &yymsp[0].minor.yy863); } +#line 5546 "sql.c" break; case 88: /* cmd ::= USE db_name */ #line 207 "sql.y" -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy701); } -#line 5532 "sql.c" +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy863); } +#line 5551 "sql.c" break; case 89: /* cmd ::= ALTER DATABASE db_name alter_db_options */ #line 208 "sql.y" -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy701, yymsp[0].minor.yy896); } -#line 5537 "sql.c" +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy863, yymsp[0].minor.yy110); } +#line 5556 "sql.c" break; case 90: /* cmd ::= FLUSH DATABASE db_name */ #line 209 "sql.y" -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy701); } -#line 5542 "sql.c" +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy863); } +#line 5561 "sql.c" break; case 91: /* cmd ::= TRIM DATABASE db_name speed_opt */ #line 210 "sql.y" -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy701, yymsp[0].minor.yy396); } -#line 5547 "sql.c" +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy863, yymsp[0].minor.yy376); } +#line 5566 "sql.c" break; case 92: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ #line 211 "sql.y" -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy701, yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 5552 "sql.c" +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy863, yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 5571 "sql.c" break; case 93: /* not_exists_opt ::= IF NOT EXISTS */ #line 215 "sql.y" -{ yymsp[-2].minor.yy733 = true; } -#line 5557 "sql.c" +{ yymsp[-2].minor.yy1019 = true; } +#line 5576 "sql.c" break; case 95: /* exists_opt ::= IF EXISTS */ case 368: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==368); case 394: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==394); #line 220 "sql.y" -{ yymsp[-1].minor.yy733 = true; } -#line 5564 "sql.c" +{ yymsp[-1].minor.yy1019 = true; } +#line 5583 "sql.c" break; case 97: /* db_options ::= */ #line 223 "sql.y" -{ yymsp[1].minor.yy896 = createDefaultDatabaseOptions(pCxt); } -#line 5569 "sql.c" +{ yymsp[1].minor.yy110 = createDefaultDatabaseOptions(pCxt); } +#line 5588 "sql.c" break; case 98: /* db_options ::= db_options BUFFER NK_INTEGER */ #line 224 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } -#line 5574 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } +#line 5593 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 99: /* db_options ::= db_options CACHEMODEL NK_STRING */ #line 225 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } -#line 5580 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } +#line 5599 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 100: /* db_options ::= db_options CACHESIZE NK_INTEGER */ #line 226 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } -#line 5586 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } +#line 5605 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 101: /* db_options ::= db_options COMP NK_INTEGER */ #line 227 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_COMP, &yymsp[0].minor.yy0); } -#line 5592 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_COMP, &yymsp[0].minor.yy0); } +#line 5611 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 102: /* db_options ::= db_options DURATION NK_INTEGER */ case 103: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==103); #line 228 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } -#line 5599 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } +#line 5618 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 104: /* db_options ::= db_options MAXROWS NK_INTEGER */ #line 230 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } -#line 5605 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } +#line 5624 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 105: /* db_options ::= db_options MINROWS NK_INTEGER */ #line 231 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } -#line 5611 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } +#line 5630 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 106: /* db_options ::= db_options KEEP integer_list */ case 107: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==107); #line 232 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_KEEP, yymsp[0].minor.yy404); } -#line 5618 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_KEEP, yymsp[0].minor.yy652); } +#line 5637 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 108: /* db_options ::= db_options PAGES NK_INTEGER */ #line 234 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } -#line 5624 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } +#line 5643 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 109: /* db_options ::= db_options PAGESIZE NK_INTEGER */ #line 235 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } -#line 5630 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } +#line 5649 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 110: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ #line 236 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } -#line 5636 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } +#line 5655 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 111: /* db_options ::= db_options PRECISION NK_STRING */ #line 237 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } -#line 5642 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } +#line 5661 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 112: /* db_options ::= db_options REPLICA NK_INTEGER */ #line 238 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } -#line 5648 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } +#line 5667 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 113: /* db_options ::= db_options VGROUPS NK_INTEGER */ #line 240 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } -#line 5654 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } +#line 5673 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 114: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ #line 241 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } -#line 5660 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } +#line 5679 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 115: /* db_options ::= db_options RETENTIONS retention_list */ #line 242 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_RETENTIONS, yymsp[0].minor.yy404); } -#line 5666 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_RETENTIONS, yymsp[0].minor.yy652); } +#line 5685 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 116: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ #line 243 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } -#line 5672 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } +#line 5691 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 117: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ #line 244 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_WAL, &yymsp[0].minor.yy0); } -#line 5678 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_WAL, &yymsp[0].minor.yy0); } +#line 5697 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 118: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ #line 245 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } -#line 5684 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } +#line 5703 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 119: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ #line 246 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } -#line 5690 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } +#line 5709 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 120: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ #line 247 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-3].minor.yy896, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-3].minor.yy110, DB_OPTION_WAL_RETENTION_PERIOD, &t); } -#line 5700 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +#line 5719 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 121: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ #line 252 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } -#line 5706 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } +#line 5725 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 122: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ #line 253 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-3].minor.yy896, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-3].minor.yy110, DB_OPTION_WAL_RETENTION_SIZE, &t); } -#line 5716 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +#line 5735 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 123: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ #line 258 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } -#line 5722 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } +#line 5741 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 124: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ #line 259 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } -#line 5728 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } +#line 5747 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 125: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ #line 260 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } -#line 5734 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } +#line 5753 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 126: /* db_options ::= db_options TABLE_PREFIX signed */ #line 261 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy896); } -#line 5740 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy110); } +#line 5759 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 127: /* db_options ::= db_options TABLE_SUFFIX signed */ #line 262 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy896); } -#line 5746 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy110); } +#line 5765 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 128: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ #line 263 "sql.y" -{ yylhsminor.yy896 = setDatabaseOption(pCxt, yymsp[-2].minor.yy896, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } -#line 5752 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setDatabaseOption(pCxt, yymsp[-2].minor.yy110, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } +#line 5771 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 129: /* alter_db_options ::= alter_db_option */ #line 265 "sql.y" -{ yylhsminor.yy896 = createAlterDatabaseOptions(pCxt); yylhsminor.yy896 = setAlterDatabaseOption(pCxt, yylhsminor.yy896, &yymsp[0].minor.yy529); } -#line 5758 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterDatabaseOptions(pCxt); yylhsminor.yy110 = setAlterDatabaseOption(pCxt, yylhsminor.yy110, &yymsp[0].minor.yy491); } +#line 5777 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 130: /* alter_db_options ::= alter_db_options alter_db_option */ #line 266 "sql.y" -{ yylhsminor.yy896 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy896, &yymsp[0].minor.yy529); } -#line 5764 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy110, &yymsp[0].minor.yy491); } +#line 5783 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 131: /* alter_db_option ::= BUFFER NK_INTEGER */ #line 270 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5770 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5789 "sql.c" break; case 132: /* alter_db_option ::= CACHEMODEL NK_STRING */ #line 271 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5775 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5794 "sql.c" break; case 133: /* alter_db_option ::= CACHESIZE NK_INTEGER */ #line 272 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5780 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5799 "sql.c" break; case 134: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ #line 273 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5785 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5804 "sql.c" break; case 135: /* alter_db_option ::= KEEP integer_list */ case 136: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==136); #line 274 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_KEEP; yymsp[-1].minor.yy529.pList = yymsp[0].minor.yy404; } -#line 5791 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_KEEP; yymsp[-1].minor.yy491.pList = yymsp[0].minor.yy652; } +#line 5810 "sql.c" break; case 137: /* alter_db_option ::= PAGES NK_INTEGER */ #line 276 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_PAGES; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5796 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_PAGES; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5815 "sql.c" break; case 138: /* alter_db_option ::= REPLICA NK_INTEGER */ #line 277 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5801 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5820 "sql.c" break; case 139: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ #line 279 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_WAL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5806 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_WAL; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5825 "sql.c" break; case 140: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ #line 280 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5811 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5830 "sql.c" break; case 141: /* alter_db_option ::= MINROWS NK_INTEGER */ #line 281 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5816 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5835 "sql.c" break; case 142: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ #line 282 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5821 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5840 "sql.c" break; case 143: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ #line 283 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy529.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy529.val = t; + yymsp[-2].minor.yy491.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy491.val = t; } -#line 5830 "sql.c" +#line 5849 "sql.c" break; case 144: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ #line 288 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5835 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5854 "sql.c" break; case 145: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ #line 289 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy529.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy529.val = t; + yymsp[-2].minor.yy491.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy491.val = t; } -#line 5844 "sql.c" +#line 5863 "sql.c" break; case 146: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ #line 294 "sql.y" -{ yymsp[-1].minor.yy529.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 5849 "sql.c" +{ yymsp[-1].minor.yy491.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 5868 "sql.c" break; case 147: /* integer_list ::= NK_INTEGER */ #line 298 "sql.y" -{ yylhsminor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 5854 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 5873 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 148: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 407: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==407); #line 299 "sql.y" -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 5861 "sql.c" - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = addNodeToList(pCxt, yymsp[-2].minor.yy652, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 5880 "sql.c" + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 149: /* variable_list ::= NK_VARIABLE */ #line 303 "sql.y" -{ yylhsminor.yy404 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5867 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5886 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 150: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ #line 304 "sql.y" -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5873 "sql.c" - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = addNodeToList(pCxt, yymsp[-2].minor.yy652, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5892 "sql.c" + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 151: /* retention_list ::= retention */ case 183: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==183); @@ -5889,9 +5908,9 @@ static YYACTIONTYPE yy_reduce( case 583: /* partition_list ::= partition_item */ yytestcase(yyruleno==583); case 644: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==644); #line 308 "sql.y" -{ yylhsminor.yy404 = createNodeList(pCxt, yymsp[0].minor.yy896); } -#line 5893 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createNodeList(pCxt, yymsp[0].minor.yy110); } +#line 5912 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 152: /* retention_list ::= retention_list NK_COMMA retention */ case 187: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==187); @@ -5907,1118 +5926,1118 @@ static YYACTIONTYPE yy_reduce( case 584: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==584); case 645: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==645); #line 309 "sql.y" -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, yymsp[0].minor.yy896); } -#line 5911 "sql.c" - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = addNodeToList(pCxt, yymsp[-2].minor.yy652, yymsp[0].minor.yy110); } +#line 5930 "sql.c" + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 153: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 154: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==154); #line 311 "sql.y" -{ yylhsminor.yy896 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5918 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5937 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 155: /* speed_opt ::= */ case 363: /* bufsize_opt ::= */ yytestcase(yyruleno==363); #line 316 "sql.y" -{ yymsp[1].minor.yy396 = 0; } -#line 5925 "sql.c" +{ yymsp[1].minor.yy376 = 0; } +#line 5944 "sql.c" break; case 156: /* speed_opt ::= BWLIMIT NK_INTEGER */ case 364: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==364); #line 317 "sql.y" -{ yymsp[-1].minor.yy396 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } -#line 5931 "sql.c" +{ yymsp[-1].minor.yy376 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5950 "sql.c" break; case 158: /* start_opt ::= START WITH NK_INTEGER */ case 162: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==162); #line 320 "sql.y" -{ yymsp[-2].minor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } -#line 5937 "sql.c" +{ yymsp[-2].minor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 5956 "sql.c" break; case 159: /* start_opt ::= START WITH NK_STRING */ case 163: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==163); #line 321 "sql.y" -{ yymsp[-2].minor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 5943 "sql.c" +{ yymsp[-2].minor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 5962 "sql.c" break; case 160: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 164: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==164); #line 322 "sql.y" -{ yymsp[-3].minor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 5949 "sql.c" +{ yymsp[-3].minor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 5968 "sql.c" break; case 165: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 167: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==167); #line 331 "sql.y" -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy733, yymsp[-5].minor.yy896, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy896); } -#line 5955 "sql.c" +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy1019, yymsp[-5].minor.yy110, yymsp[-3].minor.yy652, yymsp[-1].minor.yy652, yymsp[0].minor.yy110); } +#line 5974 "sql.c" break; case 166: /* cmd ::= CREATE TABLE multi_create_clause */ #line 332 "sql.y" -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy404); } -#line 5960 "sql.c" +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy652); } +#line 5979 "sql.c" break; case 168: /* cmd ::= DROP TABLE multi_drop_clause */ #line 335 "sql.y" -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy404); } -#line 5965 "sql.c" +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy652); } +#line 5984 "sql.c" break; case 169: /* cmd ::= DROP STABLE exists_opt full_table_name */ #line 336 "sql.y" -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy733, yymsp[0].minor.yy896); } -#line 5970 "sql.c" +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy1019, yymsp[0].minor.yy110); } +#line 5989 "sql.c" break; case 170: /* cmd ::= ALTER TABLE alter_table_clause */ case 409: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==409); case 410: /* cmd ::= insert_query */ yytestcase(yyruleno==410); #line 338 "sql.y" -{ pCxt->pRootNode = yymsp[0].minor.yy896; } -#line 5977 "sql.c" +{ pCxt->pRootNode = yymsp[0].minor.yy110; } +#line 5996 "sql.c" break; case 171: /* cmd ::= ALTER STABLE alter_table_clause */ #line 339 "sql.y" -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy896); } -#line 5982 "sql.c" +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy110); } +#line 6001 "sql.c" break; case 172: /* alter_table_clause ::= full_table_name alter_table_options */ #line 341 "sql.y" -{ yylhsminor.yy896 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 5987 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 6006 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 173: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ #line 343 "sql.y" -{ yylhsminor.yy896 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy896, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy701, yymsp[0].minor.yy504); } -#line 5993 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy110, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy863, yymsp[0].minor.yy34); } +#line 6012 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 174: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ #line 344 "sql.y" -{ yylhsminor.yy896 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy896, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy701); } -#line 5999 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy110, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy863); } +#line 6018 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 175: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ #line 346 "sql.y" -{ yylhsminor.yy896 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy896, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy701, yymsp[0].minor.yy504); } -#line 6005 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy110, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy863, yymsp[0].minor.yy34); } +#line 6024 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 176: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ #line 348 "sql.y" -{ yylhsminor.yy896 = createAlterTableAddModifyColOptions(pCxt, yymsp[-4].minor.yy896, TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS, &yymsp[-1].minor.yy701, yymsp[0].minor.yy896); } -#line 6011 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableAddModifyColOptions(pCxt, yymsp[-4].minor.yy110, TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS, &yymsp[-1].minor.yy863, yymsp[0].minor.yy110); } +#line 6030 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 177: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ #line 350 "sql.y" -{ yylhsminor.yy896 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy896, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy701, &yymsp[0].minor.yy701); } -#line 6017 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy110, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy863, &yymsp[0].minor.yy863); } +#line 6036 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 178: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ #line 352 "sql.y" -{ yylhsminor.yy896 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy896, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy701, yymsp[0].minor.yy504); } -#line 6023 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy110, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy863, yymsp[0].minor.yy34); } +#line 6042 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 179: /* alter_table_clause ::= full_table_name DROP TAG column_name */ #line 353 "sql.y" -{ yylhsminor.yy896 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy896, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy701); } -#line 6029 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy110, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy863); } +#line 6048 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 180: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ #line 355 "sql.y" -{ yylhsminor.yy896 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy896, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy701, yymsp[0].minor.yy504); } -#line 6035 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy110, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy863, yymsp[0].minor.yy34); } +#line 6054 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 181: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ #line 357 "sql.y" -{ yylhsminor.yy896 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy896, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy701, &yymsp[0].minor.yy701); } -#line 6041 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy110, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy863, &yymsp[0].minor.yy863); } +#line 6060 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 182: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ #line 359 "sql.y" -{ yylhsminor.yy896 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy896, &yymsp[-2].minor.yy701, yymsp[0].minor.yy896); } -#line 6047 "sql.c" - yymsp[-5].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy110, &yymsp[-2].minor.yy863, yymsp[0].minor.yy110); } +#line 6066 "sql.c" + yymsp[-5].minor.yy110 = yylhsminor.yy110; break; case 184: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 514: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==514); #line 364 "sql.y" -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-1].minor.yy404, yymsp[0].minor.yy896); } -#line 6054 "sql.c" - yymsp[-1].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = addNodeToList(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy110); } +#line 6073 "sql.c" + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; case 185: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ #line 368 "sql.y" -{ yylhsminor.yy896 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy733, yymsp[-8].minor.yy896, yymsp[-6].minor.yy896, yymsp[-5].minor.yy404, yymsp[-2].minor.yy404, yymsp[0].minor.yy896); } -#line 6060 "sql.c" - yymsp[-9].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy1019, yymsp[-8].minor.yy110, yymsp[-6].minor.yy110, yymsp[-5].minor.yy652, yymsp[-2].minor.yy652, yymsp[0].minor.yy110); } +#line 6079 "sql.c" + yymsp[-9].minor.yy110 = yylhsminor.yy110; break; case 188: /* drop_table_clause ::= exists_opt full_table_name */ #line 375 "sql.y" -{ yylhsminor.yy896 = createDropTableClause(pCxt, yymsp[-1].minor.yy733, yymsp[0].minor.yy896); } -#line 6066 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createDropTableClause(pCxt, yymsp[-1].minor.yy1019, yymsp[0].minor.yy110); } +#line 6085 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 190: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ case 378: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==378); #line 380 "sql.y" -{ yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404; } -#line 6073 "sql.c" +{ yymsp[-2].minor.yy652 = yymsp[-1].minor.yy652; } +#line 6092 "sql.c" break; case 191: /* full_table_name ::= table_name */ #line 382 "sql.y" -{ yylhsminor.yy896 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy701, NULL); } -#line 6078 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy863, NULL); } +#line 6097 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 192: /* full_table_name ::= db_name NK_DOT table_name */ #line 383 "sql.y" -{ yylhsminor.yy896 = createRealTableNode(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy701, NULL); } -#line 6084 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRealTableNode(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy863, NULL); } +#line 6103 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 195: /* tag_def ::= column_name type_name */ #line 389 "sql.y" -{ yylhsminor.yy896 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy701, yymsp[0].minor.yy504, NULL); } -#line 6090 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy863, yymsp[0].minor.yy34, NULL); } +#line 6109 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 198: /* column_def ::= column_name type_name column_options */ #line 397 "sql.y" -{ yylhsminor.yy896 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy701, yymsp[-1].minor.yy504, yymsp[0].minor.yy896); } -#line 6096 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy863, yymsp[-1].minor.yy34, yymsp[0].minor.yy110); } +#line 6115 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 199: /* type_name ::= BOOL */ #line 401 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BOOL); } -#line 6102 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 6121 "sql.c" break; case 200: /* type_name ::= TINYINT */ #line 402 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TINYINT); } -#line 6107 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 6126 "sql.c" break; case 201: /* type_name ::= SMALLINT */ #line 403 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_SMALLINT); } -#line 6112 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 6131 "sql.c" break; case 202: /* type_name ::= INT */ case 203: /* type_name ::= INTEGER */ yytestcase(yyruleno==203); #line 404 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_INT); } -#line 6118 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_INT); } +#line 6137 "sql.c" break; case 204: /* type_name ::= BIGINT */ #line 406 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BIGINT); } -#line 6123 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 6142 "sql.c" break; case 205: /* type_name ::= FLOAT */ #line 407 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_FLOAT); } -#line 6128 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 6147 "sql.c" break; case 206: /* type_name ::= DOUBLE */ #line 408 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DOUBLE); } -#line 6133 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 6152 "sql.c" break; case 207: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ #line 409 "sql.y" -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } -#line 6138 "sql.c" +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 6157 "sql.c" break; case 208: /* type_name ::= TIMESTAMP */ #line 410 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } -#line 6143 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 6162 "sql.c" break; case 209: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ #line 411 "sql.y" -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } -#line 6148 "sql.c" +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 6167 "sql.c" break; case 210: /* type_name ::= TINYINT UNSIGNED */ #line 412 "sql.y" -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UTINYINT); } -#line 6153 "sql.c" +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 6172 "sql.c" break; case 211: /* type_name ::= SMALLINT UNSIGNED */ #line 413 "sql.y" -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_USMALLINT); } -#line 6158 "sql.c" +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 6177 "sql.c" break; case 212: /* type_name ::= INT UNSIGNED */ #line 414 "sql.y" -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UINT); } -#line 6163 "sql.c" +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 6182 "sql.c" break; case 213: /* type_name ::= BIGINT UNSIGNED */ #line 415 "sql.y" -{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UBIGINT); } -#line 6168 "sql.c" +{ yymsp[-1].minor.yy34 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 6187 "sql.c" break; case 214: /* type_name ::= JSON */ #line 416 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_JSON); } -#line 6173 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 6192 "sql.c" break; case 215: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ #line 417 "sql.y" -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } -#line 6178 "sql.c" +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 6197 "sql.c" break; case 216: /* type_name ::= MEDIUMBLOB */ #line 418 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } -#line 6183 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 6202 "sql.c" break; case 217: /* type_name ::= BLOB */ #line 419 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BLOB); } -#line 6188 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 6207 "sql.c" break; case 218: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ #line 420 "sql.y" -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } -#line 6193 "sql.c" +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 6212 "sql.c" break; case 219: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ #line 421 "sql.y" -{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } -#line 6198 "sql.c" +{ yymsp[-3].minor.yy34 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 6217 "sql.c" break; case 220: /* type_name ::= DECIMAL */ #line 422 "sql.y" -{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6203 "sql.c" +{ yymsp[0].minor.yy34 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6222 "sql.c" break; case 221: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ #line 423 "sql.y" -{ yymsp[-3].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6208 "sql.c" +{ yymsp[-3].minor.yy34 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6227 "sql.c" break; case 222: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ #line 424 "sql.y" -{ yymsp[-5].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6213 "sql.c" +{ yymsp[-5].minor.yy34 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6232 "sql.c" break; case 225: /* tags_def ::= TAGS NK_LP tag_def_list NK_RP */ case 381: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==381); #line 433 "sql.y" -{ yymsp[-3].minor.yy404 = yymsp[-1].minor.yy404; } -#line 6219 "sql.c" +{ yymsp[-3].minor.yy652 = yymsp[-1].minor.yy652; } +#line 6238 "sql.c" break; case 226: /* table_options ::= */ #line 435 "sql.y" -{ yymsp[1].minor.yy896 = createDefaultTableOptions(pCxt); } -#line 6224 "sql.c" +{ yymsp[1].minor.yy110 = createDefaultTableOptions(pCxt); } +#line 6243 "sql.c" break; case 227: /* table_options ::= table_options COMMENT NK_STRING */ #line 436 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-2].minor.yy896, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } -#line 6229 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-2].minor.yy110, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } +#line 6248 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 228: /* table_options ::= table_options MAX_DELAY duration_list */ #line 437 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-2].minor.yy896, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy404); } -#line 6235 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-2].minor.yy110, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy652); } +#line 6254 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 229: /* table_options ::= table_options WATERMARK duration_list */ #line 438 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-2].minor.yy896, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy404); } -#line 6241 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-2].minor.yy110, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy652); } +#line 6260 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 230: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ #line 439 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-4].minor.yy896, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy404); } -#line 6247 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-4].minor.yy110, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy652); } +#line 6266 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 231: /* table_options ::= table_options TTL NK_INTEGER */ #line 440 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-2].minor.yy896, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } -#line 6253 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-2].minor.yy110, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } +#line 6272 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 232: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ #line 441 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-4].minor.yy896, TABLE_OPTION_SMA, yymsp[-1].minor.yy404); } -#line 6259 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-4].minor.yy110, TABLE_OPTION_SMA, yymsp[-1].minor.yy652); } +#line 6278 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 233: /* table_options ::= table_options DELETE_MARK duration_list */ #line 442 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-2].minor.yy896, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy404); } -#line 6265 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-2].minor.yy110, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy652); } +#line 6284 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 234: /* alter_table_options ::= alter_table_option */ #line 444 "sql.y" -{ yylhsminor.yy896 = createAlterTableOptions(pCxt); yylhsminor.yy896 = setTableOption(pCxt, yylhsminor.yy896, yymsp[0].minor.yy529.type, &yymsp[0].minor.yy529.val); } -#line 6271 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createAlterTableOptions(pCxt); yylhsminor.yy110 = setTableOption(pCxt, yylhsminor.yy110, yymsp[0].minor.yy491.type, &yymsp[0].minor.yy491.val); } +#line 6290 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 235: /* alter_table_options ::= alter_table_options alter_table_option */ #line 445 "sql.y" -{ yylhsminor.yy896 = setTableOption(pCxt, yymsp[-1].minor.yy896, yymsp[0].minor.yy529.type, &yymsp[0].minor.yy529.val); } -#line 6277 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setTableOption(pCxt, yymsp[-1].minor.yy110, yymsp[0].minor.yy491.type, &yymsp[0].minor.yy491.val); } +#line 6296 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 236: /* alter_table_option ::= COMMENT NK_STRING */ #line 449 "sql.y" -{ yymsp[-1].minor.yy529.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 6283 "sql.c" +{ yymsp[-1].minor.yy491.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 6302 "sql.c" break; case 237: /* alter_table_option ::= TTL NK_INTEGER */ #line 450 "sql.y" -{ yymsp[-1].minor.yy529.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } -#line 6288 "sql.c" +{ yymsp[-1].minor.yy491.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy491.val = yymsp[0].minor.yy0; } +#line 6307 "sql.c" break; case 238: /* duration_list ::= duration_literal */ case 468: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==468); #line 454 "sql.y" -{ yylhsminor.yy404 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy896)); } -#line 6294 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy110)); } +#line 6313 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 239: /* duration_list ::= duration_list NK_COMMA duration_literal */ case 469: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==469); #line 455 "sql.y" -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, releaseRawExprNode(pCxt, yymsp[0].minor.yy896)); } -#line 6301 "sql.c" - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = addNodeToList(pCxt, yymsp[-2].minor.yy652, releaseRawExprNode(pCxt, yymsp[0].minor.yy110)); } +#line 6320 "sql.c" + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 242: /* rollup_func_name ::= function_name */ #line 462 "sql.y" -{ yylhsminor.yy896 = createFunctionNode(pCxt, &yymsp[0].minor.yy701, NULL); } -#line 6307 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createFunctionNode(pCxt, &yymsp[0].minor.yy863, NULL); } +#line 6326 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 243: /* rollup_func_name ::= FIRST */ case 244: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==244); case 315: /* tag_item ::= QTAGS */ yytestcase(yyruleno==315); #line 463 "sql.y" -{ yylhsminor.yy896 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 6315 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 6334 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 247: /* col_name ::= column_name */ case 316: /* tag_item ::= column_name */ yytestcase(yyruleno==316); #line 471 "sql.y" -{ yylhsminor.yy896 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy701); } -#line 6322 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy863); } +#line 6341 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 248: /* cmd ::= SHOW DNODES */ #line 474 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } -#line 6328 "sql.c" +#line 6347 "sql.c" break; case 249: /* cmd ::= SHOW USERS */ #line 475 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } -#line 6333 "sql.c" +#line 6352 "sql.c" break; case 250: /* cmd ::= SHOW USER PRIVILEGES */ #line 476 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } -#line 6338 "sql.c" +#line 6357 "sql.c" break; case 251: /* cmd ::= SHOW db_kind_opt DATABASES */ #line 477 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy705); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy291); } -#line 6346 "sql.c" +#line 6365 "sql.c" break; case 252: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ #line 481 "sql.y" { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy989, yymsp[0].minor.yy896, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy61, yymsp[0].minor.yy110, OP_TYPE_LIKE); } -#line 6353 "sql.c" +#line 6372 "sql.c" break; case 253: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ #line 484 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy896, yymsp[0].minor.yy896, OP_TYPE_LIKE); } -#line 6358 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy110, yymsp[0].minor.yy110, OP_TYPE_LIKE); } +#line 6377 "sql.c" break; case 254: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ #line 485 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy896, NULL, OP_TYPE_LIKE); } -#line 6363 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy110, NULL, OP_TYPE_LIKE); } +#line 6382 "sql.c" break; case 255: /* cmd ::= SHOW MNODES */ #line 486 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } -#line 6368 "sql.c" +#line 6387 "sql.c" break; case 256: /* cmd ::= SHOW QNODES */ #line 488 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } -#line 6373 "sql.c" +#line 6392 "sql.c" break; case 257: /* cmd ::= SHOW FUNCTIONS */ #line 489 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } -#line 6378 "sql.c" +#line 6397 "sql.c" break; case 258: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ #line 490 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy896, yymsp[-1].minor.yy896, OP_TYPE_EQUAL); } -#line 6383 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy110, yymsp[-1].minor.yy110, OP_TYPE_EQUAL); } +#line 6402 "sql.c" break; case 259: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ #line 491 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy701), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy701), OP_TYPE_EQUAL); } -#line 6388 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy863), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy863), OP_TYPE_EQUAL); } +#line 6407 "sql.c" break; case 260: /* cmd ::= SHOW STREAMS */ #line 492 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } -#line 6393 "sql.c" +#line 6412 "sql.c" break; case 261: /* cmd ::= SHOW ACCOUNTS */ #line 493 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 6398 "sql.c" +#line 6417 "sql.c" break; case 262: /* cmd ::= SHOW APPS */ #line 494 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } -#line 6403 "sql.c" +#line 6422 "sql.c" break; case 263: /* cmd ::= SHOW CONNECTIONS */ #line 495 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } -#line 6408 "sql.c" +#line 6427 "sql.c" break; case 264: /* cmd ::= SHOW LICENCES */ case 265: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==265); #line 496 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } -#line 6414 "sql.c" +#line 6433 "sql.c" break; case 266: /* cmd ::= SHOW GRANTS FULL */ #line 498 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); } -#line 6419 "sql.c" +#line 6438 "sql.c" break; case 267: /* cmd ::= SHOW GRANTS LOGS */ #line 499 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); } -#line 6424 "sql.c" +#line 6443 "sql.c" break; case 268: /* cmd ::= SHOW CLUSTER MACHINES */ #line 500 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } -#line 6429 "sql.c" +#line 6448 "sql.c" break; case 269: /* cmd ::= SHOW CREATE DATABASE db_name */ #line 501 "sql.y" -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy701); } -#line 6434 "sql.c" +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy863); } +#line 6453 "sql.c" break; case 270: /* cmd ::= SHOW CREATE TABLE full_table_name */ #line 502 "sql.y" -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy896); } -#line 6439 "sql.c" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy110); } +#line 6458 "sql.c" break; case 271: /* cmd ::= SHOW CREATE STABLE full_table_name */ #line 503 "sql.y" -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy896); } -#line 6444 "sql.c" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy110); } +#line 6463 "sql.c" break; case 272: /* cmd ::= SHOW QUERIES */ #line 504 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } -#line 6449 "sql.c" +#line 6468 "sql.c" break; case 273: /* cmd ::= SHOW SCORES */ #line 505 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } -#line 6454 "sql.c" +#line 6473 "sql.c" break; case 274: /* cmd ::= SHOW TOPICS */ #line 506 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } -#line 6459 "sql.c" +#line 6478 "sql.c" break; case 275: /* cmd ::= SHOW VARIABLES */ case 276: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==276); #line 507 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } -#line 6465 "sql.c" +#line 6484 "sql.c" break; case 277: /* cmd ::= SHOW LOCAL VARIABLES */ #line 509 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } -#line 6470 "sql.c" +#line 6489 "sql.c" break; case 278: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ #line 510 "sql.y" -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy896); } -#line 6475 "sql.c" +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy110); } +#line 6494 "sql.c" break; case 279: /* cmd ::= SHOW BNODES */ #line 511 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } -#line 6480 "sql.c" +#line 6499 "sql.c" break; case 280: /* cmd ::= SHOW SNODES */ #line 512 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } -#line 6485 "sql.c" +#line 6504 "sql.c" break; case 281: /* cmd ::= SHOW CLUSTER */ #line 513 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } -#line 6490 "sql.c" +#line 6509 "sql.c" break; case 282: /* cmd ::= SHOW TRANSACTIONS */ #line 514 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } -#line 6495 "sql.c" +#line 6514 "sql.c" break; case 283: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ #line 515 "sql.y" -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy896); } -#line 6500 "sql.c" +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy110); } +#line 6519 "sql.c" break; case 284: /* cmd ::= SHOW CONSUMERS */ #line 516 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } -#line 6505 "sql.c" +#line 6524 "sql.c" break; case 285: /* cmd ::= SHOW SUBSCRIPTIONS */ #line 517 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } -#line 6510 "sql.c" +#line 6529 "sql.c" break; case 286: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ #line 518 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy896, yymsp[-1].minor.yy896, OP_TYPE_EQUAL); } -#line 6515 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy110, yymsp[-1].minor.yy110, OP_TYPE_EQUAL); } +#line 6534 "sql.c" break; case 287: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ #line 519 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy701), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy701), OP_TYPE_EQUAL); } -#line 6520 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy863), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy863), OP_TYPE_EQUAL); } +#line 6539 "sql.c" break; case 288: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ #line 520 "sql.y" -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy896, yymsp[0].minor.yy896, yymsp[-3].minor.yy404); } -#line 6525 "sql.c" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy110, yymsp[0].minor.yy110, yymsp[-3].minor.yy652); } +#line 6544 "sql.c" break; case 289: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ #line 521 "sql.y" -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy701), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy701), yymsp[-4].minor.yy404); } -#line 6530 "sql.c" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy863), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy863), yymsp[-4].minor.yy652); } +#line 6549 "sql.c" break; case 290: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ #line 522 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } -#line 6535 "sql.c" +#line 6554 "sql.c" break; case 291: /* cmd ::= SHOW VNODES */ #line 523 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } -#line 6540 "sql.c" +#line 6559 "sql.c" break; case 292: /* cmd ::= SHOW db_name_cond_opt ALIVE */ #line 525 "sql.y" -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy896, QUERY_NODE_SHOW_DB_ALIVE_STMT); } -#line 6545 "sql.c" +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy110, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 6564 "sql.c" break; case 293: /* cmd ::= SHOW CLUSTER ALIVE */ #line 526 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } -#line 6550 "sql.c" +#line 6569 "sql.c" break; case 294: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ #line 527 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy896, yymsp[0].minor.yy896, OP_TYPE_LIKE); } -#line 6555 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy110, yymsp[0].minor.yy110, OP_TYPE_LIKE); } +#line 6574 "sql.c" break; case 295: /* cmd ::= SHOW CREATE VIEW full_table_name */ #line 528 "sql.y" -{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy896); } -#line 6560 "sql.c" +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy110); } +#line 6579 "sql.c" break; case 296: /* cmd ::= SHOW COMPACTS */ #line 529 "sql.y" { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } -#line 6565 "sql.c" +#line 6584 "sql.c" break; case 297: /* cmd ::= SHOW COMPACT NK_INTEGER */ #line 530 "sql.y" { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6570 "sql.c" +#line 6589 "sql.c" break; case 298: /* table_kind_db_name_cond_opt ::= */ #line 534 "sql.y" -{ yymsp[1].minor.yy989.kind = SHOW_KIND_ALL; yymsp[1].minor.yy989.dbName = nil_token; } -#line 6575 "sql.c" +{ yymsp[1].minor.yy61.kind = SHOW_KIND_ALL; yymsp[1].minor.yy61.dbName = nil_token; } +#line 6594 "sql.c" break; case 299: /* table_kind_db_name_cond_opt ::= table_kind */ #line 535 "sql.y" -{ yylhsminor.yy989.kind = yymsp[0].minor.yy705; yylhsminor.yy989.dbName = nil_token; } -#line 6580 "sql.c" - yymsp[0].minor.yy989 = yylhsminor.yy989; +{ yylhsminor.yy61.kind = yymsp[0].minor.yy291; yylhsminor.yy61.dbName = nil_token; } +#line 6599 "sql.c" + yymsp[0].minor.yy61 = yylhsminor.yy61; break; case 300: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ #line 536 "sql.y" -{ yylhsminor.yy989.kind = SHOW_KIND_ALL; yylhsminor.yy989.dbName = yymsp[-1].minor.yy701; } -#line 6586 "sql.c" - yymsp[-1].minor.yy989 = yylhsminor.yy989; +{ yylhsminor.yy61.kind = SHOW_KIND_ALL; yylhsminor.yy61.dbName = yymsp[-1].minor.yy863; } +#line 6605 "sql.c" + yymsp[-1].minor.yy61 = yylhsminor.yy61; break; case 301: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ #line 537 "sql.y" -{ yylhsminor.yy989.kind = yymsp[-2].minor.yy705; yylhsminor.yy989.dbName = yymsp[-1].minor.yy701; } -#line 6592 "sql.c" - yymsp[-2].minor.yy989 = yylhsminor.yy989; +{ yylhsminor.yy61.kind = yymsp[-2].minor.yy291; yylhsminor.yy61.dbName = yymsp[-1].minor.yy863; } +#line 6611 "sql.c" + yymsp[-2].minor.yy61 = yylhsminor.yy61; break; case 302: /* table_kind ::= NORMAL */ #line 541 "sql.y" -{ yymsp[0].minor.yy705 = SHOW_KIND_TABLES_NORMAL; } -#line 6598 "sql.c" +{ yymsp[0].minor.yy291 = SHOW_KIND_TABLES_NORMAL; } +#line 6617 "sql.c" break; case 303: /* table_kind ::= CHILD */ #line 542 "sql.y" -{ yymsp[0].minor.yy705 = SHOW_KIND_TABLES_CHILD; } -#line 6603 "sql.c" +{ yymsp[0].minor.yy291 = SHOW_KIND_TABLES_CHILD; } +#line 6622 "sql.c" break; case 304: /* db_name_cond_opt ::= */ case 309: /* from_db_opt ::= */ yytestcase(yyruleno==309); #line 544 "sql.y" -{ yymsp[1].minor.yy896 = createDefaultDatabaseCondValue(pCxt); } -#line 6609 "sql.c" +{ yymsp[1].minor.yy110 = createDefaultDatabaseCondValue(pCxt); } +#line 6628 "sql.c" break; case 305: /* db_name_cond_opt ::= db_name NK_DOT */ #line 545 "sql.y" -{ yylhsminor.yy896 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy701); } -#line 6614 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy863); } +#line 6633 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 307: /* like_pattern_opt ::= LIKE NK_STRING */ #line 548 "sql.y" -{ yymsp[-1].minor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 6620 "sql.c" +{ yymsp[-1].minor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 6639 "sql.c" break; case 308: /* table_name_cond ::= table_name */ #line 550 "sql.y" -{ yylhsminor.yy896 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy701); } -#line 6625 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy863); } +#line 6644 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 310: /* from_db_opt ::= FROM db_name */ #line 553 "sql.y" -{ yymsp[-1].minor.yy896 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy701); } -#line 6631 "sql.c" +{ yymsp[-1].minor.yy110 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy863); } +#line 6650 "sql.c" break; case 314: /* tag_item ::= TBNAME */ #line 561 "sql.y" -{ yylhsminor.yy896 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } -#line 6636 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } +#line 6655 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 317: /* tag_item ::= column_name column_alias */ #line 564 "sql.y" -{ yylhsminor.yy896 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy701), &yymsp[0].minor.yy701); } -#line 6642 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy863), &yymsp[0].minor.yy863); } +#line 6661 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 318: /* tag_item ::= column_name AS column_alias */ #line 565 "sql.y" -{ yylhsminor.yy896 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy701), &yymsp[0].minor.yy701); } -#line 6648 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy863), &yymsp[0].minor.yy863); } +#line 6667 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 319: /* db_kind_opt ::= */ #line 569 "sql.y" -{ yymsp[1].minor.yy705 = SHOW_KIND_ALL; } -#line 6654 "sql.c" +{ yymsp[1].minor.yy291 = SHOW_KIND_ALL; } +#line 6673 "sql.c" break; case 320: /* db_kind_opt ::= USER */ #line 570 "sql.y" -{ yymsp[0].minor.yy705 = SHOW_KIND_DATABASES_USER; } -#line 6659 "sql.c" +{ yymsp[0].minor.yy291 = SHOW_KIND_DATABASES_USER; } +#line 6678 "sql.c" break; case 321: /* db_kind_opt ::= SYSTEM */ #line 571 "sql.y" -{ yymsp[0].minor.yy705 = SHOW_KIND_DATABASES_SYSTEM; } -#line 6664 "sql.c" +{ yymsp[0].minor.yy291 = SHOW_KIND_DATABASES_SYSTEM; } +#line 6683 "sql.c" break; case 322: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ #line 575 "sql.y" -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy733, yymsp[-3].minor.yy896, yymsp[-1].minor.yy896, NULL, yymsp[0].minor.yy896); } -#line 6669 "sql.c" +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy1019, yymsp[-3].minor.yy110, yymsp[-1].minor.yy110, NULL, yymsp[0].minor.yy110); } +#line 6688 "sql.c" break; case 323: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ #line 577 "sql.y" -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy733, yymsp[-5].minor.yy896, yymsp[-3].minor.yy896, yymsp[-1].minor.yy404, NULL); } -#line 6674 "sql.c" +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy1019, yymsp[-5].minor.yy110, yymsp[-3].minor.yy110, yymsp[-1].minor.yy652, NULL); } +#line 6693 "sql.c" break; case 324: /* cmd ::= DROP INDEX exists_opt full_index_name */ #line 578 "sql.y" -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy733, yymsp[0].minor.yy896); } -#line 6679 "sql.c" +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy1019, yymsp[0].minor.yy110); } +#line 6698 "sql.c" break; case 325: /* full_index_name ::= index_name */ #line 580 "sql.y" -{ yylhsminor.yy896 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy701); } -#line 6684 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy863); } +#line 6703 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 326: /* full_index_name ::= db_name NK_DOT index_name */ #line 581 "sql.y" -{ yylhsminor.yy896 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy701); } -#line 6690 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy863); } +#line 6709 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 327: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ #line 584 "sql.y" -{ yymsp[-9].minor.yy896 = createIndexOption(pCxt, yymsp[-7].minor.yy404, releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), NULL, yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 6696 "sql.c" +{ yymsp[-9].minor.yy110 = createIndexOption(pCxt, yymsp[-7].minor.yy652, releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), NULL, yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 6715 "sql.c" break; case 328: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ #line 587 "sql.y" -{ yymsp[-11].minor.yy896 = createIndexOption(pCxt, yymsp[-9].minor.yy404, releaseRawExprNode(pCxt, yymsp[-5].minor.yy896), releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 6701 "sql.c" +{ yymsp[-11].minor.yy110 = createIndexOption(pCxt, yymsp[-9].minor.yy652, releaseRawExprNode(pCxt, yymsp[-5].minor.yy110), releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 6720 "sql.c" break; case 331: /* func ::= sma_func_name NK_LP expression_list NK_RP */ #line 594 "sql.y" -{ yylhsminor.yy896 = createFunctionNode(pCxt, &yymsp[-3].minor.yy701, yymsp[-1].minor.yy404); } -#line 6706 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createFunctionNode(pCxt, &yymsp[-3].minor.yy863, yymsp[-1].minor.yy652); } +#line 6725 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 332: /* sma_func_name ::= function_name */ case 557: /* alias_opt ::= table_alias */ yytestcase(yyruleno==557); #line 598 "sql.y" -{ yylhsminor.yy701 = yymsp[0].minor.yy701; } -#line 6713 "sql.c" - yymsp[0].minor.yy701 = yylhsminor.yy701; +{ yylhsminor.yy863 = yymsp[0].minor.yy863; } +#line 6732 "sql.c" + yymsp[0].minor.yy863 = yylhsminor.yy863; break; case 337: /* sma_stream_opt ::= */ case 382: /* stream_options ::= */ yytestcase(yyruleno==382); #line 604 "sql.y" -{ yymsp[1].minor.yy896 = createStreamOptions(pCxt); } -#line 6720 "sql.c" +{ yymsp[1].minor.yy110 = createStreamOptions(pCxt); } +#line 6739 "sql.c" break; case 338: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ #line 605 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy896)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy896); yylhsminor.yy896 = yymsp[-2].minor.yy896; } -#line 6725 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ ((SStreamOptions*)yymsp[-2].minor.yy110)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy110); yylhsminor.yy110 = yymsp[-2].minor.yy110; } +#line 6744 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 339: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ #line 606 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy896)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy896); yylhsminor.yy896 = yymsp[-2].minor.yy896; } -#line 6731 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ ((SStreamOptions*)yymsp[-2].minor.yy110)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy110); yylhsminor.yy110 = yymsp[-2].minor.yy110; } +#line 6750 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 340: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ #line 607 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy896)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy896); yylhsminor.yy896 = yymsp[-2].minor.yy896; } -#line 6737 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ ((SStreamOptions*)yymsp[-2].minor.yy110)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy110); yylhsminor.yy110 = yymsp[-2].minor.yy110; } +#line 6756 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 341: /* with_meta ::= AS */ #line 612 "sql.y" -{ yymsp[0].minor.yy396 = 0; } -#line 6743 "sql.c" +{ yymsp[0].minor.yy376 = 0; } +#line 6762 "sql.c" break; case 342: /* with_meta ::= WITH META AS */ #line 613 "sql.y" -{ yymsp[-2].minor.yy396 = 1; } -#line 6748 "sql.c" +{ yymsp[-2].minor.yy376 = 1; } +#line 6767 "sql.c" break; case 343: /* with_meta ::= ONLY META AS */ #line 614 "sql.y" -{ yymsp[-2].minor.yy396 = 2; } -#line 6753 "sql.c" +{ yymsp[-2].minor.yy376 = 2; } +#line 6772 "sql.c" break; case 344: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ #line 616 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy733, &yymsp[-2].minor.yy701, yymsp[0].minor.yy896); } -#line 6758 "sql.c" +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy1019, &yymsp[-2].minor.yy863, yymsp[0].minor.yy110); } +#line 6777 "sql.c" break; case 345: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ #line 618 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy733, &yymsp[-3].minor.yy701, &yymsp[0].minor.yy701, yymsp[-2].minor.yy396); } -#line 6763 "sql.c" +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy1019, &yymsp[-3].minor.yy863, &yymsp[0].minor.yy863, yymsp[-2].minor.yy376); } +#line 6782 "sql.c" break; case 346: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ #line 620 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy733, &yymsp[-4].minor.yy701, yymsp[-1].minor.yy896, yymsp[-3].minor.yy396, yymsp[0].minor.yy896); } -#line 6768 "sql.c" +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy1019, &yymsp[-4].minor.yy863, yymsp[-1].minor.yy110, yymsp[-3].minor.yy376, yymsp[0].minor.yy110); } +#line 6787 "sql.c" break; case 347: /* cmd ::= DROP TOPIC exists_opt topic_name */ #line 622 "sql.y" -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy733, &yymsp[0].minor.yy701); } -#line 6773 "sql.c" +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy1019, &yymsp[0].minor.yy863); } +#line 6792 "sql.c" break; case 348: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ #line 623 "sql.y" -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy733, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy701); } -#line 6778 "sql.c" +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy1019, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy863); } +#line 6797 "sql.c" break; case 349: /* cmd ::= DESC full_table_name */ case 350: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==350); #line 626 "sql.y" -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy896); } -#line 6784 "sql.c" +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy110); } +#line 6803 "sql.c" break; case 351: /* cmd ::= RESET QUERY CACHE */ #line 630 "sql.y" { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } -#line 6789 "sql.c" +#line 6808 "sql.c" break; case 352: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ case 353: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==353); #line 633 "sql.y" -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy733, yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 6795 "sql.c" +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy1019, yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 6814 "sql.c" break; case 356: /* explain_options ::= */ #line 641 "sql.y" -{ yymsp[1].minor.yy896 = createDefaultExplainOptions(pCxt); } -#line 6800 "sql.c" +{ yymsp[1].minor.yy110 = createDefaultExplainOptions(pCxt); } +#line 6819 "sql.c" break; case 357: /* explain_options ::= explain_options VERBOSE NK_BOOL */ #line 642 "sql.y" -{ yylhsminor.yy896 = setExplainVerbose(pCxt, yymsp[-2].minor.yy896, &yymsp[0].minor.yy0); } -#line 6805 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setExplainVerbose(pCxt, yymsp[-2].minor.yy110, &yymsp[0].minor.yy0); } +#line 6824 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 358: /* explain_options ::= explain_options RATIO NK_FLOAT */ #line 643 "sql.y" -{ yylhsminor.yy896 = setExplainRatio(pCxt, yymsp[-2].minor.yy896, &yymsp[0].minor.yy0); } -#line 6811 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setExplainRatio(pCxt, yymsp[-2].minor.yy110, &yymsp[0].minor.yy0); } +#line 6830 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 359: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ #line 648 "sql.y" -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy733, yymsp[-9].minor.yy733, &yymsp[-6].minor.yy701, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy504, yymsp[-1].minor.yy396, &yymsp[0].minor.yy701, yymsp[-10].minor.yy733); } -#line 6817 "sql.c" +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy1019, yymsp[-9].minor.yy1019, &yymsp[-6].minor.yy863, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy34, yymsp[-1].minor.yy376, &yymsp[0].minor.yy863, yymsp[-10].minor.yy1019); } +#line 6836 "sql.c" break; case 360: /* cmd ::= DROP FUNCTION exists_opt function_name */ #line 649 "sql.y" -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy733, &yymsp[0].minor.yy701); } -#line 6822 "sql.c" +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy1019, &yymsp[0].minor.yy863); } +#line 6841 "sql.c" break; case 365: /* language_opt ::= */ case 404: /* on_vgroup_id ::= */ yytestcase(yyruleno==404); #line 663 "sql.y" -{ yymsp[1].minor.yy701 = nil_token; } -#line 6828 "sql.c" +{ yymsp[1].minor.yy863 = nil_token; } +#line 6847 "sql.c" break; case 366: /* language_opt ::= LANGUAGE NK_STRING */ case 405: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==405); #line 664 "sql.y" -{ yymsp[-1].minor.yy701 = yymsp[0].minor.yy0; } -#line 6834 "sql.c" +{ yymsp[-1].minor.yy863 = yymsp[0].minor.yy0; } +#line 6853 "sql.c" break; case 369: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ #line 673 "sql.y" -{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy733, yymsp[-2].minor.yy896, &yymsp[-1].minor.yy0, yymsp[0].minor.yy896); } -#line 6839 "sql.c" +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy1019, yymsp[-2].minor.yy110, &yymsp[-1].minor.yy0, yymsp[0].minor.yy110); } +#line 6858 "sql.c" break; case 370: /* cmd ::= DROP VIEW exists_opt full_view_name */ #line 674 "sql.y" -{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy733, yymsp[0].minor.yy896); } -#line 6844 "sql.c" +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy1019, yymsp[0].minor.yy110); } +#line 6863 "sql.c" break; case 371: /* full_view_name ::= view_name */ #line 676 "sql.y" -{ yylhsminor.yy896 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy701); } -#line 6849 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy863); } +#line 6868 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 372: /* full_view_name ::= db_name NK_DOT view_name */ #line 677 "sql.y" -{ yylhsminor.yy896 = createViewNode(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy701); } -#line 6855 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createViewNode(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy863); } +#line 6874 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 373: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ #line 682 "sql.y" -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy733, &yymsp[-8].minor.yy701, yymsp[-5].minor.yy896, yymsp[-7].minor.yy896, yymsp[-3].minor.yy404, yymsp[-2].minor.yy896, yymsp[0].minor.yy896, yymsp[-4].minor.yy404); } -#line 6861 "sql.c" +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy1019, &yymsp[-8].minor.yy863, yymsp[-5].minor.yy110, yymsp[-7].minor.yy110, yymsp[-3].minor.yy652, yymsp[-2].minor.yy110, yymsp[0].minor.yy110, yymsp[-4].minor.yy652); } +#line 6880 "sql.c" break; case 374: /* cmd ::= DROP STREAM exists_opt stream_name */ #line 683 "sql.y" -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy733, &yymsp[0].minor.yy701); } -#line 6866 "sql.c" +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy1019, &yymsp[0].minor.yy863); } +#line 6885 "sql.c" break; case 375: /* cmd ::= PAUSE STREAM exists_opt stream_name */ #line 684 "sql.y" -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy733, &yymsp[0].minor.yy701); } -#line 6871 "sql.c" +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy1019, &yymsp[0].minor.yy863); } +#line 6890 "sql.c" break; case 376: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ #line 685 "sql.y" -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy733, yymsp[-1].minor.yy733, &yymsp[0].minor.yy701); } -#line 6876 "sql.c" +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy1019, yymsp[-1].minor.yy1019, &yymsp[0].minor.yy863); } +#line 6895 "sql.c" break; case 383: /* stream_options ::= stream_options TRIGGER AT_ONCE */ case 384: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==384); #line 699 "sql.y" -{ yylhsminor.yy896 = setStreamOptions(pCxt, yymsp[-2].minor.yy896, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } -#line 6882 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setStreamOptions(pCxt, yymsp[-2].minor.yy110, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } +#line 6901 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 385: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ #line 701 "sql.y" -{ yylhsminor.yy896 = setStreamOptions(pCxt, yymsp[-3].minor.yy896, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy896)); } -#line 6888 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setStreamOptions(pCxt, yymsp[-3].minor.yy110, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy110)); } +#line 6907 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 386: /* stream_options ::= stream_options WATERMARK duration_literal */ #line 702 "sql.y" -{ yylhsminor.yy896 = setStreamOptions(pCxt, yymsp[-2].minor.yy896, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy896)); } -#line 6894 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setStreamOptions(pCxt, yymsp[-2].minor.yy110, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy110)); } +#line 6913 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 387: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ #line 703 "sql.y" -{ yylhsminor.yy896 = setStreamOptions(pCxt, yymsp[-3].minor.yy896, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } -#line 6900 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setStreamOptions(pCxt, yymsp[-3].minor.yy110, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } +#line 6919 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 388: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ #line 704 "sql.y" -{ yylhsminor.yy896 = setStreamOptions(pCxt, yymsp[-2].minor.yy896, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } -#line 6906 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setStreamOptions(pCxt, yymsp[-2].minor.yy110, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } +#line 6925 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 389: /* stream_options ::= stream_options DELETE_MARK duration_literal */ #line 705 "sql.y" -{ yylhsminor.yy896 = setStreamOptions(pCxt, yymsp[-2].minor.yy896, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy896)); } -#line 6912 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setStreamOptions(pCxt, yymsp[-2].minor.yy110, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy110)); } +#line 6931 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 390: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ #line 706 "sql.y" -{ yylhsminor.yy896 = setStreamOptions(pCxt, yymsp[-3].minor.yy896, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } -#line 6918 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setStreamOptions(pCxt, yymsp[-3].minor.yy110, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } +#line 6937 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 392: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ case 597: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==597); case 621: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==621); #line 709 "sql.y" -{ yymsp[-3].minor.yy896 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy896); } -#line 6926 "sql.c" +{ yymsp[-3].minor.yy110 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy110); } +#line 6945 "sql.c" break; case 395: /* cmd ::= KILL CONNECTION NK_INTEGER */ #line 717 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } -#line 6931 "sql.c" +#line 6950 "sql.c" break; case 396: /* cmd ::= KILL QUERY NK_STRING */ #line 718 "sql.y" { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6936 "sql.c" +#line 6955 "sql.c" break; case 397: /* cmd ::= KILL TRANSACTION NK_INTEGER */ #line 719 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } -#line 6941 "sql.c" +#line 6960 "sql.c" break; case 398: /* cmd ::= KILL COMPACT NK_INTEGER */ #line 720 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } -#line 6946 "sql.c" +#line 6965 "sql.c" break; case 399: /* cmd ::= BALANCE VGROUP */ #line 723 "sql.y" { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } -#line 6951 "sql.c" +#line 6970 "sql.c" break; case 400: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ #line 724 "sql.y" -{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy701); } -#line 6956 "sql.c" +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy863); } +#line 6975 "sql.c" break; case 401: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ #line 725 "sql.y" { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 6961 "sql.c" +#line 6980 "sql.c" break; case 402: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ #line 726 "sql.y" -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy404); } -#line 6966 "sql.c" +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy652); } +#line 6985 "sql.c" break; case 403: /* cmd ::= SPLIT VGROUP NK_INTEGER */ #line 727 "sql.y" { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6971 "sql.c" +#line 6990 "sql.c" break; case 406: /* dnode_list ::= DNODE NK_INTEGER */ #line 736 "sql.y" -{ yymsp[-1].minor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6976 "sql.c" +{ yymsp[-1].minor.yy652 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6995 "sql.c" break; case 408: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ #line 743 "sql.y" -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 6981 "sql.c" +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 7000 "sql.c" break; case 411: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ #line 752 "sql.y" -{ yymsp[-6].minor.yy896 = createInsertStmt(pCxt, yymsp[-4].minor.yy896, yymsp[-2].minor.yy404, yymsp[0].minor.yy896); } -#line 6986 "sql.c" +{ yymsp[-6].minor.yy110 = createInsertStmt(pCxt, yymsp[-4].minor.yy110, yymsp[-2].minor.yy652, yymsp[0].minor.yy110); } +#line 7005 "sql.c" break; case 412: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ #line 753 "sql.y" -{ yymsp[-3].minor.yy896 = createInsertStmt(pCxt, yymsp[-1].minor.yy896, NULL, yymsp[0].minor.yy896); } -#line 6991 "sql.c" +{ yymsp[-3].minor.yy110 = createInsertStmt(pCxt, yymsp[-1].minor.yy110, NULL, yymsp[0].minor.yy110); } +#line 7010 "sql.c" break; case 413: /* literal ::= NK_INTEGER */ #line 756 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } -#line 6996 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } +#line 7015 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 414: /* literal ::= NK_FLOAT */ #line 757 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } -#line 7002 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } +#line 7021 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 415: /* literal ::= NK_STRING */ #line 758 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 7008 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 7027 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 416: /* literal ::= NK_BOOL */ #line 759 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } -#line 7014 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } +#line 7033 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 417: /* literal ::= TIMESTAMP NK_STRING */ #line 760 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } -#line 7020 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } +#line 7039 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 418: /* literal ::= duration_literal */ case 428: /* signed_literal ::= signed */ yytestcase(yyruleno==428); @@ -7041,89 +7060,89 @@ static YYACTIONTYPE yy_reduce( case 627: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==627); case 629: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==629); #line 761 "sql.y" -{ yylhsminor.yy896 = yymsp[0].minor.yy896; } -#line 7045 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = yymsp[0].minor.yy110; } +#line 7064 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 419: /* literal ::= NULL */ #line 762 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } -#line 7051 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } +#line 7070 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 420: /* literal ::= NK_QUESTION */ #line 763 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 7057 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7076 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 421: /* duration_literal ::= NK_VARIABLE */ case 598: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==598); case 599: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==599); case 600: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==600); #line 765 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 7066 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7085 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 422: /* signed ::= NK_INTEGER */ #line 767 "sql.y" -{ yylhsminor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7072 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7091 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 423: /* signed ::= NK_PLUS NK_INTEGER */ #line 768 "sql.y" -{ yymsp[-1].minor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7078 "sql.c" +{ yymsp[-1].minor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7097 "sql.c" break; case 424: /* signed ::= NK_MINUS NK_INTEGER */ #line 769 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } -#line 7087 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +#line 7106 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 425: /* signed ::= NK_FLOAT */ #line 774 "sql.y" -{ yylhsminor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7093 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7112 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 426: /* signed ::= NK_PLUS NK_FLOAT */ #line 775 "sql.y" -{ yymsp[-1].minor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7099 "sql.c" +{ yymsp[-1].minor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7118 "sql.c" break; case 427: /* signed ::= NK_MINUS NK_FLOAT */ #line 776 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } -#line 7108 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +#line 7127 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 429: /* signed_literal ::= NK_STRING */ #line 783 "sql.y" -{ yylhsminor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 7114 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7133 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 430: /* signed_literal ::= NK_BOOL */ #line 784 "sql.y" -{ yylhsminor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } -#line 7120 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } +#line 7139 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 431: /* signed_literal ::= TIMESTAMP NK_STRING */ #line 785 "sql.y" -{ yymsp[-1].minor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 7126 "sql.c" +{ yymsp[-1].minor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 7145 "sql.c" break; case 432: /* signed_literal ::= duration_literal */ case 434: /* signed_literal ::= literal_func */ yytestcase(yyruleno==434); @@ -7134,156 +7153,156 @@ static YYACTIONTYPE yy_reduce( case 630: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==630); case 643: /* search_condition ::= common_expression */ yytestcase(yyruleno==643); #line 786 "sql.y" -{ yylhsminor.yy896 = releaseRawExprNode(pCxt, yymsp[0].minor.yy896); } -#line 7138 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = releaseRawExprNode(pCxt, yymsp[0].minor.yy110); } +#line 7157 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 433: /* signed_literal ::= NULL */ #line 787 "sql.y" -{ yylhsminor.yy896 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } -#line 7144 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } +#line 7163 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 435: /* signed_literal ::= NK_QUESTION */ #line 789 "sql.y" -{ yylhsminor.yy896 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } -#line 7150 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } +#line 7169 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 453: /* expression ::= pseudo_column */ #line 851 "sql.y" -{ yylhsminor.yy896 = yymsp[0].minor.yy896; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy896, true); } -#line 7156 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = yymsp[0].minor.yy110; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy110, true); } +#line 7175 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 457: /* expression ::= NK_LP expression NK_RP */ case 543: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==543); case 642: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==642); #line 855 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy896)); } -#line 7164 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy110)); } +#line 7183 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 458: /* expression ::= NK_PLUS expr_or_subquery */ #line 856 "sql.y" { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy896)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy110)); } -#line 7173 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +#line 7192 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 459: /* expression ::= NK_MINUS expr_or_subquery */ #line 860 "sql.y" { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy896), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy110), NULL)); } -#line 7182 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +#line 7201 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 460: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ #line 864 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7192 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7211 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 461: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ #line 869 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7202 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7221 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 462: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ #line 874 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7212 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7231 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 463: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ #line 879 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7222 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7241 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 464: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ #line 884 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7232 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7251 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 465: /* expression ::= column_reference NK_ARROW NK_STRING */ #line 889 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } -#line 7241 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7260 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 466: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ #line 893 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7251 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7270 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 467: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ #line 898 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7261 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7280 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 470: /* column_reference ::= column_name */ #line 909 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy701, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy701)); } -#line 7267 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy863, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy863)); } +#line 7286 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 471: /* column_reference ::= table_name NK_DOT column_name */ #line 910 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy701, createColumnNode(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy701)); } -#line 7273 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy863, createColumnNode(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy863)); } +#line 7292 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 472: /* column_reference ::= NK_ALIAS */ #line 911 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7279 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7298 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 473: /* column_reference ::= table_name NK_DOT NK_ALIAS */ #line 912 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy0)); } -#line 7285 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy0)); } +#line 7304 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 474: /* pseudo_column ::= ROWTS */ case 475: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==475); @@ -7298,540 +7317,546 @@ static YYACTIONTYPE yy_reduce( case 485: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==485); case 491: /* literal_func ::= NOW */ yytestcase(yyruleno==491); #line 914 "sql.y" -{ yylhsminor.yy896 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } -#line 7302 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } +#line 7321 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 476: /* pseudo_column ::= table_name NK_DOT TBNAME */ #line 916 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy701)))); } -#line 7308 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy863)))); } +#line 7327 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 486: /* function_expression ::= function_name NK_LP expression_list NK_RP */ case 487: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==487); #line 927 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy701, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy701, yymsp[-1].minor.yy404)); } -#line 7315 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy863, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy863, yymsp[-1].minor.yy652)); } +#line 7334 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 488: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ #line 930 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), yymsp[-1].minor.yy504)); } -#line 7321 "sql.c" - yymsp[-5].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), yymsp[-1].minor.yy34)); } +#line 7340 "sql.c" + yymsp[-5].minor.yy110 = yylhsminor.yy110; break; case 490: /* literal_func ::= noarg_func NK_LP NK_RP */ #line 933 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy701, NULL)); } -#line 7327 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy863, NULL)); } +#line 7346 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 505: /* star_func_para_list ::= NK_STAR */ #line 957 "sql.y" -{ yylhsminor.yy404 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7333 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7352 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 510: /* star_func_para ::= table_name NK_DOT NK_STAR */ case 578: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==578); #line 966 "sql.y" -{ yylhsminor.yy896 = createColumnNode(pCxt, &yymsp[-2].minor.yy701, &yymsp[0].minor.yy0); } -#line 7340 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createColumnNode(pCxt, &yymsp[-2].minor.yy863, &yymsp[0].minor.yy0); } +#line 7359 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 511: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ #line 969 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy404, yymsp[-1].minor.yy896)); } -#line 7346 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy652, yymsp[-1].minor.yy110)); } +#line 7365 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 512: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ #line 971 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), yymsp[-2].minor.yy404, yymsp[-1].minor.yy896)); } -#line 7352 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), yymsp[-2].minor.yy652, yymsp[-1].minor.yy110)); } +#line 7371 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 515: /* when_then_expr ::= WHEN common_expression THEN common_expression */ #line 978 "sql.y" -{ yymsp[-3].minor.yy896 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896)); } -#line 7358 "sql.c" +{ yymsp[-3].minor.yy110 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110)); } +#line 7377 "sql.c" break; case 517: /* case_when_else_opt ::= ELSE common_expression */ #line 981 "sql.y" -{ yymsp[-1].minor.yy896 = releaseRawExprNode(pCxt, yymsp[0].minor.yy896); } -#line 7363 "sql.c" +{ yymsp[-1].minor.yy110 = releaseRawExprNode(pCxt, yymsp[0].minor.yy110); } +#line 7382 "sql.c" break; case 518: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ case 523: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==523); #line 984 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy884, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy2, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7373 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7392 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 519: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ #line 991 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy896), releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy110), releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7383 "sql.c" - yymsp[-4].minor.yy896 = yylhsminor.yy896; +#line 7402 "sql.c" + yymsp[-4].minor.yy110 = yylhsminor.yy110; break; case 520: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ #line 997 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy896), releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy110), releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7393 "sql.c" - yymsp[-5].minor.yy896 = yylhsminor.yy896; +#line 7412 "sql.c" + yymsp[-5].minor.yy110 = yylhsminor.yy110; break; case 521: /* predicate ::= expr_or_subquery IS NULL */ #line 1002 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), NULL)); } -#line 7402 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7421 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 522: /* predicate ::= expr_or_subquery IS NOT NULL */ #line 1006 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), NULL)); } -#line 7411 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +#line 7430 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 524: /* compare_op ::= NK_LT */ #line 1018 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_LOWER_THAN; } -#line 7417 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_LOWER_THAN; } +#line 7436 "sql.c" break; case 525: /* compare_op ::= NK_GT */ #line 1019 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_GREATER_THAN; } -#line 7422 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_GREATER_THAN; } +#line 7441 "sql.c" break; case 526: /* compare_op ::= NK_LE */ #line 1020 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_LOWER_EQUAL; } -#line 7427 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_LOWER_EQUAL; } +#line 7446 "sql.c" break; case 527: /* compare_op ::= NK_GE */ #line 1021 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_GREATER_EQUAL; } -#line 7432 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_GREATER_EQUAL; } +#line 7451 "sql.c" break; case 528: /* compare_op ::= NK_NE */ #line 1022 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_NOT_EQUAL; } -#line 7437 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_NOT_EQUAL; } +#line 7456 "sql.c" break; case 529: /* compare_op ::= NK_EQ */ #line 1023 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_EQUAL; } -#line 7442 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_EQUAL; } +#line 7461 "sql.c" break; case 530: /* compare_op ::= LIKE */ #line 1024 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_LIKE; } -#line 7447 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_LIKE; } +#line 7466 "sql.c" break; case 531: /* compare_op ::= NOT LIKE */ #line 1025 "sql.y" -{ yymsp[-1].minor.yy884 = OP_TYPE_NOT_LIKE; } -#line 7452 "sql.c" +{ yymsp[-1].minor.yy2 = OP_TYPE_NOT_LIKE; } +#line 7471 "sql.c" break; case 532: /* compare_op ::= MATCH */ #line 1026 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_MATCH; } -#line 7457 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_MATCH; } +#line 7476 "sql.c" break; case 533: /* compare_op ::= NMATCH */ #line 1027 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_NMATCH; } -#line 7462 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_NMATCH; } +#line 7481 "sql.c" break; case 534: /* compare_op ::= CONTAINS */ #line 1028 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_JSON_CONTAINS; } -#line 7467 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_JSON_CONTAINS; } +#line 7486 "sql.c" break; case 535: /* in_op ::= IN */ #line 1032 "sql.y" -{ yymsp[0].minor.yy884 = OP_TYPE_IN; } -#line 7472 "sql.c" +{ yymsp[0].minor.yy2 = OP_TYPE_IN; } +#line 7491 "sql.c" break; case 536: /* in_op ::= NOT IN */ #line 1033 "sql.y" -{ yymsp[-1].minor.yy884 = OP_TYPE_NOT_IN; } -#line 7477 "sql.c" +{ yymsp[-1].minor.yy2 = OP_TYPE_NOT_IN; } +#line 7496 "sql.c" break; case 537: /* in_predicate_value ::= NK_LP literal_list NK_RP */ #line 1035 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } -#line 7482 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy652)); } +#line 7501 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 539: /* boolean_value_expression ::= NOT boolean_primary */ #line 1039 "sql.y" { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy896), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy110), NULL)); } -#line 7491 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +#line 7510 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 540: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ #line 1044 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7501 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7520 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 541: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ #line 1050 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy896); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy896); - yylhsminor.yy896 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy110); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy110); + yylhsminor.yy110 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } -#line 7511 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +#line 7530 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 549: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ #line 1068 "sql.y" -{ yylhsminor.yy896 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy896, yymsp[0].minor.yy896, NULL); } -#line 7517 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy110, yymsp[0].minor.yy110, NULL); } +#line 7536 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 552: /* table_primary ::= table_name alias_opt */ #line 1074 "sql.y" -{ yylhsminor.yy896 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy701, &yymsp[0].minor.yy701); } -#line 7523 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy863, &yymsp[0].minor.yy863); } +#line 7542 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 553: /* table_primary ::= db_name NK_DOT table_name alias_opt */ #line 1075 "sql.y" -{ yylhsminor.yy896 = createRealTableNode(pCxt, &yymsp[-3].minor.yy701, &yymsp[-1].minor.yy701, &yymsp[0].minor.yy701); } -#line 7529 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRealTableNode(pCxt, &yymsp[-3].minor.yy863, &yymsp[-1].minor.yy863, &yymsp[0].minor.yy863); } +#line 7548 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 554: /* table_primary ::= subquery alias_opt */ #line 1076 "sql.y" -{ yylhsminor.yy896 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy896), &yymsp[0].minor.yy701); } -#line 7535 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy110), &yymsp[0].minor.yy863); } +#line 7554 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 556: /* alias_opt ::= */ #line 1081 "sql.y" -{ yymsp[1].minor.yy701 = nil_token; } -#line 7541 "sql.c" +{ yymsp[1].minor.yy863 = nil_token; } +#line 7560 "sql.c" break; case 558: /* alias_opt ::= AS table_alias */ #line 1083 "sql.y" -{ yymsp[-1].minor.yy701 = yymsp[0].minor.yy701; } -#line 7546 "sql.c" +{ yymsp[-1].minor.yy863 = yymsp[0].minor.yy863; } +#line 7565 "sql.c" break; case 559: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ case 560: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==560); #line 1085 "sql.y" -{ yymsp[-2].minor.yy896 = yymsp[-1].minor.yy896; } -#line 7552 "sql.c" +{ yymsp[-2].minor.yy110 = yymsp[-1].minor.yy110; } +#line 7571 "sql.c" break; case 561: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ #line 1090 "sql.y" -{ yylhsminor.yy896 = createJoinTableNode(pCxt, yymsp[-4].minor.yy680, yymsp[-5].minor.yy896, yymsp[-2].minor.yy896, yymsp[0].minor.yy896); } -#line 7557 "sql.c" - yymsp[-5].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createJoinTableNode(pCxt, yymsp[-4].minor.yy684, yymsp[-5].minor.yy110, yymsp[-2].minor.yy110, yymsp[0].minor.yy110); } +#line 7576 "sql.c" + yymsp[-5].minor.yy110 = yylhsminor.yy110; break; case 562: /* join_type ::= */ #line 1094 "sql.y" -{ yymsp[1].minor.yy680 = JOIN_TYPE_INNER; } -#line 7563 "sql.c" +{ yymsp[1].minor.yy684 = JOIN_TYPE_INNER; } +#line 7582 "sql.c" break; case 563: /* join_type ::= INNER */ #line 1095 "sql.y" -{ yymsp[0].minor.yy680 = JOIN_TYPE_INNER; } -#line 7568 "sql.c" +{ yymsp[0].minor.yy684 = JOIN_TYPE_INNER; } +#line 7587 "sql.c" break; case 564: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ #line 1101 "sql.y" { - yymsp[-13].minor.yy896 = createSelectStmt(pCxt, yymsp[-11].minor.yy733, yymsp[-9].minor.yy404, yymsp[-8].minor.yy896, yymsp[-12].minor.yy404); - yymsp[-13].minor.yy896 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy896, yymsp[-10].minor.yy733); - yymsp[-13].minor.yy896 = addWhereClause(pCxt, yymsp[-13].minor.yy896, yymsp[-7].minor.yy896); - yymsp[-13].minor.yy896 = addPartitionByClause(pCxt, yymsp[-13].minor.yy896, yymsp[-6].minor.yy404); - yymsp[-13].minor.yy896 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy896, yymsp[-2].minor.yy896); - yymsp[-13].minor.yy896 = addGroupByClause(pCxt, yymsp[-13].minor.yy896, yymsp[-1].minor.yy404); - yymsp[-13].minor.yy896 = addHavingClause(pCxt, yymsp[-13].minor.yy896, yymsp[0].minor.yy896); - yymsp[-13].minor.yy896 = addRangeClause(pCxt, yymsp[-13].minor.yy896, yymsp[-5].minor.yy896); - yymsp[-13].minor.yy896 = addEveryClause(pCxt, yymsp[-13].minor.yy896, yymsp[-4].minor.yy896); - yymsp[-13].minor.yy896 = addFillClause(pCxt, yymsp[-13].minor.yy896, yymsp[-3].minor.yy896); + yymsp[-13].minor.yy110 = createSelectStmt(pCxt, yymsp[-11].minor.yy1019, yymsp[-9].minor.yy652, yymsp[-8].minor.yy110, yymsp[-12].minor.yy652); + yymsp[-13].minor.yy110 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy110, yymsp[-10].minor.yy1019); + yymsp[-13].minor.yy110 = addWhereClause(pCxt, yymsp[-13].minor.yy110, yymsp[-7].minor.yy110); + yymsp[-13].minor.yy110 = addPartitionByClause(pCxt, yymsp[-13].minor.yy110, yymsp[-6].minor.yy652); + yymsp[-13].minor.yy110 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy110, yymsp[-2].minor.yy110); + yymsp[-13].minor.yy110 = addGroupByClause(pCxt, yymsp[-13].minor.yy110, yymsp[-1].minor.yy652); + yymsp[-13].minor.yy110 = addHavingClause(pCxt, yymsp[-13].minor.yy110, yymsp[0].minor.yy110); + yymsp[-13].minor.yy110 = addRangeClause(pCxt, yymsp[-13].minor.yy110, yymsp[-5].minor.yy110); + yymsp[-13].minor.yy110 = addEveryClause(pCxt, yymsp[-13].minor.yy110, yymsp[-4].minor.yy110); + yymsp[-13].minor.yy110 = addFillClause(pCxt, yymsp[-13].minor.yy110, yymsp[-3].minor.yy110); } -#line 7584 "sql.c" +#line 7603 "sql.c" break; case 565: /* hint_list ::= */ #line 1116 "sql.y" -{ yymsp[1].minor.yy404 = createHintNodeList(pCxt, NULL); } -#line 7589 "sql.c" +{ yymsp[1].minor.yy652 = createHintNodeList(pCxt, NULL); } +#line 7608 "sql.c" break; case 566: /* hint_list ::= NK_HINT */ #line 1117 "sql.y" -{ yylhsminor.yy404 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } -#line 7594 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } +#line 7613 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 571: /* set_quantifier_opt ::= ALL */ #line 1128 "sql.y" -{ yymsp[0].minor.yy733 = false; } -#line 7600 "sql.c" +{ yymsp[0].minor.yy1019 = false; } +#line 7619 "sql.c" break; case 574: /* select_item ::= NK_STAR */ #line 1135 "sql.y" -{ yylhsminor.yy896 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } -#line 7605 "sql.c" - yymsp[0].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } +#line 7624 "sql.c" + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 576: /* select_item ::= common_expression column_alias */ case 586: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==586); #line 1137 "sql.y" -{ yylhsminor.yy896 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy896), &yymsp[0].minor.yy701); } -#line 7612 "sql.c" - yymsp[-1].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy110), &yymsp[0].minor.yy863); } +#line 7631 "sql.c" + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 577: /* select_item ::= common_expression AS column_alias */ case 587: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==587); #line 1138 "sql.y" -{ yylhsminor.yy896 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), &yymsp[0].minor.yy701); } -#line 7619 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), &yymsp[0].minor.yy863); } +#line 7638 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 582: /* partition_by_clause_opt ::= PARTITION BY partition_list */ case 612: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==612); case 632: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==632); #line 1147 "sql.y" -{ yymsp[-2].minor.yy404 = yymsp[0].minor.yy404; } -#line 7627 "sql.c" +{ yymsp[-2].minor.yy652 = yymsp[0].minor.yy652; } +#line 7646 "sql.c" break; case 589: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ #line 1160 "sql.y" -{ yymsp[-5].minor.yy896 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), releaseRawExprNode(pCxt, yymsp[-1].minor.yy896)); } -#line 7632 "sql.c" +{ yymsp[-5].minor.yy110 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), releaseRawExprNode(pCxt, yymsp[-1].minor.yy110)); } +#line 7651 "sql.c" break; case 590: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ #line 1161 "sql.y" -{ yymsp[-3].minor.yy896 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy896)); } -#line 7637 "sql.c" +{ yymsp[-3].minor.yy110 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy110)); } +#line 7656 "sql.c" break; case 591: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ #line 1163 "sql.y" -{ yymsp[-5].minor.yy896 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), NULL, yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 7642 "sql.c" +{ yymsp[-5].minor.yy110 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), NULL, yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 7661 "sql.c" break; case 592: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ #line 1167 "sql.y" -{ yymsp[-7].minor.yy896 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy896), releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), yymsp[-1].minor.yy896, yymsp[0].minor.yy896); } -#line 7647 "sql.c" +{ yymsp[-7].minor.yy110 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy110), releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), yymsp[-1].minor.yy110, yymsp[0].minor.yy110); } +#line 7666 "sql.c" break; case 593: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ #line 1169 "sql.y" -{ yymsp[-6].minor.yy896 = createEventWindowNode(pCxt, yymsp[-3].minor.yy896, yymsp[0].minor.yy896); } -#line 7652 "sql.c" +{ yymsp[-6].minor.yy110 = createEventWindowNode(pCxt, yymsp[-3].minor.yy110, yymsp[0].minor.yy110); } +#line 7671 "sql.c" break; case 594: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ #line 1171 "sql.y" -{ yymsp[-3].minor.yy896 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } -#line 7657 "sql.c" +{ yymsp[-3].minor.yy110 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } +#line 7676 "sql.c" break; case 595: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ #line 1173 "sql.y" -{ yymsp[-5].minor.yy896 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } -#line 7662 "sql.c" +{ yymsp[-5].minor.yy110 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } +#line 7681 "sql.c" break; case 602: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ #line 1183 "sql.y" -{ yymsp[-3].minor.yy896 = createFillNode(pCxt, yymsp[-1].minor.yy466, NULL); } -#line 7667 "sql.c" +{ yymsp[-3].minor.yy110 = createFillNode(pCxt, yymsp[-1].minor.yy534, NULL); } +#line 7686 "sql.c" break; case 603: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ #line 1184 "sql.y" -{ yymsp[-5].minor.yy896 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } -#line 7672 "sql.c" +{ yymsp[-5].minor.yy110 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy652)); } +#line 7691 "sql.c" break; case 604: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ #line 1185 "sql.y" -{ yymsp[-5].minor.yy896 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } -#line 7677 "sql.c" +{ yymsp[-5].minor.yy110 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy652)); } +#line 7696 "sql.c" break; case 605: /* fill_mode ::= NONE */ #line 1189 "sql.y" -{ yymsp[0].minor.yy466 = FILL_MODE_NONE; } -#line 7682 "sql.c" +{ yymsp[0].minor.yy534 = FILL_MODE_NONE; } +#line 7701 "sql.c" break; case 606: /* fill_mode ::= PREV */ #line 1190 "sql.y" -{ yymsp[0].minor.yy466 = FILL_MODE_PREV; } -#line 7687 "sql.c" +{ yymsp[0].minor.yy534 = FILL_MODE_PREV; } +#line 7706 "sql.c" break; case 607: /* fill_mode ::= NULL */ #line 1191 "sql.y" -{ yymsp[0].minor.yy466 = FILL_MODE_NULL; } -#line 7692 "sql.c" +{ yymsp[0].minor.yy534 = FILL_MODE_NULL; } +#line 7711 "sql.c" break; case 608: /* fill_mode ::= NULL_F */ #line 1192 "sql.y" -{ yymsp[0].minor.yy466 = FILL_MODE_NULL_F; } -#line 7697 "sql.c" +{ yymsp[0].minor.yy534 = FILL_MODE_NULL_F; } +#line 7716 "sql.c" break; case 609: /* fill_mode ::= LINEAR */ #line 1193 "sql.y" -{ yymsp[0].minor.yy466 = FILL_MODE_LINEAR; } -#line 7702 "sql.c" +{ yymsp[0].minor.yy534 = FILL_MODE_LINEAR; } +#line 7721 "sql.c" break; case 610: /* fill_mode ::= NEXT */ #line 1194 "sql.y" -{ yymsp[0].minor.yy466 = FILL_MODE_NEXT; } -#line 7707 "sql.c" +{ yymsp[0].minor.yy534 = FILL_MODE_NEXT; } +#line 7726 "sql.c" break; case 613: /* group_by_list ::= expr_or_subquery */ #line 1203 "sql.y" -{ yylhsminor.yy404 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); } -#line 7712 "sql.c" - yymsp[0].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } +#line 7731 "sql.c" + yymsp[0].minor.yy652 = yylhsminor.yy652; break; case 614: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ #line 1204 "sql.y" -{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy896))); } -#line 7718 "sql.c" - yymsp[-2].minor.yy404 = yylhsminor.yy404; +{ yylhsminor.yy652 = addNodeToList(pCxt, yymsp[-2].minor.yy652, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy110))); } +#line 7737 "sql.c" + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 618: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ #line 1211 "sql.y" -{ yymsp[-5].minor.yy896 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy896), releaseRawExprNode(pCxt, yymsp[-1].minor.yy896)); } -#line 7724 "sql.c" +{ yymsp[-5].minor.yy110 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy110), releaseRawExprNode(pCxt, yymsp[-1].minor.yy110)); } +#line 7743 "sql.c" break; case 619: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ #line 1213 "sql.y" -{ yymsp[-3].minor.yy896 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy896)); } -#line 7729 "sql.c" +{ yymsp[-3].minor.yy110 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy110)); } +#line 7748 "sql.c" break; case 622: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ #line 1220 "sql.y" { - yylhsminor.yy896 = addOrderByClause(pCxt, yymsp[-3].minor.yy896, yymsp[-2].minor.yy404); - yylhsminor.yy896 = addSlimitClause(pCxt, yylhsminor.yy896, yymsp[-1].minor.yy896); - yylhsminor.yy896 = addLimitClause(pCxt, yylhsminor.yy896, yymsp[0].minor.yy896); + yylhsminor.yy110 = addOrderByClause(pCxt, yymsp[-3].minor.yy110, yymsp[-2].minor.yy652); + yylhsminor.yy110 = addSlimitClause(pCxt, yylhsminor.yy110, yymsp[-1].minor.yy110); + yylhsminor.yy110 = addLimitClause(pCxt, yylhsminor.yy110, yymsp[0].minor.yy110); } -#line 7738 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +#line 7757 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 625: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ #line 1230 "sql.y" -{ yylhsminor.yy896 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy896, yymsp[0].minor.yy896); } -#line 7744 "sql.c" - yymsp[-3].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy110, yymsp[0].minor.yy110); } +#line 7763 "sql.c" + yymsp[-3].minor.yy110 = yylhsminor.yy110; break; case 626: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ #line 1232 "sql.y" -{ yylhsminor.yy896 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy896, yymsp[0].minor.yy896); } -#line 7750 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy110, yymsp[0].minor.yy110); } +#line 7769 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 634: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ case 638: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==638); #line 1246 "sql.y" -{ yymsp[-1].minor.yy896 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 7757 "sql.c" +{ yymsp[-1].minor.yy110 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 7776 "sql.c" break; case 635: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ case 639: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==639); #line 1247 "sql.y" -{ yymsp[-3].minor.yy896 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } -#line 7763 "sql.c" +{ yymsp[-3].minor.yy110 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } +#line 7782 "sql.c" break; case 636: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ case 640: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==640); #line 1248 "sql.y" -{ yymsp[-3].minor.yy896 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } -#line 7769 "sql.c" +{ yymsp[-3].minor.yy110 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } +#line 7788 "sql.c" break; case 641: /* subquery ::= NK_LP query_expression NK_RP */ #line 1256 "sql.y" -{ yylhsminor.yy896 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy896); } -#line 7774 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy110); } +#line 7793 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 646: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ #line 1270 "sql.y" -{ yylhsminor.yy896 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy896), yymsp[-1].minor.yy918, yymsp[0].minor.yy669); } -#line 7780 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy110), yymsp[-1].minor.yy596, yymsp[0].minor.yy991); } +#line 7799 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 647: /* ordering_specification_opt ::= */ #line 1274 "sql.y" -{ yymsp[1].minor.yy918 = ORDER_ASC; } -#line 7786 "sql.c" +{ yymsp[1].minor.yy596 = ORDER_ASC; } +#line 7805 "sql.c" break; case 648: /* ordering_specification_opt ::= ASC */ #line 1275 "sql.y" -{ yymsp[0].minor.yy918 = ORDER_ASC; } -#line 7791 "sql.c" +{ yymsp[0].minor.yy596 = ORDER_ASC; } +#line 7810 "sql.c" break; case 649: /* ordering_specification_opt ::= DESC */ #line 1276 "sql.y" -{ yymsp[0].minor.yy918 = ORDER_DESC; } -#line 7796 "sql.c" +{ yymsp[0].minor.yy596 = ORDER_DESC; } +#line 7815 "sql.c" break; case 650: /* null_ordering_opt ::= */ #line 1280 "sql.y" -{ yymsp[1].minor.yy669 = NULL_ORDER_DEFAULT; } -#line 7801 "sql.c" +{ yymsp[1].minor.yy991 = NULL_ORDER_DEFAULT; } +#line 7820 "sql.c" break; case 651: /* null_ordering_opt ::= NULLS FIRST */ #line 1281 "sql.y" -{ yymsp[-1].minor.yy669 = NULL_ORDER_FIRST; } -#line 7806 "sql.c" +{ yymsp[-1].minor.yy991 = NULL_ORDER_FIRST; } +#line 7825 "sql.c" break; case 652: /* null_ordering_opt ::= NULLS LAST */ #line 1282 "sql.y" -{ yymsp[-1].minor.yy669 = NULL_ORDER_LAST; } -#line 7811 "sql.c" +{ yymsp[-1].minor.yy991 = NULL_ORDER_LAST; } +#line 7830 "sql.c" break; case 653: /* column_options ::= */ #line 1288 "sql.y" -{ yymsp[1].minor.yy896 = createDefaultColumnOptions(pCxt); } -#line 7816 "sql.c" +{ yymsp[1].minor.yy110 = createDefaultColumnOptions(pCxt); } +#line 7835 "sql.c" break; - case 654: /* column_options ::= column_options ENCODE NK_STRING */ + case 654: /* column_options ::= column_options PRIMARY KEY */ #line 1289 "sql.y" -{assert(strlen(yymsp[0].minor.yy0.z) != 0); yylhsminor.yy896 = setColumnOptions(pCxt, yymsp[-2].minor.yy896, COLUMN_OPTION_ENCODE, &yymsp[0].minor.yy0); } -#line 7821 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setColumnOptions(pCxt, yymsp[-2].minor.yy110, COLUMN_OPTION_PRIMARYKEY, NULL); } +#line 7840 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; - case 655: /* column_options ::= column_options COMPRESS NK_STRING */ + case 655: /* column_options ::= column_options ENCODE NK_STRING */ #line 1290 "sql.y" -{ yylhsminor.yy896 = setColumnOptions(pCxt, yymsp[-2].minor.yy896, COLUMN_OPTION_COMPRESS, &yymsp[0].minor.yy0); } -#line 7827 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setColumnOptions(pCxt, yymsp[-2].minor.yy110, COLUMN_OPTION_ENCODE, &yymsp[0].minor.yy0); } +#line 7846 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; - case 656: /* column_options ::= column_options LEVEL NK_STRING */ + case 656: /* column_options ::= column_options COMPRESS NK_STRING */ #line 1291 "sql.y" -{ yylhsminor.yy896 = setColumnOptions(pCxt, yymsp[-2].minor.yy896, COLUMN_OPTION_LEVEL, &yymsp[0].minor.yy0); } -#line 7833 "sql.c" - yymsp[-2].minor.yy896 = yylhsminor.yy896; +{ yylhsminor.yy110 = setColumnOptions(pCxt, yymsp[-2].minor.yy110, COLUMN_OPTION_COMPRESS, &yymsp[0].minor.yy0); } +#line 7852 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; + break; + case 657: /* column_options ::= column_options LEVEL NK_STRING */ +#line 1292 "sql.y" +{ yylhsminor.yy110 = setColumnOptions(pCxt, yymsp[-2].minor.yy110, COLUMN_OPTION_LEVEL, &yymsp[0].minor.yy0); } +#line 7858 "sql.c" + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; default: break; @@ -7904,7 +7929,7 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } -#line 7907 "sql.c" +#line 7932 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 8e5aae01aa..39a312eb2c 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -619,12 +619,14 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED_FUNC, "System table not al TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED, "System table not allowed") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalidate varbinary value") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_IP_RANGE, "Invalid IPV4 address ranges") -TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VIEW_QUERY, "Invalid view query type") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_COL_QUERY_MISMATCH, "Columns number mismatch with query result") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_VIEW_CONFLICT_WITH_TABLE, "View name is conflict with table") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_SUPPORT_MULTI_RESULT, "Operator not supported multi result") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TAG_IS_PRIMARY_KEY, "tag can not be primary key") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SECOND_COL_PK, "primary key must be second column") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") //planner TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error") diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt index 3514c578e9..d6bd8d6537 100644 --- a/source/util/test/CMakeLists.txt +++ b/source/util/test/CMakeLists.txt @@ -108,3 +108,11 @@ add_test( NAME tbaseCodecTest COMMAND tbaseCodecTest ) + +# bufferTest +add_executable(bufferTest "bufferTest.cpp") +target_link_libraries(bufferTest os util gtest_main) +add_test( + NAME bufferTest + COMMAND bufferTest +) \ No newline at end of file diff --git a/source/util/test/bufferTest.cpp b/source/util/test/bufferTest.cpp new file mode 100644 index 0000000000..4e152b783b --- /dev/null +++ b/source/util/test/bufferTest.cpp @@ -0,0 +1,371 @@ +#include + +#include "tbuffer.h" + +typedef struct { + int8_t value1; + int32_t value2; + int64_t value3; +} STestStruct; + +TEST(BufferTest, simpleTest1) { + SBuffer buffer; + + tBufferInit(&buffer); + + GTEST_ASSERT_EQ(tBufferGetSize(&buffer), 0); + GTEST_ASSERT_EQ(tBufferGetData(&buffer), nullptr); + + tBufferDestroy(&buffer); +} + +TEST(BufferTest, forwardWriteAndRead) { + int32_t code = 0; + bool forward = true; + SBuffer buffer; + + tBufferInit(&buffer); + taosSeedRand(taosGetTimestampSec()); + + // write + /* fix-len struct */ + STestStruct testStruct = {1, 2}; + GTEST_ASSERT_EQ(tBufferPut(&buffer, &testStruct, sizeof(STestStruct)), 0); + + /* int8_t */ + int8_t i8 = taosRand() % UINT8_MAX - INT8_MAX; + GTEST_ASSERT_EQ(tBufferPutI8(&buffer, i8), 0); + + /* int16_t */ + int8_t i16 = taosRand() % UINT16_MAX - INT16_MAX; + GTEST_ASSERT_EQ(tBufferPutI16(&buffer, i16), 0); + + /* int32_t */ + int8_t i32 = taosRand(); + GTEST_ASSERT_EQ(tBufferPutI32(&buffer, i32), 0); + + /* int64_t */ + int64_t i64 = taosRand(); + GTEST_ASSERT_EQ(tBufferPutI64(&buffer, i64), 0); + + /* uint8_t */ + uint8_t u8 = taosRand() % UINT8_MAX; + GTEST_ASSERT_EQ(tBufferPutU8(&buffer, u8), 0); + + /* uint16_t */ + uint16_t u16 = taosRand() % UINT16_MAX; + GTEST_ASSERT_EQ(tBufferPutU16(&buffer, u16), 0); + + /* uint32_t */ + uint32_t u32 = taosRand(); + GTEST_ASSERT_EQ(tBufferPutU32(&buffer, u32), 0); + + /* uint64_t */ + uint64_t u64 = taosRand(); + GTEST_ASSERT_EQ(tBufferPutU64(&buffer, u64), 0); + + /* float */ + float f = (float)taosRand() / (float)taosRand(); + GTEST_ASSERT_EQ(tBufferPutF32(&buffer, f), 0); + + /* double */ + double d = (double)taosRand() / (double)taosRand(); + GTEST_ASSERT_EQ(tBufferPutF64(&buffer, d), 0); + + /* binary */ + uint8_t binary[10]; + for (int32_t i = 0; i < sizeof(binary); ++i) { + binary[i] = taosRand() % UINT8_MAX; + } + GTEST_ASSERT_EQ(tBufferPutBinary(&buffer, binary, sizeof(binary)), 0); + + /* cstr */ + const char *cstr = "hello world"; + GTEST_ASSERT_EQ(tBufferPutCStr(&buffer, cstr), 0); + + /* uint16v_t */ + uint16_t u16v[] = {0, 127, 128, 129, 16384, 16385, 16386, UINT16_MAX}; + for (int32_t i = 0; i < sizeof(u16v) / sizeof(u16v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferPutU16v(&buffer, u16v[i]), 0); + } + + /* uint32v_t */ + uint32_t u32v[] = {0, 127, 128, 129, 16384, 16385, 16386, (1 << 21) - 1, + (1 << 21), (1 << 21) + 1, (1 << 28) - 1, (1 << 28), (1 << 28) + 1, UINT32_MAX}; + for (int32_t i = 0; i < sizeof(u32v) / sizeof(u32v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferPutU32v(&buffer, u32v[i]), 0); + } + + /* uint64v_t */ + uint64_t u64v[] = {0, // 0 + (1ul << (7 * 1)) - 1, + (1ul << (7 * 1)), + (1ul << (7 * 1)) + 1, + (1ul << (7 * 2)) - 1, + (1ul << (7 * 2)), + (1ul << (7 * 2)) + 1, + (1ul << (7 * 3)) - 1, + (1ul << (7 * 3)), + (1ul << (7 * 3)) + 1, + (1ul << (7 * 4)) - 1, + (1ul << (7 * 4)), + (1ul << (7 * 4)) + 1, + (1ul << (7 * 5)) - 1, + (1ul << (7 * 5)), + (1ul << (7 * 5)) + 1, + (1ul << (7 * 6)) - 1, + (1ul << (7 * 6)), + (1ul << (7 * 6)) + 1, + (1ul << (7 * 7)) - 1, + (1ul << (7 * 7)), + (1ul << (7 * 7)) + 1, + (1ul << (7 * 8)) - 1, + (1ul << (7 * 8)), + (1ul << (7 * 8)) + 1, + (1ul << (7 * 9)) - 1, + (1ul << (7 * 9)), + (1ul << (7 * 9)) + 1, + UINT64_MAX}; + for (int32_t i = 0; i < sizeof(u64v) / sizeof(u64v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferPutU64v(&buffer, u64v[i]), 0); + } + + /* int16v_t */ + int16_t i16v[] = { + INT16_MIN, // + -((1 << (7 * 1)) - 1), + -((1 << (7 * 1))), + -((1 << (7 * 1)) + 1), + -((1 << (7 * 2)) - 1), + -((1 << (7 * 2))), + -((1 << (7 * 2)) + 1), + (1 << (7 * 0)) - 1, + (1 << (7 * 0)), + (1 << (7 * 0)) + 1, + (1 << (7 * 1)) - 1, + (1 << (7 * 1)), + (1 << (7 * 1)) + 1, + (1 << (7 * 2)) - 1, + (1 << (7 * 2)), + (1 << (7 * 2)) + 1, + INT16_MAX, + }; + for (int32_t i = 0; i < sizeof(i16v) / sizeof(i16v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferPutI16v(&buffer, i16v[i]), 0); + } + + /* int32v_t */ + int32_t i32v[] = { + INT32_MIN, // + -((1 << (7 * 1)) - 1), + -((1 << (7 * 1))), + -((1 << (7 * 1)) + 1), + -((1 << (7 * 2)) - 1), + -((1 << (7 * 2))), + -((1 << (7 * 2)) + 1), + -((1 << (7 * 3)) - 1), + -((1 << (7 * 3))), + -((1 << (7 * 3)) + 1), + -((1 << (7 * 4)) - 1), + -((1 << (7 * 4))), + -((1 << (7 * 4)) + 1), + (1 << (7 * 0)) - 1, + (1 << (7 * 0)), + (1 << (7 * 0)) + 1, + (1 << (7 * 1)) - 1, + (1 << (7 * 1)), + (1 << (7 * 1)) + 1, + (1 << (7 * 2)) - 1, + (1 << (7 * 2)), + (1 << (7 * 2)) + 1, + (1 << (7 * 3)) - 1, + (1 << (7 * 3)), + (1 << (7 * 3)) + 1, + (1 << (7 * 4)) - 1, + (1 << (7 * 4)), + (1 << (7 * 4)) + 1, + INT32_MAX, + }; + for (int32_t i = 0; i < sizeof(i32v) / sizeof(i32v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferPutI32v(&buffer, i32v[i]), 0); + } + + /* int64v_t */ + int64_t i64v[] = { + INT64_MIN, // + -((1l << (7 * 1)) - 1), + -((1l << (7 * 1))), + -((1l << (7 * 1)) + 1), + -((1l << (7 * 2)) - 1), + -((1l << (7 * 2))), + -((1l << (7 * 2)) + 1), + -((1l << (7 * 3)) - 1), + -((1l << (7 * 3))), + -((1l << (7 * 3)) + 1), + -((1l << (7 * 4)) - 1), + -((1l << (7 * 4))), + -((1l << (7 * 4)) + 1), + -((1l << (7 * 5)) - 1), + -((1l << (7 * 5))), + -((1l << (7 * 5)) + 1), + -((1l << (7 * 6)) - 1), + -((1l << (7 * 6))), + -((1l << (7 * 6)) + 1), + -((1l << (7 * 7)) - 1), + -((1l << (7 * 7))), + -((1l << (7 * 7)) + 1), + -((1l << (7 * 8)) - 1), + -((1l << (7 * 8))), + -((1l << (7 * 8)) + 1), + -((1l << (7 * 9)) + 1), + ((1l << (7 * 1)) - 1), + ((1l << (7 * 1))), + ((1l << (7 * 1)) + 1), + ((1l << (7 * 2)) - 1), + ((1l << (7 * 2))), + ((1l << (7 * 2)) + 1), + ((1l << (7 * 3)) - 1), + ((1l << (7 * 3))), + ((1l << (7 * 3)) + 1), + ((1l << (7 * 4)) - 1), + ((1l << (7 * 4))), + ((1l << (7 * 4)) + 1), + ((1l << (7 * 5)) - 1), + ((1l << (7 * 5))), + ((1l << (7 * 5)) + 1), + ((1l << (7 * 6)) - 1), + ((1l << (7 * 6))), + ((1l << (7 * 6)) + 1), + ((1l << (7 * 7)) - 1), + ((1l << (7 * 7))), + ((1l << (7 * 7)) + 1), + ((1l << (7 * 8)) - 1), + ((1l << (7 * 8))), + ((1l << (7 * 8)) + 1), + ((1l << (7 * 9)) + 1), + INT64_MAX, + }; + for (int32_t i = 0; i < sizeof(i64v) / sizeof(i64v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferPutI64v(&buffer, i64v[i]), 0); + } + + // read + SBufferReader reader; + tBufferReaderInit(&reader, 0, &buffer); + + /* fix-len struct */ + STestStruct testStruct2 = {1, 2}; + GTEST_ASSERT_EQ(tBufferGet(&reader, sizeof(STestStruct), &testStruct2), 0); + GTEST_ASSERT_EQ(testStruct.value1, testStruct2.value1); + GTEST_ASSERT_EQ(testStruct.value2, testStruct2.value2); + GTEST_ASSERT_EQ(testStruct.value3, testStruct2.value3); + + /* int8_t */ + int8_t i8_2 = 97; + GTEST_ASSERT_EQ(tBufferGetI8(&reader, &i8_2), 0); + GTEST_ASSERT_EQ(i8, i8_2); + + /* int16_t */ + int16_t i16_2; + GTEST_ASSERT_EQ(tBufferGetI16(&reader, &i16_2), 0); + GTEST_ASSERT_EQ(i16, i16_2); + + /* int32_t */ + int32_t i32_2; + GTEST_ASSERT_EQ(tBufferGetI32(&reader, &i32_2), 0); + GTEST_ASSERT_EQ(i32, i32_2); + + /* int64_t */ + int64_t i64_2; + GTEST_ASSERT_EQ(tBufferGetI64(&reader, &i64_2), 0); + GTEST_ASSERT_EQ(i64, i64_2); + + /* uint8_t */ + uint8_t u8_2; + GTEST_ASSERT_EQ(tBufferGetU8(&reader, &u8_2), 0); + GTEST_ASSERT_EQ(u8, u8_2); + + /* uint16_t */ + uint16_t u16_2; + GTEST_ASSERT_EQ(tBufferGetU16(&reader, &u16_2), 0); + GTEST_ASSERT_EQ(u16, u16_2); + + /* uint32_t */ + uint32_t u32_2; + GTEST_ASSERT_EQ(tBufferGetU32(&reader, &u32_2), 0); + GTEST_ASSERT_EQ(u32, u32_2); + + /* uint64_t */ + uint64_t u64_2; + GTEST_ASSERT_EQ(tBufferGetU64(&reader, &u64_2), 0); + GTEST_ASSERT_EQ(u64, u64_2); + + /* float */ + float f_2; + GTEST_ASSERT_EQ(tBufferGetF32(&reader, &f_2), 0); + GTEST_ASSERT_EQ(f, f_2); + + /* double */ + double d_2; + GTEST_ASSERT_EQ(tBufferGetF64(&reader, &d_2), 0); + GTEST_ASSERT_EQ(d, d_2); + + /* binary */ + const void *binary2; + uint32_t binarySize; + GTEST_ASSERT_EQ(tBufferGetBinary(&reader, &binary2, &binarySize), 0); + GTEST_ASSERT_EQ(memcmp(binary, binary2, sizeof(binary)), 0); + GTEST_ASSERT_EQ(binarySize, sizeof(binary)); + + /* cstr */ + const char *cstr2; + GTEST_ASSERT_EQ(tBufferGetCStr(&reader, &cstr2), 0); + GTEST_ASSERT_EQ(strcmp(cstr, cstr2), 0); + + /* uint16v_t */ + uint16_t u16v2[sizeof(u16v) / sizeof(u16v[0])]; + for (int32_t i = 0; i < sizeof(u16v) / sizeof(u16v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferGetU16v(&reader, &u16v2[i]), 0); + GTEST_ASSERT_EQ(u16v[i], u16v2[i]); + } + + /* uint32v_t */ + uint32_t u32v2[sizeof(u32v) / sizeof(u32v[0])]; + for (int32_t i = 0; i < sizeof(u32v) / sizeof(u32v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferGetU32v(&reader, &u32v2[i]), 0); + GTEST_ASSERT_EQ(u32v[i], u32v2[i]); + } + + /* uint64v_t */ + uint64_t u64v2[sizeof(u64v) / sizeof(u64v[0])]; + for (int32_t i = 0; i < sizeof(u64v) / sizeof(u64v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferGetU64v(&reader, &u64v2[i]), 0); + GTEST_ASSERT_EQ(u64v[i], u64v2[i]); + } + + /* int16v_t */ + int16_t i16v2[sizeof(i16v) / sizeof(i16v[0])]; + for (int32_t i = 0; i < sizeof(i16v) / sizeof(i16v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferGetI16v(&reader, &i16v2[i]), 0); + GTEST_ASSERT_EQ(i16v[i], i16v2[i]); + } + + /* int32v_t */ + int32_t i32v2[sizeof(i32v) / sizeof(i32v[0])]; + for (int32_t i = 0; i < sizeof(i32v) / sizeof(i32v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferGetI32v(&reader, &i32v2[i]), 0); + GTEST_ASSERT_EQ(i32v[i], i32v2[i]); + } + + /* int64v_t */ + int64_t i64v2[sizeof(i64v) / sizeof(i64v[0])]; + for (int32_t i = 0; i < sizeof(i64v) / sizeof(i64v[0]); ++i) { + GTEST_ASSERT_EQ(tBufferGetI64v(&reader, &i64v2[i]), 0); + GTEST_ASSERT_EQ(i64v[i], i64v2[i]); + } + + tBufferReaderDestroy(&reader); + + // clear + tBufferDestroy(&buffer); +}