This commit is contained in:
Hongze Cheng 2020-06-14 10:13:02 +00:00
parent 472b194a1e
commit ec4b6b085e
1 changed files with 34 additions and 26 deletions

View File

@ -100,7 +100,6 @@ int tsdbDropTable(TSDB_REPO_T *repo, STableId tableId) {
if (tsdbRemoveTableFromMeta(pMeta, pTable, true) < 0) return -1;
return 0;
}
void *tsdbGetTableTagVal(TSDB_REPO_T *repo, const STableId *id, int32_t colId, int16_t type, int16_t bytes) {
@ -457,8 +456,7 @@ static int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
return -1;
}
pTable = tsdbDecodeTable(cont, contLen);
if (pTable == NULL) return -1;
tsdbDecodeTable(cont, &pTable);
if (tsdbAddTableToMeta(pMeta, pTable, false) < 0) {
tsdbFreeTable(pTable);
@ -526,9 +524,8 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) {
goto _err;
}
pTable->tagVal = NULL;
STColumn *pColSchema = schemaColAt(pTable->tagSchema, 0);
pTable->pIndex =
tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, pColSchema->type, pColSchema->bytes, 1, 0, 1, getTagIndexKey);
STColumn *pCol = schemaColAt(pTable->tagSchema, DEFAULT_TAG_INDEX_COLUMN);
pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), colBytes(pCol), 1, 0, 1, getTagIndexKey);
if (pTable->pIndex == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
goto _err;
@ -648,7 +645,8 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx) {
if (taosHashPut(pMeta->uidMap, (char *)(&pTable->tableId.uid), sizeof(pTable->tableId.uid), (void *)(&pTable),
sizeof(pTable)) < 0) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
tsdbError("vgId:%d failed to add table %s to meta while put into uid map since %s", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable), tstrerror(terrno));
tsdbError("vgId:%d failed to add table %s to meta while put into uid map since %s", REPO_ID(pRepo),
TABLE_CHAR_NAME(pTable), tstrerror(terrno));
goto _err;
}
@ -957,6 +955,14 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
buf = tdDecodeSchema(buf, &(pTable->tagSchema));
STColumn *pCol = schemaColAt(pTable->tagSchema, DEFAULT_TAG_INDEX_COLUMN);
pTable->pIndex =
tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), colBytes(pCol), 1, 0, 1, getTagIndexKey);
if (pTable->pIndex == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
tsdbFreeTable(pTable);
return NULL;
}
}
if (TABLE_TYPE(pTable) == TSDB_STREAM_TABLE) {
@ -964,6 +970,8 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
}
}
T_REF_INC(pTable);
*pRTable = pTable;
return buf;