提交 c8c09c8a 编写于 作者: H Hongze Cheng

refact

上级 c3113421
add_subdirectory(transport) add_subdirectory(transport)
add_subdirectory(sync) add_subdirectory(sync)
add_subdirectory(tkv) add_subdirectory(tdb)
add_subdirectory(index) add_subdirectory(index)
add_subdirectory(wal) add_subdirectory(wal)
add_subdirectory(parser) add_subdirectory(parser)
......
aux_source_directory(src TKV_SRC) aux_source_directory(src TDB_SRC)
add_library(tkv STATIC ${TKV_SRC}) add_library(tdb STATIC ${TDB_SRC})
# target_include_directories( # target_include_directories(
# tkv # tkv
# PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/tkv" # PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/tkv"
# PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" # PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
# ) # )
target_include_directories( target_include_directories(
tkv tdb
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/inc" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/inc"
) )
target_link_libraries( target_link_libraries(
tkv tdb
PUBLIC os PUBLIC os
PUBLIC util PUBLIC util
) )
\ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TKV_H_ #ifndef _TD_TDB_H_
#define _TD_TKV_H_ #define _TD_TDB_H_
#include "os.h" #include "os.h"
...@@ -28,7 +28,7 @@ typedef struct TDB_ENV TDB_ENV; ...@@ -28,7 +28,7 @@ typedef struct TDB_ENV TDB_ENV;
// SKey // SKey
typedef struct { typedef struct {
void * bdata; void* bdata;
uint32_t size; uint32_t size;
} TDB_KEY, TDB_VALUE; } TDB_KEY, TDB_VALUE;
...@@ -36,4 +36,4 @@ typedef struct { ...@@ -36,4 +36,4 @@ typedef struct {
} }
#endif #endif
#endif /*_TD_TKV_H_*/ #endif /*_TD_TDB_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TKV_BTREE_H_ #ifndef _TD_TDB_BTREE_H_
#define _TD_TKV_BTREE_H_ #define _TD_TDB_BTREE_H_
#include "tkvDef.h" #include "tkvDef.h"
...@@ -24,10 +24,10 @@ extern "C" { ...@@ -24,10 +24,10 @@ extern "C" {
typedef struct { typedef struct {
pgid_t root; // root page number pgid_t root; // root page number
} STkvBtree; } TDB_BTREE;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /*_TD_TKV_BTREE_H_*/ #endif /*_TD_TDB_BTREE_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TKV_BUF_POOL_H_ #ifndef _TD_TDB_BUF_POOL_H_
#define _TD_TKV_BUF_POOL_H_ #define _TD_TDB_BUF_POOL_H_
#include "tkvPage.h" #include "tdbPage.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -26,9 +26,9 @@ typedef struct STkvBufPool STkvBufPool; ...@@ -26,9 +26,9 @@ typedef struct STkvBufPool STkvBufPool;
int tbpOpen(STkvBufPool **ppTkvBufPool); int tbpOpen(STkvBufPool **ppTkvBufPool);
int tbpClose(STkvBufPool *pTkvBufPool); int tbpClose(STkvBufPool *pTkvBufPool);
STkvPage *tbpNewPage(STkvBufPool *pTkvBufPool); STdbPage *tbpNewPage(STkvBufPool *pTkvBufPool);
int tbpDelPage(STkvBufPool *pTkvBufPool); int tbpDelPage(STkvBufPool *pTkvBufPool);
STkvPage *tbpFetchPage(STkvBufPool *pTkvBufPool, pgid_t pgid); STdbPage *tbpFetchPage(STkvBufPool *pTkvBufPool, pgid_t pgid);
int tbpUnpinPage(STkvBufPool *pTkvBufPool, pgid_t pgid); int tbpUnpinPage(STkvBufPool *pTkvBufPool, pgid_t pgid);
void tbpFlushPages(STkvBufPool *pTkvBufPool); void tbpFlushPages(STkvBufPool *pTkvBufPool);
...@@ -36,4 +36,4 @@ void tbpFlushPages(STkvBufPool *pTkvBufPool); ...@@ -36,4 +36,4 @@ void tbpFlushPages(STkvBufPool *pTkvBufPool);
} }
#endif #endif
#endif /*_TD_TKV_BUF_POOL_H_*/ #endif /*_TD_TDB_BUF_POOL_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TKV_DB_H_ #ifndef _TD_TDB_DB_H_
#define _TD_TKV_DB_H_ #define _TD_TDB_DB_H_
#include "tkvBtree.h" #include "tdbBtree.h"
#include "tkvHash.h" #include "tdbHash.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -42,4 +42,4 @@ struct TDB { ...@@ -42,4 +42,4 @@ struct TDB {
} }
#endif #endif
#endif /*_TD_TKV_DB_H_*/ #endif /*_TD_TDB_DB_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TKV_DEF_H_ #ifndef _TD_TDB_DEF_H_
#define _TD_TKV_DEF_H_ #define _TD_TDB_DEF_H_
#include "os.h" #include "os.h"
...@@ -39,4 +39,4 @@ typedef int32_t pgsize_t; ...@@ -39,4 +39,4 @@ typedef int32_t pgsize_t;
} }
#endif #endif
#endif /*_TD_TKV_DEF_H_*/ #endif /*_TD_TDB_DEF_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
#include "os.h" #include "os.h"
#include "tkvDef.h" #include "tdbDef.h"
typedef struct STkvDiskMgr STkvDiskMgr; typedef struct STkvDiskMgr STkvDiskMgr;
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _TD_TKV_ENV_H_ #ifndef _TD_TDB_ENV_H_
#define _TD_TKV_ENV_H_ #define _TD_TDB_ENV_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -28,4 +28,4 @@ struct TDB_ENV { ...@@ -28,4 +28,4 @@ struct TDB_ENV {
} }
#endif #endif
#endif /*_TD_TKV_ENV_H_*/ #endif /*_TD_TDB_ENV_H_*/
\ No newline at end of file \ No newline at end of file
...@@ -16,15 +16,15 @@ ...@@ -16,15 +16,15 @@
#ifndef _TD_TKV_HAHS_H_ #ifndef _TD_TKV_HAHS_H_
#define _TD_TKV_HAHS_H_ #define _TD_TKV_HAHS_H_
#include "tkvDef.h" #include "tdbDef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct STkvHash { typedef struct {
// TODO // TODO
} STkvHash; } TDB_HASH;
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -17,30 +17,24 @@ ...@@ -17,30 +17,24 @@
#define _TD_TKV_PAGE_H_ #define _TD_TKV_PAGE_H_
#include "os.h" #include "os.h"
#include "tkvDef.h" #include "tdbDef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct STkvPage { typedef struct {
pgid_t pgid; pgid_t pgid;
int32_t pinCount; int32_t pinCount;
bool idDirty; bool idDirty;
char* pData; char* pData;
} STkvPage; } STdbPage;
typedef struct { typedef struct {
uint16_t dbver; uint16_t dbver;
uint16_t pgsize; uint16_t pgsize;
uint32_t cksm; uint32_t cksm;
} STkvPgHdr; } STdbPgHdr;
// typedef struct {
// SPgHdr chdr;
// uint16_t used; // number of used slots
// uint16_t loffset; // the offset of the starting location of the last slot used
// } SSlottedPgHdr;
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -26,7 +26,7 @@ struct SFrameIdWrapper { ...@@ -26,7 +26,7 @@ struct SFrameIdWrapper {
}; };
struct STkvBufPool { struct STkvBufPool {
STkvPage* pages; STdbPage* pages;
STkvDiskMgr* pDiskMgr; STkvDiskMgr* pDiskMgr;
SHashObj* pgTb; // page_id_t --> frame_id_t SHashObj* pgTb; // page_id_t --> frame_id_t
TD_SLIST(SFrameIdWrapper) freeList; TD_SLIST(SFrameIdWrapper) freeList;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "tkvDiskMgr.h" #include "tdbDiskMgr.h"
struct STkvDiskMgr { struct STkvDiskMgr {
char * fname; char * fname;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册