[td-353]
This commit is contained in:
parent
a2260415fe
commit
580fb8e939
|
@ -72,9 +72,11 @@ typedef struct STableCheckInfo {
|
||||||
int32_t compSize;
|
int32_t compSize;
|
||||||
int32_t numOfBlocks; // number of qualified data blocks not the original blocks
|
int32_t numOfBlocks; // number of qualified data blocks not the original blocks
|
||||||
SDataCols* pDataCols;
|
SDataCols* pDataCols;
|
||||||
|
|
||||||
int32_t chosen; // indicate which iterator should move forward
|
int32_t chosen; // indicate which iterator should move forward
|
||||||
bool initBuf; // whether to initialize the in-memory skip list iterator or not
|
bool initBuf; // whether to initialize the in-memory skip list iterator or not
|
||||||
|
SMemTable* mem; // in-mem buffer, hold the ref count
|
||||||
|
SMemTable* imem; // imem buffer, hold the ref count to avoid release
|
||||||
|
|
||||||
SSkipListIterator* iter; // mem buffer skip list iterator
|
SSkipListIterator* iter; // mem buffer skip list iterator
|
||||||
SSkipListIterator* iiter; // imem buffer skip list iterator
|
SSkipListIterator* iiter; // imem buffer skip list iterator
|
||||||
} STableCheckInfo;
|
} STableCheckInfo;
|
||||||
|
@ -248,21 +250,23 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
|
||||||
pCheckInfo->initBuf = true;
|
pCheckInfo->initBuf = true;
|
||||||
int32_t order = pHandle->order;
|
int32_t order = pHandle->order;
|
||||||
|
|
||||||
|
tsdbTakeMemSnapshot(pHandle->pTsdb, &pCheckInfo->mem, &pCheckInfo->imem);
|
||||||
|
|
||||||
// no data in buffer, abort
|
// no data in buffer, abort
|
||||||
if (pTable->mem == NULL && pTable->imem == NULL) {
|
if (pCheckInfo->mem == NULL && pCheckInfo->imem == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pCheckInfo->iter == NULL && pCheckInfo->iiter == NULL);
|
assert(pCheckInfo->iter == NULL && pCheckInfo->iiter == NULL);
|
||||||
|
|
||||||
if (pTable->mem) {
|
if (pCheckInfo->mem) {
|
||||||
pCheckInfo->iter = tSkipListCreateIterFromVal(pTable->mem->pData, (const char*) &pCheckInfo->lastKey,
|
pCheckInfo->iter = tSkipListCreateIterFromVal(pCheckInfo->mem->tData[pCheckInfo->tableId.tid]->pData,
|
||||||
TSDB_DATA_TYPE_TIMESTAMP, order);
|
(const char*) &pCheckInfo->lastKey, TSDB_DATA_TYPE_TIMESTAMP, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTable->imem) {
|
if (pCheckInfo->imem) {
|
||||||
pCheckInfo->iiter = tSkipListCreateIterFromVal(pTable->imem->pData, (const char*) &pCheckInfo->lastKey,
|
pCheckInfo->iiter = tSkipListCreateIterFromVal(pCheckInfo->imem->tData[pCheckInfo->tableId.tid]->pData,
|
||||||
TSDB_DATA_TYPE_TIMESTAMP, order);
|
(const char*) &pCheckInfo->lastKey, TSDB_DATA_TYPE_TIMESTAMP, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
// both iterators are NULL, no data in buffer right now
|
// both iterators are NULL, no data in buffer right now
|
||||||
|
@ -1822,8 +1826,8 @@ static int32_t getAllTableIdList(STable* pSuperTable, SArray* list) {
|
||||||
while (tSkipListIterNext(iter)) {
|
while (tSkipListIterNext(iter)) {
|
||||||
SSkipListNode* pNode = tSkipListIterGet(iter);
|
SSkipListNode* pNode = tSkipListIterGet(iter);
|
||||||
|
|
||||||
STableIndexElem* elem = (STableIndexElem*)(SL_GET_NODE_DATA((SSkipListNode*) pNode));
|
STable** pTable = (STable**) SL_GET_NODE_DATA((SSkipListNode*) pNode);
|
||||||
taosArrayPush(list, &elem->pTable->tableId);
|
taosArrayPush(list, &(*pTable)->tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
tSkipListDestroyIter(iter);
|
tSkipListDestroyIter(iter);
|
||||||
|
@ -1842,8 +1846,8 @@ static void convertQueryResult(SArray* pRes, SArray* pTableList) {
|
||||||
|
|
||||||
size_t size = taosArrayGetSize(pTableList);
|
size_t size = taosArrayGetSize(pTableList);
|
||||||
for (int32_t i = 0; i < size; ++i) { // todo speedup by using reserve space.
|
for (int32_t i = 0; i < size; ++i) { // todo speedup by using reserve space.
|
||||||
STableIndexElem* elem = taosArrayGet(pTableList, i);
|
STable* pTable = taosArrayGetP(pTableList, i);
|
||||||
taosArrayPush(pRes, &elem->pTable->tableId);
|
taosArrayPush(pRes, &pTable->tableId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2027,16 +2031,16 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
|
||||||
bool indexedNodeFilterFp(const void* pNode, void* param) {
|
bool indexedNodeFilterFp(const void* pNode, void* param) {
|
||||||
tQueryInfo* pInfo = (tQueryInfo*) param;
|
tQueryInfo* pInfo = (tQueryInfo*) param;
|
||||||
|
|
||||||
STableIndexElem* elem = (STableIndexElem*)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
|
STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
|
||||||
|
|
||||||
char* val = NULL;
|
char* val = NULL;
|
||||||
int8_t type = pInfo->sch.type;
|
int8_t type = pInfo->sch.type;
|
||||||
|
|
||||||
if (pInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
val = (char*) elem->pTable->name;
|
val = (char*) pTable->name;
|
||||||
type = TSDB_DATA_TYPE_BINARY;
|
type = TSDB_DATA_TYPE_BINARY;
|
||||||
} else {
|
} else {
|
||||||
val = tdGetKVRowValOfCol(elem->pTable->tagVal, pInfo->sch.colId);
|
val = tdGetKVRowValOfCol(pTable->tagVal, pInfo->sch.colId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo :the val is possible to be null, so check it out carefully
|
//todo :the val is possible to be null, so check it out carefully
|
||||||
|
@ -2092,7 +2096,7 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr)
|
||||||
.pExtInfo = pSTable->tagSchema,
|
.pExtInfo = pSTable->tagSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
SArray* pTableList = taosArrayInit(8, sizeof(STableIndexElem));
|
SArray* pTableList = taosArrayInit(8, POINTER_BYTES);
|
||||||
|
|
||||||
tExprTreeTraverse(pExpr, pSTable->pIndex, pTableList, &supp);
|
tExprTreeTraverse(pExpr, pSTable->pIndex, pTableList, &supp);
|
||||||
tExprTreeDestroy(&pExpr, destroyHelper);
|
tExprTreeDestroy(&pExpr, destroyHelper);
|
||||||
|
|
Loading…
Reference in New Issue