more code
This commit is contained in:
parent
f8220e8b90
commit
e783609ebd
|
@ -67,9 +67,9 @@ struct SRBTree {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SRBTreeIter {
|
struct SRBTreeIter {
|
||||||
int8_t asc;
|
int8_t asc;
|
||||||
SRBTree *pTree;
|
const SRBTree *pTree;
|
||||||
SRBTreeNode *pNode;
|
SRBTreeNode *pNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -118,6 +118,8 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
||||||
|
|
||||||
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
|
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
|
||||||
|
|
||||||
|
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -60,7 +60,7 @@ typedef struct SSttLvl {
|
||||||
struct STFileSet {
|
struct STFileSet {
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
STFileObj *farr[TSDB_FTYPE_MAX]; // file array
|
STFileObj *farr[TSDB_FTYPE_MAX]; // file array
|
||||||
SRBTree lvlTree; // level tree of .stt
|
SRBTree lvlTree; // SRBTree<SSttLvl>, level tree of .stt
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -20,20 +20,24 @@ static int32_t stt_lvl_to_json(const SSttLvl *lvl, cJSON *json) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON *arr = cJSON_AddArrayToObject(json, "stt");
|
cJSON *ajson = cJSON_AddArrayToObject(json, "stt");
|
||||||
if (arr == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (ajson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
// TODO: .stt files
|
SRBTreeIter iter = tRBTreeIterCreate(&lvl->sttTree, 1);
|
||||||
// STFile *f;
|
for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) {
|
||||||
// LISTD_FOREACH(&lvl->fstt, f, listNode) {
|
STFileObj *fobj = TCONTAINER_OF(node, STFileObj, rbtn);
|
||||||
// cJSON *item = cJSON_CreateObject();
|
|
||||||
// if (item == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
// int32_t code = tsdbTFileToJson(f, item);
|
cJSON *item = cJSON_CreateObject();
|
||||||
// if (code) return code;
|
if (item == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
// cJSON_AddItemToArray(arr, item);
|
int32_t code = tsdbTFileToJson(&fobj->f, item);
|
||||||
// }
|
if (code) {
|
||||||
|
cJSON_Delete(item);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON_AddItemToArray(ajson, item);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -69,24 +73,20 @@ int32_t tsdbFileSetToJson(const STFileSet *fset, cJSON *json) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// code = tsdbTFileToJson(fset->farr[ftype], json);
|
code = tsdbTFileToJson(&fset->farr[ftype]->f, json);
|
||||||
// if (code) return code;
|
if (code) return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// each level
|
// each level
|
||||||
cJSON *ajson = cJSON_AddArrayToObject(json, "stt");
|
cJSON *ajson = cJSON_AddArrayToObject(json, "stt");
|
||||||
if (ajson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (ajson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
SSttLvl *sttLvl;
|
SRBTreeIter iter = tRBTreeIterCreate(&fset->lvlTree, 1);
|
||||||
// LISTD_FOREACH(&fset->lvl0, sttLvl, listNode) {
|
for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) {
|
||||||
// cJSON *ljson = cJSON_CreateObject();
|
SSttLvl *lvl = TCONTAINER_OF(node, SSttLvl, rbtn);
|
||||||
// if (ljson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
code = stt_lvl_to_json(lvl, ajson);
|
||||||
|
if (code) return code;
|
||||||
// code = stt_lvl_to_json(sttLvl, ljson);
|
}
|
||||||
// if (code) return code;
|
|
||||||
|
|
||||||
// cJSON_AddItemToArray(ajson, ljson);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ static void tRBTreeTransplant(SRBTree *pTree, SRBTreeNode *u, SRBTreeNode *v) {
|
||||||
v->parent = u->parent;
|
v->parent = u->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRBTreeNode *tRBTreeSuccessor(SRBTree *pTree, SRBTreeNode *pNode) {
|
static SRBTreeNode *tRBTreeSuccessor(const SRBTree *pTree, SRBTreeNode *pNode) {
|
||||||
if (pNode->right != pTree->NIL) {
|
if (pNode->right != pTree->NIL) {
|
||||||
pNode = pNode->right;
|
pNode = pNode->right;
|
||||||
while (pNode->left != pTree->NIL) {
|
while (pNode->left != pTree->NIL) {
|
||||||
|
@ -125,7 +125,7 @@ static SRBTreeNode *tRBTreeSuccessor(SRBTree *pTree, SRBTreeNode *pNode) {
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRBTreeNode *tRBTreePredecessor(SRBTree *pTree, SRBTreeNode *pNode) {
|
static SRBTreeNode *tRBTreePredecessor(const SRBTree *pTree, SRBTreeNode *pNode) {
|
||||||
if (pNode->left != pTree->NIL) {
|
if (pNode->left != pTree->NIL) {
|
||||||
pNode = pNode->left;
|
pNode = pNode->left;
|
||||||
while (pNode->right != pTree->NIL) {
|
while (pNode->right != pTree->NIL) {
|
||||||
|
|
Loading…
Reference in New Issue