提交 daed646d 编写于 作者: P Ping Xiao

Merge branch 'develop' into filterComboTest

...@@ -30,7 +30,7 @@ extern int32_t cDebugFlag; ...@@ -30,7 +30,7 @@ extern int32_t cDebugFlag;
} }
#define tscWarn(...) \ #define tscWarn(...) \
if (cDebugFlag & DEBUG_WARN) { \ if (cDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN TSC ", cDebugFlag, __VA_ARGS__); \ taosPrintLog("WARN TSC ", cDebugFlag, __VA_ARGS__); \
} }
#define tscTrace(...) \ #define tscTrace(...) \
if (cDebugFlag & DEBUG_TRACE) { \ if (cDebugFlag & DEBUG_TRACE) { \
......
...@@ -53,11 +53,7 @@ typedef struct STableComInfo { ...@@ -53,11 +53,7 @@ typedef struct STableComInfo {
} STableComInfo; } STableComInfo;
typedef struct STableMeta { typedef struct STableMeta {
// super table if it is created according to super table, otherwise, tableInfo is used STableComInfo tableInfo;
union {
struct STableMeta *pSTable;
STableComInfo tableInfo;
};
uint8_t tableType; uint8_t tableType;
int16_t sversion; int16_t sversion;
SCMVgroupInfo vgroupInfo; SCMVgroupInfo vgroupInfo;
...@@ -214,7 +210,7 @@ typedef struct SQueryInfo { ...@@ -214,7 +210,7 @@ typedef struct SQueryInfo {
int16_t numOfTables; int16_t numOfTables;
STableMetaInfo **pTableMetaInfo; STableMetaInfo **pTableMetaInfo;
struct STSBuf * tsBuf; struct STSBuf * tsBuf;
int64_t * defaultVal; // default value for interpolation int64_t * fillVal; // default value for interpolation
char * msg; // pointer to the pCmd->payload to keep error message temporarily char * msg; // pointer to the pCmd->payload to keep error message temporarily
int64_t clauseLimit; // limit for current sub clause int64_t clauseLimit; // limit for current sub clause
......
...@@ -48,7 +48,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const ...@@ -48,7 +48,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const
pSql->param = param; pSql->param = param;
pSql->pTscObj = pObj; pSql->pTscObj = pObj;
pSql->maxRetry = TSDB_MAX_REPLICA_NUM; pSql->maxRetry = TSDB_MAX_REPLICA_NUM;
pSql->fp = fp; pSql->fp = fp;
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) {
tscError("failed to malloc payload"); tscError("failed to malloc payload");
......
...@@ -390,16 +390,16 @@ static void function_finalizer(SQLFunctionCtx *pCtx) { ...@@ -390,16 +390,16 @@ static void function_finalizer(SQLFunctionCtx *pCtx) {
if (pResInfo->hasResult != DATA_SET_FLAG) { if (pResInfo->hasResult != DATA_SET_FLAG) {
tscTrace("no result generated, result is set to NULL"); tscTrace("no result generated, result is set to NULL");
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); if (pCtx->outputType == TSDB_DATA_TYPE_BINARY || pCtx->outputType == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pCtx->aOutputBuf, pCtx->outputType);
} else {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes);
}
} }
doFinalizer(pCtx); doFinalizer(pCtx);
} }
static bool usePreVal(SQLFunctionCtx *pCtx) {
return pCtx->preAggVals.isSet && pCtx->size == pCtx->preAggVals.size;
}
/* /*
* count function does need the finalize, if data is missing, the default value, which is 0, is used * count function does need the finalize, if data is missing, the default value, which is 0, is used
* count function does not use the pCtx->interResBuf to keep the intermediate buffer * count function does not use the pCtx->interResBuf to keep the intermediate buffer
...@@ -412,7 +412,7 @@ static void count_function(SQLFunctionCtx *pCtx) { ...@@ -412,7 +412,7 @@ static void count_function(SQLFunctionCtx *pCtx) {
* 2. for general non-primary key columns, pCtx->hasNull may be true or false, pCtx->preAggVals.isSet == true; * 2. for general non-primary key columns, pCtx->hasNull may be true or false, pCtx->preAggVals.isSet == true;
* 3. for primary key column, pCtx->hasNull always be false, pCtx->preAggVals.isSet == false; * 3. for primary key column, pCtx->hasNull always be false, pCtx->preAggVals.isSet == false;
*/ */
if (usePreVal(pCtx)) { if (pCtx->preAggVals.isSet) {
numOfElem = pCtx->size - pCtx->preAggVals.statis.numOfNull; numOfElem = pCtx->size - pCtx->preAggVals.statis.numOfNull;
} else { } else {
if (pCtx->hasNull) { if (pCtx->hasNull) {
...@@ -537,7 +537,7 @@ static void do_sum(SQLFunctionCtx *pCtx) { ...@@ -537,7 +537,7 @@ static void do_sum(SQLFunctionCtx *pCtx) {
int32_t notNullElems = 0; int32_t notNullElems = 0;
// Only the pre-computing information loaded and actual data does not loaded // Only the pre-computing information loaded and actual data does not loaded
if (pCtx->preAggVals.isSet && pCtx->preAggVals.size == pCtx->size) { if (pCtx->preAggVals.isSet) {
notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull;
assert(pCtx->size >= pCtx->preAggVals.statis.numOfNull); assert(pCtx->size >= pCtx->preAggVals.statis.numOfNull);
...@@ -768,7 +768,7 @@ static void avg_function(SQLFunctionCtx *pCtx) { ...@@ -768,7 +768,7 @@ static void avg_function(SQLFunctionCtx *pCtx) {
SAvgInfo *pAvgInfo = (SAvgInfo *)pResInfo->interResultBuf; SAvgInfo *pAvgInfo = (SAvgInfo *)pResInfo->interResultBuf;
double * pVal = &pAvgInfo->sum; double * pVal = &pAvgInfo->sum;
if (usePreVal(pCtx)) { if (pCtx->preAggVals.isSet) {
// Pre-aggregation // Pre-aggregation
notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull;
assert(notNullElems >= 0); assert(notNullElems >= 0);
...@@ -932,7 +932,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) { ...@@ -932,7 +932,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) {
static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, int32_t *notNullElems) { static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, int32_t *notNullElems) {
// data in current data block are qualified to the query // data in current data block are qualified to the query
if (usePreVal(pCtx)) { if (pCtx->preAggVals.isSet) {
*notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; *notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull;
assert(*notNullElems >= 0); assert(*notNullElems >= 0);
...@@ -947,18 +947,21 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, ...@@ -947,18 +947,21 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
index = pCtx->preAggVals.statis.maxIndex; index = pCtx->preAggVals.statis.maxIndex;
} }
/** TSKEY key = TSKEY_INITIAL_VAL;
* NOTE: work around the bug caused by invalid pre-calculated function. if (pCtx->ptsList != NULL) {
* Here the selectivity + ts will not return correct value. /**
* * NOTE: work around the bug caused by invalid pre-calculated function.
* The following codes of 3 lines will be removed later. * Here the selectivity + ts will not return correct value.
*/ *
if (index < 0 || index >= pCtx->size + pCtx->startOffset) { * The following codes of 3 lines will be removed later.
index = 0; */
if (index < 0 || index >= pCtx->size + pCtx->startOffset) {
index = 0;
}
key = pCtx->ptsList[index];
} }
TSKEY key = pCtx->ptsList[index];
if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) {
int64_t val = GET_INT64_VAL(tval); int64_t val = GET_INT64_VAL(tval);
if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) {
...@@ -1865,12 +1868,22 @@ static void last_row_finalizer(SQLFunctionCtx *pCtx) { ...@@ -1865,12 +1868,22 @@ static void last_row_finalizer(SQLFunctionCtx *pCtx) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx); SResultInfo *pResInfo = GET_RES_INFO(pCtx);
if (pCtx->currentStage == SECONDARY_STAGE_MERGE) { if (pCtx->currentStage == SECONDARY_STAGE_MERGE) {
if (pResInfo->hasResult != DATA_SET_FLAG) { if (pResInfo->hasResult != DATA_SET_FLAG) {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); if (pCtx->outputType == TSDB_DATA_TYPE_BINARY || pCtx->outputType == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pCtx->aOutputBuf, pCtx->outputType);
} else {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes);
}
return; return;
} }
} else { } else {
if (pResInfo->hasResult != DATA_SET_FLAG) { if (pResInfo->hasResult != DATA_SET_FLAG) {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); if (pCtx->outputType == TSDB_DATA_TYPE_BINARY || pCtx->outputType == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pCtx->aOutputBuf, pCtx->outputType);
} else {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes);
}
return; return;
} }
} }
...@@ -2886,7 +2899,12 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) { ...@@ -2886,7 +2899,12 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) {
SLeastsquareInfo *pInfo = pResInfo->interResultBuf; SLeastsquareInfo *pInfo = pResInfo->interResultBuf;
if (pInfo->num == 0) { if (pInfo->num == 0) {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); if (pCtx->outputType == TSDB_DATA_TYPE_BINARY || pCtx->outputType == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pCtx->aOutputBuf, pCtx->outputType);
} else {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes);
}
return; return;
} }
...@@ -2913,10 +2931,6 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) { ...@@ -2913,10 +2931,6 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) {
} }
static void date_col_output_function(SQLFunctionCtx *pCtx) { static void date_col_output_function(SQLFunctionCtx *pCtx) {
if (pCtx->scanFlag == REVERSE_SCAN) {
return;
}
SET_VAL(pCtx, pCtx->size, 1); SET_VAL(pCtx, pCtx->size, 1);
*(int64_t *)(pCtx->aOutputBuf) = pCtx->nStartQueryTimestamp; *(int64_t *)(pCtx->aOutputBuf) = pCtx->nStartQueryTimestamp;
} }
...@@ -3081,7 +3095,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { ...@@ -3081,7 +3095,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
pOutput += 1; pOutput += 1;
pTimestamp += 1; pTimestamp += 1;
} else { } else {
*pOutput = pData[i] - pData[i - step]; *pOutput = pData[i] - pCtx->param[1].i64Key; // direct previous may be null
*pTimestamp = pCtx->ptsList[i]; *pTimestamp = pCtx->ptsList[i];
pOutput += 1; pOutput += 1;
...@@ -3113,7 +3127,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { ...@@ -3113,7 +3127,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
pOutput += 1; pOutput += 1;
pTimestamp += 1; pTimestamp += 1;
} else { } else {
*pOutput = pData[i] - pData[i - step]; *pOutput = pData[i] - pCtx->param[1].i64Key;
*pTimestamp = pCtx->ptsList[i]; *pTimestamp = pCtx->ptsList[i];
pOutput += 1; pOutput += 1;
...@@ -3144,7 +3158,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { ...@@ -3144,7 +3158,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
pOutput += 1; pOutput += 1;
pTimestamp += 1; pTimestamp += 1;
} else { } else {
*pOutput = pData[i] - pData[i - step]; *pOutput = pData[i] - pCtx->param[1].dKey;
*pTimestamp = pCtx->ptsList[i]; *pTimestamp = pCtx->ptsList[i];
pOutput += 1; pOutput += 1;
pTimestamp += 1; pTimestamp += 1;
...@@ -3175,7 +3189,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { ...@@ -3175,7 +3189,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
pOutput += 1; pOutput += 1;
pTimestamp += 1; pTimestamp += 1;
} else { } else {
*pOutput = pData[i] - pData[i - step]; *pOutput = pData[i] - pCtx->param[1].dKey;
*pTimestamp = pCtx->ptsList[i]; *pTimestamp = pCtx->ptsList[i];
pOutput += 1; pOutput += 1;
...@@ -3207,7 +3221,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { ...@@ -3207,7 +3221,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
pOutput += 1; pOutput += 1;
pTimestamp += 1; pTimestamp += 1;
} else { } else {
*pOutput = pData[i] - pData[i - step]; *pOutput = pData[i] - pCtx->param[1].i64Key;
*pTimestamp = pCtx->ptsList[i]; *pTimestamp = pCtx->ptsList[i];
pOutput += 1; pOutput += 1;
...@@ -3239,7 +3253,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { ...@@ -3239,7 +3253,7 @@ static void diff_function(SQLFunctionCtx *pCtx) {
pOutput += 1; pOutput += 1;
pTimestamp += 1; pTimestamp += 1;
} else { } else {
*pOutput = pData[i] - pData[i - step]; *pOutput = pData[i] - pCtx->param[1].i64Key;
*pTimestamp = pCtx->ptsList[i]; *pTimestamp = pCtx->ptsList[i];
pOutput += 1; pOutput += 1;
...@@ -3420,7 +3434,7 @@ static void spread_function(SQLFunctionCtx *pCtx) { ...@@ -3420,7 +3434,7 @@ static void spread_function(SQLFunctionCtx *pCtx) {
// todo : opt with pre-calculated result // todo : opt with pre-calculated result
// column missing cause the hasNull to be true // column missing cause the hasNull to be true
if (usePreVal(pCtx)) { if (pCtx->preAggVals.isSet) {
numOfElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; numOfElems = pCtx->size - pCtx->preAggVals.statis.numOfNull;
// all data are null in current data block, ignore current data block // all data are null in current data block, ignore current data block
...@@ -3446,14 +3460,8 @@ static void spread_function(SQLFunctionCtx *pCtx) { ...@@ -3446,14 +3460,8 @@ static void spread_function(SQLFunctionCtx *pCtx) {
pInfo->max = GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.max)); pInfo->max = GET_DOUBLE_VAL(&(pCtx->preAggVals.statis.max));
} }
} }
} else {
// if (pInfo->min > pCtx->param[1].dKey) { goto _spread_over;
// pInfo->min = pCtx->param[1].dKey;
// }
//
// if (pInfo->max < pCtx->param[2].dKey) {
// pInfo->max = pCtx->param[2].dKey;
// }
} }
void *pData = GET_INPUT_CHAR(pCtx); void *pData = GET_INPUT_CHAR(pCtx);
...@@ -3873,7 +3881,11 @@ static void interp_function(SQLFunctionCtx *pCtx) { ...@@ -3873,7 +3881,11 @@ static void interp_function(SQLFunctionCtx *pCtx) {
*(TSKEY *)pCtx->aOutputBuf = pInfoDetail->ts; *(TSKEY *)pCtx->aOutputBuf = pInfoDetail->ts;
} else { } else {
if (pInfoDetail->type == TSDB_FILL_NULL) { if (pInfoDetail->type == TSDB_FILL_NULL) {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); if (pCtx->outputType == TSDB_DATA_TYPE_BINARY || pCtx->outputType == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pCtx->aOutputBuf, pCtx->outputType);
} else {
setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes);
}
} else if (pInfoDetail->type == TSDB_FILL_SET_VALUE) { } else if (pInfoDetail->type == TSDB_FILL_SET_VALUE) {
tVariantDump(&pCtx->param[1], pCtx->aOutputBuf, pCtx->inputType); tVariantDump(&pCtx->param[1], pCtx->aOutputBuf, pCtx->inputType);
} else if (pInfoDetail->type == TSDB_FILL_PREV) { } else if (pInfoDetail->type == TSDB_FILL_PREV) {
...@@ -3925,7 +3937,11 @@ static void interp_function(SQLFunctionCtx *pCtx) { ...@@ -3925,7 +3937,11 @@ static void interp_function(SQLFunctionCtx *pCtx) {
} }
} else { } else {
setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); if (srcType == TSDB_DATA_TYPE_BINARY || srcType == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(pCtx->aOutputBuf, pCtx->inputBytes);
} else {
setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes);
}
} }
} }
} }
......
...@@ -384,13 +384,10 @@ int tscProcessLocalCmd(SSqlObj *pSql) { ...@@ -384,13 +384,10 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
// keep the code in local variable in order to avoid invalid read in case of async query // keep the code in local variable in order to avoid invalid read in case of async query
int32_t code = pSql->res.code; int32_t code = pSql->res.code;
if (code == TSDB_CODE_SUCCESS) {
if (pSql->fp != NULL) { // callback function (*pSql->fp)(pSql->param, pSql, 0);
if (code == 0) { } else {
(*pSql->fp)(pSql->param, pSql, 0); tscQueueAsyncRes(pSql);
} else {
tscQueueAsyncRes(pSql);
}
} }
return code; return code;
......
...@@ -42,35 +42,42 @@ enum { ...@@ -42,35 +42,42 @@ enum {
static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows); static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows);
static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) { static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
// int32_t numType = isValidNumber(pToken); if (pToken->n == 0) {
// if (TK_ILLEGAL == numType) { return TK_ILLEGAL;
// return numType; }
// }
int32_t radix = 10; int32_t radix = 10;
if (pToken->type == TK_HEX) {
radix = 16; int32_t radixList[3] = {16, 8, 2};
} else if (pToken->type == TK_OCT) { if (pToken->type == TK_HEX || pToken->type == TK_OCT || pToken->type == TK_BIN) {
radix = 8; radix = radixList[pToken->type - TK_HEX];
} else if (pToken->type == TK_BIN) {
radix = 2;
} }
errno = 0; errno = 0;
*value = strtoll(pToken->z, endPtr, radix); *value = strtoll(pToken->z, endPtr, radix);
// not a valid integer number, return error
if ((pToken->type == TK_STRING || pToken->type == TK_ID) && ((*endPtr - pToken->z) != pToken->n)) {
return TK_ILLEGAL;
}
return pToken->type; return pToken->type;
} }
static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) { static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) {
// int32_t numType = isValidNumber(pToken); if (pToken->n == 0) {
// if (TK_ILLEGAL == numType) { return TK_ILLEGAL;
// return numType; }
// }
errno = 0; errno = 0;
*value = strtod(pToken->z, endPtr); *value = strtod(pToken->z, endPtr);
return pToken->type;
// not a valid integer number, return error
if ((pToken->type == TK_STRING || pToken->type == TK_ID) && ((*endPtr - pToken->z) != pToken->n)) {
return TK_ILLEGAL;
} else {
return pToken->type;
}
} }
int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) { int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) {
...@@ -305,8 +312,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, ...@@ -305,8 +312,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
// binary data cannot be null-terminated char string, otherwise the last char of the string is lost // binary data cannot be null-terminated char string, otherwise the last char of the string is lost
if (pToken->type == TK_NULL) { if (pToken->type == TK_NULL) {
varDataSetLen(payload, sizeof(int8_t)); setVardataNull(payload, TSDB_DATA_TYPE_BINARY);
*(uint8_t*) varDataVal(payload) = TSDB_DATA_BINARY_NULL;
} else { // too long values will return invalid sql, not be truncated automatically } else { // too long values will return invalid sql, not be truncated automatically
if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { //todo refactor if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { //todo refactor
return tscInvalidSQLErrMsg(msg, "string data overflow", pToken->z); return tscInvalidSQLErrMsg(msg, "string data overflow", pToken->z);
...@@ -319,8 +325,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, ...@@ -319,8 +325,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
if (pToken->type == TK_NULL) { if (pToken->type == TK_NULL) {
varDataSetLen(payload, sizeof(int32_t)); setVardataNull(payload, TSDB_DATA_TYPE_NCHAR);
*(uint32_t*) varDataVal(payload) = TSDB_DATA_NCHAR_NULL;
} else { } else {
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
size_t output = 0; size_t output = 0;
...@@ -422,9 +427,9 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ ...@@ -422,9 +427,9 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[
return -1; return -1;
} }
if (((sToken.type != TK_NOW) && (sToken.type != TK_INTEGER) && (sToken.type != TK_STRING) && int16_t type = sToken.type;
(sToken.type != TK_FLOAT) && (sToken.type != TK_BOOL) && (sToken.type != TK_NULL)) || if ((type != TK_NOW && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL &&
(sToken.n == 0) || (sToken.type == TK_RP)) { type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) || (sToken.n == 0) || (type == TK_RP)) {
tscInvalidSQLErrMsg(error, "invalid data or symbol", sToken.z); tscInvalidSQLErrMsg(error, "invalid data or symbol", sToken.z);
*code = TSDB_CODE_INVALID_SQL; *code = TSDB_CODE_INVALID_SQL;
return -1; return -1;
...@@ -1306,8 +1311,7 @@ int tsParseInsertSql(SSqlObj *pSql) { ...@@ -1306,8 +1311,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
SQueryInfo *pQueryInfo = NULL; SQueryInfo *pQueryInfo = NULL;
tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex, &pQueryInfo); tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex, &pQueryInfo);
uint16_t type = (sToken.type == TK_INSERT)? TSDB_QUERY_TYPE_INSERT:TSDB_QUERY_TYPE_IMPORT; TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT);
TSDB_QUERY_SET_TYPE(pQueryInfo->type, type);
sToken = tStrGetToken(pSql->sqlstr, &index, false, 0, NULL); sToken = tStrGetToken(pSql->sqlstr, &index, false, 0, NULL);
if (sToken.type != TK_INTO) { if (sToken.type != TK_INTO) {
......
...@@ -3290,14 +3290,15 @@ static int32_t setExprToCond(tSQLExpr** parent, tSQLExpr* pExpr, const char* msg ...@@ -3290,14 +3290,15 @@ static int32_t setExprToCond(tSQLExpr** parent, tSQLExpr* pExpr, const char* msg
static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, SCondExpr* pCondExpr, int32_t* type, static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, SCondExpr* pCondExpr, int32_t* type,
int32_t parentOptr) { int32_t parentOptr) {
const char* msg1 = "meter query cannot use tags filter"; const char* msg1 = "table query cannot use tags filter";
const char* msg2 = "illegal column name"; const char* msg2 = "illegal column name";
const char* msg3 = "only one query time range allowed"; const char* msg3 = "only one query time range allowed";
const char* msg4 = "only one join condition allowed"; const char* msg4 = "only one join condition allowed";
const char* msg5 = "not support ordinary column join"; const char* msg5 = "not support ordinary column join";
const char* msg6 = "only one query condition on tbname allowed"; const char* msg6 = "only one query condition on tbname allowed";
const char* msg7 = "only in/like allowed in filter table name"; const char* msg7 = "only in/like allowed in filter table name";
const char* msg8 = "wildcard string should be less than 20 characters";
tSQLExpr* pLeft = (*pExpr)->pLeft; tSQLExpr* pLeft = (*pExpr)->pLeft;
tSQLExpr* pRight = (*pExpr)->pRight; tSQLExpr* pRight = (*pExpr)->pRight;
...@@ -3344,7 +3345,7 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S ...@@ -3344,7 +3345,7 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
// check for like expression // check for like expression
if ((*pExpr)->nSQLOptr == TK_LIKE) { if ((*pExpr)->nSQLOptr == TK_LIKE) {
if (pRight->val.nLen > TSDB_PATTERN_STRING_MAX_LEN) { if (pRight->val.nLen > TSDB_PATTERN_STRING_MAX_LEN) {
return TSDB_CODE_INVALID_SQL; return invalidSqlErrMsg(pQueryInfo->msg, msg8);
} }
SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta);
...@@ -3360,6 +3361,10 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S ...@@ -3360,6 +3361,10 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S
if (!validTableNameOptr(*pExpr)) { if (!validTableNameOptr(*pExpr)) {
return invalidSqlErrMsg(pQueryInfo->msg, msg7); return invalidSqlErrMsg(pQueryInfo->msg, msg7);
} }
if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
return invalidSqlErrMsg(pQueryInfo->msg, msg1);
}
if (pCondExpr->pTableCond == NULL) { if (pCondExpr->pTableCond == NULL) {
pCondExpr->pTableCond = *pExpr; pCondExpr->pTableCond = *pExpr;
...@@ -3808,9 +3813,7 @@ int32_t parseWhereClause(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, SSqlObj* pSql ...@@ -3808,9 +3813,7 @@ int32_t parseWhereClause(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, SSqlObj* pSql
const char* msg2 = "invalid filter expression"; const char* msg2 = "invalid filter expression";
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
pQueryInfo->window = TSWINDOW_INITIALIZER;
pQueryInfo->window.skey = 0;
pQueryInfo->window.ekey = INT64_MAX;
// tags query condition may be larger than 512bytes, therefore, we need to prepare enough large space // tags query condition may be larger than 512bytes, therefore, we need to prepare enough large space
SStringBuilder sb; memset(&sb, 0, sizeof(sb)); SStringBuilder sb; memset(&sb, 0, sizeof(sb));
...@@ -4012,9 +4015,9 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) { ...@@ -4012,9 +4015,9 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
size_t size = tscSqlExprNumOfExprs(pQueryInfo); size_t size = tscSqlExprNumOfExprs(pQueryInfo);
if (pQueryInfo->defaultVal == NULL) { if (pQueryInfo->fillVal == NULL) {
pQueryInfo->defaultVal = calloc(size, sizeof(int64_t)); pQueryInfo->fillVal = calloc(size, sizeof(int64_t));
if (pQueryInfo->defaultVal == NULL) { if (pQueryInfo->fillVal == NULL) {
return TSDB_CODE_CLI_OUT_OF_MEMORY; return TSDB_CODE_CLI_OUT_OF_MEMORY;
} }
} }
...@@ -4025,7 +4028,11 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) { ...@@ -4025,7 +4028,11 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
pQueryInfo->fillType = TSDB_FILL_NULL; pQueryInfo->fillType = TSDB_FILL_NULL;
for (int32_t i = START_INTERPO_COL_IDX; i < size; ++i) { for (int32_t i = START_INTERPO_COL_IDX; i < size; ++i) {
TAOS_FIELD* pFields = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); TAOS_FIELD* pFields = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
setNull((char*)&pQueryInfo->defaultVal[i], pFields->type, pFields->bytes); if (pFields->type == TSDB_DATA_TYPE_BINARY || pFields->type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull((char*) &pQueryInfo->fillVal[i], pFields->type);
} else {
setNull((char*)&pQueryInfo->fillVal[i], pFields->type, pFields->bytes);
};
} }
} else if (strncasecmp(pItem->pVar.pz, "prev", 4) == 0 && pItem->pVar.nLen == 4) { } else if (strncasecmp(pItem->pVar.pz, "prev", 4) == 0 && pItem->pVar.nLen == 4) {
pQueryInfo->fillType = TSDB_FILL_PREV; pQueryInfo->fillType = TSDB_FILL_PREV;
...@@ -4058,11 +4065,11 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) { ...@@ -4058,11 +4065,11 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
TAOS_FIELD* pFields = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); TAOS_FIELD* pFields = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
if (pFields->type == TSDB_DATA_TYPE_BINARY || pFields->type == TSDB_DATA_TYPE_NCHAR) { if (pFields->type == TSDB_DATA_TYPE_BINARY || pFields->type == TSDB_DATA_TYPE_NCHAR) {
setNull((char*)(&pQueryInfo->defaultVal[i]), pFields->type, pFields->bytes); setVardataNull((char*) &pQueryInfo->fillVal[i], pFields->type);
continue; continue;
} }
int32_t ret = tVariantDump(&pFillToken->a[j].pVar, (char*)&pQueryInfo->defaultVal[i], pFields->type); int32_t ret = tVariantDump(&pFillToken->a[j].pVar, (char*)&pQueryInfo->fillVal[i], pFields->type);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
return invalidSqlErrMsg(pQueryInfo->msg, msg); return invalidSqlErrMsg(pQueryInfo->msg, msg);
} }
...@@ -4076,9 +4083,9 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) { ...@@ -4076,9 +4083,9 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) {
TAOS_FIELD* pFields = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); TAOS_FIELD* pFields = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
if (pFields->type == TSDB_DATA_TYPE_BINARY || pFields->type == TSDB_DATA_TYPE_NCHAR) { if (pFields->type == TSDB_DATA_TYPE_BINARY || pFields->type == TSDB_DATA_TYPE_NCHAR) {
setNull((char*)(&pQueryInfo->defaultVal[i]), pFields->type, pFields->bytes); setVardataNull((char*) &pQueryInfo->fillVal[i], pFields->type);
} else { } else {
tVariantDump(&lastItem->pVar, (char*)&pQueryInfo->defaultVal[i], pFields->type); tVariantDump(&lastItem->pVar, (char*)&pQueryInfo->fillVal[i], pFields->type);
} }
} }
} }
...@@ -5334,13 +5341,6 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) { ...@@ -5334,13 +5341,6 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
} }
} }
SColumnIndex ind = {0};
SSqlExpr* pExpr1 = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TAG_DUMMY, &ind, TSDB_DATA_TYPE_INT,
tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, false);
const char* name = (pExprList->a[0].aliasName != NULL)? pExprList->a[0].aliasName:functionsInfo[index].name;
strncpy(pExpr1->aliasName, name, tListLen(pExpr1->aliasName));
switch (index) { switch (index) {
case 0: case 0:
pQueryInfo->command = TSDB_SQL_CURRENT_DB; pQueryInfo->command = TSDB_SQL_CURRENT_DB;
...@@ -5359,6 +5359,13 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) { ...@@ -5359,6 +5359,13 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
default: { return invalidSqlErrMsg(pQueryInfo->msg, msg3); } default: { return invalidSqlErrMsg(pQueryInfo->msg, msg3); }
} }
SColumnIndex ind = {0};
SSqlExpr* pExpr1 = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TAG_DUMMY, &ind, TSDB_DATA_TYPE_INT,
tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, tDataTypeDesc[TSDB_DATA_TYPE_INT].nSize, false);
const char* name = (pExprList->a[0].aliasName != NULL)? pExprList->a[0].aliasName:functionsInfo[index].name;
strncpy(pExpr1->aliasName, name, tListLen(pExpr1->aliasName));
} }
// can only perform the parameters based on the macro definitation // can only perform the parameters based on the macro definitation
...@@ -5606,7 +5613,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { ...@@ -5606,7 +5613,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
const char* msg3 = "fill only available for interval query"; const char* msg3 = "fill only available for interval query";
const char* msg4 = "fill option not supported in stream computing"; const char* msg4 = "fill option not supported in stream computing";
const char* msg5 = "sql too long"; // todo ADD support const char* msg5 = "sql too long"; // todo ADD support
const char* msg6 = "from missing in subclause";
SSqlCmd* pCmd = &pSql->cmd; SSqlCmd* pCmd = &pSql->cmd;
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
assert(pQueryInfo->numOfTables == 1); assert(pQueryInfo->numOfTables == 1);
...@@ -5621,10 +5629,13 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { ...@@ -5621,10 +5629,13 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
if (tscValidateName(pzTableName) != TSDB_CODE_SUCCESS) { if (tscValidateName(pzTableName) != TSDB_CODE_SUCCESS) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
tVariantList* pSrcMeterName = pInfo->pCreateTableInfo->pSelect->from; tVariantList* pSrcMeterName = pInfo->pCreateTableInfo->pSelect->from;
tVariant* pVar = &pSrcMeterName->a[0].pVar; if (pSrcMeterName == NULL || pSrcMeterName->nExpr == 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
tVariant* pVar = &pSrcMeterName->a[0].pVar;
SSQLToken srcToken = {.z = pVar->pz, .n = pVar->nLen, .type = TK_STRING}; SSQLToken srcToken = {.z = pVar->pz, .n = pVar->nLen, .type = TK_STRING};
if (tscValidateName(&srcToken) != TSDB_CODE_SUCCESS) { if (tscValidateName(&srcToken) != TSDB_CODE_SUCCESS) {
return invalidSqlErrMsg(pQueryInfo->msg, msg1); return invalidSqlErrMsg(pQueryInfo->msg, msg1);
......
...@@ -145,7 +145,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) { ...@@ -145,7 +145,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) {
pFillCol[i].flag = pExpr->colInfo.flag; pFillCol[i].flag = pExpr->colInfo.flag;
pFillCol[i].col.offset = offset; pFillCol[i].col.offset = offset;
pFillCol[i].functionId = pExpr->functionId; pFillCol[i].functionId = pExpr->functionId;
pFillCol[i].defaultVal.i = pQueryInfo->defaultVal[i]; pFillCol[i].fillVal.i = pQueryInfo->fillVal[i];
offset += pExpr->resBytes; offset += pExpr->resBytes;
} }
...@@ -946,8 +946,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo ...@@ -946,8 +946,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
} }
while (1) { while (1) {
int64_t newRows = -1; int64_t newRows = taosGenerateDataBlock(pFillInfo, pResPages, pLocalReducer->resColModel->capacity);
taosGenerateDataBlock(pFillInfo, pResPages, &newRows, pLocalReducer->resColModel->capacity);
if (pQueryInfo->limit.offset < newRows) { if (pQueryInfo->limit.offset < newRows) {
newRows -= pQueryInfo->limit.offset; newRows -= pQueryInfo->limit.offset;
......
...@@ -781,8 +781,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -781,8 +781,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if (pQueryInfo->fillType != TSDB_FILL_NONE) { if (pQueryInfo->fillType != TSDB_FILL_NONE) {
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
*((int64_t *)pMsg) = htobe64(pQueryInfo->defaultVal[i]); *((int64_t *)pMsg) = htobe64(pQueryInfo->fillVal[i]);
pMsg += sizeof(pQueryInfo->defaultVal[0]); pMsg += sizeof(pQueryInfo->fillVal[0]);
} }
} }
......
...@@ -223,7 +223,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf ...@@ -223,7 +223,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
int16_t offset = tscFieldInfoGetOffset(pQueryInfo, i); int16_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
assignVal(pSql->res.data + offset, (char *)(&pQueryInfo->defaultVal[i]), pField->bytes, pField->type); assignVal(pSql->res.data + offset, (char *)(&pQueryInfo->fillVal[i]), pField->bytes, pField->type);
row[i] = pSql->res.data + offset; row[i] = pSql->res.data + offset;
} }
......
...@@ -61,7 +61,7 @@ TSKEY tscGetSubscriptionProgress(void* sub, int64_t uid, TSKEY dflt) { ...@@ -61,7 +61,7 @@ TSKEY tscGetSubscriptionProgress(void* sub, int64_t uid, TSKEY dflt) {
SSub* pSub = (SSub*)sub; SSub* pSub = (SSub*)sub;
SSubscriptionProgress target = {.uid = uid, .key = 0}; SSubscriptionProgress target = {.uid = uid, .key = 0};
SSubscriptionProgress* p = taosArraySearch(pSub->progress, tscCompareSubscriptionProgress, &target); SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
if (p == NULL) { if (p == NULL) {
return dflt; return dflt;
} }
...@@ -74,7 +74,7 @@ void tscUpdateSubscriptionProgress(void* sub, int64_t uid, TSKEY ts) { ...@@ -74,7 +74,7 @@ void tscUpdateSubscriptionProgress(void* sub, int64_t uid, TSKEY ts) {
SSub* pSub = (SSub*)sub; SSub* pSub = (SSub*)sub;
SSubscriptionProgress target = {.uid = uid, .key = ts}; SSubscriptionProgress target = {.uid = uid, .key = ts};
SSubscriptionProgress* p = taosArraySearch(pSub->progress, tscCompareSubscriptionProgress, &target); SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
if (p != NULL) { if (p != NULL) {
p->key = ts; p->key = ts;
} }
...@@ -211,7 +211,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) { ...@@ -211,7 +211,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) { if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) {
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta; STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
SSubscriptionProgress target = {.uid = pTableMeta->uid, .key = 0}; SSubscriptionProgress target = {.uid = pTableMeta->uid, .key = 0};
SSubscriptionProgress* p = taosArraySearch(pSub->progress, tscCompareSubscriptionProgress, &target); SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
if (p == NULL) { if (p == NULL) {
taosArrayClear(pSub->progress); taosArrayClear(pSub->progress);
taosArrayPush(pSub->progress, &target); taosArrayPush(pSub->progress, &target);
......
...@@ -281,7 +281,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) { ...@@ -281,7 +281,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
} }
pQueryInfo->fillType = TSDB_FILL_NONE; pQueryInfo->fillType = TSDB_FILL_NONE;
tfree(pQueryInfo->defaultVal); tfree(pQueryInfo->fillVal);
} }
int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) { int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
...@@ -1616,7 +1616,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) { ...@@ -1616,7 +1616,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
pQueryInfo->tsBuf = tsBufDestory(pQueryInfo->tsBuf); pQueryInfo->tsBuf = tsBufDestory(pQueryInfo->tsBuf);
tfree(pQueryInfo->defaultVal); tfree(pQueryInfo->fillVal);
} }
void tscClearSubqueryInfo(SSqlCmd* pCmd) { void tscClearSubqueryInfo(SSqlCmd* pCmd) {
...@@ -1768,7 +1768,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void ...@@ -1768,7 +1768,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNewQueryInfo->order = pQueryInfo->order; pNewQueryInfo->order = pQueryInfo->order;
pNewQueryInfo->clauseLimit = pQueryInfo->clauseLimit; pNewQueryInfo->clauseLimit = pQueryInfo->clauseLimit;
pNewQueryInfo->pTableMetaInfo = NULL; pNewQueryInfo->pTableMetaInfo = NULL;
pNewQueryInfo->defaultVal = NULL; pNewQueryInfo->fillVal = NULL;
pNewQueryInfo->numOfTables = 0; pNewQueryInfo->numOfTables = 0;
pNewQueryInfo->tsBuf = NULL; pNewQueryInfo->tsBuf = NULL;
...@@ -1780,8 +1780,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void ...@@ -1780,8 +1780,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
tscTagCondCopy(&pNewQueryInfo->tagCond, &pQueryInfo->tagCond); tscTagCondCopy(&pNewQueryInfo->tagCond, &pQueryInfo->tagCond);
if (pQueryInfo->fillType != TSDB_FILL_NONE) { if (pQueryInfo->fillType != TSDB_FILL_NONE) {
pNewQueryInfo->defaultVal = malloc(pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t)); pNewQueryInfo->fillVal = malloc(pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t));
memcpy(pNewQueryInfo->defaultVal, pQueryInfo->defaultVal, pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t)); memcpy(pNewQueryInfo->fillVal, pQueryInfo->fillVal, pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t));
} }
if (tscAllocPayload(pnCmd, TSDB_DEFAULT_PAYLOAD_SIZE) != TSDB_CODE_SUCCESS) { if (tscAllocPayload(pnCmd, TSDB_DEFAULT_PAYLOAD_SIZE) != TSDB_CODE_SUCCESS) {
......
...@@ -154,8 +154,8 @@ typedef struct SDataCol { ...@@ -154,8 +154,8 @@ typedef struct SDataCol {
static FORCE_INLINE void dataColReset(SDataCol *pDataCol) { pDataCol->len = 0; } static FORCE_INLINE void dataColReset(SDataCol *pDataCol) { pDataCol->len = 0; }
void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints); void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints);
void dataColAppendVal(SDataCol *pCol, void *value, int numOfPoints, int maxPoints); void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints);
void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfPoints); void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfRows);
void dataColSetOffset(SDataCol *pCol, int nEle); void dataColSetOffset(SDataCol *pCol, int nEle);
bool isNEleNull(SDataCol *pCol, int nEle); bool isNEleNull(SDataCol *pCol, int nEle);
...@@ -195,7 +195,7 @@ typedef struct { ...@@ -195,7 +195,7 @@ typedef struct {
int maxPoints; // max number of points int maxPoints; // max number of points
int bufSize; int bufSize;
int numOfPoints; int numOfRows;
int numOfCols; // Total number of cols int numOfCols; // Total number of cols
int sversion; // TODO: set sversion int sversion; // TODO: set sversion
void * buf; void * buf;
...@@ -205,7 +205,7 @@ typedef struct { ...@@ -205,7 +205,7 @@ typedef struct {
#define keyCol(pCols) (&((pCols)->cols[0])) // Key column #define keyCol(pCols) (&((pCols)->cols[0])) // Key column
#define dataColsKeyAt(pCols, idx) ((TSKEY *)(keyCol(pCols)->pData))[(idx)] #define dataColsKeyAt(pCols, idx) ((TSKEY *)(keyCol(pCols)->pData))[(idx)]
#define dataColsKeyFirst(pCols) dataColsKeyAt(pCols, 0) #define dataColsKeyFirst(pCols) dataColsKeyAt(pCols, 0)
#define dataColsKeyLast(pCols) ((pCols->numOfPoints == 0) ? 0 : dataColsKeyAt(pCols, (pCols)->numOfPoints - 1)) #define dataColsKeyLast(pCols) ((pCols->numOfRows == 0) ? 0 : dataColsKeyAt(pCols, (pCols)->numOfRows - 1))
SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows); SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows);
void tdResetDataCols(SDataCols *pCols); void tdResetDataCols(SDataCols *pCols);
......
...@@ -187,29 +187,29 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints) ...@@ -187,29 +187,29 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints)
} }
void dataColAppendVal(SDataCol *pCol, void *value, int numOfPoints, int maxPoints) { void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints) {
ASSERT(pCol != NULL && value != NULL); ASSERT(pCol != NULL && value != NULL);
switch (pCol->type) { switch (pCol->type) {
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
// set offset // set offset
pCol->dataOff[numOfPoints] = pCol->len; pCol->dataOff[numOfRows] = pCol->len;
// Copy data // Copy data
memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, varDataTLen(value)); memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, varDataTLen(value));
// Update the length // Update the length
pCol->len += varDataTLen(value); pCol->len += varDataTLen(value);
break; break;
default: default:
ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfPoints); ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfRows);
memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, pCol->bytes); memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, pCol->bytes);
pCol->len += pCol->bytes; pCol->len += pCol->bytes;
break; break;
} }
} }
void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfPoints) { void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfRows) {
int pointsLeft = numOfPoints - pointsToPop; int pointsLeft = numOfRows - pointsToPop;
ASSERT(pointsLeft > 0); ASSERT(pointsLeft > 0);
...@@ -221,7 +221,7 @@ void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfPoints) { ...@@ -221,7 +221,7 @@ void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfPoints) {
memmove(pCol->pData, POINTER_SHIFT(pCol->pData, toffset), pCol->len); memmove(pCol->pData, POINTER_SHIFT(pCol->pData, toffset), pCol->len);
dataColSetOffset(pCol, pointsLeft); dataColSetOffset(pCol, pointsLeft);
} else { } else {
ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfPoints); ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfRows);
pCol->len = TYPE_BYTES[pCol->type] * pointsLeft; pCol->len = TYPE_BYTES[pCol->type] * pointsLeft;
memmove(pCol->pData, POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * pointsToPop), pCol->len); memmove(pCol->pData, POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * pointsToPop), pCol->len);
} }
...@@ -322,7 +322,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) { ...@@ -322,7 +322,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
pRet->numOfCols = pDataCols->numOfCols; pRet->numOfCols = pDataCols->numOfCols;
pRet->sversion = pDataCols->sversion; pRet->sversion = pDataCols->sversion;
if (keepData) pRet->numOfPoints = pDataCols->numOfPoints; if (keepData) pRet->numOfRows = pDataCols->numOfRows;
for (int i = 0; i < pDataCols->numOfCols; i++) { for (int i = 0; i < pDataCols->numOfCols; i++) {
pRet->cols[i].type = pDataCols->cols[i].type; pRet->cols[i].type = pDataCols->cols[i].type;
...@@ -352,7 +352,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) { ...@@ -352,7 +352,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
} }
void tdResetDataCols(SDataCols *pCols) { void tdResetDataCols(SDataCols *pCols) {
pCols->numOfPoints = 0; pCols->numOfRows = 0;
for (int i = 0; i < pCols->maxCols; i++) { for (int i = 0; i < pCols->maxCols; i++) {
dataColReset(pCols->cols + i); dataColReset(pCols->cols + i);
} }
...@@ -365,14 +365,14 @@ void tdAppendDataRowToDataCol(SDataRow row, SDataCols *pCols) { ...@@ -365,14 +365,14 @@ void tdAppendDataRowToDataCol(SDataRow row, SDataCols *pCols) {
SDataCol *pCol = pCols->cols + i; SDataCol *pCol = pCols->cols + i;
void * value = tdGetRowDataOfCol(row, pCol->type, pCol->offset); void * value = tdGetRowDataOfCol(row, pCol->type, pCol->offset);
dataColAppendVal(pCol, value, pCols->numOfPoints, pCols->maxPoints); dataColAppendVal(pCol, value, pCols->numOfRows, pCols->maxPoints);
} }
pCols->numOfPoints++; pCols->numOfRows++;
} }
// Pop pointsToPop points from the SDataCols // Pop pointsToPop points from the SDataCols
void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop) { void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop) {
int pointsLeft = pCols->numOfPoints - pointsToPop; int pointsLeft = pCols->numOfRows - pointsToPop;
if (pointsLeft <= 0) { if (pointsLeft <= 0) {
tdResetDataCols(pCols); tdResetDataCols(pCols);
return; return;
...@@ -380,14 +380,14 @@ void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop) { ...@@ -380,14 +380,14 @@ void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop) {
for (int iCol = 0; iCol < pCols->numOfCols; iCol++) { for (int iCol = 0; iCol < pCols->numOfCols; iCol++) {
SDataCol *pCol = pCols->cols + iCol; SDataCol *pCol = pCols->cols + iCol;
dataColPopPoints(pCol, pointsToPop, pCols->numOfPoints); dataColPopPoints(pCol, pointsToPop, pCols->numOfRows);
} }
pCols->numOfPoints = pointsLeft; pCols->numOfRows = pointsLeft;
} }
int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) { int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfPoints); ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfRows);
ASSERT(target->numOfPoints + rowsToMerge <= target->maxPoints); ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints);
ASSERT(target->numOfCols == source->numOfCols); ASSERT(target->numOfCols == source->numOfCols);
SDataCols *pTarget = NULL; SDataCols *pTarget = NULL;
...@@ -395,10 +395,10 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) { ...@@ -395,10 +395,10 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
if (dataColsKeyLast(target) < dataColsKeyFirst(source)) { // No overlap if (dataColsKeyLast(target) < dataColsKeyFirst(source)) { // No overlap
for (int i = 0; i < rowsToMerge; i++) { for (int i = 0; i < rowsToMerge; i++) {
for (int j = 0; j < source->numOfCols; j++) { for (int j = 0; j < source->numOfCols; j++) {
dataColAppendVal(target->cols + j, tdGetColDataOfRow(source->cols + j, i), target->numOfPoints, dataColAppendVal(target->cols + j, tdGetColDataOfRow(source->cols + j, i), target->numOfRows,
target->maxPoints); target->maxPoints);
} }
target->numOfPoints++; target->numOfRows++;
} }
} else { } else {
pTarget = tdDupDataCols(target, true); pTarget = tdDupDataCols(target, true);
...@@ -406,7 +406,7 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) { ...@@ -406,7 +406,7 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
int iter1 = 0; int iter1 = 0;
int iter2 = 0; int iter2 = 0;
tdMergeTwoDataCols(target, pTarget, &iter1, source, &iter2, pTarget->numOfPoints + rowsToMerge); tdMergeTwoDataCols(target, pTarget, &iter1, source, &iter2, pTarget->numOfRows + rowsToMerge);
} }
tdFreeDataCols(pTarget); tdFreeDataCols(pTarget);
...@@ -421,30 +421,30 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SDataCol ...@@ -421,30 +421,30 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SDataCol
// TODO: add resolve duplicate key here // TODO: add resolve duplicate key here
tdResetDataCols(target); tdResetDataCols(target);
while (target->numOfPoints < tRows) { while (target->numOfRows < tRows) {
if (*iter1 >= src1->numOfPoints && *iter2 >= src2->numOfPoints) break; if (*iter1 >= src1->numOfRows && *iter2 >= src2->numOfRows) break;
TSKEY key1 = (*iter1 >= src1->numOfPoints) ? INT64_MAX : ((TSKEY *)(src1->cols[0].pData))[*iter1]; TSKEY key1 = (*iter1 >= src1->numOfRows) ? INT64_MAX : ((TSKEY *)(src1->cols[0].pData))[*iter1];
TSKEY key2 = (*iter2 >= src2->numOfPoints) ? INT64_MAX : ((TSKEY *)(src2->cols[0].pData))[*iter2]; TSKEY key2 = (*iter2 >= src2->numOfRows) ? INT64_MAX : ((TSKEY *)(src2->cols[0].pData))[*iter2];
if (key1 <= key2) { if (key1 <= key2) {
for (int i = 0; i < src1->numOfCols; i++) { for (int i = 0; i < src1->numOfCols; i++) {
ASSERT(target->cols[i].type == src1->cols[i].type); ASSERT(target->cols[i].type == src1->cols[i].type);
dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfPoints, dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfRows,
target->maxPoints); target->maxPoints);
} }
target->numOfPoints++; target->numOfRows++;
(*iter1)++; (*iter1)++;
if (key1 == key2) (*iter2)++; if (key1 == key2) (*iter2)++;
} else { } else {
for (int i = 0; i < src2->numOfCols; i++) { for (int i = 0; i < src2->numOfCols; i++) {
ASSERT(target->cols[i].type == src2->cols[i].type); ASSERT(target->cols[i].type == src2->cols[i].type);
dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfPoints, dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfRows,
target->maxPoints); target->maxPoints);
} }
target->numOfPoints++; target->numOfRows++;
(*iter2)++; (*iter2)++;
} }
} }
......
...@@ -142,7 +142,7 @@ int32_t rpcDebugFlag = 135; ...@@ -142,7 +142,7 @@ int32_t rpcDebugFlag = 135;
int32_t uDebugFlag = 131; int32_t uDebugFlag = 131;
int32_t debugFlag = 131; int32_t debugFlag = 131;
int32_t sDebugFlag = 135; int32_t sDebugFlag = 135;
int32_t tsdbDebugFlag = 131; int32_t tsdbDebugFlag = 135;
// the maximum number of results for projection query on super table that are returned from // the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp // one virtual node, to order according to timestamp
...@@ -202,6 +202,8 @@ char tsTimezone[64] = {0}; ...@@ -202,6 +202,8 @@ char tsTimezone[64] = {0};
char tsLocale[TSDB_LOCALE_LEN] = {0}; char tsLocale[TSDB_LOCALE_LEN] = {0};
char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string
int32_t tsMaxBinaryDisplayWidth = 30;
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT; static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
void taosSetAllDebugFlag() { void taosSetAllDebugFlag() {
...@@ -1227,6 +1229,16 @@ static void doInitGlobalConfig() { ...@@ -1227,6 +1229,16 @@ static void doInitGlobalConfig() {
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "maxBinaryDisplayWidth";
cfg.ptr = &tsMaxBinaryDisplayWidth;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 1;
cfg.maxValue = 0x7fffffff;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
} }
void taosInitGlobalCfg() { void taosInitGlobalCfg() {
......
...@@ -42,9 +42,6 @@ static void getStatics_i8(const TSKEY *primaryKey, const void *pData, int32_t nu ...@@ -42,9 +42,6 @@ static void getStatics_i8(const TSKEY *primaryKey, const void *pData, int32_t nu
ASSERT(numOfRow <= INT16_MAX); ASSERT(numOfRow <= INT16_MAX);
// int64_t lastKey = 0;
// int8_t lastVal = TSDB_DATA_TINYINT_NULL;
for (int32_t i = 0; i < numOfRow; ++i) { for (int32_t i = 0; i < numOfRow; ++i) {
if (isNull((char *)&data[i], TSDB_DATA_TYPE_TINYINT)) { if (isNull((char *)&data[i], TSDB_DATA_TYPE_TINYINT)) {
(*numOfNull) += 1; (*numOfNull) += 1;
...@@ -213,15 +210,6 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num ...@@ -213,15 +210,6 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num
fmax = fv; fmax = fv;
*maxIndex = i; *maxIndex = i;
} }
// if (isNull(&lastVal, TSDB_DATA_TYPE_FLOAT)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
} }
double csum = 0; double csum = 0;
...@@ -232,9 +220,9 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num ...@@ -232,9 +220,9 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num
SET_DOUBLE_VAL_ALIGN(max, &fmax); SET_DOUBLE_VAL_ALIGN(max, &fmax);
SET_DOUBLE_VAL_ALIGN(min, &fmin); SET_DOUBLE_VAL_ALIGN(min, &fmin);
#else #else
*sum = csum; *(double*)sum = csum;
*max = fmax; *(double*)max = fmax;
*min = fmin; *(double*)min = fmin;
#endif #endif
} }
...@@ -267,15 +255,6 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num ...@@ -267,15 +255,6 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num
dmax = dv; dmax = dv;
*maxIndex = i; *maxIndex = i;
} }
// if (isNull(&lastVal, TSDB_DATA_TYPE_DOUBLE)) {
// lastKey = primaryKey[i];
// lastVal = data[i];
// } else {
// *wsum = lastVal * (primaryKey[i] - lastKey);
// lastKey = primaryKey[i];
// lastVal = data[i];
// }
} }
double csum = 0; double csum = 0;
...@@ -285,27 +264,67 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num ...@@ -285,27 +264,67 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_
SET_DOUBLE_VAL_ALIGN(sum, &csum); SET_DOUBLE_VAL_ALIGN(sum, &csum);
SET_DOUBLE_VAL_ALIGN(max, &dmax); SET_DOUBLE_VAL_ALIGN(max, &dmax);
SET_DOUBLE_VAL_ALIGN(min, &dmin); SET_DOUBLE_VAL_ALIGN(min, &dmin);
#else #else
*sum = csum; *(double*) sum = csum;
*max = dmax; *(double*) max = dmax;
*min = dmin; *(double*) min = dmin;
#endif #endif
} }
static void getStatics_bin(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max,
int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
const char* data = pData;
ASSERT(numOfRow <= INT16_MAX);
for (int32_t i = 0; i < numOfRow; ++i) {
if (isNull((const char*) varDataVal(data), TSDB_DATA_TYPE_BINARY)) {
(*numOfNull) += 1;
}
data += varDataLen(data);
}
*sum = 0;
*max = 0;
*min = 0;
*minIndex = 0;
*maxIndex = 0;
}
static void getStatics_nchr(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max,
int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
const char* data = pData;
ASSERT(numOfRow <= INT16_MAX);
for (int32_t i = 0; i < numOfRow; ++i) {
if (isNull((const char*) varDataVal(data), TSDB_DATA_TYPE_NCHAR)) {
(*numOfNull) += 1;
}
data += varDataLen(data);
}
*sum = 0;
*max = 0;
*min = 0;
*minIndex = 0;
*maxIndex = 0;
}
tDataTypeDescriptor tDataTypeDesc[11] = { tDataTypeDescriptor tDataTypeDesc[11] = {
{TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", NULL, NULL, NULL}, {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", NULL, NULL, NULL},
{TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", tsCompressBool, tsDecompressBool, NULL}, {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", tsCompressBool, tsDecompressBool, getStatics_i8},
{TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", tsCompressTinyint, tsDecompressTinyint, getStatics_i8}, {TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", tsCompressTinyint, tsDecompressTinyint, getStatics_i8},
{TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", tsCompressSmallint, tsDecompressSmallint, getStatics_i16}, {TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", tsCompressSmallint, tsDecompressSmallint, getStatics_i16},
{TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", tsCompressInt, tsDecompressInt, getStatics_i32}, {TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", tsCompressInt, tsDecompressInt, getStatics_i32},
{TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", tsCompressBigint, tsDecompressBigint, getStatics_i64}, {TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", tsCompressBigint, tsDecompressBigint, getStatics_i64},
{TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", tsCompressFloat, tsDecompressFloat, getStatics_f}, {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", tsCompressFloat, tsDecompressFloat, getStatics_f},
{TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", tsCompressDouble, tsDecompressDouble, getStatics_d}, {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", tsCompressDouble, tsDecompressDouble, getStatics_d},
{TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", tsCompressString, tsDecompressString, NULL}, {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", tsCompressString, tsDecompressString, getStatics_bin},
{TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64}, {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64},
{TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", tsCompressString, tsDecompressString, NULL}, {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", tsCompressString, tsDecompressString, getStatics_nchr},
}; };
char tTokenTypeSwitcher[13] = { char tTokenTypeSwitcher[13] = {
...@@ -362,6 +381,18 @@ bool isNull(const char *val, int32_t type) { ...@@ -362,6 +381,18 @@ bool isNull(const char *val, int32_t type) {
}; };
} }
void setVardataNull(char* val, int32_t type) {
if (type == TSDB_DATA_TYPE_BINARY) {
varDataSetLen(val, sizeof(int8_t));
*(uint8_t*) varDataVal(val) = TSDB_DATA_BINARY_NULL;
} else if (type == TSDB_DATA_TYPE_NCHAR) {
varDataSetLen(val, sizeof(int32_t));
*(uint32_t*) varDataVal(val) = TSDB_DATA_NCHAR_NULL;
} else {
assert(0);
}
}
void setNull(char *val, int32_t type, int32_t bytes) { setNullN(val, type, bytes, 1); } void setNull(char *val, int32_t type, int32_t bytes) { setNullN(val, type, bytes, 1); }
void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) { void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) {
...@@ -464,7 +495,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { ...@@ -464,7 +495,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
break; break;
}; };
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
wcsncpy((wchar_t*)val, (wchar_t*)src, len / TSDB_NCHAR_SIZE); varDataCopy(val, src);
break; break;
}; };
default: { default: {
......
...@@ -188,7 +188,7 @@ public class TSDBDriver implements java.sql.Driver { ...@@ -188,7 +188,7 @@ public class TSDBDriver implements java.sql.Driver {
} }
public boolean acceptsURL(String url) throws SQLException { public boolean acceptsURL(String url) throws SQLException {
return true; return StringUtils.isNotBlank(url) && url.startsWith(URL_PREFIX);
} }
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
...@@ -355,4 +355,4 @@ public class TSDBDriver implements java.sql.Driver { ...@@ -355,4 +355,4 @@ public class TSDBDriver implements java.sql.Driver {
public String database(Properties props) { public String database(Properties props) {
return props.getProperty(PROPERTY_KEY_DBNAME); return props.getProperty(PROPERTY_KEY_DBNAME);
} }
} }
\ No newline at end of file
...@@ -157,6 +157,7 @@ extern tDataTypeDescriptor tDataTypeDesc[11]; ...@@ -157,6 +157,7 @@ extern tDataTypeDescriptor tDataTypeDesc[11];
bool isValidDataType(int32_t type, int32_t length); bool isValidDataType(int32_t type, int32_t length);
bool isNull(const char *val, int32_t type); bool isNull(const char *val, int32_t type);
void setVardataNull(char* val, int32_t type);
void setNull(char *val, int32_t type, int32_t bytes); void setNull(char *val, int32_t type, int32_t bytes);
void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems); void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems);
...@@ -326,8 +327,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); ...@@ -326,8 +327,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_QUERY_TYPE_TAG_FILTER_QUERY 0x400u #define TSDB_QUERY_TYPE_TAG_FILTER_QUERY 0x400u
#define TSDB_QUERY_TYPE_INSERT 0x100u // insert type #define TSDB_QUERY_TYPE_INSERT 0x100u // insert type
#define TSDB_QUERY_TYPE_IMPORT 0x200u // import data #define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x200u
#define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x800u
#define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0) #define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0)
#define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type)) #define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type))
......
...@@ -443,7 +443,7 @@ typedef struct { ...@@ -443,7 +443,7 @@ typedef struct {
int16_t numOfOutput; // final output columns numbers int16_t numOfOutput; // final output columns numbers
int16_t tagNameRelType; // relation of tag criteria and tbname criteria int16_t tagNameRelType; // relation of tag criteria and tbname criteria
int16_t fillType; // interpolate type int16_t fillType; // interpolate type
uint64_t defaultVal; // default value array list uint64_t fillVal; // default value array list
int32_t tsOffset; // offset value in current msg body, NOTE: ts list is compressed int32_t tsOffset; // offset value in current msg body, NOTE: ts list is compressed
int32_t tsLen; // total length of ts comp block int32_t tsLen; // total length of ts comp block
int32_t tsNumOfBlocks; // ts comp block numbers int32_t tsNumOfBlocks; // ts comp block numbers
......
...@@ -29,18 +29,6 @@ ...@@ -29,18 +29,6 @@
#define MAX_COMMAND_SIZE 65536 #define MAX_COMMAND_SIZE 65536
#define HISTORY_FILE ".taos_history" #define HISTORY_FILE ".taos_history"
#define BOOL_OUTPUT_LENGTH 6
#define TINYINT_OUTPUT_LENGTH 6
#define SMALLINT_OUTPUT_LENGTH 7
#define INT_OUTPUT_LENGTH 11
#define BIGINT_OUTPUT_LENGTH 21
#define FLOAT_OUTPUT_LENGTH 20
#define DOUBLE_OUTPUT_LENGTH 25
#define BINARY_OUTPUT_LENGTH 20
// dynamic config timestamp width according to maximum time precision
extern int32_t TIMESTAMP_OUTPUT_LENGTH;
typedef struct SShellHistory { typedef struct SShellHistory {
char* hist[MAX_HISTORY_SIZE]; char* hist[MAX_HISTORY_SIZE];
int hstart; int hstart;
...@@ -80,7 +68,7 @@ void get_history_path(char* history); ...@@ -80,7 +68,7 @@ void get_history_path(char* history);
void cleanup_handler(void* arg); void cleanup_handler(void* arg);
void exitShell(); void exitShell();
int shellDumpResult(TAOS* con, char* fname, int* error_no, bool printMode); int shellDumpResult(TAOS* con, char* fname, int* error_no, bool printMode);
void shellPrintNChar(char* str, int width, bool printMode); void shellPrintNChar(const char* str, int length, int width);
void shellGetGrantInfo(void *con); void shellGetGrantInfo(void *con);
int isCommentLine(char *line); int isCommentLine(char *line);
......
...@@ -352,37 +352,31 @@ void *shellLoopQuery(void *arg) { ...@@ -352,37 +352,31 @@ void *shellLoopQuery(void *arg) {
return NULL; return NULL;
} }
void shellPrintNChar(char *str, int width, bool printMode) { void shellPrintNChar(const char *str, int length, int width) {
int col_left = width; int pos = 0, cols = 0;
wchar_t wc; while (pos < length) {
while (col_left > 0) { wchar_t wc;
if (*str == '\0') break; pos += mbtowc(&wc, str + pos, MB_CUR_MAX);
char *tstr = str; if (pos > length) {
int byte_width = mbtowc(&wc, tstr, MB_CUR_MAX); break;
if (byte_width <= 0) break;
int col_width = wcwidth(wc);
if (col_width <= 0) {
str += byte_width;
continue;
} }
if (col_left < col_width) break;
printf("%lc", wc);
str += byte_width;
col_left -= col_width;
}
while (col_left > 0) { int w = wcwidth(wc);
printf(" "); if (w > 0) {
col_left--; if (width > 0 && cols + w > width) {
break;
}
printf("%lc", wc);
cols += w;
}
} }
if (!printMode) { for (; cols < width; cols++) {
printf("|"); putchar(' ');
} else {
printf("\n");
} }
} }
int get_old_terminal_mode(struct termios *tio) { int get_old_terminal_mode(struct termios *tio) {
/* Make sure stdin is a terminal. */ /* Make sure stdin is a terminal. */
if (!isatty(STDIN_FILENO)) { if (!isatty(STDIN_FILENO)) {
......
此差异已折叠。
...@@ -329,34 +329,27 @@ void *shellLoopQuery(void *arg) { ...@@ -329,34 +329,27 @@ void *shellLoopQuery(void *arg) {
return NULL; return NULL;
} }
void shellPrintNChar(char *str, int width, bool printMode) { void shellPrintNChar(const char *str, int length, int width) {
int col_left = width; int pos = 0, cols = 0;
wchar_t wc; while (pos < length) {
while (col_left > 0) { wchar_t wc;
if (*str == '\0') break; pos += mbtowc(&wc, str + pos, MB_CUR_MAX);
char *tstr = str; if (pos > length) {
int byte_width = mbtowc(&wc, tstr, MB_CUR_MAX); break;
if (byte_width <= 0) break;
int col_width = wcwidth(wc);
if (col_width <= 0) {
str += byte_width;
continue;
} }
if (col_left < col_width) break;
printf("%lc", wc);
str += byte_width;
col_left -= col_width;
}
while (col_left > 0) { int w = wcwidth(wc);
printf(" "); if (w > 0) {
col_left--; if (width > 0 && cols + w > width) {
break;
}
printf("%lc", wc);
cols += w;
}
} }
if (!printMode) { for (; cols < width; cols++) {
printf("|"); putchar(' ');
} else {
printf("\n");
} }
} }
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
TAOS* con; TAOS* con;
pthread_t pid; pthread_t pid;
int32_t TIMESTAMP_OUTPUT_LENGTH = 22;
// TODO: IMPLEMENT INTERRUPT HANDLER. // TODO: IMPLEMENT INTERRUPT HANDLER.
void interruptHandler(int signum) { void interruptHandler(int signum) {
......
...@@ -217,32 +217,32 @@ void *shellLoopQuery(void *arg) { ...@@ -217,32 +217,32 @@ void *shellLoopQuery(void *arg) {
return NULL; return NULL;
} }
void shellPrintNChar(char *str, int width, bool printMode) { void shellPrintNChar(const char *str, int length, int width) {
int col_left = width; int pos = 0, cols = 0;
wchar_t wc; while (pos < length) {
while (col_left > 0) { wchar_t wc;
if (*str == '\0') break; int bytes = mbtowc(&wc, str + pos, MB_CUR_MAX);
char *tstr = str; pos += bytes;
int byte_width = mbtowc(&wc, tstr, MB_CUR_MAX); if (pos > length) {
int col_width = byte_width; break;
if (col_left < col_width) break; }
printf("%lc", wc);
str += byte_width;
col_left -= col_width;
}
while (col_left > 0) { int w = bytes;
printf(" "); if (w > 0) {
col_left--; if (width > 0 && cols + w > width) {
break;
}
printf("%lc", wc);
cols += w;
}
} }
if (!printMode) { for (; cols < width; cols++) {
printf("|"); putchar(' ');
} else {
printf("\n");
} }
} }
void get_history_path(char *history) { sprintf(history, "%s/%s", ".", HISTORY_FILE); } void get_history_path(char *history) { sprintf(history, "%s/%s", ".", HISTORY_FILE); }
void exitShell() { exit(EXIT_SUCCESS); } void exitShell() { exit(EXIT_SUCCESS); }
...@@ -138,7 +138,7 @@ typedef struct SQuery { ...@@ -138,7 +138,7 @@ typedef struct SQuery {
SColumnInfo* colList; SColumnInfo* colList;
SColumnInfo* tagColList; SColumnInfo* tagColList;
int32_t numOfFilterCols; int32_t numOfFilterCols;
int64_t* defaultVal; int64_t* fillVal;
uint32_t status; // query status uint32_t status; // query status
SResultRec rec; SResultRec rec;
int32_t pos; int32_t pos;
......
...@@ -28,7 +28,7 @@ typedef struct { ...@@ -28,7 +28,7 @@ typedef struct {
STColumn col; // column info STColumn col; // column info
int16_t functionId; // sql function id int16_t functionId; // sql function id
int16_t flag; // column flag: TAG COLUMN|NORMAL COLUMN int16_t flag; // column flag: TAG COLUMN|NORMAL COLUMN
union {int64_t i; double d;} defaultVal; union {int64_t i; double d;} fillVal;
} SFillColInfo; } SFillColInfo;
typedef struct SFillInfo { typedef struct SFillInfo {
...@@ -75,15 +75,13 @@ void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInpu ...@@ -75,15 +75,13 @@ void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInpu
TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int64_t timeInterval, int8_t slidingTimeUnit, int8_t precision); TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int64_t timeInterval, int8_t slidingTimeUnit, int8_t precision);
int32_t taosGetNumOfResultWithFill(SFillInfo* pFillInfo, int32_t numOfRows, int64_t ekey, int32_t maxNumOfRows); int64_t taosGetNumOfResultWithFill(SFillInfo* pFillInfo, int32_t numOfRows, int64_t ekey, int32_t maxNumOfRows);
int32_t taosNumOfRemainRows(SFillInfo *pFillInfo); int32_t taosNumOfRemainRows(SFillInfo *pFillInfo);
int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numOfRows, int32_t outputRows, char** srcData);
int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point); int taosDoLinearInterpolation(int32_t type, SPoint *point1, SPoint *point2, SPoint *point);
void taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int64_t* outputRows, int32_t capacity); int64_t taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int32_t capacity);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -126,7 +126,6 @@ typedef struct SArithmeticSupport { ...@@ -126,7 +126,6 @@ typedef struct SArithmeticSupport {
typedef struct SQLPreAggVal { typedef struct SQLPreAggVal {
bool isSet; bool isSet;
int32_t size;
SDataStatis statis; SDataStatis statis;
} SQLPreAggVal; } SQLPreAggVal;
...@@ -174,7 +173,6 @@ typedef struct SQLFunctionCtx { ...@@ -174,7 +173,6 @@ typedef struct SQLFunctionCtx {
int16_t outputBytes; // size of results, determined by function and input column data type int16_t outputBytes; // size of results, determined by function and input column data type
bool hasNull; // null value exist in current block bool hasNull; // null value exist in current block
int16_t functionId; // function id int16_t functionId; // function id
int32_t blockStatus; // Indicate if data is loaded, it is first/last/internal block. Only for file blocks
void * aInputElemBuf; void * aInputElemBuf;
char * aOutputBuf; // final result output buffer, point to sdata->data char * aOutputBuf; // final result output buffer, point to sdata->data
uint8_t currentStage; // record current running step, default: 0 uint8_t currentStage; // record current running step, default: 0
......
此差异已折叠。
...@@ -773,9 +773,6 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, ...@@ -773,9 +773,6 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
// todo refactor: // todo refactor:
tstr *name = ((STableIndexElem *)pData)->pTable->name; tstr *name = ((STableIndexElem *)pData)->pTable->name;
// char* name = NULL;
// tsdbGetTableName(pQueryInfo->, pTable, &name);
// todo speed up by using hash // todo speed up by using hash
if (pQueryInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) { if (pQueryInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
if (pQueryInfo->optr == TSDB_RELATION_IN) { if (pQueryInfo->optr == TSDB_RELATION_IN) {
...@@ -1051,7 +1048,7 @@ static void* exception_malloc(size_t size) { ...@@ -1051,7 +1048,7 @@ static void* exception_malloc(size_t size) {
return p; return p;
} }
static char* exception_strdup(const char* str) { static UNUSED_FUNC char* exception_strdup(const char* str) {
char* p = strdup(str); char* p = strdup(str);
if (p == NULL) { if (p == NULL) {
THROW(TSDB_CODE_SERV_OUT_OF_MEMORY); THROW(TSDB_CODE_SERV_OUT_OF_MEMORY);
...@@ -1154,28 +1151,33 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { ...@@ -1154,28 +1151,33 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
tVariant* pVal = exception_calloc(1, sizeof(tVariant)); tVariant* pVal = exception_calloc(1, sizeof(tVariant));
right->pVal = pVal; right->pVal = pVal;
pVal->nType = TSDB_DATA_TYPE_ARRAY; pVal->nType = TSDB_DATA_TYPE_ARRAY;
pVal->arr = taosArrayInit(2, sizeof(char*)); pVal->arr = taosArrayInit(2, POINTER_BYTES);
const char* cond = tbnameCond + QUERY_COND_REL_PREFIX_IN_LEN; const char* cond = tbnameCond + QUERY_COND_REL_PREFIX_IN_LEN;
for (const char *e = cond; *e != 0; e++) { for (const char *e = cond; *e != 0; e++) {
if (*e == TS_PATH_DELIMITER[0]) { if (*e == TS_PATH_DELIMITER[0]) {
cond = e + 1; cond = e + 1;
} else if (*e == ',') { } else if (*e == ',') {
size_t len = e - cond + 1; size_t len = e - cond + VARSTR_HEADER_SIZE;
char* p = exception_malloc( len ); char* p = exception_malloc(len);
memcpy(p, cond, len); varDataSetLen(p, len - VARSTR_HEADER_SIZE);
p[len - 1] = 0; memcpy(varDataVal(p), cond, len);
cond += len; cond += len;
taosArrayPush(pVal->arr, &p); taosArrayPush(pVal->arr, &p);
} }
} }
if (*cond != 0) { if (*cond != 0) {
char* p = exception_strdup( cond ); size_t len = strlen(cond) + VARSTR_HEADER_SIZE;
taosArrayPush(pVal->arr, &p);
char* p = exception_malloc(len);
varDataSetLen(p, len - VARSTR_HEADER_SIZE);
memcpy(varDataVal(p), cond, len);
taosArrayPush(pVal->arr, &p);
} }
taosArraySortString(pVal->arr); taosArraySortString(pVal->arr, taosArrayCompareString);
} }
CLEANUP_EXECUTE_TO(anchor, false); CLEANUP_EXECUTE_TO(anchor, false);
......
...@@ -34,7 +34,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, ch ...@@ -34,7 +34,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, ch
* here we revised the start time of day according to the local time zone, * here we revised the start time of day according to the local time zone,
* but in case of DST, the start time of one day need to be dynamically decided. * but in case of DST, the start time of one day need to be dynamically decided.
* *
* TODO dynamically decide the start time of a day * TODO dynamically decide the start time of a day, move to common module
*/ */
// todo refactor to extract function that is available for Linux/Windows/Mac platform // todo refactor to extract function that is available for Linux/Windows/Mac platform
...@@ -116,10 +116,9 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) ...@@ -116,10 +116,9 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey)
return; return;
} }
pFillInfo->rowIdx = 0; pFillInfo->rowIdx = 0;
pFillInfo->endKey = endKey;
pFillInfo->numOfRows = numOfRows; pFillInfo->numOfRows = numOfRows;
pFillInfo->endKey = endKey;
} }
void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput) { void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput) {
...@@ -131,6 +130,8 @@ void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput) ...@@ -131,6 +130,8 @@ void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput)
void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInput) { void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInput) {
assert(pFillInfo->numOfRows == pInput->num); assert(pFillInfo->numOfRows == pInput->num);
int32_t t = 0;
for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) { for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SFillColInfo* pCol = &pFillInfo->pFillCol[i];
...@@ -138,7 +139,7 @@ void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInpu ...@@ -138,7 +139,7 @@ void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, tFilePage* pInpu
memcpy(pFillInfo->pData[i], s, pInput->num * pCol->col.bytes); memcpy(pFillInfo->pData[i], s, pInput->num * pCol->col.bytes);
if (pCol->flag == TSDB_COL_TAG) { // copy the tag value if (pCol->flag == TSDB_COL_TAG) { // copy the tag value
memcpy(pFillInfo->pTags[i], pFillInfo->pData[i], pCol->col.bytes); memcpy(pFillInfo->pTags[t++], pFillInfo->pData[i], pCol->col.bytes);
} }
} }
} }
...@@ -170,7 +171,7 @@ static int32_t taosGetTotalNumOfFilledRes(SFillInfo* pFillInfo, const TSKEY* tsA ...@@ -170,7 +171,7 @@ static int32_t taosGetTotalNumOfFilledRes(SFillInfo* pFillInfo, const TSKEY* tsA
} }
} }
int32_t taosGetNumOfResultWithFill(SFillInfo* pFillInfo, int32_t numOfRows, int64_t ekey, int32_t maxNumOfRows) { int64_t taosGetNumOfResultWithFill(SFillInfo* pFillInfo, int32_t numOfRows, int64_t ekey, int32_t maxNumOfRows) {
int32_t numOfRes = taosGetTotalNumOfFilledRes(pFillInfo, (int64_t*) pFillInfo->pData[0], numOfRows, int32_t numOfRes = taosGetTotalNumOfFilledRes(pFillInfo, (int64_t*) pFillInfo->pData[0], numOfRows,
pFillInfo->slidingTime, ekey); pFillInfo->slidingTime, ekey);
return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes; return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes;
...@@ -193,7 +194,7 @@ static double linearInterpolationImpl(double v1, double v2, double k1, double k2 ...@@ -193,7 +194,7 @@ static double linearInterpolationImpl(double v1, double v2, double k1, double k2
int taosDoLinearInterpolation(int32_t type, SPoint* point1, SPoint* point2, SPoint* point) { int taosDoLinearInterpolation(int32_t type, SPoint* point1, SPoint* point2, SPoint* point) {
switch (type) { switch (type) {
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
*(int32_t*)point->val = linearInterpolationImpl(*(int32_t*)point1->val, *(int32_t*)point2->val, point1->key, *(int32_t*)point->val = (int32_t) linearInterpolationImpl(*(int32_t*)point1->val, *(int32_t*)point2->val, point1->key,
point2->key, point->key); point2->key, point->key);
break; break;
} }
...@@ -209,17 +210,17 @@ int taosDoLinearInterpolation(int32_t type, SPoint* point1, SPoint* point2, SPoi ...@@ -209,17 +210,17 @@ int taosDoLinearInterpolation(int32_t type, SPoint* point1, SPoint* point2, SPoi
}; };
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
case TSDB_DATA_TYPE_BIGINT: { case TSDB_DATA_TYPE_BIGINT: {
*(int64_t*)point->val = linearInterpolationImpl(*(int64_t*)point1->val, *(int64_t*)point2->val, point1->key, *(int64_t*)point->val = (int64_t) linearInterpolationImpl(*(int64_t*)point1->val, *(int64_t*)point2->val, point1->key,
point2->key, point->key); point2->key, point->key);
break; break;
}; };
case TSDB_DATA_TYPE_SMALLINT: { case TSDB_DATA_TYPE_SMALLINT: {
*(int16_t*)point->val = linearInterpolationImpl(*(int16_t*)point1->val, *(int16_t*)point2->val, point1->key, *(int16_t*)point->val = (int16_t) linearInterpolationImpl(*(int16_t*)point1->val, *(int16_t*)point2->val, point1->key,
point2->key, point->key); point2->key, point->key);
break; break;
}; };
case TSDB_DATA_TYPE_TINYINT: { case TSDB_DATA_TYPE_TINYINT: {
*(int8_t*)point->val = *(int8_t*) point->val = (int8_t)
linearInterpolationImpl(*(int8_t*)point1->val, *(int8_t*)point2->val, point1->key, point2->key, point->key); linearInterpolationImpl(*(int8_t*)point1->val, *(int8_t*)point2->val, point1->key, point2->key, point->key);
break; break;
}; };
...@@ -243,8 +244,8 @@ static void setTagsValue(SFillInfo* pColInfo, tFilePage** data, char** pTags, in ...@@ -243,8 +244,8 @@ static void setTagsValue(SFillInfo* pColInfo, tFilePage** data, char** pTags, in
static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* num, char** srcData, static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* num, char** srcData,
int64_t ts, char** pTags, bool outOfBound) { int64_t ts, char** pTags, bool outOfBound) {
char** prevValues = &pFillInfo->prevValues; char* prevValues = pFillInfo->prevValues;
char** nextValues = &pFillInfo->nextValues; char* nextValues = pFillInfo->nextValues;
SPoint point1, point2, point; SPoint point1, point2, point;
...@@ -257,16 +258,21 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* ...@@ -257,16 +258,21 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t*
// set the other values // set the other values
if (pFillInfo->fillType == TSDB_FILL_PREV) { if (pFillInfo->fillType == TSDB_FILL_PREV) {
char* pInterpolationData = FILL_IS_ASC_FILL(pFillInfo) ? *prevValues : *nextValues; char* p = FILL_IS_ASC_FILL(pFillInfo) ? prevValues : nextValues;
if (pInterpolationData != NULL) {
if (p != NULL) {
for (int32_t i = 1; i < numOfValCols; ++i) { for (int32_t i = 1; i < numOfValCols; ++i) {
SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SFillColInfo* pCol = &pFillInfo->pFillCol[i];
char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num);
if (isNull(pInterpolationData + pCol->col.offset, pCol->col.type)) { if (isNull(p + pCol->col.offset, pCol->col.type)) {
setNull(val1, pCol->col.type, pCol->col.bytes); if (pCol->col.type == TSDB_DATA_TYPE_BINARY || pCol->col.type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(val1, pCol->col.type);
} else {
setNull(val1, pCol->col.type, pCol->col.bytes);
}
} else { } else {
assignVal(val1, pInterpolationData + pCol->col.offset, pCol->col.bytes, pCol->col.type); assignVal(val1, p + pCol->col.offset, pCol->col.bytes, pCol->col.type);
} }
} }
} else { // no prev value yet, set the value for NULL } else { // no prev value yet, set the value for NULL
...@@ -274,14 +280,18 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* ...@@ -274,14 +280,18 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t*
SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SFillColInfo* pCol = &pFillInfo->pFillCol[i];
char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num);
setNull(val1, pCol->col.type, pCol->col.bytes); if (pCol->col.type == TSDB_DATA_TYPE_BINARY||pCol->col.type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(val1, pCol->col.type);
} else {
setNull(val1, pCol->col.type, pCol->col.bytes);
}
} }
} }
setTagsValue(pFillInfo, data, pTags, numOfValCols, *num); setTagsValue(pFillInfo, data, pTags, numOfValCols, *num);
} else if (pFillInfo->fillType == TSDB_FILL_LINEAR) { } else if (pFillInfo->fillType == TSDB_FILL_LINEAR) {
// TODO : linear interpolation supports NULL value // TODO : linear interpolation supports NULL value
if (*prevValues != NULL && !outOfBound) { if (prevValues != NULL && !outOfBound) {
for (int32_t i = 1; i < numOfValCols; ++i) { for (int32_t i = 1; i < numOfValCols; ++i) {
SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SFillColInfo* pCol = &pFillInfo->pFillCol[i];
...@@ -289,14 +299,17 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* ...@@ -289,14 +299,17 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t*
int16_t bytes = pCol->col.bytes; int16_t bytes = pCol->col.bytes;
char *val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); char *val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num);
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BOOL) { if (type == TSDB_DATA_TYPE_BINARY|| type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(val1, pCol->col.type);
continue;
} else if (type == TSDB_DATA_TYPE_BOOL) {
setNull(val1, pCol->col.type, bytes); setNull(val1, pCol->col.type, bytes);
continue; continue;
} }
point1 = (SPoint){.key = *(TSKEY*)(*prevValues), .val = *prevValues + pCol->col.offset}; point1 = (SPoint){.key = *(TSKEY*)(prevValues), .val = prevValues + pCol->col.offset};
point2 = (SPoint){.key = ts, .val = srcData[i] + pFillInfo->rowIdx * bytes}; point2 = (SPoint){.key = ts, .val = srcData[i] + pFillInfo->rowIdx * bytes};
point = (SPoint){.key = pFillInfo->start, .val = val1}; point = (SPoint){.key = pFillInfo->start, .val = val1};
taosDoLinearInterpolation(type, &point1, &point2, &point); taosDoLinearInterpolation(type, &point1, &point2, &point);
} }
...@@ -307,7 +320,12 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* ...@@ -307,7 +320,12 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t*
SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SFillColInfo* pCol = &pFillInfo->pFillCol[i];
char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num);
setNull(val1, pCol->col.type, pCol->col.bytes);
if (pCol->col.type == TSDB_DATA_TYPE_BINARY || pCol->col.type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(val1, pCol->col.type);
} else {
setNull(val1, pCol->col.type, pCol->col.bytes);
}
} }
setTagsValue(pFillInfo, data, pTags, numOfValCols, *num); setTagsValue(pFillInfo, data, pTags, numOfValCols, *num);
...@@ -318,7 +336,7 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* ...@@ -318,7 +336,7 @@ static void doInterpoResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t*
SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SFillColInfo* pCol = &pFillInfo->pFillCol[i];
char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num); char* val1 = elePtrAt(data[i]->data, pCol->col.bytes, *num);
assignVal(val1, (char*)&pCol->defaultVal.i, pCol->col.bytes, pCol->col.type); assignVal(val1, (char*)&pCol->fillVal.i, pCol->col.bytes, pCol->col.type);
} }
setTagsValue(pFillInfo, data, pTags, numOfValCols, *num); setTagsValue(pFillInfo, data, pTags, numOfValCols, *num);
...@@ -338,11 +356,16 @@ static void initBeforeAfterDataBuf(SFillInfo* pFillInfo, char** nextValues) { ...@@ -338,11 +356,16 @@ static void initBeforeAfterDataBuf(SFillInfo* pFillInfo, char** nextValues) {
*nextValues = calloc(1, pFillInfo->rowSize); *nextValues = calloc(1, pFillInfo->rowSize);
for (int i = 1; i < pFillInfo->numOfCols; i++) { for (int i = 1; i < pFillInfo->numOfCols; i++) {
SFillColInfo* pCol = &pFillInfo->pFillCol[i]; SFillColInfo* pCol = &pFillInfo->pFillCol[i];
setNull(*nextValues + pCol->col.offset, pCol->col.type, pCol->col.bytes);
if (pCol->col.type == TSDB_DATA_TYPE_BINARY||pCol->col.type == TSDB_DATA_TYPE_NCHAR) {
setVardataNull(*nextValues + pCol->col.offset, pCol->col.type);
} else {
setNull(*nextValues + pCol->col.offset, pCol->col.type, pCol->col.bytes);
}
} }
} }
int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numOfRows, int32_t outputRows, char** srcData) { int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t numOfRows, int32_t outputRows, char** srcData) {
int32_t num = 0; int32_t num = 0;
pFillInfo->numOfCurrent = 0; pFillInfo->numOfCurrent = 0;
...@@ -356,8 +379,8 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO ...@@ -356,8 +379,8 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO
if (numOfRows == 0) { if (numOfRows == 0) {
/* /*
* we need to rebuild whole result set * These data are generated according to fill strategy, since the current timestamp is out of time window of
* NOTE:we need to keep the last saved data, to generated the filled data * real result set. Note that we need to keep the direct previous result rows, to generated the filled data.
*/ */
while (num < outputRows) { while (num < outputRows) {
doInterpoResultImpl(pFillInfo, data, &num, srcData, pFillInfo->start, pTags, true); doInterpoResultImpl(pFillInfo, data, &num, srcData, pFillInfo->start, pTags, true);
...@@ -387,7 +410,7 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO ...@@ -387,7 +410,7 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO
while (((pFillInfo->start < ts && FILL_IS_ASC_FILL(pFillInfo)) || while (((pFillInfo->start < ts && FILL_IS_ASC_FILL(pFillInfo)) ||
(pFillInfo->start > ts && !FILL_IS_ASC_FILL(pFillInfo))) && num < outputRows) { (pFillInfo->start > ts && !FILL_IS_ASC_FILL(pFillInfo))) && num < outputRows) {
doInterpoResultImpl(pFillInfo, data, &num, srcData, pFillInfo->start, pTags, false); doInterpoResultImpl(pFillInfo, data, &num, srcData, ts, pTags, false);
} }
/* output buffer is full, abort */ /* output buffer is full, abort */
...@@ -420,7 +443,7 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO ...@@ -420,7 +443,7 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO
assignVal(val1, src, pCol->col.bytes, pCol->col.type); assignVal(val1, src, pCol->col.bytes, pCol->col.type);
memcpy(*prevValues + pCol->col.offset, src, pCol->col.bytes); memcpy(*prevValues + pCol->col.offset, src, pCol->col.bytes);
} else { } else {
assignVal(val1, (char*) &pCol->defaultVal.i, pCol->col.bytes, pCol->col.type); assignVal(val1, (char*) &pCol->fillVal.i, pCol->col.bytes, pCol->col.type);
} }
} }
} }
...@@ -450,21 +473,12 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO ...@@ -450,21 +473,12 @@ int32_t taosDoInterpoResult(SFillInfo* pFillInfo, tFilePage** data, int32_t numO
} }
} }
void taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int64_t* outputRows, int32_t capacity) { int64_t taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int32_t capacity) {
int32_t remain = taosNumOfRemainRows(pFillInfo); // todo use iterator? int32_t remain = taosNumOfRemainRows(pFillInfo); // todo use iterator?
int32_t rows = taosGetNumOfResultWithFill(pFillInfo, remain, pFillInfo->endKey, capacity);
// TSKEY ekey = taosGetRevisedEndKey(pQuery->window.ekey, pQuery->order.order, pQuery->slidingTime,
// pQuery->slidingTimeUnit, pQuery->precision);
// if (QUERY_IS_ASC_QUERY(pQuery)) {
// assert(ekey >= pQuery->window.ekey);
// } else {
// assert(ekey <= pQuery->window.ekey);
// }
int32_t rows = taosGetNumOfResultWithFill(pFillInfo, remain, pFillInfo->endKey, capacity);
int32_t numOfRes = taosDoInterpoResult(pFillInfo, output, remain, rows, pFillInfo->pData); int32_t numOfRes = generateDataBlockImpl(pFillInfo, output, remain, rows, pFillInfo->pData);
*outputRows = rows;
assert(numOfRes == rows); assert(numOfRes == rows);
return numOfRes;
} }
...@@ -101,11 +101,12 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 ...@@ -101,11 +101,12 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32
break; break;
} }
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
pVar->nLen = len / TSDB_NCHAR_SIZE; int32_t lenInwchar = len / TSDB_NCHAR_SIZE;
pVar->wpz = calloc(1, (pVar->nLen + 1) * TSDB_NCHAR_SIZE); pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
wcsncpy(pVar->wpz, (wchar_t *)pz, pVar->nLen); wcsncpy(pVar->wpz, (wchar_t *)pz, lenInwchar);
pVar->wpz[pVar->nLen] = 0; pVar->wpz[lenInwchar] = 0;
pVar->nLen = len;
break; break;
} }
......
...@@ -74,7 +74,7 @@ void tsdbCloseMetaFile(SMetaFile *mfh); ...@@ -74,7 +74,7 @@ void tsdbCloseMetaFile(SMetaFile *mfh);
typedef struct { typedef struct {
TSKEY keyFirst; TSKEY keyFirst;
TSKEY keyLast; TSKEY keyLast;
int32_t numOfPoints; int32_t numOfRows;
void * pData; void * pData;
} SMemTable; } SMemTable;
...@@ -173,7 +173,7 @@ typedef struct { ...@@ -173,7 +173,7 @@ typedef struct {
typedef struct { typedef struct {
TSKEY keyFirst; TSKEY keyFirst;
TSKEY keyLast; TSKEY keyLast;
int64_t numOfPoints; int64_t numOfRows;
SList * list; SList * list;
} SCacheMem; } SCacheMem;
...@@ -294,7 +294,7 @@ typedef struct { ...@@ -294,7 +294,7 @@ typedef struct {
int64_t last : 1; // If the block in data file or last file int64_t last : 1; // If the block in data file or last file
int64_t offset : 63; // Offset of data block or sub-block index depending on numOfSubBlocks int64_t offset : 63; // Offset of data block or sub-block index depending on numOfSubBlocks
int32_t algorithm : 8; // Compression algorithm int32_t algorithm : 8; // Compression algorithm
int32_t numOfPoints : 24; // Number of total points int32_t numOfRows : 24; // Number of total points
int32_t sversion; // Schema version int32_t sversion; // Schema version
int32_t len; // Data block length or nothing int32_t len; // Data block length or nothing
int16_t numOfSubBlocks; // Number of sub-blocks; int16_t numOfSubBlocks; // Number of sub-blocks;
......
...@@ -82,7 +82,7 @@ void *tsdbAllocFromCache(STsdbCache *pCache, int bytes, TSKEY key) { ...@@ -82,7 +82,7 @@ void *tsdbAllocFromCache(STsdbCache *pCache, int bytes, TSKEY key) {
memset(ptr, 0, bytes); memset(ptr, 0, bytes);
if (key < pCache->mem->keyFirst) pCache->mem->keyFirst = key; if (key < pCache->mem->keyFirst) pCache->mem->keyFirst = key;
if (key > pCache->mem->keyLast) pCache->mem->keyLast = key; if (key > pCache->mem->keyLast) pCache->mem->keyLast = key;
pCache->mem->numOfPoints++; pCache->mem->numOfRows++;
return ptr; return ptr;
} }
...@@ -127,7 +127,7 @@ static int tsdbAllocBlockFromPool(STsdbCache *pCache) { ...@@ -127,7 +127,7 @@ static int tsdbAllocBlockFromPool(STsdbCache *pCache) {
if (pCache->mem == NULL) return -1; if (pCache->mem == NULL) return -1;
pCache->mem->keyFirst = INT64_MAX; pCache->mem->keyFirst = INT64_MAX;
pCache->mem->keyLast = 0; pCache->mem->keyLast = 0;
pCache->mem->numOfPoints = 0; pCache->mem->numOfRows = 0;
pCache->mem->list = tdListNew(sizeof(STsdbCacheBlock *)); pCache->mem->list = tdListNew(sizeof(STsdbCacheBlock *));
} }
......
...@@ -233,10 +233,10 @@ SFileGroup *tsdbGetFileGroupNext(SFileGroupIter *pIter) { ...@@ -233,10 +233,10 @@ SFileGroup *tsdbGetFileGroupNext(SFileGroupIter *pIter) {
// SCompBlock *pBlock = pStartBlock; // SCompBlock *pBlock = pStartBlock;
// for (int i = 0; i < numOfBlocks; i++) { // for (int i = 0; i < numOfBlocks; i++) {
// if (tsdbLoadCompCols(pFile, pBlock, (void *)pCompData) < 0) return -1; // if (tsdbLoadCompCols(pFile, pBlock, (void *)pCompData) < 0) return -1;
// pCols->numOfPoints += (pCompData->cols[0].len / 8); // pCols->numOfRows += (pCompData->cols[0].len / 8);
// for (int iCol = 0; iCol < pBlock->numOfCols; iCol++) { // for (int iCol = 0; iCol < pBlock->numOfCols; iCol++) {
// SCompCol *pCompCol = &(pCompData->cols[iCol]); // SCompCol *pCompCol = &(pCompData->cols[iCol]);
// // pCols->numOfPoints += pBlock->numOfPoints; // // pCols->numOfRows += pBlock->numOfRows;
// int k = 0; // int k = 0;
// for (; k < pCols->numOfCols; k++) { // for (; k < pCols->numOfCols; k++) {
// if (pCompCol->colId == pCols->cols[k].colId) break; // if (pCompCol->colId == pCols->cols[k].colId) break;
......
...@@ -830,7 +830,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable ...@@ -830,7 +830,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
tSkipListNewNodeInfo(pTable->mem->pData, &level, &headSize); tSkipListNewNodeInfo(pTable->mem->pData, &level, &headSize);
TSKEY key = dataRowKey(row); TSKEY key = dataRowKey(row);
// printf("insert:%lld, size:%d\n", key, pTable->mem->numOfPoints); // printf("insert:%lld, size:%d\n", key, pTable->mem->numOfRows);
// Copy row into the memory // Copy row into the memory
SSkipListNode *pNode = tsdbAllocFromCache(pRepo->tsdbCache, headSize + dataRowLen(row), key); SSkipListNode *pNode = tsdbAllocFromCache(pRepo->tsdbCache, headSize + dataRowLen(row), key);
...@@ -854,7 +854,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable ...@@ -854,7 +854,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
if (key < pTable->mem->keyFirst) pTable->mem->keyFirst = key; if (key < pTable->mem->keyFirst) pTable->mem->keyFirst = key;
if (key > pTable->lastKey) pTable->lastKey = key; if (key > pTable->lastKey) pTable->lastKey = key;
pTable->mem->numOfPoints = tSkipListGetSize(pTable->mem->pData); pTable->mem->numOfRows = tSkipListGetSize(pTable->mem->pData);
tsdbTrace("vgId:%d, tid:%d, uid:%" PRId64 ", table:%s a row is inserted to table! key:%" PRId64, pRepo->config.tsdbId, tsdbTrace("vgId:%d, tid:%d, uid:%" PRId64 ", table:%s a row is inserted to table! key:%" PRId64, pRepo->config.tsdbId,
pTable->tableId.tid, pTable->tableId.uid, varDataVal(pTable->name), dataRowKey(row)); pTable->tableId.tid, pTable->tableId.uid, varDataVal(pTable->name), dataRowKey(row));
...@@ -1063,7 +1063,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters ...@@ -1063,7 +1063,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
while (true) { while (true) {
int rowsRead = tsdbReadRowsFromCache(pIter, maxKey, maxRowsToRead, pDataCols); int rowsRead = tsdbReadRowsFromCache(pIter, maxKey, maxRowsToRead, pDataCols);
assert(rowsRead >= 0); assert(rowsRead >= 0);
if (pDataCols->numOfPoints == 0) break; if (pDataCols->numOfRows == 0) break;
nLoop++; nLoop++;
ASSERT(dataColsKeyFirst(pDataCols) >= minKey && dataColsKeyFirst(pDataCols) <= maxKey); ASSERT(dataColsKeyFirst(pDataCols) >= minKey && dataColsKeyFirst(pDataCols) <= maxKey);
...@@ -1072,13 +1072,13 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters ...@@ -1072,13 +1072,13 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
int rowsWritten = tsdbWriteDataBlock(pHelper, pDataCols); int rowsWritten = tsdbWriteDataBlock(pHelper, pDataCols);
ASSERT(rowsWritten != 0); ASSERT(rowsWritten != 0);
if (rowsWritten < 0) goto _err; if (rowsWritten < 0) goto _err;
ASSERT(rowsWritten <= pDataCols->numOfPoints); ASSERT(rowsWritten <= pDataCols->numOfRows);
tdPopDataColsPoints(pDataCols, rowsWritten); tdPopDataColsPoints(pDataCols, rowsWritten);
maxRowsToRead = pCfg->maxRowsPerFileBlock * 4 / 5 - pDataCols->numOfPoints; maxRowsToRead = pCfg->maxRowsPerFileBlock * 4 / 5 - pDataCols->numOfRows;
} }
ASSERT(pDataCols->numOfPoints == 0); ASSERT(pDataCols->numOfRows == 0);
// Move the last block to the new .l file if neccessary // Move the last block to the new .l file if neccessary
if (tsdbMoveLastBlockIfNeccessary(pHelper) < 0) { if (tsdbMoveLastBlockIfNeccessary(pHelper) < 0) {
...@@ -1196,7 +1196,7 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t * ...@@ -1196,7 +1196,7 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *
// Map index to the file name // Map index to the file name
int fid = (*index) / 3; int fid = (*index) / 3;
if (fid > pFileH->numOfFGroups) { if (fid >= pFileH->numOfFGroups) {
// return meta data file // return meta data file
if ((*index) % 3 > 0) { // it is finished if ((*index) % 3 > 0) { // it is finished
tfree(spath); tfree(spath);
......
...@@ -307,7 +307,7 @@ void tsdbSetHelperTable(SRWHelper *pHelper, STable *pTable, STsdbRepo *pRepo) { ...@@ -307,7 +307,7 @@ void tsdbSetHelperTable(SRWHelper *pHelper, STable *pTable, STsdbRepo *pRepo) {
*/ */
int tsdbWriteDataBlock(SRWHelper *pHelper, SDataCols *pDataCols) { int tsdbWriteDataBlock(SRWHelper *pHelper, SDataCols *pDataCols) {
ASSERT(TSDB_HELPER_TYPE(pHelper) == TSDB_WRITE_HELPER); ASSERT(TSDB_HELPER_TYPE(pHelper) == TSDB_WRITE_HELPER);
ASSERT(pDataCols->numOfPoints > 0); ASSERT(pDataCols->numOfRows > 0);
SCompBlock compBlock; SCompBlock compBlock;
int rowsToWrite = 0; int rowsToWrite = 0;
...@@ -322,7 +322,7 @@ int tsdbWriteDataBlock(SRWHelper *pHelper, SDataCols *pDataCols) { ...@@ -322,7 +322,7 @@ int tsdbWriteDataBlock(SRWHelper *pHelper, SDataCols *pDataCols) {
if (pIdx->offset == 0 || (!pIdx->hasLast && keyFirst > pIdx->maxKey)) { // Just append as a super block if (pIdx->offset == 0 || (!pIdx->hasLast && keyFirst > pIdx->maxKey)) { // Just append as a super block
ASSERT(pHelper->hasOldLastBlock == false); ASSERT(pHelper->hasOldLastBlock == false);
rowsToWrite = pDataCols->numOfPoints; rowsToWrite = pDataCols->numOfRows;
SFile *pWFile = NULL; SFile *pWFile = NULL;
bool isLast = false; bool isLast = false;
...@@ -380,10 +380,10 @@ int tsdbMoveLastBlockIfNeccessary(SRWHelper *pHelper) { ...@@ -380,10 +380,10 @@ int tsdbMoveLastBlockIfNeccessary(SRWHelper *pHelper) {
if (pCompBlock->numOfSubBlocks > 1) { if (pCompBlock->numOfSubBlocks > 1) {
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, pIdx->numOfBlocks - 1), NULL) < 0) return -1; if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, pIdx->numOfBlocks - 1), NULL) < 0) return -1;
ASSERT(pHelper->pDataCols[0]->numOfPoints > 0 && ASSERT(pHelper->pDataCols[0]->numOfRows > 0 &&
pHelper->pDataCols[0]->numOfPoints < pHelper->config.minRowsPerFileBlock); pHelper->pDataCols[0]->numOfRows < pHelper->config.minRowsPerFileBlock);
if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.nLastF), pHelper->pDataCols[0], if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.nLastF), pHelper->pDataCols[0],
pHelper->pDataCols[0]->numOfPoints, &compBlock, true, true) < 0) pHelper->pDataCols[0]->numOfRows, &compBlock, true, true) < 0)
return -1; return -1;
if (tsdbUpdateSuperBlock(pHelper, &compBlock, pIdx->numOfBlocks - 1) < 0) return -1; if (tsdbUpdateSuperBlock(pHelper, &compBlock, pIdx->numOfBlocks - 1) < 0) return -1;
...@@ -625,13 +625,13 @@ int tsdbLoadBlockDataCols(SRWHelper *pHelper, SDataCols *pDataCols, int blkIdx, ...@@ -625,13 +625,13 @@ int tsdbLoadBlockDataCols(SRWHelper *pHelper, SDataCols *pDataCols, int blkIdx,
for (int i = 1; i < numOfSubBlocks; i++) { for (int i = 1; i < numOfSubBlocks; i++) {
pStartBlock++; pStartBlock++;
if (tsdbLoadSingleBlockDataCols(pHelper, pStartBlock, colIds, numOfColIds, pHelper->pDataCols[1]) < 0) return -1; if (tsdbLoadSingleBlockDataCols(pHelper, pStartBlock, colIds, numOfColIds, pHelper->pDataCols[1]) < 0) return -1;
tdMergeDataCols(pDataCols, pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfPoints); tdMergeDataCols(pDataCols, pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows);
} }
return 0; return 0;
} }
static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32_t len, int8_t comp, int numOfPoints, static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32_t len, int8_t comp, int numOfRows,
int maxPoints, char *buffer, int bufferSize) { int maxPoints, char *buffer, int bufferSize) {
// Verify by checksum // Verify by checksum
if (!taosCheckChecksumWhole((uint8_t *)content, len)) return -1; if (!taosCheckChecksumWhole((uint8_t *)content, len)) return -1;
...@@ -640,16 +640,16 @@ static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32 ...@@ -640,16 +640,16 @@ static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32
if (comp) { if (comp) {
// // Need to decompress // // Need to decompress
pDataCol->len = (*(tDataTypeDesc[pDataCol->type].decompFunc))( pDataCol->len = (*(tDataTypeDesc[pDataCol->type].decompFunc))(
content, len - sizeof(TSCKSUM), numOfPoints, pDataCol->pData, pDataCol->spaceSize, comp, buffer, bufferSize); content, len - sizeof(TSCKSUM), numOfRows, pDataCol->pData, pDataCol->spaceSize, comp, buffer, bufferSize);
if (pDataCol->type == TSDB_DATA_TYPE_BINARY || pDataCol->type == TSDB_DATA_TYPE_NCHAR) { if (pDataCol->type == TSDB_DATA_TYPE_BINARY || pDataCol->type == TSDB_DATA_TYPE_NCHAR) {
dataColSetOffset(pDataCol, numOfPoints); dataColSetOffset(pDataCol, numOfRows);
} }
} else { } else {
// No need to decompress, just memcpy it // No need to decompress, just memcpy it
pDataCol->len = len - sizeof(TSCKSUM); pDataCol->len = len - sizeof(TSCKSUM);
memcpy(pDataCol->pData, content, pDataCol->len); memcpy(pDataCol->pData, content, pDataCol->len);
if (pDataCol->type == TSDB_DATA_TYPE_BINARY || pDataCol->type == TSDB_DATA_TYPE_NCHAR) { if (pDataCol->type == TSDB_DATA_TYPE_BINARY || pDataCol->type == TSDB_DATA_TYPE_NCHAR) {
dataColSetOffset(pDataCol, numOfPoints); dataColSetOffset(pDataCol, numOfRows);
} }
} }
return 0; return 0;
...@@ -673,7 +673,7 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa ...@@ -673,7 +673,7 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
int32_t tsize = sizeof(SCompData) + sizeof(SCompCol) * pCompBlock->numOfCols + sizeof(TSCKSUM); int32_t tsize = sizeof(SCompData) + sizeof(SCompCol) * pCompBlock->numOfCols + sizeof(TSCKSUM);
if (!taosCheckChecksumWhole((uint8_t *)pCompData, tsize)) goto _err; if (!taosCheckChecksumWhole((uint8_t *)pCompData, tsize)) goto _err;
pDataCols->numOfPoints = pCompBlock->numOfPoints; pDataCols->numOfRows = pCompBlock->numOfRows;
// Recover the data // Recover the data
int ccol = 0; int ccol = 0;
...@@ -682,7 +682,7 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa ...@@ -682,7 +682,7 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
SDataCol *pDataCol = &(pDataCols->cols[dcol]); SDataCol *pDataCol = &(pDataCols->cols[dcol]);
if (ccol >= pCompData->numOfCols) { if (ccol >= pCompData->numOfCols) {
// Set current column as NULL and forward // Set current column as NULL and forward
dataColSetNEleNull(pDataCol, pCompBlock->numOfPoints, pDataCols->maxPoints); dataColSetNEleNull(pDataCol, pCompBlock->numOfRows, pDataCols->maxPoints);
dcol++; dcol++;
continue; continue;
} }
...@@ -691,15 +691,15 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa ...@@ -691,15 +691,15 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
if (pCompCol->colId == pDataCol->colId) { if (pCompCol->colId == pDataCol->colId) {
if (pCompBlock->algorithm == TWO_STAGE_COMP) { if (pCompBlock->algorithm == TWO_STAGE_COMP) {
int zsize = pDataCol->bytes * pCompBlock->numOfPoints + COMP_OVERFLOW_BYTES; int zsize = pDataCol->bytes * pCompBlock->numOfRows + COMP_OVERFLOW_BYTES;
if (pCompCol->type == TSDB_DATA_TYPE_BINARY || pCompCol->type == TSDB_DATA_TYPE_NCHAR) { if (pCompCol->type == TSDB_DATA_TYPE_BINARY || pCompCol->type == TSDB_DATA_TYPE_NCHAR) {
zsize += (sizeof(VarDataLenT) * pCompBlock->numOfPoints); zsize += (sizeof(VarDataLenT) * pCompBlock->numOfRows);
} }
pHelper->compBuffer = trealloc(pHelper->compBuffer, zsize); pHelper->compBuffer = trealloc(pHelper->compBuffer, zsize);
if (pHelper->compBuffer == NULL) goto _err; if (pHelper->compBuffer == NULL) goto _err;
} }
if (tsdbCheckAndDecodeColumnData(pDataCol, (char *)pCompData + tsize + pCompCol->offset, pCompCol->len, if (tsdbCheckAndDecodeColumnData(pDataCol, (char *)pCompData + tsize + pCompCol->offset, pCompCol->len,
pCompBlock->algorithm, pCompBlock->numOfPoints, pDataCols->maxPoints, pCompBlock->algorithm, pCompBlock->numOfRows, pDataCols->maxPoints,
pHelper->compBuffer, tsizeof(pHelper->compBuffer)) < 0) pHelper->compBuffer, tsizeof(pHelper->compBuffer)) < 0)
goto _err; goto _err;
dcol++; dcol++;
...@@ -708,7 +708,7 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa ...@@ -708,7 +708,7 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
ccol++; ccol++;
} else { } else {
// Set current column as NULL and forward // Set current column as NULL and forward
dataColSetNEleNull(pDataCol, pCompBlock->numOfPoints, pDataCols->maxPoints); dataColSetNEleNull(pDataCol, pCompBlock->numOfRows, pDataCols->maxPoints);
dcol++; dcol++;
} }
} }
...@@ -732,7 +732,7 @@ int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *tar ...@@ -732,7 +732,7 @@ int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *tar
tdResetDataCols(pHelper->pDataCols[1]); tdResetDataCols(pHelper->pDataCols[1]);
pCompBlock++; pCompBlock++;
if (tsdbLoadBlockDataImpl(pHelper, pCompBlock, pHelper->pDataCols[1]) < 0) goto _err; if (tsdbLoadBlockDataImpl(pHelper, pCompBlock, pHelper->pDataCols[1]) < 0) goto _err;
if (tdMergeDataCols(pHelper->pDataCols[0], pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfPoints) < 0) goto _err; if (tdMergeDataCols(pHelper->pDataCols[0], pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows) < 0) goto _err;
} }
// if (target) TODO // if (target) TODO
...@@ -753,7 +753,7 @@ static bool tsdbShouldCreateNewLast(SRWHelper *pHelper) { ...@@ -753,7 +753,7 @@ static bool tsdbShouldCreateNewLast(SRWHelper *pHelper) {
static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDataCols, int rowsToWrite, SCompBlock *pCompBlock, static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDataCols, int rowsToWrite, SCompBlock *pCompBlock,
bool isLast, bool isSuperBlock) { bool isLast, bool isSuperBlock) {
ASSERT(rowsToWrite > 0 && rowsToWrite <= pDataCols->numOfPoints && ASSERT(rowsToWrite > 0 && rowsToWrite <= pDataCols->numOfRows &&
rowsToWrite <= pHelper->config.maxRowsPerFileBlock); rowsToWrite <= pHelper->config.maxRowsPerFileBlock);
SCompData *pCompData = (SCompData *)(pHelper->pBuffer); SCompData *pCompData = (SCompData *)(pHelper->pBuffer);
...@@ -840,7 +840,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa ...@@ -840,7 +840,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
pCompBlock->last = isLast; pCompBlock->last = isLast;
pCompBlock->offset = offset; pCompBlock->offset = offset;
pCompBlock->algorithm = pHelper->config.compress; pCompBlock->algorithm = pHelper->config.compress;
pCompBlock->numOfPoints = rowsToWrite; pCompBlock->numOfRows = rowsToWrite;
pCompBlock->sversion = pHelper->tableInfo.sversion; pCompBlock->sversion = pHelper->tableInfo.sversion;
pCompBlock->len = (int32_t)lsize; pCompBlock->len = (int32_t)lsize;
pCompBlock->numOfSubBlocks = isSuperBlock ? 1 : 0; pCompBlock->numOfSubBlocks = isSuperBlock ? 1 : 0;
...@@ -877,7 +877,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -877,7 +877,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
int rowsWritten = 0; int rowsWritten = 0;
SCompBlock compBlock = {0}; SCompBlock compBlock = {0};
ASSERT(pDataCols->numOfPoints > 0); ASSERT(pDataCols->numOfRows > 0);
TSKEY keyFirst = dataColsKeyFirst(pDataCols); TSKEY keyFirst = dataColsKeyFirst(pDataCols);
SCompIdx *pIdx = pHelper->pCompIdx + pHelper->tableInfo.tid; SCompIdx *pIdx = pHelper->pCompIdx + pHelper->tableInfo.tid;
...@@ -889,32 +889,32 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -889,32 +889,32 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
// ASSERT(compareKeyBlock((void *)&keyFirst, (void *)pCompBlock) == 0); // ASSERT(compareKeyBlock((void *)&keyFirst, (void *)pCompBlock) == 0);
if (keyFirst > blockAtIdx(pHelper, blkIdx)->keyLast) { // Merge with the last block by append if (keyFirst > blockAtIdx(pHelper, blkIdx)->keyLast) { // Merge with the last block by append
ASSERT(blockAtIdx(pHelper, blkIdx)->numOfPoints < pHelper->config.minRowsPerFileBlock && blkIdx == pIdx->numOfBlocks-1); ASSERT(blockAtIdx(pHelper, blkIdx)->numOfRows < pHelper->config.minRowsPerFileBlock && blkIdx == pIdx->numOfBlocks-1);
int defaultRowsToWrite = pHelper->config.maxRowsPerFileBlock * 4 / 5; // TODO: make a interface int defaultRowsToWrite = pHelper->config.maxRowsPerFileBlock * 4 / 5; // TODO: make a interface
rowsWritten = MIN((defaultRowsToWrite - blockAtIdx(pHelper, blkIdx)->numOfPoints), pDataCols->numOfPoints); rowsWritten = MIN((defaultRowsToWrite - blockAtIdx(pHelper, blkIdx)->numOfRows), pDataCols->numOfRows);
if ((blockAtIdx(pHelper, blkIdx)->numOfSubBlocks < TSDB_MAX_SUBBLOCKS) && if ((blockAtIdx(pHelper, blkIdx)->numOfSubBlocks < TSDB_MAX_SUBBLOCKS) &&
(blockAtIdx(pHelper, blkIdx)->numOfPoints + rowsWritten < pHelper->config.minRowsPerFileBlock) && (pHelper->files.nLastF.fd) > 0) { (blockAtIdx(pHelper, blkIdx)->numOfRows + rowsWritten < pHelper->config.minRowsPerFileBlock) && (pHelper->files.nLastF.fd) > 0) {
if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.lastF), pDataCols, rowsWritten, &compBlock, true, false) < 0) if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.lastF), pDataCols, rowsWritten, &compBlock, true, false) < 0)
goto _err; goto _err;
if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err; if (tsdbAddSubBlock(pHelper, &compBlock, blkIdx, rowsWritten) < 0) goto _err;
} else { } else {
// Load // Load
if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx), NULL) < 0) goto _err; if (tsdbLoadBlockData(pHelper, blockAtIdx(pHelper, blkIdx), NULL) < 0) goto _err;
ASSERT(pHelper->pDataCols[0]->numOfPoints == blockAtIdx(pHelper, blkIdx)->numOfPoints); ASSERT(pHelper->pDataCols[0]->numOfRows == blockAtIdx(pHelper, blkIdx)->numOfRows);
// Merge // Merge
if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, rowsWritten) < 0) goto _err; if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, rowsWritten) < 0) goto _err;
// Write // Write
SFile *pWFile = NULL; SFile *pWFile = NULL;
bool isLast = false; bool isLast = false;
if (pHelper->pDataCols[0]->numOfPoints >= pHelper->config.minRowsPerFileBlock) { if (pHelper->pDataCols[0]->numOfRows >= pHelper->config.minRowsPerFileBlock) {
pWFile = &(pHelper->files.dataF); pWFile = &(pHelper->files.dataF);
} else { } else {
isLast = true; isLast = true;
pWFile = (pHelper->files.nLastF.fd > 0) ? &(pHelper->files.nLastF) : &(pHelper->files.lastF); pWFile = (pHelper->files.nLastF.fd > 0) ? &(pHelper->files.nLastF) : &(pHelper->files.lastF);
} }
if (tsdbWriteBlockToFile(pHelper, pWFile, pHelper->pDataCols[0], if (tsdbWriteBlockToFile(pHelper, pWFile, pHelper->pDataCols[0],
pHelper->pDataCols[0]->numOfPoints, &compBlock, isLast, true) < 0) pHelper->pDataCols[0]->numOfRows, &compBlock, isLast, true) < 0)
goto _err; goto _err;
if (tsdbUpdateSuperBlock(pHelper, &compBlock, blkIdx) < 0) goto _err; if (tsdbUpdateSuperBlock(pHelper, &compBlock, blkIdx) < 0) goto _err;
} }
...@@ -931,7 +931,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -931,7 +931,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
// rows1: number of rows must merge in this block // rows1: number of rows must merge in this block
int rows1 = tsdbGetRowsInRange(pDataCols, blockAtIdx(pHelper, blkIdx)->keyFirst, blockAtIdx(pHelper, blkIdx)->keyLast); int rows1 = tsdbGetRowsInRange(pDataCols, blockAtIdx(pHelper, blkIdx)->keyFirst, blockAtIdx(pHelper, blkIdx)->keyLast);
// rows2: max nuber of rows the block can have more // rows2: max nuber of rows the block can have more
int rows2 = pHelper->config.maxRowsPerFileBlock - blockAtIdx(pHelper, blkIdx)->numOfPoints; int rows2 = pHelper->config.maxRowsPerFileBlock - blockAtIdx(pHelper, blkIdx)->numOfRows;
// rows3: number of rows between this block and the next block // rows3: number of rows between this block and the next block
int rows3 = tsdbGetRowsInRange(pDataCols, blockAtIdx(pHelper, blkIdx)->keyFirst, keyLimit); int rows3 = tsdbGetRowsInRange(pDataCols, blockAtIdx(pHelper, blkIdx)->keyFirst, keyLimit);
...@@ -939,7 +939,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -939,7 +939,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
if ((rows2 >= rows1) && if ((rows2 >= rows1) &&
(( blockAtIdx(pHelper, blkIdx)->last) || (( blockAtIdx(pHelper, blkIdx)->last) ||
((rows1 + blockAtIdx(pHelper, blkIdx)->numOfPoints < pHelper->config.minRowsPerFileBlock) && (pHelper->files.nLastF.fd < 0)))) { ((rows1 + blockAtIdx(pHelper, blkIdx)->numOfRows < pHelper->config.minRowsPerFileBlock) && (pHelper->files.nLastF.fd < 0)))) {
rowsWritten = rows1; rowsWritten = rows1;
bool isLast = false; bool isLast = false;
SFile *pFile = NULL; SFile *pFile = NULL;
...@@ -965,11 +965,11 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -965,11 +965,11 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
int round = 0; int round = 0;
// tdResetDataCols(pHelper->pDataCols[1]); // tdResetDataCols(pHelper->pDataCols[1]);
while (true) { while (true) {
if (iter1 >= pHelper->pDataCols[0]->numOfPoints && iter2 >= rows3) break; if (iter1 >= pHelper->pDataCols[0]->numOfRows && iter2 >= rows3) break;
tdMergeTwoDataCols(pHelper->pDataCols[1], pHelper->pDataCols[0], &iter1, pDataCols, &iter2, pHelper->config.maxRowsPerFileBlock * 4 / 5); tdMergeTwoDataCols(pHelper->pDataCols[1], pHelper->pDataCols[0], &iter1, pDataCols, &iter2, pHelper->config.maxRowsPerFileBlock * 4 / 5);
ASSERT(pHelper->pDataCols[1]->numOfPoints > 0); ASSERT(pHelper->pDataCols[1]->numOfRows > 0);
if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.dataF), pHelper->pDataCols[1], if (tsdbWriteBlockToFile(pHelper, &(pHelper->files.dataF), pHelper->pDataCols[1],
pHelper->pDataCols[1]->numOfPoints, &compBlock, false, true) < 0) pHelper->pDataCols[1]->numOfRows, &compBlock, false, true) < 0)
goto _err; goto _err;
if (round == 0) { if (round == 0) {
tsdbUpdateSuperBlock(pHelper, &compBlock, blkIdx); tsdbUpdateSuperBlock(pHelper, &compBlock, blkIdx);
...@@ -980,17 +980,17 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -980,17 +980,17 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
blkIdx++; blkIdx++;
// TODO: the blkIdx here is not correct // TODO: the blkIdx here is not correct
// if (iter1 >= pHelper->pDataCols[0]->numOfPoints && iter2 >= rows3) { // if (iter1 >= pHelper->pDataCols[0]->numOfRows && iter2 >= rows3) {
// if (pHelper->pDataCols[1]->numOfPoints > 0) { // if (pHelper->pDataCols[1]->numOfRows > 0) {
// if (tsdbWriteBlockToFile(pHelper, &pHelper->files.dataF, pHelper->pDataCols[1], // if (tsdbWriteBlockToFile(pHelper, &pHelper->files.dataF, pHelper->pDataCols[1],
// pHelper->pDataCols[1]->numOfPoints, &compBlock, false, true) < 0) // pHelper->pDataCols[1]->numOfRows, &compBlock, false, true) < 0)
// goto _err; // goto _err;
// // TODO: the blkIdx here is not correct // // TODO: the blkIdx here is not correct
// tsdbAddSubBlock(pHelper, &compBlock, blkIdx, pHelper->pDataCols[1]->numOfPoints); // tsdbAddSubBlock(pHelper, &compBlock, blkIdx, pHelper->pDataCols[1]->numOfRows);
// } // }
// } // }
// TSKEY key1 = iter1 >= pHelper->pDataCols[0]->numOfPoints // TSKEY key1 = iter1 >= pHelper->pDataCols[0]->numOfRows
// ? INT64_MAX // ? INT64_MAX
// : ((int64_t *)(pHelper->pDataCols[0]->cols[0].pData))[iter1]; // : ((int64_t *)(pHelper->pDataCols[0]->cols[0].pData))[iter1];
// TSKEY key2 = iter2 >= rowsWritten ? INT64_MAX : ((int64_t *)(pDataCols->cols[0].pData))[iter2]; // TSKEY key2 = iter2 >= rowsWritten ? INT64_MAX : ((int64_t *)(pDataCols->cols[0].pData))[iter2];
...@@ -998,11 +998,11 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -998,11 +998,11 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
// if (key1 < key2) { // if (key1 < key2) {
// for (int i = 0; i < pDataCols->numOfCols; i++) { // for (int i = 0; i < pDataCols->numOfCols; i++) {
// SDataCol *pDataCol = pHelper->pDataCols[1]->cols + i; // SDataCol *pDataCol = pHelper->pDataCols[1]->cols + i;
// memcpy(((char *)pDataCol->pData + TYPE_BYTES[pDataCol->type] * pHelper->pDataCols[1]->numOfPoints), // memcpy(((char *)pDataCol->pData + TYPE_BYTES[pDataCol->type] * pHelper->pDataCols[1]->numOfRows),
// ((char *)pHelper->pDataCols[0]->cols[i].pData + TYPE_BYTES[pDataCol->type] * iter1), // ((char *)pHelper->pDataCols[0]->cols[i].pData + TYPE_BYTES[pDataCol->type] * iter1),
// TYPE_BYTES[pDataCol->type]); // TYPE_BYTES[pDataCol->type]);
// } // }
// pHelper->pDataCols[1]->numOfPoints++; // pHelper->pDataCols[1]->numOfRows++;
// iter1++; // iter1++;
// } else if (key1 == key2) { // } else if (key1 == key2) {
// // TODO: think about duplicate key cases // // TODO: think about duplicate key cases
...@@ -1010,17 +1010,17 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa ...@@ -1010,17 +1010,17 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
// } else { // } else {
// for (int i = 0; i < pDataCols->numOfCols; i++) { // for (int i = 0; i < pDataCols->numOfCols; i++) {
// SDataCol *pDataCol = pHelper->pDataCols[1]->cols + i; // SDataCol *pDataCol = pHelper->pDataCols[1]->cols + i;
// memcpy(((char *)pDataCol->pData + TYPE_BYTES[pDataCol->type] * pHelper->pDataCols[1]->numOfPoints), // memcpy(((char *)pDataCol->pData + TYPE_BYTES[pDataCol->type] * pHelper->pDataCols[1]->numOfRows),
// ((char *)pDataCols->cols[i].pData + // ((char *)pDataCols->cols[i].pData +
// TYPE_BYTES[pDataCol->type] * iter2), // TYPE_BYTES[pDataCol->type] * iter2),
// TYPE_BYTES[pDataCol->type]); // TYPE_BYTES[pDataCol->type]);
// } // }
// pHelper->pDataCols[1]->numOfPoints++; // pHelper->pDataCols[1]->numOfRows++;
// iter2++; // iter2++;
// } // }
// if (pHelper->pDataCols[0]->numOfPoints >= pHelper->config.maxRowsPerFileBlock * 4 / 5) { // if (pHelper->pDataCols[0]->numOfRows >= pHelper->config.maxRowsPerFileBlock * 4 / 5) {
// if (tsdbWriteBlockToFile(pHelper, &pHelper->files.dataF, pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfPoints, &compBlock, false, true) < 0) goto _err; // if (tsdbWriteBlockToFile(pHelper, &pHelper->files.dataF, pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows, &compBlock, false, true) < 0) goto _err;
// // TODO: blkIdx here is not correct, fix it // // TODO: blkIdx here is not correct, fix it
// tsdbInsertSuperBlock(pHelper, &compBlock, blkIdx); // tsdbInsertSuperBlock(pHelper, &compBlock, blkIdx);
...@@ -1133,7 +1133,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId ...@@ -1133,7 +1133,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
pSCompBlock->numOfSubBlocks++; pSCompBlock->numOfSubBlocks++;
ASSERT(pSCompBlock->numOfSubBlocks <= TSDB_MAX_SUBBLOCKS); ASSERT(pSCompBlock->numOfSubBlocks <= TSDB_MAX_SUBBLOCKS);
pSCompBlock->len += sizeof(SCompBlock); pSCompBlock->len += sizeof(SCompBlock);
pSCompBlock->numOfPoints += rowsAdded; pSCompBlock->numOfRows += rowsAdded;
pSCompBlock->keyFirst = MIN(pSCompBlock->keyFirst, pCompBlock->keyFirst); pSCompBlock->keyFirst = MIN(pSCompBlock->keyFirst, pCompBlock->keyFirst);
pSCompBlock->keyLast = MAX(pSCompBlock->keyLast, pCompBlock->keyLast); pSCompBlock->keyLast = MAX(pSCompBlock->keyLast, pCompBlock->keyLast);
pIdx->len += sizeof(SCompBlock); pIdx->len += sizeof(SCompBlock);
...@@ -1164,7 +1164,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId ...@@ -1164,7 +1164,7 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
((SCompBlock *)ptr)[1] = *pCompBlock; ((SCompBlock *)ptr)[1] = *pCompBlock;
pSCompBlock->numOfSubBlocks = 2; pSCompBlock->numOfSubBlocks = 2;
pSCompBlock->numOfPoints += rowsAdded; pSCompBlock->numOfRows += rowsAdded;
pSCompBlock->offset = ((char *)ptr) - ((char *)pHelper->pCompInfo); pSCompBlock->offset = ((char *)ptr) - ((char *)pHelper->pCompInfo);
pSCompBlock->len = sizeof(SCompBlock) * 2; pSCompBlock->len = sizeof(SCompBlock) * 2;
pSCompBlock->keyFirst = MIN(((SCompBlock *)ptr)[0].keyFirst, ((SCompBlock *)ptr)[1].keyFirst); pSCompBlock->keyFirst = MIN(((SCompBlock *)ptr)[0].keyFirst, ((SCompBlock *)ptr)[1].keyFirst);
...@@ -1219,7 +1219,7 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int ...@@ -1219,7 +1219,7 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
// Get the number of rows in range [minKey, maxKey] // Get the number of rows in range [minKey, maxKey]
static int tsdbGetRowsInRange(SDataCols *pDataCols, TSKEY minKey, TSKEY maxKey) { static int tsdbGetRowsInRange(SDataCols *pDataCols, TSKEY minKey, TSKEY maxKey) {
if (pDataCols->numOfPoints == 0) return 0; if (pDataCols->numOfRows == 0) return 0;
ASSERT(minKey <= maxKey); ASSERT(minKey <= maxKey);
TSKEY keyFirst = dataColsKeyFirst(pDataCols); TSKEY keyFirst = dataColsKeyFirst(pDataCols);
...@@ -1228,11 +1228,11 @@ static int tsdbGetRowsInRange(SDataCols *pDataCols, TSKEY minKey, TSKEY maxKey) ...@@ -1228,11 +1228,11 @@ static int tsdbGetRowsInRange(SDataCols *pDataCols, TSKEY minKey, TSKEY maxKey)
if (minKey > keyLast || maxKey < keyFirst) return 0; if (minKey > keyLast || maxKey < keyFirst) return 0;
void *ptr1 = taosbsearch((void *)&minKey, (void *)pDataCols->cols[0].pData, pDataCols->numOfPoints, sizeof(TSKEY), void *ptr1 = taosbsearch((void *)&minKey, (void *)pDataCols->cols[0].pData, pDataCols->numOfRows, sizeof(TSKEY),
compTSKEY, TD_GE); compTSKEY, TD_GE);
ASSERT(ptr1 != NULL); ASSERT(ptr1 != NULL);
void *ptr2 = taosbsearch((void *)&maxKey, (void *)pDataCols->cols[0].pData, pDataCols->numOfPoints, sizeof(TSKEY), void *ptr2 = taosbsearch((void *)&maxKey, (void *)pDataCols->cols[0].pData, pDataCols->numOfRows, sizeof(TSKEY),
compTSKEY, TD_LE); compTSKEY, TD_LE);
ASSERT(ptr2 != NULL); ASSERT(ptr2 != NULL);
......
此差异已折叠。
...@@ -129,7 +129,7 @@ void taosArraySort(SArray* pArray, int (*compar)(const void*, const void*)); ...@@ -129,7 +129,7 @@ void taosArraySort(SArray* pArray, int (*compar)(const void*, const void*));
* sort string array * sort string array
* @param pArray * @param pArray
*/ */
void taosArraySortString(SArray* pArray); void taosArraySortString(SArray* pArray, __compar_fn_t comparFn);
/** /**
* search the array * search the array
...@@ -137,14 +137,14 @@ void taosArraySortString(SArray* pArray); ...@@ -137,14 +137,14 @@ void taosArraySortString(SArray* pArray);
* @param compar * @param compar
* @param key * @param key
*/ */
void* taosArraySearch(const SArray* pArray, int (*compar)(const void*, const void*), const void* key); void* taosArraySearch(const SArray* pArray, const void* key, __compar_fn_t comparFn);
/** /**
* search the array * search the array
* @param pArray * @param pArray
* @param key * @param key
*/ */
char* taosArraySearchString(const SArray* pArray, const char* key); char* taosArraySearchString(const SArray* pArray, const char* key, __compar_fn_t comparFn);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -34,16 +34,18 @@ typedef struct SPatternCompareInfo { ...@@ -34,16 +34,18 @@ typedef struct SPatternCompareInfo {
char matchOne; // symbol for match one wildcard, default: '_' char matchOne; // symbol for match one wildcard, default: '_'
} SPatternCompareInfo; } SPatternCompareInfo;
int patternMatch(const char *zPattern, const char *zString, size_t size, const SPatternCompareInfo *pInfo); int patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo);
int WCSPatternMatch(const wchar_t *zPattern, const wchar_t *zString, size_t size, const SPatternCompareInfo *pInfo); int WCSPatternMatch(const wchar_t *pattern, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo);
int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size); int32_t doCompare(const char* a, const char* b, int32_t type, size_t size);
__compar_fn_t getKeyComparFunc(int32_t keyType); __compar_fn_t getKeyComparFunc(int32_t keyType);
__compar_fn_t getComparFunc(int32_t type, int32_t optr); __compar_fn_t getComparFunc(int32_t type, int32_t optr);
int32_t taosArrayCompareString(const void* a, const void* b);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -197,30 +197,23 @@ void taosArraySort(SArray* pArray, int (*compar)(const void*, const void*)) { ...@@ -197,30 +197,23 @@ void taosArraySort(SArray* pArray, int (*compar)(const void*, const void*)) {
qsort(pArray->pData, pArray->size, pArray->elemSize, compar); qsort(pArray->pData, pArray->size, pArray->elemSize, compar);
} }
void* taosArraySearch(const SArray* pArray, int (*compar)(const void*, const void*), const void* key) { void* taosArraySearch(const SArray* pArray, const void* key, __compar_fn_t comparFn) {
assert(pArray != NULL); assert(pArray != NULL && comparFn != NULL);
assert(compar != NULL);
assert(key != NULL); assert(key != NULL);
return bsearch(key, pArray->pData, pArray->size, pArray->elemSize, compar); return bsearch(key, pArray->pData, pArray->size, pArray->elemSize, comparFn);
}
static int taosArrayCompareString(const void* a, const void* b) {
const char* x = *(const char**)a;
const char* y = *(const char**)b;
return strcmp(x, y);
} }
void taosArraySortString(SArray* pArray) { void taosArraySortString(SArray* pArray, __compar_fn_t comparFn) {
assert(pArray != NULL); assert(pArray != NULL);
qsort(pArray->pData, pArray->size, pArray->elemSize, taosArrayCompareString); qsort(pArray->pData, pArray->size, pArray->elemSize, comparFn);
} }
char* taosArraySearchString(const SArray* pArray, const char* key) { char* taosArraySearchString(const SArray* pArray, const char* key, __compar_fn_t comparFn) {
assert(pArray != NULL); assert(pArray != NULL);
assert(key != NULL); assert(key != NULL);
void* p = bsearch(&key, pArray->pData, pArray->size, pArray->elemSize, taosArrayCompareString); void* p = bsearch(&key, pArray->pData, pArray->size, pArray->elemSize, comparFn);
if (p == NULL) { if (p == NULL) {
return NULL; return NULL;
} }
......
...@@ -227,9 +227,16 @@ static int32_t compareStrPatternComp(const void* pLeft, const void* pRight) { ...@@ -227,9 +227,16 @@ static int32_t compareStrPatternComp(const void* pLeft, const void* pRight) {
return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; return (ret == TSDB_PATTERN_MATCH) ? 0 : 1;
} }
int32_t taosArrayCompareString(const void* a, const void* b) {
const char* x = *(const char**)a;
const char* y = *(const char**)b;
return compareLenPrefixedStr(x, y);
}
static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) { static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) {
const SArray* arr = (const SArray*) pRight; const SArray* arr = (const SArray*) pRight;
return taosArraySearchString(arr, pLeft) == NULL ? 0 : 1; return taosArraySearchString(arr, pLeft, taosArrayCompareString) == NULL ? 0 : 1;
} }
static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) {
...@@ -248,25 +255,25 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { ...@@ -248,25 +255,25 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
switch (type) { switch (type) {
case TSDB_DATA_TYPE_SMALLINT: { case TSDB_DATA_TYPE_SMALLINT: {
comparFn = compareInt16Val; break; comparFn = compareInt16Val; break;
} }
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
comparFn = compareInt32Val; break; comparFn = compareInt32Val; break;
} }
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_TIMESTAMP: { case TSDB_DATA_TYPE_TIMESTAMP: {
comparFn = compareInt64Val; break; comparFn = compareInt64Val; break;
} }
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT:{ case TSDB_DATA_TYPE_TINYINT:{
comparFn = compareInt8Val; break; comparFn = compareInt8Val; break;
} }
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
comparFn = compareFloatVal; break; comparFn = compareFloatVal; break;
} }
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
......
...@@ -29,7 +29,8 @@ class TDTestCase: ...@@ -29,7 +29,8 @@ class TDTestCase:
tdSql.prepare() tdSql.prepare()
tdLog.info("=============== step1") tdLog.info("=============== step1")
tdSql.execute('create table tb (ts timestamp, speed int, temp float, note binary(5), flag bool)') tdSql.execute(
'create table tb (ts timestamp, speed int, temp float, note binary(5), flag bool)')
numOfRecords = 0 numOfRecords = 0
randomList = [10, 50, 100, 500, 1000, 5000] randomList = [10, 50, 100, 500, 1000, 5000]
...@@ -38,23 +39,24 @@ class TDTestCase: ...@@ -38,23 +39,24 @@ class TDTestCase:
tdLog.info("will insert %d records" % num) tdLog.info("will insert %d records" % num)
for x in range(0, num): for x in range(0, num):
tdLog.info( tdLog.info(
'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % x) 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' %
x)
tdSql.execute( tdSql.execute(
'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % x) 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' %
x)
numOfRecords = numOfRecords + num numOfRecords = numOfRecords + num
tdSql.query("select * from tb") tdSql.query("select * from tb")
tdSql.checkRows(numOfRecords) tdSql.checkRows(numOfRecords)
tdSql.checkData(numOfRecords-num, 1, None) tdSql.checkData(numOfRecords - num, 1, None)
tdSql.checkData(numOfRecords-1, 2, None) tdSql.checkData(numOfRecords - 1, 2, None)
tdLog.info("stop dnode to commit data to disk") tdLog.info("stop dnode to commit data to disk")
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.start(1) tdDnodes.start(1)
tdLog.sleep(5) tdLog.sleep(5)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
tdSql.prepare()
tdLog.info("=============== step1")
tdSql.execute(
'create table tb (ts timestamp, speed int, temp float, note binary(4000), flag bool)')
numOfRecords = 1000000
dividend = 1000
tdLog.info("will insert %d records" % numOfRecords)
ts = 1500000000000
for i in range(0, numOfRecords):
if (i % dividend):
print(".", end="")
tdSql.execute(
'insert into tb values (%d + %da, NULL, NULL, NULL, TRUE)' %
(ts, i))
else:
print("a", end="")
tdSql.execute(
'insert into tb values (%d + %da, NULL, NULL, "a", FALSE)' %
(ts, i))
tdSql.query("select * from tb")
tdSql.checkRows(numOfRecords)
tdSql.checkData(numOfRecords - dividend, 3, 'a')
tdSql.checkData(numOfRecords - dividend - 1, 3, None)
tdLog.info("stop dnode to commit data to disk")
tdDnodes.stop(1)
tdLog.info("dnodes:%d size is %d" % (1, tdDnodes.getDataSize(1)))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -121,6 +121,7 @@ class Test: ...@@ -121,6 +121,7 @@ class Test:
tdDnodes.start(1) tdDnodes.start(1)
tdSql.prepare() tdSql.prepare()
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
......
...@@ -98,12 +98,16 @@ class TDTestCase: ...@@ -98,12 +98,16 @@ class TDTestCase:
# create a super table with name exceed max length # create a super table with name exceed max length
sname = self.generateString(maxTableNameLen + 1) sname = self.generateString(maxTableNameLen + 1)
tdLog.info("create a super table with length %d" % len(sname)) tdLog.info("create a super table with length %d" % len(sname))
tdSql.error("create table %s (ts timestamp, value int) tags(id int)" % sname) tdSql.error(
"create table %s (ts timestamp, value int) tags(id int)" %
sname)
# create a super table with name of max length # create a super table with name of max length
sname = self.generateString(maxTableNameLen) sname = self.generateString(maxTableNameLen)
tdLog.info("create a super table with length %d" % len(sname)) tdLog.info("create a super table with length %d" % len(sname))
tdSql.execute("create table %s (ts timestamp, value int) tags(id int)" % sname) tdSql.execute(
"create table %s (ts timestamp, value int) tags(id int)" %
sname)
tdLog.info("check table count, should be one") tdLog.info("check table count, should be one")
tdSql.query('show stables') tdSql.query('show stables')
tdSql.checkRows(1) tdSql.checkRows(1)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -82,10 +82,10 @@ class TDTestCase: ...@@ -82,10 +82,10 @@ class TDTestCase:
(tb, ms, x)) (tb, ms, x))
# TSIM: $x = $x + 1 # TSIM: $x = $x + 1
x = x + 1 x = x + 1
#TSIM: endw # TSIM: endw
# TSIM: $i = $i + 1 # TSIM: $i = $i + 1
i = i + 1 i = i + 1
#TSIM: endw # TSIM: endw
# TSIM: while $i < 10 # TSIM: while $i < 10
while (i < 10): while (i < 10):
# TSIM: $tb = $tbPrefix . $i # TSIM: $tb = $tbPrefix . $i
...@@ -108,10 +108,10 @@ class TDTestCase: ...@@ -108,10 +108,10 @@ class TDTestCase:
(tb, ms, x)) (tb, ms, x))
# TSIM: $x = $x + 1 # TSIM: $x = $x + 1
x = x + 1 x = x + 1
#TSIM: endw # TSIM: endw
# TSIM: $i = $i + 1 # TSIM: $i = $i + 1
i = i + 1 i = i + 1
#TSIM: endw # TSIM: endw
# TSIM: # TSIM:
# TSIM: print =============== step2 # TSIM: print =============== step2
tdLog.info('=============== step2') tdLog.info('=============== step2')
...@@ -123,7 +123,7 @@ class TDTestCase: ...@@ -123,7 +123,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow($rowNum)') tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum) tdSql.checkRows(rowNum)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m # TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb)) tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb)) tdSql.query('select * from %s where ts < now + 4m' % (tb))
...@@ -131,7 +131,7 @@ class TDTestCase: ...@@ -131,7 +131,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m # TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb)) tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb)) tdSql.query('select * from %s where ts <= now + 4m' % (tb))
...@@ -139,7 +139,7 @@ class TDTestCase: ...@@ -139,7 +139,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m # TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb)) tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb)) tdSql.query('select * from %s where ts > now + 4m' % (tb))
...@@ -147,7 +147,7 @@ class TDTestCase: ...@@ -147,7 +147,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(15)') tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15) tdSql.checkRows(15)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m # TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb)) tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb)) tdSql.query('select * from %s where ts >= now + 4m' % (tb))
...@@ -155,7 +155,7 @@ class TDTestCase: ...@@ -155,7 +155,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(15)') tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15) tdSql.checkRows(15)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' % 'select * from %s where ts > now + 4m and ts < now + 5m' %
...@@ -167,7 +167,7 @@ class TDTestCase: ...@@ -167,7 +167,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(1)') tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1) tdSql.checkRows(1)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info( tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' % 'select * from %s where ts < now + 4m and ts > now + 5m' %
...@@ -179,7 +179,7 @@ class TDTestCase: ...@@ -179,7 +179,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000 # TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query( tdSql.query(
...@@ -189,7 +189,7 @@ class TDTestCase: ...@@ -189,7 +189,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' % 'select * from %s where ts > now + 4m and ts < now + 3m' %
...@@ -201,7 +201,7 @@ class TDTestCase: ...@@ -201,7 +201,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m # ts < now + 6m
tdLog.info( tdLog.info(
...@@ -214,7 +214,7 @@ class TDTestCase: ...@@ -214,7 +214,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(1)') tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1) tdSql.checkRows(1)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step3 # TSIM: print =============== step3
tdLog.info('=============== step3') tdLog.info('=============== step3')
...@@ -225,7 +225,7 @@ class TDTestCase: ...@@ -225,7 +225,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow($totalNum)') tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum) tdSql.checkRows(totalNum)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: sql select * from $mt where ts < now + 4m # TSIM: sql select * from $mt where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (mt)) tdLog.info('select * from %s where ts < now + 4m' % (mt))
...@@ -234,7 +234,7 @@ class TDTestCase: ...@@ -234,7 +234,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(50)') tdLog.info('tdSql.checkRow(50)')
tdSql.checkRows(50) tdSql.checkRows(50)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m # TSIM: sql select * from $mt where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (mt)) tdLog.info('select * from %s where ts > now + 4m' % (mt))
tdSql.query('select * from %s where ts > now + 4m' % (mt)) tdSql.query('select * from %s where ts > now + 4m' % (mt))
...@@ -242,7 +242,7 @@ class TDTestCase: ...@@ -242,7 +242,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(150)') tdLog.info('tdSql.checkRow(150)')
tdSql.checkRows(150) tdSql.checkRows(150)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts = now + 4m # TSIM: sql select * from $mt where ts = now + 4m
tdLog.info('select * from %s where ts = now + 4m' % (mt)) tdLog.info('select * from %s where ts = now + 4m' % (mt))
tdSql.query('select * from %s where ts = now + 4m' % (mt)) tdSql.query('select * from %s where ts = now + 4m' % (mt))
...@@ -250,7 +250,7 @@ class TDTestCase: ...@@ -250,7 +250,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' % 'select * from %s where ts > now + 4m and ts < now + 5m' %
...@@ -262,7 +262,7 @@ class TDTestCase: ...@@ -262,7 +262,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(10)') tdLog.info('tdSql.checkRow(10)')
tdSql.checkRows(10) tdSql.checkRows(10)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step4 # TSIM: print =============== step4
tdLog.info('=============== step4') tdLog.info('=============== step4')
...@@ -273,7 +273,7 @@ class TDTestCase: ...@@ -273,7 +273,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0 # TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt)) tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt)) tdSql.query('select * from %s where tgcol <> 0' % (mt))
...@@ -281,7 +281,7 @@ class TDTestCase: ...@@ -281,7 +281,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1 # TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt)) tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt)) tdSql.query('select * from %s where tgcol = 1' % (mt))
...@@ -289,7 +289,7 @@ class TDTestCase: ...@@ -289,7 +289,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1 # TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt)) tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt)) tdSql.query('select * from %s where tgcol <> 1' % (mt))
...@@ -297,7 +297,7 @@ class TDTestCase: ...@@ -297,7 +297,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1 # TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt)) tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt)) tdSql.query('select * from %s where tgcol = 1' % (mt))
...@@ -305,7 +305,7 @@ class TDTestCase: ...@@ -305,7 +305,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1 # TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt)) tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt)) tdSql.query('select * from %s where tgcol <> 1' % (mt))
...@@ -313,7 +313,7 @@ class TDTestCase: ...@@ -313,7 +313,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0 # TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt)) tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt)) tdSql.query('select * from %s where tgcol = 0' % (mt))
...@@ -321,7 +321,7 @@ class TDTestCase: ...@@ -321,7 +321,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0 # TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt)) tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt)) tdSql.query('select * from %s where tgcol <> 0' % (mt))
...@@ -329,7 +329,7 @@ class TDTestCase: ...@@ -329,7 +329,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step5 # TSIM: print =============== step5
tdLog.info('=============== step5') tdLog.info('=============== step5')
...@@ -342,7 +342,7 @@ class TDTestCase: ...@@ -342,7 +342,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(75)') tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75) tdSql.checkRows(75)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1 # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 1
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> 1' % 'select * from %s where ts > now + 4m and tgcol <> 1' %
...@@ -354,7 +354,7 @@ class TDTestCase: ...@@ -354,7 +354,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(75)') tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75) tdSql.checkRows(75)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0 # TSIM: sql select * from $mt where ts < now + 4m and tgcol = 0
tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt)) tdLog.info('select * from %s where ts < now + 4m and tgcol = 0' % (mt))
tdSql.query( tdSql.query(
...@@ -364,7 +364,7 @@ class TDTestCase: ...@@ -364,7 +364,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0 # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> 0
tdLog.info( tdLog.info(
'select * from %s where ts < now + 4m and tgcol <> 0' % 'select * from %s where ts < now + 4m and tgcol <> 0' %
...@@ -376,7 +376,7 @@ class TDTestCase: ...@@ -376,7 +376,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0 # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = 0
tdLog.info( tdLog.info(
'select * from %s where ts <= now + 4m and tgcol = 0' % 'select * from %s where ts <= now + 4m and tgcol = 0' %
...@@ -388,7 +388,7 @@ class TDTestCase: ...@@ -388,7 +388,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0 # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> 0
tdLog.info( tdLog.info(
'select * from %s where ts <= now + 4m and tgcol <> 0' % 'select * from %s where ts <= now + 4m and tgcol <> 0' %
...@@ -400,7 +400,7 @@ class TDTestCase: ...@@ -400,7 +400,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
# tgcol <> 0 # tgcol <> 0
tdLog.info( tdLog.info(
...@@ -413,7 +413,7 @@ class TDTestCase: ...@@ -413,7 +413,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> 0 and ts
# < now + 5m # < now + 5m
tdLog.info( tdLog.info(
...@@ -426,7 +426,7 @@ class TDTestCase: ...@@ -426,7 +426,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step6 # TSIM: print =============== step6
tdLog.info('=============== step6') tdLog.info('=============== step6')
...@@ -444,7 +444,7 @@ class TDTestCase: ...@@ -444,7 +444,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 200)') tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200) tdSql.checkData(0, 0, 200)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step7 # TSIM: print =============== step7
tdLog.info('=============== step7') tdLog.info('=============== step7')
...@@ -462,7 +462,7 @@ class TDTestCase: ...@@ -462,7 +462,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step8 # TSIM: print =============== step8
tdLog.info('=============== step8') tdLog.info('=============== step8')
...@@ -480,7 +480,7 @@ class TDTestCase: ...@@ -480,7 +480,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 50)') tdLog.info('tdSql.checkData(0, 0, 50)')
tdSql.checkData(0, 0, 50) tdSql.checkData(0, 0, 50)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step9 # TSIM: print =============== step9
tdLog.info('=============== step9') tdLog.info('=============== step9')
...@@ -498,7 +498,7 @@ class TDTestCase: ...@@ -498,7 +498,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step10 # TSIM: print =============== step10
tdLog.info('=============== step10') tdLog.info('=============== step10')
...@@ -517,7 +517,7 @@ class TDTestCase: ...@@ -517,7 +517,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step11 # TSIM: print =============== step11
tdLog.info('=============== step11') tdLog.info('=============== step11')
...@@ -536,7 +536,7 @@ class TDTestCase: ...@@ -536,7 +536,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 25)') tdLog.info('tdSql.checkData(0, 0, 25)')
tdSql.checkData(0, 0, 25) tdSql.checkData(0, 0, 25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: # TSIM:
# TSIM: print =============== step12 # TSIM: print =============== step12
...@@ -556,7 +556,7 @@ class TDTestCase: ...@@ -556,7 +556,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 1, 100)') tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100) tdSql.checkData(0, 1, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== clear # TSIM: print =============== clear
tdLog.info('=============== clear') tdLog.info('=============== clear')
...@@ -570,7 +570,7 @@ class TDTestCase: ...@@ -570,7 +570,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end # convert end
......
...@@ -82,10 +82,10 @@ class TDTestCase: ...@@ -82,10 +82,10 @@ class TDTestCase:
(tb, ms, x)) (tb, ms, x))
# TSIM: $x = $x + 1 # TSIM: $x = $x + 1
x = x + 1 x = x + 1
#TSIM: endw # TSIM: endw
# TSIM: $i = $i + 1 # TSIM: $i = $i + 1
i = i + 1 i = i + 1
#TSIM: endw # TSIM: endw
# TSIM: while $i < 10 # TSIM: while $i < 10
while (i < 10): while (i < 10):
# TSIM: $tb = $tbPrefix . $i # TSIM: $tb = $tbPrefix . $i
...@@ -108,10 +108,10 @@ class TDTestCase: ...@@ -108,10 +108,10 @@ class TDTestCase:
(tb, ms, x)) (tb, ms, x))
# TSIM: $x = $x + 1 # TSIM: $x = $x + 1
x = x + 1 x = x + 1
#TSIM: endw # TSIM: endw
# TSIM: $i = $i + 1 # TSIM: $i = $i + 1
i = i + 1 i = i + 1
#TSIM: endw # TSIM: endw
# TSIM: # TSIM:
# TSIM: print =============== step2 # TSIM: print =============== step2
tdLog.info('=============== step2') tdLog.info('=============== step2')
...@@ -123,7 +123,7 @@ class TDTestCase: ...@@ -123,7 +123,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow($rowNum)') tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum) tdSql.checkRows(rowNum)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m # TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb)) tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb)) tdSql.query('select * from %s where ts < now + 4m' % (tb))
...@@ -131,7 +131,7 @@ class TDTestCase: ...@@ -131,7 +131,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m # TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb)) tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb)) tdSql.query('select * from %s where ts <= now + 4m' % (tb))
...@@ -139,7 +139,7 @@ class TDTestCase: ...@@ -139,7 +139,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m # TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb)) tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb)) tdSql.query('select * from %s where ts > now + 4m' % (tb))
...@@ -147,7 +147,7 @@ class TDTestCase: ...@@ -147,7 +147,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(15)') tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15) tdSql.checkRows(15)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m # TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb)) tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb)) tdSql.query('select * from %s where ts >= now + 4m' % (tb))
...@@ -155,7 +155,7 @@ class TDTestCase: ...@@ -155,7 +155,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(15)') tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15) tdSql.checkRows(15)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' % 'select * from %s where ts > now + 4m and ts < now + 5m' %
...@@ -167,7 +167,7 @@ class TDTestCase: ...@@ -167,7 +167,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(1)') tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1) tdSql.checkRows(1)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m # TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info( tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' % 'select * from %s where ts < now + 4m and ts > now + 5m' %
...@@ -179,7 +179,7 @@ class TDTestCase: ...@@ -179,7 +179,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000 # TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb)) tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query( tdSql.query(
...@@ -189,7 +189,7 @@ class TDTestCase: ...@@ -189,7 +189,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m # TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' % 'select * from %s where ts > now + 4m and ts < now + 3m' %
...@@ -201,7 +201,7 @@ class TDTestCase: ...@@ -201,7 +201,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and # TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m # ts < now + 6m
tdLog.info( tdLog.info(
...@@ -214,7 +214,7 @@ class TDTestCase: ...@@ -214,7 +214,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(1)') tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1) tdSql.checkRows(1)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step3 # TSIM: print =============== step3
tdLog.info('=============== step3') tdLog.info('=============== step3')
...@@ -225,7 +225,7 @@ class TDTestCase: ...@@ -225,7 +225,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow($totalNum)') tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum) tdSql.checkRows(totalNum)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: sql select * from $mt where ts < now + 4m # TSIM: sql select * from $mt where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (mt)) tdLog.info('select * from %s where ts < now + 4m' % (mt))
...@@ -234,7 +234,7 @@ class TDTestCase: ...@@ -234,7 +234,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(50)') tdLog.info('tdSql.checkRow(50)')
tdSql.checkRows(50) tdSql.checkRows(50)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m # TSIM: sql select * from $mt where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (mt)) tdLog.info('select * from %s where ts > now + 4m' % (mt))
tdSql.query('select * from %s where ts > now + 4m' % (mt)) tdSql.query('select * from %s where ts > now + 4m' % (mt))
...@@ -242,7 +242,7 @@ class TDTestCase: ...@@ -242,7 +242,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(150)') tdLog.info('tdSql.checkRow(150)')
tdSql.checkRows(150) tdSql.checkRows(150)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts = now + 4m # TSIM: sql select * from $mt where ts = now + 4m
tdLog.info('select * from %s where ts = now + 4m' % (mt)) tdLog.info('select * from %s where ts = now + 4m' % (mt))
tdSql.query('select * from %s where ts = now + 4m' % (mt)) tdSql.query('select * from %s where ts = now + 4m' % (mt))
...@@ -250,7 +250,7 @@ class TDTestCase: ...@@ -250,7 +250,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' % 'select * from %s where ts > now + 4m and ts < now + 5m' %
...@@ -262,7 +262,7 @@ class TDTestCase: ...@@ -262,7 +262,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(10)') tdLog.info('tdSql.checkRow(10)')
tdSql.checkRows(10) tdSql.checkRows(10)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step4 # TSIM: print =============== step4
tdLog.info('=============== step4') tdLog.info('=============== step4')
...@@ -273,7 +273,7 @@ class TDTestCase: ...@@ -273,7 +273,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '0' # TSIM: sql select * from $mt where tgcol <> '0'
tdLog.info('select * from %s where tgcol <> "0"' % (mt)) tdLog.info('select * from %s where tgcol <> "0"' % (mt))
tdSql.query('select * from %s where tgcol <> "0"' % (mt)) tdSql.query('select * from %s where tgcol <> "0"' % (mt))
...@@ -281,7 +281,7 @@ class TDTestCase: ...@@ -281,7 +281,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol = '1' # TSIM: sql select * from $mt where tgcol = '1'
tdLog.info('select * from %s where tgcol = "1"' % (mt)) tdLog.info('select * from %s where tgcol = "1"' % (mt))
tdSql.query('select * from %s where tgcol = "1"' % (mt)) tdSql.query('select * from %s where tgcol = "1"' % (mt))
...@@ -289,7 +289,7 @@ class TDTestCase: ...@@ -289,7 +289,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '1' # TSIM: sql select * from $mt where tgcol <> '1'
tdLog.info('select * from %s where tgcol <> "1"' % (mt)) tdLog.info('select * from %s where tgcol <> "1"' % (mt))
tdSql.query('select * from %s where tgcol <> "1"' % (mt)) tdSql.query('select * from %s where tgcol <> "1"' % (mt))
...@@ -297,7 +297,7 @@ class TDTestCase: ...@@ -297,7 +297,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol = '1' # TSIM: sql select * from $mt where tgcol = '1'
tdLog.info('select * from %s where tgcol = "1"' % (mt)) tdLog.info('select * from %s where tgcol = "1"' % (mt))
tdSql.query('select * from %s where tgcol = "1"' % (mt)) tdSql.query('select * from %s where tgcol = "1"' % (mt))
...@@ -305,7 +305,7 @@ class TDTestCase: ...@@ -305,7 +305,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '1' # TSIM: sql select * from $mt where tgcol <> '1'
tdLog.info('select * from %s where tgcol <> "1"' % (mt)) tdLog.info('select * from %s where tgcol <> "1"' % (mt))
tdSql.query('select * from %s where tgcol <> "1"' % (mt)) tdSql.query('select * from %s where tgcol <> "1"' % (mt))
...@@ -313,7 +313,7 @@ class TDTestCase: ...@@ -313,7 +313,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol = '0' # TSIM: sql select * from $mt where tgcol = '0'
tdLog.info('select * from %s where tgcol = "0"' % (mt)) tdLog.info('select * from %s where tgcol = "0"' % (mt))
tdSql.query('select * from %s where tgcol = "0"' % (mt)) tdSql.query('select * from %s where tgcol = "0"' % (mt))
...@@ -321,7 +321,7 @@ class TDTestCase: ...@@ -321,7 +321,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '0' # TSIM: sql select * from $mt where tgcol <> '0'
tdLog.info('select * from %s where tgcol <> "0"' % (mt)) tdLog.info('select * from %s where tgcol <> "0"' % (mt))
tdSql.query('select * from %s where tgcol <> "0"' % (mt)) tdSql.query('select * from %s where tgcol <> "0"' % (mt))
...@@ -329,7 +329,7 @@ class TDTestCase: ...@@ -329,7 +329,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(100)') tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100) tdSql.checkRows(100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step5 # TSIM: print =============== step5
tdLog.info('=============== step5') tdLog.info('=============== step5')
...@@ -344,7 +344,7 @@ class TDTestCase: ...@@ -344,7 +344,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(75)') tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75) tdSql.checkRows(75)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '1' # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '1'
tdLog.info( tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> "1"' % 'select * from %s where ts > now + 4m and tgcol <> "1"' %
...@@ -356,7 +356,7 @@ class TDTestCase: ...@@ -356,7 +356,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(75)') tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75) tdSql.checkRows(75)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol = '0' # TSIM: sql select * from $mt where ts < now + 4m and tgcol = '0'
tdLog.info( tdLog.info(
'select * from %s where ts < now + 4m and tgcol = "0"' % 'select * from %s where ts < now + 4m and tgcol = "0"' %
...@@ -368,7 +368,7 @@ class TDTestCase: ...@@ -368,7 +368,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol <> '0' # TSIM: sql select * from $mt where ts < now + 4m and tgcol <> '0'
tdLog.info( tdLog.info(
'select * from %s where ts < now + 4m and tgcol <> "0"' % 'select * from %s where ts < now + 4m and tgcol <> "0"' %
...@@ -380,7 +380,7 @@ class TDTestCase: ...@@ -380,7 +380,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol = '0' # TSIM: sql select * from $mt where ts <= now + 4m and tgcol = '0'
tdLog.info( tdLog.info(
'select * from %s where ts <= now + 4m and tgcol = "0"' % 'select * from %s where ts <= now + 4m and tgcol = "0"' %
...@@ -392,7 +392,7 @@ class TDTestCase: ...@@ -392,7 +392,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> '0' # TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> '0'
tdLog.info( tdLog.info(
'select * from %s where ts <= now + 4m and tgcol <> "0"' % 'select * from %s where ts <= now + 4m and tgcol <> "0"' %
...@@ -404,7 +404,7 @@ class TDTestCase: ...@@ -404,7 +404,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(25)') tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25) tdSql.checkRows(25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
# tgcol <> '0' # tgcol <> '0'
tdLog.info( tdLog.info(
...@@ -417,7 +417,7 @@ class TDTestCase: ...@@ -417,7 +417,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '0' and # TSIM: sql select * from $mt where ts > now + 4m and tgcol <> '0' and
# ts < now + 5m # ts < now + 5m
tdLog.info( tdLog.info(
...@@ -430,7 +430,7 @@ class TDTestCase: ...@@ -430,7 +430,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(5)') tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5) tdSql.checkRows(5)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step6 # TSIM: print =============== step6
tdLog.info('=============== step6') tdLog.info('=============== step6')
...@@ -448,7 +448,7 @@ class TDTestCase: ...@@ -448,7 +448,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 200)') tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200) tdSql.checkData(0, 0, 200)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step7 # TSIM: print =============== step7
tdLog.info('=============== step7') tdLog.info('=============== step7')
...@@ -466,7 +466,7 @@ class TDTestCase: ...@@ -466,7 +466,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step8 # TSIM: print =============== step8
tdLog.info('=============== step8') tdLog.info('=============== step8')
...@@ -484,7 +484,7 @@ class TDTestCase: ...@@ -484,7 +484,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 50)') tdLog.info('tdSql.checkData(0, 0, 50)')
tdSql.checkData(0, 0, 50) tdSql.checkData(0, 0, 50)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step9 # TSIM: print =============== step9
tdLog.info('=============== step9') tdLog.info('=============== step9')
...@@ -502,7 +502,7 @@ class TDTestCase: ...@@ -502,7 +502,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step10 # TSIM: print =============== step10
tdLog.info('=============== step10') tdLog.info('=============== step10')
...@@ -521,7 +521,7 @@ class TDTestCase: ...@@ -521,7 +521,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step11 # TSIM: print =============== step11
tdLog.info('=============== step11') tdLog.info('=============== step11')
...@@ -540,7 +540,7 @@ class TDTestCase: ...@@ -540,7 +540,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 0, 25)') tdLog.info('tdSql.checkData(0, 0, 25)')
tdSql.checkData(0, 0, 25) tdSql.checkData(0, 0, 25)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: # TSIM:
# TSIM: print =============== step12 # TSIM: print =============== step12
...@@ -560,7 +560,7 @@ class TDTestCase: ...@@ -560,7 +560,7 @@ class TDTestCase:
tdLog.info('tdSql.checkData(0, 1, 100)') tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100) tdSql.checkData(0, 1, 100)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== clear # TSIM: print =============== clear
tdLog.info('=============== clear') tdLog.info('=============== clear')
...@@ -574,7 +574,7 @@ class TDTestCase: ...@@ -574,7 +574,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end # convert end
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -103,7 +103,7 @@ class TDTestCase: ...@@ -103,7 +103,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(4)') tdLog.info('tdSql.checkRow(4)')
tdSql.checkRows(4) tdSql.checkRows(4)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step3 # TSIM: print =============== step3
tdLog.info('=============== step3') tdLog.info('=============== step3')
...@@ -149,7 +149,7 @@ class TDTestCase: ...@@ -149,7 +149,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(1)') tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1) tdSql.checkRows(1)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== step5 # TSIM: print =============== step5
tdLog.info('=============== step5') tdLog.info('=============== step5')
...@@ -160,7 +160,7 @@ class TDTestCase: ...@@ -160,7 +160,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(4)') tdLog.info('tdSql.checkRow(4)')
tdSql.checkRows(4) tdSql.checkRows(4)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: sql select * from $mt where tgcol = 1 # TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt)) tdLog.info('select * from %s where tgcol = 1' % (mt))
...@@ -169,7 +169,7 @@ class TDTestCase: ...@@ -169,7 +169,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(1)') tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1) tdSql.checkRows(1)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: print =============== clear # TSIM: print =============== clear
tdLog.info('=============== clear') tdLog.info('=============== clear')
...@@ -183,7 +183,7 @@ class TDTestCase: ...@@ -183,7 +183,7 @@ class TDTestCase:
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
# TSIM: return -1 # TSIM: return -1
#TSIM: endi # TSIM: endi
# TSIM: # TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end # convert end
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -99,6 +99,19 @@ class TDDnode: ...@@ -99,6 +99,19 @@ class TDDnode:
def setValgrind(self, value): def setValgrind(self, value):
self.valgrind = value self.valgrind = value
def getDataSize(self):
totalSize = 0
if (self.deployed == 1):
for dirpath, dirnames, filenames in os.walk(self.dataDir):
for f in filenames:
fp = os.path.join(dirpath, f)
if not os.path.islink(fp):
totalSize = totalSize + os.path.getsize(fp)
return totalSize
def deploy(self): def deploy(self):
self.logDir = "%s/pysim/dnode%d/log" % (self.path, self.index) self.logDir = "%s/pysim/dnode%d/log" % (self.path, self.index)
self.dataDir = "%s/pysim/dnode%d/data" % (self.path, self.index) self.dataDir = "%s/pysim/dnode%d/data" % (self.path, self.index)
...@@ -384,6 +397,10 @@ class TDDnodes: ...@@ -384,6 +397,10 @@ class TDDnodes:
self.check(index) self.check(index)
self.dnodes[index - 1].stop() self.dnodes[index - 1].stop()
def getDataSize(self, index):
self.check(index)
return self.dnodes[index - 1].getDataSize()
def forcestop(self, index): def forcestop(self, index):
self.check(index) self.check(index)
self.dnodes[index - 1].forcestop() self.dnodes[index - 1].forcestop()
......
...@@ -104,14 +104,14 @@ $replica = 1 # max=3 ...@@ -104,14 +104,14 @@ $replica = 1 # max=3
$days = 10 $days = 10
$keep = 365 $keep = 365
$rows_db = 1000 $rows_db = 1000
$cache = 4096 # 4 kb $cache = 16 # 16MB
$ablocks = 100 $ablocks = 100
$tblocks = 32 # max=512, automatically trimmed when exceeding $tblocks = 32 # max=512, automatically trimmed when exceeding
$ctime = 36000 # 10 hours $ctime = 36000 # 10 hours
$wal = 0 # valid value is 0, 1, 2 $wal = 0 # valid value is 0, 1, 2
$comp = 1 # max=32, automatically trimmed when exceeding $comp = 1 # max=32, automatically trimmed when exceeding
sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache ablocks $ablocks tblocks $tblocks ctime $ctime wal $wal comp $comp sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache ctime $ctime wal $wal comp $comp
sql show databases sql show databases
if $rows != 1 then if $rows != 1 then
return -1 return -1
......
...@@ -36,6 +36,7 @@ if $data01 != 2 then ...@@ -36,6 +36,7 @@ if $data01 != 2 then
return -1 return -1
endi endi
if $data02 != tb2 then if $data02 != tb2 then
print expect tb2, actual: $data02
return -1 return -1
endi endi
if $data03 != tb2 then if $data03 != tb2 then
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册