提交 81ef708c 编写于 作者: H Hongze Cheng

more

上级 e0b4319b
......@@ -32,6 +32,7 @@ extern "C" {
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
typedef struct TSDBROW TSDBROW;
typedef struct TSDBKEY TSDBKEY;
typedef struct SDelOp SDelOp;
......@@ -855,9 +856,9 @@ static FORCE_INLINE int tsdbUnLockFS(STsdbFS *pFs) {
return 0;
}
struct STsdbRow {
int64_t version;
STSRow row;
struct TSDBROW {
int64_t version;
STSRow2 *pRow;
};
struct TSDBKEY {
......@@ -869,7 +870,6 @@ struct SDelOp {
int64_t version;
TSKEY sKey; // included
TSKEY eKey; // included
SDelOp *pNext;
};
#endif
......
......@@ -26,7 +26,7 @@ struct SMemData {
TSDBKEY minKey;
TSDBKEY maxKey;
int64_t nRows;
SDelOp *pDelList;
SArray *aDelOp; // SArray<SDelOp>
};
struct SMemTable {
......@@ -35,9 +35,11 @@ struct SMemTable {
TSDBKEY minKey;
TSDBKEY maxKey;
int64_t nRows;
SArray *pArray;
SArray *pArray; // SArray<SMemData>
};
static int32_t tsdbGetOrCreateTbData(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SMemData **ppMemData);
// SMemTable ==============================================
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable) {
int32_t code = 0;
......@@ -69,11 +71,61 @@ _err:
}
void tsdbMemTableDestroy2(SMemTable *pMemTable) {
ASSERT(0);
taosArrayDestroyEx(pMemTable->pArray, NULL /*TODO*/);
taosMemoryFree(pMemTable);
}
int32_t tsdbInsertTableData2(STsdb *pTsdb, int64_t version, SVSubmitBlk *pSubmitBlk) {
int32_t code = 0;
SMemData *pMemData;
// check if table exists
{
// TODO
}
code = tsdbGetOrCreateTbData(pTsdb, pSubmitBlk->suid, pSubmitBlk->uid, &pMemData);
if (code) {
tsdbError("vgId:%d failed to create/get table data since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
goto _err;
}
// do insert
return code;
_err:
return code;
}
int32_t tsdbDeleteTableData2(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey) {
int32_t code = 0;
// TODO
return code;
}
static int32_t tsdbGetOrCreateTbData(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SMemData **ppMemData) {
int32_t code = 0;
SMemData *pMemData = NULL;
SMemTable *pMemTable = (SMemTable *)pTsdb->mem;
// search
pMemData = (SMemData *)taosbsearch(NULL, pMemTable->pArray->pData, taosArrayGetSize(pMemTable->pArray),
sizeof(SMemData *), NULL, TD_GE);
if (pMemData == NULL) {
// not found, create one
}
*ppMemData = pMemData;
return code;
_err:
*ppMemData = NULL;
return code;
}
#if 0
#if 0 //====================================================================================
#define SL_MAX_LEVEL 5
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册