提交 7cf2911c 编写于 作者: H Hongze Cheng

more code

上级 85a36d62
......@@ -238,6 +238,54 @@ void tdListNodeGetData(SList *list, SListNode *node, void *target);
void tdListInitIter(SList *list, SListIter *pIter, TD_LIST_DIRECTION_T direction);
SListNode *tdListNext(SListIter *pIter);
// macros ====================================================================================
// q: for queue
// n: for node
// m: for member
#define LISTD(TYPE) \
struct { \
TYPE *next, *prev; \
}
#define LISTD_NEXT(n, m) ((n)->m.next)
#define LISTD_PREV(n, m) ((n)->m.prev)
#define LISTD_INIT(q, m) (LISTD_NEXT(q, m) = LISTD_PREV(q, m) = (q))
#define LISTD_HEAD(q, m) (LISTD_NEXT(q, m))
#define LISTD_TAIL(q, m) (LISTD_PREV(q, m))
#define LISTD_PREV_NEXT(n, m) (LISTD_NEXT(LISTD_PREV(n, m), m))
#define LISTD_NEXT_PREV(n, m) (LISTD_PREV(LISTD_NEXT(n, m), m))
#define LISTD_INSERT_HEAD(q, n, m) \
do { \
LISTD_NEXT(n, m) = LISTD_NEXT(q, m); \
LISTD_PREV(n, m) = (q); \
LISTD_NEXT_PREV(n, m) = (n); \
LISTD_NEXT(q, m) = (n); \
} while (0)
#define LISTD_INSERT_TAIL(q, n, m) \
do { \
LISTD_NEXT(n, m) = (q); \
LISTD_PREV(n, m) = LISTD_PREV(q, m); \
LISTD_PREV_NEXT(n, m) = (n); \
LISTD_PREV(q, m) = (n); \
} while (0)
#define LISTD_REMOVE(n, m) \
do { \
LISTD_PREV_NEXT(n, m) = LISTD_NEXT(n, m); \
LISTD_NEXT_PREV(n, m) = LISTD_PREV(n, m); \
} while (0)
#define LISTD_FOREACH(q, n, m) for ((n) = LISTD_HEAD(q, m); (n) != (q); (n) = LISTD_NEXT(n, m))
#define LISTD_FOREACH_REVERSE(q, n, m) for ((n) = LISTD_TAIL(q, m); (n) != (q); (n) = LISTD_PREV(n, m))
#define LISTD_FOREACH_SAFE(q, n, t, m) \
for ((n) = LISTD_HEAD(q, m), (t) = LISTD_NEXT(n, m); (n) != (q); (n) = (t), (t) = LISTD_NEXT(n, m))
#define LISTD_FOREACH_REVERSE_SAFE(q, n, t, m) \
for ((n) = LISTD_TAIL(q, m), (t) = LISTD_PREV(n, m); (n) != (q); (n) = (t), (t) = LISTD_PREV(n, m))
#ifdef __cplusplus
}
#endif
......
......@@ -34,49 +34,49 @@ int32_t tsdbFileSetEdit(struct SFileSet *pSet, struct SFileOp *pOp) {
int32_t code = 0;
int32_t lino;
switch (pOp->op) {
case TSDB_FOP_CREATE: {
struct STFile **ppFile;
switch (pOp->nState.type) {
case TSDB_FTYPE_HEAD: {
ppFile = &pSet->fHead;
} break;
case TSDB_FTYPE_DATA: {
ppFile = &pSet->fData;
} break;
case TSDB_FTYPE_SMA: {
ppFile = &pSet->fSma;
} break;
case TSDB_FTYPE_TOMB: {
ppFile = &pSet->fTomb;
} break;
case TSDB_FTYPE_STT: {
// ppFile = &pSet->lStt[0].fStt;
} break;
default: {
ASSERTS(0, "Invalid file type");
} break;
}
// switch (pOp->op) {
// case TSDB_FOP_CREATE: {
// struct STFile **ppFile;
// switch (pOp->nState.type) {
// case TSDB_FTYPE_HEAD: {
// ppFile = &pSet->fHead;
// } break;
// case TSDB_FTYPE_DATA: {
// ppFile = &pSet->fData;
// } break;
// case TSDB_FTYPE_SMA: {
// ppFile = &pSet->fSma;
// } break;
// case TSDB_FTYPE_TOMB: {
// ppFile = &pSet->fTomb;
// } break;
// case TSDB_FTYPE_STT: {
// // ppFile = &pSet->lStt[0].fStt;
// } break;
// default: {
// ASSERTS(0, "Invalid file type");
// } break;
// }
TSDB_CHECK_CODE( //
code = tsdbTFileCreate(&pOp->nState, ppFile), //
lino, //
_exit);
} break;
// TSDB_CHECK_CODE( //
// code = tsdbTFileCreate(&pOp->nState, ppFile), //
// lino, //
// _exit);
// } break;
case TSDB_FOP_DELETE: {
ASSERTS(0, "TODO: Not implemented yet");
} break;
case TSDB_FOP_TRUNCATE: {
ASSERTS(0, "TODO: Not implemented yet");
} break;
case TSDB_FOP_EXTEND: {
ASSERTS(0, "TODO: Not implemented yet");
} break;
default: {
ASSERTS(0, "Invalid file operation");
} break;
}
// case TSDB_FOP_DELETE: {
// ASSERTS(0, "TODO: Not implemented yet");
// } break;
// case TSDB_FOP_TRUNCATE: {
// ASSERTS(0, "TODO: Not implemented yet");
// } break;
// case TSDB_FOP_EXTEND: {
// ASSERTS(0, "TODO: Not implemented yet");
// } break;
// default: {
// ASSERTS(0, "Invalid file operation");
// } break;
// }
_exit:
return code;
......
......@@ -42,18 +42,15 @@ struct SFileOp {
struct SSttLvl {
int32_t level;
int32_t nStt;
SSttLvl *pNext;
struct STFile *fSttList;
LISTD(SSttLvl) listNode;
};
struct SFileSet {
int32_t fid;
int64_t nextid;
struct STFile *fHead; // .head
struct STFile *fData; // .data
struct STFile *fSma; // .sma
struct STFile *fTomb; // .tomb
SSttLvl *sttLevelList;
struct STFile *farr[TSDB_FTYPE_MAX];
SSttLvl lvl0; // level 0 of .stt
};
int32_t tsdbFileSetCreate(int32_t fid, struct SFileSet **ppSet);
......
......@@ -23,23 +23,22 @@ extern "C" {
#endif
typedef enum {
TSDB_FTYPE_NONE = 0, // NONE
TSDB_FTYPE_HEAD, // .head
TSDB_FTYPE_HEAD = 0, // .head
TSDB_FTYPE_DATA, // .data
TSDB_FTYPE_SMA, // .sma
TSDB_FTYPE_TOMB, // .tomb
TSDB_FTYPE_MAX, // max
TSDB_FTYPE_STT, // .stt
} tsdb_ftype_t;
struct STFile {
char fname[TSDB_FILENAME_LEN];
int32_t ref;
tsdb_ftype_t type;
SDiskID diskId;
int64_t size;
int64_t cid;
int32_t fid;
int32_t ref;
char fname[TSDB_FILENAME_LEN];
};
int32_t tsdbTFileCreate(const struct STFile *config, struct STFile **ppFile);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册