提交 4d8d1df2 编写于 作者: H Hongze Cheng

more work

上级 cae57255
...@@ -522,7 +522,6 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i ...@@ -522,7 +522,6 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
} }
if (pTbData->minKey > key.ts) pTbData->minKey = key.ts; if (pTbData->minKey > key.ts) pTbData->minKey = key.ts;
if (pMemTable->minKey > key.ts) pMemTable->minKey = key.ts;
pLastRow = row.pTSRow; pLastRow = row.pTSRow;
...@@ -554,9 +553,14 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i ...@@ -554,9 +553,14 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
tsdbCacheInsertLastrow(pMemTable->pTsdb->lruCache, pTbData->uid, pLastRow); tsdbCacheInsertLastrow(pMemTable->pTsdb->lruCache, pTbData->uid, pLastRow);
} }
} }
if (key.ts > pMemTable->maxKey) pMemTable->maxKey = key.ts;
if (pTbData->minVersion > version) pTbData->minVersion = version; if (pTbData->minVersion > version) pTbData->minVersion = version;
if (pTbData->maxVersion < version) pTbData->maxVersion = version; if (pTbData->maxVersion < version) pTbData->maxVersion = version;
// SMemTable
if (pMemTable->minKey > pTbData->minKey) pMemTable->minKey = pTbData->minKey;
if (pMemTable->maxKey < pTbData->maxKey) pMemTable->maxKey = pTbData->maxKey;
if (pMemTable->minVersion > pTbData->minVersion) pMemTable->minVersion = pTbData->minVersion;
if (pMemTable->maxVersion < pTbData->maxVersion) pMemTable->maxVersion = pTbData->maxVersion;
pMemTable->nRow += nRow; pMemTable->nRow += nRow;
pRsp->numOfRows = nRow; pRsp->numOfRows = nRow;
......
...@@ -47,6 +47,7 @@ int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(u ...@@ -47,6 +47,7 @@ int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(u
if (code) goto _err; if (code) goto _err;
// put // put
ASSERT(pMapData->flag == TSDB_OFFSET_I32);
((int32_t *)pMapData->pOfst)[nItem] = offset; ((int32_t *)pMapData->pOfst)[nItem] = offset;
tPutItemFn(pMapData->pData + offset, pItem); tPutItemFn(pMapData->pData + offset, pItem);
...@@ -54,31 +55,31 @@ _err: ...@@ -54,31 +55,31 @@ _err:
return code; return code;
} }
int32_t tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)) { static int32_t tMapDataGetOffset(SMapData *pMapData, int32_t idx) {
int32_t code = 0;
int32_t offset;
if (idx < 0 || idx >= pMapData->nItem) {
code = TSDB_CODE_NOT_FOUND;
goto _exit;
}
switch (pMapData->flag) { switch (pMapData->flag) {
case TSDB_OFFSET_I8: case TSDB_OFFSET_I8:
offset = ((int8_t *)pMapData->pOfst)[idx]; return ((int8_t *)pMapData->pOfst)[idx];
break; break;
case TSDB_OFFSET_I16: case TSDB_OFFSET_I16:
offset = ((int16_t *)pMapData->pOfst)[idx]; return ((int16_t *)pMapData->pOfst)[idx];
break; break;
case TSDB_OFFSET_I32: case TSDB_OFFSET_I32:
offset = ((int32_t *)pMapData->pOfst)[idx]; return ((int32_t *)pMapData->pOfst)[idx];
break; break;
default: default:
ASSERT(0); ASSERT(0);
} }
}
int32_t tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)) {
int32_t code = 0;
if (idx < 0 || idx >= pMapData->nItem) {
code = TSDB_CODE_NOT_FOUND;
goto _exit;
}
tGetItemFn(pMapData->pData + offset, pItem); tGetItemFn(pMapData->pData + tMapDataGetOffset(pMapData, idx), pItem);
_exit: _exit:
return code; return code;
...@@ -91,7 +92,7 @@ int32_t tPutMapData(uint8_t *p, SMapData *pMapData) { ...@@ -91,7 +92,7 @@ int32_t tPutMapData(uint8_t *p, SMapData *pMapData) {
ASSERT(pMapData->flag == TSDB_OFFSET_I32); ASSERT(pMapData->flag == TSDB_OFFSET_I32);
ASSERT(pMapData->nItem > 0); ASSERT(pMapData->nItem > 0);
maxOffset = ((int32_t *)pMapData->pOfst)[pMapData->nItem - 1]; maxOffset = tMapDataGetOffset(pMapData, pMapData->nItem - 1);
n += tPutI32v(p ? p + n : p, pMapData->nItem); n += tPutI32v(p ? p + n : p, pMapData->nItem);
if (maxOffset <= INT8_MAX) { if (maxOffset <= INT8_MAX) {
......
...@@ -48,26 +48,21 @@ int vnodeBegin(SVnode *pVnode) { ...@@ -48,26 +48,21 @@ int vnodeBegin(SVnode *pVnode) {
} }
// begin tsdb // begin tsdb
if (pVnode->pSma) { if (tsdbBegin(pVnode->pTsdb) < 0) {
if (tsdbBegin(VND_RSMA0(pVnode)) < 0) { vError("vgId:%d, failed to begin tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
vError("vgId:%d, failed to begin rsma0 since %s", TD_VID(pVnode), tstrerror(terrno)); return -1;
return -1; }
}
if (tsdbBegin(VND_RSMA1(pVnode)) < 0) { if (pVnode->pSma) {
if (VND_RSMA1(pVnode) && tsdbBegin(VND_RSMA1(pVnode)) < 0) {
vError("vgId:%d, failed to begin rsma1 since %s", TD_VID(pVnode), tstrerror(terrno)); vError("vgId:%d, failed to begin rsma1 since %s", TD_VID(pVnode), tstrerror(terrno));
return -1; return -1;
} }
if (tsdbBegin(VND_RSMA2(pVnode)) < 0) { if (VND_RSMA2(pVnode) && tsdbBegin(VND_RSMA2(pVnode)) < 0) {
vError("vgId:%d, failed to begin rsma2 since %s", TD_VID(pVnode), tstrerror(terrno)); vError("vgId:%d, failed to begin rsma2 since %s", TD_VID(pVnode), tstrerror(terrno));
return -1; return -1;
} }
} else {
if (tsdbBegin(pVnode->pTsdb) < 0) {
vError("vgId:%d, failed to begin tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
return -1;
}
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册