Merge branch 'develop' into metadataQuery
This commit is contained in:
commit
805ed72e9c
|
@ -618,7 +618,7 @@ typedef struct {
|
||||||
} SMDVnodeDesc;
|
} SMDVnodeDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_NAME_LEN];
|
char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN];
|
||||||
SMDVnodeCfg cfg;
|
SMDVnodeCfg cfg;
|
||||||
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
SMDVnodeDesc nodes[TSDB_MAX_REPLICA];
|
||||||
} SMDCreateVnodeMsg;
|
} SMDCreateVnodeMsg;
|
||||||
|
|
|
@ -132,7 +132,7 @@ typedef struct SVgObj {
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int32_t lbDnodeId;
|
int32_t lbDnodeId;
|
||||||
int32_t lbTime;
|
int32_t lbTime;
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
char dbName[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN];
|
||||||
int8_t inUse;
|
int8_t inUse;
|
||||||
int8_t accessState;
|
int8_t accessState;
|
||||||
int8_t reserved0[5];
|
int8_t reserved0[5];
|
||||||
|
|
|
@ -367,6 +367,7 @@ void sdbCleanUp() {
|
||||||
tsSdbObj.status = SDB_STATUS_CLOSING;
|
tsSdbObj.status = SDB_STATUS_CLOSING;
|
||||||
|
|
||||||
sdbCleanupWriteWorker();
|
sdbCleanupWriteWorker();
|
||||||
|
sdbDebug("sdb will be closed, version:%" PRId64, tsSdbObj.version);
|
||||||
|
|
||||||
if (tsSdbObj.sync) {
|
if (tsSdbObj.sync) {
|
||||||
syncStop(tsSdbObj.sync);
|
syncStop(tsSdbObj.sync);
|
||||||
|
|
|
@ -281,6 +281,7 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
||||||
SCMConnectMsg *pConnectMsg = pMsg->rpcMsg.pCont;
|
SCMConnectMsg *pConnectMsg = pMsg->rpcMsg.pCont;
|
||||||
|
SCMConnectRsp *pConnectRsp = NULL;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SRpcConnInfo connInfo;
|
SRpcConnInfo connInfo;
|
||||||
|
@ -309,7 +310,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
||||||
mnodeDecDbRef(pDb);
|
mnodeDecDbRef(pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCMConnectRsp *pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp));
|
pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp));
|
||||||
if (pConnectRsp == NULL) {
|
if (pConnectRsp == NULL) {
|
||||||
code = TSDB_CODE_MND_OUT_OF_MEMORY;
|
code = TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
goto connect_over;
|
goto connect_over;
|
||||||
|
@ -332,7 +333,7 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
connect_over:
|
connect_over:
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
rpcFreeCont(pConnectRsp);
|
if (pConnectRsp) rpcFreeCont(pConnectRsp);
|
||||||
mLError("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
mLError("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
mLInfo("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
mLInfo("user:%s login from %s, result:%s", connInfo.user, taosIpStr(connInfo.clientIp), tstrerror(code));
|
||||||
|
|
|
@ -457,10 +457,9 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
|
||||||
free(pNew);
|
free(pNew);
|
||||||
free(oldTableId);
|
free(oldTableId);
|
||||||
free(oldSchema);
|
free(oldSchema);
|
||||||
|
|
||||||
mnodeDecTableRef(pTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mnodeDecTableRef(pTable);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2374,6 +2373,17 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
strcat(prefix, TS_PATH_DELIMITER);
|
strcat(prefix, TS_PATH_DELIMITER);
|
||||||
int32_t prefixLen = strlen(prefix);
|
int32_t prefixLen = strlen(prefix);
|
||||||
|
|
||||||
|
char* pattern = NULL;
|
||||||
|
if (pShow->payloadLen > 0) {
|
||||||
|
pattern = (char*)malloc(pShow->payloadLen + 1);
|
||||||
|
if (pattern == NULL) {
|
||||||
|
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memcpy(pattern, pShow->payload, pShow->payloadLen);
|
||||||
|
pattern[pShow->payloadLen] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pShow->pIter = mnodeGetNextChildTable(pShow->pIter, &pTable);
|
pShow->pIter = mnodeGetNextChildTable(pShow->pIter, &pTable);
|
||||||
if (pTable == NULL) break;
|
if (pTable == NULL) break;
|
||||||
|
@ -2389,7 +2399,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
// pattern compare for table name
|
// pattern compare for table name
|
||||||
mnodeExtractTableName(pTable->info.tableId, tableName);
|
mnodeExtractTableName(pTable->info.tableId, tableName);
|
||||||
|
|
||||||
if (pShow->payloadLen > 0 && patternMatch(pShow->payload, tableName, sizeof(tableName) - 1, &info) != TSDB_PATTERN_MATCH) {
|
if (pattern != NULL && patternMatch(pattern, tableName, sizeof(tableName) - 1, &info) != TSDB_PATTERN_MATCH) {
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2433,6 +2443,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
|
|
||||||
mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow);
|
||||||
mnodeDecDbRef(pDb);
|
mnodeDecDbRef(pDb);
|
||||||
|
free(pattern);
|
||||||
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,7 +358,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) {
|
||||||
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
||||||
|
|
||||||
SVgObj *pVgroup = (SVgObj *)calloc(1, sizeof(SVgObj));
|
SVgObj *pVgroup = (SVgObj *)calloc(1, sizeof(SVgObj));
|
||||||
tstrncpy(pVgroup->dbName, pDb->name, TSDB_DB_NAME_LEN);
|
tstrncpy(pVgroup->dbName, pDb->name, TSDB_ACCT_LEN + TSDB_DB_NAME_LEN);
|
||||||
pVgroup->numOfVnodes = pDb->cfg.replications;
|
pVgroup->numOfVnodes = pDb->cfg.replications;
|
||||||
pVgroup->createdTime = taosGetTimestampMs();
|
pVgroup->createdTime = taosGetTimestampMs();
|
||||||
pVgroup->accessState = TSDB_VN_ALL_ACCCESS;
|
pVgroup->accessState = TSDB_VN_ALL_ACCCESS;
|
||||||
|
|
|
@ -6009,7 +6009,7 @@ void qDestroyQueryInfo(qinfo_t qHandle, void (*fp)(void*), void* param) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t ref = T_REF_DEC(pQInfo);
|
int32_t ref = T_REF_DEC(pQInfo);
|
||||||
qDebug("QInfo:%p dec refCount, value:%d", pQInfo, ref);
|
qDebug("QInfo:%p dec refCount, value:%d", pQInfo, ref);
|
||||||
|
|
||||||
if (ref == 0) {
|
if (ref == 0) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
|
||||||
ASSERT(pTableData->numOfRows == tSkipListGetSize(pTableData->pData));
|
ASSERT(pTableData->numOfRows == tSkipListGetSize(pTableData->pData));
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d a row is inserted to table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
|
tsdbTrace("vgId:%d a row is inserted to table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
|
||||||
TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable), key);
|
TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable), key);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -550,13 +550,13 @@ int tsdbUnlockRepoMeta(STsdbRepo *pRepo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbRefTable(STable *pTable) {
|
void tsdbRefTable(STable *pTable) {
|
||||||
int16_t ref = T_REF_INC(pTable);
|
int32_t ref = T_REF_INC(pTable);
|
||||||
UNUSED(ref);
|
UNUSED(ref);
|
||||||
// tsdbDebug("ref table %"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
// tsdbDebug("ref table %"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbUnRefTable(STable *pTable) {
|
void tsdbUnRefTable(STable *pTable) {
|
||||||
int16_t ref = T_REF_DEC(pTable);
|
int32_t ref = T_REF_DEC(pTable);
|
||||||
tsdbDebug("unref table uid:%"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
tsdbDebug("unref table uid:%"PRIu64", tid:%d, refCount:%d", TABLE_UID(pTable), TABLE_TID(pTable), ref);
|
||||||
|
|
||||||
if (ref == 0) {
|
if (ref == 0) {
|
||||||
|
@ -596,7 +596,7 @@ static int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d table %s tid %d uid %" PRIu64 " is restored from file", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
tsdbTrace("vgId:%d table %s tid %d uid %" PRIu64 " is restored from file", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
||||||
TABLE_TID(pTable), TABLE_UID(pTable));
|
TABLE_TID(pTable), TABLE_UID(pTable));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx) {
|
||||||
pTable->cqhandle = (*pRepo->appH.cqCreateFunc)(pRepo->appH.cqH, TABLE_UID(pTable), TABLE_TID(pTable), pTable->sql, tsdbGetTableSchema(pTable));
|
pTable->cqhandle = (*pRepo->appH.cqCreateFunc)(pRepo->appH.cqH, TABLE_UID(pTable), TABLE_TID(pTable), pTable->sql, tsdbGetTableSchema(pTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
tsdbTrace("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
|
||||||
TABLE_TID(pTable), TABLE_UID(pTable));
|
TABLE_TID(pTable), TABLE_UID(pTable));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1252,4 +1252,4 @@ static int tsdbRmTableFromMeta(STsdbRepo *pRepo, STable *pTable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ typedef void (*_ref_fn_t)(const void* pObj);
|
||||||
|
|
||||||
#define T_REF_DECLARE() \
|
#define T_REF_DECLARE() \
|
||||||
struct { \
|
struct { \
|
||||||
int16_t val; \
|
int32_t val; \
|
||||||
} _ref;
|
} _ref;
|
||||||
|
|
||||||
#define T_REF_REGISTER_FUNC(s, e) \
|
#define T_REF_REGISTER_FUNC(s, e) \
|
||||||
|
@ -31,7 +31,7 @@ typedef void (*_ref_fn_t)(const void* pObj);
|
||||||
_ref_fn_t end; \
|
_ref_fn_t end; \
|
||||||
} _ref_func = {.begin = (s), .end = (e)};
|
} _ref_func = {.begin = (s), .end = (e)};
|
||||||
|
|
||||||
#define T_REF_INC(x) (atomic_add_fetch_16(&((x)->_ref.val), 1))
|
#define T_REF_INC(x) (atomic_add_fetch_32(&((x)->_ref.val), 1))
|
||||||
|
|
||||||
#define T_REF_INC_WITH_CB(x, p) \
|
#define T_REF_INC_WITH_CB(x, p) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -41,11 +41,11 @@ typedef void (*_ref_fn_t)(const void* pObj);
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define T_REF_DEC(x) (atomic_sub_fetch_16(&((x)->_ref.val), 1))
|
#define T_REF_DEC(x) (atomic_sub_fetch_32(&((x)->_ref.val), 1))
|
||||||
|
|
||||||
#define T_REF_DEC_WITH_CB(x, p) \
|
#define T_REF_DEC_WITH_CB(x, p) \
|
||||||
do { \
|
do { \
|
||||||
int32_t v = atomic_sub_fetch_16(&((x)->_ref.val), 1); \
|
int32_t v = atomic_sub_fetch_32(&((x)->_ref.val), 1); \
|
||||||
if (v == 0 && (p)->_ref_func.end != NULL) { \
|
if (v == 0 && (p)->_ref_func.end != NULL) { \
|
||||||
(p)->_ref_func.end((x)); \
|
(p)->_ref_func.end((x)); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -415,7 +415,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
int16_t ref = T_REF_DEC(pNode);
|
int32_t ref = T_REF_DEC(pNode);
|
||||||
uDebug("%p data released, refcnt:%d", pNode, ref);
|
uDebug("%p data released, refcnt:%d", pNode, ref);
|
||||||
|
|
||||||
if (_remove) {
|
if (_remove) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ void *taosAllocateQitem(int size) {
|
||||||
void taosFreeQitem(void *param) {
|
void taosFreeQitem(void *param) {
|
||||||
if (param == NULL) return;
|
if (param == NULL) return;
|
||||||
|
|
||||||
uDebug("item:%p is freed", param);
|
uTrace("item:%p is freed", param);
|
||||||
char *temp = (char *)param;
|
char *temp = (char *)param;
|
||||||
temp -= sizeof(STaosQnode);
|
temp -= sizeof(STaosQnode);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
@ -124,7 +124,7 @@ int taosWriteQitem(taos_queue param, int type, void *item) {
|
||||||
|
|
||||||
queue->numOfItems++;
|
queue->numOfItems++;
|
||||||
if (queue->qset) atomic_add_fetch_32(&queue->qset->numOfItems, 1);
|
if (queue->qset) atomic_add_fetch_32(&queue->qset->numOfItems, 1);
|
||||||
uDebug("item:%p is put into queue:%p, type:%d items:%d", item, queue, type, queue->numOfItems);
|
uTrace("item:%p is put into queue:%p, type:%d items:%d", item, queue, type, queue->numOfItems);
|
||||||
|
|
||||||
pthread_mutex_unlock(&queue->mutex);
|
pthread_mutex_unlock(&queue->mutex);
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ int taosGetQitem(taos_qall param, int *type, void **pitem) {
|
||||||
*pitem = pNode->item;
|
*pitem = pNode->item;
|
||||||
*type = pNode->type;
|
*type = pNode->type;
|
||||||
num = 1;
|
num = 1;
|
||||||
uDebug("item:%p is fetched, type:%d", *pitem, *type);
|
uTrace("item:%p is fetched, type:%d", *pitem, *type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
|
@ -344,7 +344,7 @@ int taosReadQitemFromQset(taos_qset param, int *type, void **pitem, void **phand
|
||||||
queue->numOfItems--;
|
queue->numOfItems--;
|
||||||
atomic_sub_fetch_32(&qset->numOfItems, 1);
|
atomic_sub_fetch_32(&qset->numOfItems, 1);
|
||||||
code = 1;
|
code = 1;
|
||||||
uDebug("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
|
uTrace("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&queue->mutex);
|
pthread_mutex_unlock(&queue->mutex);
|
||||||
|
|
|
@ -94,7 +94,7 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR
|
||||||
|
|
||||||
// save insert result into item
|
// save insert result into item
|
||||||
|
|
||||||
vDebug("vgId:%d, submit msg is processed", pVnode->vgId);
|
vTrace("vgId:%d, submit msg is processed", pVnode->vgId);
|
||||||
|
|
||||||
pRet->len = sizeof(SShellSubmitRspMsg);
|
pRet->len = sizeof(SShellSubmitRspMsg);
|
||||||
pRet->rsp = rpcMallocCont(pRet->len);
|
pRet->rsp = rpcMallocCont(pRet->len);
|
||||||
|
|
|
@ -13,16 +13,20 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import taos
|
import taos
|
||||||
|
import threading
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
class MetadataQuery:
|
||||||
class QueryMetaData:
|
def initConnection(self):
|
||||||
def __init__(self):
|
self.tables = 10000
|
||||||
|
self.records = 10
|
||||||
|
self.numOfTherads = 10
|
||||||
|
self.ts = 1537146000000
|
||||||
self.host = "127.0.0.1"
|
self.host = "127.0.0.1"
|
||||||
self.user = "root"
|
self.user = "root"
|
||||||
self.password = "taosdata"
|
self.password = "taosdata"
|
||||||
self.config = "/etc/taos"
|
self.config = "/etc/taos"
|
||||||
|
|
||||||
def connectDB(self):
|
def connectDB(self):
|
||||||
self.conn = taos.connect(
|
self.conn = taos.connect(
|
||||||
|
@ -30,31 +34,88 @@ class QueryMetaData:
|
||||||
self.user,
|
self.user,
|
||||||
self.password,
|
self.password,
|
||||||
self.config)
|
self.config)
|
||||||
self.cursor = self.conn.cursor()
|
return self.conn.cursor()
|
||||||
|
|
||||||
|
def createStable(self):
|
||||||
|
print("================= Create stable meters =================")
|
||||||
|
cursor = self.connectDB()
|
||||||
|
cursor.execute("drop database if exists test")
|
||||||
|
cursor.execute("create database test")
|
||||||
|
cursor.execute("use test")
|
||||||
|
cursor.execute('''create table if not exists meters (ts timestamp, speed int) tags(
|
||||||
|
tgcol1 tinyint, tgcol2 smallint, tgcol3 int, tgcol4 bigint, tgcol5 float, tgcol6 double, tgcol7 bool, tgcol8 binary(20), tgcol9 nchar(20),
|
||||||
|
tgcol10 tinyint, tgcol11 smallint, tgcol12 int, tgcol13 bigint, tgcol14 float, tgcol15 double, tgcol16 bool, tgcol17 binary(20), tgcol18 nchar(20),
|
||||||
|
tgcol19 tinyint, tgcol20 smallint, tgcol21 int, tgcol22 bigint, tgcol23 float, tgcol24 double, tgcol25 bool, tgcol26 binary(20), tgcol27 nchar(20),
|
||||||
|
tgcol28 tinyint, tgcol29 smallint, tgcol30 int, tgcol31 bigint, tgcol32 float, tgcol33 double, tgcol34 bool, tgcol35 binary(20), tgcol36 nchar(20),
|
||||||
|
tgcol37 tinyint, tgcol38 smallint, tgcol39 int, tgcol40 bigint, tgcol41 float, tgcol42 double, tgcol43 bool, tgcol44 binary(20), tgcol45 nchar(20),
|
||||||
|
tgcol46 tinyint, tgcol47 smallint, tgcol48 int, tgcol49 bigint, tgcol50 float, tgcol51 double, tgcol52 bool, tgcol53 binary(20), tgcol54 nchar(20))''')
|
||||||
|
cursor.close()
|
||||||
|
self.conn.close()
|
||||||
|
|
||||||
|
def queryData(self, q):
|
||||||
|
print("================= query tag data =================")
|
||||||
|
cursor = self.connectDB()
|
||||||
|
cursor.execute("use test")
|
||||||
|
|
||||||
def queryData(self):
|
|
||||||
print("===============query tag data===============")
|
|
||||||
self.cursor.execute("use test")
|
|
||||||
startTime = datetime.now()
|
startTime = datetime.now()
|
||||||
self.cursor.execute("select areaid from meters")
|
cursor.execute(q)
|
||||||
data = self.cursor.fetchall()
|
cursor.fetchall()
|
||||||
endTime = datetime.now()
|
endTime = datetime.now()
|
||||||
|
print("Query time for the above query is %d seconds" % (endTime - startTime).seconds)
|
||||||
print(endTime - startTime)
|
|
||||||
|
|
||||||
start = datetime.now()
|
|
||||||
self.cursor.execute("select areaid, loc from meters")
|
|
||||||
data2 = self.cursor.fetchall()
|
|
||||||
end = datetime.now()
|
|
||||||
|
|
||||||
print(end - start)
|
|
||||||
|
|
||||||
def closeConn(self):
|
cursor.close()
|
||||||
self.cursor.close()
|
self.conn.close()
|
||||||
|
|
||||||
|
def createTablesAndInsertData(self, threadID):
|
||||||
|
cursor = self.connectDB()
|
||||||
|
cursor.execute("use test")
|
||||||
|
base = threadID * self.tables
|
||||||
|
for i in range(self.tables):
|
||||||
|
cursor.execute('''create table t%d using meters tags(
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d',
|
||||||
|
%d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')'''
|
||||||
|
% (base + i + 1,
|
||||||
|
(base + i) % 100, (base + i) % 10000, (base + i) % 1000000, (base + i) % 100000000, (base + i) % 100 * 1.1, (base + i) % 100 * 2.3, (base + i) % 2, (base + i) % 100, (base + i) % 100,
|
||||||
|
(base + i) % 100, (base + i) % 10000, (base + i) % 1000000, (base + i) % 100000000, (base + i) % 100 * 1.1, (base + i) % 100 * 2.3, (base + i) % 2, (base + i) % 100, (base + i) % 100,
|
||||||
|
(base + i) % 100, (base + i) % 10000, (base + i) % 1000000, (base + i) % 100000000, (base + i) % 100 * 1.1, (base + i) % 100 * 2.3, (base + i) % 2, (base + i) % 100, (base + i) % 100,
|
||||||
|
(base + i) % 100, (base + i) % 10000, (base + i) % 1000000, (base + i) % 100000000, (base + i) % 100 * 1.1, (base + i) % 100 * 2.3, (base + i) % 2, (base + i) % 100, (base + i) % 100,
|
||||||
|
(base + i) % 100, (base + i) % 10000, (base + i) % 1000000, (base + i) % 100000000, (base + i) % 100 * 1.1, (base + i) % 100 * 2.3, (base + i) % 2, (base + i) % 100, (base + i) % 100,
|
||||||
|
(base + i) % 100, (base + i) % 10000, (base + i) % 1000000, (base + i) % 100000000, (base + i) % 100 * 1.1, (base + i) % 100 * 2.3, (base + i) % 2, (base + i) % 100, (base + i) % 100 ))
|
||||||
|
for j in range(self.records):
|
||||||
|
cursor.execute("insert into t%d values(%d, %d)" % (base + i + 1, self.ts + j, j))
|
||||||
|
cursor.close()
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
||||||
|
|
||||||
test = QueryMetaData()
|
if __name__ == '__main__':
|
||||||
test.connectDB()
|
|
||||||
test.queryData()
|
t = MetadataQuery()
|
||||||
test.closeConn()
|
t.initConnection()
|
||||||
|
t.createStable()
|
||||||
|
|
||||||
|
print("================= Create %d tables and insert %d records into each table =================" % (t.tables, t.records))
|
||||||
|
startTime = datetime.now()
|
||||||
|
for i in range(t.numOfTherads):
|
||||||
|
thread = threading.Thread(target=t.createTablesAndInsertData, args=(i,))
|
||||||
|
thread.start()
|
||||||
|
thread.join()
|
||||||
|
endTime = datetime.now()
|
||||||
|
diff = (endTime - startTime).seconds
|
||||||
|
|
||||||
|
print("spend %d seconds to create %d tables and insert %d records into each table" % (diff, t.tables, t.records));
|
||||||
|
|
||||||
|
# tgcol28, tgcol29, tgcol30, tgcol31, tgcol32, tgcol33, tgcol34, tgcol35, tgcol36,
|
||||||
|
# tgcol37, tgcol38, tgcol39, tgcol40, tgcol41, tgcol42, tgcol43, tgcol44, tgcol45,
|
||||||
|
# tgcol46, tgcol47, tgcol48, tgcol49, tgcol50, tgcol51, tgcol52, tgcol53, tgcol54
|
||||||
|
# tgcol19, tgcol20, tgcol21, tgcol22, tgcol23, tgcol24, tgcol25, tgcol26, tgcol27,
|
||||||
|
|
||||||
|
query = '''select tgcol1, tgcol2, tgcol3, tgcol4, tgcol5, tgcol6, tgcol7, tgcol8, tgcol9,
|
||||||
|
tgcol10, tgcol11, tgcol12, tgcol13, tgcol14, tgcol15, tgcol16, tgcol17, tgcol18,
|
||||||
|
from meters where tgcol1 > 10 AND tgcol1 < 100 and tgcol2 > 100 and tgcol2 < 1000 or tgcol3 > 10000 or tgcol7 = true
|
||||||
|
or tgcol8 like '%2' and tgcol10 < 10'''
|
||||||
|
|
||||||
|
t.queryData(query)
|
||||||
|
|
|
@ -142,6 +142,8 @@ run general/stable/dnode3.sim
|
||||||
run general/stable/metrics.sim
|
run general/stable/metrics.sim
|
||||||
run general/stable/values.sim
|
run general/stable/values.sim
|
||||||
run general/stable/vnode3.sim
|
run general/stable/vnode3.sim
|
||||||
|
run general/stable/refcount.sim
|
||||||
|
run general/stable/show.sim
|
||||||
run general/table/autocreate.sim
|
run general/table/autocreate.sim
|
||||||
run general/table/basic1.sim
|
run general/table/basic1.sim
|
||||||
run general/table/basic2.sim
|
run general/table/basic2.sim
|
||||||
|
|
Loading…
Reference in New Issue