diff --git a/Jenkinsfile2 b/Jenkinsfile2 index dd15807308..5a0e7972c6 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -387,7 +387,7 @@ pipeline { } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 55, unit: 'MINUTES'){ + timeout(time: 75, unit: 'MINUTES'){ pre_test_win() pre_test_build_win() run_win_ctest() diff --git a/README-CN.md b/README-CN.md index a5d239a532..b5a2564f91 100644 --- a/README-CN.md +++ b/README-CN.md @@ -276,7 +276,7 @@ sudo make install 安装成功后,可以在应用程序中双击 TDengine 图标启动服务,或者在终端中启动 TDengine 服务: ```bash -launchctl start com.tdengine.taosd +sudo launchctl start com.tdengine.taosd ``` 用户可以使用 TDengine CLI 来连接 TDengine 服务,在终端中,输入: diff --git a/README.md b/README.md index 885f91cb4e..3f7208dfb9 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ Installing from source code will also configure service management for TDengine. To start the service after installation, double-click the /applications/TDengine to start the program, or in a terminal, use: ```bash -launchctl start com.tdengine.taosd +sudo launchctl start com.tdengine.taosd ``` Then users can use the TDengine CLI to connect the TDengine server. In a terminal, use: diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 05191138e5..5f9a44084c 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG 22627d7 + GIT_TAG 7c641c5 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/include/common/tcommon.h b/include/common/tcommon.h index f74795a250..d88747eb92 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -367,6 +367,12 @@ typedef struct SSortExecInfo { int32_t readBytes; // read io bytes } SSortExecInfo; +typedef struct STUidTagInfo { + char* name; + uint64_t uid; + void* pTagVal; +} STUidTagInfo; + // stream special block column #define START_TS_COLUMN_INDEX 0 diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 0703dc6099..8dcadf47b6 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1772,6 +1772,7 @@ typedef struct { SArray* pTags; // array of SField // 3.0.20 int64_t checkpointFreq; // ms + int64_t deleteMark; int8_t igUpdate; } SCMCreateStreamReq; diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 32db6773e0..c44ad12759 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -132,14 +132,16 @@ typedef struct SqlFunctionCtx { SInputColumnInfoData input; SResultDataInfo resDataInfo; uint32_t order; // data block scanner order: asc|desc + uint8_t isPseudoFunc;// denote current function is pseudo function or not [added for perf reason] + uint8_t isNotNullFunc;// not return null value. uint8_t scanFlag; // record current running step, default: 0 int16_t functionId; // function id char *pOutput; // final result output buffer, point to sdata->data - int32_t numOfParams; // input parameter, e.g., top(k, 20), the number of results of top query is kept in param SFunctParam *param; // corresponding output buffer for timestamp of each result, e.g., diff/csum SColumnInfoData *pTsOutput; + int32_t numOfParams; int32_t offset; SResultRowEntryInfo *resultInfo; SSubsidiaryResInfo subsidiaries; @@ -152,7 +154,7 @@ typedef struct SqlFunctionCtx { struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity SSerializeDataHandle saveHandle; int32_t exprIdx; - char udfName[TSDB_FUNC_NAME_LEN]; + char *udfName; } SqlFunctionCtx; typedef struct tExprNode { diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index 8fdac0da7f..912c09a0fb 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -110,6 +110,7 @@ int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal #if 0 char* streamStateSessionDump(SStreamState* pState); +char* streamStateIntervalDump(SStreamState* pState); #endif #ifdef __cplusplus diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index defafce30e..5e37da4f3f 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -36,7 +36,7 @@ extern "C" { #define SYNC_DEL_WAL_MS (1000 * 60) #define SYNC_ADD_QUORUM_COUNT 3 #define SYNC_MNODE_LOG_RETENTION 10000 -#define SYNC_VNODE_LOG_RETENTION 20 +#define SYNC_VNODE_LOG_RETENTION (TSDB_SYNC_LOG_BUFFER_RETENTION + 1) #define SNAPSHOT_MAX_CLOCK_SKEW_MS 1000 * 10 #define SNAPSHOT_WAIT_MS 1000 * 30 diff --git a/include/os/osEnv.h b/include/os/osEnv.h index 533d989ffc..bc65da47a9 100644 --- a/include/os/osEnv.h +++ b/include/os/osEnv.h @@ -41,6 +41,7 @@ extern char tsSSE42Enable; extern char tsAVXEnable; extern char tsAVX2Enable; extern char tsFMAEnable; +extern char tsTagFilterCache; extern char configDir[]; extern char tsDataDir[]; diff --git a/include/util/tarray.h b/include/util/tarray.h index 0e78397ecb..af9cf5fde1 100644 --- a/include/util/tarray.h +++ b/include/util/tarray.h @@ -53,6 +53,7 @@ typedef struct SArray { * @return */ SArray* taosArrayInit(size_t size, size_t elemSize); +SArray* taosArrayInit_s(size_t size, size_t elemSize, size_t initialSize); /** * @@ -149,14 +150,6 @@ void* taosArrayGetLast(const SArray* pArray); */ size_t taosArrayGetSize(const SArray* pArray); -/** - * set the size of array - * @param pArray - * @param size size of the array - * @return - */ -void taosArraySetSize(SArray* pArray, size_t size); - /** * insert data into array * @param pArray diff --git a/include/util/tdef.h b/include/util/tdef.h index 3a152a36a1..e03352d98b 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -283,6 +283,7 @@ typedef enum ELogicConditionType { #define TSDB_MAX_REPLICA 5 #define TSDB_SYNC_LOG_BUFFER_SIZE 4096 +#define TSDB_SYNC_LOG_BUFFER_RETENTION (TSDB_SYNC_LOG_BUFFER_SIZE >> 4) #define TSDB_TBNAME_COLUMN_INDEX (-1) #define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta diff --git a/include/util/tlog.h b/include/util/tlog.h index 808377fa77..4311719ca5 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -89,7 +89,7 @@ bool taosAssertRelease(bool condition); // Disable all asserts that may compromise the performance. #if defined DISABLE_ASSERT #define ASSERT(condition) -#define ASSERTS(condition, ...) +#define ASSERTS(condition, ...) (0) #else #define ASSERTS(condition, ...) taosAssertDebug(condition, __FILE__, __LINE__, __VA_ARGS__) #ifdef NDEBUG diff --git a/source/libs/executor/inc/tsimplehash.h b/include/util/tsimplehash.h similarity index 99% rename from source/libs/executor/inc/tsimplehash.h rename to include/util/tsimplehash.h index 7344c34261..c9df911476 100644 --- a/source/libs/executor/inc/tsimplehash.h +++ b/include/util/tsimplehash.h @@ -116,6 +116,7 @@ typedef struct SHNode { struct SHNode *next; uint32_t keyLen : 20; uint32_t dataLen : 12; + uint32_t hashVal; char data[]; } SHNode; #pragma pack(pop) diff --git a/include/util/ttrace.h b/include/util/ttrace.h index 579768228a..5cdb1eecaa 100644 --- a/include/util/ttrace.h +++ b/include/util/ttrace.h @@ -45,11 +45,25 @@ typedef struct STraceId { #define TRACE_GET_MSGID(traceId) (traceId)->msgId -#define TRACE_TO_STR(traceId, buf) \ - do { \ - int64_t rootId = (traceId) != NULL ? (traceId)->rootId : 0; \ - int64_t msgId = (traceId) != NULL ? (traceId)->msgId : 0; \ - sprintf(buf, "0x%" PRIx64 ":0x%" PRIx64 "", rootId, msgId); \ +//#define TRACE_TO_STR(traceId, buf) \ +// do { \ +// int64_t rootId = (traceId) != NULL ? (traceId)->rootId : 0; \ +// int64_t msgId = (traceId) != NULL ? (traceId)->msgId : 0; \ +// sprintf(buf, "0x%" PRIx64 ":0x%" PRIx64 "", rootId, msgId); \ +// } while (0) + +#define TRACE_TO_STR(_traceId, _buf) \ + do { \ + int64_t rootId = (_traceId) != NULL ? (_traceId)->rootId : 0; \ + int64_t msgId = (_traceId) != NULL ? (_traceId)->msgId : 0; \ + char* _t = _buf; \ + _t[0] = '0'; \ + _t[1] = 'x'; \ + _t += titoa(rootId, 16, &_t[2]); \ + _t[0] = ':'; \ + _t[1] = '0'; \ + _t[2] = 'x'; \ + _t += titoa(msgId, 16, &_t[3]); \ } while (0) #ifdef __cplusplus diff --git a/include/util/tutil.h b/include/util/tutil.h index 9fb68aebdc..e0801e5295 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -46,6 +46,9 @@ char *paGetToken(char *src, char **token, int32_t *tokenLen); int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]); int32_t taosHexStrToByteArray(char hexstr[], char bytes[]); +int32_t tintToHex(uint64_t val, char hex[]); +int32_t titoa(uint64_t val, size_t radix, char str[]); + char *taosIpStr(uint32_t ipInt); uint32_t ip2uint(const char *const ip_addr); void taosIp2String(uint32_t ip, char *str); diff --git a/include/util/xxhash.h b/include/util/xxhash.h new file mode 100644 index 0000000000..d6bad94335 --- /dev/null +++ b/include/util/xxhash.h @@ -0,0 +1,328 @@ +/* + xxHash - Extremely Fast Hash algorithm + Header File + Copyright (C) 2012-2016, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - xxHash source repository : https://github.com/Cyan4973/xxHash +*/ + +/* Notice extracted from xxHash homepage : + +xxHash is an extremely fast Hash algorithm, running at RAM speed limits. +It also successfully passes all tests from the SMHasher suite. + +Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz) + +Name Speed Q.Score Author +xxHash 5.4 GB/s 10 +CrapWow 3.2 GB/s 2 Andrew +MumurHash 3a 2.7 GB/s 10 Austin Appleby +SpookyHash 2.0 GB/s 10 Bob Jenkins +SBox 1.4 GB/s 9 Bret Mulvey +Lookup3 1.2 GB/s 9 Bob Jenkins +SuperFastHash 1.2 GB/s 1 Paul Hsieh +CityHash64 1.05 GB/s 10 Pike & Alakuijala +FNV 0.55 GB/s 5 Fowler, Noll, Vo +CRC32 0.43 GB/s 9 +MD5-32 0.33 GB/s 10 Ronald L. Rivest +SHA1-32 0.28 GB/s 10 + +Q.Score is a measure of quality of the hash function. +It depends on successfully passing SMHasher test set. +10 is a perfect score. + +A 64-bit version, named XXH64, is available since r35. +It offers much better speed, but for 64-bit applications only. +Name Speed on 64 bits Speed on 32 bits +XXH64 13.8 GB/s 1.9 GB/s +XXH32 6.8 GB/s 6.0 GB/s +*/ + +#ifndef XXHASH_H_5627135585666179 +#define XXHASH_H_5627135585666179 1 + +#if defined (__cplusplus) +extern "C" { +#endif + + +/* **************************** +* Definitions +******************************/ +#include /* size_t */ +typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; + + +/* **************************** + * API modifier + ******************************/ +/** XXH_INLINE_ALL (and XXH_PRIVATE_API) + * This is useful to include xxhash functions in `static` mode + * in order to inline them, and remove their symbol from the public list. + * Inlining can offer dramatic performance improvement on small keys. + * Methodology : + * #define XXH_INLINE_ALL + * #include "xxhash.h" + * `xxhash.c` is automatically included. + * It's not useful to compile and link it as a separate module. + */ +#if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) +# ifndef XXH_STATIC_LINKING_ONLY +# define XXH_STATIC_LINKING_ONLY +# endif +# if defined(__GNUC__) +# define XXH_PUBLIC_API static __inline __attribute__((unused)) +# elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) +# define XXH_PUBLIC_API static inline +# elif defined(_MSC_VER) +# define XXH_PUBLIC_API static __inline +# else + /* this version may generate warnings for unused static functions */ +# define XXH_PUBLIC_API static +# endif +#else +# define XXH_PUBLIC_API /* do nothing */ +#endif /* XXH_INLINE_ALL || XXH_PRIVATE_API */ + +/*! XXH_NAMESPACE, aka Namespace Emulation : + * + * If you want to include _and expose_ xxHash functions from within your own library, + * but also want to avoid symbol collisions with other libraries which may also include xxHash, + * + * you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library + * with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values). + * + * Note that no change is required within the calling program as long as it includes `xxhash.h` : + * regular symbol name will be automatically translated by this header. + */ +#ifdef XXH_NAMESPACE +# define XXH_CAT(A,B) A##B +# define XXH_NAME2(A,B) XXH_CAT(A,B) +# define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber) +# define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32) +# define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState) +# define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState) +# define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset) +# define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update) +# define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest) +# define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState) +# define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash) +# define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical) +# define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64) +# define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState) +# define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState) +# define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset) +# define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update) +# define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest) +# define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState) +# define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash) +# define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical) +#endif + + +/* ************************************* +* Version +***************************************/ +#define XXH_VERSION_MAJOR 0 +#define XXH_VERSION_MINOR 6 +#define XXH_VERSION_RELEASE 5 +#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) +XXH_PUBLIC_API unsigned XXH_versionNumber (void); + + +/*-********************************************************************** +* 32-bit hash +************************************************************************/ +typedef unsigned int XXH32_hash_t; + +/*! XXH32() : + Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input". + The memory between input & input+length must be valid (allocated and read-accessible). + "seed" can be used to alter the result predictably. + Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s */ +XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed); + +/*====== Streaming ======*/ +typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */ +XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void); +XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr); +XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dst_state, const XXH32_state_t* src_state); + +XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed); +XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length); +XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr); + +/* + * Streaming functions generate the xxHash of an input provided in multiple segments. + * Note that, for small input, they are slower than single-call functions, due to state management. + * For small inputs, prefer `XXH32()` and `XXH64()`, which are better optimized. + * + * XXH state must first be allocated, using XXH*_createState() . + * + * Start a new hash by initializing state with a seed, using XXH*_reset(). + * + * Then, feed the hash state by calling XXH*_update() as many times as necessary. + * The function returns an error code, with 0 meaning OK, and any other value meaning there is an error. + * + * Finally, a hash value can be produced anytime, by using XXH*_digest(). + * This function returns the nn-bits hash as an int or long long. + * + * It's still possible to continue inserting input into the hash state after a digest, + * and generate some new hashes later on, by calling again XXH*_digest(). + * + * When done, free XXH state space if it was allocated dynamically. + */ + +/*====== Canonical representation ======*/ + +typedef struct { unsigned char digest[4]; } XXH32_canonical_t; +XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash); +XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src); + +/* Default result type for XXH functions are primitive unsigned 32 and 64 bits. + * The canonical representation uses human-readable write convention, aka big-endian (large digits first). + * These functions allow transformation of hash result into and from its canonical format. + * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs. + */ + + +#ifndef XXH_NO_LONG_LONG +/*-********************************************************************** +* 64-bit hash +************************************************************************/ +typedef unsigned long long XXH64_hash_t; + +/*! XXH64() : + Calculate the 64-bit hash of sequence of length "len" stored at memory address "input". + "seed" can be used to alter the result predictably. + This function runs faster on 64-bit systems, but slower on 32-bit systems (see benchmark). +*/ +XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed); + +/*====== Streaming ======*/ +typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */ +XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void); +XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr); +XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dst_state, const XXH64_state_t* src_state); + +XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed); +XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length); +XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr); + +/*====== Canonical representation ======*/ +typedef struct { unsigned char digest[8]; } XXH64_canonical_t; +XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash); +XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src); +#endif /* XXH_NO_LONG_LONG */ + + + +#ifdef XXH_STATIC_LINKING_ONLY + +/* ================================================================================================ + This section contains declarations which are not guaranteed to remain stable. + They may change in future versions, becoming incompatible with a different version of the library. + These declarations should only be used with static linking. + Never use them in association with dynamic linking ! +=================================================================================================== */ + +/* These definitions are only present to allow + * static allocation of XXH state, on stack or in a struct for example. + * Never **ever** use members directly. */ + +#if !defined (__VMS) \ + && (defined (__cplusplus) \ + || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) +# include + +struct XXH32_state_s { + uint32_t total_len_32; + uint32_t large_len; + uint32_t v1; + uint32_t v2; + uint32_t v3; + uint32_t v4; + uint32_t mem32[4]; + uint32_t memsize; + uint32_t reserved; /* never read nor write, might be removed in a future version */ +}; /* typedef'd to XXH32_state_t */ + +struct XXH64_state_s { + uint64_t total_len; + uint64_t v1; + uint64_t v2; + uint64_t v3; + uint64_t v4; + uint64_t mem64[4]; + uint32_t memsize; + uint32_t reserved[2]; /* never read nor write, might be removed in a future version */ +}; /* typedef'd to XXH64_state_t */ + +# else + +struct XXH32_state_s { + unsigned total_len_32; + unsigned large_len; + unsigned v1; + unsigned v2; + unsigned v3; + unsigned v4; + unsigned mem32[4]; + unsigned memsize; + unsigned reserved; /* never read nor write, might be removed in a future version */ +}; /* typedef'd to XXH32_state_t */ + +# ifndef XXH_NO_LONG_LONG /* remove 64-bit support */ +struct XXH64_state_s { + unsigned long long total_len; + unsigned long long v1; + unsigned long long v2; + unsigned long long v3; + unsigned long long v4; + unsigned long long mem64[4]; + unsigned memsize; + unsigned reserved[2]; /* never read nor write, might be removed in a future version */ +}; /* typedef'd to XXH64_state_t */ +# endif + +# endif + + +#if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) +# include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */ +#endif + +#endif /* XXH_STATIC_LINKING_ONLY */ + + +#if defined (__cplusplus) +} +#endif + +#endif /* XXHASH_H_5627135585666179 */ diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 9034fd85f5..aae3c3b593 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -531,13 +531,13 @@ function install_taosadapter_service() { } function install_service_on_launchctl() { - ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : + ${csudo}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : ${csudo}cp ${script_dir}/com.taosdata.taosd.plist /Library/LaunchDaemons/com.taosdata.taosd.plist - ${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : + ${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : - ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : + ${csudo}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : ${csudo}cp ${script_dir}/com.taosdata.taosadapter.plist /Library/LaunchDaemons/com.taosdata.taosadapter.plist - ${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : + ${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : } function install_service() { diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 482345dcd8..4441e0ba1f 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -512,14 +512,14 @@ function install_service_on_systemd() { function install_service_on_launchctl() { if [ -f ${install_main_dir}/service/com.taosdata.taosd.plist ]; then - ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : + ${csudo}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : ${csudo}cp ${install_main_dir}/service/com.taosdata.taosd.plist /Library/LaunchDaemons/com.taosdata.taosd.plist || : - ${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist || : + ${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist || : fi if [ -f ${install_main_dir}/service/com.taosdata.taosadapter.plist ]; then - ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : + ${csudo}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : ${csudo}cp ${install_main_dir}/service/com.taosdata.taosadapter.plist /Library/LaunchDaemons/com.taosdata.taosadapter.plist || : - ${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist || : + ${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist || : fi } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index e5f677637e..2042ff141c 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -934,6 +934,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { } if (TSDB_CODE_SUCCESS == code) { + pRequest->stmtType = pRequest->pQuery->pRoot->type; phaseAsyncQuery(pWrapper); } else { tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code), diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index f41eb1adaf..86dcd1eceb 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1546,7 +1546,10 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) { } void colDataDestroy(SColumnInfoData* pColData) { - if (!pColData) return; + if (!pColData) { + return; + } + if (IS_VAR_DATA_TYPE(pColData->info.type)) { taosMemoryFreeClear(pColData->varmeta.offset); } else { @@ -2353,8 +2356,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) { pStart += sizeof(uint64_t); if (pBlock->pDataBlock == NULL) { - pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); - taosArraySetSize(pBlock->pDataBlock, numOfCols); + pBlock->pDataBlock = taosArrayInit_s(numOfCols, sizeof(SColumnInfoData), numOfCols); } for (int32_t i = 0; i < numOfCols; ++i) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 037c8a4541..d4849650e6 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -140,6 +140,7 @@ int32_t tsMaxMemUsedByInsert = 1024; float tsSelectivityRatio = 1.0; int32_t tsTagFilterResCacheSize = 1024 * 10; +char tsTagFilterCache = 0; // the maximum allowed query buffer size during query processing for each data node. // -1 no limit (default) @@ -351,6 +352,7 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "AVX2", tsAVX2Enable, 0) != 0) return -1; if (cfgAddBool(pCfg, "FMA", tsFMAEnable, 0) != 0) return -1; if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, 0) != 0) return -1; + if (cfgAddBool(pCfg, "tagFilterCache", tsTagFilterCache, 0) != 0) return -1; if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 0) return -1; if (cfgAddInt64(pCfg, "streamMax", tsStreamMax, 0, INT64_MAX, 1) != 0) return -1; @@ -731,6 +733,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; tsSIMDBuiltins = (bool)cfgGetItem(pCfg, "SIMD-builtins")->bval; + tsTagFilterCache = (bool)cfgGetItem(pCfg, "tagFilterCache")->bval; tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval; tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index ec617163a2..44d3f7be25 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5425,6 +5425,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; if (tEncodeCStr(&encoder, pField->name) < 0) return -1; } + if (tEncodeI64(&encoder, pReq->deleteMark) < 0) return -1; if (tEncodeI8(&encoder, pReq->igUpdate) < 0) return -1; tEndEncode(&encoder); @@ -5487,6 +5488,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea } } + if (tDecodeI64(&decoder, &pReq->deleteMark) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igUpdate) < 0) return -1; tEndDecode(&decoder); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index f4e6aad7a7..b8bafff104 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -880,6 +880,12 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { if (strcasecmp(cfgReq.config, "resetlog") == 0) { strcpy(dcfgReq.config, "resetlog"); } else if (strncasecmp(cfgReq.config, "monitor", 7) == 0) { + if (' ' != cfgReq.config[7] && 0 != cfgReq.config[7]) { + mError("dnode:%d, failed to config monitor since invalid conf:%s", cfgReq.dnodeId, cfgReq.config); + terrno = TSDB_CODE_INVALID_CFG; + return -1; + } + const char *value = cfgReq.value; int32_t flag = atoi(value); if (flag <= 0) { @@ -900,12 +906,18 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { int32_t optLen = strlen(optName); if (strncasecmp(cfgReq.config, optName, optLen) != 0) continue; + if (' ' != cfgReq.config[optLen] && 0 != cfgReq.config[optLen]) { + mError("dnode:%d, failed to config since invalid conf:%s", cfgReq.dnodeId, cfgReq.config); + terrno = TSDB_CODE_INVALID_CFG; + return -1; + } + const char *value = cfgReq.value; int32_t flag = atoi(value); if (flag <= 0) { flag = atoi(cfgReq.config + optLen + 1); } - if (flag <= 0 || flag > 255) { + if (flag < 0 || flag > 255) { mError("dnode:%d, failed to config %s since value:%d", cfgReq.dnodeId, optName, flag); terrno = TSDB_CODE_INVALID_CFG; return -1; diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 61e9fc5366..fc53fca27c 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -297,6 +297,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, pObj->triggerParam = pCreate->maxDelay; pObj->watermark = pCreate->watermark; pObj->fillHistory = pCreate->fillHistory; + pObj->deleteMark = pCreate->deleteMark; pObj->igCheckUpdate = pCreate->igUpdate; memcpy(pObj->sourceDb, pCreate->sourceDB, TSDB_DB_FNAME_LEN); @@ -346,6 +347,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, .triggerType = pObj->trigger == STREAM_TRIGGER_MAX_DELAY ? STREAM_TRIGGER_WINDOW_CLOSE : pObj->trigger, .watermark = pObj->watermark, .igExpired = pObj->igExpired, + .deleteMark = pObj->deleteMark, .igCheckUpdate = pObj->igCheckUpdate, }; @@ -477,9 +479,8 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN); createReq.numOfColumns = pStream->outputSchema.nCols; createReq.numOfTags = 1; // group id - createReq.pColumns = taosArrayInit(createReq.numOfColumns, sizeof(SField)); + createReq.pColumns = taosArrayInit_s(createReq.numOfColumns, sizeof(SField), createReq.numOfColumns); // build fields - taosArraySetSize(createReq.pColumns, createReq.numOfColumns); for (int32_t i = 0; i < createReq.numOfColumns; i++) { SField *pField = taosArrayGet(createReq.pColumns, i); tstrncpy(pField->name, pStream->outputSchema.pSchema[i].name, TSDB_COL_NAME_LEN); @@ -487,8 +488,8 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre pField->type = pStream->outputSchema.pSchema[i].type; pField->bytes = pStream->outputSchema.pSchema[i].bytes; } - createReq.pTags = taosArrayInit(createReq.numOfTags, sizeof(SField)); - taosArraySetSize(createReq.pTags, 1); + createReq.pTags = taosArrayInit_s(createReq.numOfTags, sizeof(SField), 1); + // build tags SField *pField = taosArrayGet(createReq.pTags, 0); strcpy(pField->name, "group_id"); diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 3b7687359c..a9652fb2ff 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -104,8 +104,8 @@ void metaReaderClear(SMetaReader *pReader); int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid); int32_t metaGetTableEntryByUidCache(SMetaReader *pReader, tb_uid_t uid); int metaGetTableEntryByName(SMetaReader *pReader, const char *name); -int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags); -int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHashObj *tags); +int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList); +int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList); int32_t metaReadNext(SMetaReader *pReader); const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal); int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index ec66e581ef..702cbea333 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -236,6 +236,7 @@ void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, char fname[]); void tsdbSttFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSttFile *pSttF, char fname[]); void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]); + // SDelFile void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]); // tsdbFS.c ============================================================================================== @@ -646,6 +647,7 @@ typedef struct SSttBlockLoadInfo { int16_t *colIds; int32_t numOfCols; bool sttBlockLoaded; + int32_t numOfStt; // keep the last access position, this position may be used to reduce the binary times for // starting last block data for a new table @@ -711,7 +713,7 @@ bool tMergeTreeNext(SMergeTree *pMTree); TSDBROW tMergeTreeGetRow(SMergeTree *pMTree); void tMergeTreeClose(SMergeTree *pMTree); -SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols); +SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols, int32_t numOfStt); void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo); void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el); void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 2501af7f04..ec925087d0 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -107,7 +107,7 @@ typedef struct STbUidStore STbUidStore; #define META_BEGIN_HEAP_NIL 2 int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback); -int metaClose(SMeta* pMeta); +int metaClose(SMeta** pMeta); int metaBegin(SMeta* pMeta, int8_t fromSys); TXN* metaGetTxn(SMeta* pMeta); int metaCommit(SMeta* pMeta, TXN* txn); diff --git a/source/dnode/vnode/src/meta/metaCache.c b/source/dnode/vnode/src/meta/metaCache.c index d68658b0d9..21a1014e87 100644 --- a/source/dnode/vnode/src/meta/metaCache.c +++ b/source/dnode/vnode/src/meta/metaCache.c @@ -32,9 +32,9 @@ typedef struct SMetaStbStatsEntry { } SMetaStbStatsEntry; typedef struct STagFilterResEntry { - uint64_t suid; // uid for super table SList list; // the linked list of md5 digest, extracted from the serialized tag query condition - uint32_t qTimes; // queried times for current super table + uint32_t hitTimes; // queried times for current super table + uint32_t accTime; } STagFilterResEntry; struct SMetaCache { @@ -55,6 +55,7 @@ struct SMetaCache { // query cache struct STagFilterResCache { TdThreadMutex lock; + uint32_t accTimes; SHashObj* pTableEntry; SLRUCache* pUidResCache; } sTagFilterResCache; @@ -132,6 +133,7 @@ int32_t metaCacheOpen(SMeta* pMeta) { goto _err2; } + pCache->sTagFilterResCache.accTimes = 0; pCache->sTagFilterResCache.pTableEntry = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK); if (pCache->sTagFilterResCache.pTableEntry == NULL) { @@ -159,9 +161,9 @@ void metaCacheClose(SMeta* pMeta) { entryCacheClose(pMeta); statsCacheClose(pMeta); - taosHashCleanup(pMeta->pCache->sTagFilterResCache.pTableEntry); taosLRUCacheCleanup(pMeta->pCache->sTagFilterResCache.pUidResCache); taosThreadMutexDestroy(&pMeta->pCache->sTagFilterResCache.lock); + taosHashCleanup(pMeta->pCache->sTagFilterResCache.pTableEntry); taosMemoryFree(pMeta->pCache); pMeta->pCache = NULL; @@ -424,6 +426,31 @@ int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo) { return code; } +static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInvalidRes, int32_t keyLen, SLRUCache* pCache, uint64_t suid) { + SListIter iter = {0}; + tdListInitIter((SList*)&(pEntry->list), &iter, TD_LIST_FORWARD); + + SListNode* pNode = NULL; + uint64_t buf[3]; + buf[0] = suid; + + int32_t len = sizeof(uint64_t) * tListLen(buf); + + while ((pNode = tdListNext(&iter)) != NULL) { + memcpy(&buf[1], pNode->data, keyLen); + + // check whether it is existed in LRU cache, and remove it from linked list if not. + LRUHandle* pRes = taosLRUCacheLookup(pCache, buf, len); + if (pRes == NULL) { // remove the item in the linked list + taosArrayPush(pInvalidRes, &pNode); + } else { + taosLRUCacheRelease(pCache, pRes, false); + } + } + + return 0; +} + int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1, bool* acquireRes) { // generate the composed key for LRU cache @@ -431,16 +458,18 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK SHashObj* pTableMap = pMeta->pCache->sTagFilterResCache.pTableEntry; TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; - uint64_t buf[3] = {0}; - uint32_t times = 0; + uint64_t buf[4]; *acquireRes = 0; - buf[0] = suid; - memcpy(&buf[1], pKey, keyLen); + + buf[0] = (uint64_t) pTableMap; + buf[1] = suid; + memcpy(&buf[2], pKey, keyLen); taosThreadMutexLock(pLock); + pMeta->pCache->sTagFilterResCache.accTimes += 1; - int32_t len = keyLen + sizeof(uint64_t); + int32_t len = keyLen + sizeof(uint64_t) * 2; LRUHandle* pHandle = taosLRUCacheLookup(pCache, buf, len); if (pHandle == NULL) { taosThreadMutexUnlock(pLock); @@ -458,48 +487,17 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK // set the result into the buffer taosArrayAddBatch(pList1, p + sizeof(int32_t), size); - times = atomic_add_fetch_32(&(*pEntry)->qTimes, 1); + (*pEntry)->hitTimes += 1; + + uint32_t acc = pMeta->pCache->sTagFilterResCache.accTimes; + if ((*pEntry)->hitTimes % 5000 == 0 && (*pEntry)->hitTimes > 0) { + metaInfo("cache hit:%d, total acc:%d, rate:%.2f", (*pEntry)->hitTimes, acc, ((double)(*pEntry)->hitTimes) / acc); + } + taosLRUCacheRelease(pCache, pHandle, false); // unlock meta taosThreadMutexUnlock(pLock); - - // check if scanning all items are necessary or not - if (times >= 5000 && TD_DLIST_NELES(&(*pEntry)->list) > 10) { - taosThreadMutexLock(pLock); - - SArray* pInvalidRes = taosArrayInit(64, POINTER_BYTES); - - SListIter iter = {0}; - tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD); - - SListNode* pNode = NULL; - while ((pNode = tdListNext(&iter)) != NULL) { - memcpy(&buf[1], pNode->data, keyLen); - - // check whether it is existed in LRU cache, and remove it from linked list if not. - LRUHandle* pRes = taosLRUCacheLookup(pCache, buf, len); - if (pRes == NULL) { // remove the item in the linked list - taosArrayPush(pInvalidRes, &pNode); - } else { - taosLRUCacheRelease(pCache, pRes, false); - } - } - - // remove the keys, of which query uid lists have been replaced already. - size_t s = taosArrayGetSize(pInvalidRes); - for (int32_t i = 0; i < s; ++i) { - SListNode** p1 = taosArrayGet(pInvalidRes, i); - tdListPopNode(&(*pEntry)->list, *p1); - taosMemoryFree(*p1); - } - - atomic_store_32(&(*pEntry)->qTimes, 0); // reset the query times - taosArrayDestroy(pInvalidRes); - - taosThreadMutexUnlock(pLock); - } - return TSDB_CODE_SUCCESS; } @@ -507,9 +505,52 @@ static void freePayload(const void* key, size_t keyLen, void* value) { if (value == NULL) { return; } + + const uint64_t* p = key; + if (keyLen != sizeof(int64_t) * 4) { + metaError("key length is invalid, length:%d, expect:%d", (int32_t) keyLen, (int32_t) sizeof(uint64_t)*2); + return; + } + + SHashObj* pHashObj = (SHashObj*)p[0]; + STagFilterResEntry** pEntry = taosHashGet(pHashObj, &p[1], sizeof(uint64_t)); + + { + int64_t st = taosGetTimestampUs(); + + SListIter iter = {0}; + tdListInitIter((SList*)&((*pEntry)->list), &iter, TD_LIST_FORWARD); + + SListNode* pNode = NULL; + while ((pNode = tdListNext(&iter)) != NULL) { + uint64_t* digest = (uint64_t*)pNode->data; + if (digest[0] == p[2] && digest[1] == p[3]) { + tdListPopNode(&((*pEntry)->list), pNode); + + int64_t et = taosGetTimestampUs(); + metaInfo("clear items in cache, remain cached item:%d, elapsed time:%.2fms", listNEles(&((*pEntry)->list)), + (et - st)/1000.0); + return; + } + } + } + taosMemoryFree(value); } +static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyLen, uint64_t suid) { + STagFilterResEntry* p = taosMemoryMalloc(sizeof(STagFilterResEntry)); + if (p == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + p->hitTimes = 0; + tdListInit(&p->list, keyLen); + taosHashPut(pTableEntry, &suid, sizeof(uint64_t), &p, POINTER_BYTES); + tdListAppend(&p->list, pKey); + return 0; +} + // check both the payload size and selectivity ratio int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, void* pPayload, int32_t payloadLen, double selectivityRatio) { @@ -533,42 +574,61 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry; TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; + // the format of key: + // hash table address(8bytes) + suid(8bytes) + MD5 digest(16bytes) + + uint64_t buf[4] = {0}; + buf[0] = (uint64_t) pTableEntry; + buf[1] = suid; + memcpy(&buf[2], pKey, keyLen); + ASSERT(keyLen == 16); + + int32_t code = 0; taosThreadMutexLock(pLock); STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t)); if (pEntry == NULL) { - STagFilterResEntry* p = taosMemoryMalloc(sizeof(STagFilterResEntry)); - p->qTimes = 0; - tdListInit(&p->list, keyLen); - taosHashPut(pTableEntry, &suid, sizeof(uint64_t), &p, POINTER_BYTES); - tdListAppend(&p->list, pKey); + code = addNewEntry(pTableEntry, pKey, keyLen, suid); + if (code != TSDB_CODE_SUCCESS) { + goto _end; + } } else { - tdListAppend(&(*pEntry)->list, pKey); + // check if it exists or not + size_t size = listNEles(&(*pEntry)->list); + if (size == 0) { + tdListAppend(&(*pEntry)->list, pKey); + } else { + SListNode* pNode = listHead(&(*pEntry)->list); + uint64_t* p = (uint64_t*)pNode->data; + if (p[1] == ((uint64_t*)pKey)[1] && p[0] == ((uint64_t*)pKey)[0]) { + // we have already found the existed items, no need to added to cache anymore. + taosThreadMutexUnlock(pLock); + return TSDB_CODE_SUCCESS; + } else { // not equal, append it + tdListAppend(&(*pEntry)->list, pKey); + } + } } - uint64_t buf[3] = {0}; - buf[0] = suid; - - memcpy(&buf[1], pKey, keyLen); - ASSERT(sizeof(uint64_t) + keyLen == 24); - // add to cache. - taosLRUCacheInsert(pCache, buf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL, + taosLRUCacheInsert(pCache, buf, sizeof(uint64_t)*2 + keyLen, pPayload, payloadLen, freePayload, NULL, TAOS_LRU_PRIORITY_LOW); - + _end: taosThreadMutexUnlock(pLock); metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", TD_VID(pMeta->pVnode), suid, (int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry)); - return TSDB_CODE_SUCCESS; + return code; } // remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) { int32_t keyLen = sizeof(uint64_t) * 3; - uint64_t p[3] = {0}; - p[0] = suid; + uint64_t p[4] = {0}; + + p[0] = (uint64_t) pMeta->pCache->sTagFilterResCache.pTableEntry; + p[1] = suid; TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; @@ -584,11 +644,11 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) { SListNode* pNode = NULL; while ((pNode = tdListNext(&iter)) != NULL) { - memcpy(&p[1], pNode->data, 16); + memcpy(&p[2], pNode->data, 16); taosLRUCacheErase(pMeta->pCache->sTagFilterResCache.pUidResCache, p, keyLen); } - (*pEntry)->qTimes = 0; + (*pEntry)->hitTimes = 0; tdListEmpty(&(*pEntry)->list); taosThreadMutexUnlock(pLock); diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 35677d6f07..550d7b587c 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -201,7 +201,8 @@ _err: return -1; } -int metaClose(SMeta *pMeta) { +int metaClose(SMeta **ppMeta) { + SMeta *pMeta = *ppMeta; if (pMeta) { if (pMeta->pEnv) metaAbort(pMeta); if (pMeta->pCache) metaCacheClose(pMeta); @@ -221,7 +222,8 @@ int metaClose(SMeta *pMeta) { if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb); if (pMeta->pEnv) tdbClose(pMeta->pEnv); metaDestroyLock(pMeta); - taosMemoryFree(pMeta); + + taosMemoryFreeClear(*ppMeta); } return 0; diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 28bac3e8d0..20f789b348 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -1371,13 +1371,14 @@ static int32_t metaGetTableTagByUid(SMeta *pMeta, int64_t suid, int64_t uid, voi return ret; } -int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHashObj *tags) { + +int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList) { const int32_t LIMIT = 128; int32_t isLock = false; int32_t sz = uidList ? taosArrayGetSize(uidList) : 0; for (int i = 0; i < sz; i++) { - tb_uid_t *id = taosArrayGet(uidList, i); + STUidTagInfo *p = taosArrayGet(uidList, i); if (i % LIMIT == 0) { if (isLock) metaULock(pMeta); @@ -1386,51 +1387,72 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHas isLock = true; } - if (taosHashGet(tags, id, sizeof(tb_uid_t)) == NULL) { +// if (taosHashGet(tags, &p->uid, sizeof(tb_uid_t)) == NULL) { void *val = NULL; int32_t len = 0; - if (metaGetTableTagByUid(pMeta, suid, *id, &val, &len, false) == 0) { - taosHashPut(tags, id, sizeof(tb_uid_t), val, len); + if (metaGetTableTagByUid(pMeta, suid, p->uid, &val, &len, false) == 0) { + p->pTagVal = taosMemoryMalloc(len); + memcpy(p->pTagVal, val, len); tdbFree(val); } else { - metaError("vgId:%d, failed to table IDs, suid: %" PRId64 ", uid: %" PRId64 "", TD_VID(pMeta->pVnode), suid, - *id); + metaError("vgId:%d, failed to table tags, suid: %" PRId64 ", uid: %" PRId64 "", TD_VID(pMeta->pVnode), suid, + p->uid); } } - } +// } if (isLock) metaULock(pMeta); - return 0; } -int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) { +int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *pUidTagInfo) { SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid, 1); - SHashObj *uHash = NULL; - size_t len = taosArrayGetSize(uidList); // len > 0 means there already have uids - if (len > 0) { - uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); - for (int i = 0; i < len; i++) { - int64_t *uid = taosArrayGet(uidList, i); - taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i)); + // If len > 0 means there already have uids, and we only want the + // tags of the specified tables, of which uid in the uid list. Otherwise, all table tags are retrieved and kept + // in the hash map, that may require a lot of memory + SHashObj *pSepecifiedUidMap = NULL; + size_t numOfElems = taosArrayGetSize(pUidTagInfo); + if (numOfElems > 0) { + pSepecifiedUidMap = taosHashInit(numOfElems / 0.7, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); + for (int i = 0; i < numOfElems; i++) { + STUidTagInfo *pTagInfo = taosArrayGet(pUidTagInfo, i); + taosHashPut(pSepecifiedUidMap, &pTagInfo->uid, sizeof(uint64_t), &i, sizeof(int32_t)); } } - while (1) { - tb_uid_t id = metaCtbCursorNext(pCur); - if (id == 0) { - break; - } - if (len > 0 && taosHashGet(uHash, &id, sizeof(int64_t)) == NULL) { - continue; - } else if (len == 0) { - taosArrayPush(uidList, &id); - } + if (numOfElems == 0) { // all data needs to be added into the pUidTagInfo list + while (1) { + tb_uid_t uid = metaCtbCursorNext(pCur); + if (uid == 0) { + break; + } - taosHashPut(tags, &id, sizeof(int64_t), pCur->pVal, pCur->vLen); + STUidTagInfo info = {.uid = uid, .pTagVal = pCur->pVal}; + info.pTagVal = taosMemoryMalloc(pCur->vLen); + memcpy(info.pTagVal, pCur->pVal, pCur->vLen); + taosArrayPush(pUidTagInfo, &info); + } + } else { // only the specified tables need to be added + while (1) { + tb_uid_t uid = metaCtbCursorNext(pCur); + if (uid == 0) { + break; + } + + int32_t *index = taosHashGet(pSepecifiedUidMap, &uid, sizeof(uint64_t)); + if (index == NULL) { + continue; + } + + STUidTagInfo *pTagInfo = taosArrayGet(pUidTagInfo, *index); + if (pTagInfo->pTagVal == NULL) { + pTagInfo->pTagVal = taosMemoryMalloc(pCur->vLen); + memcpy(pTagInfo->pTagVal, pCur->pVal, pCur->vLen); + } + } } - taosHashCleanup(uHash); + taosHashCleanup(pSepecifiedUidMap); metaCloseCtbCursor(pCur, 1); return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index cca241a1cf..3e13eaa6e8 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -816,7 +816,6 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t version, char* msg, int32_t msgL // TODO version should be assigned and refed during preprocess SWalRef* pRef = walRefCommittedVer(pTq->pVnode->pWal); if (pRef == NULL) { - ASSERT(0); return -1; } int64_t ver = pRef->refVer; @@ -837,12 +836,9 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t version, char* msg, int32_t msgL pHandle->execHandle.task = qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, &pHandle->execHandle.numOfCols, NULL); - ASSERT(pHandle->execHandle.task); void* scanner = NULL; qExtractStreamScanner(pHandle->execHandle.task, &scanner); - ASSERT(scanner); pHandle->execHandle.pExecReader = qExtractReaderFromStreamScanner(scanner); - ASSERT(pHandle->execHandle.pExecReader); } else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) { pHandle->pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); pHandle->execHandle.pExecReader = tqOpenReader(pTq->pVnode); @@ -875,8 +871,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t version, char* msg, int32_t msgL taosHashPut(pTq->pHandle, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle)); tqDebug("try to persist handle %s consumer %" PRId64, req.subKey, pHandle->consumerId); if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) { - // TODO - ASSERT(0); + return -1; } } else { /*ASSERT(pExec->consumerId == req.oldConsumerId);*/ @@ -886,8 +881,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t version, char* msg, int32_t msgL atomic_add_fetch_32(&pHandle->epoch, 1); taosMemoryFree(req.qmsg); if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) { - // TODO - ASSERT(0); + return -1; } // close handle } diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 3ad01e2370..34f57bc697 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -71,17 +71,14 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) { int32_t tqMetaOpen(STQ* pTq) { if (tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaDB, 0) < 0) { - ASSERT(0); return -1; } if (tdbTbOpen("tq.db", -1, -1, NULL, pTq->pMetaDB, &pTq->pExecStore, 0) < 0) { - ASSERT(0); return -1; } if (tdbTbOpen("tq.check.db", -1, -1, NULL, pTq->pMetaDB, &pTq->pCheckStore, 0) < 0) { - ASSERT(0); return -1; } @@ -197,40 +194,49 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) { int32_t code; int32_t vlen; tEncodeSize(tEncodeSTqHandle, pHandle, vlen, code); - ASSERT(code == 0); tqDebug("tq save %s(%d) consumer %" PRId64 " vgId:%d", pHandle->subKey, (int32_t)strlen(pHandle->subKey), pHandle->consumerId, TD_VID(pTq->pVnode)); void* buf = taosMemoryCalloc(1, vlen); if (buf == NULL) { - ASSERT(0); + return -1; } SEncoder encoder; tEncoderInit(&encoder, buf, vlen); if (tEncodeSTqHandle(&encoder, pHandle) < 0) { - ASSERT(0); + tEncoderClear(&encoder); + taosMemoryFree(buf); + return -1; } TXN* txn; if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { - ASSERT(0); + tEncoderClear(&encoder); + taosMemoryFree(buf); + return -1; } if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, txn) < 0) { - ASSERT(0); + tEncoderClear(&encoder); + taosMemoryFree(buf); + return -1; } if (tdbCommit(pTq->pMetaDB, txn) < 0) { - ASSERT(0); + tEncoderClear(&encoder); + taosMemoryFree(buf); + return -1; } if (tdbPostCommit(pTq->pMetaDB, txn) < 0) { - ASSERT(0); + tEncoderClear(&encoder); + taosMemoryFree(buf); + return -1; } tEncoderClear(&encoder); diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 9e04b70f41..338f9d6c24 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -101,7 +101,8 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) { } char* fname = tqOffsetBuildFName(pStore->pTq->path, 0); if (tqOffsetRestoreFromFile(pStore, fname) < 0) { - ASSERT(0); + taosMemoryFree(fname); + return NULL; } taosMemoryFree(fname); return pStore; diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index fb2efda8e4..ec0944193a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -244,6 +244,11 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST int16_t nCol = taosArrayGetSize(pLast); int16_t iCol = 0; + if (nCol != pTSchema->numOfCols) { + invalidate = true; + goto _invalidate; + } + SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol); if (keyTs > tTsVal->ts) { STColumn *pTColumn = &pTSchema->columns[0]; @@ -259,6 +264,12 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST SColVal colVal = {0}; tTSRowGetVal(row, pTSchema, iCol, &colVal); + + if (colVal.cid != tColVal->cid) { + invalidate = true; + goto _invalidate; + } + if (!COL_VAL_IS_NONE(&colVal)) { if (keyTs == tTsVal1->ts && !COL_VAL_IS_NONE(tColVal)) { invalidate = true; @@ -268,7 +279,8 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); - taosMemoryFree(pLastCol->colVal.value.pData); + if (pLastCol->colVal.value.nData > 0 && NULL != pLastCol->colVal.value.pData) + taosMemoryFree(pLastCol->colVal.value.pData); lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); if (lastCol.colVal.value.pData == NULL) { @@ -315,6 +327,11 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb int16_t nCol = taosArrayGetSize(pLast); int16_t iCol = 0; + if (nCol != pTSchema->numOfCols) { + invalidate = true; + goto _invalidate; + } + SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol); if (keyTs > tTsVal->ts) { STColumn *pTColumn = &pTSchema->columns[0]; @@ -330,6 +347,12 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb SColVal colVal = {0}; tTSRowGetVal(row, pTSchema, iCol, &colVal); + + if (colVal.cid != tColVal->cid) { + invalidate = true; + goto _invalidate; + } + if (COL_VAL_IS_VALUE(&colVal)) { if (keyTs == tTsVal1->ts && COL_VAL_IS_VALUE(tColVal)) { invalidate = true; @@ -339,7 +362,8 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); - taosMemoryFree(pLastCol->colVal.value.pData); + if (pLastCol->colVal.value.nData > 0 && NULL != pLastCol->colVal.value.pData) + taosMemoryFree(pLastCol->colVal.value.pData); lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); if (lastCol.colVal.value.pData == NULL) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index fd5e8eb6e0..c94d2130c5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -41,6 +41,13 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p int32_t slotId = slotIds[i]; SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId); + // add check for null value, caused by the modification of table schema (new column added). + if (pColVal == NULL) { + p->ts = 0; + p->isNull = true; + continue; + } + p->ts = pColVal->ts; p->isNull = !COL_VAL_IS_VALUE(&pColVal->colVal); allNullRow = p->isNull & allNullRow; @@ -174,7 +181,8 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, } } - p->pLoadInfo = tCreateLastBlockLoadInfo(p->pSchema, NULL, 0); + int32_t numOfStt = ((SVnode*)pVnode)->config.sttTrigger; + p->pLoadInfo = tCreateLastBlockLoadInfo(p->pSchema, NULL, 0, numOfStt); if (p->pLoadInfo == NULL) { tsdbCacherowsReaderClose(p); return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 3c944584de..42728be657 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -92,24 +92,56 @@ static int32_t tGetSmaFile(uint8_t *p, SSmaFile *pSmaFile) { } // EXPOSED APIS ================================================== +static char* getFileNamePrefix(STsdb *pTsdb, SDiskID did, int32_t fid, uint64_t commitId, char fname[]) { + const char* p1 = tfsGetDiskPath(pTsdb->pVnode->pTfs, did); + int32_t len = strlen(p1); + + char* p = memcpy(fname, p1, len); + p += len; + + *(p++) = TD_DIRSEP[0]; + len = strlen(pTsdb->path); + + memcpy(p, pTsdb->path, len); + p += len; + + *(p++) = TD_DIRSEP[0]; + *(p++) = 'v'; + + p += titoa(TD_VID(pTsdb->pVnode), 10, p); + *(p++) = 'f'; + + p += titoa(fid, 10, p); + + memcpy(p, "ver", 3); + p += 3; + + p += titoa(commitId, 10, p); + return p; +} + void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, char fname[]) { - snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did), - TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pHeadF->commitID, ".head"); + char* p = getFileNamePrefix(pTsdb, did, fid, pHeadF->commitID, fname); + memcpy(p, ".head", 5); + p[5] = 0; } void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, char fname[]) { - snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did), - TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pDataF->commitID, ".data"); + char* p = getFileNamePrefix(pTsdb, did, fid, pDataF->commitID, fname); + memcpy(p, ".data", 5); + p[5] = 0; } void tsdbSttFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSttFile *pSttF, char fname[]) { - snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did), - TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pSttF->commitID, ".stt"); + char* p = getFileNamePrefix(pTsdb, did, fid, pSttF->commitID, fname); + memcpy(p, ".stt", 4); + p[4] = 0; } void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]) { - snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did), - TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pSmaF->commitID, ".sma"); + char* p = getFileNamePrefix(pTsdb, did, fid, pSmaF->commitID, fname); + memcpy(p, ".sma", 4); + p[4] = 0; } bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2) { return pDelFile1->commitID == pDelFile2->commitID; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 132b7c797c..91152574d2 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -31,14 +31,16 @@ struct SLDataIter { SSttBlockLoadInfo *pBlockLoadInfo; }; -SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols) { - SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(TSDB_MAX_STT_TRIGGER, sizeof(SSttBlockLoadInfo)); +SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols, int32_t numOfSttTrigger) { + SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(numOfSttTrigger, sizeof(SSttBlockLoadInfo)); if (pLoadInfo == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) { + pLoadInfo->numOfStt = numOfSttTrigger; + + for (int32_t i = 0; i < numOfSttTrigger; ++i) { pLoadInfo[i].blockIndex[0] = -1; pLoadInfo[i].blockIndex[1] = -1; pLoadInfo[i].currentLoadBlockIndex = 1; @@ -63,7 +65,7 @@ SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, } void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) { - for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) { + for (int32_t i = 0; i < pLoadInfo->numOfStt; ++i) { pLoadInfo[i].currentLoadBlockIndex = 1; pLoadInfo[i].blockIndex[0] = -1; pLoadInfo[i].blockIndex[1] = -1; @@ -77,14 +79,14 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) { } void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el) { - for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) { + for (int32_t i = 0; i < pLoadInfo->numOfStt; ++i) { *el += pLoadInfo[i].elapsedTime; *blocks += pLoadInfo[i].loadBlocks; } } void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) { - for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) { + for (int32_t i = 0; i < pLoadInfo->numOfStt; ++i) { pLoadInfo[i].currentLoadBlockIndex = 1; pLoadInfo[i].blockIndex[0] = -1; pLoadInfo[i].blockIndex[1] = -1; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index e9bb7e3d09..4e1b24750a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -133,17 +133,17 @@ typedef struct SFileBlockDumpInfo { bool allDumped; } SFileBlockDumpInfo; -typedef struct SUidOrderCheckInfo { +typedef struct STableUidList { uint64_t* tableUidList; // access table uid list in uid ascending order list int32_t currentIndex; // index in table uid list -} SUidOrderCheckInfo; +} STableUidList; typedef struct SReaderStatus { bool loadFromFile; // check file stage bool composedDataBlock; // the returned data block is a composed block or not SHashObj* pTableMap; // SHash STableBlockScanInfo** pTableIter; // table iterator used in building in-memory buffer data blocks. - SUidOrderCheckInfo uidCheckInfo; // check all table in uid order + STableUidList uidList; // check tables in uid order, to avoid the repeatly load of blocks in STT. SFileBlockDumpInfo fBlockDumpInfo; SDFileSet* pCurrentFileset; // current opened file set SBlockData fileBlockData; @@ -317,9 +317,19 @@ static void* getPosInBlockInfoBuf(SBlockInfoBuf* pBuf, int32_t index) { return (*pBucket) + (index % pBuf->numPerBucket) * sizeof(STableBlockScanInfo); } +static int32_t uidComparFunc(const void* p1, const void* p2) { + uint64_t pu1 = *(uint64_t*)p1; + uint64_t pu2 = *(uint64_t*)p2; + if (pu1 == pu2) { + return 0; + } else { + return (pu1 < pu2) ? -1 : 1; + } +} + // NOTE: speedup the whole processing by preparing the buffer for STableBlockScanInfo in batch model static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf, const STableKeyInfo* idList, - int32_t numOfTables) { + STableUidList *pUidList, int32_t numOfTables) { // allocate buffer in order to load data blocks from file // todo use simple hash instead, optimize the memory consumption SHashObj* pTableMap = @@ -331,9 +341,18 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf int64_t st = taosGetTimestampUs(); initBlockScanInfoBuf(pBuf, numOfTables); + pUidList->tableUidList = taosMemoryMalloc(numOfTables * sizeof(uint64_t)); + if (pUidList->tableUidList == NULL) { + return NULL; + } + pUidList->currentIndex = 0; + for (int32_t j = 0; j < numOfTables; ++j) { STableBlockScanInfo* pScanInfo = getPosInBlockInfoBuf(pBuf, j); + pScanInfo->uid = idList[j].uid; + pUidList->tableUidList[j] = idList[j].uid; + if (ASCENDING_TRAVERSE(pTsdbReader->order)) { int64_t skey = pTsdbReader->window.skey; pScanInfo->lastKey = (skey > INT64_MIN) ? (skey - 1) : skey; @@ -347,6 +366,8 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf pScanInfo->lastKey, pTsdbReader->idStr); } + taosSort(pUidList->tableUidList, numOfTables, sizeof(uint64_t), uidComparFunc); + pTsdbReader->cost.createScanInfoList = (taosGetTimestampUs() - st) / 1000.0; tsdbDebug("%p create %d tables scan-info, size:%.2f Kb, elapsed time:%.2f ms, %s", pTsdbReader, numOfTables, (sizeof(STableBlockScanInfo) * numOfTables) / 1024.0, pTsdbReader->cost.createScanInfoList, @@ -451,8 +472,11 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb if (pLReader->pInfo == NULL) { // here we ignore the first column, which is always be the primary timestamp column + SBlockLoadSuppInfo* pInfo = &pReader->suppInfo; + + int32_t numOfStt = pReader->pTsdb->pVnode->config.sttTrigger; pLReader->pInfo = - tCreateLastBlockLoadInfo(pReader->pSchema, &pReader->suppInfo.colId[1], pReader->suppInfo.numOfCols - 1); + tCreateLastBlockLoadInfo(pReader->pSchema, &pInfo->colId[1], pInfo->numOfCols - 1, numOfStt); if (pLReader->pInfo == NULL) { tsdbDebug("init fileset iterator failed, code:%s %s", tstrerror(terrno), pReader->idStr); return terrno; @@ -621,7 +645,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd goto _end; } - setColumnIdSlotList(&pReader->suppInfo, pCond->colList, pCond->pSlotList, pCond->numOfCols); + setColumnIdSlotList(pSup, pCond->colList, pCond->pSlotList, pCond->numOfCols); *ppReader = pReader; return code; @@ -633,57 +657,74 @@ _end: } static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader, SArray* pIndexList) { - // SArray* aBlockIdx = taosArrayInit(8, sizeof(SBlockIdx)); - int64_t st = taosGetTimestampUs(); - // int32_t code = tsdbReadBlockIdx(pFileReader, aBlockIdx); LRUHandle* handle = NULL; int32_t code = tsdbCacheGetBlockIdx(pFileReader->pTsdb->biCache, pFileReader, &handle); if (code != TSDB_CODE_SUCCESS || handle == NULL) { goto _end; } + int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap); + SArray* aBlockIdx = (SArray*)taosLRUCacheValue(pFileReader->pTsdb->biCache, handle); size_t num = taosArrayGetSize(aBlockIdx); if (num == 0) { tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); - // taosArrayDestroy(aBlockIdx); return TSDB_CODE_SUCCESS; } + // todo binary search to the start position int64_t et1 = taosGetTimestampUs(); SBlockIdx* pBlockIdx = NULL; - for (int32_t i = 0; i < num; ++i) { + STableUidList* pList = &pReader->status.uidList; + + int32_t i = 0, j = 0; + while(i < num && j < numOfTables) { pBlockIdx = (SBlockIdx*)taosArrayGet(aBlockIdx, i); - - // uid check if (pBlockIdx->suid != pReader->suid) { + i += 1; continue; } - // this block belongs to a table that is not queried. - void* p = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(uint64_t)); - if (p == NULL) { + if (pBlockIdx->uid < pList->tableUidList[j]) { + i += 1; continue; } - STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)p; - if (pScanInfo->pBlockList == NULL) { - pScanInfo->pBlockList = taosArrayInit(4, sizeof(SBlockIndex)); + if (pBlockIdx->uid > pList->tableUidList[j]) { + j += 1; + continue; } - taosArrayPush(pIndexList, pBlockIdx); + if (pBlockIdx->uid == pList->tableUidList[j]) { + // this block belongs to a table that is not queried. + void* p = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(uint64_t)); + if (p == NULL) { + tsdbError("failed to locate the tableBlockScan Info in hashmap, uid:%"PRIu64", %s", pBlockIdx->uid, pReader->idStr); + return TSDB_CODE_APP_ERROR; + } + + STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)p; + if (pScanInfo->pBlockList == NULL) { + pScanInfo->pBlockList = taosArrayInit(4, sizeof(SBlockIndex)); + } + + taosArrayPush(pIndexList, pBlockIdx); + + i += 1; + j += 1; + } } int64_t et2 = taosGetTimestampUs(); - tsdbDebug("load block index for %d tables completed, elapsed time:%.2f ms, set blockIdx:%.2f ms, size:%.2f Kb %s", - (int32_t)num, (et1 - st) / 1000.0, (et2 - et1) / 1000.0, num * sizeof(SBlockIdx) / 1024.0, pReader->idStr); + tsdbDebug("load block index for %d/%d tables completed, elapsed time:%.2f ms, set blockIdx:%.2f ms, size:%.2f Kb %s", + numOfTables, (int32_t)num, (et1 - st) / 1000.0, (et2 - et1) / 1000.0, num * sizeof(SBlockIdx) / 1024.0, + pReader->idStr); pReader->cost.headFileLoadTime += (et1 - st) / 1000.0; _end: - // taosArrayDestroy(aBlockIdx); tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); return code; } @@ -2725,74 +2766,15 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) { return TSDB_CODE_SUCCESS; } -static int32_t uidComparFunc(const void* p1, const void* p2) { - uint64_t pu1 = *(uint64_t*)p1; - uint64_t pu2 = *(uint64_t*)p2; - if (pu1 == pu2) { - return 0; - } else { - return (pu1 < pu2) ? -1 : 1; - } +static void resetTableListIndex(SReaderStatus *pStatus) { + STableUidList* pList = &pStatus->uidList; + + pList->currentIndex = 0; + uint64_t uid = pList->tableUidList[0]; + pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); } -static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus, int32_t order) { - int32_t index = 0; - int32_t total = taosHashGetSize(pStatus->pTableMap); - - void* p = taosHashIterate(pStatus->pTableMap, NULL); - while (p != NULL) { - STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)p; - pOrderCheckInfo->tableUidList[index++] = pScanInfo->uid; - p = taosHashIterate(pStatus->pTableMap, p); - } - - taosSort(pOrderCheckInfo->tableUidList, total, sizeof(uint64_t), uidComparFunc); -} - -static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, STsdbReader* pReader) { - SReaderStatus* pStatus = &pReader->status; - - int32_t total = taosHashGetSize(pStatus->pTableMap); - if (total == 0) { - return TSDB_CODE_SUCCESS; - } - - if (pOrderCheckInfo->tableUidList == NULL) { - pOrderCheckInfo->currentIndex = 0; - pOrderCheckInfo->tableUidList = taosMemoryMalloc(total * sizeof(uint64_t)); - if (pOrderCheckInfo->tableUidList == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); - uint64_t uid = pOrderCheckInfo->tableUidList[0]; - pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); - } else { - if (pStatus->pTableIter == NULL) { // it is the last block of a new file - pOrderCheckInfo->currentIndex = 0; - uint64_t uid = pOrderCheckInfo->tableUidList[pOrderCheckInfo->currentIndex]; - pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); - - // the tableMap has already updated - if (pStatus->pTableIter == NULL) { - void* p = taosMemoryRealloc(pOrderCheckInfo->tableUidList, total * sizeof(uint64_t)); - if (p == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - pOrderCheckInfo->tableUidList = p; - extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); - - uid = pOrderCheckInfo->tableUidList[0]; - pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); - } - } - } - - return TSDB_CODE_SUCCESS; -} - -static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus* pStatus) { +static bool moveToNextTable(STableUidList* pOrderedCheckInfo, SReaderStatus* pStatus) { pOrderedCheckInfo->currentIndex += 1; if (pOrderedCheckInfo->currentIndex >= taosHashGetSize(pStatus->pTableMap)) { pStatus->pTableIter = NULL; @@ -2807,11 +2789,10 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; SLastBlockReader* pLastBlockReader = pStatus->fileIter.pLastBlockReader; + STableUidList* pUidList = &pStatus->uidList; - SUidOrderCheckInfo* pOrderedCheckInfo = &pStatus->uidCheckInfo; - int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pReader); - if (code != TSDB_CODE_SUCCESS || (taosHashGetSize(pStatus->pTableMap) == 0)) { - return code; + if (taosHashGetSize(pStatus->pTableMap) == 0) { + return TSDB_CODE_SUCCESS; } SSDataBlock* pResBlock = pReader->pResBlock; @@ -2822,7 +2803,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader); if (!hasVal) { - bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus); + bool hasNexTable = moveToNextTable(pUidList, pStatus); if (!hasNexTable) { return TSDB_CODE_SUCCESS; } @@ -2857,7 +2838,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { } // current table is exhausted, let's try next table - bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus); + bool hasNexTable = moveToNextTable(pUidList, pStatus); if (!hasNexTable) { return TSDB_CODE_SUCCESS; } @@ -2961,14 +2942,15 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; + STableUidList* pUidList = &pStatus->uidList; while (1) { - if (pStatus->pTableIter == NULL) { - pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, NULL); - if (pStatus->pTableIter == NULL) { - return TSDB_CODE_SUCCESS; - } - } +// if (pStatus->pTableIter == NULL) { +// pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, NULL); +// if (pStatus->pTableIter == NULL) { +// return TSDB_CODE_SUCCESS; +// } +// } STableBlockScanInfo** pBlockScanInfo = pStatus->pTableIter; initMemDataIterator(*pBlockScanInfo, pReader); @@ -2983,9 +2965,9 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) { return TSDB_CODE_SUCCESS; } - // current table is exhausted, let's try the next table - pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, pStatus->pTableIter); - if (pStatus->pTableIter == NULL) { + // current table is exhausted, let's try next table + bool hasNexTable = moveToNextTable(pUidList, pStatus); + if (!hasNexTable) { return TSDB_CODE_SUCCESS; } } @@ -3006,7 +2988,6 @@ void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) { static int32_t initForFirstBlockInFile(STsdbReader* pReader, SDataBlockIter* pBlockIter) { SBlockNumber num = {0}; - int32_t code = moveToNextFile(pReader, &num); if (code != TSDB_CODE_SUCCESS) { return code; @@ -3024,6 +3005,7 @@ static int32_t initForFirstBlockInFile(STsdbReader* pReader, SDataBlockIter* pBl } else { // no block data, only last block exists tBlockDataReset(&pReader->status.fileBlockData); resetDataBlockIterator(pBlockIter, pReader->order); + resetTableListIndex(&pReader->status); } // set the correct start position according to the query time window @@ -3064,6 +3046,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { // this file does not have data files, let's start check the last block file if exists if (pBlockIter->numOfBlocks == 0) { + resetTableListIndex(&pReader->status); goto _begin; } } @@ -3095,6 +3078,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { // data blocks in current file are exhausted, let's try the next file now tBlockDataReset(&pReader->status.fileBlockData); resetDataBlockIterator(pBlockIter, pReader->order); + resetTableListIndex(&pReader->status); goto _begin; } else { code = initForFirstBlockInFile(pReader, pBlockIter); @@ -3106,6 +3090,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { // this file does not have blocks, let's start check the last block file if (pBlockIter->numOfBlocks == 0) { + resetTableListIndex(&pReader->status); goto _begin; } } @@ -3768,11 +3753,15 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n ASSERT(size >= num); taosHashClear(pReader->status.pTableMap); + STableUidList* pUidList = &pReader->status.uidList; + pUidList->currentIndex = 0; STableKeyInfo* pList = (STableKeyInfo*)pTableList; for (int32_t i = 0; i < num; ++i) { STableBlockScanInfo* pInfo = getPosInBlockInfoBuf(&pReader->blockInfoBuf, i); pInfo->uid = pList[i].uid; + pUidList->tableUidList[i] = pList[i].uid; + taosHashPut(pReader->status.pTableMap, &pInfo->uid, sizeof(uint64_t), &pInfo, POINTER_BYTES); } @@ -3796,18 +3785,24 @@ void* tsdbGetIvtIdx(SMeta* pMeta) { uint64_t getReaderMaxVersion(STsdbReader* pReader) { return pReader->verRange.maxVer; } static int32_t doOpenReaderImpl(STsdbReader* pReader) { - SDataBlockIter* pBlockIter = &pReader->status.blockIter; + SReaderStatus* pStatus = &pReader->status; + SDataBlockIter* pBlockIter = &pStatus->blockIter; - initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader); - resetDataBlockIterator(&pReader->status.blockIter, pReader->order); + initFilesetIterator(&pStatus->fileIter, pReader->pReadSnap->fs.aDFileSet, pReader); + resetDataBlockIterator(&pStatus->blockIter, pReader->order); - // no data in files, let's try buffer in memory - if (pReader->status.fileIter.numOfFiles == 0) { - pReader->status.loadFromFile = false; - return TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; + if (pStatus->fileIter.numOfFiles == 0) { + pStatus->loadFromFile = false; } else { - return initForFirstBlockInFile(pReader, pBlockIter); + code = initForFirstBlockInFile(pReader, pBlockIter); } + + if (!pStatus->loadFromFile) { + resetTableListIndex(pStatus); + } + + return code; } // ====================================== EXPOSED APIs ====================================== @@ -3894,7 +3889,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } STsdbReader* p = (pReader->innerReader[0] != NULL) ? pReader->innerReader[0] : pReader; - pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, numOfTables); + pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, &pReader->status.uidList, numOfTables); if (pReader->status.pTableMap == NULL) { *ppReader = NULL; code = TSDB_CODE_OUT_OF_MEMORY; @@ -3919,12 +3914,14 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL // we need only one row pPrevReader->capacity = 1; pPrevReader->status.pTableMap = pReader->status.pTableMap; + pPrevReader->status.uidList = pReader->status.uidList; pPrevReader->pSchema = pReader->pSchema; pPrevReader->pMemSchema = pReader->pMemSchema; pPrevReader->pReadSnap = pReader->pReadSnap; pNextReader->capacity = 1; pNextReader->status.pTableMap = pReader->status.pTableMap; + pNextReader->status.uidList = pReader->status.uidList; pNextReader->pSchema = pReader->pSchema; pNextReader->pMemSchema = pReader->pMemSchema; pNextReader->pReadSnap = pReader->pReadSnap; @@ -3942,6 +3939,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL _err: tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr); tsdbReaderClose(pReader); + *ppReader = NULL; // reset the pointer value. return code; } @@ -3955,6 +3953,7 @@ void tsdbReaderClose(STsdbReader* pReader) { STsdbReader* p = pReader->innerReader[0]; p->status.pTableMap = NULL; + p->status.uidList.tableUidList = NULL; p->pReadSnap = NULL; p->pSchema = NULL; p->pMemSchema = NULL; @@ -3962,6 +3961,7 @@ void tsdbReaderClose(STsdbReader* pReader) { p = pReader->innerReader[1]; p->status.pTableMap = NULL; + p->status.uidList.tableUidList = NULL; p->pReadSnap = NULL; p->pSchema = NULL; p->pMemSchema = NULL; @@ -4009,7 +4009,7 @@ void tsdbReaderClose(STsdbReader* pReader) { tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap, pReader->idStr); - taosMemoryFree(pReader->status.uidCheckInfo.tableUidList); + taosMemoryFree(pReader->status.uidList.tableUidList); SIOCostSummary* pCost = &pReader->cost; SFilesetIter* pFilesetIter = &pReader->status.fileIter; @@ -4063,6 +4063,7 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) { if (pBlock->info.rows > 0) { return true; } else { + resetTableListIndex(&pReader->status); buildBlockFromBufferSequentially(pReader); return pBlock->info.rows > 0; } @@ -4073,11 +4074,11 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) { } bool tsdbNextDataBlock(STsdbReader* pReader) { - if (isEmptyQueryTimeWindow(&pReader->window)) { + if (isEmptyQueryTimeWindow(&pReader->window) || pReader->step == EXTERNAL_ROWS_NEXT) { return false; } - if (pReader->innerReader[0] != NULL && pReader->step == 0) { + if (pReader->step == 0 && pReader->innerReader[0] != NULL) { bool ret = doTsdbNextDataBlock(pReader->innerReader[0]); pReader->step = EXTERNAL_ROWS_PREV; if (ret) { @@ -4102,7 +4103,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { return ret; } - if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) { + if (pReader->step == EXTERNAL_ROWS_MAIN && pReader->innerReader[1] != NULL) { // prepare for the next row scan int32_t code = doOpenReaderImpl(pReader->innerReader[1]); resetAllDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey); @@ -4110,10 +4111,10 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { return code; } - bool ret1 = doTsdbNextDataBlock(pReader->innerReader[1]); + ret = doTsdbNextDataBlock(pReader->innerReader[1]); pReader->step = EXTERNAL_ROWS_NEXT; - if (ret1) { - return ret1; + if (ret) { + return ret; } } @@ -4276,12 +4277,14 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { return TSDB_CODE_SUCCESS; } - SDataBlockIter* pBlockIter = &pReader->status.blockIter; + SReaderStatus* pStatus = &pReader->status; + + SDataBlockIter* pBlockIter = &pStatus->blockIter; pReader->order = pCond->order; pReader->type = TIMEWINDOW_RANGE_CONTAINED; - pReader->status.loadFromFile = true; - pReader->status.pTableIter = NULL; + pStatus->loadFromFile = true; + pStatus->pTableIter = NULL; pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows); // allocate buffer in order to load data blocks from file @@ -4290,19 +4293,21 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { pReader->suppInfo.tsColAgg.colId = PRIMARYKEY_TIMESTAMP_COL_ID; tsdbDataFReaderClose(&pReader->pFileReader); - int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap); + int32_t numOfTables = taosHashGetSize(pStatus->pTableMap); - initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader); + initFilesetIterator(&pStatus->fileIter, pReader->pReadSnap->fs.aDFileSet, pReader); resetDataBlockIterator(pBlockIter, pReader->order); + resetTableListIndex(&pReader->status); int64_t ts = ASCENDING_TRAVERSE(pReader->order) ? pReader->window.skey - 1 : pReader->window.ekey + 1; - resetAllDataBlockScanInfo(pReader->status.pTableMap, ts); + resetAllDataBlockScanInfo(pStatus->pTableMap, ts); int32_t code = 0; // no data in files, let's try buffer in memory - if (pReader->status.fileIter.numOfFiles == 0) { - pReader->status.loadFromFile = false; + if (pStatus->fileIter.numOfFiles == 0) { + pStatus->loadFromFile = false; + resetTableListIndex(pStatus); } else { code = initForFirstBlockInFile(pReader, pBlockIter); if (code != TSDB_CODE_SUCCESS) { @@ -4380,7 +4385,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa hasNext = blockIteratorNext(&pStatus->blockIter, pReader->idStr); } else { code = initForFirstBlockInFile(pReader, pBlockIter); - if ((code != TSDB_CODE_SUCCESS) || (pReader->status.loadFromFile == false)) { + if ((code != TSDB_CODE_SUCCESS) || (pStatus->loadFromFile == false)) { break; } diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index c7bce6182a..50fd9d7aa7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -47,15 +47,21 @@ static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsd taosMemoryFree(pFD); goto _exit; } - if (taosStatFile(path, &pFD->szFile, NULL) < 0) { - code = TAOS_SYSTEM_ERROR(errno); - taosMemoryFree(pFD->pBuf); - taosCloseFile(&pFD->pFD); - taosMemoryFree(pFD); - goto _exit; + + // not check file size when reading data files. + if (flag != TD_FILE_READ) { + if (taosStatFile(path, &pFD->szFile, NULL) < 0) { + code = TAOS_SYSTEM_ERROR(errno); + taosMemoryFree(pFD->pBuf); + taosCloseFile(&pFD->pFD); + taosMemoryFree(pFD); + goto _exit; + } + + ASSERT(pFD->szFile % szPage == 0); + pFD->szFile = pFD->szFile / szPage; } - ASSERT(pFD->szFile % szPage == 0); - pFD->szFile = pFD->szFile / szPage; + *ppFD = pFD; _exit: @@ -103,7 +109,7 @@ _exit: static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) { int32_t code = 0; - ASSERT(pgno <= pFD->szFile); + // ASSERT(pgno <= pFD->szFile); // seek int64_t offset = PAGE_OFFSET(pgno, pFD->szPage); @@ -175,7 +181,7 @@ static int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t int32_t szPgCont = PAGE_CONTENT_SIZE(pFD->szPage); int64_t bOffset = fOffset % pFD->szPage; - ASSERT(pgno && pgno <= pFD->szFile); + // ASSERT(pgno && pgno <= pFD->szFile); ASSERT(bOffset < szPgCont); while (n < size) { diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index a252c6deb6..853f0bcc21 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -1054,9 +1054,7 @@ static int32_t tsdbMergeSkyline(SArray *pSkyline1, SArray *pSkyline2, SArray *pS i2++; } - taosArraySetSize(pSkyline, TARRAY_ELEM_IDX(pSkyline, pItem)); - -_exit: + pSkyline->size = TARRAY_ELEM_IDX(pSkyline, pItem); return code; } diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index b94d44eb7d..cefa9e6755 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -21,12 +21,34 @@ static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData); static int vnodeCommitImpl(SCommitInfo *pInfo); +#define WAIT_TIME_MILI_SEC 50 + int vnodeBegin(SVnode *pVnode) { // alloc buffer pool + int32_t nTry = 0; + taosThreadMutexLock(&pVnode->mutex); while (pVnode->pPool == NULL) { - taosThreadCondWait(&pVnode->poolNotEmpty, &pVnode->mutex); + vInfo("vgId:%d no free buffer pool on %d try, wait %d ms...", TD_VID(pVnode), ++nTry, WAIT_TIME_MILI_SEC); + + struct timeval tv; + struct timespec ts; + taosGetTimeOfDay(&tv); + ts.tv_nsec = tv.tv_usec * 1000 + WAIT_TIME_MILI_SEC * 1000000; + if (ts.tv_nsec > 999999999l) { + ts.tv_sec = tv.tv_sec + 1; + ts.tv_nsec -= 1000000000l; + } else { + ts.tv_sec = tv.tv_sec; + } + + int32_t rc = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts); + if (rc && rc != ETIMEDOUT) { + terrno = TAOS_SYSTEM_ERROR(rc); + taosThreadMutexUnlock(&pVnode->mutex); + return -1; + } } pVnode->inUse = pVnode->pPool; @@ -70,7 +92,7 @@ int vnodeShouldCommit(SVnode *pVnode) { } SVCommitSched *pSched = &pVnode->commitSched; - int64_t nowMs = taosGetMonoTimestampMs(); + int64_t nowMs = taosGetMonoTimestampMs(); return (((pVnode->inUse->size > pVnode->inUse->node.size) && (pSched->commitMs + SYNC_VND_COMMIT_MIN_MS < nowMs)) || (pVnode->inUse->size > 0 && pSched->commitMs + pSched->maxWaitMs < nowMs)); diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 58d9f1a049..97ee2e4a89 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -239,7 +239,7 @@ _err: if (pVnode->pWal) walClose(pVnode->pWal); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); if (pVnode->pSma) smaClose(pVnode->pSma); - if (pVnode->pMeta) metaClose(pVnode->pMeta); + if (pVnode->pMeta) metaClose(&pVnode->pMeta); if (pVnode->pPool) vnodeCloseBufPool(pVnode); tsem_destroy(&(pVnode->canCommit)); @@ -263,7 +263,7 @@ void vnodeClose(SVnode *pVnode) { tqClose(pVnode->pTq); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); smaClose(pVnode->pSma); - metaClose(pVnode->pMeta); + if (pVnode->pMeta) metaClose(&pVnode->pMeta); vnodeCloseBufPool(pVnode); tsem_post(&pVnode->canCommit); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 5ee0e821b1..67990bc8c9 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -312,10 +312,13 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp walApplyVer(pVnode->pWal, version); + /*vInfo("vgId:%d, push msg begin", pVnode->config.vgId);*/ if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, version) < 0) { + /*vInfo("vgId:%d, push msg end", pVnode->config.vgId);*/ vError("vgId:%d, failed to push msg to TQ since %s", TD_VID(pVnode), tstrerror(terrno)); return -1; } + /*vInfo("vgId:%d, push msg end", pVnode->config.vgId);*/ // commit if need if (needCommit) { @@ -1019,7 +1022,7 @@ _exit: atomic_add_fetch_64(&pVnode->statis.nBatchInsert, statis.nBatchInsert); atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, statis.nBatchInsertSuccess); - vDebug("vgId:%d, submit success, index:%" PRId64, pVnode->config.vgId, version); + vDebug("vgId:%d %s done, index:%" PRId64, TD_VID(pVnode), __func__, version); return 0; } diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index be101059f2..43eaacfff9 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -283,7 +283,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { metaRemoveSmaFromDb(pMeta, indexUid2); tDestroyTSma(&tSma); - metaClose(pMeta); + metaClose(&pMeta); } #endif @@ -577,9 +577,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { tDestroyTSma(&tSma); tfsClose(pTsdb->pTfs); tsdbClose(pTsdb); - metaClose(pMeta); + metaClose(&pMeta); } #endif -#pragma GCC diagnostic pop \ No newline at end of file +#pragma GCC diagnostic pop diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 30593fbaab..41c7eca7f0 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -300,7 +300,7 @@ typedef struct SCtgSubRes { ctgSubTaskCbFp fp; } SCtgSubRes; -typedef struct SCtgTask { +struct SCtgTask { CTG_TASK_TYPE type; int32_t taskId; SCtgJob* pJob; @@ -313,7 +313,7 @@ typedef struct SCtgTask { SRWLatch lock; SArray* pParents; SCtgSubRes subRes; -} SCtgTask; +}; typedef struct SCtgTaskReq { SCtgTask* pTask; diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 325d6e0e46..89e92b0cc8 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -1707,9 +1707,7 @@ int32_t ctgLaunchGetTbMetasTask(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } - pTask->msgCtxs = taosArrayInit(pCtx->fetchNum, sizeof(SCtgMsgCtx)); - taosArraySetSize(pTask->msgCtxs, pCtx->fetchNum); - + pTask->msgCtxs = taosArrayInit_s(pCtx->fetchNum, sizeof(SCtgMsgCtx), pCtx->fetchNum); for (int32_t i = 0; i < pCtx->fetchNum; ++i) { SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i); SName* pName = ctgGetFetchName(pCtx->pNames, pFetch); @@ -1844,7 +1842,10 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask* pTask) { ctgAddFetch(&pCtx->pFetchs, i, -1, &fetchIdx, baseResIdx, 0); baseResIdx += taosArrayGetSize(pReq->pTables); - taosArraySetSize(pCtx->pResList, baseResIdx); + int32_t inc = baseResIdx - taosArrayGetSize(pCtx->pResList); + for(int32_t j = 0; j < inc; ++j) { + taosArrayPush(pCtx->pResList, &(SMetaRes){0}); + } } } @@ -1856,8 +1857,7 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } - pTask->msgCtxs = taosArrayInit(pCtx->fetchNum, sizeof(SCtgMsgCtx)); - taosArraySetSize(pTask->msgCtxs, pCtx->fetchNum); + pTask->msgCtxs = taosArrayInit_s(pCtx->fetchNum, sizeof(SCtgMsgCtx), pCtx->fetchNum); for (int32_t i = 0; i < pCtx->fetchNum; ++i) { SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i); diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 6e4077eae0..06db2c3268 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -2480,20 +2480,20 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe ctgDebug("db %s not in cache", dbFName); for (int32_t i = 0; i < tbNum; ++i) { ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); - taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); + taosArrayPush(ctx->pResList, &(SMetaData){0}); } return TSDB_CODE_SUCCESS; } for (int32_t i = 0; i < tbNum; ++i) { - SName *pName = taosArrayGet(pList, i); + pName = taosArrayGet(pList, i); pCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname)); if (NULL == pCache) { ctgDebug("tb %s not in cache, dbFName:%s", pName->tname, dbFName); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); - taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); continue; } @@ -2503,7 +2503,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe CTG_UNLOCK(CTG_READ, &pCache->metaLock); ctgDebug("tb %s meta not in cache, dbFName:%s", pName->tname, dbFName); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); - taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); continue; } @@ -2576,7 +2576,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe if (NULL == stName) { ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", pTableMeta->suid, dbFName); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); - taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); taosMemoryFreeClear(pTableMeta); continue; @@ -2588,7 +2588,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe taosHashRelease(dbCache->stbCache, stName); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); - taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); taosMemoryFreeClear(pTableMeta); continue; @@ -2603,7 +2603,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe taosHashRelease(dbCache->tbCache, pCache); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); - taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); taosMemoryFreeClear(pTableMeta); @@ -2619,7 +2619,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe nctx.tbInfo.suid); ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag); - taosArraySetSize(ctx->pResList, taosArrayGetSize(ctx->pResList) + 1); + taosArrayPush(ctx->pResList, &(SMetaRes){0}); taosMemoryFreeClear(pTableMeta); diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index e0d2276e6f..f99c7de93d 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -44,6 +44,8 @@ typedef struct SGroupResInfo { int32_t index; SArray* pRows; // SArray + char* pBuf; + bool freeItem; } SGroupResInfo; typedef struct SResultRow { @@ -115,10 +117,6 @@ struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t i static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos, bool forUpdate) { SFilePage* bufPage = (SFilePage*)getBufPage(pBuf, pos->pageId); - if (NULL == bufPage) { - return NULL; - } - if (forUpdate) { setBufPageDirty(bufPage, true); } diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 7ee186511a..60e4e85fb8 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -149,6 +149,10 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { // check if it is a group by tbname if ((pInfo->retrieveType & CACHESCAN_RETRIEVE_TYPE_ALL) == CACHESCAN_RETRIEVE_TYPE_ALL) { + if (isTaskKilled(pTaskInfo)) { + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + } + if (pInfo->indexOfBufferedRes >= pInfo->pBufferredRes->info.rows) { blockDataCleanup(pInfo->pBufferredRes); taosArrayClear(pInfo->pUidList); @@ -207,6 +211,10 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { size_t totalGroups = tableListGetOutputGroups(pTableList); while (pInfo->currentGroupIndex < totalGroups) { + if (isTaskKilled(pTaskInfo)) { + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + } + STableKeyInfo* pList = NULL; int32_t num = 0; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 3c4cafb753..a98accba77 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -43,11 +43,12 @@ typedef struct tagFilterAssist { SArray* cInfoList; } tagFilterAssist; -static int32_t removeInvalidTable(SArray* uids, SHashObj* tags); -static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond, SHashObj* tags); -static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond); +static int32_t removeInvalidUid(SArray* uids, SHashObj* tags); +static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* pRes, SNode* pTagCond); +static int32_t optimizeTbnameInCondImpl(void* metaHandle, SArray* pExistedUidList, SNode* pTagCond); static int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, - SNode* pTagIndexCond, STableListInfo* pListInfo); + SNode* pTagIndexCond, STableListInfo* pListInfo, const char* idstr); +static SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTables, SArray* pUidTagList, void* metaHandle); static int64_t getLimit(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; } static int64_t getOffset(const SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; } @@ -88,15 +89,20 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) { return rowSize; } +static void freeEx(void* p) { + taosMemoryFree(*(void**)p); +} + void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) { - assert(pGroupResInfo != NULL); - - for (int32_t i = 0; i < taosArrayGetSize(pGroupResInfo->pRows); ++i) { - SResKeyPos* pRes = taosArrayGetP(pGroupResInfo->pRows, i); - taosMemoryFree(pRes); + taosMemoryFreeClear(pGroupResInfo->pBuf); + if (pGroupResInfo->freeItem) { +// taosArrayDestroy(pGroupResInfo->pRows); + taosArrayDestroyEx(pGroupResInfo->pRows, freeEx); + pGroupResInfo->freeItem = false; + pGroupResInfo->pRows = NULL; + } else { + pGroupResInfo->pRows = taosArrayDestroy(pGroupResInfo->pRows); } - - pGroupResInfo->pRows = taosArrayDestroy(pGroupResInfo->pRows); pGroupResInfo->index = 0; } @@ -126,26 +132,40 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in } // extract the result rows information from the hash map - void* pData = NULL; - pGroupResInfo->pRows = taosArrayInit(10, POINTER_BYTES); + int32_t size = tSimpleHashGetSize(pHashmap); + + void* pData = NULL; + pGroupResInfo->pRows = taosArrayInit(size, POINTER_BYTES); - // todo avoid repeated malloc memory size_t keyLen = 0; int32_t iter = 0; + int32_t bufLen = 0, offset = 0; + + // todo move away and record this during create window + while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) { + /*void* key = */tSimpleHashGetKey(pData, &keyLen); + bufLen += keyLen + sizeof(SResultRowPosition); + } + + pGroupResInfo->pBuf = taosMemoryMalloc(bufLen); + + iter = 0; while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) { void* key = tSimpleHashGetKey(pData, &keyLen); - SResKeyPos* p = taosMemoryMalloc(keyLen + sizeof(SResultRowPosition)); + SResKeyPos* p = (SResKeyPos*) (pGroupResInfo->pBuf + offset); p->groupId = *(uint64_t*)key; p->pos = *(SResultRowPosition*)pData; memcpy(p->key, (char*)key + sizeof(uint64_t), keyLen - sizeof(uint64_t)); taosArrayPush(pGroupResInfo->pRows, &p); + + offset += keyLen + sizeof(struct SResultRowPosition); } if (order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC) { __compar_fn_t fn = (order == TSDB_ORDER_ASC) ? resultrowComparAsc : resultrowComparDesc; - int32_t size = POINTER_BYTES; + size = POINTER_BYTES; taosSort(pGroupResInfo->pRows->pData, taosArrayGetSize(pGroupResInfo->pRows), size, fn); } @@ -158,6 +178,7 @@ void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayL taosArrayDestroyP(pGroupResInfo->pRows, taosMemoryFree); } + pGroupResInfo->freeItem = true; pGroupResInfo->pRows = pArrayList; pGroupResInfo->index = 0; ASSERT(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo)); @@ -172,7 +193,6 @@ bool hasRemainResults(SGroupResInfo* pGroupResInfo) { } int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) { - assert(pGroupResInfo != NULL); if (pGroupResInfo->pRows == 0) { return 0; } @@ -392,150 +412,6 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara return TSDB_CODE_SUCCESS; } -static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray* uidList, SNode* pTagCond) { - int32_t code = TSDB_CODE_SUCCESS; - SArray* pBlockList = NULL; - SSDataBlock* pResBlock = NULL; - SHashObj* tags = NULL; - SScalarParam output = {0}; - - tagFilterAssist ctx = {0}; - - ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); - if (ctx.colHash == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - - ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo)); - if (ctx.cInfoList == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - - nodesRewriteExprPostOrder(&pTagCond, getColumn, (void*)&ctx); - - pResBlock = createDataBlock(); - if (pResBlock == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - - for (int32_t i = 0; i < taosArrayGetSize(ctx.cInfoList); ++i) { - SColumnInfoData colInfo = {0}; - colInfo.info = *(SColumnInfo*)taosArrayGet(ctx.cInfoList, i); - blockDataAppendColInfo(pResBlock, &colInfo); - } - - // int64_t stt = taosGetTimestampUs(); - tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); - - int32_t filter = optimizeTbnameInCond(metaHandle, suid, uidList, pTagCond, tags); - if (filter == -1) { - code = metaGetTableTags(metaHandle, suid, uidList, tags); - if (code != TSDB_CODE_SUCCESS) { - qError("failed to get table tags from meta, reason:%s, suid:%" PRIu64, tstrerror(code), suid); - terrno = code; - goto end; - } - } - if (suid != 0) { - removeInvalidTable(uidList, tags); - } - - int32_t rows = taosArrayGetSize(uidList); - if (rows == 0) { - goto end; - } - - code = blockDataEnsureCapacity(pResBlock, rows); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - goto end; - } - - for (int32_t i = 0; i < rows; i++) { - int64_t* uid = taosArrayGet(uidList, i); - for (int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++) { - SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j); - - if (pColInfo->info.colId == -1) { // tbname - char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; - metaGetTableNameByUid(metaHandle, *uid, str); - colDataAppend(pColInfo, i, str, false); -#if TAG_FILTER_DEBUG - qDebug("tagfilter uid:%ld, tbname:%s", *uid, str + 2); -#endif - } else { - void* tag = taosHashGet(tags, uid, sizeof(int64_t)); - if (tag == NULL) { - continue; - } - STagVal tagVal = {0}; - tagVal.cid = pColInfo->info.colId; - const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal); - - if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)) { - colDataAppend(pColInfo, i, p, true); - } else if (pColInfo->info.type == TSDB_DATA_TYPE_JSON) { - colDataAppend(pColInfo, i, p, false); - } else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) { - char* tmp = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1); - varDataSetLen(tmp, tagVal.nData); - memcpy(tmp + VARSTR_HEADER_SIZE, tagVal.pData, tagVal.nData); - colDataAppend(pColInfo, i, tmp, false); -#if TAG_FILTER_DEBUG - qDebug("tagfilter varch:%s", tmp + 2); -#endif - taosMemoryFree(tmp); - } else { - colDataAppend(pColInfo, i, (const char*)&tagVal.i64, false); -#if TAG_FILTER_DEBUG - if (pColInfo->info.type == TSDB_DATA_TYPE_INT) { - qDebug("tagfilter int:%d", *(int*)(&tagVal.i64)); - } else if (pColInfo->info.type == TSDB_DATA_TYPE_DOUBLE) { - qDebug("tagfilter double:%f", *(double*)(&tagVal.i64)); - } -#endif - } - } - } - } - - pResBlock->info.rows = rows; - - // int64_t st1 = taosGetTimestampUs(); - // qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st); - - pBlockList = taosArrayInit(2, POINTER_BYTES); - taosArrayPush(pBlockList, &pResBlock); - - SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; - code = createResultData(&type, rows, &output); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - qError("failed to create result, reason:%s", tstrerror(code)); - goto end; - } - - code = scalarCalculate(pTagCond, pBlockList, &output); - if (code != TSDB_CODE_SUCCESS) { - qError("failed to calculate scalar, reason:%s", tstrerror(code)); - terrno = code; - goto end; - } - // int64_t st2 = taosGetTimestampUs(); - // qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1); - -end: - taosHashCleanup(tags); - taosHashCleanup(ctx.colHash); - taosArrayDestroy(ctx.cInfoList); - blockDataDestroy(pResBlock); - taosArrayDestroy(pBlockList); - return output.columnData; -} - static void releaseColInfoData(void* pCol) { if (pCol) { SColumnInfoData* col = (SColumnInfoData*)pCol; @@ -544,12 +420,17 @@ static void releaseColInfoData(void* pCol) { } } +void freeItem(void* p) { + STUidTagInfo *pInfo = p; + if (pInfo->pTagVal != NULL) { + taosMemoryFree(pInfo->pTagVal); + } +} + int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableListInfo* pTableListInfo) { int32_t code = TSDB_CODE_SUCCESS; SArray* pBlockList = NULL; SSDataBlock* pResBlock = NULL; - SHashObj* tags = NULL; - SArray* uidList = NULL; void* keyBuf = NULL; SArray* groupData = NULL; @@ -578,89 +459,26 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis REPLACE_NODE(pNode); } - pResBlock = createDataBlock(); - if (pResBlock == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - - for (int32_t i = 0; i < taosArrayGetSize(ctx.cInfoList); ++i) { - SColumnInfoData colInfo = {0}; - colInfo.info = *(SColumnInfo*)taosArrayGet(ctx.cInfoList, i); - blockDataAppendColInfo(pResBlock, &colInfo); - } - - uidList = taosArrayInit(rows, sizeof(uint64_t)); + SArray* pUidTagList = taosArrayInit(8, sizeof(STUidTagInfo)); for (int32_t i = 0; i < rows; ++i) { STableKeyInfo* pkeyInfo = taosArrayGet(pTableListInfo->pTableList, i); - taosArrayPush(uidList, &pkeyInfo->uid); + STUidTagInfo info = {.uid = pkeyInfo->uid}; + taosArrayPush(pUidTagList, &info); } // int64_t stt = taosGetTimestampUs(); - tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); - code = metaGetTableTags(metaHandle, pTableListInfo->suid, uidList, tags); + code = metaGetTableTags(metaHandle, pTableListInfo->suid, pUidTagList); if (code != TSDB_CODE_SUCCESS) { goto end; } - // int64_t stt1 = taosGetTimestampUs(); - // qDebug("generate tag meta rows:%d, cost:%ld us", rows, stt1-stt); - - code = blockDataEnsureCapacity(pResBlock, rows); - if (code != TSDB_CODE_SUCCESS) { + int32_t numOfTables = taosArrayGetSize(pUidTagList); + pResBlock = createTagValBlockForFilter(ctx.cInfoList, numOfTables, pUidTagList, metaHandle); + if (pResBlock == NULL) { + code = terrno; goto end; } - // int64_t st = taosGetTimestampUs(); - for (int32_t i = 0; i < rows; i++) { - int64_t* uid = taosArrayGet(uidList, i); - for (int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++) { - SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j); - - if (pColInfo->info.colId == -1) { // tbname - char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; - metaGetTableNameByUid(metaHandle, *uid, str); - colDataAppend(pColInfo, i, str, false); -#if TAG_FILTER_DEBUG - qDebug("tagfilter uid:%ld, tbname:%s", *uid, str + 2); -#endif - } else { - void* tag = taosHashGet(tags, uid, sizeof(int64_t)); - ASSERT(tag); - - STagVal tagVal = {0}; - tagVal.cid = pColInfo->info.colId; - const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal); - - if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)) { - colDataAppend(pColInfo, i, p, true); - } else if (pColInfo->info.type == TSDB_DATA_TYPE_JSON) { - colDataAppend(pColInfo, i, p, false); - } else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) { - char* tmp = taosMemoryCalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1, 1); - varDataSetLen(tmp, tagVal.nData); - memcpy(tmp + VARSTR_HEADER_SIZE, tagVal.pData, tagVal.nData); - colDataAppend(pColInfo, i, tmp, false); -#if TAG_FILTER_DEBUG - qDebug("tagfilter varch:%s", tmp + 2); -#endif - taosMemoryFree(tmp); - } else { - colDataAppend(pColInfo, i, (const char*)&tagVal.i64, false); -#if TAG_FILTER_DEBUG - if (pColInfo->info.type == TSDB_DATA_TYPE_INT) { - qDebug("tagfilter int:%d", *(int*)(&tagVal.i64)); - } else if (pColInfo->info.type == TSDB_DATA_TYPE_DOUBLE) { - qDebug("tagfilter double:%f", *(double*)(&tagVal.i64)); - } -#endif - } - } - } - } - - pResBlock->info.rows = rows; - // int64_t st1 = taosGetTimestampUs(); // qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st); @@ -768,12 +586,11 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis end: taosMemoryFreeClear(keyBuf); - taosHashCleanup(tags); taosHashCleanup(ctx.colHash); taosArrayDestroy(ctx.cInfoList); blockDataDestroy(pResBlock); taosArrayDestroy(pBlockList); - taosArrayDestroy(uidList); + taosArrayDestroyEx(pUidTagList, freeItem); taosArrayDestroyP(groupData, releaseColInfoData); return code; } @@ -842,17 +659,26 @@ static int tableUidCompare(const void* a, const void* b) { return u1 < u2 ? -1 : 1; } -static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* cond, SHashObj* tags) { - int32_t ret = -1; - if (nodeType(cond) == QUERY_NODE_OPERATOR) { - ret = optimizeTbnameInCondImpl(metaHandle, suid, list, cond); - if (ret != -1) { - metaGetTableTagsByUids(metaHandle, suid, list, tags); - removeInvalidTable(list, tags); - } +static int32_t filterTableInfoCompare(const void* a, const void* b) { + STUidTagInfo* p1 = (STUidTagInfo*) a; + STUidTagInfo* p2 = (STUidTagInfo*) b; + + if (p1->uid == p2->uid) { + return 0; } - if (nodeType(cond) != QUERY_NODE_LOGIC_CONDITION || ((SLogicConditionNode*)cond)->condType != LOGIC_COND_TYPE_AND) { + return p1->uid < p2->uid? -1:1; +} + +static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* pRes, SNode* cond) { + int32_t ret = -1; + int32_t ntype = nodeType(cond); + + if (ntype == QUERY_NODE_OPERATOR) { + ret = optimizeTbnameInCondImpl(metaHandle, pRes, cond); + } + + if (ntype != QUERY_NODE_LOGIC_CONDITION || ((SLogicConditionNode*)cond)->condType != LOGIC_COND_TYPE_AND) { return ret; } @@ -868,36 +694,40 @@ static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list SListCell* cell = pList->pHead; for (int i = 0; i < len; i++) { if (cell == NULL) break; - if (optimizeTbnameInCondImpl(metaHandle, suid, list, cell->pNode) == 0) { + if (optimizeTbnameInCondImpl(metaHandle, pRes, cell->pNode) == 0) { hasTbnameCond = true; break; } cell = cell->pNext; } - taosArraySort(list, tableUidCompare); - taosArrayRemoveDuplicate(list, tableUidCompare, NULL); + taosArraySort(pRes, filterTableInfoCompare); + taosArrayRemoveDuplicate(pRes, filterTableInfoCompare, NULL); if (hasTbnameCond) { - ret = metaGetTableTagsByUids(metaHandle, suid, list, tags); - removeInvalidTable(list, tags); + ret = metaGetTableTagsByUids(metaHandle, suid, pRes); +// removeInvalidUid(pRes, tags); } return ret; } +#if 0 /* * handle invalid uid */ -static int32_t removeInvalidTable(SArray* uids, SHashObj* tags) { - if (taosArrayGetSize(uids) <= 0) return 0; +static int32_t removeInvalidUid(SArray* uids, SHashObj* tags) { + int32_t size = taosArrayGetSize(uids); + if (size <= 0) { + return 0; + } - SArray* validUid = taosArrayInit(taosArrayGetSize(uids), sizeof(int64_t)); + SArray* validUid = taosArrayInit(size, sizeof(STUidTagInfo)); - for (int32_t i = 0; i < taosArrayGetSize(uids); i++) { - int64_t* uid = taosArrayGet(uids, i); - if (taosHashGet(tags, uid, sizeof(int64_t)) != NULL) { - taosArrayPush(validUid, uid); + for (int32_t i = 0; i < size; i++) { + STUidTagInfo* p = taosArrayGet(uids, i); + if (taosHashGet(tags, &p->uid, sizeof(int64_t)) != NULL) { + taosArrayPush(validUid, p); } } @@ -906,7 +736,10 @@ static int32_t removeInvalidTable(SArray* uids, SHashObj* tags) { return 0; } -static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond) { +#endif + +// only return uid that does not contained in pExistedUidList +static int32_t optimizeTbnameInCondImpl(void* metaHandle, SArray* pExistedUidList, SNode* pTagCond) { if (nodeType(pTagCond) != QUERY_NODE_OPERATOR) { return -1; } @@ -929,12 +762,13 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* SArray* pTbList = getTableNameList(pList); int32_t numOfTables = taosArrayGetSize(pTbList); SHashObj* uHash = NULL; - size_t listlen = taosArrayGetSize(list); // len > 0 means there already have uids - if (listlen > 0) { - uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); - for (int i = 0; i < listlen; i++) { - int64_t* uid = taosArrayGet(list, i); - taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i)); + + size_t numOfExisted = taosArrayGetSize(pExistedUidList); // len > 0 means there already have uids + if (numOfExisted > 0) { + uHash = taosHashInit(numOfExisted / 0.7, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); + for (int i = 0; i < numOfExisted; i++) { + STUidTagInfo* pTInfo = taosArrayGet(pExistedUidList, i); + taosHashPut(uHash, &pTInfo->uid, sizeof(uint64_t), &i, sizeof(i)); } } @@ -946,7 +780,8 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* ETableType tbType = TSDB_TABLE_MAX; if (metaGetTableTypeByName(metaHandle, name, &tbType) == 0 && tbType == TSDB_CHILD_TABLE) { if (NULL == uHash || taosHashGet(uHash, &uid, sizeof(uid)) == NULL) { - taosArrayPush(list, &uid); + STUidTagInfo s = {.uid = uid, .name = name, .pTagVal = NULL}; + taosArrayPush(pExistedUidList, &s); } } else { taosArrayDestroy(pTbList); @@ -983,129 +818,299 @@ static void genTagFilterDigest(const SNode* pTagCond, T_MD5_CTX* pContext) { taosMemoryFree(payload); } -static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* res, SNode* pTagCond, void* metaHandle) { +static SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTables, SArray* pUidTagList, void* metaHandle) { + SSDataBlock* pResBlock = createDataBlock(); + if (pResBlock == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + for (int32_t i = 0; i < taosArrayGetSize(pColList); ++i) { + SColumnInfoData colInfo = {0}; + colInfo.info = *(SColumnInfo*)taosArrayGet(pColList, i); + blockDataAppendColInfo(pResBlock, &colInfo); + } + + int32_t code = blockDataEnsureCapacity(pResBlock, numOfTables); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return NULL; + } + + pResBlock->info.rows = numOfTables; + + int32_t numOfCols = taosArrayGetSize(pResBlock->pDataBlock); + + for (int32_t i = 0; i < numOfTables; i++) { + STUidTagInfo* p1 = taosArrayGet(pUidTagList, i); + + for (int32_t j = 0; j < numOfCols; j++) { + SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, j); + + if (pColInfo->info.colId == -1) { // tbname + char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; + if (p1->name != NULL) { + STR_TO_VARSTR(str, p1->name); + } else { // name is not retrieved during filter + metaGetTableNameByUid(metaHandle, p1->uid, str); + } + + colDataAppend(pColInfo, i, str, false); +#if TAG_FILTER_DEBUG + qDebug("tagfilter uid:%ld, tbname:%s", *uid, str + 2); +#endif + } else { + STagVal tagVal = {0}; + tagVal.cid = pColInfo->info.colId; + if (p1->pTagVal == NULL) { + colDataAppendNULL(pColInfo, i); + } + + const char* p = metaGetTableTagVal(p1->pTagVal, pColInfo->info.type, &tagVal); + + if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)) { + colDataAppendNULL(pColInfo, i); + } else if (pColInfo->info.type == TSDB_DATA_TYPE_JSON) { + colDataAppend(pColInfo, i, p, false); + } else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) { + char* tmp = alloca(tagVal.nData + VARSTR_HEADER_SIZE + 1); + varDataSetLen(tmp, tagVal.nData); + memcpy(tmp + VARSTR_HEADER_SIZE, tagVal.pData, tagVal.nData); + colDataAppend(pColInfo, i, tmp, false); +#if TAG_FILTER_DEBUG + qDebug("tagfilter varch:%s", tmp + 2); +#endif + } else { + colDataAppend(pColInfo, i, (const char*)&tagVal.i64, false); +#if TAG_FILTER_DEBUG + if (pColInfo->info.type == TSDB_DATA_TYPE_INT) { + qDebug("tagfilter int:%d", *(int*)(&tagVal.i64)); + } else if (pColInfo->info.type == TSDB_DATA_TYPE_DOUBLE) { + qDebug("tagfilter double:%f", *(double*)(&tagVal.i64)); + } +#endif + } + } + } + } + + return pResBlock; +} + +static void doSetQualifiedUid(SArray* pUidList, const SArray* pUidTagList, bool* pResultList) { + taosArrayClear(pUidList); + + int32_t numOfTables = taosArrayGetSize(pUidTagList); + for(int32_t i = 0; i < numOfTables; ++i) { + uint64_t uid = ((STUidTagInfo*)taosArrayGet(pUidTagList, i))->uid; + qDebug("tagfilter get uid:%" PRId64 ", res:%d", uid, pResultList[i]); + + if (pResultList[i]) { + taosArrayPush(pUidList, &uid); + } + } +} + +static void copyExistedUids(SArray* pUidTagList, const SArray* pUidList) { + int32_t numOfExisted = taosArrayGetSize(pUidList); + if (numOfExisted == 0) { + return; + } + + for(int32_t i = 0; i < numOfExisted; ++i) { + uint64_t* uid = taosArrayGet(pUidList, i); + STUidTagInfo info = {.uid = *uid}; + taosArrayPush(pUidTagList, &info); + } +} + +static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SNode* pTagCond, void* metaHandle) { if (pTagCond == NULL) { return TSDB_CODE_SUCCESS; } terrno = TDB_CODE_SUCCESS; - SColumnInfoData* pColInfoData = getColInfoResult(metaHandle, pListInfo->suid, res, pTagCond); - if (terrno != TDB_CODE_SUCCESS) { - colDataDestroy(pColInfoData); - taosMemoryFreeClear(pColInfoData); - taosArrayDestroy(res); - qError("failed to getColInfoResult, code: %s", tstrerror(terrno)); - return terrno; + + int32_t code = TSDB_CODE_SUCCESS; + SArray* pBlockList = NULL; + SSDataBlock* pResBlock = NULL; + SScalarParam output = {0}; + + tagFilterAssist ctx = {0}; + ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); + if (ctx.colHash == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto end; } - int32_t i = 0; - int32_t len = taosArrayGetSize(res); + ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo)); + if (ctx.cInfoList == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } - if (pColInfoData != NULL) { - bool* pResult = (bool*)pColInfoData->pData; - SArray* p = taosArrayInit(taosArrayGetSize(res), sizeof(uint64_t)); + nodesRewriteExprPostOrder(&pTagCond, getColumn, (void*)&ctx); - while (i < len && pColInfoData) { - int64_t* uid = taosArrayGet(res, i); - qDebug("tagfilter get uid:%" PRId64 ", res:%d", *uid, pResult[i]); + SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; - if (pResult[i]) { - taosArrayPush(p, uid); - } - i += 1; + // int64_t stt = taosGetTimestampUs(); + SArray* pUidTagList = taosArrayInit(10, sizeof(STUidTagInfo)); + copyExistedUids(pUidTagList, pUidList); + + int32_t filter = optimizeTbnameInCond(metaHandle, pListInfo->suid, pUidTagList, pTagCond); + if (filter == 0) { // tbname in filter is activated, do nothing and return + taosArrayClear(pUidList); + + int32_t numOfRows = taosArrayGetSize(pUidTagList); + taosArrayEnsureCap(pUidList, numOfRows); + for(int32_t i = 0; i < numOfRows; ++i) { + STUidTagInfo* pInfo = taosArrayGet(pUidTagList, i); + taosArrayPush(pUidList, &pInfo->uid); } - taosArraySwap(res, p); - taosArrayDestroy(p); + terrno = 0; + goto end; + } else { + // here we retrieve all tags from the vnode table-meta store + code = metaGetTableTags(metaHandle, pListInfo->suid, pUidTagList); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get table tags from meta, reason:%s, suid:%" PRIu64, tstrerror(code), pListInfo->suid); + terrno = code; + goto end; + } } - colDataDestroy(pColInfoData); - taosMemoryFreeClear(pColInfoData); + int32_t numOfTables = taosArrayGetSize(pUidTagList); + if (numOfTables == 0) { + goto end; + } - return TSDB_CODE_SUCCESS; + pResBlock = createTagValBlockForFilter(ctx.cInfoList, numOfTables, pUidTagList, metaHandle); + if (pResBlock == NULL) { + code = terrno; + goto end; + } + + // int64_t st1 = taosGetTimestampUs(); + // qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st); + pBlockList = taosArrayInit(2, POINTER_BYTES); + taosArrayPush(pBlockList, &pResBlock); + + code = createResultData(&type, numOfTables, &output); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + goto end; + } + + code = scalarCalculate(pTagCond, pBlockList, &output); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to calculate scalar, reason:%s", tstrerror(code)); + terrno = code; + goto end; + } + + doSetQualifiedUid(pUidList, pUidTagList, (bool*) output.columnData->pData); + + end: + taosHashCleanup(ctx.colHash); + taosArrayDestroy(ctx.cInfoList); + blockDataDestroy(pResBlock); + taosArrayDestroy(pBlockList); + taosArrayDestroyEx(pUidTagList, freeItem); + + colDataDestroy(output.columnData); + taosMemoryFreeClear(output.columnData); + return code; } int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond, - STableListInfo* pListInfo) { + STableListInfo* pListInfo, const char* idstr) { int32_t code = TSDB_CODE_SUCCESS; size_t numOfTables = 0; - uint64_t tableUid = pScanNode->uid; pListInfo->suid = pScanNode->suid; - SArray* res = taosArrayInit(8, sizeof(uint64_t)); + SArray* pUidList = taosArrayInit(8, sizeof(uint64_t)); if (pScanNode->tableType != TSDB_SUPER_TABLE) { - if (metaIsTableExist(metaHandle, tableUid)) { - taosArrayPush(res, &tableUid); + if (metaIsTableExist(metaHandle, pScanNode->uid)) { + taosArrayPush(pUidList, &pScanNode->uid); } - code = doFilterByTagCond(pListInfo, res, pTagCond, metaHandle); + code = doFilterByTagCond(pListInfo, pUidList, pTagCond, metaHandle); if (code != TSDB_CODE_SUCCESS) { - return code; - } - } else { - // try to retrieve the result from meta cache - T_MD5_CTX context = {0}; - genTagFilterDigest(pTagCond, &context); - - bool acquired = false; - metaGetCachedTableUidList(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), res, &acquired); - if (acquired) { - qDebug("retrieve table uid list from cache, numOfTables:%d", (int32_t)taosArrayGetSize(res)); goto _end; } + } else { + T_MD5_CTX context = {0}; - if (!pTagCond) { // no tag condition exists, let's fetch all tables of this super table + if (tsTagFilterCache) { + // try to retrieve the result from meta cache + genTagFilterDigest(pTagCond, &context); + + bool acquired = false; + metaGetCachedTableUidList(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), pUidList, &acquired); + if (acquired) { + qDebug("retrieve table uid list from cache, numOfTables:%d", (int32_t)taosArrayGetSize(pUidList)); + goto _end; + } + } + + if (!pTagCond) { // no tag filter condition exists, let's fetch all tables of this super table ASSERT(pTagIndexCond == NULL); - vnodeGetCtbIdList(pVnode, pScanNode->suid, res); + vnodeGetCtbIdList(pVnode, pScanNode->suid, pUidList); } else { // failed to find the result in the cache, let try to calculate the results if (pTagIndexCond) { + void* pIndex = tsdbGetIvtIdx(metaHandle); SIndexMetaArg metaArg = { - .metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = tsdbGetIvtIdx(metaHandle), .suid = tableUid}; + .metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = pIndex, .suid = pScanNode->uid}; SIdxFltStatus status = SFLT_NOT_INDEX; - code = doFilterTag(pTagIndexCond, &metaArg, res, &status); - if (code != 0 || status == SFLT_NOT_INDEX) { - qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); + code = doFilterTag(pTagIndexCond, &metaArg, pUidList, &status); + if (code != 0 || status == SFLT_NOT_INDEX) { // temporarily disable it for performance sake +// qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); code = TDB_CODE_SUCCESS; } } } - code = doFilterByTagCond(pListInfo, res, pTagCond, metaHandle); + code = doFilterByTagCond(pListInfo, pUidList, pTagCond, metaHandle); if (code != TSDB_CODE_SUCCESS) { - return code; + goto _end; } // let's add the filter results into meta-cache - numOfTables = taosArrayGetSize(res); - size_t size = numOfTables * sizeof(uint64_t) + sizeof(int32_t); - char* pPayload = taosMemoryMalloc(size); - *(int32_t*)pPayload = numOfTables; + numOfTables = taosArrayGetSize(pUidList); - if (numOfTables > 0) { - memcpy(pPayload + sizeof(int32_t), taosArrayGet(res, 0), numOfTables * sizeof(uint64_t)); + if (tsTagFilterCache) { + size_t size = numOfTables * sizeof(uint64_t) + sizeof(int32_t); + char* pPayload = taosMemoryMalloc(size); + + if (numOfTables > 0) { + *(int32_t*)pPayload = numOfTables; + memcpy(pPayload + sizeof(int32_t), taosArrayGet(pUidList, 0), numOfTables * sizeof(uint64_t)); + } + + metaUidFilterCachePut(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), pPayload, size, 1); + taosMemoryFree(pPayload); } - - metaUidFilterCachePut(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), pPayload, size, 1); } _end: - numOfTables = taosArrayGetSize(res); + numOfTables = taosArrayGetSize(pUidList); for (int i = 0; i < numOfTables; i++) { - STableKeyInfo info = {.uid = *(uint64_t*)taosArrayGet(res, i), .groupId = 0}; + STableKeyInfo info = {.uid = *(uint64_t*)taosArrayGet(pUidList, i), .groupId = 0}; void* p = taosArrayPush(pListInfo->pTableList, &info); if (p == NULL) { - taosArrayDestroy(res); + taosArrayDestroy(pUidList); return TSDB_CODE_OUT_OF_MEMORY; } - qTrace("tagfilter get uid:%" PRIu64 "", info.uid); + qTrace("tagfilter get uid:%" PRIu64", %s", info.uid, idstr); } - taosArrayDestroy(res); + taosArrayDestroy(pUidList); return code; } @@ -1506,6 +1511,8 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, if (pExpr->pExpr->nodeType == QUERY_NODE_FUNCTION) { SFuncExecEnv env = {0}; pCtx->functionId = pExpr->pExpr->_function.pFunctNode->funcId; + pCtx->isPseudoFunc = fmIsWindowPseudoColumnFunc(pCtx->functionId); + pCtx->isNotNullFunc = fmIsNotNullOutputFunc(pCtx->functionId); if (fmIsAggFunc(pCtx->functionId) || fmIsIndefiniteRowsFunc(pCtx->functionId)) { bool isUdaf = fmIsUserDefinedFunc(pCtx->functionId); @@ -1513,7 +1520,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet); } else { char* udfName = pExpr->pExpr->_function.pFunctNode->functionName; - tstrncpy(pCtx->udfName, udfName, TSDB_FUNC_NAME_LEN); + pCtx->udfName = strdup(udfName); fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet); } pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env); @@ -2002,7 +2009,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags return TSDB_CODE_INVALID_PARA; } - int32_t code = getTableList(pHandle->meta, pHandle->vnode, pScanNode, pTagCond, pTagIndexCond, pTableListInfo); + int32_t code = getTableList(pHandle->meta, pHandle->vnode, pScanNode, pTagCond, pTagIndexCond, pTableListInfo, idStr); if (code != TSDB_CODE_SUCCESS) { qError("failed to getTableList, code: %s", tstrerror(code)); return code; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 448e2b0a91..d28c3cfe58 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -176,10 +176,12 @@ SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, i // set the number of rows in current disk page SResultRow* pResultRow = (SResultRow*)((char*)pData + pData->num); + + memset((char*) pResultRow, 0, interBufSize); pResultRow->pageId = pageId; pResultRow->offset = (int32_t)pData->num; - *currentPageId = pageId; + *currentPageId = pageId; pData->num += interBufSize; return pResultRow; } @@ -363,7 +365,7 @@ void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pC pCtx[k].input.colDataSMAIsSet = false; } - if (fmIsWindowPseudoColumnFunc(pCtx[k].functionId)) { + if (pCtx[k].isPseudoFunc) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[k]); char* p = GET_ROWCELL_INTERBUF(pEntryInfo); @@ -817,7 +819,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO continue; } - if (fmIsWindowPseudoColumnFunc(pCtx[i].functionId)) { + if (pCtx[i].isPseudoFunc) { continue; } @@ -1063,7 +1065,7 @@ static void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t nu pRow->numOfRows = pResInfo->numOfRes; } - if (fmIsNotNullOutputFunc(pCtx[j].functionId)) { + if (pCtx[j].isNotNullFunc) { returnNotNull = true; } } @@ -1187,9 +1189,15 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS } if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) { - ASSERT(pBlock->info.rows > 0); releaseBufPage(pBuf, page); - break; + + if (pBlock->info.rows <= 0 || pRow->numOfRows > pBlock->info.capacity) { + qError("error in copy data to ssdatablock, existed rows in block:%d, rows in pRow:%d, capacity:%d, %s", + pBlock->info.rows, pRow->numOfRows, pBlock->info.capacity, GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR); + } else { + break; + } } pGroupResInfo->index += 1; @@ -1730,12 +1738,12 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, const char* pKey) { int32_t code = 0; - _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); +// _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pAggSup->currentPageId = -1; pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t)); - pAggSup->pResultRowHashTable = tSimpleHashInit(100, hashFn); + pAggSup->pResultRowHashTable = tSimpleHashInit(100, taosFastHash); if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -1820,6 +1828,10 @@ void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) { taosMemoryFreeClear(pCtx[i].subsidiaries.buf); taosMemoryFree(pCtx[i].input.pData); taosMemoryFree(pCtx[i].input.pColumnDataAgg); + + if (pCtx[i].udfName != NULL) { + taosMemoryFree(pCtx[i].udfName); + } } taosMemoryFreeClear(pCtx); @@ -1950,6 +1962,22 @@ void destroyAggOperatorInfo(void* param) { taosMemoryFreeClear(param); } +static char* buildTaskId(uint64_t taskId, uint64_t queryId) { + char* p = taosMemoryMalloc(64); + + int32_t offset = 6; + memcpy(p, "TID:0x", offset); + offset += tintToHex(taskId, &p[offset]); + + memcpy(&p[offset], " QID:0x", 7); + offset += 7; + offset += tintToHex(queryId, &p[offset]); + + p[offset] = 0; + + return p; +} + static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPTR_EXEC_MODEL model, char* dbFName) { SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo)); if (pTaskInfo == NULL) { @@ -1960,16 +1988,13 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); pTaskInfo->schemaInfo.dbname = strdup(dbFName); - pTaskInfo->id.queryId = queryId; pTaskInfo->execModel = model; pTaskInfo->pTableInfoList = tableListCreate(); pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo)); pTaskInfo->pResultBlockList = taosArrayInit(128, POINTER_BYTES); - char* p = taosMemoryCalloc(1, 128); - snprintf(p, 128, "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, queryId); - pTaskInfo->id.str = p; - + pTaskInfo->id.queryId = queryId; + pTaskInfo->id.str = buildTaskId(taskId, queryId); return pTaskInfo; } diff --git a/source/libs/executor/src/filloperator.c b/source/libs/executor/src/filloperator.c index 41e4c990f8..16983cb507 100644 --- a/source/libs/executor/src/filloperator.c +++ b/source/libs/executor/src/filloperator.c @@ -832,10 +832,13 @@ static bool checkResult(SStreamFillSupporter* pFillSup, TSKEY ts, uint64_t group return true; } -static void buildFillResult(SResultRowData* pResRow, SStreamFillSupporter* pFillSup, TSKEY ts, SSDataBlock* pBlock) { +static bool buildFillResult(SResultRowData* pResRow, SStreamFillSupporter* pFillSup, TSKEY ts, SSDataBlock* pBlock) { + if (pBlock->info.rows >= pBlock->info.capacity) { + return false; + } uint64_t groupId = pBlock->info.id.groupId; if (pFillSup->hasDelete && !checkResult(pFillSup, ts, groupId)) { - return; + return true; } for (int32_t i = 0; i < pFillSup->numOfAllCols; ++i) { SFillColInfo* pFillCol = pFillSup->pAllColInfo + i; @@ -853,6 +856,7 @@ static void buildFillResult(SResultRowData* pResRow, SStreamFillSupporter* pFill } } pBlock->info.rows++; + return true; } static bool hasRemainCalc(SStreamFillInfo* pFillInfo) { @@ -932,7 +936,9 @@ static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* } if (pFillInfo->pos == FILL_POS_START) { - buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { + pFillInfo->pos = FILL_POS_INVALID; + } } if (pFillInfo->type != TSDB_FILL_LINEAR) { doStreamFillNormal(pFillSup, pFillInfo, pRes); @@ -940,7 +946,9 @@ static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* doStreamFillLinear(pFillSup, pFillInfo, pRes); if (pFillInfo->pos == FILL_POS_MID) { - buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { + pFillInfo->pos = FILL_POS_INVALID; + } } if (pFillInfo->current > pFillInfo->end && pFillInfo->pLinearInfo->hasNext) { @@ -954,7 +962,9 @@ static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* } } if (pFillInfo->pos == FILL_POS_END) { - buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes); + if (buildFillResult(&pFillSup->cur, pFillSup, pFillSup->cur.key, pRes)) { + pFillInfo->pos = FILL_POS_INVALID; + } } } @@ -989,10 +999,6 @@ static void doStreamFillImpl(SOperatorInfo* pOperator) { uint64_t groupId = pBlock->info.id.groupId; SSDataBlock* pRes = pInfo->pRes; pRes->info.id.groupId = groupId; - if (hasRemainCalc(pFillInfo)) { - doStreamFillRange(pFillInfo, pFillSup, pRes); - } - SColumnInfoData* pTsCol = taosArrayGet(pInfo->pSrcBlock->pDataBlock, pInfo->primaryTsCol); TSKEY* tsCol = (TSKEY*)pTsCol->pData; @@ -1204,13 +1210,14 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) { return NULL; } blockDataCleanup(pInfo->pRes); - if (pOperator->status == OP_RES_TO_RETURN) { - if (hasRemainCalc(pInfo->pFillInfo)) { - doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); - if (pInfo->pRes->info.rows > 0) { - return pInfo->pRes; - } + if (hasRemainCalc(pInfo->pFillInfo) || (pInfo->pFillInfo->pos != FILL_POS_INVALID && pInfo->pFillInfo->needFill == true )) { + doStreamFillRange(pInfo->pFillInfo, pInfo->pFillSup, pInfo->pRes); + if (pInfo->pRes->info.rows > 0) { + printDataBlock(pInfo->pRes, "stream fill"); + return pInfo->pRes; } + } + if (pOperator->status == OP_RES_TO_RETURN) { doDeleteFillFinalize(pOperator); if (pInfo->pRes->info.rows > 0) { printDataBlock(pInfo->pRes, "stream fill"); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 29fe9817c9..b556733254 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1175,6 +1175,20 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32 } } +static int32_t getPreSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId, + SSessionKey* pKey) { + pKey->win.skey = startTs; + pKey->win.ekey = endTs; + pKey->groupId = groupId; + + SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev(pAggSup->pState, pKey); + int32_t code = streamStateSessionGetKVByCur(pCur, pKey, NULL, 0); + if (code != TSDB_CODE_SUCCESS) { + SET_SESSION_WIN_KEY_INVALID(pKey); + } + return code; +} + static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) { blockDataCleanup(pDestBlock); if (pSrcBlock->info.rows == 0) { @@ -1210,7 +1224,14 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr } SSessionKey endWin = {0}; getCurSessionWindow(pInfo->windowSup.pStreamAggSup, endData[i], endData[i], groupId, &endWin); - ASSERT(!IS_INVALID_SESSION_WIN_KEY(endWin)); + if(IS_INVALID_SESSION_WIN_KEY(endWin)) { + getPreSessionWindow(pInfo->windowSup.pStreamAggSup, endData[i], endData[i], groupId, &endWin); + } + if (IS_INVALID_SESSION_WIN_KEY(startWin)) { + // window has been closed. + qError("generate session scan range failed. rang start:%" PRIx64 ", end:%" PRIx64 , startData[i], endData[i]); + continue; + } colDataAppend(pDestStartCol, i, (const char*)&startWin.win.skey, false); colDataAppend(pDestEndCol, i, (const char*)&endWin.win.ekey, false); @@ -2276,13 +2297,14 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys if (pHandle->initTableReader) { pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER; pTSInfo->base.dataReader = NULL; - code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock, - &pTSInfo->base.dataReader, NULL); - if (code != 0) { - terrno = code; - destroyTableScanOperatorInfo(pTableScanOp); - goto _error; - } + pTaskInfo->streamInfo.lastStatus.uid = -1; +// code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock, +// &pTSInfo->base.dataReader, NULL); +// if (code != 0) { +// terrno = code; +// destroyTableScanOperatorInfo(pTableScanOp); +// goto _error; +// } } if (pHandle->initTqReader) { @@ -2752,6 +2774,10 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { SSDataBlock* pBlock = NULL; while (pInfo->tableStartIndex < tableListSize) { + if (isTaskKilled(pTaskInfo)) { + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + } + pBlock = getSortedTableMergeScanBlockData(pInfo->pSortHandle, pInfo->pResBlock, pOperator->resultInfo.capacity, pOperator); if (pBlock != NULL) { diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 3f9e61dbbb..88d9fb1a1f 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -2001,7 +2001,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi } pInfo->readHandle = *readHandle; - pInfo->uid = pBlockScanNode->suid; + pInfo->uid = (pBlockScanNode->suid != 0)? pBlockScanNode->suid:pBlockScanNode->uid; int32_t numOfCols = 0; SExprInfo* pExprInfo = createExprInfo(pBlockScanNode->pScanPseudoCols, NULL, &numOfCols); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 0dbed103c8..c5dc927bd1 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -119,8 +119,8 @@ static void doKeepNewWindowStartInfo(SWindowRowsSup* pRowSup, const int64_t* tsL pRowSup->groupId = groupId; } -FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, - int32_t pos, int32_t order, int64_t* pData) { +FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, int32_t pos, + int32_t order, int64_t* pData) { int32_t forwardRows = 0; if (order == TSDB_ORDER_ASC) { @@ -639,7 +639,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num if (NULL == pr) { T_LONG_JMP(pTaskInfo->env, terrno); } - + ASSERT(pr->offset == p1->offset && pr->pageId == p1->pageId); if (pr->closed) { @@ -847,6 +847,7 @@ static int32_t saveWinResult(int64_t ts, int32_t pageId, int32_t offset, uint64_ if (newPos == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } + newPos->groupId = groupId; newPos->pos = (SResultRowPosition){.pageId = pageId, .offset = offset}; *(int64_t*)newPos->key = ts; @@ -854,6 +855,7 @@ static int32_t saveWinResult(int64_t ts, int32_t pageId, int32_t offset, uint64_ if (taosHashPut(pUpdatedMap, &key, sizeof(SWinKey), &newPos, sizeof(void*)) != TSDB_CODE_SUCCESS) { taosMemoryFree(newPos); } + return TSDB_CODE_SUCCESS; } @@ -1318,11 +1320,11 @@ static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type } static void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprSupp* pSup, int32_t numOfOutput) { - SResultRow* pResult = getResultRowByPos(pResultBuf, p1, false); + SResultRow* pResult = getResultRowByPos(pResultBuf, p1, false); if (NULL == pResult) { return; } - + SqlFunctionCtx* pCtx = pSup->pCtx; for (int32_t i = 0; i < numOfOutput; ++i) { pCtx[i].resultInfo = getResultEntryInfo(pResult, i, pSup->rowEntryInfoOffset); @@ -2567,6 +2569,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK); while (1) { @@ -2877,6 +2880,8 @@ int32_t initBasicInfoEx(SOptrBasicInfo* pBasicInfo, SExprSupp* pSup, SExprInfo* void initDummyFunction(SqlFunctionCtx* pDummy, SqlFunctionCtx* pCtx, int32_t nums) { for (int i = 0; i < nums; i++) { pDummy[i].functionId = pCtx[i].functionId; + pDummy[i].isNotNullFunc = pCtx[i].isNotNullFunc; + pDummy[i].isPseudoFunc = pCtx[i].isPseudoFunc; } } @@ -3404,9 +3409,11 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) { } } +// the allocated memory comes from outer function. void initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList) { pGroupResInfo->pRows = pArrayList; pGroupResInfo->index = 0; + pGroupResInfo->pBuf = NULL; } void doBuildSessionResult(SOperatorInfo* pOperator, SStreamState* pState, SGroupResInfo* pGroupResInfo, @@ -3417,8 +3424,7 @@ void doBuildSessionResult(SOperatorInfo* pOperator, SStreamState* pState, SGroup blockDataCleanup(pBlock); if (!hasRemainResults(pGroupResInfo)) { - taosArrayDestroy(pGroupResInfo->pRows); - pGroupResInfo->pRows = NULL; + cleanupGroupResInfo(pGroupResInfo); return; } @@ -4753,6 +4759,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { SOperatorInfo* downstream = pOperator->pDownstream[0]; SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); // SResKeyPos + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK); @@ -4812,9 +4819,16 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { taosArraySort(pUpdated, resultrowComparAsc); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); + blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); taosHashCleanup(pUpdatedMap); +#if 0 + char* pBuf = streamStateIntervalDump(pInfo->pState); + qDebug("===stream===interval state%s", pBuf); + taosMemoryFree(pBuf); +#endif + doBuildDeleteResult(pInfo, pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); if (pInfo->pDelRes->info.rows > 0) { printDataBlock(pInfo->pDelRes, "single interval delete"); diff --git a/source/libs/executor/src/tlinearhash.c b/source/libs/executor/src/tlinearhash.c index d97f81c994..2cba3855c7 100644 --- a/source/libs/executor/src/tlinearhash.c +++ b/source/libs/executor/src/tlinearhash.c @@ -123,8 +123,6 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t } static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket* pBucket) { - ASSERT(pPage != NULL && pNode != NULL && pBucket->size >= 1); - int32_t len = GET_LHASH_NODE_LEN(pNode); char* p = (char*)pNode + len; @@ -301,8 +299,6 @@ void* tHashCleanup(SLHashObj* pHashObj) { } int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data, size_t size) { - ASSERT(pHashObj != NULL && key != NULL); - if (pHashObj->bits == 0) { SLHashBucket* pBucket = pHashObj->pBucket[0]; doAddToBucket(pHashObj, pBucket, 0, key, keyLen, data, size); @@ -363,14 +359,12 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data if (v1 != splitBucketId) { // place it into the new bucket ASSERT(v1 == newBucketId); // printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1); - SLHashBucket* pNewBucket = pHashObj->pBucket[newBucketId]; doAddToBucket(pHashObj, pNewBucket, newBucketId, (void*)GET_LHASH_NODE_KEY(pNode), pNode->keyLen, GET_LHASH_NODE_KEY(pNode), pNode->dataLen); doRemoveFromBucket(p, pNode, pBucket); } else { // printf("check key:%d, located into: %d, skip it\n", *(int*) k, v1); - int32_t nodeSize = GET_LHASH_NODE_LEN(pStart); pStart += nodeSize; } @@ -385,7 +379,6 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data } char* tHashGet(SLHashObj* pHashObj, const void* key, size_t keyLen) { - ASSERT(pHashObj != NULL && key != NULL && keyLen > 0); int32_t hashv = pHashObj->hashFn(key, keyLen); int32_t bucketId = doGetBucketIdFromHashVal(hashv, pHashObj->bits); diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index e4081ddf0d..50ceda4605 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -789,17 +789,46 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); pEntryInfo->isNullRes = (pEntryInfo->numOfRes == 0) ? 1 : 0; - if (pCol->info.type == TSDB_DATA_TYPE_FLOAT) { - float v = GET_FLOAT_VAL(&pRes->v); - colDataAppend(pCol, currentRow, (const char*)&v, pEntryInfo->isNullRes); + // NOTE: do nothing change it, for performance issue + if (!pEntryInfo->isNullRes) { + switch (pCol->info.type) { + case TSDB_DATA_TYPE_UBIGINT: + case TSDB_DATA_TYPE_BIGINT: + ((int64_t*)pCol->pData)[currentRow] = pRes->v; +// colDataAppendInt64(pCol, currentRow, &pRes->v); + break; + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_INT: + colDataAppendInt32(pCol, currentRow, (int32_t*)&pRes->v); + break; + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_SMALLINT: + colDataAppendInt16(pCol, currentRow, (int16_t*)&pRes->v); + break; + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_TINYINT: + colDataAppendInt8(pCol, currentRow, (int8_t*)&pRes->v); + break; + case TSDB_DATA_TYPE_DOUBLE: + colDataAppendDouble(pCol, currentRow, (double*)&pRes->v); + break; + case TSDB_DATA_TYPE_FLOAT: { + float v = GET_FLOAT_VAL(&pRes->v); + colDataAppendFloat(pCol, currentRow, &v); + break; + } + } } else { - colDataAppend(pCol, currentRow, (const char*)&pRes->v, pEntryInfo->isNullRes); + colDataAppendNULL(pCol, currentRow); } - if (pEntryInfo->numOfRes > 0) { - code = setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow); - } else { - code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow); + if (pCtx->subsidiaries.num > 0) { + if (pEntryInfo->numOfRes > 0) { + code = setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow); + } else { + code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow); + } } return code; diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c index b24172acc0..3ca1c06303 100644 --- a/source/libs/function/src/detail/tminmax.c +++ b/source/libs/function/src/detail/tminmax.c @@ -61,6 +61,8 @@ } \ } +#define GET_INVOKE_INTRINSIC_THRESHOLD(_bits, _bytes) ((_bits) / ((_bytes) << 3u)) + static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder, int32_t* rounds, int32_t* width) { const int32_t bitWidth = 256; @@ -700,8 +702,29 @@ static void doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunct } } +static int32_t saveRelatedTuple(SqlFunctionCtx* pCtx, SInputColumnInfoData* pInput, int32_t index, void* tval) { + SColumnInfoData* pCol = pInput->pData[0]; + + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SMinmaxResInfo* pBuf = GET_ROWCELL_INTERBUF(pResInfo); + + int32_t code = 0; + if (pCtx->subsidiaries.num > 0) { + index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); + if (index >= 0) { + code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + } + + return code; +} + int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) { int32_t numOfElems = 0; + int32_t code = TSDB_CODE_SUCCESS; SInputColumnInfoData* pInput = &pCtx->input; SColumnDataAgg* pAgg = pInput->pColumnDataAgg[0]; @@ -719,6 +742,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) // data in current data block are qualified to the query if (pInput->colDataSMAIsSet) { + numOfElems = pInput->numOfRows - pAgg->numOfNull; if (numOfElems == 0) { goto _over; @@ -734,15 +758,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) pBuf->v = GET_INT64_VAL(tval); } - if (pCtx->subsidiaries.num > 0) { - index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); - if (index >= 0) { - int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } - } + code = saveRelatedTuple(pCtx, pInput, index, tval); } else { if (IS_SIGNED_NUMERIC_TYPE(type)) { int64_t prev = 0; @@ -751,15 +767,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) int64_t val = GET_INT64_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_INT64_VAL(&pBuf->v) = val; - if (pCtx->subsidiaries.num > 0) { - index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); - if (index >= 0) { - int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } - } + code = saveRelatedTuple(pCtx, pInput, index, tval); } } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { uint64_t prev = 0; @@ -768,15 +776,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) uint64_t val = GET_UINT64_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_UINT64_VAL(&pBuf->v) = val; - if (pCtx->subsidiaries.num > 0) { - index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); - if (index >= 0) { - int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } - } + code = saveRelatedTuple(pCtx, pInput, index, tval); } } else if (type == TSDB_DATA_TYPE_DOUBLE) { double prev = 0; @@ -785,15 +785,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) double val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_DOUBLE_VAL(&pBuf->v) = val; - if (pCtx->subsidiaries.num > 0) { - index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); - if (index >= 0) { - int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } - } + code = saveRelatedTuple(pCtx, pInput, index, tval); } } else if (type == TSDB_DATA_TYPE_FLOAT) { float prev = 0; @@ -802,16 +794,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) float val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_FLOAT_VAL(&pBuf->v) = val; - } - - if (pCtx->subsidiaries.num > 0) { - index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); - if (index >= 0) { - int32_t code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } + code = saveRelatedTuple(pCtx, pInput, index, tval); } } } @@ -825,14 +808,51 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) int32_t numOfRows = pInput->numOfRows; int32_t end = start + numOfRows; - if (pCol->hasNull || numOfRows < 32 || pCtx->subsidiaries.num > 0) { + // clang-format off + int32_t threshold[] = { + //NULL, BOOL, TINYINT, SMALLINT, INT, BIGINT, FLOAT, DOUBLE, VARCHAR, TIMESTAMP, NCHAR, + INT32_MAX, INT32_MAX, 32, 16, 8, 4, 8, 4, INT32_MAX, INT32_MAX, INT32_MAX, + // UTINYINT,USMALLINT, UINT, UBIGINT, JSON, VARBINARY, DECIMAL, BLOB, MEDIUMBLOB, BINARY + 32, 16, 8, 4, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, + }; + // clang-format on + + if (pCol->hasNull || numOfRows < threshold[pCol->info.type] || pCtx->subsidiaries.num > 0) { int32_t i = findFirstValPosition(pCol, start, numOfRows); if ((i < end) && (!pBuf->assign)) { - memcpy(&pBuf->v, pCol->pData + (pCol->info.bytes * i), pCol->info.bytes); + char* p = pCol->pData + pCol->info.bytes * i; + + switch (type) { + case TSDB_DATA_TYPE_DOUBLE: + case TSDB_DATA_TYPE_UBIGINT: + case TSDB_DATA_TYPE_BIGINT: + pBuf->v = *(int64_t*)p; + break; + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_INT: + pBuf->v = *(int32_t*)p; + break; + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_SMALLINT: + pBuf->v = *(int16_t*)p; + break; + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_TINYINT: + pBuf->v = *(int8_t*)p; + break; + case TSDB_DATA_TYPE_FLOAT: { + *(float*)&pBuf->v = *(float*)p; + break; + } + default: + memcpy(&pBuf->v, p, pCol->info.bytes); + break; + } if (pCtx->subsidiaries.num > 0) { - int32_t code = saveTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos); + code = saveTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -849,7 +869,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) } else { numOfElems = numOfRows; - switch (pCol->info.type) { + switch (type) { case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: { handleInt8Col(pCol->pData, start, numOfRows, pBuf, isMinFunc, true); @@ -898,13 +918,14 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) _over: if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved) { - int32_t code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pBuf->nullTuplePos); + code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pBuf->nullTuplePos); if (code != TSDB_CODE_SUCCESS) { return code; } + pBuf->nullTupleSaved = true; } *nElems = numOfElems; - return TSDB_CODE_SUCCESS; + return code; } diff --git a/source/libs/function/src/tpercentile.c b/source/libs/function/src/tpercentile.c index 6b85155486..1734b535f1 100644 --- a/source/libs/function/src/tpercentile.c +++ b/source/libs/function/src/tpercentile.c @@ -347,8 +347,6 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT * in memory bucket, we only accept data array list */ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { - ASSERT(pBucket != NULL && data != NULL && size > 0); - int32_t count = 0; int32_t bytes = pBucket->bytes; for (int32_t i = 0; i < size; ++i) { diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index c9fa70ff11..b9e72847a1 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -812,7 +812,7 @@ int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) { block->info.hasVarCol = IS_VAR_DATA_TYPE(udfCol->colMeta.type); block->pDataBlock = taosArrayInit(1, sizeof(SColumnInfoData)); - taosArraySetSize(block->pDataBlock, 1); + taosArrayPush(block->pDataBlock, &(SColumnInfoData){0}); SColumnInfoData *col = taosArrayGet(block->pDataBlock, 0); SUdfColumnMeta *meta = &udfCol->colMeta; col->info.precision = meta->precision; diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index 274cac405d..104f066fa9 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -315,6 +315,11 @@ static int32_t tlvDecodeImpl(STlv* pTlv, void* pValue, int32_t len) { } static int32_t tlvDecodeValueImpl(STlvDecoder* pDecoder, void* pValue, int32_t len) { + // compatible with lower version messages + if (pDecoder->bufSize == pDecoder->offset) { + memset(pValue, 0, len); + return TSDB_CODE_SUCCESS; + } if (len > pDecoder->bufSize - pDecoder->offset) { return TSDB_CODE_FAILED; } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 44a8f7e89f..faa908021e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -544,6 +544,7 @@ stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } stream_options(A) ::= stream_options(B) IGNORE EXPIRED NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreExpired = taosStr2Int8(C.z, NULL, 10); A = B; } stream_options(A) ::= stream_options(B) FILL_HISTORY NK_INTEGER(C). { ((SStreamOptions*)B)->fillHistory = taosStr2Int8(C.z, NULL, 10); A = B; } +stream_options(A) ::= stream_options(B) DELETE_MARK duration_literal(C). { ((SStreamOptions*)B)->pDeleteMark = releaseRawExprNode(pCxt, C); A = B; } stream_options(A) ::= stream_options(B) IGNORE UPDATE NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreUpdate = taosStr2Int8(C.z, NULL, 10); A = B; } subtable_opt(A) ::= . { A = NULL; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 2c99e50ff3..0d052846f7 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -666,6 +666,9 @@ static uint8_t getPrecisionFromCurrStmt(SNode* pCurrStmt, uint8_t defaultVal) { if (isSetOperator(pCurrStmt)) { return ((SSetOperator*)pCurrStmt)->precision; } + if (NULL != pCurrStmt && QUERY_NODE_CREATE_STREAM_STMT == nodeType(pCurrStmt)) { + return getPrecisionFromCurrStmt(((SCreateStreamStmt*)pCurrStmt)->pQuery, defaultVal); + } return defaultVal; } @@ -1464,6 +1467,15 @@ static int32_t translateInterpFunc(STranslateContext* pCxt, SFunctionNode* pFunc return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt; + SNode* pTable = pSelect->pFromTable; + + if ((NULL != pTable && (QUERY_NODE_REAL_TABLE != nodeType(pTable) || + (TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType && + TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType)))) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE, + "%s is only supported in single table query", pFunc->functionName); + } + if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc || pSelect->hasIndefiniteRowsFunc) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } @@ -5512,16 +5524,6 @@ static bool crossTableWithUdaf(SSelectStmt* pSelect) { } static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) { - if (NULL != pStmt->pOptions->pWatermark && - (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark))) { - return pCxt->errCode; - } - - if (NULL != pStmt->pOptions->pDelay && - (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pDelay))) { - return pCxt->errCode; - } - if (NULL == pStmt->pQuery) { return TSDB_CODE_SUCCESS; } @@ -5714,6 +5716,17 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt return code; } +static int32_t translateStreamOptions(STranslateContext* pCxt, SCreateStreamStmt* pStmt) { + pCxt->pCurrStmt = (SNode*)pStmt; + SStreamOptions* pOptions = pStmt->pOptions; + if ((NULL != pOptions->pWatermark && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pOptions->pWatermark))) || + (NULL != pOptions->pDeleteMark && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pOptions->pDeleteMark))) || + (NULL != pOptions->pDelay && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pOptions->pDelay)))) { + return pCxt->errCode; + } + return TSDB_CODE_SUCCESS; +} + static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) { pReq->igExists = pStmt->ignoreExists; @@ -5735,10 +5748,16 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* } } + if (TSDB_CODE_SUCCESS == code) { + code = translateStreamOptions(pCxt, pStmt); + } + if (TSDB_CODE_SUCCESS == code) { pReq->triggerType = pStmt->pOptions->triggerType; pReq->maxDelay = (NULL != pStmt->pOptions->pDelay ? ((SValueNode*)pStmt->pOptions->pDelay)->datum.i : 0); pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); + pReq->deleteMark = + (NULL != pStmt->pOptions->pDeleteMark ? ((SValueNode*)pStmt->pOptions->pDeleteMark)->datum.i : 0); pReq->fillHistory = pStmt->pOptions->fillHistory; pReq->igExpired = pStmt->pOptions->ignoreExpired; pReq->igUpdate = pStmt->pOptions->ignoreUpdate; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 9cd3a3c65c..98368d3806 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 715 -#define YYNRULE 544 +#define YYNSTATE 716 +#define YYNRULE 545 #define YYNTOKEN 324 -#define YY_MAX_SHIFT 714 -#define YY_MIN_SHIFTREDUCE 1061 -#define YY_MAX_SHIFTREDUCE 1604 -#define YY_ERROR_ACTION 1605 -#define YY_ACCEPT_ACTION 1606 -#define YY_NO_ACTION 1607 -#define YY_MIN_REDUCE 1608 -#define YY_MAX_REDUCE 2151 +#define YY_MAX_SHIFT 715 +#define YY_MIN_SHIFTREDUCE 1063 +#define YY_MAX_SHIFTREDUCE 1607 +#define YY_ERROR_ACTION 1608 +#define YY_ACCEPT_ACTION 1609 +#define YY_NO_ACTION 1610 +#define YY_MIN_REDUCE 1611 +#define YY_MAX_REDUCE 2155 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -218,280 +218,280 @@ typedef union { *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (2733) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 462, 369, 463, 1644, 1807, 1809, 403, 1965, 1752, 33, - /* 10 */ 276, 170, 43, 41, 1533, 1631, 1750, 570, 168, 1947, - /* 20 */ 364, 2122, 1383, 1951, 1801, 42, 40, 39, 38, 37, - /* 30 */ 1965, 604, 1606, 1463, 1947, 1381, 569, 174, 1983, 334, - /* 40 */ 1861, 2123, 571, 1808, 1809, 52, 621, 590, 549, 1943, - /* 50 */ 1949, 1933, 2122, 620, 11, 10, 1408, 588, 1458, 1933, - /* 60 */ 614, 1983, 1761, 16, 1943, 1949, 346, 2128, 174, 585, - /* 70 */ 1389, 1409, 2123, 571, 1933, 614, 620, 461, 1964, 603, - /* 80 */ 466, 1650, 1999, 43, 41, 161, 1966, 624, 1968, 1969, - /* 90 */ 619, 364, 614, 1383, 478, 12, 1870, 379, 603, 549, - /* 100 */ 604, 1964, 159, 2122, 1463, 1999, 1381, 1715, 101, 1966, - /* 110 */ 624, 1968, 1969, 619, 124, 614, 259, 711, 2128, 174, - /* 120 */ 171, 501, 2052, 2123, 571, 228, 358, 2048, 1791, 1458, - /* 130 */ 603, 1761, 1465, 1466, 16, 97, 604, 572, 2143, 549, - /* 140 */ 176, 1389, 582, 2122, 471, 94, 463, 1644, 2078, 1506, - /* 150 */ 124, 157, 1180, 59, 46, 86, 296, 506, 2128, 174, - /* 160 */ 591, 1439, 1448, 2123, 571, 470, 12, 1761, 466, 1650, - /* 170 */ 294, 67, 355, 132, 66, 1874, 2067, 516, 515, 514, - /* 180 */ 1384, 1677, 1382, 1263, 1264, 129, 510, 1182, 711, 1952, - /* 190 */ 509, 356, 194, 458, 456, 508, 513, 1316, 1317, 156, - /* 200 */ 1947, 507, 2064, 1465, 1466, 46, 1387, 1388, 1763, 1438, - /* 210 */ 1441, 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, 1456, - /* 220 */ 1457, 1459, 1460, 1461, 1462, 1464, 1467, 2, 59, 604, - /* 230 */ 1943, 1949, 1439, 1448, 256, 2060, 581, 589, 125, 580, - /* 240 */ 1410, 614, 2122, 179, 468, 1408, 516, 515, 514, 168, - /* 250 */ 464, 1384, 226, 1382, 129, 510, 50, 569, 174, 509, - /* 260 */ 1761, 548, 2123, 571, 508, 513, 480, 100, 36, 35, - /* 270 */ 507, 1862, 42, 40, 39, 38, 37, 1387, 1388, 377, - /* 280 */ 1438, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, - /* 290 */ 1456, 1457, 1459, 1460, 1461, 1462, 1464, 1467, 2, 521, - /* 300 */ 9, 43, 41, 177, 177, 75, 74, 406, 92, 364, - /* 310 */ 181, 1383, 83, 322, 531, 1983, 344, 98, 532, 1965, - /* 320 */ 59, 549, 1463, 564, 1381, 2122, 1814, 145, 225, 318, - /* 330 */ 1754, 133, 394, 357, 392, 388, 384, 381, 378, 1753, - /* 340 */ 2128, 174, 1812, 524, 1951, 2123, 571, 1458, 518, 367, - /* 350 */ 1983, 63, 16, 224, 370, 1947, 1571, 156, 621, 1389, - /* 360 */ 2127, 658, 156, 1933, 563, 620, 1763, 39, 38, 37, - /* 370 */ 590, 1763, 43, 41, 1468, 565, 59, 1410, 177, 51, - /* 380 */ 364, 1965, 1383, 258, 12, 1943, 1949, 347, 59, 65, - /* 390 */ 1964, 81, 64, 1463, 1999, 1381, 614, 101, 1966, 624, - /* 400 */ 1968, 1969, 619, 9, 614, 128, 711, 135, 1494, 142, - /* 410 */ 2023, 2052, 1983, 1739, 1756, 358, 2048, 599, 1458, 1870, - /* 420 */ 621, 1465, 1466, 267, 268, 1933, 1094, 620, 266, 1737, - /* 430 */ 1389, 1220, 646, 645, 644, 1224, 643, 1226, 1227, 642, - /* 440 */ 1229, 639, 59, 1235, 636, 1237, 1238, 633, 630, 649, - /* 450 */ 1439, 1448, 1964, 1594, 1409, 44, 1999, 1608, 186, 102, - /* 460 */ 1966, 624, 1968, 1969, 619, 1096, 614, 1099, 1100, 1384, - /* 470 */ 177, 1382, 402, 2052, 401, 480, 1408, 711, 2049, 409, + /* 0 */ 463, 370, 464, 1647, 1810, 1812, 404, 1969, 1755, 33, + /* 10 */ 277, 170, 43, 41, 1536, 1634, 1753, 571, 168, 1951, + /* 20 */ 365, 2126, 1386, 1955, 1804, 42, 40, 39, 38, 37, + /* 30 */ 1969, 605, 1609, 1466, 1951, 1384, 570, 174, 1987, 335, + /* 40 */ 1864, 2127, 572, 1811, 1812, 52, 622, 591, 550, 1947, + /* 50 */ 1953, 1937, 2126, 621, 11, 10, 1411, 589, 1461, 1937, + /* 60 */ 615, 1987, 1764, 16, 1947, 1953, 347, 2132, 174, 586, + /* 70 */ 1392, 1412, 2127, 572, 1937, 615, 621, 462, 1968, 604, + /* 80 */ 467, 1653, 2003, 43, 41, 161, 1970, 625, 1972, 1973, + /* 90 */ 620, 365, 615, 1386, 479, 12, 1873, 380, 604, 550, + /* 100 */ 605, 1968, 159, 2126, 1466, 2003, 1384, 1718, 101, 1970, + /* 110 */ 625, 1972, 1973, 620, 124, 615, 260, 712, 2132, 174, + /* 120 */ 171, 502, 2056, 2127, 572, 229, 359, 2052, 1794, 1461, + /* 130 */ 604, 1764, 1468, 1469, 16, 97, 605, 573, 2147, 550, + /* 140 */ 176, 1392, 583, 2126, 472, 94, 464, 1647, 2082, 1509, + /* 150 */ 124, 157, 1182, 59, 46, 86, 297, 507, 2132, 174, + /* 160 */ 592, 1442, 1451, 2127, 572, 471, 12, 1764, 467, 1653, + /* 170 */ 295, 67, 356, 132, 66, 1877, 2071, 517, 516, 515, + /* 180 */ 1387, 1680, 1385, 1265, 1266, 129, 511, 1184, 712, 1956, + /* 190 */ 510, 357, 194, 459, 457, 509, 514, 1318, 1319, 156, + /* 200 */ 1951, 508, 2068, 1468, 1469, 46, 1390, 1391, 1766, 1441, + /* 210 */ 1444, 1445, 1446, 1447, 1448, 1449, 1450, 617, 613, 1459, + /* 220 */ 1460, 1462, 1463, 1464, 1465, 1467, 1470, 2, 59, 605, + /* 230 */ 1947, 1953, 1442, 1451, 257, 2064, 582, 590, 125, 581, + /* 240 */ 1413, 615, 2126, 179, 469, 1411, 517, 516, 515, 168, + /* 250 */ 465, 1387, 227, 1385, 129, 511, 226, 570, 174, 510, + /* 260 */ 1764, 50, 2127, 572, 509, 514, 549, 100, 36, 35, + /* 270 */ 508, 1865, 42, 40, 39, 38, 37, 1390, 1391, 378, + /* 280 */ 1441, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 617, 613, + /* 290 */ 1459, 1460, 1462, 1463, 1464, 1465, 1467, 1470, 2, 522, + /* 300 */ 9, 43, 41, 177, 177, 75, 74, 407, 92, 365, + /* 310 */ 181, 1386, 83, 323, 532, 1987, 345, 98, 533, 1969, + /* 320 */ 59, 550, 1466, 565, 1384, 2126, 1817, 145, 225, 319, + /* 330 */ 1757, 133, 395, 358, 393, 389, 385, 382, 379, 1756, + /* 340 */ 2132, 174, 1815, 525, 1955, 2127, 572, 1461, 519, 368, + /* 350 */ 1987, 63, 16, 224, 371, 1951, 1574, 156, 622, 1392, + /* 360 */ 2131, 481, 156, 1937, 564, 621, 1766, 39, 38, 37, + /* 370 */ 591, 1766, 43, 41, 1471, 566, 59, 1413, 177, 51, + /* 380 */ 365, 1969, 1386, 259, 12, 1947, 1953, 348, 59, 65, + /* 390 */ 1968, 81, 64, 1466, 2003, 1384, 615, 101, 1970, 625, + /* 400 */ 1972, 1973, 620, 9, 615, 128, 712, 135, 1497, 142, + /* 410 */ 2027, 2056, 1987, 1742, 1759, 359, 2052, 600, 1461, 1873, + /* 420 */ 622, 1468, 1469, 268, 269, 1937, 1096, 621, 267, 1740, + /* 430 */ 1392, 1222, 647, 646, 645, 1226, 644, 1228, 1229, 643, + /* 440 */ 1231, 640, 59, 1237, 637, 1239, 1240, 634, 631, 650, + /* 450 */ 1442, 1451, 1968, 1597, 1412, 44, 2003, 1611, 186, 102, + /* 460 */ 1970, 625, 1972, 1973, 620, 1098, 615, 1101, 1102, 1387, + /* 470 */ 177, 1385, 403, 2056, 402, 481, 1411, 712, 2053, 410, /* 480 */ 30, 123, 122, 121, 120, 119, 118, 117, 116, 115, - /* 490 */ 1499, 658, 1465, 1466, 78, 1387, 1388, 77, 1438, 1441, - /* 500 */ 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, 1456, 1457, - /* 510 */ 1459, 1460, 1461, 1462, 1464, 1467, 2, 512, 511, 320, - /* 520 */ 258, 1439, 1448, 1609, 114, 604, 177, 113, 112, 111, - /* 530 */ 110, 109, 108, 107, 106, 105, 81, 1407, 177, 407, - /* 540 */ 1384, 158, 1382, 1620, 114, 1389, 1630, 113, 112, 111, - /* 550 */ 110, 109, 108, 107, 106, 105, 1761, 36, 35, 1757, - /* 560 */ 1965, 42, 40, 39, 38, 37, 1387, 1388, 47, 1438, - /* 570 */ 1441, 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, 1456, - /* 580 */ 1457, 1459, 1460, 1461, 1462, 1464, 1467, 2, 43, 41, - /* 590 */ 1933, 1983, 177, 25, 410, 445, 364, 591, 1383, 585, - /* 600 */ 339, 1113, 670, 1112, 1933, 560, 620, 411, 9, 1463, - /* 610 */ 7, 1381, 1875, 1814, 1814, 606, 211, 2024, 36, 35, - /* 620 */ 368, 331, 42, 40, 39, 38, 37, 6, 1629, 1812, - /* 630 */ 1812, 1964, 1114, 1951, 1458, 1999, 530, 582, 101, 1966, - /* 640 */ 624, 1968, 1969, 619, 1947, 614, 1389, 1560, 604, 528, - /* 650 */ 171, 526, 2052, 190, 189, 582, 358, 2048, 2067, 43, - /* 660 */ 41, 340, 408, 338, 337, 1746, 503, 364, 132, 1383, - /* 670 */ 505, 44, 1933, 327, 1943, 1949, 359, 1748, 2079, 1761, - /* 680 */ 1463, 398, 1381, 1411, 2063, 614, 132, 570, 1537, 566, - /* 690 */ 561, 2122, 504, 711, 1408, 557, 556, 1558, 1559, 1561, - /* 700 */ 1562, 1563, 544, 400, 396, 1458, 569, 174, 1465, 1466, - /* 710 */ 1628, 2123, 571, 227, 1492, 2127, 1627, 1389, 177, 2122, - /* 720 */ 36, 35, 604, 1744, 42, 40, 39, 38, 37, 173, - /* 730 */ 2060, 2061, 1411, 130, 2065, 2126, 417, 1439, 1448, 2123, - /* 740 */ 2125, 2127, 12, 2067, 1473, 2122, 584, 172, 2060, 2061, - /* 750 */ 1408, 130, 2065, 1761, 1933, 231, 1384, 608, 1382, 2024, - /* 760 */ 1933, 2126, 505, 1626, 711, 2123, 2124, 36, 35, 2062, - /* 770 */ 1493, 42, 40, 39, 38, 37, 1359, 1360, 134, 1465, - /* 780 */ 1466, 2023, 1387, 1388, 504, 1438, 1441, 1442, 1443, 1444, - /* 790 */ 1445, 1446, 1447, 616, 612, 1456, 1457, 1459, 1460, 1461, - /* 800 */ 1462, 1464, 1467, 2, 319, 2126, 1406, 1933, 1439, 1448, - /* 810 */ 1113, 615, 1112, 439, 682, 680, 452, 36, 35, 451, - /* 820 */ 1857, 42, 40, 39, 38, 37, 183, 1384, 1674, 1382, - /* 830 */ 650, 182, 1526, 1805, 423, 1440, 453, 1625, 1530, 425, - /* 840 */ 1624, 1114, 32, 362, 1487, 1488, 1489, 1490, 1491, 1495, - /* 850 */ 1496, 1497, 1498, 1387, 1388, 1549, 1438, 1441, 1442, 1443, - /* 860 */ 1444, 1445, 1446, 1447, 616, 612, 1456, 1457, 1459, 1460, - /* 870 */ 1461, 1462, 1464, 1467, 2, 236, 29, 1623, 648, 1622, - /* 880 */ 335, 1933, 36, 35, 1933, 1621, 42, 40, 39, 38, - /* 890 */ 37, 1440, 413, 688, 687, 686, 685, 374, 1619, 684, - /* 900 */ 683, 136, 678, 677, 676, 675, 674, 673, 672, 149, - /* 910 */ 668, 667, 666, 373, 372, 663, 662, 661, 660, 659, - /* 920 */ 1618, 1933, 449, 1933, 1965, 444, 443, 442, 441, 438, - /* 930 */ 437, 436, 435, 434, 430, 429, 428, 427, 336, 420, - /* 940 */ 419, 418, 1933, 415, 414, 333, 1617, 1965, 1616, 1857, - /* 950 */ 1857, 290, 361, 360, 1791, 1983, 1615, 604, 604, 1411, - /* 960 */ 184, 188, 1397, 621, 1933, 604, 604, 1614, 1933, 1738, - /* 970 */ 620, 431, 432, 1463, 156, 1390, 1408, 582, 1983, 371, - /* 980 */ 479, 1601, 671, 1764, 1731, 1814, 621, 2092, 1761, 1761, - /* 990 */ 1933, 1933, 1933, 620, 376, 1964, 1761, 1761, 1458, 1999, - /* 1000 */ 1933, 1813, 101, 1966, 624, 1968, 1969, 619, 132, 614, - /* 1010 */ 1389, 1933, 1099, 1100, 2142, 1613, 2052, 1716, 1964, 1612, - /* 1020 */ 358, 2048, 1999, 1844, 1611, 101, 1966, 624, 1968, 1969, - /* 1030 */ 619, 2086, 614, 1965, 574, 31, 549, 2142, 253, 2052, - /* 1040 */ 2122, 36, 35, 358, 2048, 42, 40, 39, 38, 37, - /* 1050 */ 654, 2072, 1526, 1805, 2116, 2128, 174, 610, 1920, 1933, - /* 1060 */ 2123, 571, 655, 1933, 1983, 1805, 573, 212, 1933, 175, - /* 1070 */ 2060, 2061, 621, 130, 2065, 210, 656, 1933, 1600, 620, - /* 1080 */ 1529, 1664, 163, 1657, 48, 138, 3, 126, 497, 493, - /* 1090 */ 489, 485, 209, 68, 558, 147, 146, 653, 652, 651, - /* 1100 */ 144, 577, 235, 517, 1964, 519, 386, 534, 1999, 533, - /* 1110 */ 1965, 101, 1966, 624, 1968, 1969, 619, 1440, 614, 604, - /* 1120 */ 1398, 217, 1393, 2142, 215, 2052, 1603, 1604, 82, 358, - /* 1130 */ 2048, 207, 1392, 1758, 1965, 664, 219, 234, 1383, 218, - /* 1140 */ 2071, 1983, 61, 76, 61, 240, 1401, 1403, 656, 621, - /* 1150 */ 1761, 1381, 604, 1655, 1933, 1391, 620, 1161, 612, 1456, - /* 1160 */ 1457, 1459, 1460, 1461, 1462, 1983, 140, 147, 146, 653, - /* 1170 */ 652, 651, 144, 621, 426, 522, 84, 611, 1933, 1965, - /* 1180 */ 620, 1964, 247, 1761, 221, 1999, 1389, 220, 101, 1966, - /* 1190 */ 624, 1968, 1969, 619, 1557, 614, 1556, 242, 206, 200, - /* 1200 */ 2027, 205, 2052, 45, 476, 1964, 358, 2048, 1984, 1999, - /* 1210 */ 1983, 1736, 101, 1966, 624, 1968, 1969, 619, 621, 614, - /* 1220 */ 198, 11, 10, 1933, 2025, 620, 2052, 375, 1866, 264, - /* 1230 */ 358, 2048, 604, 711, 1965, 36, 35, 604, 1645, 42, - /* 1240 */ 40, 39, 38, 37, 2082, 141, 545, 143, 145, 61, - /* 1250 */ 1964, 586, 604, 604, 1999, 1329, 575, 101, 1966, 624, - /* 1260 */ 1968, 1969, 619, 1761, 614, 1983, 271, 601, 1761, 607, - /* 1270 */ 1802, 2052, 604, 621, 223, 358, 2048, 222, 1933, 1395, - /* 1280 */ 620, 269, 537, 1761, 1761, 255, 602, 36, 35, 583, - /* 1290 */ 1965, 42, 40, 39, 38, 37, 1384, 596, 1382, 273, - /* 1300 */ 1213, 1500, 1394, 1761, 45, 1964, 1954, 45, 628, 1999, - /* 1310 */ 143, 145, 102, 1966, 624, 1968, 1969, 619, 656, 614, - /* 1320 */ 1484, 1983, 1387, 1388, 549, 578, 2052, 1651, 2122, 621, - /* 1330 */ 2051, 2048, 127, 604, 1933, 1965, 620, 147, 146, 653, - /* 1340 */ 652, 651, 144, 2128, 174, 665, 143, 277, 2123, 571, - /* 1350 */ 1142, 252, 1, 4, 1956, 380, 1449, 385, 1965, 289, - /* 1360 */ 1241, 1964, 1245, 1252, 1761, 1999, 1983, 1159, 102, 1966, - /* 1370 */ 624, 1968, 1969, 619, 621, 614, 706, 332, 1346, 1933, - /* 1380 */ 284, 620, 2052, 187, 1250, 1143, 609, 2048, 412, 1983, - /* 1390 */ 155, 1411, 1867, 416, 447, 421, 1406, 618, 148, 433, - /* 1400 */ 1859, 454, 1933, 440, 620, 446, 622, 191, 448, 455, - /* 1410 */ 1999, 457, 459, 102, 1966, 624, 1968, 1969, 619, 1412, - /* 1420 */ 614, 460, 469, 1414, 473, 472, 1413, 2052, 197, 1964, - /* 1430 */ 199, 326, 2048, 1999, 1415, 474, 312, 1966, 624, 1968, - /* 1440 */ 1969, 619, 617, 614, 605, 2017, 1965, 477, 202, 475, - /* 1450 */ 204, 79, 481, 80, 208, 500, 1116, 1909, 538, 498, - /* 1460 */ 502, 499, 1965, 1751, 536, 321, 214, 104, 285, 539, - /* 1470 */ 559, 2083, 229, 1747, 1908, 2093, 216, 1983, 540, 232, - /* 1480 */ 546, 2098, 150, 151, 594, 621, 1749, 1745, 152, 153, - /* 1490 */ 1933, 2097, 620, 1983, 5, 568, 2074, 246, 554, 552, - /* 1500 */ 543, 621, 249, 164, 551, 553, 1933, 248, 620, 555, - /* 1510 */ 348, 349, 562, 250, 579, 2145, 576, 1964, 1965, 1526, - /* 1520 */ 131, 1999, 2121, 238, 160, 1966, 624, 1968, 1969, 619, - /* 1530 */ 241, 614, 1410, 1964, 587, 254, 260, 1999, 352, 1416, - /* 1540 */ 160, 1966, 624, 1968, 1969, 619, 1965, 614, 251, 1983, - /* 1550 */ 2068, 1871, 286, 592, 593, 1880, 287, 621, 1879, 1878, - /* 1560 */ 354, 597, 1933, 598, 620, 550, 2089, 89, 288, 91, - /* 1570 */ 58, 2033, 1762, 93, 626, 291, 707, 1983, 1806, 1732, - /* 1580 */ 708, 280, 2090, 710, 49, 621, 315, 295, 300, 1964, - /* 1590 */ 1933, 314, 620, 1999, 1927, 323, 306, 1966, 624, 1968, - /* 1600 */ 1969, 619, 324, 614, 304, 293, 1926, 72, 1965, 1925, - /* 1610 */ 1924, 73, 1921, 382, 1375, 383, 1376, 1964, 180, 387, - /* 1620 */ 714, 1999, 1919, 389, 161, 1966, 624, 1968, 1969, 619, - /* 1630 */ 390, 614, 391, 1918, 283, 393, 1917, 395, 1916, 1983, - /* 1640 */ 567, 397, 1915, 399, 353, 1349, 1348, 621, 1891, 167, - /* 1650 */ 1890, 405, 1933, 404, 620, 704, 700, 696, 692, 281, - /* 1660 */ 1889, 1888, 1307, 1965, 185, 137, 1848, 1847, 1850, 1846, - /* 1670 */ 1845, 1843, 1842, 1841, 422, 1840, 424, 2144, 1852, 1964, - /* 1680 */ 1851, 1849, 1839, 1999, 1838, 1837, 313, 1966, 624, 1968, - /* 1690 */ 1969, 619, 1836, 614, 1983, 99, 1835, 1834, 274, 1833, - /* 1700 */ 1832, 1831, 618, 1830, 1829, 1828, 1827, 1933, 1826, 620, - /* 1710 */ 1825, 1824, 1823, 1822, 1821, 1820, 139, 1309, 1819, 1818, - /* 1720 */ 1817, 450, 1816, 1815, 1188, 1965, 70, 169, 195, 1639, - /* 1730 */ 1102, 600, 1679, 1678, 1964, 192, 1676, 193, 1999, 1640, - /* 1740 */ 1953, 312, 1966, 624, 1968, 1969, 619, 1904, 614, 465, - /* 1750 */ 2018, 1101, 1898, 1887, 467, 1965, 1983, 196, 203, 1886, - /* 1760 */ 71, 363, 1869, 201, 621, 1740, 1675, 1673, 261, 1933, - /* 1770 */ 482, 620, 1671, 1135, 1669, 483, 486, 484, 487, 488, - /* 1780 */ 490, 492, 491, 1667, 494, 1353, 1983, 230, 1654, 496, - /* 1790 */ 1653, 365, 495, 1636, 621, 1742, 1964, 1256, 60, 1933, - /* 1800 */ 1999, 620, 1741, 313, 1966, 624, 1968, 1969, 619, 1171, - /* 1810 */ 614, 1257, 1179, 1965, 1178, 1177, 1176, 679, 1665, 1173, - /* 1820 */ 1172, 1170, 681, 341, 1658, 342, 1964, 213, 1656, 1965, - /* 1830 */ 1999, 343, 520, 313, 1966, 624, 1968, 1969, 619, 523, - /* 1840 */ 614, 1635, 525, 1634, 1983, 527, 1633, 529, 1364, 103, - /* 1850 */ 1365, 1363, 621, 1367, 1903, 24, 1355, 1933, 1897, 620, - /* 1860 */ 1983, 53, 541, 1885, 1883, 2127, 17, 14, 621, 18, - /* 1870 */ 56, 154, 62, 1933, 1965, 620, 57, 244, 245, 28, - /* 1880 */ 15, 1954, 19, 1588, 535, 1573, 26, 237, 1999, 162, - /* 1890 */ 1965, 308, 1966, 624, 1968, 1969, 619, 547, 614, 257, - /* 1900 */ 1964, 239, 1555, 243, 1999, 1983, 542, 297, 1966, 624, - /* 1910 */ 1968, 1969, 619, 621, 614, 27, 233, 345, 1933, 1548, - /* 1920 */ 620, 1983, 85, 1587, 350, 1592, 55, 1591, 351, 621, - /* 1930 */ 165, 1884, 1593, 1594, 1933, 1523, 620, 1882, 1522, 1881, - /* 1940 */ 20, 262, 1868, 263, 265, 1964, 1553, 88, 270, 1999, - /* 1950 */ 87, 90, 298, 1966, 624, 1968, 1969, 619, 275, 614, - /* 1960 */ 21, 1964, 595, 272, 94, 1999, 10, 1965, 299, 1966, - /* 1970 */ 624, 1968, 1969, 619, 54, 614, 1475, 1399, 1431, 2002, - /* 1980 */ 166, 1453, 613, 178, 625, 8, 1474, 627, 366, 631, - /* 1990 */ 34, 1965, 1451, 1450, 13, 22, 634, 1423, 1983, 23, - /* 2000 */ 637, 1242, 629, 1485, 640, 1239, 621, 632, 623, 1236, - /* 2010 */ 635, 1933, 638, 620, 1230, 1228, 641, 1234, 1219, 95, - /* 2020 */ 278, 1233, 1983, 96, 1251, 1232, 1247, 647, 1167, 1231, - /* 2030 */ 621, 1133, 1166, 69, 657, 1933, 1165, 620, 1964, 669, - /* 2040 */ 1164, 1163, 1999, 1162, 1160, 305, 1966, 624, 1968, 1969, - /* 2050 */ 619, 1158, 614, 1965, 1157, 1156, 1186, 279, 1154, 1153, - /* 2060 */ 1152, 1151, 1964, 1150, 1149, 1148, 1999, 1181, 1183, 309, - /* 2070 */ 1966, 624, 1968, 1969, 619, 1145, 614, 1144, 1141, 1140, - /* 2080 */ 1139, 1138, 1672, 1965, 1983, 689, 690, 691, 1670, 694, - /* 2090 */ 693, 695, 621, 1668, 697, 698, 699, 1933, 1666, 620, - /* 2100 */ 701, 702, 703, 1652, 705, 1091, 1632, 282, 709, 1607, - /* 2110 */ 1607, 1385, 292, 712, 1983, 713, 1607, 1607, 1607, 1607, - /* 2120 */ 1607, 1607, 621, 1607, 1964, 1607, 1607, 1933, 1999, 620, - /* 2130 */ 1607, 301, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, - /* 2140 */ 1607, 1965, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2150 */ 1607, 1607, 1607, 1607, 1964, 1607, 1607, 1965, 1999, 1607, - /* 2160 */ 1607, 310, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, - /* 2170 */ 1607, 1607, 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2180 */ 621, 1607, 1607, 1607, 1607, 1933, 1607, 620, 1983, 1607, - /* 2190 */ 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, - /* 2200 */ 1607, 1933, 1965, 620, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2210 */ 1607, 1607, 1964, 1607, 1607, 1607, 1999, 1607, 1965, 302, - /* 2220 */ 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1964, 1607, - /* 2230 */ 1607, 1607, 1999, 1983, 1607, 311, 1966, 624, 1968, 1969, - /* 2240 */ 619, 621, 614, 1607, 1607, 1607, 1933, 1607, 620, 1983, - /* 2250 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, - /* 2260 */ 1607, 1607, 1933, 1607, 620, 1607, 1607, 1607, 1607, 1607, - /* 2270 */ 1607, 1607, 1607, 1964, 1607, 1607, 1607, 1999, 1607, 1607, - /* 2280 */ 303, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1964, - /* 2290 */ 1607, 1607, 1607, 1999, 1607, 1965, 316, 1966, 624, 1968, - /* 2300 */ 1969, 619, 1607, 614, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2310 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1965, - /* 2320 */ 1607, 1607, 1607, 1607, 1607, 1607, 1983, 1607, 1607, 1607, - /* 2330 */ 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, 1607, 1933, - /* 2340 */ 1607, 620, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2350 */ 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, - /* 2360 */ 1607, 1607, 1607, 1933, 1607, 620, 1964, 1607, 1607, 1607, - /* 2370 */ 1999, 1607, 1607, 317, 1966, 624, 1968, 1969, 619, 1607, - /* 2380 */ 614, 1965, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2390 */ 1964, 1607, 1607, 1607, 1999, 1607, 1607, 1977, 1966, 624, - /* 2400 */ 1968, 1969, 619, 1607, 614, 1607, 1607, 1607, 1607, 1607, - /* 2410 */ 1607, 1965, 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2420 */ 621, 1607, 1607, 1607, 1607, 1933, 1607, 620, 1607, 1607, - /* 2430 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2440 */ 1607, 1607, 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2450 */ 621, 1607, 1964, 1607, 1607, 1933, 1999, 620, 1607, 1976, - /* 2460 */ 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1607, 1965, - /* 2470 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2480 */ 1607, 1607, 1964, 1607, 1607, 1965, 1999, 1607, 1607, 1975, - /* 2490 */ 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1607, 1607, - /* 2500 */ 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, - /* 2510 */ 1607, 1607, 1607, 1933, 1607, 620, 1983, 1607, 1607, 1607, - /* 2520 */ 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, 1607, 1933, - /* 2530 */ 1965, 620, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2540 */ 1964, 1607, 1607, 1607, 1999, 1607, 1965, 328, 1966, 624, - /* 2550 */ 1968, 1969, 619, 1607, 614, 1607, 1964, 1607, 1607, 1607, - /* 2560 */ 1999, 1983, 1607, 329, 1966, 624, 1968, 1969, 619, 621, - /* 2570 */ 614, 1607, 1607, 1607, 1933, 1607, 620, 1983, 1607, 1607, - /* 2580 */ 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, 1607, - /* 2590 */ 1933, 1607, 620, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2600 */ 1607, 1964, 1607, 1607, 1607, 1999, 1607, 1607, 325, 1966, - /* 2610 */ 624, 1968, 1969, 619, 1607, 614, 1607, 1964, 1607, 1607, - /* 2620 */ 1607, 1999, 1607, 1965, 330, 1966, 624, 1968, 1969, 619, - /* 2630 */ 1607, 614, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, - /* 2640 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1965, 1607, 1607, - /* 2650 */ 1607, 1607, 1607, 1607, 1983, 1607, 1607, 1607, 1607, 1607, - /* 2660 */ 1607, 1607, 621, 1607, 1607, 1607, 1607, 1933, 1607, 620, - /* 2670 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1983, 1607, - /* 2680 */ 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, - /* 2690 */ 1607, 1933, 1607, 620, 622, 1607, 1607, 1607, 1999, 1607, - /* 2700 */ 1607, 308, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, - /* 2710 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1964, 1607, - /* 2720 */ 1607, 1607, 1999, 1607, 1607, 307, 1966, 624, 1968, 1969, - /* 2730 */ 619, 1607, 614, + /* 490 */ 1502, 659, 1468, 1469, 78, 1390, 1391, 77, 1441, 1444, + /* 500 */ 1445, 1446, 1447, 1448, 1449, 1450, 617, 613, 1459, 1460, + /* 510 */ 1462, 1463, 1464, 1465, 1467, 1470, 2, 513, 512, 321, + /* 520 */ 259, 1442, 1451, 1612, 114, 605, 177, 113, 112, 111, + /* 530 */ 110, 109, 108, 107, 106, 105, 81, 659, 177, 408, + /* 540 */ 1387, 158, 1385, 1623, 114, 1410, 1633, 113, 112, 111, + /* 550 */ 110, 109, 108, 107, 106, 105, 1764, 36, 35, 1760, + /* 560 */ 1969, 42, 40, 39, 38, 37, 1390, 1391, 47, 1441, + /* 570 */ 1444, 1445, 1446, 1447, 1448, 1449, 1450, 617, 613, 1459, + /* 580 */ 1460, 1462, 1463, 1464, 1465, 1467, 1470, 2, 43, 41, + /* 590 */ 1937, 1987, 177, 25, 411, 446, 365, 592, 1386, 586, + /* 600 */ 340, 1115, 1392, 1114, 1937, 561, 621, 412, 9, 1466, + /* 610 */ 7, 1384, 1878, 1817, 1817, 607, 211, 2028, 36, 35, + /* 620 */ 369, 332, 42, 40, 39, 38, 37, 6, 1632, 1815, + /* 630 */ 1815, 1968, 1116, 1955, 1461, 2003, 531, 583, 101, 1970, + /* 640 */ 625, 1972, 1973, 620, 1951, 615, 1392, 1563, 605, 529, + /* 650 */ 171, 527, 2056, 190, 189, 583, 359, 2052, 2071, 43, + /* 660 */ 41, 341, 409, 339, 338, 671, 504, 365, 132, 1386, + /* 670 */ 506, 44, 1937, 328, 1947, 1953, 360, 1749, 2083, 1764, + /* 680 */ 1466, 399, 1384, 1414, 2067, 615, 132, 571, 1540, 567, + /* 690 */ 562, 2126, 505, 712, 1411, 558, 557, 1561, 1562, 1564, + /* 700 */ 1565, 1566, 545, 401, 397, 1461, 570, 174, 1468, 1469, + /* 710 */ 1631, 2127, 572, 228, 1495, 2131, 1630, 1392, 177, 2126, + /* 720 */ 36, 35, 605, 1751, 42, 40, 39, 38, 37, 173, + /* 730 */ 2064, 2065, 1414, 130, 2069, 2130, 418, 1442, 1451, 2127, + /* 740 */ 2129, 2131, 12, 2071, 1476, 2126, 585, 172, 2064, 2065, + /* 750 */ 1411, 130, 2069, 1764, 1937, 1747, 1387, 609, 1385, 2028, + /* 760 */ 1937, 2130, 506, 1629, 712, 2127, 2128, 36, 35, 2066, + /* 770 */ 1496, 42, 40, 39, 38, 37, 1361, 1362, 134, 1468, + /* 780 */ 1469, 2027, 1390, 1391, 505, 1441, 1444, 1445, 1446, 1447, + /* 790 */ 1448, 1449, 1450, 617, 613, 1459, 1460, 1462, 1463, 1464, + /* 800 */ 1465, 1467, 1470, 2, 320, 2130, 1409, 1937, 1442, 1451, + /* 810 */ 1115, 232, 1114, 440, 683, 681, 453, 36, 35, 452, + /* 820 */ 1860, 42, 40, 39, 38, 37, 183, 1387, 1677, 1385, + /* 830 */ 651, 182, 1529, 1808, 424, 1443, 454, 1628, 1533, 426, + /* 840 */ 1627, 1116, 32, 363, 1490, 1491, 1492, 1493, 1494, 1498, + /* 850 */ 1499, 1500, 1501, 1390, 1391, 1552, 1441, 1444, 1445, 1446, + /* 860 */ 1447, 1448, 1449, 1450, 617, 613, 1459, 1460, 1462, 1463, + /* 870 */ 1464, 1465, 1467, 1470, 2, 237, 29, 1626, 616, 1625, + /* 880 */ 336, 1937, 36, 35, 1937, 649, 42, 40, 39, 38, + /* 890 */ 37, 1443, 414, 689, 688, 687, 686, 375, 1622, 685, + /* 900 */ 684, 136, 679, 678, 677, 676, 675, 674, 673, 149, + /* 910 */ 669, 668, 667, 374, 373, 664, 663, 662, 661, 660, + /* 920 */ 1621, 1937, 450, 1937, 1969, 445, 444, 443, 442, 439, + /* 930 */ 438, 437, 436, 435, 431, 430, 429, 428, 337, 421, + /* 940 */ 420, 419, 1937, 416, 415, 334, 1620, 1969, 1619, 1860, + /* 950 */ 1860, 291, 362, 361, 1794, 1987, 1618, 605, 605, 1414, + /* 960 */ 184, 188, 1400, 622, 1937, 605, 605, 1617, 1937, 1741, + /* 970 */ 621, 432, 433, 1466, 156, 1393, 1411, 583, 1987, 372, + /* 980 */ 480, 1604, 672, 1767, 1734, 1817, 622, 1624, 1764, 1764, + /* 990 */ 1937, 1937, 1937, 621, 377, 1968, 1764, 1764, 1461, 2003, + /* 1000 */ 1937, 1816, 101, 1970, 625, 1972, 1973, 620, 132, 615, + /* 1010 */ 1392, 1937, 1101, 1102, 2146, 1616, 2056, 1719, 1968, 1615, + /* 1020 */ 359, 2052, 2003, 1847, 1614, 101, 1970, 625, 1972, 1973, + /* 1030 */ 620, 2090, 615, 1969, 575, 31, 550, 2146, 2096, 2056, + /* 1040 */ 2126, 36, 35, 359, 2052, 42, 40, 39, 38, 37, + /* 1050 */ 655, 2076, 1529, 1808, 2120, 2132, 174, 611, 1924, 1937, + /* 1060 */ 2127, 572, 656, 1937, 1987, 1808, 574, 212, 1937, 175, + /* 1070 */ 2064, 2065, 622, 130, 2069, 210, 657, 1937, 1603, 621, + /* 1080 */ 1532, 1667, 163, 1660, 48, 138, 3, 126, 498, 494, + /* 1090 */ 490, 486, 209, 68, 254, 147, 146, 654, 653, 652, + /* 1100 */ 144, 578, 236, 518, 1968, 520, 387, 535, 2003, 534, + /* 1110 */ 1969, 101, 1970, 625, 1972, 1973, 620, 1443, 615, 605, + /* 1120 */ 1401, 217, 1396, 2146, 215, 2056, 1606, 1607, 82, 359, + /* 1130 */ 2052, 207, 1395, 1761, 1969, 665, 219, 235, 1386, 218, + /* 1140 */ 2075, 1987, 61, 76, 61, 241, 1404, 1406, 657, 622, + /* 1150 */ 1764, 1384, 605, 1658, 1937, 1394, 621, 1163, 613, 1459, + /* 1160 */ 1460, 1462, 1463, 1464, 1465, 1987, 140, 147, 146, 654, + /* 1170 */ 653, 652, 144, 622, 427, 523, 84, 612, 1937, 1969, + /* 1180 */ 621, 1968, 559, 1764, 221, 2003, 1392, 220, 101, 1970, + /* 1190 */ 625, 1972, 1973, 620, 1560, 615, 1559, 243, 206, 200, + /* 1200 */ 2031, 205, 2056, 45, 477, 1968, 359, 2052, 248, 2003, + /* 1210 */ 1987, 1739, 101, 1970, 625, 1972, 1973, 620, 622, 615, + /* 1220 */ 198, 11, 10, 1937, 2029, 621, 2056, 1988, 376, 265, + /* 1230 */ 359, 2052, 605, 712, 1969, 36, 35, 605, 1869, 42, + /* 1240 */ 40, 39, 38, 37, 1648, 141, 546, 143, 145, 61, + /* 1250 */ 1968, 587, 605, 605, 2003, 1331, 576, 101, 1970, 625, + /* 1260 */ 1972, 1973, 620, 1764, 615, 1987, 272, 602, 1764, 608, + /* 1270 */ 1805, 2056, 605, 622, 223, 359, 2052, 222, 1937, 1398, + /* 1280 */ 621, 270, 538, 1764, 1764, 2086, 603, 36, 35, 584, + /* 1290 */ 1969, 42, 40, 39, 38, 37, 1387, 597, 1385, 274, + /* 1300 */ 1215, 1503, 1397, 1764, 45, 1968, 1958, 45, 629, 2003, + /* 1310 */ 143, 145, 102, 1970, 625, 1972, 1973, 620, 657, 615, + /* 1320 */ 1487, 1987, 1390, 1391, 550, 579, 2056, 1654, 2126, 622, + /* 1330 */ 2055, 2052, 127, 605, 1937, 1969, 621, 147, 146, 654, + /* 1340 */ 653, 652, 144, 2132, 174, 666, 143, 278, 2127, 572, + /* 1350 */ 1144, 256, 253, 4, 1960, 1, 1452, 381, 1969, 290, + /* 1360 */ 1243, 1968, 1247, 1254, 1764, 2003, 1987, 1161, 102, 1970, + /* 1370 */ 625, 1972, 1973, 620, 622, 615, 707, 386, 333, 1937, + /* 1380 */ 1348, 621, 2056, 285, 1252, 1145, 610, 2052, 187, 1987, + /* 1390 */ 155, 413, 1414, 1870, 417, 448, 422, 619, 148, 1409, + /* 1400 */ 434, 1862, 1937, 441, 621, 447, 623, 455, 449, 191, + /* 1410 */ 2003, 456, 458, 102, 1970, 625, 1972, 1973, 620, 460, + /* 1420 */ 615, 1415, 461, 470, 1417, 473, 474, 2056, 197, 1968, + /* 1430 */ 199, 327, 2052, 2003, 1416, 475, 313, 1970, 625, 1972, + /* 1440 */ 1973, 620, 618, 615, 606, 2021, 1969, 1418, 202, 476, + /* 1450 */ 204, 478, 79, 80, 208, 1118, 482, 501, 539, 1915, + /* 1460 */ 503, 499, 1969, 500, 537, 322, 1754, 104, 214, 540, + /* 1470 */ 286, 2087, 541, 230, 1912, 1750, 216, 1987, 544, 233, + /* 1480 */ 547, 560, 150, 595, 151, 622, 2102, 1752, 1748, 152, + /* 1490 */ 1937, 153, 621, 1987, 5, 2101, 2078, 569, 1911, 247, + /* 1500 */ 555, 622, 553, 164, 249, 552, 1937, 251, 621, 250, + /* 1510 */ 554, 350, 556, 349, 563, 2149, 580, 1968, 1969, 2097, + /* 1520 */ 577, 2003, 1529, 239, 160, 1970, 625, 1972, 1973, 620, + /* 1530 */ 242, 615, 131, 1968, 2125, 255, 1413, 2003, 261, 1419, + /* 1540 */ 160, 1970, 625, 1972, 1973, 620, 1969, 615, 252, 1987, + /* 1550 */ 2072, 588, 1874, 353, 593, 287, 288, 622, 594, 1883, + /* 1560 */ 1882, 1881, 1937, 355, 621, 551, 2093, 598, 89, 599, + /* 1570 */ 58, 91, 289, 1765, 2037, 93, 627, 1987, 1735, 1809, + /* 1580 */ 292, 281, 2094, 709, 708, 622, 49, 711, 301, 1968, + /* 1590 */ 1937, 316, 621, 2003, 294, 315, 307, 1970, 625, 1972, + /* 1600 */ 1973, 620, 324, 615, 305, 296, 1931, 1930, 1969, 325, + /* 1610 */ 72, 1929, 1928, 73, 1925, 383, 384, 1968, 1378, 1379, + /* 1620 */ 715, 2003, 180, 1923, 161, 1970, 625, 1972, 1973, 620, + /* 1630 */ 388, 615, 390, 391, 284, 392, 1922, 394, 1921, 1987, + /* 1640 */ 568, 1920, 398, 396, 354, 1919, 1351, 622, 400, 167, + /* 1650 */ 1350, 1894, 1937, 1893, 621, 705, 701, 697, 693, 282, + /* 1660 */ 405, 1892, 406, 1969, 1309, 1855, 1854, 1852, 137, 1851, + /* 1670 */ 1850, 1853, 1849, 1848, 1846, 1845, 1844, 2148, 1891, 1968, + /* 1680 */ 185, 423, 1843, 2003, 425, 1842, 314, 1970, 625, 1972, + /* 1690 */ 1973, 620, 1841, 615, 1987, 99, 1840, 1839, 275, 1838, + /* 1700 */ 1837, 1836, 619, 1835, 1834, 1833, 1832, 1937, 1831, 621, + /* 1710 */ 1830, 1829, 1828, 1827, 1826, 1825, 1824, 1823, 1822, 139, + /* 1720 */ 1311, 1821, 1820, 451, 1819, 1969, 1190, 1682, 1681, 1679, + /* 1730 */ 1643, 601, 1818, 70, 1968, 195, 1957, 192, 2003, 193, + /* 1740 */ 1642, 313, 1970, 625, 1972, 1973, 620, 1104, 615, 466, + /* 1750 */ 2022, 169, 1103, 1907, 1901, 1969, 1987, 1890, 1889, 1872, + /* 1760 */ 196, 364, 71, 203, 622, 1743, 468, 1678, 262, 1937, + /* 1770 */ 201, 621, 1676, 1137, 483, 485, 1674, 487, 1672, 491, + /* 1780 */ 489, 1670, 484, 488, 1657, 1355, 1987, 231, 493, 497, + /* 1790 */ 495, 366, 1656, 492, 622, 496, 1968, 1639, 1745, 1937, + /* 1800 */ 2003, 621, 1258, 314, 1970, 625, 1972, 1973, 620, 1259, + /* 1810 */ 615, 1744, 1181, 1969, 1180, 680, 1173, 1179, 1178, 682, + /* 1820 */ 1175, 1174, 1172, 1668, 342, 1661, 1968, 213, 343, 1969, + /* 1830 */ 2003, 1659, 344, 314, 1970, 625, 1972, 1973, 620, 521, + /* 1840 */ 615, 60, 524, 1638, 1987, 1637, 1636, 526, 528, 530, + /* 1850 */ 1366, 1368, 622, 103, 1365, 1906, 1370, 1937, 24, 621, + /* 1860 */ 1987, 1357, 1900, 154, 542, 1888, 1886, 2131, 622, 1576, + /* 1870 */ 14, 18, 17, 1937, 1969, 621, 56, 62, 57, 245, + /* 1880 */ 15, 28, 19, 26, 536, 238, 246, 240, 2003, 1558, + /* 1890 */ 1969, 309, 1970, 625, 1972, 1973, 620, 1551, 615, 162, + /* 1900 */ 1968, 1958, 1591, 244, 2003, 1987, 53, 298, 1970, 625, + /* 1910 */ 1972, 1973, 620, 622, 615, 543, 234, 548, 1937, 27, + /* 1920 */ 621, 1987, 1590, 351, 346, 1596, 258, 1595, 1594, 622, + /* 1930 */ 352, 85, 165, 54, 1937, 1887, 621, 1597, 55, 1885, + /* 1940 */ 1526, 1884, 1871, 1525, 263, 1968, 20, 88, 264, 2003, + /* 1950 */ 276, 266, 299, 1970, 625, 1972, 1973, 620, 271, 615, + /* 1960 */ 21, 1968, 596, 273, 1556, 2003, 87, 1969, 300, 1970, + /* 1970 */ 625, 1972, 1973, 620, 94, 615, 90, 10, 1402, 2006, + /* 1980 */ 166, 178, 1456, 1434, 614, 628, 1454, 367, 626, 632, + /* 1990 */ 1478, 1969, 1453, 34, 8, 13, 1477, 22, 1987, 635, + /* 2000 */ 1426, 1488, 23, 1221, 638, 1244, 622, 630, 624, 1241, + /* 2010 */ 633, 1937, 636, 621, 1238, 1232, 639, 641, 1230, 642, + /* 2020 */ 1236, 648, 1987, 95, 1235, 1234, 96, 279, 1253, 1233, + /* 2030 */ 622, 69, 1249, 1169, 1135, 1937, 658, 621, 1968, 1168, + /* 2040 */ 1167, 1166, 2003, 1165, 1164, 306, 1970, 625, 1972, 1973, + /* 2050 */ 620, 1162, 615, 1969, 1160, 1159, 1158, 1188, 670, 280, + /* 2060 */ 1156, 1155, 1968, 1154, 1153, 1152, 2003, 1151, 1150, 310, + /* 2070 */ 1970, 625, 1972, 1973, 620, 1183, 615, 1185, 1147, 1146, + /* 2080 */ 1143, 1142, 1141, 1969, 1987, 1140, 1675, 690, 692, 691, + /* 2090 */ 1673, 694, 622, 1671, 696, 695, 698, 1937, 700, 621, + /* 2100 */ 1669, 699, 702, 704, 1655, 703, 706, 1093, 1635, 283, + /* 2110 */ 710, 1610, 714, 1388, 1987, 1610, 293, 713, 1610, 1610, + /* 2120 */ 1610, 1610, 622, 1610, 1968, 1610, 1610, 1937, 2003, 621, + /* 2130 */ 1610, 302, 1970, 625, 1972, 1973, 620, 1610, 615, 1610, + /* 2140 */ 1610, 1969, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2150 */ 1610, 1610, 1610, 1610, 1968, 1610, 1610, 1969, 2003, 1610, + /* 2160 */ 1610, 311, 1970, 625, 1972, 1973, 620, 1610, 615, 1610, + /* 2170 */ 1610, 1610, 1987, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2180 */ 622, 1610, 1610, 1610, 1610, 1937, 1610, 621, 1987, 1610, + /* 2190 */ 1610, 1610, 1610, 1610, 1610, 1610, 622, 1610, 1610, 1610, + /* 2200 */ 1610, 1937, 1969, 621, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2210 */ 1610, 1610, 1968, 1610, 1610, 1610, 2003, 1610, 1969, 303, + /* 2220 */ 1970, 625, 1972, 1973, 620, 1610, 615, 1610, 1968, 1610, + /* 2230 */ 1610, 1610, 2003, 1987, 1610, 312, 1970, 625, 1972, 1973, + /* 2240 */ 620, 622, 615, 1610, 1610, 1610, 1937, 1610, 621, 1987, + /* 2250 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 622, 1610, 1610, + /* 2260 */ 1610, 1610, 1937, 1610, 621, 1610, 1610, 1610, 1610, 1610, + /* 2270 */ 1610, 1610, 1610, 1968, 1610, 1610, 1610, 2003, 1610, 1610, + /* 2280 */ 304, 1970, 625, 1972, 1973, 620, 1610, 615, 1610, 1968, + /* 2290 */ 1610, 1610, 1610, 2003, 1610, 1969, 317, 1970, 625, 1972, + /* 2300 */ 1973, 620, 1610, 615, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2310 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1969, + /* 2320 */ 1610, 1610, 1610, 1610, 1610, 1610, 1987, 1610, 1610, 1610, + /* 2330 */ 1610, 1610, 1610, 1610, 622, 1610, 1610, 1610, 1610, 1937, + /* 2340 */ 1610, 621, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2350 */ 1987, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 622, 1610, + /* 2360 */ 1610, 1610, 1610, 1937, 1610, 621, 1968, 1610, 1610, 1610, + /* 2370 */ 2003, 1610, 1610, 318, 1970, 625, 1972, 1973, 620, 1610, + /* 2380 */ 615, 1969, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2390 */ 1968, 1610, 1610, 1610, 2003, 1610, 1610, 1981, 1970, 625, + /* 2400 */ 1972, 1973, 620, 1610, 615, 1610, 1610, 1610, 1610, 1610, + /* 2410 */ 1610, 1969, 1987, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2420 */ 622, 1610, 1610, 1610, 1610, 1937, 1610, 621, 1610, 1610, + /* 2430 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2440 */ 1610, 1610, 1987, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2450 */ 622, 1610, 1968, 1610, 1610, 1937, 2003, 621, 1610, 1980, + /* 2460 */ 1970, 625, 1972, 1973, 620, 1610, 615, 1610, 1610, 1969, + /* 2470 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2480 */ 1610, 1610, 1968, 1610, 1610, 1969, 2003, 1610, 1610, 1979, + /* 2490 */ 1970, 625, 1972, 1973, 620, 1610, 615, 1610, 1610, 1610, + /* 2500 */ 1987, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 622, 1610, + /* 2510 */ 1610, 1610, 1610, 1937, 1610, 621, 1987, 1610, 1610, 1610, + /* 2520 */ 1610, 1610, 1610, 1610, 622, 1610, 1610, 1610, 1610, 1937, + /* 2530 */ 1969, 621, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2540 */ 1968, 1610, 1610, 1610, 2003, 1610, 1969, 329, 1970, 625, + /* 2550 */ 1972, 1973, 620, 1610, 615, 1610, 1968, 1610, 1610, 1610, + /* 2560 */ 2003, 1987, 1610, 330, 1970, 625, 1972, 1973, 620, 622, + /* 2570 */ 615, 1610, 1610, 1610, 1937, 1610, 621, 1987, 1610, 1610, + /* 2580 */ 1610, 1610, 1610, 1610, 1610, 622, 1610, 1610, 1610, 1610, + /* 2590 */ 1937, 1610, 621, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2600 */ 1610, 1968, 1610, 1610, 1610, 2003, 1610, 1610, 326, 1970, + /* 2610 */ 625, 1972, 1973, 620, 1610, 615, 1610, 1968, 1610, 1610, + /* 2620 */ 1610, 2003, 1610, 1969, 331, 1970, 625, 1972, 1973, 620, + /* 2630 */ 1610, 615, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, + /* 2640 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1969, 1610, 1610, + /* 2650 */ 1610, 1610, 1610, 1610, 1987, 1610, 1610, 1610, 1610, 1610, + /* 2660 */ 1610, 1610, 622, 1610, 1610, 1610, 1610, 1937, 1610, 621, + /* 2670 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1987, 1610, + /* 2680 */ 1610, 1610, 1610, 1610, 1610, 1610, 622, 1610, 1610, 1610, + /* 2690 */ 1610, 1937, 1610, 621, 623, 1610, 1610, 1610, 2003, 1610, + /* 2700 */ 1610, 309, 1970, 625, 1972, 1973, 620, 1610, 615, 1610, + /* 2710 */ 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1610, 1968, 1610, + /* 2720 */ 1610, 1610, 2003, 1610, 1610, 308, 1970, 625, 1972, 1973, + /* 2730 */ 620, 1610, 615, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 331, 369, 333, 334, 372, 373, 389, 327, 360, 420, @@ -519,8 +519,8 @@ static const YYCODETYPE yy_lookahead[] = { /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 95, 335, /* 230 */ 401, 402, 161, 162, 427, 428, 429, 20, 431, 432, /* 240 */ 20, 412, 435, 349, 14, 20, 65, 66, 67, 358, - /* 250 */ 20, 180, 127, 182, 73, 74, 163, 450, 451, 78, - /* 260 */ 366, 168, 455, 456, 83, 84, 62, 134, 8, 9, + /* 250 */ 20, 180, 127, 182, 73, 74, 131, 450, 451, 78, + /* 260 */ 366, 163, 455, 456, 83, 84, 168, 134, 8, 9, /* 270 */ 89, 380, 12, 13, 14, 15, 16, 206, 207, 389, /* 280 */ 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 4, @@ -547,8 +547,8 @@ static const YYCODETYPE yy_lookahead[] = { /* 500 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, /* 510 */ 221, 222, 223, 224, 225, 226, 227, 344, 345, 375, /* 520 */ 163, 161, 162, 0, 21, 335, 245, 24, 25, 26, - /* 530 */ 27, 28, 29, 30, 31, 32, 341, 20, 245, 349, - /* 540 */ 180, 326, 182, 328, 21, 70, 327, 24, 25, 26, + /* 530 */ 27, 28, 29, 30, 31, 32, 341, 62, 245, 349, + /* 540 */ 180, 326, 182, 328, 21, 20, 327, 24, 25, 26, /* 550 */ 27, 28, 29, 30, 31, 32, 366, 8, 9, 364, /* 560 */ 327, 12, 13, 14, 15, 16, 206, 207, 95, 209, /* 570 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, @@ -560,7 +560,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 630 */ 374, 398, 51, 360, 58, 402, 21, 335, 405, 406, /* 640 */ 407, 408, 409, 410, 371, 412, 70, 206, 335, 34, /* 650 */ 417, 36, 419, 137, 138, 335, 423, 424, 404, 12, - /* 660 */ 13, 98, 349, 100, 101, 359, 103, 20, 366, 22, + /* 660 */ 13, 98, 349, 100, 101, 70, 103, 20, 366, 22, /* 670 */ 107, 95, 371, 63, 401, 402, 403, 359, 445, 366, /* 680 */ 33, 175, 35, 20, 430, 412, 366, 431, 14, 250, /* 690 */ 251, 435, 129, 117, 20, 254, 255, 256, 257, 258, @@ -582,7 +582,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 850 */ 240, 241, 242, 206, 207, 96, 209, 210, 211, 212, /* 860 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, /* 870 */ 223, 224, 225, 226, 227, 163, 2, 327, 359, 327, - /* 880 */ 94, 371, 8, 9, 371, 328, 12, 13, 14, 15, + /* 880 */ 94, 371, 8, 9, 371, 359, 12, 13, 14, 15, /* 890 */ 16, 161, 106, 65, 66, 67, 68, 69, 327, 71, /* 900 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, /* 910 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, @@ -592,18 +592,18 @@ static const YYCODETYPE yy_lookahead[] = { /* 950 */ 366, 351, 12, 13, 354, 358, 327, 335, 335, 20, /* 960 */ 377, 377, 22, 366, 371, 335, 335, 327, 371, 0, /* 970 */ 373, 349, 349, 33, 358, 35, 20, 335, 358, 349, - /* 980 */ 349, 172, 346, 367, 348, 358, 366, 381, 366, 366, + /* 980 */ 349, 172, 346, 367, 348, 358, 366, 328, 366, 366, /* 990 */ 371, 371, 371, 373, 389, 398, 366, 366, 58, 402, /* 1000 */ 371, 374, 405, 406, 407, 408, 409, 410, 366, 412, /* 1010 */ 70, 371, 45, 46, 417, 327, 419, 347, 398, 327, /* 1020 */ 423, 424, 402, 0, 327, 405, 406, 407, 408, 409, - /* 1030 */ 410, 434, 412, 327, 44, 2, 431, 417, 459, 419, + /* 1030 */ 410, 434, 412, 327, 44, 2, 431, 417, 381, 419, /* 1040 */ 435, 8, 9, 423, 424, 12, 13, 14, 15, 16, /* 1050 */ 368, 243, 244, 371, 434, 450, 451, 117, 0, 371, /* 1060 */ 455, 456, 368, 371, 358, 371, 264, 33, 371, 427, /* 1070 */ 428, 429, 366, 431, 432, 337, 107, 371, 269, 373, /* 1080 */ 246, 0, 48, 0, 42, 42, 44, 44, 54, 55, - /* 1090 */ 56, 57, 58, 106, 448, 126, 127, 128, 129, 130, + /* 1090 */ 56, 57, 58, 106, 459, 126, 127, 128, 129, 130, /* 1100 */ 131, 44, 163, 22, 398, 22, 48, 192, 402, 194, /* 1110 */ 327, 405, 406, 407, 408, 409, 410, 161, 412, 335, /* 1120 */ 180, 99, 182, 417, 102, 419, 132, 133, 94, 423, @@ -612,100 +612,100 @@ static const YYCODETYPE yy_lookahead[] = { /* 1150 */ 366, 35, 335, 0, 371, 35, 373, 35, 218, 219, /* 1160 */ 220, 221, 222, 223, 224, 358, 349, 126, 127, 128, /* 1170 */ 129, 130, 131, 366, 151, 22, 97, 63, 371, 327, - /* 1180 */ 373, 398, 442, 366, 99, 402, 70, 102, 405, 406, + /* 1180 */ 373, 398, 448, 366, 99, 402, 70, 102, 405, 406, /* 1190 */ 407, 408, 409, 410, 96, 412, 96, 96, 164, 165, - /* 1200 */ 417, 167, 419, 44, 170, 398, 423, 424, 358, 402, + /* 1200 */ 417, 167, 419, 44, 170, 398, 423, 424, 442, 402, /* 1210 */ 358, 0, 405, 406, 407, 408, 409, 410, 366, 412, - /* 1220 */ 186, 1, 2, 371, 417, 373, 419, 337, 381, 44, - /* 1230 */ 423, 424, 335, 117, 327, 8, 9, 335, 334, 12, - /* 1240 */ 13, 14, 15, 16, 381, 44, 349, 44, 44, 44, + /* 1220 */ 186, 1, 2, 371, 417, 373, 419, 358, 337, 44, + /* 1230 */ 423, 424, 335, 117, 327, 8, 9, 335, 381, 12, + /* 1240 */ 13, 14, 15, 16, 334, 44, 349, 44, 44, 44, /* 1250 */ 398, 349, 335, 335, 402, 96, 266, 405, 406, 407, /* 1260 */ 408, 409, 410, 366, 412, 358, 349, 349, 366, 417, /* 1270 */ 370, 419, 335, 366, 99, 423, 424, 102, 371, 182, - /* 1280 */ 373, 96, 389, 366, 366, 452, 349, 8, 9, 433, + /* 1280 */ 373, 96, 389, 366, 366, 381, 349, 8, 9, 433, /* 1290 */ 327, 12, 13, 14, 15, 16, 180, 96, 182, 96, /* 1300 */ 96, 96, 182, 366, 44, 398, 47, 44, 44, 402, /* 1310 */ 44, 44, 405, 406, 407, 408, 409, 410, 107, 412, /* 1320 */ 206, 358, 206, 207, 431, 268, 419, 0, 435, 366, /* 1330 */ 423, 424, 44, 335, 371, 327, 373, 126, 127, 128, /* 1340 */ 129, 130, 131, 450, 451, 13, 44, 349, 455, 456, - /* 1350 */ 35, 425, 436, 247, 95, 400, 96, 48, 327, 96, + /* 1350 */ 35, 452, 425, 247, 95, 436, 96, 400, 327, 96, /* 1360 */ 96, 398, 96, 96, 366, 402, 358, 35, 405, 406, - /* 1370 */ 407, 408, 409, 410, 366, 412, 49, 399, 178, 371, - /* 1380 */ 391, 373, 419, 42, 96, 70, 423, 424, 378, 358, - /* 1390 */ 163, 20, 381, 378, 160, 376, 20, 366, 96, 335, - /* 1400 */ 335, 93, 371, 378, 373, 376, 398, 335, 376, 343, - /* 1410 */ 402, 335, 335, 405, 406, 407, 408, 409, 410, 20, - /* 1420 */ 412, 329, 329, 20, 373, 395, 20, 419, 341, 398, + /* 1370 */ 407, 408, 409, 410, 366, 412, 49, 48, 399, 371, + /* 1380 */ 178, 373, 419, 391, 96, 70, 423, 424, 42, 358, + /* 1390 */ 163, 378, 20, 381, 378, 160, 376, 366, 96, 20, + /* 1400 */ 335, 335, 371, 378, 373, 376, 398, 93, 376, 335, + /* 1410 */ 402, 343, 335, 405, 406, 407, 408, 409, 410, 335, + /* 1420 */ 412, 20, 329, 329, 20, 395, 373, 419, 341, 398, /* 1430 */ 341, 423, 424, 402, 20, 336, 405, 406, 407, 408, - /* 1440 */ 409, 410, 411, 412, 413, 414, 327, 336, 341, 390, - /* 1450 */ 341, 341, 335, 341, 341, 329, 52, 371, 397, 338, - /* 1460 */ 358, 338, 327, 358, 195, 329, 358, 335, 395, 185, - /* 1470 */ 253, 381, 339, 358, 371, 381, 358, 358, 394, 339, - /* 1480 */ 335, 441, 358, 358, 252, 366, 358, 358, 358, 358, - /* 1490 */ 371, 441, 373, 358, 261, 171, 444, 443, 263, 262, - /* 1500 */ 373, 366, 439, 441, 248, 371, 371, 440, 373, 371, - /* 1510 */ 371, 270, 371, 438, 267, 460, 265, 398, 327, 244, - /* 1520 */ 366, 402, 454, 386, 405, 406, 407, 408, 409, 410, - /* 1530 */ 386, 412, 20, 398, 335, 453, 339, 402, 336, 20, + /* 1440 */ 409, 410, 411, 412, 413, 414, 327, 20, 341, 390, + /* 1450 */ 341, 336, 341, 341, 341, 52, 335, 329, 397, 371, + /* 1460 */ 358, 338, 327, 338, 195, 329, 358, 335, 358, 185, + /* 1470 */ 395, 381, 394, 339, 371, 358, 358, 358, 373, 339, + /* 1480 */ 335, 253, 358, 252, 358, 366, 441, 358, 358, 358, + /* 1490 */ 371, 358, 373, 358, 261, 441, 444, 171, 371, 443, + /* 1500 */ 263, 366, 262, 441, 440, 248, 371, 438, 373, 439, + /* 1510 */ 371, 270, 371, 371, 371, 460, 267, 398, 327, 381, + /* 1520 */ 265, 402, 244, 386, 405, 406, 407, 408, 409, 410, + /* 1530 */ 386, 412, 366, 398, 454, 453, 20, 402, 339, 20, /* 1540 */ 405, 406, 407, 408, 409, 410, 327, 412, 400, 358, - /* 1550 */ 404, 384, 386, 371, 371, 371, 386, 366, 371, 371, - /* 1560 */ 371, 165, 371, 383, 373, 446, 447, 339, 354, 339, - /* 1570 */ 95, 422, 366, 95, 362, 335, 36, 358, 371, 348, - /* 1580 */ 330, 339, 447, 329, 392, 366, 396, 325, 352, 398, - /* 1590 */ 371, 352, 373, 402, 0, 387, 405, 406, 407, 408, - /* 1600 */ 409, 410, 387, 412, 352, 340, 0, 187, 327, 0, - /* 1610 */ 0, 42, 0, 35, 35, 200, 35, 398, 35, 200, - /* 1620 */ 19, 402, 0, 35, 405, 406, 407, 408, 409, 410, - /* 1630 */ 35, 412, 200, 0, 33, 200, 0, 35, 0, 358, - /* 1640 */ 449, 22, 0, 35, 363, 182, 180, 366, 0, 48, - /* 1650 */ 0, 175, 371, 176, 373, 54, 55, 56, 57, 58, - /* 1660 */ 0, 0, 47, 327, 151, 42, 0, 0, 0, 0, - /* 1670 */ 0, 0, 0, 0, 35, 0, 151, 458, 0, 398, - /* 1680 */ 0, 0, 0, 402, 0, 0, 405, 406, 407, 408, + /* 1550 */ 404, 335, 384, 336, 371, 386, 386, 366, 371, 371, + /* 1560 */ 371, 371, 371, 371, 373, 446, 447, 165, 339, 383, + /* 1570 */ 95, 339, 354, 366, 422, 95, 362, 358, 348, 371, + /* 1580 */ 335, 339, 447, 330, 36, 366, 392, 329, 352, 398, + /* 1590 */ 371, 396, 373, 402, 340, 352, 405, 406, 407, 408, + /* 1600 */ 409, 410, 387, 412, 352, 325, 0, 0, 327, 387, + /* 1610 */ 187, 0, 0, 42, 0, 35, 200, 398, 35, 35, + /* 1620 */ 19, 402, 35, 0, 405, 406, 407, 408, 409, 410, + /* 1630 */ 200, 412, 35, 35, 33, 200, 0, 200, 0, 358, + /* 1640 */ 449, 0, 22, 35, 363, 0, 182, 366, 35, 48, + /* 1650 */ 180, 0, 371, 0, 373, 54, 55, 56, 57, 58, + /* 1660 */ 176, 0, 175, 327, 47, 0, 0, 0, 42, 0, + /* 1670 */ 0, 0, 0, 0, 0, 0, 0, 458, 0, 398, + /* 1680 */ 151, 35, 0, 402, 151, 0, 405, 406, 407, 408, /* 1690 */ 409, 410, 0, 412, 358, 94, 0, 0, 97, 0, /* 1700 */ 0, 0, 366, 0, 0, 0, 0, 371, 0, 373, - /* 1710 */ 0, 0, 0, 0, 0, 0, 42, 22, 0, 0, - /* 1720 */ 0, 135, 0, 0, 35, 327, 39, 44, 42, 0, - /* 1730 */ 14, 130, 0, 0, 398, 58, 0, 58, 402, 0, - /* 1740 */ 47, 405, 406, 407, 408, 409, 410, 0, 412, 47, - /* 1750 */ 414, 14, 0, 0, 47, 327, 358, 40, 171, 0, - /* 1760 */ 39, 363, 0, 39, 366, 0, 0, 0, 167, 371, - /* 1770 */ 35, 373, 0, 64, 0, 48, 35, 39, 48, 39, - /* 1780 */ 35, 39, 48, 0, 35, 184, 358, 186, 0, 39, - /* 1790 */ 0, 363, 48, 0, 366, 0, 398, 22, 104, 371, - /* 1800 */ 402, 373, 0, 405, 406, 407, 408, 409, 410, 22, - /* 1810 */ 412, 35, 35, 327, 35, 35, 35, 44, 0, 35, - /* 1820 */ 35, 35, 44, 22, 0, 22, 398, 102, 0, 327, - /* 1830 */ 402, 22, 50, 405, 406, 407, 408, 409, 410, 35, - /* 1840 */ 412, 0, 35, 0, 358, 35, 0, 22, 35, 20, - /* 1850 */ 35, 35, 366, 96, 0, 95, 35, 371, 0, 373, - /* 1860 */ 358, 163, 22, 0, 0, 3, 44, 249, 366, 249, - /* 1870 */ 44, 183, 3, 371, 327, 373, 44, 44, 47, 44, - /* 1880 */ 249, 47, 44, 35, 398, 96, 95, 95, 402, 95, - /* 1890 */ 327, 405, 406, 407, 408, 409, 410, 169, 412, 47, - /* 1900 */ 398, 96, 96, 95, 402, 358, 163, 405, 406, 407, - /* 1910 */ 408, 409, 410, 366, 412, 95, 165, 163, 371, 96, - /* 1920 */ 373, 358, 95, 35, 35, 35, 44, 35, 35, 366, - /* 1930 */ 47, 0, 96, 96, 371, 96, 373, 0, 96, 0, - /* 1940 */ 95, 47, 0, 96, 95, 398, 96, 39, 95, 402, - /* 1950 */ 95, 95, 405, 406, 407, 408, 409, 410, 47, 412, - /* 1960 */ 44, 398, 166, 164, 105, 402, 2, 327, 405, 406, - /* 1970 */ 407, 408, 409, 410, 243, 412, 228, 22, 22, 95, - /* 1980 */ 47, 96, 95, 47, 106, 230, 228, 35, 35, 35, - /* 1990 */ 95, 327, 96, 96, 95, 95, 35, 96, 358, 95, - /* 2000 */ 35, 96, 95, 206, 35, 96, 366, 95, 208, 96, - /* 2010 */ 95, 371, 95, 373, 96, 96, 95, 119, 22, 95, - /* 2020 */ 44, 119, 358, 95, 35, 119, 22, 107, 35, 119, - /* 2030 */ 366, 64, 35, 95, 63, 371, 35, 373, 398, 92, + /* 1710 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, + /* 1720 */ 22, 0, 0, 135, 0, 327, 35, 0, 0, 0, + /* 1730 */ 0, 130, 0, 39, 398, 42, 47, 58, 402, 58, + /* 1740 */ 0, 405, 406, 407, 408, 409, 410, 14, 412, 47, + /* 1750 */ 414, 44, 14, 0, 0, 327, 358, 0, 0, 0, + /* 1760 */ 40, 363, 39, 171, 366, 0, 47, 0, 167, 371, + /* 1770 */ 39, 373, 0, 64, 35, 39, 0, 35, 0, 35, + /* 1780 */ 39, 0, 48, 48, 0, 184, 358, 186, 39, 39, + /* 1790 */ 35, 363, 0, 48, 366, 48, 398, 0, 0, 371, + /* 1800 */ 402, 373, 22, 405, 406, 407, 408, 409, 410, 35, + /* 1810 */ 412, 0, 35, 327, 35, 44, 22, 35, 35, 44, + /* 1820 */ 35, 35, 35, 0, 22, 0, 398, 102, 22, 327, + /* 1830 */ 402, 0, 22, 405, 406, 407, 408, 409, 410, 50, + /* 1840 */ 412, 104, 35, 0, 358, 0, 0, 35, 35, 22, + /* 1850 */ 35, 35, 366, 20, 35, 0, 96, 371, 95, 373, + /* 1860 */ 358, 35, 0, 183, 22, 0, 0, 3, 366, 96, + /* 1870 */ 249, 249, 44, 371, 327, 373, 44, 3, 44, 44, + /* 1880 */ 249, 44, 44, 95, 398, 95, 47, 96, 402, 96, + /* 1890 */ 327, 405, 406, 407, 408, 409, 410, 96, 412, 95, + /* 1900 */ 398, 47, 35, 95, 402, 358, 163, 405, 406, 407, + /* 1910 */ 408, 409, 410, 366, 412, 163, 165, 169, 371, 95, + /* 1920 */ 373, 358, 35, 35, 163, 96, 47, 35, 35, 366, + /* 1930 */ 35, 95, 47, 243, 371, 0, 373, 96, 44, 0, + /* 1940 */ 96, 0, 0, 96, 47, 398, 95, 39, 96, 402, + /* 1950 */ 47, 95, 405, 406, 407, 408, 409, 410, 95, 412, + /* 1960 */ 44, 398, 166, 164, 96, 402, 95, 327, 405, 406, + /* 1970 */ 407, 408, 409, 410, 105, 412, 95, 2, 22, 95, + /* 1980 */ 47, 47, 96, 22, 95, 35, 96, 35, 106, 35, + /* 1990 */ 228, 327, 96, 95, 230, 95, 228, 95, 358, 35, + /* 2000 */ 96, 206, 95, 22, 35, 96, 366, 95, 208, 96, + /* 2010 */ 95, 371, 95, 373, 96, 96, 95, 35, 96, 95, + /* 2020 */ 119, 107, 358, 95, 119, 119, 95, 44, 35, 119, + /* 2030 */ 366, 95, 22, 35, 64, 371, 63, 373, 398, 35, /* 2040 */ 35, 35, 402, 35, 35, 405, 406, 407, 408, 409, - /* 2050 */ 410, 35, 412, 327, 35, 35, 70, 44, 35, 35, - /* 2060 */ 35, 22, 398, 35, 35, 35, 402, 35, 70, 405, - /* 2070 */ 406, 407, 408, 409, 410, 35, 412, 35, 35, 35, - /* 2080 */ 22, 35, 0, 327, 358, 35, 48, 39, 0, 48, - /* 2090 */ 35, 39, 366, 0, 35, 48, 39, 371, 0, 373, - /* 2100 */ 35, 48, 39, 0, 35, 35, 0, 22, 21, 461, - /* 2110 */ 461, 22, 22, 21, 358, 20, 461, 461, 461, 461, + /* 2050 */ 410, 35, 412, 327, 35, 35, 35, 70, 92, 44, + /* 2060 */ 35, 35, 398, 35, 22, 35, 402, 35, 35, 405, + /* 2070 */ 406, 407, 408, 409, 410, 35, 412, 70, 35, 35, + /* 2080 */ 35, 35, 22, 327, 358, 35, 0, 35, 39, 48, + /* 2090 */ 0, 35, 366, 0, 39, 48, 35, 371, 39, 373, + /* 2100 */ 0, 48, 35, 39, 0, 48, 35, 35, 0, 22, + /* 2110 */ 21, 461, 20, 22, 358, 461, 22, 21, 461, 461, /* 2120 */ 461, 461, 366, 461, 398, 461, 461, 371, 402, 373, /* 2130 */ 461, 405, 406, 407, 408, 409, 410, 461, 412, 461, /* 2140 */ 461, 327, 461, 461, 461, 461, 461, 461, 461, 461, @@ -769,9 +769,9 @@ static const YYCODETYPE yy_lookahead[] = { /* 2720 */ 461, 461, 402, 461, 461, 405, 406, 407, 408, 409, /* 2730 */ 410, 461, 412, }; -#define YY_SHIFT_COUNT (714) +#define YY_SHIFT_COUNT (715) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2106) +#define YY_SHIFT_MAX (2108) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 133, 0, 71, 0, 289, 289, 289, 289, 289, 289, /* 10 */ 289, 289, 289, 360, 576, 576, 647, 576, 576, 576, @@ -781,72 +781,72 @@ static const unsigned short int yy_shift_ofst[] = { /* 50 */ 58, 281, 473, 281, 110, 110, 940, 940, 940, 281, /* 60 */ 940, 940, 347, 281, 78, 78, 422, 422, 36, 51, /* 70 */ 230, 230, 78, 78, 78, 78, 78, 78, 78, 217, - /* 80 */ 78, 78, 204, 78, 78, 355, 78, 434, 78, 217, - /* 90 */ 456, 78, 78, 456, 78, 456, 456, 456, 78, 299, + /* 80 */ 78, 78, 299, 78, 78, 355, 78, 434, 78, 217, + /* 90 */ 456, 78, 78, 456, 78, 456, 456, 456, 78, 475, /* 100 */ 786, 610, 610, 503, 112, 1116, 1116, 1116, 1116, 1116, /* 110 */ 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, /* 120 */ 1116, 1116, 1116, 1116, 563, 357, 36, 51, 413, 117, - /* 130 */ 220, 220, 220, 429, 379, 379, 117, 517, 517, 517, - /* 140 */ 343, 434, 174, 456, 475, 456, 475, 475, 343, 532, + /* 130 */ 220, 220, 220, 429, 379, 379, 117, 525, 525, 525, + /* 140 */ 343, 434, 174, 456, 532, 456, 532, 532, 343, 595, /* 150 */ 323, 323, 323, 323, 323, 323, 323, 1601, 523, 181, /* 160 */ 712, 809, 441, 581, 439, 674, 730, 790, 663, 967, /* 170 */ 655, 939, 808, 588, 802, 808, 1042, 834, 956, 1106, - /* 180 */ 1309, 1200, 1341, 1371, 1341, 1234, 1376, 1376, 1341, 1234, - /* 190 */ 1234, 1308, 1376, 1376, 1376, 1399, 1399, 1403, 204, 434, - /* 200 */ 204, 1406, 1414, 204, 1406, 204, 204, 204, 1376, 204, - /* 210 */ 1404, 1404, 1399, 456, 456, 456, 456, 456, 456, 456, - /* 220 */ 456, 456, 456, 456, 1376, 1399, 475, 475, 1269, 1403, - /* 230 */ 299, 1284, 434, 299, 1376, 1371, 1371, 475, 1217, 1232, - /* 240 */ 475, 1217, 1232, 475, 475, 456, 1233, 1324, 1217, 1235, - /* 250 */ 1237, 1256, 1106, 1241, 1247, 1251, 1275, 517, 1512, 1376, - /* 260 */ 1406, 299, 1519, 1232, 475, 475, 475, 475, 475, 1232, - /* 270 */ 475, 1396, 299, 343, 299, 517, 1475, 1478, 475, 532, - /* 280 */ 1376, 299, 1540, 1399, 2733, 2733, 2733, 2733, 2733, 2733, - /* 290 */ 2733, 2733, 2733, 828, 1034, 457, 295, 260, 549, 759, - /* 300 */ 969, 874, 1033, 1227, 1211, 1279, 1279, 1279, 1279, 1279, - /* 310 */ 1279, 1279, 1279, 1279, 1041, 125, 13, 13, 506, 400, - /* 320 */ 516, 615, 587, 297, 297, 353, 53, 248, 353, 353, - /* 330 */ 353, 283, 1058, 572, 1043, 987, 1023, 1022, 1037, 1085, - /* 340 */ 1175, 1081, 1083, 1153, 915, 1079, 1098, 1100, 1101, 994, - /* 350 */ 990, 1057, 93, 1159, 1185, 1201, 1203, 1204, 1220, 1205, - /* 360 */ 1097, 1120, 1114, 1260, 1259, 1263, 1264, 1266, 1267, 1288, - /* 370 */ 1302, 40, 1122, 1332, 1315, 1327, 1594, 1606, 1420, 1609, - /* 380 */ 1610, 1569, 1612, 1578, 1415, 1579, 1581, 1583, 1419, 1622, - /* 390 */ 1588, 1595, 1432, 1633, 1435, 1636, 1602, 1638, 1619, 1642, - /* 400 */ 1608, 1463, 1466, 1648, 1650, 1477, 1476, 1660, 1661, 1615, - /* 410 */ 1678, 1680, 1681, 1623, 1666, 1667, 1668, 1669, 1670, 1671, - /* 420 */ 1672, 1673, 1513, 1639, 1675, 1525, 1682, 1684, 1685, 1692, - /* 430 */ 1696, 1697, 1699, 1700, 1701, 1703, 1704, 1705, 1706, 1708, - /* 440 */ 1710, 1674, 1711, 1712, 1713, 1714, 1715, 1695, 1718, 1719, - /* 450 */ 1720, 1586, 1722, 1723, 1689, 1732, 1677, 1733, 1679, 1736, - /* 460 */ 1739, 1686, 1687, 1683, 1693, 1716, 1702, 1737, 1707, 1729, - /* 470 */ 1717, 1721, 1747, 1752, 1753, 1724, 1587, 1759, 1762, 1765, - /* 480 */ 1709, 1766, 1767, 1735, 1727, 1738, 1772, 1741, 1730, 1740, - /* 490 */ 1774, 1745, 1734, 1742, 1783, 1749, 1744, 1750, 1788, 1790, - /* 500 */ 1793, 1795, 1694, 1725, 1776, 1775, 1802, 1777, 1779, 1780, - /* 510 */ 1781, 1773, 1778, 1784, 1785, 1787, 1786, 1818, 1801, 1824, - /* 520 */ 1803, 1782, 1828, 1809, 1804, 1841, 1807, 1843, 1810, 1846, - /* 530 */ 1825, 1829, 1813, 1815, 1816, 1757, 1760, 1854, 1698, 1821, - /* 540 */ 1858, 1688, 1840, 1743, 1751, 1863, 1864, 1754, 1728, 1862, - /* 550 */ 1822, 1618, 1791, 1789, 1792, 1805, 1826, 1832, 1806, 1794, - /* 560 */ 1808, 1820, 1823, 1833, 1831, 1834, 1827, 1835, 1620, 1836, - /* 570 */ 1837, 1869, 1838, 1631, 1848, 1888, 1889, 1890, 1892, 1893, - /* 580 */ 1839, 1842, 1852, 1731, 1882, 1883, 1931, 1937, 1939, 1693, - /* 590 */ 1894, 1845, 1847, 1850, 1849, 1853, 1796, 1855, 1942, 1908, - /* 600 */ 1799, 1856, 1859, 1693, 1911, 1916, 1748, 1755, 1758, 1964, - /* 610 */ 1955, 1797, 1884, 1885, 1887, 1896, 1895, 1897, 1933, 1899, - /* 620 */ 1900, 1936, 1901, 1956, 1800, 1904, 1878, 1905, 1952, 1953, - /* 630 */ 1907, 1909, 1954, 1912, 1913, 1961, 1915, 1918, 1965, 1917, - /* 640 */ 1919, 1969, 1921, 1898, 1902, 1906, 1910, 1996, 1920, 1924, - /* 650 */ 1976, 1928, 1989, 1938, 1976, 1976, 2004, 1967, 1971, 1993, - /* 660 */ 1997, 2001, 2005, 2006, 2008, 2009, 2016, 2019, 2020, 1986, - /* 670 */ 1947, 2013, 2023, 2024, 2025, 2039, 2028, 2029, 2030, 1998, - /* 680 */ 1773, 2032, 1778, 2040, 2042, 2043, 2044, 2058, 2046, 2082, - /* 690 */ 2050, 2038, 2048, 2088, 2055, 2041, 2052, 2093, 2059, 2047, - /* 700 */ 2057, 2098, 2065, 2053, 2063, 2103, 2069, 2070, 2106, 2085, - /* 710 */ 2087, 2089, 2090, 2092, 2095, + /* 180 */ 1329, 1202, 1346, 1372, 1346, 1235, 1379, 1379, 1346, 1235, + /* 190 */ 1235, 1314, 1379, 1379, 1379, 1401, 1401, 1404, 299, 434, + /* 200 */ 299, 1414, 1427, 299, 1414, 299, 299, 299, 1379, 299, + /* 210 */ 1403, 1403, 1401, 456, 456, 456, 456, 456, 456, 456, + /* 220 */ 456, 456, 456, 456, 1379, 1401, 532, 532, 532, 1269, + /* 230 */ 1404, 475, 1284, 434, 475, 1379, 1372, 1372, 532, 1228, + /* 240 */ 1231, 532, 1228, 1231, 532, 532, 456, 1233, 1326, 1228, + /* 250 */ 1237, 1240, 1257, 1106, 1241, 1249, 1255, 1278, 525, 1516, + /* 260 */ 1379, 1414, 475, 1519, 1231, 532, 532, 532, 532, 532, + /* 270 */ 1231, 532, 1402, 475, 343, 475, 525, 1475, 1480, 532, + /* 280 */ 595, 1379, 475, 1548, 1401, 2733, 2733, 2733, 2733, 2733, + /* 290 */ 2733, 2733, 2733, 2733, 828, 1034, 457, 295, 260, 549, + /* 300 */ 759, 969, 874, 1033, 1227, 1211, 1279, 1279, 1279, 1279, + /* 310 */ 1279, 1279, 1279, 1279, 1279, 1041, 125, 13, 13, 506, + /* 320 */ 400, 516, 615, 587, 297, 297, 353, 53, 248, 353, + /* 330 */ 353, 353, 283, 1058, 572, 1043, 987, 1023, 1022, 1037, + /* 340 */ 1085, 1175, 1081, 1083, 1153, 915, 1079, 1098, 1100, 1101, + /* 350 */ 994, 990, 1057, 98, 1159, 1185, 1201, 1203, 1204, 1220, + /* 360 */ 1205, 1097, 1120, 1114, 1260, 1259, 1263, 1264, 1266, 1267, + /* 370 */ 1288, 1302, 40, 1122, 1332, 1315, 1327, 1606, 1607, 1423, + /* 380 */ 1611, 1612, 1571, 1614, 1580, 1416, 1583, 1584, 1587, 1430, + /* 390 */ 1623, 1597, 1598, 1435, 1636, 1437, 1638, 1608, 1641, 1620, + /* 400 */ 1645, 1613, 1464, 1470, 1651, 1653, 1484, 1487, 1661, 1678, + /* 410 */ 1617, 1665, 1666, 1667, 1626, 1669, 1670, 1671, 1672, 1673, + /* 420 */ 1674, 1675, 1676, 1529, 1646, 1682, 1533, 1685, 1692, 1696, + /* 430 */ 1697, 1699, 1700, 1701, 1703, 1704, 1705, 1706, 1708, 1710, + /* 440 */ 1711, 1712, 1677, 1713, 1714, 1715, 1716, 1717, 1698, 1718, + /* 450 */ 1721, 1722, 1588, 1724, 1732, 1691, 1727, 1679, 1728, 1681, + /* 460 */ 1729, 1730, 1693, 1694, 1707, 1689, 1733, 1702, 1738, 1719, + /* 470 */ 1740, 1720, 1723, 1753, 1754, 1757, 1731, 1592, 1758, 1759, + /* 480 */ 1765, 1709, 1767, 1772, 1739, 1734, 1736, 1776, 1742, 1735, + /* 490 */ 1741, 1778, 1744, 1745, 1749, 1781, 1755, 1747, 1750, 1784, + /* 500 */ 1792, 1797, 1798, 1737, 1725, 1774, 1780, 1811, 1777, 1779, + /* 510 */ 1782, 1783, 1771, 1775, 1785, 1786, 1794, 1787, 1823, 1802, + /* 520 */ 1825, 1806, 1789, 1831, 1810, 1807, 1843, 1812, 1845, 1813, + /* 530 */ 1846, 1827, 1833, 1815, 1816, 1819, 1760, 1763, 1855, 1743, + /* 540 */ 1826, 1862, 1680, 1842, 1752, 1751, 1865, 1866, 1761, 1748, + /* 550 */ 1864, 1828, 1621, 1788, 1773, 1790, 1791, 1832, 1834, 1793, + /* 560 */ 1804, 1808, 1824, 1801, 1835, 1839, 1854, 1836, 1837, 1622, + /* 570 */ 1829, 1841, 1874, 1838, 1631, 1867, 1887, 1888, 1892, 1893, + /* 580 */ 1895, 1844, 1847, 1879, 1690, 1894, 1885, 1935, 1939, 1941, + /* 590 */ 1689, 1897, 1851, 1852, 1868, 1856, 1863, 1796, 1871, 1942, + /* 600 */ 1908, 1799, 1881, 1869, 1689, 1903, 1916, 1762, 1764, 1768, + /* 610 */ 1975, 1956, 1795, 1884, 1886, 1889, 1890, 1898, 1896, 1933, + /* 620 */ 1900, 1902, 1934, 1904, 1961, 1800, 1907, 1882, 1909, 1950, + /* 630 */ 1952, 1912, 1913, 1954, 1915, 1918, 1964, 1917, 1919, 1969, + /* 640 */ 1921, 1922, 1982, 1924, 1901, 1905, 1906, 1910, 1981, 1914, + /* 650 */ 1928, 1983, 1931, 1993, 1936, 1983, 1983, 2010, 1970, 1973, + /* 660 */ 1998, 2004, 2005, 2006, 2008, 2009, 2016, 2019, 2020, 2021, + /* 670 */ 1987, 1966, 2015, 2025, 2026, 2028, 2042, 2030, 2032, 2033, + /* 680 */ 2007, 1771, 2040, 1775, 2043, 2044, 2045, 2046, 2060, 2050, + /* 690 */ 2086, 2052, 2041, 2049, 2090, 2056, 2047, 2055, 2093, 2061, + /* 700 */ 2053, 2059, 2100, 2067, 2057, 2064, 2104, 2071, 2072, 2108, + /* 710 */ 2087, 2089, 2091, 2094, 2096, 2092, }; -#define YY_REDUCE_COUNT (292) +#define YY_REDUCE_COUNT (293) #define YY_REDUCE_MIN (-414) #define YY_REDUCE_MAX (2320) static const short yy_reduce_ofst[] = { @@ -865,95 +865,95 @@ static const short yy_reduce_ofst[] = { /* 120 */ 640, 688, 692, 697, -346, -228, -109, -329, 195, 173, /* 130 */ -228, 254, 339, -31, 199, 341, 470, 454, 583, 584, /* 140 */ -226, 224, 363, 616, 462, 627, 682, 694, 600, 636, - /* 150 */ -343, 306, 318, 364, 396, 452, 519, 309, 557, 670, - /* 160 */ 606, 579, 646, 738, 740, 850, 850, 890, 847, 904, - /* 170 */ 900, 863, 856, 856, 833, 856, 926, 916, 850, 955, - /* 180 */ 978, 989, 1010, 1011, 1015, 1019, 1064, 1065, 1025, 1029, - /* 190 */ 1032, 1066, 1072, 1076, 1077, 1092, 1093, 1030, 1087, 1051, - /* 200 */ 1089, 1099, 1059, 1107, 1111, 1109, 1110, 1112, 1117, 1113, - /* 210 */ 1121, 1123, 1126, 1102, 1105, 1108, 1115, 1118, 1124, 1125, - /* 220 */ 1128, 1129, 1130, 1131, 1132, 1136, 1086, 1103, 1061, 1073, - /* 230 */ 1133, 1084, 1127, 1140, 1145, 1090, 1094, 1134, 1040, 1137, - /* 240 */ 1138, 1050, 1144, 1139, 1141, 850, 1052, 1054, 1062, 1067, - /* 250 */ 1063, 1075, 1148, 1055, 1068, 1082, 856, 1154, 1146, 1199, - /* 260 */ 1202, 1197, 1167, 1166, 1182, 1183, 1184, 1187, 1188, 1170, - /* 270 */ 1189, 1180, 1228, 1214, 1230, 1206, 1149, 1212, 1207, 1231, - /* 280 */ 1240, 1242, 1250, 1254, 1192, 1190, 1208, 1215, 1236, 1239, - /* 290 */ 1252, 1265, 1262, + /* 150 */ -343, 318, 364, 396, 452, 519, 526, 309, 659, 670, + /* 160 */ 657, 635, 734, 738, 766, 869, 869, 891, 857, 910, + /* 170 */ 900, 904, 856, 856, 899, 856, 927, 919, 869, 957, + /* 180 */ 979, 992, 1013, 1012, 1016, 1020, 1065, 1066, 1025, 1029, + /* 190 */ 1032, 1068, 1074, 1077, 1084, 1093, 1094, 1030, 1087, 1053, + /* 200 */ 1089, 1099, 1059, 1107, 1115, 1109, 1111, 1112, 1121, 1113, + /* 210 */ 1123, 1125, 1128, 1102, 1108, 1110, 1117, 1118, 1124, 1126, + /* 220 */ 1129, 1130, 1131, 1133, 1132, 1136, 1088, 1103, 1127, 1061, + /* 230 */ 1075, 1134, 1078, 1105, 1140, 1145, 1090, 1138, 1139, 1045, + /* 240 */ 1137, 1141, 1054, 1144, 1142, 1143, 869, 1052, 1056, 1062, + /* 250 */ 1064, 1070, 1069, 1148, 1055, 1080, 1082, 856, 1166, 1146, + /* 260 */ 1216, 1217, 1199, 1168, 1169, 1183, 1187, 1188, 1189, 1190, + /* 270 */ 1170, 1192, 1186, 1229, 1218, 1232, 1207, 1152, 1214, 1208, + /* 280 */ 1230, 1245, 1242, 1253, 1258, 1194, 1195, 1215, 1222, 1236, + /* 290 */ 1243, 1252, 1254, 1280, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 10 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 20 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 30 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 40 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 50 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 60 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1860, 1605, - /* 70 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 80 */ 1605, 1605, 1683, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 90 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1681, - /* 100 */ 1853, 2054, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 110 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 120 */ 1605, 1605, 1605, 1605, 1605, 2066, 1605, 1605, 1683, 1605, - /* 130 */ 2066, 2066, 2066, 1681, 2026, 2026, 1605, 1605, 1605, 1605, - /* 140 */ 1790, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1790, 1605, - /* 150 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1899, 1605, 1605, - /* 160 */ 2091, 2146, 1605, 1605, 2094, 1605, 1605, 1605, 1865, 1605, - /* 170 */ 1743, 2081, 2058, 2072, 2130, 2059, 2056, 2075, 1605, 2085, - /* 180 */ 1605, 1892, 1858, 1605, 1858, 1855, 1605, 1605, 1858, 1855, - /* 190 */ 1855, 1734, 1605, 1605, 1605, 1605, 1605, 1605, 1683, 1605, - /* 200 */ 1683, 1605, 1605, 1683, 1605, 1683, 1683, 1683, 1605, 1683, - /* 210 */ 1662, 1662, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 220 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1913, 1605, - /* 230 */ 1681, 1901, 1605, 1681, 1605, 1605, 1605, 1605, 2101, 2099, - /* 240 */ 1605, 2101, 2099, 1605, 1605, 1605, 2115, 2111, 2101, 2119, - /* 250 */ 2117, 2087, 2085, 2149, 2136, 2132, 2072, 1605, 1605, 1605, - /* 260 */ 1605, 1681, 1605, 2099, 1605, 1605, 1605, 1605, 1605, 2099, - /* 270 */ 1605, 1605, 1681, 1605, 1681, 1605, 1605, 1759, 1605, 1605, - /* 280 */ 1605, 1681, 1637, 1605, 1894, 1905, 1877, 1877, 1793, 1793, - /* 290 */ 1793, 1684, 1610, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 300 */ 1605, 1605, 1605, 1605, 1605, 2114, 2113, 1982, 1605, 2030, - /* 310 */ 2029, 2028, 2019, 1981, 1755, 1605, 1980, 1979, 1605, 1605, - /* 320 */ 1605, 1605, 1605, 1873, 1872, 1973, 1605, 1605, 1974, 1972, - /* 330 */ 1971, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 340 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 350 */ 2133, 2137, 1605, 1605, 1605, 1605, 1605, 1605, 2055, 1605, - /* 360 */ 1605, 1605, 1605, 1605, 1955, 1605, 1605, 1605, 1605, 1605, - /* 370 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 380 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 390 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 400 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 410 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 420 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 430 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 440 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 450 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 460 */ 1605, 1605, 1605, 1642, 1960, 1605, 1605, 1605, 1605, 1605, - /* 470 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 480 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 490 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 500 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 510 */ 1605, 1722, 1721, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 520 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 530 */ 1605, 1605, 1605, 1605, 1605, 1964, 1605, 1605, 1605, 1605, - /* 540 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 2129, - /* 550 */ 2088, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 560 */ 1605, 1605, 1605, 1605, 1605, 1955, 1605, 2112, 1605, 1605, - /* 570 */ 2127, 1605, 2131, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 580 */ 2065, 2061, 1605, 1605, 2057, 1605, 1605, 1605, 1605, 1963, - /* 590 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 600 */ 1605, 1605, 1605, 1954, 1605, 2016, 1605, 1605, 1605, 2050, - /* 610 */ 1605, 1605, 2001, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 620 */ 1605, 1605, 1964, 1605, 1967, 1605, 1605, 1605, 1605, 1605, - /* 630 */ 1787, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 640 */ 1605, 1605, 1605, 1772, 1770, 1769, 1768, 1605, 1765, 1605, - /* 650 */ 1800, 1605, 1605, 1605, 1796, 1795, 1605, 1605, 1605, 1605, - /* 660 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 670 */ 1605, 1702, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 680 */ 1694, 1605, 1693, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 690 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 700 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, - /* 710 */ 1605, 1605, 1605, 1605, 1605, + /* 0 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 10 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 20 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 30 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 40 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 50 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 60 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1863, 1608, + /* 70 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 80 */ 1608, 1608, 1686, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 90 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1684, + /* 100 */ 1856, 2058, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 110 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 120 */ 1608, 1608, 1608, 1608, 1608, 2070, 1608, 1608, 1686, 1608, + /* 130 */ 2070, 2070, 2070, 1684, 2030, 2030, 1608, 1608, 1608, 1608, + /* 140 */ 1793, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1793, 1608, + /* 150 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1902, 1608, 1608, + /* 160 */ 2095, 2150, 1608, 1608, 2098, 1608, 1608, 1608, 1868, 1608, + /* 170 */ 1746, 2085, 2062, 2076, 2134, 2063, 2060, 2079, 1608, 2089, + /* 180 */ 1608, 1895, 1861, 1608, 1861, 1858, 1608, 1608, 1861, 1858, + /* 190 */ 1858, 1737, 1608, 1608, 1608, 1608, 1608, 1608, 1686, 1608, + /* 200 */ 1686, 1608, 1608, 1686, 1608, 1686, 1686, 1686, 1608, 1686, + /* 210 */ 1665, 1665, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 220 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1917, + /* 230 */ 1608, 1684, 1904, 1608, 1684, 1608, 1608, 1608, 1608, 2105, + /* 240 */ 2103, 1608, 2105, 2103, 1608, 1608, 1608, 2119, 2115, 2105, + /* 250 */ 2123, 2121, 2091, 2089, 2153, 2140, 2136, 2076, 1608, 1608, + /* 260 */ 1608, 1608, 1684, 1608, 2103, 1608, 1608, 1608, 1608, 1608, + /* 270 */ 2103, 1608, 1608, 1684, 1608, 1684, 1608, 1608, 1762, 1608, + /* 280 */ 1608, 1608, 1684, 1640, 1608, 1897, 1908, 1880, 1880, 1796, + /* 290 */ 1796, 1796, 1687, 1613, 1608, 1608, 1608, 1608, 1608, 1608, + /* 300 */ 1608, 1608, 1608, 1608, 1608, 1608, 2118, 2117, 1986, 1608, + /* 310 */ 2034, 2033, 2032, 2023, 1985, 1758, 1608, 1984, 1983, 1608, + /* 320 */ 1608, 1608, 1608, 1608, 1876, 1875, 1977, 1608, 1608, 1978, + /* 330 */ 1976, 1975, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 340 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 350 */ 1608, 2137, 2141, 1608, 1608, 1608, 1608, 1608, 1608, 2059, + /* 360 */ 1608, 1608, 1608, 1608, 1608, 1959, 1608, 1608, 1608, 1608, + /* 370 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 380 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 390 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 400 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 410 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 420 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 430 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 440 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 450 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 460 */ 1608, 1608, 1608, 1608, 1645, 1964, 1608, 1608, 1608, 1608, + /* 470 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 480 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 490 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 500 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 510 */ 1608, 1608, 1725, 1724, 1608, 1608, 1608, 1608, 1608, 1608, + /* 520 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 530 */ 1608, 1608, 1608, 1608, 1608, 1608, 1968, 1608, 1608, 1608, + /* 540 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 550 */ 2133, 2092, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 560 */ 1608, 1608, 1608, 1608, 1608, 1608, 1959, 1608, 2116, 1608, + /* 570 */ 1608, 2131, 1608, 2135, 1608, 1608, 1608, 1608, 1608, 1608, + /* 580 */ 1608, 2069, 2065, 1608, 1608, 2061, 1608, 1608, 1608, 1608, + /* 590 */ 1967, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 600 */ 1608, 1608, 1608, 1608, 1958, 1608, 2020, 1608, 1608, 1608, + /* 610 */ 2054, 1608, 1608, 2005, 1608, 1608, 1608, 1608, 1608, 1608, + /* 620 */ 1608, 1608, 1608, 1968, 1608, 1971, 1608, 1608, 1608, 1608, + /* 630 */ 1608, 1790, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 640 */ 1608, 1608, 1608, 1608, 1775, 1773, 1772, 1771, 1608, 1768, + /* 650 */ 1608, 1803, 1608, 1608, 1608, 1799, 1798, 1608, 1608, 1608, + /* 660 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 670 */ 1608, 1608, 1705, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 680 */ 1608, 1697, 1608, 1696, 1608, 1608, 1608, 1608, 1608, 1608, + /* 690 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 700 */ 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, 1608, + /* 710 */ 1608, 1608, 1608, 1608, 1608, 1608, }; /********** End of lemon-generated parsing tables *****************************/ @@ -2156,246 +2156,247 @@ static const char *const yyRuleName[] = { /* 301 */ "stream_options ::= stream_options WATERMARK duration_literal", /* 302 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", /* 303 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 304 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 305 */ "subtable_opt ::=", - /* 306 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 307 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 308 */ "cmd ::= KILL QUERY NK_STRING", - /* 309 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 310 */ "cmd ::= BALANCE VGROUP", - /* 311 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 312 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 313 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 314 */ "dnode_list ::= DNODE NK_INTEGER", - /* 315 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 316 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 317 */ "cmd ::= query_or_subquery", - /* 318 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 319 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 320 */ "literal ::= NK_INTEGER", - /* 321 */ "literal ::= NK_FLOAT", - /* 322 */ "literal ::= NK_STRING", - /* 323 */ "literal ::= NK_BOOL", - /* 324 */ "literal ::= TIMESTAMP NK_STRING", - /* 325 */ "literal ::= duration_literal", - /* 326 */ "literal ::= NULL", - /* 327 */ "literal ::= NK_QUESTION", - /* 328 */ "duration_literal ::= NK_VARIABLE", - /* 329 */ "signed ::= NK_INTEGER", - /* 330 */ "signed ::= NK_PLUS NK_INTEGER", - /* 331 */ "signed ::= NK_MINUS NK_INTEGER", - /* 332 */ "signed ::= NK_FLOAT", - /* 333 */ "signed ::= NK_PLUS NK_FLOAT", - /* 334 */ "signed ::= NK_MINUS NK_FLOAT", - /* 335 */ "signed_literal ::= signed", - /* 336 */ "signed_literal ::= NK_STRING", - /* 337 */ "signed_literal ::= NK_BOOL", - /* 338 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 339 */ "signed_literal ::= duration_literal", - /* 340 */ "signed_literal ::= NULL", - /* 341 */ "signed_literal ::= literal_func", - /* 342 */ "signed_literal ::= NK_QUESTION", - /* 343 */ "literal_list ::= signed_literal", - /* 344 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 345 */ "db_name ::= NK_ID", - /* 346 */ "table_name ::= NK_ID", - /* 347 */ "column_name ::= NK_ID", - /* 348 */ "function_name ::= NK_ID", - /* 349 */ "table_alias ::= NK_ID", - /* 350 */ "column_alias ::= NK_ID", - /* 351 */ "user_name ::= NK_ID", - /* 352 */ "topic_name ::= NK_ID", - /* 353 */ "stream_name ::= NK_ID", - /* 354 */ "cgroup_name ::= NK_ID", - /* 355 */ "index_name ::= NK_ID", - /* 356 */ "expr_or_subquery ::= expression", - /* 357 */ "expression ::= literal", - /* 358 */ "expression ::= pseudo_column", - /* 359 */ "expression ::= column_reference", - /* 360 */ "expression ::= function_expression", - /* 361 */ "expression ::= case_when_expression", - /* 362 */ "expression ::= NK_LP expression NK_RP", - /* 363 */ "expression ::= NK_PLUS expr_or_subquery", - /* 364 */ "expression ::= NK_MINUS expr_or_subquery", - /* 365 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 366 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 367 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 368 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 369 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 370 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 371 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 372 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 373 */ "expression_list ::= expr_or_subquery", - /* 374 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 375 */ "column_reference ::= column_name", - /* 376 */ "column_reference ::= table_name NK_DOT column_name", - /* 377 */ "pseudo_column ::= ROWTS", - /* 378 */ "pseudo_column ::= TBNAME", - /* 379 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 380 */ "pseudo_column ::= QSTART", - /* 381 */ "pseudo_column ::= QEND", - /* 382 */ "pseudo_column ::= QDURATION", - /* 383 */ "pseudo_column ::= WSTART", - /* 384 */ "pseudo_column ::= WEND", - /* 385 */ "pseudo_column ::= WDURATION", - /* 386 */ "pseudo_column ::= IROWTS", - /* 387 */ "pseudo_column ::= QTAGS", - /* 388 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 389 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 390 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 391 */ "function_expression ::= literal_func", - /* 392 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 393 */ "literal_func ::= NOW", - /* 394 */ "noarg_func ::= NOW", - /* 395 */ "noarg_func ::= TODAY", - /* 396 */ "noarg_func ::= TIMEZONE", - /* 397 */ "noarg_func ::= DATABASE", - /* 398 */ "noarg_func ::= CLIENT_VERSION", - /* 399 */ "noarg_func ::= SERVER_VERSION", - /* 400 */ "noarg_func ::= SERVER_STATUS", - /* 401 */ "noarg_func ::= CURRENT_USER", - /* 402 */ "noarg_func ::= USER", - /* 403 */ "star_func ::= COUNT", - /* 404 */ "star_func ::= FIRST", - /* 405 */ "star_func ::= LAST", - /* 406 */ "star_func ::= LAST_ROW", - /* 407 */ "star_func_para_list ::= NK_STAR", - /* 408 */ "star_func_para_list ::= other_para_list", - /* 409 */ "other_para_list ::= star_func_para", - /* 410 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 411 */ "star_func_para ::= expr_or_subquery", - /* 412 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 413 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 414 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 415 */ "when_then_list ::= when_then_expr", - /* 416 */ "when_then_list ::= when_then_list when_then_expr", - /* 417 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 418 */ "case_when_else_opt ::=", - /* 419 */ "case_when_else_opt ::= ELSE common_expression", - /* 420 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 421 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 422 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 423 */ "predicate ::= expr_or_subquery IS NULL", - /* 424 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 425 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 426 */ "compare_op ::= NK_LT", - /* 427 */ "compare_op ::= NK_GT", - /* 428 */ "compare_op ::= NK_LE", - /* 429 */ "compare_op ::= NK_GE", - /* 430 */ "compare_op ::= NK_NE", - /* 431 */ "compare_op ::= NK_EQ", - /* 432 */ "compare_op ::= LIKE", - /* 433 */ "compare_op ::= NOT LIKE", - /* 434 */ "compare_op ::= MATCH", - /* 435 */ "compare_op ::= NMATCH", - /* 436 */ "compare_op ::= CONTAINS", - /* 437 */ "in_op ::= IN", - /* 438 */ "in_op ::= NOT IN", - /* 439 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 440 */ "boolean_value_expression ::= boolean_primary", - /* 441 */ "boolean_value_expression ::= NOT boolean_primary", - /* 442 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 443 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 444 */ "boolean_primary ::= predicate", - /* 445 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 446 */ "common_expression ::= expr_or_subquery", - /* 447 */ "common_expression ::= boolean_value_expression", - /* 448 */ "from_clause_opt ::=", - /* 449 */ "from_clause_opt ::= FROM table_reference_list", - /* 450 */ "table_reference_list ::= table_reference", - /* 451 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 452 */ "table_reference ::= table_primary", - /* 453 */ "table_reference ::= joined_table", - /* 454 */ "table_primary ::= table_name alias_opt", - /* 455 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 456 */ "table_primary ::= subquery alias_opt", - /* 457 */ "table_primary ::= parenthesized_joined_table", - /* 458 */ "alias_opt ::=", - /* 459 */ "alias_opt ::= table_alias", - /* 460 */ "alias_opt ::= AS table_alias", - /* 461 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 462 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 463 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 464 */ "join_type ::=", - /* 465 */ "join_type ::= INNER", - /* 466 */ "query_specification ::= SELECT set_quantifier_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", - /* 467 */ "set_quantifier_opt ::=", - /* 468 */ "set_quantifier_opt ::= DISTINCT", - /* 469 */ "set_quantifier_opt ::= ALL", - /* 470 */ "select_list ::= select_item", - /* 471 */ "select_list ::= select_list NK_COMMA select_item", - /* 472 */ "select_item ::= NK_STAR", - /* 473 */ "select_item ::= common_expression", - /* 474 */ "select_item ::= common_expression column_alias", - /* 475 */ "select_item ::= common_expression AS column_alias", - /* 476 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 477 */ "where_clause_opt ::=", - /* 478 */ "where_clause_opt ::= WHERE search_condition", - /* 479 */ "partition_by_clause_opt ::=", - /* 480 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 481 */ "partition_list ::= partition_item", - /* 482 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 483 */ "partition_item ::= expr_or_subquery", - /* 484 */ "partition_item ::= expr_or_subquery column_alias", - /* 485 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 486 */ "twindow_clause_opt ::=", - /* 487 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 488 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 489 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 490 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 491 */ "sliding_opt ::=", - /* 492 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 493 */ "fill_opt ::=", - /* 494 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 495 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 496 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP", - /* 497 */ "fill_mode ::= NONE", - /* 498 */ "fill_mode ::= PREV", - /* 499 */ "fill_mode ::= NULL", - /* 500 */ "fill_mode ::= NULL_F", - /* 501 */ "fill_mode ::= LINEAR", - /* 502 */ "fill_mode ::= NEXT", - /* 503 */ "group_by_clause_opt ::=", - /* 504 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 505 */ "group_by_list ::= expr_or_subquery", - /* 506 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 507 */ "having_clause_opt ::=", - /* 508 */ "having_clause_opt ::= HAVING search_condition", - /* 509 */ "range_opt ::=", - /* 510 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 511 */ "every_opt ::=", - /* 512 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 513 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 514 */ "query_simple ::= query_specification", - /* 515 */ "query_simple ::= union_query_expression", - /* 516 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 517 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 518 */ "query_simple_or_subquery ::= query_simple", - /* 519 */ "query_simple_or_subquery ::= subquery", - /* 520 */ "query_or_subquery ::= query_expression", - /* 521 */ "query_or_subquery ::= subquery", - /* 522 */ "order_by_clause_opt ::=", - /* 523 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 524 */ "slimit_clause_opt ::=", - /* 525 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 526 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 527 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 528 */ "limit_clause_opt ::=", - /* 529 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 530 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 531 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 532 */ "subquery ::= NK_LP query_expression NK_RP", - /* 533 */ "subquery ::= NK_LP subquery NK_RP", - /* 534 */ "search_condition ::= common_expression", - /* 535 */ "sort_specification_list ::= sort_specification", - /* 536 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 537 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 538 */ "ordering_specification_opt ::=", - /* 539 */ "ordering_specification_opt ::= ASC", - /* 540 */ "ordering_specification_opt ::= DESC", - /* 541 */ "null_ordering_opt ::=", - /* 542 */ "null_ordering_opt ::= NULLS FIRST", - /* 543 */ "null_ordering_opt ::= NULLS LAST", + /* 304 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 305 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 306 */ "subtable_opt ::=", + /* 307 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 308 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 309 */ "cmd ::= KILL QUERY NK_STRING", + /* 310 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 311 */ "cmd ::= BALANCE VGROUP", + /* 312 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 313 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 314 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 315 */ "dnode_list ::= DNODE NK_INTEGER", + /* 316 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 317 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 318 */ "cmd ::= query_or_subquery", + /* 319 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 320 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 321 */ "literal ::= NK_INTEGER", + /* 322 */ "literal ::= NK_FLOAT", + /* 323 */ "literal ::= NK_STRING", + /* 324 */ "literal ::= NK_BOOL", + /* 325 */ "literal ::= TIMESTAMP NK_STRING", + /* 326 */ "literal ::= duration_literal", + /* 327 */ "literal ::= NULL", + /* 328 */ "literal ::= NK_QUESTION", + /* 329 */ "duration_literal ::= NK_VARIABLE", + /* 330 */ "signed ::= NK_INTEGER", + /* 331 */ "signed ::= NK_PLUS NK_INTEGER", + /* 332 */ "signed ::= NK_MINUS NK_INTEGER", + /* 333 */ "signed ::= NK_FLOAT", + /* 334 */ "signed ::= NK_PLUS NK_FLOAT", + /* 335 */ "signed ::= NK_MINUS NK_FLOAT", + /* 336 */ "signed_literal ::= signed", + /* 337 */ "signed_literal ::= NK_STRING", + /* 338 */ "signed_literal ::= NK_BOOL", + /* 339 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 340 */ "signed_literal ::= duration_literal", + /* 341 */ "signed_literal ::= NULL", + /* 342 */ "signed_literal ::= literal_func", + /* 343 */ "signed_literal ::= NK_QUESTION", + /* 344 */ "literal_list ::= signed_literal", + /* 345 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 346 */ "db_name ::= NK_ID", + /* 347 */ "table_name ::= NK_ID", + /* 348 */ "column_name ::= NK_ID", + /* 349 */ "function_name ::= NK_ID", + /* 350 */ "table_alias ::= NK_ID", + /* 351 */ "column_alias ::= NK_ID", + /* 352 */ "user_name ::= NK_ID", + /* 353 */ "topic_name ::= NK_ID", + /* 354 */ "stream_name ::= NK_ID", + /* 355 */ "cgroup_name ::= NK_ID", + /* 356 */ "index_name ::= NK_ID", + /* 357 */ "expr_or_subquery ::= expression", + /* 358 */ "expression ::= literal", + /* 359 */ "expression ::= pseudo_column", + /* 360 */ "expression ::= column_reference", + /* 361 */ "expression ::= function_expression", + /* 362 */ "expression ::= case_when_expression", + /* 363 */ "expression ::= NK_LP expression NK_RP", + /* 364 */ "expression ::= NK_PLUS expr_or_subquery", + /* 365 */ "expression ::= NK_MINUS expr_or_subquery", + /* 366 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 367 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 368 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 369 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 370 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 371 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 372 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 373 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 374 */ "expression_list ::= expr_or_subquery", + /* 375 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 376 */ "column_reference ::= column_name", + /* 377 */ "column_reference ::= table_name NK_DOT column_name", + /* 378 */ "pseudo_column ::= ROWTS", + /* 379 */ "pseudo_column ::= TBNAME", + /* 380 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 381 */ "pseudo_column ::= QSTART", + /* 382 */ "pseudo_column ::= QEND", + /* 383 */ "pseudo_column ::= QDURATION", + /* 384 */ "pseudo_column ::= WSTART", + /* 385 */ "pseudo_column ::= WEND", + /* 386 */ "pseudo_column ::= WDURATION", + /* 387 */ "pseudo_column ::= IROWTS", + /* 388 */ "pseudo_column ::= QTAGS", + /* 389 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 390 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 391 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 392 */ "function_expression ::= literal_func", + /* 393 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 394 */ "literal_func ::= NOW", + /* 395 */ "noarg_func ::= NOW", + /* 396 */ "noarg_func ::= TODAY", + /* 397 */ "noarg_func ::= TIMEZONE", + /* 398 */ "noarg_func ::= DATABASE", + /* 399 */ "noarg_func ::= CLIENT_VERSION", + /* 400 */ "noarg_func ::= SERVER_VERSION", + /* 401 */ "noarg_func ::= SERVER_STATUS", + /* 402 */ "noarg_func ::= CURRENT_USER", + /* 403 */ "noarg_func ::= USER", + /* 404 */ "star_func ::= COUNT", + /* 405 */ "star_func ::= FIRST", + /* 406 */ "star_func ::= LAST", + /* 407 */ "star_func ::= LAST_ROW", + /* 408 */ "star_func_para_list ::= NK_STAR", + /* 409 */ "star_func_para_list ::= other_para_list", + /* 410 */ "other_para_list ::= star_func_para", + /* 411 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 412 */ "star_func_para ::= expr_or_subquery", + /* 413 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 414 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 415 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 416 */ "when_then_list ::= when_then_expr", + /* 417 */ "when_then_list ::= when_then_list when_then_expr", + /* 418 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 419 */ "case_when_else_opt ::=", + /* 420 */ "case_when_else_opt ::= ELSE common_expression", + /* 421 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 422 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 423 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 424 */ "predicate ::= expr_or_subquery IS NULL", + /* 425 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 426 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 427 */ "compare_op ::= NK_LT", + /* 428 */ "compare_op ::= NK_GT", + /* 429 */ "compare_op ::= NK_LE", + /* 430 */ "compare_op ::= NK_GE", + /* 431 */ "compare_op ::= NK_NE", + /* 432 */ "compare_op ::= NK_EQ", + /* 433 */ "compare_op ::= LIKE", + /* 434 */ "compare_op ::= NOT LIKE", + /* 435 */ "compare_op ::= MATCH", + /* 436 */ "compare_op ::= NMATCH", + /* 437 */ "compare_op ::= CONTAINS", + /* 438 */ "in_op ::= IN", + /* 439 */ "in_op ::= NOT IN", + /* 440 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 441 */ "boolean_value_expression ::= boolean_primary", + /* 442 */ "boolean_value_expression ::= NOT boolean_primary", + /* 443 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 444 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 445 */ "boolean_primary ::= predicate", + /* 446 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 447 */ "common_expression ::= expr_or_subquery", + /* 448 */ "common_expression ::= boolean_value_expression", + /* 449 */ "from_clause_opt ::=", + /* 450 */ "from_clause_opt ::= FROM table_reference_list", + /* 451 */ "table_reference_list ::= table_reference", + /* 452 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 453 */ "table_reference ::= table_primary", + /* 454 */ "table_reference ::= joined_table", + /* 455 */ "table_primary ::= table_name alias_opt", + /* 456 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 457 */ "table_primary ::= subquery alias_opt", + /* 458 */ "table_primary ::= parenthesized_joined_table", + /* 459 */ "alias_opt ::=", + /* 460 */ "alias_opt ::= table_alias", + /* 461 */ "alias_opt ::= AS table_alias", + /* 462 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 463 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 464 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 465 */ "join_type ::=", + /* 466 */ "join_type ::= INNER", + /* 467 */ "query_specification ::= SELECT set_quantifier_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", + /* 468 */ "set_quantifier_opt ::=", + /* 469 */ "set_quantifier_opt ::= DISTINCT", + /* 470 */ "set_quantifier_opt ::= ALL", + /* 471 */ "select_list ::= select_item", + /* 472 */ "select_list ::= select_list NK_COMMA select_item", + /* 473 */ "select_item ::= NK_STAR", + /* 474 */ "select_item ::= common_expression", + /* 475 */ "select_item ::= common_expression column_alias", + /* 476 */ "select_item ::= common_expression AS column_alias", + /* 477 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 478 */ "where_clause_opt ::=", + /* 479 */ "where_clause_opt ::= WHERE search_condition", + /* 480 */ "partition_by_clause_opt ::=", + /* 481 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 482 */ "partition_list ::= partition_item", + /* 483 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 484 */ "partition_item ::= expr_or_subquery", + /* 485 */ "partition_item ::= expr_or_subquery column_alias", + /* 486 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 487 */ "twindow_clause_opt ::=", + /* 488 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 489 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 490 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 491 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 492 */ "sliding_opt ::=", + /* 493 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 494 */ "fill_opt ::=", + /* 495 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 496 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 497 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP", + /* 498 */ "fill_mode ::= NONE", + /* 499 */ "fill_mode ::= PREV", + /* 500 */ "fill_mode ::= NULL", + /* 501 */ "fill_mode ::= NULL_F", + /* 502 */ "fill_mode ::= LINEAR", + /* 503 */ "fill_mode ::= NEXT", + /* 504 */ "group_by_clause_opt ::=", + /* 505 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 506 */ "group_by_list ::= expr_or_subquery", + /* 507 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 508 */ "having_clause_opt ::=", + /* 509 */ "having_clause_opt ::= HAVING search_condition", + /* 510 */ "range_opt ::=", + /* 511 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 512 */ "every_opt ::=", + /* 513 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 514 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 515 */ "query_simple ::= query_specification", + /* 516 */ "query_simple ::= union_query_expression", + /* 517 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 518 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 519 */ "query_simple_or_subquery ::= query_simple", + /* 520 */ "query_simple_or_subquery ::= subquery", + /* 521 */ "query_or_subquery ::= query_expression", + /* 522 */ "query_or_subquery ::= subquery", + /* 523 */ "order_by_clause_opt ::=", + /* 524 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 525 */ "slimit_clause_opt ::=", + /* 526 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 527 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 528 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 529 */ "limit_clause_opt ::=", + /* 530 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 531 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 532 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 533 */ "subquery ::= NK_LP query_expression NK_RP", + /* 534 */ "subquery ::= NK_LP subquery NK_RP", + /* 535 */ "search_condition ::= common_expression", + /* 536 */ "sort_specification_list ::= sort_specification", + /* 537 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 538 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 539 */ "ordering_specification_opt ::=", + /* 540 */ "ordering_specification_opt ::= ASC", + /* 541 */ "ordering_specification_opt ::= DESC", + /* 542 */ "null_ordering_opt ::=", + /* 543 */ "null_ordering_opt ::= NULLS FIRST", + /* 544 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -3313,246 +3314,247 @@ static const struct { { 396, -3 }, /* (301) stream_options ::= stream_options WATERMARK duration_literal */ { 396, -4 }, /* (302) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ { 396, -3 }, /* (303) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - { 396, -4 }, /* (304) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - { 397, 0 }, /* (305) subtable_opt ::= */ - { 397, -4 }, /* (306) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 324, -3 }, /* (307) cmd ::= KILL CONNECTION NK_INTEGER */ - { 324, -3 }, /* (308) cmd ::= KILL QUERY NK_STRING */ - { 324, -3 }, /* (309) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 324, -2 }, /* (310) cmd ::= BALANCE VGROUP */ - { 324, -4 }, /* (311) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 324, -4 }, /* (312) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 324, -3 }, /* (313) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 399, -2 }, /* (314) dnode_list ::= DNODE NK_INTEGER */ - { 399, -3 }, /* (315) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 324, -4 }, /* (316) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 324, -1 }, /* (317) cmd ::= query_or_subquery */ - { 324, -7 }, /* (318) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 324, -4 }, /* (319) cmd ::= INSERT INTO full_table_name query_or_subquery */ - { 327, -1 }, /* (320) literal ::= NK_INTEGER */ - { 327, -1 }, /* (321) literal ::= NK_FLOAT */ - { 327, -1 }, /* (322) literal ::= NK_STRING */ - { 327, -1 }, /* (323) literal ::= NK_BOOL */ - { 327, -2 }, /* (324) literal ::= TIMESTAMP NK_STRING */ - { 327, -1 }, /* (325) literal ::= duration_literal */ - { 327, -1 }, /* (326) literal ::= NULL */ - { 327, -1 }, /* (327) literal ::= NK_QUESTION */ - { 371, -1 }, /* (328) duration_literal ::= NK_VARIABLE */ - { 401, -1 }, /* (329) signed ::= NK_INTEGER */ - { 401, -2 }, /* (330) signed ::= NK_PLUS NK_INTEGER */ - { 401, -2 }, /* (331) signed ::= NK_MINUS NK_INTEGER */ - { 401, -1 }, /* (332) signed ::= NK_FLOAT */ - { 401, -2 }, /* (333) signed ::= NK_PLUS NK_FLOAT */ - { 401, -2 }, /* (334) signed ::= NK_MINUS NK_FLOAT */ - { 360, -1 }, /* (335) signed_literal ::= signed */ - { 360, -1 }, /* (336) signed_literal ::= NK_STRING */ - { 360, -1 }, /* (337) signed_literal ::= NK_BOOL */ - { 360, -2 }, /* (338) signed_literal ::= TIMESTAMP NK_STRING */ - { 360, -1 }, /* (339) signed_literal ::= duration_literal */ - { 360, -1 }, /* (340) signed_literal ::= NULL */ - { 360, -1 }, /* (341) signed_literal ::= literal_func */ - { 360, -1 }, /* (342) signed_literal ::= NK_QUESTION */ - { 403, -1 }, /* (343) literal_list ::= signed_literal */ - { 403, -3 }, /* (344) literal_list ::= literal_list NK_COMMA signed_literal */ - { 335, -1 }, /* (345) db_name ::= NK_ID */ - { 366, -1 }, /* (346) table_name ::= NK_ID */ - { 358, -1 }, /* (347) column_name ::= NK_ID */ - { 373, -1 }, /* (348) function_name ::= NK_ID */ - { 404, -1 }, /* (349) table_alias ::= NK_ID */ - { 381, -1 }, /* (350) column_alias ::= NK_ID */ - { 329, -1 }, /* (351) user_name ::= NK_ID */ - { 336, -1 }, /* (352) topic_name ::= NK_ID */ - { 395, -1 }, /* (353) stream_name ::= NK_ID */ - { 390, -1 }, /* (354) cgroup_name ::= NK_ID */ - { 384, -1 }, /* (355) index_name ::= NK_ID */ - { 405, -1 }, /* (356) expr_or_subquery ::= expression */ - { 398, -1 }, /* (357) expression ::= literal */ - { 398, -1 }, /* (358) expression ::= pseudo_column */ - { 398, -1 }, /* (359) expression ::= column_reference */ - { 398, -1 }, /* (360) expression ::= function_expression */ - { 398, -1 }, /* (361) expression ::= case_when_expression */ - { 398, -3 }, /* (362) expression ::= NK_LP expression NK_RP */ - { 398, -2 }, /* (363) expression ::= NK_PLUS expr_or_subquery */ - { 398, -2 }, /* (364) expression ::= NK_MINUS expr_or_subquery */ - { 398, -3 }, /* (365) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 398, -3 }, /* (366) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 398, -3 }, /* (367) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 398, -3 }, /* (368) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 398, -3 }, /* (369) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 398, -3 }, /* (370) expression ::= column_reference NK_ARROW NK_STRING */ - { 398, -3 }, /* (371) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 398, -3 }, /* (372) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 363, -1 }, /* (373) expression_list ::= expr_or_subquery */ - { 363, -3 }, /* (374) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 407, -1 }, /* (375) column_reference ::= column_name */ - { 407, -3 }, /* (376) column_reference ::= table_name NK_DOT column_name */ - { 406, -1 }, /* (377) pseudo_column ::= ROWTS */ - { 406, -1 }, /* (378) pseudo_column ::= TBNAME */ - { 406, -3 }, /* (379) pseudo_column ::= table_name NK_DOT TBNAME */ - { 406, -1 }, /* (380) pseudo_column ::= QSTART */ - { 406, -1 }, /* (381) pseudo_column ::= QEND */ - { 406, -1 }, /* (382) pseudo_column ::= QDURATION */ - { 406, -1 }, /* (383) pseudo_column ::= WSTART */ - { 406, -1 }, /* (384) pseudo_column ::= WEND */ - { 406, -1 }, /* (385) pseudo_column ::= WDURATION */ - { 406, -1 }, /* (386) pseudo_column ::= IROWTS */ - { 406, -1 }, /* (387) pseudo_column ::= QTAGS */ - { 408, -4 }, /* (388) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 408, -4 }, /* (389) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 408, -6 }, /* (390) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 408, -1 }, /* (391) function_expression ::= literal_func */ - { 402, -3 }, /* (392) literal_func ::= noarg_func NK_LP NK_RP */ - { 402, -1 }, /* (393) literal_func ::= NOW */ - { 412, -1 }, /* (394) noarg_func ::= NOW */ - { 412, -1 }, /* (395) noarg_func ::= TODAY */ - { 412, -1 }, /* (396) noarg_func ::= TIMEZONE */ - { 412, -1 }, /* (397) noarg_func ::= DATABASE */ - { 412, -1 }, /* (398) noarg_func ::= CLIENT_VERSION */ - { 412, -1 }, /* (399) noarg_func ::= SERVER_VERSION */ - { 412, -1 }, /* (400) noarg_func ::= SERVER_STATUS */ - { 412, -1 }, /* (401) noarg_func ::= CURRENT_USER */ - { 412, -1 }, /* (402) noarg_func ::= USER */ - { 410, -1 }, /* (403) star_func ::= COUNT */ - { 410, -1 }, /* (404) star_func ::= FIRST */ - { 410, -1 }, /* (405) star_func ::= LAST */ - { 410, -1 }, /* (406) star_func ::= LAST_ROW */ - { 411, -1 }, /* (407) star_func_para_list ::= NK_STAR */ - { 411, -1 }, /* (408) star_func_para_list ::= other_para_list */ - { 413, -1 }, /* (409) other_para_list ::= star_func_para */ - { 413, -3 }, /* (410) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 414, -1 }, /* (411) star_func_para ::= expr_or_subquery */ - { 414, -3 }, /* (412) star_func_para ::= table_name NK_DOT NK_STAR */ - { 409, -4 }, /* (413) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 409, -5 }, /* (414) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 415, -1 }, /* (415) when_then_list ::= when_then_expr */ - { 415, -2 }, /* (416) when_then_list ::= when_then_list when_then_expr */ - { 418, -4 }, /* (417) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 416, 0 }, /* (418) case_when_else_opt ::= */ - { 416, -2 }, /* (419) case_when_else_opt ::= ELSE common_expression */ - { 419, -3 }, /* (420) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 419, -5 }, /* (421) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 419, -6 }, /* (422) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 419, -3 }, /* (423) predicate ::= expr_or_subquery IS NULL */ - { 419, -4 }, /* (424) predicate ::= expr_or_subquery IS NOT NULL */ - { 419, -3 }, /* (425) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 420, -1 }, /* (426) compare_op ::= NK_LT */ - { 420, -1 }, /* (427) compare_op ::= NK_GT */ - { 420, -1 }, /* (428) compare_op ::= NK_LE */ - { 420, -1 }, /* (429) compare_op ::= NK_GE */ - { 420, -1 }, /* (430) compare_op ::= NK_NE */ - { 420, -1 }, /* (431) compare_op ::= NK_EQ */ - { 420, -1 }, /* (432) compare_op ::= LIKE */ - { 420, -2 }, /* (433) compare_op ::= NOT LIKE */ - { 420, -1 }, /* (434) compare_op ::= MATCH */ - { 420, -1 }, /* (435) compare_op ::= NMATCH */ - { 420, -1 }, /* (436) compare_op ::= CONTAINS */ - { 421, -1 }, /* (437) in_op ::= IN */ - { 421, -2 }, /* (438) in_op ::= NOT IN */ - { 422, -3 }, /* (439) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 423, -1 }, /* (440) boolean_value_expression ::= boolean_primary */ - { 423, -2 }, /* (441) boolean_value_expression ::= NOT boolean_primary */ - { 423, -3 }, /* (442) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 423, -3 }, /* (443) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 424, -1 }, /* (444) boolean_primary ::= predicate */ - { 424, -3 }, /* (445) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 417, -1 }, /* (446) common_expression ::= expr_or_subquery */ - { 417, -1 }, /* (447) common_expression ::= boolean_value_expression */ - { 425, 0 }, /* (448) from_clause_opt ::= */ - { 425, -2 }, /* (449) from_clause_opt ::= FROM table_reference_list */ - { 426, -1 }, /* (450) table_reference_list ::= table_reference */ - { 426, -3 }, /* (451) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 427, -1 }, /* (452) table_reference ::= table_primary */ - { 427, -1 }, /* (453) table_reference ::= joined_table */ - { 428, -2 }, /* (454) table_primary ::= table_name alias_opt */ - { 428, -4 }, /* (455) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 428, -2 }, /* (456) table_primary ::= subquery alias_opt */ - { 428, -1 }, /* (457) table_primary ::= parenthesized_joined_table */ - { 430, 0 }, /* (458) alias_opt ::= */ - { 430, -1 }, /* (459) alias_opt ::= table_alias */ - { 430, -2 }, /* (460) alias_opt ::= AS table_alias */ - { 432, -3 }, /* (461) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 432, -3 }, /* (462) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 429, -6 }, /* (463) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 433, 0 }, /* (464) join_type ::= */ - { 433, -1 }, /* (465) join_type ::= INNER */ - { 435, -12 }, /* (466) query_specification ::= SELECT set_quantifier_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 */ - { 436, 0 }, /* (467) set_quantifier_opt ::= */ - { 436, -1 }, /* (468) set_quantifier_opt ::= DISTINCT */ - { 436, -1 }, /* (469) set_quantifier_opt ::= ALL */ - { 437, -1 }, /* (470) select_list ::= select_item */ - { 437, -3 }, /* (471) select_list ::= select_list NK_COMMA select_item */ - { 445, -1 }, /* (472) select_item ::= NK_STAR */ - { 445, -1 }, /* (473) select_item ::= common_expression */ - { 445, -2 }, /* (474) select_item ::= common_expression column_alias */ - { 445, -3 }, /* (475) select_item ::= common_expression AS column_alias */ - { 445, -3 }, /* (476) select_item ::= table_name NK_DOT NK_STAR */ - { 400, 0 }, /* (477) where_clause_opt ::= */ - { 400, -2 }, /* (478) where_clause_opt ::= WHERE search_condition */ - { 438, 0 }, /* (479) partition_by_clause_opt ::= */ - { 438, -3 }, /* (480) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 446, -1 }, /* (481) partition_list ::= partition_item */ - { 446, -3 }, /* (482) partition_list ::= partition_list NK_COMMA partition_item */ - { 447, -1 }, /* (483) partition_item ::= expr_or_subquery */ - { 447, -2 }, /* (484) partition_item ::= expr_or_subquery column_alias */ - { 447, -3 }, /* (485) partition_item ::= expr_or_subquery AS column_alias */ - { 442, 0 }, /* (486) twindow_clause_opt ::= */ - { 442, -6 }, /* (487) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 442, -4 }, /* (488) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 442, -6 }, /* (489) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 442, -8 }, /* (490) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 386, 0 }, /* (491) sliding_opt ::= */ - { 386, -4 }, /* (492) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 441, 0 }, /* (493) fill_opt ::= */ - { 441, -4 }, /* (494) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 441, -6 }, /* (495) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 441, -6 }, /* (496) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ - { 448, -1 }, /* (497) fill_mode ::= NONE */ - { 448, -1 }, /* (498) fill_mode ::= PREV */ - { 448, -1 }, /* (499) fill_mode ::= NULL */ - { 448, -1 }, /* (500) fill_mode ::= NULL_F */ - { 448, -1 }, /* (501) fill_mode ::= LINEAR */ - { 448, -1 }, /* (502) fill_mode ::= NEXT */ - { 443, 0 }, /* (503) group_by_clause_opt ::= */ - { 443, -3 }, /* (504) group_by_clause_opt ::= GROUP BY group_by_list */ - { 449, -1 }, /* (505) group_by_list ::= expr_or_subquery */ - { 449, -3 }, /* (506) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 444, 0 }, /* (507) having_clause_opt ::= */ - { 444, -2 }, /* (508) having_clause_opt ::= HAVING search_condition */ - { 439, 0 }, /* (509) range_opt ::= */ - { 439, -6 }, /* (510) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 440, 0 }, /* (511) every_opt ::= */ - { 440, -4 }, /* (512) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 450, -4 }, /* (513) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 451, -1 }, /* (514) query_simple ::= query_specification */ - { 451, -1 }, /* (515) query_simple ::= union_query_expression */ - { 455, -4 }, /* (516) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 455, -3 }, /* (517) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 456, -1 }, /* (518) query_simple_or_subquery ::= query_simple */ - { 456, -1 }, /* (519) query_simple_or_subquery ::= subquery */ - { 389, -1 }, /* (520) query_or_subquery ::= query_expression */ - { 389, -1 }, /* (521) query_or_subquery ::= subquery */ - { 452, 0 }, /* (522) order_by_clause_opt ::= */ - { 452, -3 }, /* (523) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 453, 0 }, /* (524) slimit_clause_opt ::= */ - { 453, -2 }, /* (525) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 453, -4 }, /* (526) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 453, -4 }, /* (527) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 454, 0 }, /* (528) limit_clause_opt ::= */ - { 454, -2 }, /* (529) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 454, -4 }, /* (530) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 454, -4 }, /* (531) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 431, -3 }, /* (532) subquery ::= NK_LP query_expression NK_RP */ - { 431, -3 }, /* (533) subquery ::= NK_LP subquery NK_RP */ - { 434, -1 }, /* (534) search_condition ::= common_expression */ - { 457, -1 }, /* (535) sort_specification_list ::= sort_specification */ - { 457, -3 }, /* (536) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 458, -3 }, /* (537) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 459, 0 }, /* (538) ordering_specification_opt ::= */ - { 459, -1 }, /* (539) ordering_specification_opt ::= ASC */ - { 459, -1 }, /* (540) ordering_specification_opt ::= DESC */ - { 460, 0 }, /* (541) null_ordering_opt ::= */ - { 460, -2 }, /* (542) null_ordering_opt ::= NULLS FIRST */ - { 460, -2 }, /* (543) null_ordering_opt ::= NULLS LAST */ + { 396, -3 }, /* (304) stream_options ::= stream_options DELETE_MARK duration_literal */ + { 396, -4 }, /* (305) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + { 397, 0 }, /* (306) subtable_opt ::= */ + { 397, -4 }, /* (307) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 324, -3 }, /* (308) cmd ::= KILL CONNECTION NK_INTEGER */ + { 324, -3 }, /* (309) cmd ::= KILL QUERY NK_STRING */ + { 324, -3 }, /* (310) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 324, -2 }, /* (311) cmd ::= BALANCE VGROUP */ + { 324, -4 }, /* (312) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 324, -4 }, /* (313) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 324, -3 }, /* (314) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 399, -2 }, /* (315) dnode_list ::= DNODE NK_INTEGER */ + { 399, -3 }, /* (316) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 324, -4 }, /* (317) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 324, -1 }, /* (318) cmd ::= query_or_subquery */ + { 324, -7 }, /* (319) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 324, -4 }, /* (320) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 327, -1 }, /* (321) literal ::= NK_INTEGER */ + { 327, -1 }, /* (322) literal ::= NK_FLOAT */ + { 327, -1 }, /* (323) literal ::= NK_STRING */ + { 327, -1 }, /* (324) literal ::= NK_BOOL */ + { 327, -2 }, /* (325) literal ::= TIMESTAMP NK_STRING */ + { 327, -1 }, /* (326) literal ::= duration_literal */ + { 327, -1 }, /* (327) literal ::= NULL */ + { 327, -1 }, /* (328) literal ::= NK_QUESTION */ + { 371, -1 }, /* (329) duration_literal ::= NK_VARIABLE */ + { 401, -1 }, /* (330) signed ::= NK_INTEGER */ + { 401, -2 }, /* (331) signed ::= NK_PLUS NK_INTEGER */ + { 401, -2 }, /* (332) signed ::= NK_MINUS NK_INTEGER */ + { 401, -1 }, /* (333) signed ::= NK_FLOAT */ + { 401, -2 }, /* (334) signed ::= NK_PLUS NK_FLOAT */ + { 401, -2 }, /* (335) signed ::= NK_MINUS NK_FLOAT */ + { 360, -1 }, /* (336) signed_literal ::= signed */ + { 360, -1 }, /* (337) signed_literal ::= NK_STRING */ + { 360, -1 }, /* (338) signed_literal ::= NK_BOOL */ + { 360, -2 }, /* (339) signed_literal ::= TIMESTAMP NK_STRING */ + { 360, -1 }, /* (340) signed_literal ::= duration_literal */ + { 360, -1 }, /* (341) signed_literal ::= NULL */ + { 360, -1 }, /* (342) signed_literal ::= literal_func */ + { 360, -1 }, /* (343) signed_literal ::= NK_QUESTION */ + { 403, -1 }, /* (344) literal_list ::= signed_literal */ + { 403, -3 }, /* (345) literal_list ::= literal_list NK_COMMA signed_literal */ + { 335, -1 }, /* (346) db_name ::= NK_ID */ + { 366, -1 }, /* (347) table_name ::= NK_ID */ + { 358, -1 }, /* (348) column_name ::= NK_ID */ + { 373, -1 }, /* (349) function_name ::= NK_ID */ + { 404, -1 }, /* (350) table_alias ::= NK_ID */ + { 381, -1 }, /* (351) column_alias ::= NK_ID */ + { 329, -1 }, /* (352) user_name ::= NK_ID */ + { 336, -1 }, /* (353) topic_name ::= NK_ID */ + { 395, -1 }, /* (354) stream_name ::= NK_ID */ + { 390, -1 }, /* (355) cgroup_name ::= NK_ID */ + { 384, -1 }, /* (356) index_name ::= NK_ID */ + { 405, -1 }, /* (357) expr_or_subquery ::= expression */ + { 398, -1 }, /* (358) expression ::= literal */ + { 398, -1 }, /* (359) expression ::= pseudo_column */ + { 398, -1 }, /* (360) expression ::= column_reference */ + { 398, -1 }, /* (361) expression ::= function_expression */ + { 398, -1 }, /* (362) expression ::= case_when_expression */ + { 398, -3 }, /* (363) expression ::= NK_LP expression NK_RP */ + { 398, -2 }, /* (364) expression ::= NK_PLUS expr_or_subquery */ + { 398, -2 }, /* (365) expression ::= NK_MINUS expr_or_subquery */ + { 398, -3 }, /* (366) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 398, -3 }, /* (367) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 398, -3 }, /* (368) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 398, -3 }, /* (369) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 398, -3 }, /* (370) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 398, -3 }, /* (371) expression ::= column_reference NK_ARROW NK_STRING */ + { 398, -3 }, /* (372) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 398, -3 }, /* (373) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 363, -1 }, /* (374) expression_list ::= expr_or_subquery */ + { 363, -3 }, /* (375) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 407, -1 }, /* (376) column_reference ::= column_name */ + { 407, -3 }, /* (377) column_reference ::= table_name NK_DOT column_name */ + { 406, -1 }, /* (378) pseudo_column ::= ROWTS */ + { 406, -1 }, /* (379) pseudo_column ::= TBNAME */ + { 406, -3 }, /* (380) pseudo_column ::= table_name NK_DOT TBNAME */ + { 406, -1 }, /* (381) pseudo_column ::= QSTART */ + { 406, -1 }, /* (382) pseudo_column ::= QEND */ + { 406, -1 }, /* (383) pseudo_column ::= QDURATION */ + { 406, -1 }, /* (384) pseudo_column ::= WSTART */ + { 406, -1 }, /* (385) pseudo_column ::= WEND */ + { 406, -1 }, /* (386) pseudo_column ::= WDURATION */ + { 406, -1 }, /* (387) pseudo_column ::= IROWTS */ + { 406, -1 }, /* (388) pseudo_column ::= QTAGS */ + { 408, -4 }, /* (389) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 408, -4 }, /* (390) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 408, -6 }, /* (391) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 408, -1 }, /* (392) function_expression ::= literal_func */ + { 402, -3 }, /* (393) literal_func ::= noarg_func NK_LP NK_RP */ + { 402, -1 }, /* (394) literal_func ::= NOW */ + { 412, -1 }, /* (395) noarg_func ::= NOW */ + { 412, -1 }, /* (396) noarg_func ::= TODAY */ + { 412, -1 }, /* (397) noarg_func ::= TIMEZONE */ + { 412, -1 }, /* (398) noarg_func ::= DATABASE */ + { 412, -1 }, /* (399) noarg_func ::= CLIENT_VERSION */ + { 412, -1 }, /* (400) noarg_func ::= SERVER_VERSION */ + { 412, -1 }, /* (401) noarg_func ::= SERVER_STATUS */ + { 412, -1 }, /* (402) noarg_func ::= CURRENT_USER */ + { 412, -1 }, /* (403) noarg_func ::= USER */ + { 410, -1 }, /* (404) star_func ::= COUNT */ + { 410, -1 }, /* (405) star_func ::= FIRST */ + { 410, -1 }, /* (406) star_func ::= LAST */ + { 410, -1 }, /* (407) star_func ::= LAST_ROW */ + { 411, -1 }, /* (408) star_func_para_list ::= NK_STAR */ + { 411, -1 }, /* (409) star_func_para_list ::= other_para_list */ + { 413, -1 }, /* (410) other_para_list ::= star_func_para */ + { 413, -3 }, /* (411) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 414, -1 }, /* (412) star_func_para ::= expr_or_subquery */ + { 414, -3 }, /* (413) star_func_para ::= table_name NK_DOT NK_STAR */ + { 409, -4 }, /* (414) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 409, -5 }, /* (415) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 415, -1 }, /* (416) when_then_list ::= when_then_expr */ + { 415, -2 }, /* (417) when_then_list ::= when_then_list when_then_expr */ + { 418, -4 }, /* (418) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 416, 0 }, /* (419) case_when_else_opt ::= */ + { 416, -2 }, /* (420) case_when_else_opt ::= ELSE common_expression */ + { 419, -3 }, /* (421) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 419, -5 }, /* (422) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 419, -6 }, /* (423) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 419, -3 }, /* (424) predicate ::= expr_or_subquery IS NULL */ + { 419, -4 }, /* (425) predicate ::= expr_or_subquery IS NOT NULL */ + { 419, -3 }, /* (426) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 420, -1 }, /* (427) compare_op ::= NK_LT */ + { 420, -1 }, /* (428) compare_op ::= NK_GT */ + { 420, -1 }, /* (429) compare_op ::= NK_LE */ + { 420, -1 }, /* (430) compare_op ::= NK_GE */ + { 420, -1 }, /* (431) compare_op ::= NK_NE */ + { 420, -1 }, /* (432) compare_op ::= NK_EQ */ + { 420, -1 }, /* (433) compare_op ::= LIKE */ + { 420, -2 }, /* (434) compare_op ::= NOT LIKE */ + { 420, -1 }, /* (435) compare_op ::= MATCH */ + { 420, -1 }, /* (436) compare_op ::= NMATCH */ + { 420, -1 }, /* (437) compare_op ::= CONTAINS */ + { 421, -1 }, /* (438) in_op ::= IN */ + { 421, -2 }, /* (439) in_op ::= NOT IN */ + { 422, -3 }, /* (440) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 423, -1 }, /* (441) boolean_value_expression ::= boolean_primary */ + { 423, -2 }, /* (442) boolean_value_expression ::= NOT boolean_primary */ + { 423, -3 }, /* (443) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 423, -3 }, /* (444) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 424, -1 }, /* (445) boolean_primary ::= predicate */ + { 424, -3 }, /* (446) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 417, -1 }, /* (447) common_expression ::= expr_or_subquery */ + { 417, -1 }, /* (448) common_expression ::= boolean_value_expression */ + { 425, 0 }, /* (449) from_clause_opt ::= */ + { 425, -2 }, /* (450) from_clause_opt ::= FROM table_reference_list */ + { 426, -1 }, /* (451) table_reference_list ::= table_reference */ + { 426, -3 }, /* (452) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 427, -1 }, /* (453) table_reference ::= table_primary */ + { 427, -1 }, /* (454) table_reference ::= joined_table */ + { 428, -2 }, /* (455) table_primary ::= table_name alias_opt */ + { 428, -4 }, /* (456) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 428, -2 }, /* (457) table_primary ::= subquery alias_opt */ + { 428, -1 }, /* (458) table_primary ::= parenthesized_joined_table */ + { 430, 0 }, /* (459) alias_opt ::= */ + { 430, -1 }, /* (460) alias_opt ::= table_alias */ + { 430, -2 }, /* (461) alias_opt ::= AS table_alias */ + { 432, -3 }, /* (462) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 432, -3 }, /* (463) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 429, -6 }, /* (464) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 433, 0 }, /* (465) join_type ::= */ + { 433, -1 }, /* (466) join_type ::= INNER */ + { 435, -12 }, /* (467) query_specification ::= SELECT set_quantifier_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 */ + { 436, 0 }, /* (468) set_quantifier_opt ::= */ + { 436, -1 }, /* (469) set_quantifier_opt ::= DISTINCT */ + { 436, -1 }, /* (470) set_quantifier_opt ::= ALL */ + { 437, -1 }, /* (471) select_list ::= select_item */ + { 437, -3 }, /* (472) select_list ::= select_list NK_COMMA select_item */ + { 445, -1 }, /* (473) select_item ::= NK_STAR */ + { 445, -1 }, /* (474) select_item ::= common_expression */ + { 445, -2 }, /* (475) select_item ::= common_expression column_alias */ + { 445, -3 }, /* (476) select_item ::= common_expression AS column_alias */ + { 445, -3 }, /* (477) select_item ::= table_name NK_DOT NK_STAR */ + { 400, 0 }, /* (478) where_clause_opt ::= */ + { 400, -2 }, /* (479) where_clause_opt ::= WHERE search_condition */ + { 438, 0 }, /* (480) partition_by_clause_opt ::= */ + { 438, -3 }, /* (481) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 446, -1 }, /* (482) partition_list ::= partition_item */ + { 446, -3 }, /* (483) partition_list ::= partition_list NK_COMMA partition_item */ + { 447, -1 }, /* (484) partition_item ::= expr_or_subquery */ + { 447, -2 }, /* (485) partition_item ::= expr_or_subquery column_alias */ + { 447, -3 }, /* (486) partition_item ::= expr_or_subquery AS column_alias */ + { 442, 0 }, /* (487) twindow_clause_opt ::= */ + { 442, -6 }, /* (488) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 442, -4 }, /* (489) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 442, -6 }, /* (490) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 442, -8 }, /* (491) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 386, 0 }, /* (492) sliding_opt ::= */ + { 386, -4 }, /* (493) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 441, 0 }, /* (494) fill_opt ::= */ + { 441, -4 }, /* (495) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 441, -6 }, /* (496) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 441, -6 }, /* (497) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ + { 448, -1 }, /* (498) fill_mode ::= NONE */ + { 448, -1 }, /* (499) fill_mode ::= PREV */ + { 448, -1 }, /* (500) fill_mode ::= NULL */ + { 448, -1 }, /* (501) fill_mode ::= NULL_F */ + { 448, -1 }, /* (502) fill_mode ::= LINEAR */ + { 448, -1 }, /* (503) fill_mode ::= NEXT */ + { 443, 0 }, /* (504) group_by_clause_opt ::= */ + { 443, -3 }, /* (505) group_by_clause_opt ::= GROUP BY group_by_list */ + { 449, -1 }, /* (506) group_by_list ::= expr_or_subquery */ + { 449, -3 }, /* (507) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 444, 0 }, /* (508) having_clause_opt ::= */ + { 444, -2 }, /* (509) having_clause_opt ::= HAVING search_condition */ + { 439, 0 }, /* (510) range_opt ::= */ + { 439, -6 }, /* (511) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 440, 0 }, /* (512) every_opt ::= */ + { 440, -4 }, /* (513) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 450, -4 }, /* (514) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 451, -1 }, /* (515) query_simple ::= query_specification */ + { 451, -1 }, /* (516) query_simple ::= union_query_expression */ + { 455, -4 }, /* (517) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 455, -3 }, /* (518) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 456, -1 }, /* (519) query_simple_or_subquery ::= query_simple */ + { 456, -1 }, /* (520) query_simple_or_subquery ::= subquery */ + { 389, -1 }, /* (521) query_or_subquery ::= query_expression */ + { 389, -1 }, /* (522) query_or_subquery ::= subquery */ + { 452, 0 }, /* (523) order_by_clause_opt ::= */ + { 452, -3 }, /* (524) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 453, 0 }, /* (525) slimit_clause_opt ::= */ + { 453, -2 }, /* (526) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 453, -4 }, /* (527) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 453, -4 }, /* (528) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 454, 0 }, /* (529) limit_clause_opt ::= */ + { 454, -2 }, /* (530) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 454, -4 }, /* (531) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 454, -4 }, /* (532) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 431, -3 }, /* (533) subquery ::= NK_LP query_expression NK_RP */ + { 431, -3 }, /* (534) subquery ::= NK_LP subquery NK_RP */ + { 434, -1 }, /* (535) search_condition ::= common_expression */ + { 457, -1 }, /* (536) sort_specification_list ::= sort_specification */ + { 457, -3 }, /* (537) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 458, -3 }, /* (538) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 459, 0 }, /* (539) ordering_specification_opt ::= */ + { 459, -1 }, /* (540) ordering_specification_opt ::= ASC */ + { 459, -1 }, /* (541) ordering_specification_opt ::= DESC */ + { 460, 0 }, /* (542) null_ordering_opt ::= */ + { 460, -2 }, /* (543) null_ordering_opt ::= NULLS FIRST */ + { 460, -2 }, /* (544) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3745,7 +3747,7 @@ static YYACTIONTYPE yy_reduce( yymsp[-2].minor.yy77 = yylhsminor.yy77; break; case 42: /* priv_level ::= topic_name */ - case 459: /* alias_opt ::= table_alias */ yytestcase(yyruleno==459); + case 460: /* alias_opt ::= table_alias */ yytestcase(yyruleno==460); { yylhsminor.yy77 = yymsp[0].minor.yy77; } yymsp[0].minor.yy77 = yylhsminor.yy77; break; @@ -3776,30 +3778,30 @@ static YYACTIONTYPE yy_reduce( case 51: /* dnode_endpoint ::= NK_STRING */ case 52: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==52); case 53: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==53); - case 345: /* db_name ::= NK_ID */ yytestcase(yyruleno==345); - case 346: /* table_name ::= NK_ID */ yytestcase(yyruleno==346); - case 347: /* column_name ::= NK_ID */ yytestcase(yyruleno==347); - case 348: /* function_name ::= NK_ID */ yytestcase(yyruleno==348); - case 349: /* table_alias ::= NK_ID */ yytestcase(yyruleno==349); - case 350: /* column_alias ::= NK_ID */ yytestcase(yyruleno==350); - case 351: /* user_name ::= NK_ID */ yytestcase(yyruleno==351); - case 352: /* topic_name ::= NK_ID */ yytestcase(yyruleno==352); - case 353: /* stream_name ::= NK_ID */ yytestcase(yyruleno==353); - case 354: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==354); - case 355: /* index_name ::= NK_ID */ yytestcase(yyruleno==355); - case 394: /* noarg_func ::= NOW */ yytestcase(yyruleno==394); - case 395: /* noarg_func ::= TODAY */ yytestcase(yyruleno==395); - case 396: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==396); - case 397: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==397); - case 398: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==398); - case 399: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==399); - case 400: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==400); - case 401: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==401); - case 402: /* noarg_func ::= USER */ yytestcase(yyruleno==402); - case 403: /* star_func ::= COUNT */ yytestcase(yyruleno==403); - case 404: /* star_func ::= FIRST */ yytestcase(yyruleno==404); - case 405: /* star_func ::= LAST */ yytestcase(yyruleno==405); - case 406: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==406); + case 346: /* db_name ::= NK_ID */ yytestcase(yyruleno==346); + case 347: /* table_name ::= NK_ID */ yytestcase(yyruleno==347); + case 348: /* column_name ::= NK_ID */ yytestcase(yyruleno==348); + case 349: /* function_name ::= NK_ID */ yytestcase(yyruleno==349); + case 350: /* table_alias ::= NK_ID */ yytestcase(yyruleno==350); + case 351: /* column_alias ::= NK_ID */ yytestcase(yyruleno==351); + case 352: /* user_name ::= NK_ID */ yytestcase(yyruleno==352); + case 353: /* topic_name ::= NK_ID */ yytestcase(yyruleno==353); + case 354: /* stream_name ::= NK_ID */ yytestcase(yyruleno==354); + case 355: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==355); + case 356: /* index_name ::= NK_ID */ yytestcase(yyruleno==356); + case 395: /* noarg_func ::= NOW */ yytestcase(yyruleno==395); + case 396: /* noarg_func ::= TODAY */ yytestcase(yyruleno==396); + case 397: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==397); + case 398: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==398); + case 399: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==399); + case 400: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==400); + case 401: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==401); + case 402: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==402); + case 403: /* noarg_func ::= USER */ yytestcase(yyruleno==403); + case 404: /* star_func ::= COUNT */ yytestcase(yyruleno==404); + case 405: /* star_func ::= FIRST */ yytestcase(yyruleno==405); + case 406: /* star_func ::= LAST */ yytestcase(yyruleno==406); + case 407: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==407); { yylhsminor.yy77 = yymsp[0].minor.yy0; } yymsp[0].minor.yy77 = yylhsminor.yy77; break; @@ -3808,13 +3810,13 @@ static YYACTIONTYPE yy_reduce( case 75: /* exists_opt ::= */ yytestcase(yyruleno==75); case 284: /* analyze_opt ::= */ yytestcase(yyruleno==284); case 291: /* agg_func_opt ::= */ yytestcase(yyruleno==291); - case 467: /* set_quantifier_opt ::= */ yytestcase(yyruleno==467); + case 468: /* set_quantifier_opt ::= */ yytestcase(yyruleno==468); { yymsp[1].minor.yy841 = false; } break; case 55: /* force_opt ::= FORCE */ case 285: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==285); case 292: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==292); - case 468: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==468); + case 469: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==469); { yymsp[0].minor.yy841 = true; } break; case 56: /* cmd ::= ALTER LOCAL NK_STRING */ @@ -4037,7 +4039,7 @@ static YYACTIONTYPE yy_reduce( yymsp[0].minor.yy601 = yylhsminor.yy601; break; case 120: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 315: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==315); + case 316: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==316); { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } yymsp[-2].minor.yy601 = yylhsminor.yy601; break; @@ -4057,12 +4059,12 @@ static YYACTIONTYPE yy_reduce( case 204: /* col_name_list ::= col_name */ yytestcase(yyruleno==204); case 253: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==253); case 266: /* func_list ::= func */ yytestcase(yyruleno==266); - case 343: /* literal_list ::= signed_literal */ yytestcase(yyruleno==343); - case 409: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==409); - case 415: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==415); - case 470: /* select_list ::= select_item */ yytestcase(yyruleno==470); - case 481: /* partition_list ::= partition_item */ yytestcase(yyruleno==481); - case 535: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==535); + case 344: /* literal_list ::= signed_literal */ yytestcase(yyruleno==344); + case 410: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==410); + case 416: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==416); + case 471: /* select_list ::= select_item */ yytestcase(yyruleno==471); + case 482: /* partition_list ::= partition_item */ yytestcase(yyruleno==482); + case 536: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==536); { yylhsminor.yy601 = createNodeList(pCxt, yymsp[0].minor.yy600); } yymsp[0].minor.yy601 = yylhsminor.yy601; break; @@ -4072,11 +4074,11 @@ static YYACTIONTYPE yy_reduce( case 205: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==205); case 254: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==254); case 267: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==267); - case 344: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==344); - case 410: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==410); - case 471: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==471); - case 482: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==482); - case 536: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==536); + case 345: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==345); + case 411: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==411); + case 472: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==472); + case 483: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==483); + case 537: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==537); { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } yymsp[-2].minor.yy601 = yylhsminor.yy601; break; @@ -4106,7 +4108,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } break; case 133: /* cmd ::= ALTER TABLE alter_table_clause */ - case 317: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==317); + case 318: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==318); { pCxt->pRootNode = yymsp[0].minor.yy600; } break; case 134: /* cmd ::= ALTER STABLE alter_table_clause */ @@ -4154,7 +4156,7 @@ static YYACTIONTYPE yy_reduce( break; case 146: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 149: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==149); - case 416: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==416); + case 417: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==417); { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-1].minor.yy601, yymsp[0].minor.yy600); } yymsp[-1].minor.yy601 = yylhsminor.yy601; break; @@ -4169,9 +4171,9 @@ static YYACTIONTYPE yy_reduce( case 151: /* specific_cols_opt ::= */ case 182: /* tags_def_opt ::= */ yytestcase(yyruleno==182); case 252: /* tag_list_opt ::= */ yytestcase(yyruleno==252); - case 479: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==479); - case 503: /* group_by_clause_opt ::= */ yytestcase(yyruleno==503); - case 522: /* order_by_clause_opt ::= */ yytestcase(yyruleno==522); + case 480: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==480); + case 504: /* group_by_clause_opt ::= */ yytestcase(yyruleno==504); + case 523: /* order_by_clause_opt ::= */ yytestcase(yyruleno==523); { yymsp[1].minor.yy601 = NULL; } break; case 152: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ @@ -4261,7 +4263,7 @@ static YYACTIONTYPE yy_reduce( { yymsp[-5].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 183: /* tags_def_opt ::= tags_def */ - case 408: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==408); + case 409: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==409); { yylhsminor.yy601 = yymsp[0].minor.yy601; } yymsp[0].minor.yy601 = yylhsminor.yy601; break; @@ -4314,12 +4316,12 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy661.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 197: /* duration_list ::= duration_literal */ - case 373: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==373); + case 374: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==374); { yylhsminor.yy601 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } yymsp[0].minor.yy601 = yylhsminor.yy601; break; case 198: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 374: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==374); + case 375: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==375); { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } yymsp[-2].minor.yy601 = yylhsminor.yy601; break; @@ -4457,18 +4459,18 @@ static YYACTIONTYPE yy_reduce( yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 247: /* like_pattern_opt ::= */ - case 305: /* subtable_opt ::= */ yytestcase(yyruleno==305); - case 418: /* case_when_else_opt ::= */ yytestcase(yyruleno==418); - case 448: /* from_clause_opt ::= */ yytestcase(yyruleno==448); - case 477: /* where_clause_opt ::= */ yytestcase(yyruleno==477); - case 486: /* twindow_clause_opt ::= */ yytestcase(yyruleno==486); - case 491: /* sliding_opt ::= */ yytestcase(yyruleno==491); - case 493: /* fill_opt ::= */ yytestcase(yyruleno==493); - case 507: /* having_clause_opt ::= */ yytestcase(yyruleno==507); - case 509: /* range_opt ::= */ yytestcase(yyruleno==509); - case 511: /* every_opt ::= */ yytestcase(yyruleno==511); - case 524: /* slimit_clause_opt ::= */ yytestcase(yyruleno==524); - case 528: /* limit_clause_opt ::= */ yytestcase(yyruleno==528); + case 306: /* subtable_opt ::= */ yytestcase(yyruleno==306); + case 419: /* case_when_else_opt ::= */ yytestcase(yyruleno==419); + case 449: /* from_clause_opt ::= */ yytestcase(yyruleno==449); + case 478: /* where_clause_opt ::= */ yytestcase(yyruleno==478); + case 487: /* twindow_clause_opt ::= */ yytestcase(yyruleno==487); + case 492: /* sliding_opt ::= */ yytestcase(yyruleno==492); + case 494: /* fill_opt ::= */ yytestcase(yyruleno==494); + case 508: /* having_clause_opt ::= */ yytestcase(yyruleno==508); + case 510: /* range_opt ::= */ yytestcase(yyruleno==510); + case 512: /* every_opt ::= */ yytestcase(yyruleno==512); + case 525: /* slimit_clause_opt ::= */ yytestcase(yyruleno==525); + case 529: /* limit_clause_opt ::= */ yytestcase(yyruleno==529); { yymsp[1].minor.yy600 = NULL; } break; case 248: /* like_pattern_opt ::= LIKE NK_STRING */ @@ -4531,6 +4533,7 @@ static YYACTIONTYPE yy_reduce( yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 272: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + case 304: /* stream_options ::= stream_options DELETE_MARK duration_literal */ yytestcase(yyruleno==304); { ((SStreamOptions*)yymsp[-2].minor.yy600)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-2].minor.yy600; } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; @@ -4608,112 +4611,112 @@ static YYACTIONTYPE yy_reduce( { ((SStreamOptions*)yymsp[-2].minor.yy600)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy600 = yymsp[-2].minor.yy600; } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 304: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + case 305: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ { ((SStreamOptions*)yymsp[-3].minor.yy600)->ignoreUpdate = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy600 = yymsp[-3].minor.yy600; } yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 306: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 492: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==492); - case 512: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==512); + case 307: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 493: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==493); + case 513: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==513); { yymsp[-3].minor.yy600 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy600); } break; - case 307: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 308: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 308: /* cmd ::= KILL QUERY NK_STRING */ + case 309: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 309: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 310: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 310: /* cmd ::= BALANCE VGROUP */ + case 311: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 311: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 312: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 312: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + case 313: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy601); } break; - case 313: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 314: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 314: /* dnode_list ::= DNODE NK_INTEGER */ + case 315: /* dnode_list ::= DNODE NK_INTEGER */ { yymsp[-1].minor.yy601 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 316: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ + case 317: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ { pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; - case 318: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + case 319: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ { pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy600, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } break; - case 319: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ + case 320: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ { pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy600, NULL, yymsp[0].minor.yy600); } break; - case 320: /* literal ::= NK_INTEGER */ + case 321: /* literal ::= NK_INTEGER */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 321: /* literal ::= NK_FLOAT */ + case 322: /* literal ::= NK_FLOAT */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 322: /* literal ::= NK_STRING */ + case 323: /* literal ::= NK_STRING */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 323: /* literal ::= NK_BOOL */ + case 324: /* literal ::= NK_BOOL */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 324: /* literal ::= TIMESTAMP NK_STRING */ + case 325: /* literal ::= TIMESTAMP NK_STRING */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 325: /* literal ::= duration_literal */ - case 335: /* signed_literal ::= signed */ yytestcase(yyruleno==335); - case 356: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==356); - case 357: /* expression ::= literal */ yytestcase(yyruleno==357); - case 358: /* expression ::= pseudo_column */ yytestcase(yyruleno==358); - case 359: /* expression ::= column_reference */ yytestcase(yyruleno==359); - case 360: /* expression ::= function_expression */ yytestcase(yyruleno==360); - case 361: /* expression ::= case_when_expression */ yytestcase(yyruleno==361); - case 391: /* function_expression ::= literal_func */ yytestcase(yyruleno==391); - case 440: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==440); - case 444: /* boolean_primary ::= predicate */ yytestcase(yyruleno==444); - case 446: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==446); - case 447: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==447); - case 450: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==450); - case 452: /* table_reference ::= table_primary */ yytestcase(yyruleno==452); - case 453: /* table_reference ::= joined_table */ yytestcase(yyruleno==453); - case 457: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==457); - case 514: /* query_simple ::= query_specification */ yytestcase(yyruleno==514); - case 515: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==515); - case 518: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==518); - case 520: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==520); + case 326: /* literal ::= duration_literal */ + case 336: /* signed_literal ::= signed */ yytestcase(yyruleno==336); + case 357: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==357); + case 358: /* expression ::= literal */ yytestcase(yyruleno==358); + case 359: /* expression ::= pseudo_column */ yytestcase(yyruleno==359); + case 360: /* expression ::= column_reference */ yytestcase(yyruleno==360); + case 361: /* expression ::= function_expression */ yytestcase(yyruleno==361); + case 362: /* expression ::= case_when_expression */ yytestcase(yyruleno==362); + case 392: /* function_expression ::= literal_func */ yytestcase(yyruleno==392); + case 441: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==441); + case 445: /* boolean_primary ::= predicate */ yytestcase(yyruleno==445); + case 447: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==447); + case 448: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==448); + case 451: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==451); + case 453: /* table_reference ::= table_primary */ yytestcase(yyruleno==453); + case 454: /* table_reference ::= joined_table */ yytestcase(yyruleno==454); + case 458: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==458); + case 515: /* query_simple ::= query_specification */ yytestcase(yyruleno==515); + case 516: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==516); + case 519: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==519); + case 521: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==521); { yylhsminor.yy600 = yymsp[0].minor.yy600; } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 326: /* literal ::= NULL */ + case 327: /* literal ::= NULL */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 327: /* literal ::= NK_QUESTION */ + case 328: /* literal ::= NK_QUESTION */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 328: /* duration_literal ::= NK_VARIABLE */ + case 329: /* duration_literal ::= NK_VARIABLE */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 329: /* signed ::= NK_INTEGER */ + case 330: /* signed ::= NK_INTEGER */ { yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 330: /* signed ::= NK_PLUS NK_INTEGER */ + case 331: /* signed ::= NK_PLUS NK_INTEGER */ { yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 331: /* signed ::= NK_MINUS NK_INTEGER */ + case 332: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; @@ -4721,14 +4724,14 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 332: /* signed ::= NK_FLOAT */ + case 333: /* signed ::= NK_FLOAT */ { yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 333: /* signed ::= NK_PLUS NK_FLOAT */ + case 334: /* signed ::= NK_PLUS NK_FLOAT */ { yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 334: /* signed ::= NK_MINUS NK_FLOAT */ + case 335: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; @@ -4736,57 +4739,57 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 336: /* signed_literal ::= NK_STRING */ + case 337: /* signed_literal ::= NK_STRING */ { yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 337: /* signed_literal ::= NK_BOOL */ + case 338: /* signed_literal ::= NK_BOOL */ { yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 338: /* signed_literal ::= TIMESTAMP NK_STRING */ + case 339: /* signed_literal ::= TIMESTAMP NK_STRING */ { yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 339: /* signed_literal ::= duration_literal */ - case 341: /* signed_literal ::= literal_func */ yytestcase(yyruleno==341); - case 411: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==411); - case 473: /* select_item ::= common_expression */ yytestcase(yyruleno==473); - case 483: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==483); - case 519: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==519); - case 521: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==521); - case 534: /* search_condition ::= common_expression */ yytestcase(yyruleno==534); + case 340: /* signed_literal ::= duration_literal */ + case 342: /* signed_literal ::= literal_func */ yytestcase(yyruleno==342); + case 412: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==412); + case 474: /* select_item ::= common_expression */ yytestcase(yyruleno==474); + case 484: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==484); + case 520: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==520); + case 522: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==522); + case 535: /* search_condition ::= common_expression */ yytestcase(yyruleno==535); { yylhsminor.yy600 = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 340: /* signed_literal ::= NULL */ + case 341: /* signed_literal ::= NULL */ { yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 342: /* signed_literal ::= NK_QUESTION */ + case 343: /* signed_literal ::= NK_QUESTION */ { yylhsminor.yy600 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 362: /* expression ::= NK_LP expression NK_RP */ - case 445: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==445); - case 533: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==533); + case 363: /* expression ::= NK_LP expression NK_RP */ + case 446: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==446); + case 534: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==534); { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 363: /* expression ::= NK_PLUS expr_or_subquery */ + case 364: /* expression ::= NK_PLUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 364: /* expression ::= NK_MINUS expr_or_subquery */ + case 365: /* expression ::= NK_MINUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy600), NULL)); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 365: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 366: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4794,7 +4797,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 366: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 367: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4802,7 +4805,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 367: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 368: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4810,7 +4813,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 368: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 369: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4818,7 +4821,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 369: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 370: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4826,14 +4829,14 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 370: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 371: /* expression ::= column_reference NK_ARROW NK_STRING */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 371: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 372: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4841,7 +4844,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 372: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 373: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4849,70 +4852,70 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 375: /* column_reference ::= column_name */ + case 376: /* column_reference ::= column_name */ { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy77, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy77)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 376: /* column_reference ::= table_name NK_DOT column_name */ + case 377: /* column_reference ::= table_name NK_DOT column_name */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77, createColumnNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77)); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 377: /* pseudo_column ::= ROWTS */ - case 378: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==378); - case 380: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==380); - case 381: /* pseudo_column ::= QEND */ yytestcase(yyruleno==381); - case 382: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==382); - case 383: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==383); - case 384: /* pseudo_column ::= WEND */ yytestcase(yyruleno==384); - case 385: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==385); - case 386: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==386); - case 387: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==387); - case 393: /* literal_func ::= NOW */ yytestcase(yyruleno==393); + case 378: /* pseudo_column ::= ROWTS */ + case 379: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==379); + case 381: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==381); + case 382: /* pseudo_column ::= QEND */ yytestcase(yyruleno==382); + case 383: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==383); + case 384: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==384); + case 385: /* pseudo_column ::= WEND */ yytestcase(yyruleno==385); + case 386: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==386); + case 387: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==387); + case 388: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==388); + case 394: /* literal_func ::= NOW */ yytestcase(yyruleno==394); { yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 379: /* pseudo_column ::= table_name NK_DOT TBNAME */ + case 380: /* pseudo_column ::= table_name NK_DOT TBNAME */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy77)))); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 388: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 389: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==389); + case 389: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 390: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==390); { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy77, yymsp[-1].minor.yy601)); } yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 390: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + case 391: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy888)); } yymsp[-5].minor.yy600 = yylhsminor.yy600; break; - case 392: /* literal_func ::= noarg_func NK_LP NK_RP */ + case 393: /* literal_func ::= noarg_func NK_LP NK_RP */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy77, NULL)); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 407: /* star_func_para_list ::= NK_STAR */ + case 408: /* star_func_para_list ::= NK_STAR */ { yylhsminor.yy601 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy601 = yylhsminor.yy601; break; - case 412: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 476: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==476); + case 413: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 477: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==477); { yylhsminor.yy600 = createColumnNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 413: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ + case 414: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy601, yymsp[-1].minor.yy600)); } yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 414: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + case 415: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-2].minor.yy601, yymsp[-1].minor.yy600)); } yymsp[-4].minor.yy600 = yylhsminor.yy600; break; - case 417: /* when_then_expr ::= WHEN common_expression THEN common_expression */ + case 418: /* when_then_expr ::= WHEN common_expression THEN common_expression */ { yymsp[-3].minor.yy600 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } break; - case 419: /* case_when_else_opt ::= ELSE common_expression */ + case 420: /* case_when_else_opt ::= ELSE common_expression */ { yymsp[-1].minor.yy600 = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); } break; - case 420: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 425: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==425); + case 421: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 426: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==426); { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4920,7 +4923,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 421: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 422: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4928,7 +4931,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy600 = yylhsminor.yy600; break; - case 422: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 423: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -4936,71 +4939,71 @@ static YYACTIONTYPE yy_reduce( } yymsp[-5].minor.yy600 = yylhsminor.yy600; break; - case 423: /* predicate ::= expr_or_subquery IS NULL */ + case 424: /* predicate ::= expr_or_subquery IS NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), NULL)); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 424: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 425: /* predicate ::= expr_or_subquery IS NOT NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy600); yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL)); } yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 426: /* compare_op ::= NK_LT */ + case 427: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy666 = OP_TYPE_LOWER_THAN; } break; - case 427: /* compare_op ::= NK_GT */ + case 428: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy666 = OP_TYPE_GREATER_THAN; } break; - case 428: /* compare_op ::= NK_LE */ + case 429: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy666 = OP_TYPE_LOWER_EQUAL; } break; - case 429: /* compare_op ::= NK_GE */ + case 430: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy666 = OP_TYPE_GREATER_EQUAL; } break; - case 430: /* compare_op ::= NK_NE */ + case 431: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy666 = OP_TYPE_NOT_EQUAL; } break; - case 431: /* compare_op ::= NK_EQ */ + case 432: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy666 = OP_TYPE_EQUAL; } break; - case 432: /* compare_op ::= LIKE */ + case 433: /* compare_op ::= LIKE */ { yymsp[0].minor.yy666 = OP_TYPE_LIKE; } break; - case 433: /* compare_op ::= NOT LIKE */ + case 434: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy666 = OP_TYPE_NOT_LIKE; } break; - case 434: /* compare_op ::= MATCH */ + case 435: /* compare_op ::= MATCH */ { yymsp[0].minor.yy666 = OP_TYPE_MATCH; } break; - case 435: /* compare_op ::= NMATCH */ + case 436: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy666 = OP_TYPE_NMATCH; } break; - case 436: /* compare_op ::= CONTAINS */ + case 437: /* compare_op ::= CONTAINS */ { yymsp[0].minor.yy666 = OP_TYPE_JSON_CONTAINS; } break; - case 437: /* in_op ::= IN */ + case 438: /* in_op ::= IN */ { yymsp[0].minor.yy666 = OP_TYPE_IN; } break; - case 438: /* in_op ::= NOT IN */ + case 439: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy666 = OP_TYPE_NOT_IN; } break; - case 439: /* in_predicate_value ::= NK_LP literal_list NK_RP */ + case 440: /* in_predicate_value ::= NK_LP literal_list NK_RP */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 441: /* boolean_value_expression ::= NOT boolean_primary */ + case 442: /* boolean_value_expression ::= NOT boolean_primary */ { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy600), NULL)); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 442: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 443: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -5008,7 +5011,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 443: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 444: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); @@ -5016,48 +5019,48 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 449: /* from_clause_opt ::= FROM table_reference_list */ - case 478: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==478); - case 508: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==508); + case 450: /* from_clause_opt ::= FROM table_reference_list */ + case 479: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==479); + case 509: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==509); { yymsp[-1].minor.yy600 = yymsp[0].minor.yy600; } break; - case 451: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ + case 452: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy600 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy600, yymsp[0].minor.yy600, NULL); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 454: /* table_primary ::= table_name alias_opt */ + case 455: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy600 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 455: /* table_primary ::= db_name NK_DOT table_name alias_opt */ + case 456: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy600 = createRealTableNode(pCxt, &yymsp[-3].minor.yy77, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 456: /* table_primary ::= subquery alias_opt */ + case 457: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy600 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600), &yymsp[0].minor.yy77); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 458: /* alias_opt ::= */ + case 459: /* alias_opt ::= */ { yymsp[1].minor.yy77 = nil_token; } break; - case 460: /* alias_opt ::= AS table_alias */ + case 461: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy77 = yymsp[0].minor.yy77; } break; - case 461: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 462: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==462); + case 462: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 463: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==463); { yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600; } break; - case 463: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + case 464: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ { yylhsminor.yy600 = createJoinTableNode(pCxt, yymsp[-4].minor.yy560, yymsp[-5].minor.yy600, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } yymsp[-5].minor.yy600 = yylhsminor.yy600; break; - case 464: /* join_type ::= */ + case 465: /* join_type ::= */ { yymsp[1].minor.yy560 = JOIN_TYPE_INNER; } break; - case 465: /* join_type ::= INNER */ + case 466: /* join_type ::= INNER */ { yymsp[0].minor.yy560 = JOIN_TYPE_INNER; } break; - case 466: /* query_specification ::= SELECT set_quantifier_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 */ + case 467: /* query_specification ::= SELECT set_quantifier_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 */ { yymsp[-11].minor.yy600 = createSelectStmt(pCxt, yymsp[-10].minor.yy841, yymsp[-9].minor.yy601, yymsp[-8].minor.yy600); yymsp[-11].minor.yy600 = addWhereClause(pCxt, yymsp[-11].minor.yy600, yymsp[-7].minor.yy600); @@ -5070,79 +5073,79 @@ static YYACTIONTYPE yy_reduce( yymsp[-11].minor.yy600 = addFillClause(pCxt, yymsp[-11].minor.yy600, yymsp[-3].minor.yy600); } break; - case 469: /* set_quantifier_opt ::= ALL */ + case 470: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy841 = false; } break; - case 472: /* select_item ::= NK_STAR */ + case 473: /* select_item ::= NK_STAR */ { yylhsminor.yy600 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 474: /* select_item ::= common_expression column_alias */ - case 484: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==484); + case 475: /* select_item ::= common_expression column_alias */ + case 485: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==485); { yylhsminor.yy600 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600), &yymsp[0].minor.yy77); } yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 475: /* select_item ::= common_expression AS column_alias */ - case 485: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==485); + case 476: /* select_item ::= common_expression AS column_alias */ + case 486: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==486); { yylhsminor.yy600 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), &yymsp[0].minor.yy77); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 480: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 504: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==504); - case 523: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==523); + case 481: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 505: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==505); + case 524: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==524); { yymsp[-2].minor.yy601 = yymsp[0].minor.yy601; } break; - case 487: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + case 488: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ { yymsp[-5].minor.yy600 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } break; - case 488: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + case 489: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy600 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } break; - case 489: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + case 490: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy600 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; - case 490: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + case 491: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-7].minor.yy600 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy600), releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; - case 494: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ + case 495: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy600 = createFillNode(pCxt, yymsp[-1].minor.yy798, NULL); } break; - case 495: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + case 496: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy600 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } break; - case 496: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ + case 497: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy600 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } break; - case 497: /* fill_mode ::= NONE */ + case 498: /* fill_mode ::= NONE */ { yymsp[0].minor.yy798 = FILL_MODE_NONE; } break; - case 498: /* fill_mode ::= PREV */ + case 499: /* fill_mode ::= PREV */ { yymsp[0].minor.yy798 = FILL_MODE_PREV; } break; - case 499: /* fill_mode ::= NULL */ + case 500: /* fill_mode ::= NULL */ { yymsp[0].minor.yy798 = FILL_MODE_NULL; } break; - case 500: /* fill_mode ::= NULL_F */ + case 501: /* fill_mode ::= NULL_F */ { yymsp[0].minor.yy798 = FILL_MODE_NULL_F; } break; - case 501: /* fill_mode ::= LINEAR */ + case 502: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy798 = FILL_MODE_LINEAR; } break; - case 502: /* fill_mode ::= NEXT */ + case 503: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy798 = FILL_MODE_NEXT; } break; - case 505: /* group_by_list ::= expr_or_subquery */ + case 506: /* group_by_list ::= expr_or_subquery */ { yylhsminor.yy601 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } yymsp[0].minor.yy601 = yylhsminor.yy601; break; - case 506: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + case 507: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ { yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } yymsp[-2].minor.yy601 = yylhsminor.yy601; break; - case 510: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + case 511: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ { yymsp[-5].minor.yy600 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } break; - case 513: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 514: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy600 = addOrderByClause(pCxt, yymsp[-3].minor.yy600, yymsp[-2].minor.yy601); yylhsminor.yy600 = addSlimitClause(pCxt, yylhsminor.yy600, yymsp[-1].minor.yy600); @@ -5150,50 +5153,50 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 516: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + case 517: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ { yylhsminor.yy600 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy600, yymsp[0].minor.yy600); } yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 517: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + case 518: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ { yylhsminor.yy600 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 525: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 529: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==529); + case 526: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 530: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==530); { yymsp[-1].minor.yy600 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 526: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 530: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==530); + case 527: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 531: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==531); { yymsp[-3].minor.yy600 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 527: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 531: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==531); + case 528: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 532: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==532); { yymsp[-3].minor.yy600 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 532: /* subquery ::= NK_LP query_expression NK_RP */ + case 533: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy600); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 537: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + case 538: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ { yylhsminor.yy600 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), yymsp[-1].minor.yy32, yymsp[0].minor.yy385); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 538: /* ordering_specification_opt ::= */ + case 539: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy32 = ORDER_ASC; } break; - case 539: /* ordering_specification_opt ::= ASC */ + case 540: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy32 = ORDER_ASC; } break; - case 540: /* ordering_specification_opt ::= DESC */ + case 541: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy32 = ORDER_DESC; } break; - case 541: /* null_ordering_opt ::= */ + case 542: /* null_ordering_opt ::= */ { yymsp[1].minor.yy385 = NULL_ORDER_DEFAULT; } break; - case 542: /* null_ordering_opt ::= NULLS FIRST */ + case 543: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy385 = NULL_ORDER_FIRST; } break; - case 543: /* null_ordering_opt ::= NULLS LAST */ + case 544: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy385 = NULL_ORDER_LAST; } break; default: diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 6486b4b684..2df0109d19 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -263,6 +263,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, SOutputData output = {0}; if (NULL == ctx->sinkHandle) { + pOutput->queryEnd = true; return TSDB_CODE_SUCCESS; } @@ -758,7 +759,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { } QW_LOCK(QW_WRITE, &ctx->lock); - if (qComplete || (queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code) { + if (atomic_load_8((int8_t*)&ctx->queryEnd) || (queryStop && (0 == atomic_load_8((int8_t *)&ctx->queryContinue))) || code) { // Note: query is not running anymore QW_SET_PHASE(ctx, QW_PHASE_POST_CQUERY); QW_UNLOCK(QW_WRITE, &ctx->lock); diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 74d555af77..25e65d2588 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1057,7 +1057,7 @@ static FORCE_INLINE int32_t filterAddColFieldFromField(SFilterInfo *info, SFilte int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *fid) { if (node == NULL) { - fltError("empty node"); + fltDebug("empty node"); FLT_ERR_RET(TSDB_CODE_APP_ERROR); } diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c index 6cc684dddf..8b869cc59f 100644 --- a/source/libs/stream/src/streamData.c +++ b/source/libs/stream/src/streamData.c @@ -17,11 +17,10 @@ int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData) { int32_t blockNum = pReq->blockNum; - SArray* pArray = taosArrayInit(blockNum, sizeof(SSDataBlock)); + SArray* pArray = taosArrayInit_s(blockNum, sizeof(SSDataBlock), blockNum); if (pArray == NULL) { return -1; } - taosArraySetSize(pArray, blockNum); ASSERT(pReq->blockNum == taosArrayGetSize(pReq->data)); ASSERT(pReq->blockNum == taosArrayGetSize(pReq->dataLen)); @@ -49,7 +48,7 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock if (pArray == NULL) { return -1; } - taosArraySetSize(pArray, 1); + taosArrayPush(pArray, &(SSDataBlock){0}); SRetrieveTableRsp* pRetrieve = pReq->pRetrieve; SSDataBlock* pDataBlock = taosArrayGet(pArray, 0); blockDecode(pDataBlock, pRetrieve->data); diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 184c1c8abf..e345bc1c6e 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -258,7 +258,6 @@ int32_t streamMetaAbort(SStreamMeta* pMeta) { int32_t streamLoadTasks(SStreamMeta* pMeta) { TBC* pCur = NULL; if (tdbTbcOpen(pMeta->pTaskDb, &pCur, NULL) < 0) { - ASSERT(0); return -1; } diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 25f5a3091c..b4e44cc5b7 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -107,8 +107,6 @@ static inline int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, } SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages) { - szPage = szPage < 0 ? 4096 : szPage; - pages = pages < 0 ? 256 : pages; SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState)); if (pState == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -128,6 +126,28 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int memset(statePath, 0, 1024); tstrncpy(statePath, path, 1024); } + + char cfgPath[1030]; + sprintf(cfgPath, "%s/cfg", statePath); + + char cfg[1024]; + memset(cfg, 0, 1024); + TdFilePtr pCfgFile = taosOpenFile(cfgPath, TD_FILE_READ); + if (pCfgFile != NULL) { + int64_t size; + taosFStatFile(pCfgFile, &size, NULL); + taosReadFile(pCfgFile, cfg, size); + sscanf(cfg, "%d\n%d\n", &szPage, &pages); + } else { + taosMulModeMkDir(statePath, 0755); + pCfgFile = taosOpenFile(cfgPath, TD_FILE_WRITE | TD_FILE_CREATE); + szPage = szPage < 0 ? 4096 : szPage; + pages = pages < 0 ? 256 : pages; + sprintf(cfg, "%d\n%d\n", szPage, pages); + taosWriteFile(pCfgFile, cfg, strlen(cfg)); + } + taosCloseFile(&pCfgFile); + if (tdbOpen(statePath, szPage, pages, &pState->pTdbState->db, 1) < 0) { goto _err; } @@ -879,4 +899,47 @@ char* streamStateSessionDump(SStreamState* pState) { streamStateFreeCur(pCur); return dumpBuf; } + +char* streamStateIntervalDump(SStreamState* pState) { + SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); + if (pCur == NULL) { + return NULL; + } + pCur->number = pState->number; + if (tdbTbcOpen(pState->pTdbState->pStateDb, &pCur->pCur, NULL) < 0) { + streamStateFreeCur(pCur); + return NULL; + } + tdbTbcMoveToFirst(pCur->pCur); + + SWinKey key = {0}; + void* buf = NULL; + int32_t bufSize = 0; + int32_t code = streamStateGetKVByCur(pCur, &key, (const void **)&buf, &bufSize); + if (code != 0) { + streamStateFreeCur(pCur); + return NULL; + } + + int32_t size = 2048; + char* dumpBuf = taosMemoryCalloc(size, 1); + int64_t len = 0; + len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.ts); + // len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey); + len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId); + while (1) { + tdbTbcMoveToNext(pCur->pCur); + key = (SWinKey){0}; + code = streamStateGetKVByCur(pCur, &key, NULL, 0); + if (code != 0) { + streamStateFreeCur(pCur); + return dumpBuf; + } + len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.ts); + // len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey); + len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId); + } + streamStateFreeCur(pCur); + return dumpBuf; +} #endif diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index b3eb5684cf..d1ef8701be 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -563,7 +563,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm } // recycle - SyncIndex until = pBuf->commitIndex - (pBuf->size >> 4); + SyncIndex until = pBuf->commitIndex - TSDB_SYNC_LOG_BUFFER_RETENTION; for (SyncIndex index = pBuf->startIndex; index < until; index++) { SSyncRaftEntry* pEntry = pBuf->entries[(index + pBuf->size) % pBuf->size].pItem; ASSERT(pEntry != NULL); diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index a547378967..707c47f6b1 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -759,28 +759,30 @@ int walMetaDeserialize(SWal* pWal, const char* bytes) { // deserialize SArray* pArray = pWal->fileInfoSet; taosArrayEnsureCap(pArray, sz); - SWalFileInfo* pData = pArray->pData; + for (int i = 0; i < sz; i++) { - cJSON* pInfoJson = cJSON_GetArrayItem(pFiles, i); + pInfoJson = cJSON_GetArrayItem(pFiles, i); if (!pInfoJson) goto _err; - SWalFileInfo* pInfo = &pData[i]; + + SWalFileInfo info = {0}; + pField = cJSON_GetObjectItem(pInfoJson, "firstVer"); if (!pField) goto _err; - pInfo->firstVer = atoll(cJSON_GetStringValue(pField)); + info.firstVer = atoll(cJSON_GetStringValue(pField)); pField = cJSON_GetObjectItem(pInfoJson, "lastVer"); if (!pField) goto _err; - pInfo->lastVer = atoll(cJSON_GetStringValue(pField)); + info.lastVer = atoll(cJSON_GetStringValue(pField)); pField = cJSON_GetObjectItem(pInfoJson, "createTs"); if (!pField) goto _err; - pInfo->createTs = atoll(cJSON_GetStringValue(pField)); + info.createTs = atoll(cJSON_GetStringValue(pField)); pField = cJSON_GetObjectItem(pInfoJson, "closeTs"); if (!pField) goto _err; - pInfo->closeTs = atoll(cJSON_GetStringValue(pField)); + info.closeTs = atoll(cJSON_GetStringValue(pField)); pField = cJSON_GetObjectItem(pInfoJson, "fileSize"); if (!pField) goto _err; - pInfo->fileSize = atoll(cJSON_GetStringValue(pField)); + info.fileSize = atoll(cJSON_GetStringValue(pField)); + taosArrayPush(pArray, &info); } - taosArraySetSize(pArray, sz); pWal->fileInfoSet = pArray; pWal->writeCur = sz - 1; cJSON_Delete(pRoot); diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index d4ea526b78..96c77d0971 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -87,8 +87,6 @@ int32_t walApplyVer(SWal *pWal, int64_t ver) { } int32_t walCommit(SWal *pWal, int64_t ver) { - ASSERT(pWal->vers.commitVer >= pWal->vers.snapshotVer); - ASSERT(pWal->vers.commitVer <= pWal->vers.lastVer); if (ver < pWal->vers.commitVer) { return 0; } @@ -122,41 +120,37 @@ int32_t walRollback(SWal *pWal, int64_t ver) { // delete files in descending order int fileSetSize = taosArrayGetSize(pWal->fileInfoSet); - for (int i = fileSetSize - 1; i >= pWal->writeCur + 1; i--) { - walBuildLogName(pWal, ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, i))->firstVer, fnameStr); + for (int i = pWal->writeCur + 1; i < fileSetSize; i++) { + SWalFileInfo* pInfo = taosArrayPop(pWal->fileInfoSet); + + walBuildLogName(pWal, pInfo->firstVer, fnameStr); wDebug("vgId:%d, wal remove file %s for rollback", pWal->cfg.vgId, fnameStr); taosRemoveFile(fnameStr); - walBuildIdxName(pWal, ((SWalFileInfo *)taosArrayGet(pWal->fileInfoSet, i))->firstVer, fnameStr); + walBuildIdxName(pWal, pInfo->firstVer, fnameStr); wDebug("vgId:%d, wal remove file %s for rollback", pWal->cfg.vgId, fnameStr); taosRemoveFile(fnameStr); } - // pop from fileInfoSet - taosArraySetSize(pWal->fileInfoSet, pWal->writeCur + 1); } walBuildIdxName(pWal, walGetCurFileFirstVer(pWal), fnameStr); TdFilePtr pIdxFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND); if (pIdxFile == NULL) { - ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); return -1; } int64_t idxOff = walGetVerIdxOffset(pWal, ver); code = taosLSeekFile(pIdxFile, idxOff, SEEK_SET); if (code < 0) { - ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); return -1; } // read idx file and get log file pos SWalIdxEntry entry; if (taosReadFile(pIdxFile, &entry, sizeof(SWalIdxEntry)) != sizeof(SWalIdxEntry)) { - ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); return -1; } - ASSERT(entry.ver == ver); walBuildLogName(pWal, walGetCurFileFirstVer(pWal), fnameStr); TdFilePtr pLogFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND); @@ -176,24 +170,19 @@ int32_t walRollback(SWal *pWal, int64_t ver) { } // validate offset SWalCkHead head; - ASSERT(taosValidFile(pLogFile)); - int64_t size = taosReadFile(pLogFile, &head, sizeof(SWalCkHead)); + int64_t size = taosReadFile(pLogFile, &head, sizeof(SWalCkHead)); if (size != sizeof(SWalCkHead)) { - ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); return -1; } code = walValidHeadCksum(&head); - ASSERT(code == 0); if (code != 0) { terrno = TSDB_CODE_WAL_FILE_CORRUPTED; - ASSERT(0); taosThreadMutexUnlock(&pWal->mutex); return -1; } if (head.head.version != ver) { - ASSERT(0); terrno = TSDB_CODE_WAL_FILE_CORRUPTED; taosThreadMutexUnlock(&pWal->mutex); return -1; @@ -202,22 +191,17 @@ int32_t walRollback(SWal *pWal, int64_t ver) { // truncate old files code = taosFtruncateFile(pLogFile, entry.offset); if (code < 0) { - ASSERT(0); terrno = TAOS_SYSTEM_ERROR(errno); taosThreadMutexUnlock(&pWal->mutex); return -1; } code = taosFtruncateFile(pIdxFile, idxOff); if (code < 0) { - ASSERT(0); terrno = TAOS_SYSTEM_ERROR(errno); taosThreadMutexUnlock(&pWal->mutex); return -1; } pWal->vers.lastVer = ver - 1; - if (pWal->vers.lastVer < pWal->vers.firstVer) { - ASSERT(pWal->vers.lastVer == pWal->vers.firstVer - 1); - } ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->lastVer = ver - 1; ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->fileSize = entry.offset; taosCloseFile(&pIdxFile); @@ -386,7 +370,7 @@ int32_t walEndSnapshot(SWal *pWal) { walBuildIdxName(pWal, pInfo->firstVer, fnameStr); wDebug("vgId:%d, wal remove file %s", pWal->cfg.vgId, fnameStr); if (taosRemoveFile(fnameStr) < 0 && errno != ENOENT) { - ASSERT(0); + goto END; } } taosArrayClear(pWal->toDeleteFiles); @@ -441,7 +425,6 @@ int32_t walRollImpl(SWal *pWal) { pWal->pIdxFile = pIdxFile; pWal->pLogFile = pLogFile; pWal->writeCur = taosArrayGetSize(pWal->fileInfoSet) - 1; - ASSERT(pWal->writeCur >= 0); pWal->lastRollSeq = walGetSeq(); @@ -458,9 +441,7 @@ END: static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { SWalIdxEntry entry = {.ver = ver, .offset = offset}; SWalFileInfo *pFileInfo = walGetCurFileInfo(pWal); - ASSERT(pFileInfo != NULL); - ASSERT(pFileInfo->firstVer >= 0); - int64_t idxOffset = (entry.ver - pFileInfo->firstVer) * sizeof(SWalIdxEntry); + int64_t idxOffset = (entry.ver - pFileInfo->firstVer) * sizeof(SWalIdxEntry); wDebug("vgId:%d, write index, index:%" PRId64 ", offset:%" PRId64 ", at %" PRId64, pWal->cfg.vgId, ver, offset, idxOffset); @@ -476,7 +457,6 @@ static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { if (endOffset < 0) { wFatal("vgId:%d, failed to seek end of idxfile due to %s. ver:%" PRId64 "", pWal->cfg.vgId, strerror(errno), ver); } - ASSERT(endOffset == idxOffset + sizeof(SWalIdxEntry) && "Offset of idx entries misaligned"); return 0; } @@ -486,9 +466,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy int64_t offset = walGetCurFileOffset(pWal); SWalFileInfo *pFileInfo = walGetCurFileInfo(pWal); - ASSERT(pFileInfo != NULL); - ASSERT(pFileInfo->firstVer != -1); pWal->writeHead.head.version = index; pWal->writeHead.head.bodyLen = bodyLen; pWal->writeHead.head.msgType = msgType; @@ -525,7 +503,6 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy // set status if (pWal->vers.firstVer == -1) { - ASSERT(index == 0); pWal->vers.firstVer = 0; } pWal->vers.lastVer = index; @@ -541,7 +518,6 @@ END: wFatal("vgId:%d, failed to ftruncate logfile to offset:%" PRId64 " during recovery due to %s", pWal->cfg.vgId, offset, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); - ASSERT(0 && "failed to recover from error"); } int64_t idxOffset = (index - pFileInfo->firstVer) * sizeof(SWalIdxEntry); @@ -549,7 +525,6 @@ END: wFatal("vgId:%d, failed to ftruncate idxfile to offset:%" PRId64 "during recovery due to %s", pWal->cfg.vgId, idxOffset, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); - ASSERT(0 && "failed to recover from error"); } return -1; } @@ -576,8 +551,6 @@ int64_t walAppendLog(SWal *pWal, int64_t index, tmsg_t msgType, SWalSyncInfo syn } } - ASSERT(pWal->pLogFile != NULL && pWal->pIdxFile != NULL && pWal->writeCur >= 0); - if (walWriteImpl(pWal, index, msgType, syncMeta, body, bodyLen) < 0) { taosThreadMutexUnlock(&pWal->mutex); return -1; @@ -614,8 +587,6 @@ int32_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SWalSync } } - ASSERT(pWal->pIdxFile != NULL && pWal->pLogFile != NULL && pWal->writeCur >= 0); - if (walWriteImpl(pWal, index, msgType, syncMeta, body, bodyLen) < 0) { taosThreadMutexUnlock(&pWal->mutex); return -1; diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 6b0bfb3a02..3a93a26b85 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -1078,7 +1078,7 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) { // return -1; //} #else // Linux like systems - uint32_t conn_timeout_ms = timeout * 1000; + uint32_t conn_timeout_ms = timeout; if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) { taosCloseSocketNoCheck1(fd); return -1; diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 237edfdeb2..64701574bb 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -48,6 +48,26 @@ SArray* taosArrayInit(size_t size, size_t elemSize) { return pArray; } +SArray* taosArrayInit_s(size_t size, size_t elemSize, size_t initialSize) { + SArray* pArray = taosMemoryMalloc(sizeof(SArray)); + if (pArray == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + pArray->size = initialSize; + pArray->pData = taosMemoryCalloc(initialSize, elemSize); + if (pArray->pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + taosMemoryFree(pArray); + return NULL; + } + + pArray->capacity = initialSize; + pArray->elemSize = elemSize; + return pArray; +} + static int32_t taosArrayResize(SArray* pArray) { assert(pArray->size >= pArray->capacity); @@ -223,7 +243,13 @@ void* taosArrayGetP(const SArray* pArray, size_t index) { return *p; } -void* taosArrayGetLast(const SArray* pArray) { return TARRAY_GET_ELEM(pArray, pArray->size - 1); } +void* taosArrayGetLast(const SArray* pArray) { + if (pArray->size == 0) { + return NULL; + } + + return TARRAY_GET_ELEM(pArray, pArray->size - 1); +} size_t taosArrayGetSize(const SArray* pArray) { if (pArray == NULL) { @@ -232,11 +258,6 @@ size_t taosArrayGetSize(const SArray* pArray) { return pArray->size; } -void taosArraySetSize(SArray* pArray, size_t size) { - assert(size <= pArray->capacity); - pArray->size = size; -} - void* taosArrayInsert(SArray* pArray, size_t index, void* pData) { if (pArray == NULL || pData == NULL) { return NULL; diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 64d550e874..695a83abb1 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -228,6 +228,7 @@ int32_t tsCompressINTImp(const char *const input, const int32_t nelements, char } int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, char *const output, const char type) { + int32_t word_length = 0; switch (type) { case TSDB_DATA_TYPE_BIGINT: @@ -263,6 +264,177 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha int32_t _pos = 0; int64_t prev_value = 0; +#if __AVX2__ + while (1) { + if (_pos == nelements) break; + + uint64_t w = 0; + memcpy(&w, ip, LONG_BYTES); + + char selector = (char)(w & INT64MASK(4)); // selector = 4 + char bit = bit_per_integer[(int32_t)selector]; // bit = 3 + int32_t elems = selector_to_elems[(int32_t)selector]; + + // Optimize the performance, by remove the constantly switch operation. + int32_t v = 4; + uint64_t zigzag_value = 0; + uint64_t mask = INT64MASK(bit); + + switch (type) { + case TSDB_DATA_TYPE_BIGINT: { + int64_t* p = (int64_t*) output; + + int32_t gRemainder = (nelements - _pos); + int32_t num = (gRemainder > elems)? elems:gRemainder; + + int32_t batch = num >> 2; + int32_t remain = num & 0x03; + if (selector == 0 || selector == 1) { + if (tsAVX2Enable && tsSIMDBuiltins) { + for (int32_t i = 0; i < batch; ++i) { + __m256i prev = _mm256_set1_epi64x(prev_value); + _mm256_storeu_si256((__m256i *)&p[_pos], prev); + _pos += 4; + } + + for (int32_t i = 0; i < remain; ++i) { + p[_pos++] = prev_value; + } + } else { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + p[_pos++] = prev_value; + v += bit; + } + } + } else { + if (tsAVX2Enable && tsSIMDBuiltins) { + __m256i base = _mm256_set1_epi64x(w); + __m256i maskVal = _mm256_set1_epi64x(mask); + + __m256i shiftBits = _mm256_set_epi64x(bit * 3 + 4, bit * 2 + 4, bit + 4, 4); + __m256i inc = _mm256_set1_epi64x(bit << 2); + + for (int32_t i = 0; i < batch; ++i) { + __m256i after = _mm256_srlv_epi64(base, shiftBits); + __m256i zigzagVal = _mm256_and_si256(after, maskVal); + + // ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1))) + __m256i signmask = _mm256_and_si256(_mm256_set1_epi64x(1), zigzagVal); + signmask = _mm256_sub_epi64(_mm256_setzero_si256(), signmask); + // get the four zigzag values here + __m256i delta = _mm256_xor_si256(_mm256_srli_epi64(zigzagVal, 1), signmask); + + // calculate the cumulative sum (prefix sum) for each number + // decode[0] = prev_value + final[0] + // decode[1] = decode[0] + final[1] -----> prev_value + final[0] + final[1] + // decode[2] = decode[1] + final[1] -----> prev_value + final[0] + final[1] + final[2] + // decode[3] = decode[2] + final[1] -----> prev_value + final[0] + final[1] + final[2] + final[3] + + // 1, 2, 3, 4 + //+ 0, 1, 2, 3 + // 1, 3, 5, 7 + // shift and add for the first round + __m128i prev = _mm_set1_epi64x(prev_value); + delta = _mm256_add_epi64(delta, _mm256_slli_si256(delta, 8)); + _mm256_storeu_si256((__m256i *)&p[_pos], delta); + + // 1, 3, 5, 7 + //+ 0, 0, 1, 3 + // 1, 3, 6, 10 + // shift and add operation for the second round + __m128i firstPart = _mm_loadu_si128((__m128i *)&p[_pos]); + __m128i secPart = _mm_add_epi64(_mm_loadu_si128((__m128i *)&p[_pos + 2]), firstPart); + firstPart = _mm_add_epi64(firstPart, prev); + secPart = _mm_add_epi64(secPart, prev); + + // save it in the memory + _mm_storeu_si128((__m128i *)&p[_pos], firstPart); + _mm_storeu_si128((__m128i *)&p[_pos + 2], secPart); + + shiftBits = _mm256_add_epi64(shiftBits, inc); + prev_value = p[_pos + 3]; + _pos += 4; + } + + // handle the remain value + for (int32_t i = 0; i < remain; i++) { + zigzag_value = ((w >> (v + (batch * bit))) & mask); + prev_value += ZIGZAG_DECODE(int64_t, zigzag_value); + + p[_pos++] = prev_value; + v += bit; + } + } else { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + zigzag_value = ((w >> v) & mask); + prev_value += ZIGZAG_DECODE(int64_t, zigzag_value); + + p[_pos++] = prev_value; + v += bit; + } + } + } + } break; + case TSDB_DATA_TYPE_INT: { + int32_t* p = (int32_t*) output; + + if (selector == 0 || selector == 1) { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + p[_pos++] = (int32_t)prev_value; + } + } else { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + zigzag_value = ((w >> v) & mask); + prev_value += ZIGZAG_DECODE(int64_t, zigzag_value); + + p[_pos++] = (int32_t)prev_value; + v += bit; + } + } + } break; + case TSDB_DATA_TYPE_SMALLINT: { + int16_t* p = (int16_t*) output; + + if (selector == 0 || selector == 1) { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + p[_pos++] = (int16_t)prev_value; + } + } else { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + zigzag_value = ((w >> v) & mask); + prev_value += ZIGZAG_DECODE(int64_t, zigzag_value); + + p[_pos++] = (int16_t)prev_value; + v += bit; + } + } + } break; + + case TSDB_DATA_TYPE_TINYINT: { + int8_t *p = (int8_t *)output; + + if (selector == 0 || selector == 1) { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + p[_pos++] = (int8_t)prev_value; + } + } else { + for (int32_t i = 0; i < elems && count < nelements; i++, count++) { + zigzag_value = ((w >> v) & mask); + prev_value += ZIGZAG_DECODE(int64_t, zigzag_value); + + p[_pos++] = (int8_t)prev_value; + v += bit; + } + } + } break; + } + + ip += LONG_BYTES; + } + + return nelements * word_length; +#else + while (1) { if (count == nelements) break; @@ -273,94 +445,47 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha char bit = bit_per_integer[(int32_t)selector]; // bit = 3 int32_t elems = selector_to_elems[(int32_t)selector]; - // Optimize the performance, by remove the constantly switch operation. - int32_t v = 0; - uint64_t zigzag_value; + for (int32_t i = 0; i < elems; i++) { + uint64_t zigzag_value; - switch (type) { - case TSDB_DATA_TYPE_BIGINT: { - for (int32_t i = 0; i < elems; i++) { - if (selector == 0 || selector == 1) { - zigzag_value = 0; - } else { - zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); - } - - int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); - int64_t curr_value = diff + prev_value; - prev_value = curr_value; + if (selector == 0 || selector == 1) { + zigzag_value = 0; + } else { + zigzag_value = ((w >> (4 + bit * i)) & INT64MASK(bit)); + } + int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); + int64_t curr_value = diff + prev_value; + prev_value = curr_value; + switch (type) { + case TSDB_DATA_TYPE_BIGINT: *((int64_t *)output + _pos) = (int64_t)curr_value; _pos++; - - v += bit; - if ((++count) == nelements) break; - } - } break; - case TSDB_DATA_TYPE_INT: { - for (int32_t i = 0; i < elems; i++) { - if (selector == 0 || selector == 1) { - zigzag_value = 0; - } else { - zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); - } - - int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); - int64_t curr_value = diff + prev_value; - prev_value = curr_value; - + break; + case TSDB_DATA_TYPE_INT: *((int32_t *)output + _pos) = (int32_t)curr_value; _pos++; - - v += bit; - if ((++count) == nelements) break; - } - } break; - case TSDB_DATA_TYPE_SMALLINT: { - for (int32_t i = 0; i < elems; i++) { - if (selector == 0 || selector == 1) { - zigzag_value = 0; - } else { - zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); - } - - int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); - int64_t curr_value = diff + prev_value; - prev_value = curr_value; - + break; + case TSDB_DATA_TYPE_SMALLINT: *((int16_t *)output + _pos) = (int16_t)curr_value; _pos++; - - v += bit; - if ((++count) == nelements) break; - } - } break; - - case TSDB_DATA_TYPE_TINYINT: { - for (int32_t i = 0; i < elems; i++) { - if (selector == 0 || selector == 1) { - zigzag_value = 0; - } else { - zigzag_value = ((w >> (4 + v)) & INT64MASK(bit)); - } - - int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value); - int64_t curr_value = diff + prev_value; - prev_value = curr_value; - + break; + case TSDB_DATA_TYPE_TINYINT: *((int8_t *)output + _pos) = (int8_t)curr_value; _pos++; - - v += bit; - if ((++count) == nelements) break; - } - } break; + break; + default: + perror("Wrong integer types.\n"); + return -1; + } + count++; + if (count == nelements) break; } - ip += LONG_BYTES; } return nelements * word_length; +#endif } /* ----------------------------------------------Bool Compression diff --git a/source/util/src/thash.c b/source/util/src/thash.c index e9548613aa..926dc304a4 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -421,7 +421,11 @@ int32_t taosHashGetDup_m(SHashObj *pHashObj, const void *key, size_t keyLen, voi } void *taosHashGetImpl(SHashObj *pHashObj, const void *key, size_t keyLen, void **d, int32_t *size, bool addRef) { - if (pHashObj == NULL || taosHashTableEmpty(pHashObj) || keyLen == 0 || key == NULL) { + if (pHashObj == NULL || keyLen == 0 || key == NULL) { + return NULL; + } + + if ((atomic_load_64((int64_t *)&pHashObj->size) == 0)) { return NULL; } diff --git a/source/util/src/thashutil.c b/source/util/src/thashutil.c index 59f7d389c2..21b9359076 100644 --- a/source/util/src/thashutil.c +++ b/source/util/src/thashutil.c @@ -17,6 +17,7 @@ #include "tcompare.h" #include "thash.h" #include "types.h" +#include "xxhash.h" #define ROTL32(x, r) ((x) << (r) | (x) >> (32u - (r))) @@ -49,6 +50,11 @@ uint32_t taosDJB2Hash(const char *key, uint32_t len) { return hash; } +uint32_t xxHash(const char *key, uint32_t len) { + int32_t seed = 0xcc9e2d51; + return XXH32(key, len, seed); +} + uint32_t MurmurHash3_32(const char *key, uint32_t len) { const uint8_t *data = (const uint8_t *)key; const int32_t nblocks = len >> 2u; @@ -192,8 +198,6 @@ _hash_fn_t taosGetDefaultHashFunction(int32_t type) { fn = taosIntHash_64; break; case TSDB_DATA_TYPE_BINARY: - fn = MurmurHash3_32; - break; case TSDB_DATA_TYPE_NCHAR: fn = MurmurHash3_32; break; diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c index 48638af8d5..27d14d05b1 100644 --- a/source/util/src/tjson.c +++ b/source/util/src/tjson.c @@ -325,11 +325,10 @@ int32_t tjsonToTArray(const SJson* pJson, const char* pName, FToObject func, SAr const cJSON* jArray = tjsonGetObjectItem(pJson, pName); int32_t size = tjsonGetArraySize(jArray); if (size > 0) { - *pArray = taosArrayInit(size, itemSize); + *pArray = taosArrayInit_s(size, itemSize, size); if (NULL == *pArray) { return TSDB_CODE_OUT_OF_MEMORY; } - taosArraySetSize(*pArray, size); for (int32_t i = 0; i < size; ++i) { int32_t code = func(tjsonGetArrayItem(jArray, i), taosArrayGet(*pArray, i)); if (TSDB_CODE_SUCCESS != code) { diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index 3cecfdff9c..6bcf4ad39b 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -2,7 +2,7 @@ #include "tpagedbuf.h" #include "taoserror.h" #include "tcompression.h" -#include "thash.h" +#include "tsimplehash.h" #include "tlog.h" #define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES) @@ -38,7 +38,7 @@ struct SDiskbasedBuf { int32_t inMemPages; // numOfPages that are allocated in memory SList* freePgList; // free page list SArray* pIdList; // page id list - SHashObj* all; + SSHashObj*all; SList* lruList; void* emptyDummyIdList; // dummy id list void* assistBuf; // assistant buffer for compress/decompress data @@ -374,12 +374,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem goto _error; } - pPBuf->assistBuf = taosMemoryMalloc(pPBuf->pageSize + 2); // EXTRA BYTES - if (pPBuf->assistBuf == NULL) { - goto _error; - } - - pPBuf->all = taosHashInit(10, fn, true, false); + pPBuf->all = tSimpleHashInit(64, fn); if (pPBuf->all == NULL) { goto _error; } @@ -441,7 +436,7 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) { } // add to hash map - taosHashPut(pBuf->all, pageId, sizeof(int32_t), &pi, POINTER_BYTES); + tSimpleHashPut(pBuf->all, pageId, sizeof(int32_t), &pi, POINTER_BYTES); pBuf->totalBufSize += pBuf->pageSize; } @@ -466,7 +461,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { pBuf->statis.getPages += 1; - SPageInfo** pi = taosHashGet(pBuf->all, &id, sizeof(int32_t)); + SPageInfo** pi = tSimpleHashGet(pBuf->all, &id, sizeof(int32_t)); if (pi == NULL || *pi == NULL) { uError("failed to locate the buffer page:%d, %s", id, pBuf->id); terrno = TSDB_CODE_INVALID_PARA; @@ -615,7 +610,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { taosArrayDestroy(pBuf->emptyDummyIdList); taosArrayDestroy(pBuf->pFree); - taosHashCleanup(pBuf->all); + tSimpleHashCleanup(pBuf->all); taosMemoryFreeClear(pBuf->id); taosMemoryFreeClear(pBuf->assistBuf); @@ -641,7 +636,12 @@ void setBufPageDirty(void* pPage, bool dirty) { ppi->dirty = dirty; } -void setBufPageCompressOnDisk(SDiskbasedBuf* pBuf, bool comp) { pBuf->comp = comp; } +void setBufPageCompressOnDisk(SDiskbasedBuf* pBuf, bool comp) { + pBuf->comp = comp; + if (comp && (pBuf->assistBuf == NULL)) { + pBuf->assistBuf = taosMemoryMalloc(pBuf->pageSize + 2); // EXTRA BYTES + } +} void dBufSetBufPageRecycled(SDiskbasedBuf* pBuf, void* pPage) { SPageInfo* ppi = getPageInfoFromPayload(pPage); @@ -704,7 +704,7 @@ void clearDiskbasedBuf(SDiskbasedBuf* pBuf) { taosArrayClear(pBuf->emptyDummyIdList); taosArrayClear(pBuf->pFree); - taosHashClear(pBuf->all); + tSimpleHashClear(pBuf->all); pBuf->numOfPages = 0; // all pages are in buffer in the first place pBuf->totalBufSize = 0; diff --git a/source/libs/executor/src/tsimplehash.c b/source/util/src/tsimplehash.c similarity index 79% rename from source/libs/executor/src/tsimplehash.c rename to source/util/src/tsimplehash.c index fd6215e3a1..70acffed5d 100644 --- a/source/libs/executor/src/tsimplehash.c +++ b/source/util/src/tsimplehash.c @@ -18,12 +18,13 @@ #include "tlog.h" #include "tdef.h" +#define DEFAULT_BUF_PAGE_SIZE 1024 #define SHASH_DEFAULT_LOAD_FACTOR 0.75 #define HASH_MAX_CAPACITY (1024 * 1024 * 16L) #define SHASH_NEED_RESIZE(_h) ((_h)->size >= (_h)->capacity * SHASH_DEFAULT_LOAD_FACTOR) -#define GET_SHASH_NODE_KEY(_n, _dl) ((char *)(_n) + sizeof(SHNode) + (_dl)) -#define GET_SHASH_NODE_DATA(_n) ((char *)(_n) + sizeof(SHNode)) +#define GET_SHASH_NODE_DATA(_n) (((SHNode*)_n)->data) +#define GET_SHASH_NODE_KEY(_n, _dl) ((char*)GET_SHASH_NODE_DATA(_n) + (_dl)) #define HASH_INDEX(v, c) ((v) & ((c)-1)) @@ -38,6 +39,8 @@ struct SSHashObj { int64_t size; // number of elements in hash table _hash_fn_t hashFp; // hash function _equal_fn_t equalFp; // equal function + SArray* pHashNodeBuf;// hash node allocation buffer, 1k size of each page by default + int32_t offset; // allocation offset in current page }; static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { @@ -57,24 +60,28 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) { capacity = 4; } - SSHashObj *pHashObj = (SSHashObj *)taosMemoryCalloc(1, sizeof(SSHashObj)); + SSHashObj *pHashObj = (SSHashObj *)taosMemoryMalloc(sizeof(SSHashObj)); if (!pHashObj) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } // the max slots is not defined by user - pHashObj->capacity = taosHashCapacity((int32_t)capacity); - - pHashObj->equalFp = memcmp; pHashObj->hashFp = fn; + pHashObj->capacity = taosHashCapacity((int32_t)capacity); + pHashObj->equalFp = memcmp; + pHashObj->pHashNodeBuf = taosArrayInit(10, sizeof(void*)); + pHashObj->offset = 0; + pHashObj->size = 0; + pHashObj->hashList = (SHNode **)taosMemoryCalloc(pHashObj->capacity, sizeof(void *)); if (!pHashObj->hashList) { taosMemoryFree(pHashObj); terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } + return pHashObj; } @@ -82,19 +89,53 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) { if (!pHashObj) { return 0; } - return (int32_t)atomic_load_64((int64_t *)&pHashObj->size); + return (int32_t) pHashObj->size; } -static SHNode *doCreateHashNode(const void *key, size_t keyLen, const void *data, size_t dataLen, uint32_t hashVal) { - SHNode *pNewNode = taosMemoryMalloc(sizeof(SHNode) + keyLen + dataLen); +static void* doInternalAlloc(SSHashObj* pHashObj, int32_t size) { +#if 0 + void** p = taosArrayGetLast(pHashObj->pHashNodeBuf); + if (p == NULL || (pHashObj->offset + size) > DEFAULT_BUF_PAGE_SIZE) { + // let's allocate one new page + int32_t allocSize = TMAX(size, DEFAULT_BUF_PAGE_SIZE); + void* pNewPage = taosMemoryMalloc(allocSize); + if (pNewPage == NULL) { + return NULL; + } + + // if the allocate the buffer page is greater than the DFFAULT_BUF_PAGE_SIZE, + // pHashObj->offset will always be greater than DEFAULT_BUF_PAGE_SIZE, which means that + // current buffer page is full. And a new buffer page needs to be allocated. + pHashObj->offset = size; + taosArrayPush(pHashObj->pHashNodeBuf, &pNewPage); + return pNewPage; + } else { + void* pPos = (char*)(*p) + pHashObj->offset; + pHashObj->offset += size; + return pPos; + } +#else + return taosMemoryMalloc(size); +#endif +} + +static SHNode *doCreateHashNode(SSHashObj *pHashObj, const void *key, size_t keyLen, const void *data, size_t dataLen, + uint32_t hashVal) { + SHNode *pNewNode = doInternalAlloc(pHashObj, sizeof(SHNode) + keyLen + dataLen); if (!pNewNode) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } + pNewNode->keyLen = keyLen; pNewNode->dataLen = dataLen; pNewNode->next = NULL; - if (data) memcpy(GET_SHASH_NODE_DATA(pNewNode), data, dataLen); + pNewNode->hashVal = hashVal; + + if (data) { + memcpy(GET_SHASH_NODE_DATA(pNewNode), data, dataLen); + } + memcpy(GET_SHASH_NODE_KEY(pNewNode, dataLen), key, keyLen); return pNewNode; } @@ -111,7 +152,7 @@ static void tSimpleHashTableResize(SSHashObj *pHashObj) { return; } - int64_t st = taosGetTimestampUs(); +// int64_t st = taosGetTimestampUs(); void *pNewEntryList = taosMemoryRealloc(pHashObj->hashList, POINTER_BYTES * newCapacity); if (!pNewEntryList) { uWarn("hash resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity); @@ -134,10 +175,7 @@ static void tSimpleHashTableResize(SSHashObj *pHashObj) { SHNode *pPrev = NULL; while (pNode != NULL) { - void *key = GET_SHASH_NODE_KEY(pNode, pNode->dataLen); - uint32_t hashVal = (*pHashObj->hashFp)(key, (uint32_t)pNode->keyLen); - - int32_t newIdx = HASH_INDEX(hashVal, pHashObj->capacity); + int32_t newIdx = HASH_INDEX(pNode->hashVal, pHashObj->capacity); pNext = pNode->next; if (newIdx != idx) { if (!pPrev) { @@ -156,8 +194,7 @@ static void tSimpleHashTableResize(SSHashObj *pHashObj) { } } - int64_t et = taosGetTimestampUs(); - +// int64_t et = taosGetTimestampUs(); // uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", // (int32_t)pHashObj->capacity, // ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0); @@ -179,13 +216,13 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, size_t keyLen, cons SHNode *pNode = pHashObj->hashList[slot]; if (!pNode) { - SHNode *pNewNode = doCreateHashNode(key, keyLen, data, dataLen, hashVal); + SHNode *pNewNode = doCreateHashNode(pHashObj, key, keyLen, data, dataLen, hashVal); if (!pNewNode) { return -1; } pHashObj->hashList[slot] = pNewNode; - atomic_add_fetch_64(&pHashObj->size, 1); + pHashObj->size += 1; return 0; } @@ -197,13 +234,13 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, size_t keyLen, cons } if (!pNode) { - SHNode *pNewNode = doCreateHashNode(key, keyLen, data, dataLen, hashVal); + SHNode *pNewNode = doCreateHashNode(pHashObj, key, keyLen, data, dataLen, hashVal); if (!pNewNode) { return -1; } pNewNode->next = pHashObj->hashList[slot]; pHashObj->hashList[slot] = pNewNode; - atomic_add_fetch_64(&pHashObj->size, 1); + pHashObj->size += 1; } else if (data) { // update data memcpy(GET_SHASH_NODE_DATA(pNode), data, dataLen); } @@ -270,7 +307,7 @@ int32_t tSimpleHashRemove(SSHashObj *pHashObj, const void *key, size_t keyLen) { pPrev->next = pNode->next; } FREE_HASH_NODE(pNode); - atomic_sub_fetch_64(&pHashObj->size, 1); + pHashObj->size -= 1; code = TSDB_CODE_SUCCESS; break; } @@ -305,7 +342,7 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke } FREE_HASH_NODE(pNode); - atomic_sub_fetch_64(&pHashObj->size, 1); + pHashObj->size -= 1; break; } pPrev = pNode; @@ -315,6 +352,10 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke return TSDB_CODE_SUCCESS; } +static void destroyItems(void* pItem) { + taosMemoryFree(*(void**)pItem); +} + void tSimpleHashClear(SSHashObj *pHashObj) { if (!pHashObj || taosHashTableEmpty(pHashObj)) { return; @@ -332,9 +373,13 @@ void tSimpleHashClear(SSHashObj *pHashObj) { FREE_HASH_NODE(pNode); pNode = pNext; } + pHashObj->hashList[i] = NULL; } - atomic_store_64(&pHashObj->size, 0); + + taosArrayClearEx(pHashObj->pHashNodeBuf, destroyItems); + pHashObj->offset = 0; + pHashObj->size = 0; } void tSimpleHashCleanup(SSHashObj *pHashObj) { @@ -343,6 +388,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj) { } tSimpleHashClear(pHashObj); + taosArrayDestroy(pHashObj->pHashNodeBuf); taosMemoryFreeClear(pHashObj->hashList); taosMemoryFree(pHashObj); } diff --git a/source/util/src/tutil.c b/source/util/src/tutil.c index e94f94a00d..55d7d4f6e7 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -159,10 +159,6 @@ char *strtolower(char *dst, const char *src) { int32_t esc = 0; char quote = 0, *p = dst, c; - if (ASSERTS(dst != NULL, "dst is NULL")) { - return NULL; - } - for (c = *src++; c; c = *src++) { if (esc) { esc = 0; @@ -188,10 +184,6 @@ char *strntolower(char *dst, const char *src, int32_t n) { int32_t esc = 0; char quote = 0, *p = dst, c; - if (ASSERTS(dst != NULL, "dst is NULL")) { - return NULL; - } - if (n == 0) { *p = 0; return dst; @@ -219,11 +211,6 @@ char *strntolower(char *dst, const char *src, int32_t n) { char *strntolower_s(char *dst, const char *src, int32_t n) { char *p = dst, c; - - if (ASSERTS(dst != NULL, "dst is NULL")) { - return NULL; - } - if (n == 0) { return NULL; } @@ -333,6 +320,50 @@ char *strbetween(char *string, char *begin, char *end) { return result; } +int32_t tintToHex(uint64_t val, char hex[]) { + const char hexstr[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + + int32_t j = 0, k = 0; + if (val == 0) { + hex[j++] = hexstr[0]; + return j; + } + + // ignore the initial 0 + while((val & (((uint64_t)0xfL) << ((15 - k) * 4))) == 0) { + k += 1; + } + + for (j = 0; k < 16; ++k, ++j) { + hex[j] = hexstr[(val & (((uint64_t)0xfL) << ((15 - k) * 4))) >> (15 - k) * 4]; + } + + return j; +} + +int32_t titoa(uint64_t val, size_t radix, char str[]) { + if (radix < 2 || radix > 16) { + return 0; + } + + const char* s = "0123456789abcdef"; + char buf[65] = {0}; + + int32_t i = 0; + uint64_t v = val; + while(v > 0) { + buf[i++] = s[v % radix]; + v /= radix; + } + + // reverse order + for(int32_t j = 0; j < i; ++j) { + str[j] = buf[i - j - 1]; + } + + return i; +} + int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]) { int32_t i; char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; diff --git a/source/util/src/xxhash.c b/source/util/src/xxhash.c new file mode 100644 index 0000000000..ff28749e31 --- /dev/null +++ b/source/util/src/xxhash.c @@ -0,0 +1,1030 @@ +/* +* xxHash - Fast Hash algorithm +* Copyright (C) 2012-2016, Yann Collet +* +* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following disclaimer +* in the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* You can contact the author at : +* - xxHash homepage: http://www.xxhash.com +* - xxHash source repository : https://github.com/Cyan4973/xxHash +*/ + + +/* ************************************* +* Tuning parameters +***************************************/ +/*!XXH_FORCE_MEMORY_ACCESS : + * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable. + * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal. + * The below switch allow to select different access method for improved performance. + * Method 0 (default) : use `memcpy()`. Safe and portable. + * Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable). + * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`. + * Method 2 : direct access. This method doesn't depend on compiler but violate C standard. + * It can generate buggy code on targets which do not support unaligned memory accesses. + * But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6) + * See http://stackoverflow.com/a/32095106/646947 for details. + * Prefer these methods in priority order (0 > 1 > 2) + */ +#ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */ +# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ + || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ + || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) ) +# define XXH_FORCE_MEMORY_ACCESS 2 +# elif (defined(__INTEL_COMPILER) && !defined(_WIN32)) || \ + (defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ + || defined(__ARM_ARCH_7S__) )) +# define XXH_FORCE_MEMORY_ACCESS 1 +# endif +#endif + +/*!XXH_ACCEPT_NULL_INPUT_POINTER : + * If input pointer is NULL, xxHash default behavior is to dereference it, triggering a segfault. + * When this macro is enabled, xxHash actively checks input for null pointer. + * It it is, result for null input pointers is the same as a null-length input. + */ +#ifndef XXH_ACCEPT_NULL_INPUT_POINTER /* can be defined externally */ +# define XXH_ACCEPT_NULL_INPUT_POINTER 0 +#endif + +/*!XXH_FORCE_NATIVE_FORMAT : + * By default, xxHash library provides endian-independent Hash values, based on little-endian convention. + * Results are therefore identical for little-endian and big-endian CPU. + * This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format. + * Should endian-independence be of no importance for your application, you may set the #define below to 1, + * to improve speed for Big-endian CPU. + * This option has no impact on Little_Endian CPU. + */ +#ifndef XXH_FORCE_NATIVE_FORMAT /* can be defined externally */ +# define XXH_FORCE_NATIVE_FORMAT 0 +#endif + +/*!XXH_FORCE_ALIGN_CHECK : + * This is a minor performance trick, only useful with lots of very small keys. + * It means : check for aligned/unaligned input. + * The check costs one initial branch per hash; + * set it to 0 when the input is guaranteed to be aligned, + * or when alignment doesn't matter for performance. + */ +#ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */ +# if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) +# define XXH_FORCE_ALIGN_CHECK 0 +# else +# define XXH_FORCE_ALIGN_CHECK 1 +# endif +#endif + + +/* ************************************* +* Includes & Memory related functions +***************************************/ +/*! Modify the local functions below should you wish to use some other memory routines +* for malloc(), free() */ +#include +static void* XXH_malloc(size_t s) { return malloc(s); } +static void XXH_free (void* p) { free(p); } +/*! and for memcpy() */ +#include +static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); } + +#include /* assert */ + +#define XXH_STATIC_LINKING_ONLY +#include "xxhash.h" + + +/* ************************************* +* Compiler Specific Options +***************************************/ +#ifdef _MSC_VER /* Visual Studio */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +# define FORCE_INLINE static __forceinline +#else +# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# ifdef __GNUC__ +# define FORCE_INLINE static inline __attribute__((always_inline)) +# else +# define FORCE_INLINE static inline +# endif +# else +# define FORCE_INLINE static +# endif /* __STDC_VERSION__ */ +#endif + + +/* ************************************* +* Basic Types +***************************************/ +#ifndef MEM_MODULE +# if !defined (__VMS) \ + && (defined (__cplusplus) \ + || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) +# include + typedef uint8_t BYTE; + typedef uint16_t U16; + typedef uint32_t U32; +# else + typedef unsigned char BYTE; + typedef unsigned short U16; + typedef unsigned int U32; +# endif +#endif + +#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2)) + +/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */ +static U32 XXH_read32(const void* memPtr) { return *(const U32*) memPtr; } + +#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1)) + +/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */ +/* currently only defined for gcc and icc */ +typedef union { U32 u32; } __attribute__((packed)) unalign; +static U32 XXH_read32(const void* ptr) { return ((const unalign*)ptr)->u32; } + +#else + +/* portable and safe solution. Generally efficient. + * see : http://stackoverflow.com/a/32095106/646947 + */ +static U32 XXH_read32(const void* memPtr) +{ + U32 val; + memcpy(&val, memPtr, sizeof(val)); + return val; +} + +#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */ + + +/* **************************************** +* Compiler-specific Functions and Macros +******************************************/ +#define XXH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) + +/* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */ +#if defined(_MSC_VER) +# define XXH_rotl32(x,r) _rotl(x,r) +# define XXH_rotl64(x,r) _rotl64(x,r) +#else +# define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r))) +# define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r))) +#endif + +#if defined(_MSC_VER) /* Visual Studio */ +# define XXH_swap32 _byteswap_ulong +#elif XXH_GCC_VERSION >= 403 +# define XXH_swap32 __builtin_bswap32 +#else +static U32 XXH_swap32 (U32 x) +{ + return ((x << 24) & 0xff000000 ) | + ((x << 8) & 0x00ff0000 ) | + ((x >> 8) & 0x0000ff00 ) | + ((x >> 24) & 0x000000ff ); +} +#endif + + +/* ************************************* +* Architecture Macros +***************************************/ +typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess; + +/* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */ +#ifndef XXH_CPU_LITTLE_ENDIAN +static int XXH_isLittleEndian(void) +{ + const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ + return one.c[0]; +} +# define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian() +#endif + + +/* *************************** +* Memory reads +*****************************/ +typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment; + +FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +{ + if (align==XXH_unaligned) + return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr)); + else + return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr); +} + +FORCE_INLINE U32 XXH_readLE32(const void* ptr, XXH_endianess endian) +{ + return XXH_readLE32_align(ptr, endian, XXH_unaligned); +} + +static U32 XXH_readBE32(const void* ptr) +{ + return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr); +} + + +/* ************************************* +* Macros +***************************************/ +#define XXH_STATIC_ASSERT(c) { enum { XXH_sa = 1/(int)(!!(c)) }; } /* use after variable declarations */ +XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; } + + +/* ******************************************************************* +* 32-bit hash functions +*********************************************************************/ +static const U32 PRIME32_1 = 2654435761U; +static const U32 PRIME32_2 = 2246822519U; +static const U32 PRIME32_3 = 3266489917U; +static const U32 PRIME32_4 = 668265263U; +static const U32 PRIME32_5 = 374761393U; + +static U32 XXH32_round(U32 seed, U32 input) +{ + seed += input * PRIME32_2; + seed = XXH_rotl32(seed, 13); + seed *= PRIME32_1; + return seed; +} + +/* mix all bits */ +static U32 XXH32_avalanche(U32 h32) +{ + h32 ^= h32 >> 15; + h32 *= PRIME32_2; + h32 ^= h32 >> 13; + h32 *= PRIME32_3; + h32 ^= h32 >> 16; + return(h32); +} + +#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align) + +static U32 +XXH32_finalize(U32 h32, const void* ptr, size_t len, + XXH_endianess endian, XXH_alignment align) + +{ + const BYTE* p = (const BYTE*)ptr; + +#define PROCESS1 \ + h32 += (*p++) * PRIME32_5; \ + h32 = XXH_rotl32(h32, 11) * PRIME32_1 ; + +#define PROCESS4 \ + h32 += XXH_get32bits(p) * PRIME32_3; \ + p+=4; \ + h32 = XXH_rotl32(h32, 17) * PRIME32_4 ; + + switch(len&15) /* or switch(bEnd - p) */ + { + case 12: PROCESS4; + /* fallthrough */ + case 8: PROCESS4; + /* fallthrough */ + case 4: PROCESS4; + return XXH32_avalanche(h32); + + case 13: PROCESS4; + /* fallthrough */ + case 9: PROCESS4; + /* fallthrough */ + case 5: PROCESS4; + PROCESS1; + return XXH32_avalanche(h32); + + case 14: PROCESS4; + /* fallthrough */ + case 10: PROCESS4; + /* fallthrough */ + case 6: PROCESS4; + PROCESS1; + PROCESS1; + return XXH32_avalanche(h32); + + case 15: PROCESS4; + /* fallthrough */ + case 11: PROCESS4; + /* fallthrough */ + case 7: PROCESS4; + /* fallthrough */ + case 3: PROCESS1; + /* fallthrough */ + case 2: PROCESS1; + /* fallthrough */ + case 1: PROCESS1; + /* fallthrough */ + case 0: return XXH32_avalanche(h32); + } + assert(0); + return h32; /* reaching this point is deemed impossible */ +} + + +FORCE_INLINE U32 +XXH32_endian_align(const void* input, size_t len, U32 seed, + XXH_endianess endian, XXH_alignment align) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* bEnd = p + len; + U32 h32; + +#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) + if (p==NULL) { + len=0; + bEnd=p=(const BYTE*)(size_t)16; + } +#endif + + if (len>=16) { + const BYTE* const limit = bEnd - 15; + U32 v1 = seed + PRIME32_1 + PRIME32_2; + U32 v2 = seed + PRIME32_2; + U32 v3 = seed + 0; + U32 v4 = seed - PRIME32_1; + + do { + v1 = XXH32_round(v1, XXH_get32bits(p)); p+=4; + v2 = XXH32_round(v2, XXH_get32bits(p)); p+=4; + v3 = XXH32_round(v3, XXH_get32bits(p)); p+=4; + v4 = XXH32_round(v4, XXH_get32bits(p)); p+=4; + } while (p < limit); + + h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7) + + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18); + } else { + h32 = seed + PRIME32_5; + } + + h32 += (U32)len; + + return XXH32_finalize(h32, p, len&15, endian, align); +} + + +XXH_PUBLIC_API unsigned int XXH32 (const void* input, size_t len, unsigned int seed) +{ +#if 0 + /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ + XXH32_state_t state; + XXH32_reset(&state, seed); + XXH32_update(&state, input, len); + return XXH32_digest(&state); +#else + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if (XXH_FORCE_ALIGN_CHECK) { + if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */ + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned); + else + return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned); + } } + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned); + else + return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned); +#endif +} + + + +/*====== Hash streaming ======*/ + +XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void) +{ + return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t)); +} +XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr) +{ + XXH_free(statePtr); + return XXH_OK; +} + +XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dstState, const XXH32_state_t* srcState) +{ + memcpy(dstState, srcState, sizeof(*dstState)); +} + +XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int seed) +{ + XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */ + memset(&state, 0, sizeof(state)); + state.v1 = seed + PRIME32_1 + PRIME32_2; + state.v2 = seed + PRIME32_2; + state.v3 = seed + 0; + state.v4 = seed - PRIME32_1; + /* do not write into reserved, planned to be removed in a future version */ + memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved)); + return XXH_OK; +} + + +FORCE_INLINE XXH_errorcode +XXH32_update_endian(XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian) +{ + if (input==NULL) +#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) + return XXH_OK; +#else + return XXH_ERROR; +#endif + + { const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; + + state->total_len_32 += (unsigned)len; + state->large_len |= (len>=16) | (state->total_len_32>=16); + + if (state->memsize + len < 16) { /* fill in tmp buffer */ + XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len); + state->memsize += (unsigned)len; + return XXH_OK; + } + + if (state->memsize) { /* some data left from previous update */ + XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize); + { const U32* p32 = state->mem32; + state->v1 = XXH32_round(state->v1, XXH_readLE32(p32, endian)); p32++; + state->v2 = XXH32_round(state->v2, XXH_readLE32(p32, endian)); p32++; + state->v3 = XXH32_round(state->v3, XXH_readLE32(p32, endian)); p32++; + state->v4 = XXH32_round(state->v4, XXH_readLE32(p32, endian)); + } + p += 16-state->memsize; + state->memsize = 0; + } + + if (p <= bEnd-16) { + const BYTE* const limit = bEnd - 16; + U32 v1 = state->v1; + U32 v2 = state->v2; + U32 v3 = state->v3; + U32 v4 = state->v4; + + do { + v1 = XXH32_round(v1, XXH_readLE32(p, endian)); p+=4; + v2 = XXH32_round(v2, XXH_readLE32(p, endian)); p+=4; + v3 = XXH32_round(v3, XXH_readLE32(p, endian)); p+=4; + v4 = XXH32_round(v4, XXH_readLE32(p, endian)); p+=4; + } while (p<=limit); + + state->v1 = v1; + state->v2 = v2; + state->v3 = v3; + state->v4 = v4; + } + + if (p < bEnd) { + XXH_memcpy(state->mem32, p, (size_t)(bEnd-p)); + state->memsize = (unsigned)(bEnd-p); + } + } + + return XXH_OK; +} + + +XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void* input, size_t len) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_update_endian(state_in, input, len, XXH_littleEndian); + else + return XXH32_update_endian(state_in, input, len, XXH_bigEndian); +} + + +FORCE_INLINE U32 +XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian) +{ + U32 h32; + + if (state->large_len) { + h32 = XXH_rotl32(state->v1, 1) + + XXH_rotl32(state->v2, 7) + + XXH_rotl32(state->v3, 12) + + XXH_rotl32(state->v4, 18); + } else { + h32 = state->v3 /* == seed */ + PRIME32_5; + } + + h32 += state->total_len_32; + + return XXH32_finalize(h32, state->mem32, state->memsize, endian, XXH_aligned); +} + + +XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state_in) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_digest_endian(state_in, XXH_littleEndian); + else + return XXH32_digest_endian(state_in, XXH_bigEndian); +} + + +/*====== Canonical representation ======*/ + +/*! Default XXH result types are basic unsigned 32 and 64 bits. +* The canonical representation follows human-readable write convention, aka big-endian (large digits first). +* These functions allow transformation of hash result into and from its canonical format. +* This way, hash values can be written into a file or buffer, remaining comparable across different systems. +*/ + +XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash) +{ + XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t)); + if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash); + memcpy(dst, &hash, sizeof(*dst)); +} + +XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src) +{ + return XXH_readBE32(src); +} + + +#ifndef XXH_NO_LONG_LONG + +/* ******************************************************************* +* 64-bit hash functions +*********************************************************************/ + +/*====== Memory access ======*/ + +#ifndef MEM_MODULE +# define MEM_MODULE +# if !defined (__VMS) \ + && (defined (__cplusplus) \ + || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) +# include + typedef uint64_t U64; +# else + /* if compiler doesn't support unsigned long long, replace by another 64-bit type */ + typedef unsigned long long U64; +# endif +#endif + + +#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2)) + +/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */ +static U64 XXH_read64(const void* memPtr) { return *(const U64*) memPtr; } + +#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1)) + +/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */ +/* currently only defined for gcc and icc */ +typedef union { U32 u32; U64 u64; } __attribute__((packed)) unalign64; +static U64 XXH_read64(const void* ptr) { return ((const unalign64*)ptr)->u64; } + +#else + +/* portable and safe solution. Generally efficient. + * see : http://stackoverflow.com/a/32095106/646947 + */ + +static U64 XXH_read64(const void* memPtr) +{ + U64 val; + memcpy(&val, memPtr, sizeof(val)); + return val; +} + +#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */ + +#if defined(_MSC_VER) /* Visual Studio */ +# define XXH_swap64 _byteswap_uint64 +#elif XXH_GCC_VERSION >= 403 +# define XXH_swap64 __builtin_bswap64 +#else +static U64 XXH_swap64 (U64 x) +{ + return ((x << 56) & 0xff00000000000000ULL) | + ((x << 40) & 0x00ff000000000000ULL) | + ((x << 24) & 0x0000ff0000000000ULL) | + ((x << 8) & 0x000000ff00000000ULL) | + ((x >> 8) & 0x00000000ff000000ULL) | + ((x >> 24) & 0x0000000000ff0000ULL) | + ((x >> 40) & 0x000000000000ff00ULL) | + ((x >> 56) & 0x00000000000000ffULL); +} +#endif + +FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +{ + if (align==XXH_unaligned) + return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr)); + else + return endian==XXH_littleEndian ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr); +} + +FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian) +{ + return XXH_readLE64_align(ptr, endian, XXH_unaligned); +} + +static U64 XXH_readBE64(const void* ptr) +{ + return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr); +} + + +/*====== xxh64 ======*/ + +static const U64 PRIME64_1 = 11400714785074694791ULL; +static const U64 PRIME64_2 = 14029467366897019727ULL; +static const U64 PRIME64_3 = 1609587929392839161ULL; +static const U64 PRIME64_4 = 9650029242287828579ULL; +static const U64 PRIME64_5 = 2870177450012600261ULL; + +static U64 XXH64_round(U64 acc, U64 input) +{ + acc += input * PRIME64_2; + acc = XXH_rotl64(acc, 31); + acc *= PRIME64_1; + return acc; +} + +static U64 XXH64_mergeRound(U64 acc, U64 val) +{ + val = XXH64_round(0, val); + acc ^= val; + acc = acc * PRIME64_1 + PRIME64_4; + return acc; +} + +static U64 XXH64_avalanche(U64 h64) +{ + h64 ^= h64 >> 33; + h64 *= PRIME64_2; + h64 ^= h64 >> 29; + h64 *= PRIME64_3; + h64 ^= h64 >> 32; + return h64; +} + + +#define XXH_get64bits(p) XXH_readLE64_align(p, endian, align) + +static U64 +XXH64_finalize(U64 h64, const void* ptr, size_t len, + XXH_endianess endian, XXH_alignment align) +{ + const BYTE* p = (const BYTE*)ptr; + +#define PROCESS1_64 \ + h64 ^= (*p++) * PRIME64_5; \ + h64 = XXH_rotl64(h64, 11) * PRIME64_1; + +#define PROCESS4_64 \ + h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1; \ + p+=4; \ + h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; + +#define PROCESS8_64 { \ + U64 const k1 = XXH64_round(0, XXH_get64bits(p)); \ + p+=8; \ + h64 ^= k1; \ + h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; \ +} + + switch(len&31) { + case 24: PROCESS8_64; + /* fallthrough */ + case 16: PROCESS8_64; + /* fallthrough */ + case 8: PROCESS8_64; + return XXH64_avalanche(h64); + + case 28: PROCESS8_64; + /* fallthrough */ + case 20: PROCESS8_64; + /* fallthrough */ + case 12: PROCESS8_64; + /* fallthrough */ + case 4: PROCESS4_64; + return XXH64_avalanche(h64); + + case 25: PROCESS8_64; + /* fallthrough */ + case 17: PROCESS8_64; + /* fallthrough */ + case 9: PROCESS8_64; + PROCESS1_64; + return XXH64_avalanche(h64); + + case 29: PROCESS8_64; + /* fallthrough */ + case 21: PROCESS8_64; + /* fallthrough */ + case 13: PROCESS8_64; + /* fallthrough */ + case 5: PROCESS4_64; + PROCESS1_64; + return XXH64_avalanche(h64); + + case 26: PROCESS8_64; + /* fallthrough */ + case 18: PROCESS8_64; + /* fallthrough */ + case 10: PROCESS8_64; + PROCESS1_64; + PROCESS1_64; + return XXH64_avalanche(h64); + + case 30: PROCESS8_64; + /* fallthrough */ + case 22: PROCESS8_64; + /* fallthrough */ + case 14: PROCESS8_64; + /* fallthrough */ + case 6: PROCESS4_64; + PROCESS1_64; + PROCESS1_64; + return XXH64_avalanche(h64); + + case 27: PROCESS8_64; + /* fallthrough */ + case 19: PROCESS8_64; + /* fallthrough */ + case 11: PROCESS8_64; + PROCESS1_64; + PROCESS1_64; + PROCESS1_64; + return XXH64_avalanche(h64); + + case 31: PROCESS8_64; + /* fallthrough */ + case 23: PROCESS8_64; + /* fallthrough */ + case 15: PROCESS8_64; + /* fallthrough */ + case 7: PROCESS4_64; + /* fallthrough */ + case 3: PROCESS1_64; + /* fallthrough */ + case 2: PROCESS1_64; + /* fallthrough */ + case 1: PROCESS1_64; + /* fallthrough */ + case 0: return XXH64_avalanche(h64); + } + + /* impossible to reach */ + assert(0); + return 0; /* unreachable, but some compilers complain without it */ +} + +FORCE_INLINE U64 +XXH64_endian_align(const void* input, size_t len, U64 seed, + XXH_endianess endian, XXH_alignment align) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* bEnd = p + len; + U64 h64; + +#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) + if (p==NULL) { + len=0; + bEnd=p=(const BYTE*)(size_t)32; + } +#endif + + if (len>=32) { + const BYTE* const limit = bEnd - 32; + U64 v1 = seed + PRIME64_1 + PRIME64_2; + U64 v2 = seed + PRIME64_2; + U64 v3 = seed + 0; + U64 v4 = seed - PRIME64_1; + + do { + v1 = XXH64_round(v1, XXH_get64bits(p)); p+=8; + v2 = XXH64_round(v2, XXH_get64bits(p)); p+=8; + v3 = XXH64_round(v3, XXH_get64bits(p)); p+=8; + v4 = XXH64_round(v4, XXH_get64bits(p)); p+=8; + } while (p<=limit); + + h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); + h64 = XXH64_mergeRound(h64, v1); + h64 = XXH64_mergeRound(h64, v2); + h64 = XXH64_mergeRound(h64, v3); + h64 = XXH64_mergeRound(h64, v4); + + } else { + h64 = seed + PRIME64_5; + } + + h64 += (U64) len; + + return XXH64_finalize(h64, p, len, endian, align); +} + + +XXH_PUBLIC_API unsigned long long XXH64 (const void* input, size_t len, unsigned long long seed) +{ +#if 0 + /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ + XXH64_state_t state; + XXH64_reset(&state, seed); + XXH64_update(&state, input, len); + return XXH64_digest(&state); +#else + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if (XXH_FORCE_ALIGN_CHECK) { + if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */ + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned); + else + return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned); + } } + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned); + else + return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned); +#endif +} + +/*====== Hash Streaming ======*/ + +XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void) +{ + return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t)); +} +XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr) +{ + XXH_free(statePtr); + return XXH_OK; +} + +XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dstState, const XXH64_state_t* srcState) +{ + memcpy(dstState, srcState, sizeof(*dstState)); +} + +XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed) +{ + XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */ + memset(&state, 0, sizeof(state)); + state.v1 = seed + PRIME64_1 + PRIME64_2; + state.v2 = seed + PRIME64_2; + state.v3 = seed + 0; + state.v4 = seed - PRIME64_1; + /* do not write into reserved, planned to be removed in a future version */ + memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved)); + return XXH_OK; +} + +FORCE_INLINE XXH_errorcode +XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian) +{ + if (input==NULL) +#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1) + return XXH_OK; +#else + return XXH_ERROR; +#endif + + { const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; + + state->total_len += len; + + if (state->memsize + len < 32) { /* fill in tmp buffer */ + XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, len); + state->memsize += (U32)len; + return XXH_OK; + } + + if (state->memsize) { /* tmp buffer is full */ + XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, 32-state->memsize); + state->v1 = XXH64_round(state->v1, XXH_readLE64(state->mem64+0, endian)); + state->v2 = XXH64_round(state->v2, XXH_readLE64(state->mem64+1, endian)); + state->v3 = XXH64_round(state->v3, XXH_readLE64(state->mem64+2, endian)); + state->v4 = XXH64_round(state->v4, XXH_readLE64(state->mem64+3, endian)); + p += 32-state->memsize; + state->memsize = 0; + } + + if (p+32 <= bEnd) { + const BYTE* const limit = bEnd - 32; + U64 v1 = state->v1; + U64 v2 = state->v2; + U64 v3 = state->v3; + U64 v4 = state->v4; + + do { + v1 = XXH64_round(v1, XXH_readLE64(p, endian)); p+=8; + v2 = XXH64_round(v2, XXH_readLE64(p, endian)); p+=8; + v3 = XXH64_round(v3, XXH_readLE64(p, endian)); p+=8; + v4 = XXH64_round(v4, XXH_readLE64(p, endian)); p+=8; + } while (p<=limit); + + state->v1 = v1; + state->v2 = v2; + state->v3 = v3; + state->v4 = v4; + } + + if (p < bEnd) { + XXH_memcpy(state->mem64, p, (size_t)(bEnd-p)); + state->memsize = (unsigned)(bEnd-p); + } + } + + return XXH_OK; +} + +XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void* input, size_t len) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_update_endian(state_in, input, len, XXH_littleEndian); + else + return XXH64_update_endian(state_in, input, len, XXH_bigEndian); +} + +FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian) +{ + U64 h64; + + if (state->total_len >= 32) { + U64 const v1 = state->v1; + U64 const v2 = state->v2; + U64 const v3 = state->v3; + U64 const v4 = state->v4; + + h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18); + h64 = XXH64_mergeRound(h64, v1); + h64 = XXH64_mergeRound(h64, v2); + h64 = XXH64_mergeRound(h64, v3); + h64 = XXH64_mergeRound(h64, v4); + } else { + h64 = state->v3 /*seed*/ + PRIME64_5; + } + + h64 += (U64) state->total_len; + + return XXH64_finalize(h64, state->mem64, (size_t)state->total_len, endian, XXH_aligned); +} + +XXH_PUBLIC_API unsigned long long XXH64_digest (const XXH64_state_t* state_in) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH64_digest_endian(state_in, XXH_littleEndian); + else + return XXH64_digest_endian(state_in, XXH_bigEndian); +} + + +/*====== Canonical representation ======*/ + +XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash) +{ + XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t)); + if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash); + memcpy(dst, &hash, sizeof(*dst)); +} + +XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src) +{ + return XXH_readBE64(src); +} + +#endif /* XXH_NO_LONG_LONG */ diff --git a/source/util/test/utilTests.cpp b/source/util/test/utilTests.cpp index c56ef348cc..a355125410 100644 --- a/source/util/test/utilTests.cpp +++ b/source/util/test/utilTests.cpp @@ -294,4 +294,32 @@ TEST(utilTest, tstrncspn) { const char* reject5 = "911"; v = tstrncspn(p2, strlen(p2), reject5, 0); ASSERT_EQ(v, 14); +} + +TEST(utilTest, intToHextStr) { + char buf[64] = {0}; + + int64_t v = 0; + tintToHex(0, buf); + ASSERT_STREQ(buf, "0"); + + v = 100000000; + tintToHex(v, buf); + + char destBuf[128]; + sprintf(destBuf, "%" PRIx64, v); + ASSERT_STREQ(buf, destBuf); + + taosSeedRand(taosGetTimestampSec()); + + for(int32_t i = 0; i < 100000; ++i) { + memset(buf, 0, tListLen(buf)); + memset(destBuf, 0, tListLen(destBuf)); + + v = taosRand(); + tintToHex(v, buf); + + sprintf(destBuf, "%" PRIx64, v); + ASSERT_STREQ(buf, destBuf); + } } \ No newline at end of file diff --git a/tests/develop-test/2-query/table_count_scan.py b/tests/develop-test/2-query/table_count_scan.py index 1ef65bfc67..5bdc915cdd 100644 --- a/tests/develop-test/2-query/table_count_scan.py +++ b/tests/develop-test/2-query/table_count_scan.py @@ -75,7 +75,7 @@ class TDTestCase: tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.query('select count(1),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') + tdSql.query('select count(1) v,db_name, stable_name from information_schema.ins_tables group by db_name, stable_name order by v desc;') tdSql.checkRows(3) tdSql.checkData(0, 0, 23) tdSql.checkData(0, 1, 'information_schema') @@ -87,12 +87,12 @@ class TDTestCase: tdSql.checkData(2, 1, 'tbl_count') tdSql.checkData(2, 2, 'stb1') - tdSql.query('select count(1),db_name from information_schema.ins_tables group by db_name') + tdSql.query('select count(1) v,db_name from information_schema.ins_tables group by db_name order by v asc') tdSql.checkRows(3) - tdSql.checkData(0, 0, 5) - tdSql.checkData(0, 1, 'performance_schema') - tdSql.checkData(1, 0, 3) - tdSql.checkData(1, 1, 'tbl_count') + tdSql.checkData(1, 0, 5) + tdSql.checkData(1, 1, 'performance_schema') + tdSql.checkData(0, 0, 3) + tdSql.checkData(0, 1, 'tbl_count') tdSql.checkData(2, 0, 23) tdSql.checkData(2, 1, 'information_schema') @@ -177,42 +177,44 @@ class TDTestCase: tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:29\',true, 0,0,0,0,0,0,"000","0000",0,0,0,0);') - tdSql.query('select count(*),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') + tdSql.query('select count(*) v,db_name, stable_name from information_schema.ins_tables group by db_name, stable_name order by v;') tdSql.checkRows(4) tdSql.checkData(0, 0, 1) tdSql.checkData(0, 1, 'tbl_count') tdSql.checkData(0, 2, 'stba') - tdSql.checkData(1, 0, 23) - tdSql.checkData(1, 1, 'information_schema') - tdSql.checkData(1, 2, None) - tdSql.checkData(2, 0, 3) - tdSql.checkData(2, 1, 'tbl_count') - tdSql.checkData(2, 2, 'stb1') - tdSql.checkData(3, 0, 5) - tdSql.checkData(3, 1, 'performance_schema') + + tdSql.checkData(1, 0, 3) + tdSql.checkData(1, 1, 'tbl_count') + tdSql.checkData(1, 2, 'stb1') + tdSql.checkData(2, 0, 5) + tdSql.checkData(2, 1, 'performance_schema') + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 0, 23) + tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) - tdSql.query('select count(1),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') + tdSql.query('select count(1) v,db_name, stable_name from information_schema.ins_tables group by db_name, stable_name order by v;') tdSql.checkRows(4) - tdSql.checkData(0, 0, 23) - tdSql.checkData(0, 1, 'information_schema') - tdSql.checkData(0, 2, None) + tdSql.checkData(0, 0, 1) + tdSql.checkData(0, 1, 'tbl_count') + tdSql.checkData(0, 2, 'stba') + tdSql.checkData(1, 0, 3) + tdSql.checkData(1, 1, 'tbl_count') + tdSql.checkData(1, 2, 'stb1') + tdSql.checkData(2, 0, 5) + tdSql.checkData(2, 1, 'performance_schema') + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 0, 23) + tdSql.checkData(3, 1, 'information_schema') + tdSql.checkData(3, 2, None) + + tdSql.query('select count(1) v,db_name from information_schema.ins_tables group by db_name order by v') + tdSql.checkRows(3) + + tdSql.checkData(0, 0, 4) + tdSql.checkData(0, 1, 'tbl_count') tdSql.checkData(1, 0, 5) tdSql.checkData(1, 1, 'performance_schema') - tdSql.checkData(1, 2, None) - tdSql.checkData(2, 0, 1) - tdSql.checkData(2, 1, 'tbl_count') - tdSql.checkData(2, 2, 'stba') - tdSql.checkData(3, 0, 3) - tdSql.checkData(3, 1, 'tbl_count') - tdSql.checkData(3, 2, 'stb1') - - tdSql.query('select count(1),db_name from information_schema.ins_tables group by db_name') - tdSql.checkRows(3) - tdSql.checkData(0, 0, 5) - tdSql.checkData(0, 1, 'performance_schema') - tdSql.checkData(1, 0, 4) - tdSql.checkData(1, 1, 'tbl_count') tdSql.checkData(2, 0, 23) tdSql.checkData(2, 1, 'information_schema') diff --git a/tests/script/tsim/alter/dnode.sim b/tests/script/tsim/alter/dnode.sim index 8cfa86a88a..f9b794924b 100644 --- a/tests/script/tsim/alter/dnode.sim +++ b/tests/script/tsim/alter/dnode.sim @@ -58,6 +58,8 @@ sql_error alter dnode 1 'monDebugFlag 131' sql_error alter dnode 1 'cqDebugFlag 131' sql_error alter dnode 1 'httpDebugFlag 131' sql_error alter dnode 1 'mqttDebugFlag 131' +sql_error alter dnode 1 'qDebugFlaga 131' +sql_error alter all dnodes 'qDebugFlaga 131' sql_error alter dnode 2 'wDebugFlag' '135' sql_error alter dnode 2 'tmrDebugFlag' '135' @@ -65,6 +67,8 @@ sql_error alter dnode 1 'monDebugFlag' '131' sql_error alter dnode 1 'cqDebugFlag' '131' sql_error alter dnode 1 'httpDebugFlag' '131' sql_error alter dnode 1 'mqttDebugFlag' '131' +sql_error alter dnode 1 'qDebugFlaga' '131' +sql_error alter all dnodes 'qDebugFlaga' '131' print ======== step3 sql_error alter $hostname1 debugFlag 135 diff --git a/tests/script/tsim/compute/block_dist.sim b/tests/script/tsim/compute/block_dist.sim index 4fdcf63e34..772959644e 100644 --- a/tests/script/tsim/compute/block_dist.sim +++ b/tests/script/tsim/compute/block_dist.sim @@ -81,7 +81,6 @@ $nt = $ntPrefix . $i #sql select _block_dist() from $nt print show table distributed $nt -sql_error show table distributed $nt #if $rows == 0 then # return -1 diff --git a/tests/script/tsim/parser/nestquery.sim b/tests/script/tsim/parser/nestquery.sim index 494c3de99f..2a363de43d 100644 --- a/tests/script/tsim/parser/nestquery.sim +++ b/tests/script/tsim/parser/nestquery.sim @@ -351,7 +351,7 @@ sql_error select last_row(*) from (select * from nest_tb0) having c1 > 0 print ===========>td-4805 sql_error select tbname, i from (select * from nest_tb0) group by i; -sql select count(*),c1 from (select * from nest_tb0) where c1 < 2 group by c1; +sql select count(*),c1 from (select * from nest_tb0) where c1 < 2 group by c1 order by c1; if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/parser/regressiontest.sim b/tests/script/tsim/parser/regressiontest.sim index c08b1bbf27..fe388a611e 100644 --- a/tests/script/tsim/parser/regressiontest.sim +++ b/tests/script/tsim/parser/regressiontest.sim @@ -143,9 +143,11 @@ sql delete from t1 where ts<=1537146409500 sql flush database $db +print ======================================>TS-2639 +sql show table distributed t1; + print =====================================>TD-22007 sql select count(*) from t1 interval(10a) - sql drop table t1 sql create table st1 (ts timestamp, k int) tags(a int); @@ -165,7 +167,7 @@ if $data00 != 10 then return -1 endi -sql select last_row(*) from st1 group by a +sql select last_row(*) from st1 group by a order by a desc if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/scalar/caseWhen.sim b/tests/script/tsim/scalar/caseWhen.sim index f6b9c3ff08..c10413f23c 100644 --- a/tests/script/tsim/scalar/caseWhen.sim +++ b/tests/script/tsim/scalar/caseWhen.sim @@ -519,7 +519,7 @@ if $rows != 0 then return -1 endi -sql select sum(f1),count(f1) from tba1 partition by case when f1 then f1 when 1 then 1 end; +sql select sum(f1) v,count(f1) from tba1 partition by case when f1 then f1 when 1 then 1 end order by v; if $rows != 2 then return -1 endi diff --git a/tests/script/tsim/stream/deleteSession.sim b/tests/script/tsim/stream/deleteSession.sim index 541609633b..c3c64a5977 100644 --- a/tests/script/tsim/stream/deleteSession.sim +++ b/tests/script/tsim/stream/deleteSession.sim @@ -524,6 +524,112 @@ if $data42 != 14 then goto loop20 endi +sql drop database if exists test4; +sql drop stream if exists streams4; +sql create database test4 vgroups 1; +sql use test4; +sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +print create stream streams4 trigger at_once into streamt4 as select _wstart, count(*) c1 from st partition by tbname session(ts, 2s); +sql create stream streams4 trigger at_once into streamt4 as select _wstart, count(*) c1 from st partition by tbname session(ts, 2s); + +sql insert into t1 values(1648791210000,1,2,3); +sql insert into t1 values(1648791220000,2,2,3); +sql insert into t1 values(1648791221000,2,2,3); +sql insert into t1 values(1648791222000,2,2,3); +sql insert into t1 values(1648791223000,2,2,3); +sql insert into t1 values(1648791231000,2,2,3); + +sql insert into t2 values(1648791210000,1,2,3); +sql insert into t2 values(1648791220000,2,2,3); +sql insert into t2 values(1648791221000,2,2,3); +sql insert into t2 values(1648791231000,2,2,3); + +$loop_count = 0 + +loop21: +sleep 200 +sql select * from streamt4 order by c1 desc;; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 6 then + print =====rows=$rows + goto loop21 +endi + +if $data01 != 4 then + print =====data01=$data01 + goto loop21 +endi + +if $data11 != 2 then + print =====data11=$data11 + goto loop21 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop21 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop21 +endi + +if $data41 != 1 then + print =====data41=$data41 + goto loop21 +endi + +if $data51 != 1 then + print =====data51=$data51 + goto loop21 +endi + +print delete from st where ts >= 1648791220000 and ts <=1648791223000; +sql delete from st where ts >= 1648791220000 and ts <=1648791223000; + +loop22: +sleep 200 +sql select * from streamt4 order by c1 desc;; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 4 then + print =====rows=$rows + goto loop22 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop22 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop22 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop22 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop22 +endi + $loop_all = $loop_all + 1 print ============loop_all=$loop_all diff --git a/tests/script/tsim/stream/deleteState.sim b/tests/script/tsim/stream/deleteState.sim index ecd9f55340..45d9bc3e39 100644 --- a/tests/script/tsim/stream/deleteState.sim +++ b/tests/script/tsim/stream/deleteState.sim @@ -189,6 +189,112 @@ if $data12 != 4 then goto loop6 endi +sql drop database if exists test4; +sql drop stream if exists streams4; +sql create database test4 vgroups 1; +sql use test4; +sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +print create stream streams4 trigger at_once into streamt4 as select _wstart, count(*) c1 from st partition by tbname state_window(c); +sql create stream streams4 trigger at_once into streamt4 as select _wstart, count(*) c1 from st partition by tbname state_window(c); + +sql insert into t1 values(1648791210000,1,2,1); +sql insert into t1 values(1648791220000,2,2,2); +sql insert into t1 values(1648791221000,2,2,2); +sql insert into t1 values(1648791222000,2,2,2); +sql insert into t1 values(1648791223000,2,2,2); +sql insert into t1 values(1648791231000,2,2,3); + +sql insert into t2 values(1648791210000,1,2,1); +sql insert into t2 values(1648791220000,2,2,2); +sql insert into t2 values(1648791221000,2,2,2); +sql insert into t2 values(1648791231000,2,2,3); + +$loop_count = 0 + +loop21: +sleep 200 +sql select * from streamt4 order by c1 desc;; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 6 then + print =====rows=$rows + goto loop21 +endi + +if $data01 != 4 then + print =====data01=$data01 + goto loop21 +endi + +if $data11 != 2 then + print =====data11=$data11 + goto loop21 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop21 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop21 +endi + +if $data41 != 1 then + print =====data41=$data41 + goto loop21 +endi + +if $data51 != 1 then + print =====data51=$data51 + goto loop21 +endi + +print delete from st where ts >= 1648791220000 and ts <=1648791223000; +sql delete from st where ts >= 1648791220000 and ts <=1648791223000; + +loop22: +sleep 200 +sql select * from streamt4 order by c1 desc;; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 4 then + print =====rows=$rows + goto loop22 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop22 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop22 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop22 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop22 +endi + $loop_all = $loop_all + 1 print ============loop_all=$loop_all diff --git a/tests/script/tsim/stream/fillIntervalRange.sim b/tests/script/tsim/stream/fillIntervalRange.sim new file mode 100644 index 0000000000..a0905141f2 --- /dev/null +++ b/tests/script/tsim/stream/fillIntervalRange.sim @@ -0,0 +1,225 @@ +$loop_all = 0 +looptest: + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start + +sleep 500 +sql connect + +sql drop database if exists test; +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20));; +sql create stream streams1 trigger at_once into streamt as select _wstart ts, count(*) c1 from t1 interval(1s) fill(NULL); +sql insert into t1 values(1648791211000,1,2,3,1.0,'aaa'); +sleep 100 +sql insert into t1 values(1648795308000,1,2,3,1.0,'aaa'); + +$loop_count = 0 + +loop0: + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 500 +sql select * from streamt where c1 > 0; + +if $rows != 2 then + print =====rows=$rows + goto loop0 +endi + +sql select count(*) from streamt; + +if $data00 != 4098 then + print =====data00=$data00 + goto loop0 +endi + +sql insert into t1 values(1648800308000,1,1,1,1.0,'aaa'); + + +$loop_count = 0 + +loop1: +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 500 +sql select * from streamt where c1 > 0; + +if $rows != 3 then + print =====rows=$rows + goto loop1 +endi + +sql select count(*) from streamt; + +if $data00 != 9098 then + print =====rows=$rows + goto loop1 +endi + +sql insert into t1 values(1648786211000,1,1,1,1.0,'aaa'); + + +$loop_count = 0 + +loop2: +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 500 +sql select * from streamt where c1 > 0; + +if $rows != 4 then + print =====rows=$rows + goto loop2 +endi + +sql select count(*) from streamt; + +if $data00 != 14098 then + print =====rows=$rows + goto loop2 +endi + +sql insert into t1 values(1648801308000,1,1,1,1.0,'aaa') (1648802308000,1,1,1,1.0,'aaa') (1648803308000,1,1,1,1.0,'aaa') (1648804308000,1,1,1,1.0,'aaa') (1648805308000,1,1,1,1.0,'aaa'); + + +$loop_count = 0 + +loop21: +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 500 +sql select * from streamt where c1 > 0; + +if $rows != 9 then + print =====rows=$rows + goto loop21 +endi + +sql select count(*) from streamt; + +if $data00 != 19098 then + print =====rows=$rows + goto loop21 +endi + +sql drop database if exists test; +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20)); +print create stream streams1 trigger at_once into streamt as select _wstart ts, max(a) c1 from t1 interval(1s) fill(linear); +sql create stream streams1 trigger at_once into streamt as select _wstart ts, max(a) c1 from t1 interval(1s) fill(linear); + +print create stream streams2 trigger at_once into streamt2 as select _wstart ts, max(a) c1 from t1 interval(1s) fill(prev); +sql create stream streams2 trigger at_once into streamt2 as select _wstart ts, max(a) c1 from t1 interval(1s) fill(prev); + +sql insert into t1 values(1648791211000,1,2,3,1.0,'aaa'); +sleep 100 +sql insert into t1 values(1648795308000,1,2,3,1.0,'aaa'); + +$loop_count = 0 + +loop3: + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 500 + +print select count(*) from streamt; +sql select count(*) from streamt; + +if $data00 != 4098 then + print =====data00=$data00 + goto loop3 +endi + +print select count(*) from streamt2; +sql select count(*) from streamt2; + +if $data00 != 4098 then + print =====data00=$data00 + goto loop3 +endi + +sql insert into t1 values(1648800308000,1,1,1,1.0,'aaa'); + + +$loop_count = 0 + +loop4: +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 500 + +print select count(*) from streamt; +sql select count(*) from streamt; + +if $data00 != 9098 then + print =====rows=$rows + goto loop4 +endi + +print select count(*) from streamt2; +sql select count(*) from streamt2; + +if $data00 != 9098 then + print =====rows=$rows + goto loop4 +endi + +sql insert into t1 values(1648786211000,1,1,1,1.0,'aaa'); + + +$loop_count = 0 + +loop5: +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sleep 500 + +print select count(*) from streamt; +sql select count(*) from streamt; + +if $data00 != 14098 then + print =====rows=$rows + goto loop5 +endi + +print select count(*) from streamt2; +sql select count(*) from streamt2; + +if $data00 != 14098 then + print =====rows=$rows + goto loop5 +endi + +system sh/stop_dnodes.sh + +#goto looptest diff --git a/tests/system-test/2-query/interp.py b/tests/system-test/2-query/interp.py index ce57357abd..d30575aaa3 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -1850,15 +1850,16 @@ class TDTestCase: tdSql.error(f"select interp('abcd') from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)") tdSql.error(f"select interp('中文字符') from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)") + tdLog.printNoPrefix("==========step13:stable cases") - #tdSql.query(f"select interp(c0) from {dbname}.{stbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(null)") + tdSql.error(f"select interp(c0) from {dbname}.{stbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(null)") #tdSql.checkRows(13) #tdSql.query(f"select interp(c0) from {dbname}.{ctbname1} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(null)") #tdSql.checkRows(13) - #tdSql.query(f"select interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1s) fill(null)") + tdSql.error(f"select interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1s) fill(null)") #tdSql.checkRows(13) #tdSql.query(f"select _irowts,interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1h) fill(prev)") diff --git a/tests/system-test/2-query/unique.py b/tests/system-test/2-query/unique.py index 6af9b130ef..9b5da50e1f 100644 --- a/tests/system-test/2-query/unique.py +++ b/tests/system-test/2-query/unique.py @@ -433,7 +433,7 @@ class TDTestCase: tdSql.checkRows(11) tdSql.checkData(1,0,0) tdSql.checkData(10,0,9) - tdSql.query(f"select unique(t1) from (select _rowts , t1 , tbname from {dbname}.stb1 )") + tdSql.query(f"select unique(t1) v from (select _rowts , t1 , tbname from {dbname}.stb1 ) order by v desc") tdSql.checkRows(2) tdSql.checkData(0,0,4) tdSql.checkData(1,0,1) diff --git a/tools/shell/inc/shellAuto.h b/tools/shell/inc/shellAuto.h index b7bf5fa101..151f6da8c6 100644 --- a/tools/shell/inc/shellAuto.h +++ b/tools/shell/inc/shellAuto.h @@ -28,7 +28,7 @@ void pressOtherKey(char c); bool shellAutoInit(); // set conn -void shellSetConn(TAOS* conn); +void shellSetConn(TAOS* conn, bool runOnce); // exit shell auto funciton, shell exit call once void shellAutoExit(); diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 6e50a97c02..f58a5d0931 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -332,6 +332,7 @@ bool varMode = false; // enter var names list mode TAOS* varCon = NULL; SShellCmd* varCmd = NULL; +bool varRunOnce = false; SMatch* lastMatch = NULL; // save last match result int cntDel = 0; // delete byte count after next press tab @@ -375,7 +376,7 @@ void showHelp() { ----- C ----- \n\ create table using tags ...\n\ create database ...\n\ - create dnode \"fqdn:port\"n\ + create dnode \"fqdn:port\" ...\n\ create index ...\n\ create mnode on dnode ;\n\ create qnode on dnode ;\n\ @@ -637,10 +638,11 @@ bool shellAutoInit() { } // set conn -void shellSetConn(TAOS* conn) { - varCon = conn; +void shellSetConn(TAOS* conn, bool runOnce) { + varCon = conn; + varRunOnce = runOnce; // init database and stable - updateTireValue(WT_VAR_DBNAME, false); + if (!runOnce) updateTireValue(WT_VAR_DBNAME, false); } // exit shell auto funciton, shell exit call once @@ -784,6 +786,12 @@ int writeVarNames(int type, TAOS_RES* tres) { return numOfRows; } +void setThreadNull(int type) { + taosThreadMutexLock(&tiresMutex); + threads[type] = NULL; + taosThreadMutexUnlock(&tiresMutex); +} + bool firstMatchCommand(TAOS* con, SShellCmd* cmd); // // thread obtain var thread from db server @@ -799,6 +807,7 @@ void* varObtainThread(void* param) { TAOS_RES* pSql = taos_query(varCon, varSqls[type]); if (taos_errno(pSql)) { taos_free_result(pSql); + setThreadNull(type); return NULL; } @@ -814,6 +823,7 @@ void* varObtainThread(void* param) { firstMatchCommand(varCon, varCmd); } + setThreadNull(type); return NULL; } @@ -1977,7 +1987,7 @@ void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb) { if (dealUseDB(sql)) { // change to new db - updateTireValue(WT_VAR_STABLE, false); + if (!varRunOnce) updateTireValue(WT_VAR_STABLE, false); return; } diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 479c2cf39a..9b842a9e6f 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -1097,10 +1097,11 @@ int32_t shellExecute() { } #endif - shellSetConn(shell.conn); + bool runOnce = pArgs->commands != NULL || pArgs->file[0] != 0; + shellSetConn(shell.conn, runOnce); shellReadHistory(); - if (pArgs->commands != NULL || pArgs->file[0] != 0) { + if (runOnce) { if (pArgs->commands != NULL) { printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands); char *cmd = strdup(pArgs->commands); @@ -1160,5 +1161,8 @@ int32_t shellExecute() { taosThreadJoin(spid, NULL); shellCleanupHistory(); + taos_kill_query(shell.conn); + taos_close(shell.conn); + return 0; }