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

refact

上级 64cb09cc
......@@ -11,4 +11,6 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
\ No newline at end of file
*/
#include "tdbInt.h"
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tdbInt.h"
\ No newline at end of file
......@@ -11,4 +11,6 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
\ No newline at end of file
*/
#include "tdbInt.h"
\ No newline at end of file
......@@ -13,61 +13,61 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tdb_db.h"
#include "tdbInt.h"
static int tdbOpenImpl(TDB *dbp);
// static int tdbOpenImpl(TDB *dbp);
int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) {
TDB * dbp;
TDB_MPFILE *mpf;
uint8_t fileid[TDB_FILE_ID_LEN];
// int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) {
// TDB * dbp;
// TDB_MPFILE *mpf;
// uint8_t fileid[TDB_FILE_ID_LEN];
if ((dbp = (TDB *)calloc(1, sizeof(*dbp))) == NULL) {
return -1;
}
// if ((dbp = (TDB *)calloc(1, sizeof(*dbp))) == NULL) {
// return -1;
// }
if ((dbp->fname = strdup(fname)) == NULL) {
free(dbp);
return -1;
}
// if ((dbp->fname = strdup(fname)) == NULL) {
// free(dbp);
// return -1;
// }
if ((dbname) && ((dbp->dbname = strdup(dbname)) == NULL)) {
free(dbp->fname);
free(dbp);
return -1;
}
// if ((dbname) && ((dbp->dbname = strdup(dbname)) == NULL)) {
// free(dbp->fname);
// free(dbp);
// return -1;
// }
// if (tdbGnrtFileID(fname, fileid) < 0) {
// // todo
// return -1;
// }
// // if (tdbGnrtFileID(fname, fileid) < 0) {
// // // todo
// // return -1;
// // }
// TODO: mpf = tdbGetMPFileByID(fileid);
if (mpf == NULL) {
// todoerr: maybe we need to create one
return -1;
}
// // TODO: mpf = tdbGetMPFileByID(fileid);
// if (mpf == NULL) {
// // todoerr: maybe we need to create one
// return -1;
// }
if (tdbOpenImpl(dbp) < 0) {
// todoerr
return -1;
}
// if (tdbOpenImpl(dbp) < 0) {
// // todoerr
// return -1;
// }
*dbpp = dbp;
return 0;
}
// *dbpp = dbp;
// return 0;
// }
int tdbClose(TDB *dbp, uint32_t flags) {
// TODO
return 0;
}
// int tdbClose(TDB *dbp, uint32_t flags) {
// // TODO
// return 0;
// }
static int tdbOpenImpl(TDB *dbp) {
if (dbp->dbname == NULL) {
// todo: open the DB as a master DB
} else {
// todo: open the DB as a sub-db
}
// TODO
return 0;
}
\ No newline at end of file
// static int tdbOpenImpl(TDB *dbp) {
// if (dbp->dbname == NULL) {
// // todo: open the DB as a master DB
// } else {
// // todo: open the DB as a sub-db
// }
// // TODO
// return 0;
// }
\ No newline at end of file
......@@ -16,6 +16,8 @@
#ifndef _TD_BTREE_H_
#define _TD_BTREE_H_
#include "tdbInt.h"
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -16,12 +16,21 @@
#ifndef _TD_PAGE_FILE_H_
#define _TD_PAGE_FILE_H_
#include "tdbInt.h"
#include "pgcache.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SPgFile SPgFile;
struct SPgFile {
char * fname; // backend file name
SPgCache *pPgCache; // page cache underline
};
#ifdef __cplusplus
}
#endif
......
......@@ -20,6 +20,8 @@
#include "tlist.h"
#include "tlockfree.h"
#include "tdb.h"
#ifdef __cplusplus
extern "C" {
#endif
......@@ -51,6 +53,8 @@ typedef int32_t pgsize_t;
// tdb_log
#define tdbError(var)
#include "pgcache.h"
// tdb util
int tdbGnrtFileID(const char *fname, uint8_t *fileid);
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_TDB_DB_H_
#define _TD_TDB_DB_H_
#include "tdb_mpool.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct TDB TDB;
struct TDB {
char * fname;
char * dbname;
TDB_MPFILE *mpf;
// union {
// TDB_BTREE *btree;
// TDB_HASH * hash;
// TDB_HEAP * heap;
// } dbam; // db access method
};
int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags);
int tdbClose(TDB *dbp, uint32_t flags);
#ifdef __cplusplus
}
#endif
#endif /*_TD_TDB_DB_H_*/
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册