more code
This commit is contained in:
parent
0b17e3fe1c
commit
ec7cb5f217
|
@ -55,7 +55,7 @@ struct STFile {
|
||||||
int64_t size;
|
int64_t size;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
int32_t lvl;
|
int32_t level;
|
||||||
int32_t nseg;
|
int32_t nseg;
|
||||||
} stt;
|
} stt;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "inc/tsdbFSet.h"
|
#include "inc/tsdbFSet.h"
|
||||||
|
|
||||||
static int32_t stt_lvl_to_json(const SSttLvl *lvl, cJSON *json) {
|
static int32_t stt_lvl_to_json(const SSttLvl *lvl, cJSON *json) {
|
||||||
if (cJSON_AddNumberToObject(json, "lvl", lvl->level) == NULL) {
|
if (cJSON_AddNumberToObject(json, "level", lvl->level) == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ static int32_t add_file_to_stt_lvl(SSttLvl *lvl, STFileObj *fobj) {
|
||||||
static int32_t json_to_stt_lvl(const cJSON *json, SSttLvl *lvl) {
|
static int32_t json_to_stt_lvl(const cJSON *json, SSttLvl *lvl) {
|
||||||
const cJSON *item1, *item2;
|
const cJSON *item1, *item2;
|
||||||
|
|
||||||
item1 = cJSON_GetObjectItem(json, "lvl");
|
item1 = cJSON_GetObjectItem(json, "level");
|
||||||
if (cJSON_IsNumber(item1)) {
|
if (cJSON_IsNumber(item1)) {
|
||||||
lvl->level = item1->valuedouble;
|
lvl->level = item1->valuedouble;
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,7 +102,7 @@ static int32_t add_stt_lvl(STFileSet *fset, SSttLvl *lvl) {
|
||||||
static int32_t add_file_to_fset(STFileSet *fset, STFileObj *fobj) {
|
static int32_t add_file_to_fset(STFileSet *fset, STFileObj *fobj) {
|
||||||
if (fobj->f.type == TSDB_FTYPE_STT) {
|
if (fobj->f.type == TSDB_FTYPE_STT) {
|
||||||
SSttLvl *lvl;
|
SSttLvl *lvl;
|
||||||
SSttLvl tlvl = {.level = fobj->f.stt.lvl};
|
SSttLvl tlvl = {.level = fobj->f.stt.level};
|
||||||
|
|
||||||
SRBTreeNode *node = tRBTreeGet(&fset->lvlTree, &tlvl.rbtn);
|
SRBTreeNode *node = tRBTreeGet(&fset->lvlTree, &tlvl.rbtn);
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -111,7 +111,7 @@ static int32_t add_file_to_fset(STFileSet *fset, STFileObj *fobj) {
|
||||||
lvl = taosMemoryMalloc(sizeof(*lvl));
|
lvl = taosMemoryMalloc(sizeof(*lvl));
|
||||||
if (!lvl) return TSDB_CODE_OUT_OF_MEMORY;
|
if (!lvl) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
stt_lvl_init(lvl, fobj->f.stt.lvl);
|
stt_lvl_init(lvl, fobj->f.stt.level);
|
||||||
add_stt_lvl(fset, lvl);
|
add_stt_lvl(fset, lvl);
|
||||||
}
|
}
|
||||||
add_file_to_stt_lvl(lvl, fobj);
|
add_file_to_stt_lvl(lvl, fobj);
|
||||||
|
@ -150,6 +150,7 @@ static int32_t fset_clear(STFileSet *fset) {
|
||||||
|
|
||||||
int32_t tsdbFileSetToJson(const STFileSet *fset, cJSON *json) {
|
int32_t tsdbFileSetToJson(const STFileSet *fset, cJSON *json) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
cJSON *item1, *item2;
|
||||||
|
|
||||||
// fid
|
// fid
|
||||||
if (cJSON_AddNumberToObject(json, "fid", fset->fid) == NULL) {
|
if (cJSON_AddNumberToObject(json, "fid", fset->fid) == NULL) {
|
||||||
|
@ -164,13 +165,15 @@ int32_t tsdbFileSetToJson(const STFileSet *fset, cJSON *json) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// each level
|
// each level
|
||||||
cJSON *ajson = cJSON_AddArrayToObject(json, "stt");
|
item1 = cJSON_AddArrayToObject(json, "stt levels");
|
||||||
if (ajson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (item1 == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
SRBTreeIter iter = tRBTreeIterCreate(&fset->lvlTree, 1);
|
SRBTreeIter iter = tRBTreeIterCreate(&fset->lvlTree, 1);
|
||||||
for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) {
|
for (SRBTreeNode *node = tRBTreeIterNext(&iter); node; node = tRBTreeIterNext(&iter)) {
|
||||||
SSttLvl *lvl = TCONTAINER_OF(node, SSttLvl, rbtn);
|
item2 = cJSON_CreateObject();
|
||||||
code = stt_lvl_to_json(lvl, ajson);
|
if (!item2) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
cJSON_AddItemToArray(item1, item2);
|
||||||
|
|
||||||
|
code = stt_lvl_to_json(TCONTAINER_OF(node, SSttLvl, rbtn), item2);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ static int32_t stt_to_json(const STFile *file, cJSON *json) {
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
/* lvl */
|
/* lvl */
|
||||||
if (cJSON_AddNumberToObject(json, "lvl", file->stt.lvl) == NULL) {
|
if (cJSON_AddNumberToObject(json, "level", file->stt.level) == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ static int32_t stt_from_json(const cJSON *json, STFile *file) {
|
||||||
const cJSON *item;
|
const cJSON *item;
|
||||||
|
|
||||||
/* lvl */
|
/* lvl */
|
||||||
item = cJSON_GetObjectItem(json, "lvl");
|
item = cJSON_GetObjectItem(json, "level");
|
||||||
if (cJSON_IsNumber(item)) {
|
if (cJSON_IsNumber(item)) {
|
||||||
file->stt.lvl = item->valuedouble;
|
file->stt.level = item->valuedouble;
|
||||||
} else {
|
} else {
|
||||||
return TSDB_CODE_FILE_CORRUPTED;
|
return TSDB_CODE_FILE_CORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue