refact
This commit is contained in:
parent
64cb09cc3a
commit
fd94249ffd
|
@ -12,3 +12,5 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "tdbInt.h"
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* 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"
|
|
@ -12,3 +12,5 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "tdbInt.h"
|
|
@ -13,61 +13,61 @@
|
||||||
* 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 "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) {
|
// int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) {
|
||||||
TDB * dbp;
|
// TDB * dbp;
|
||||||
TDB_MPFILE *mpf;
|
// TDB_MPFILE *mpf;
|
||||||
uint8_t fileid[TDB_FILE_ID_LEN];
|
// uint8_t fileid[TDB_FILE_ID_LEN];
|
||||||
|
|
||||||
if ((dbp = (TDB *)calloc(1, sizeof(*dbp))) == NULL) {
|
// if ((dbp = (TDB *)calloc(1, sizeof(*dbp))) == NULL) {
|
||||||
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 (tdbGnrtFileID(fname, fileid) < 0) {
|
|
||||||
// // todo
|
|
||||||
// return -1;
|
// return -1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// TODO: mpf = tdbGetMPFileByID(fileid);
|
// if ((dbp->fname = strdup(fname)) == NULL) {
|
||||||
if (mpf == NULL) {
|
// free(dbp);
|
||||||
// todoerr: maybe we need to create one
|
// return -1;
|
||||||
return -1;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
if (tdbOpenImpl(dbp) < 0) {
|
// if ((dbname) && ((dbp->dbname = strdup(dbname)) == NULL)) {
|
||||||
// todoerr
|
// free(dbp->fname);
|
||||||
return -1;
|
// free(dbp);
|
||||||
}
|
// return -1;
|
||||||
|
// }
|
||||||
|
|
||||||
*dbpp = dbp;
|
// // if (tdbGnrtFileID(fname, fileid) < 0) {
|
||||||
return 0;
|
// // // todo
|
||||||
}
|
// // return -1;
|
||||||
|
// // }
|
||||||
|
|
||||||
int tdbClose(TDB *dbp, uint32_t flags) {
|
// // TODO: mpf = tdbGetMPFileByID(fileid);
|
||||||
// TODO
|
// if (mpf == NULL) {
|
||||||
return 0;
|
// // todoerr: maybe we need to create one
|
||||||
}
|
// return -1;
|
||||||
|
// }
|
||||||
|
|
||||||
static int tdbOpenImpl(TDB *dbp) {
|
// if (tdbOpenImpl(dbp) < 0) {
|
||||||
if (dbp->dbname == NULL) {
|
// // todoerr
|
||||||
// todo: open the DB as a master DB
|
// return -1;
|
||||||
} else {
|
// }
|
||||||
// todo: open the DB as a sub-db
|
|
||||||
}
|
// *dbpp = dbp;
|
||||||
// TODO
|
// return 0;
|
||||||
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;
|
||||||
|
// }
|
|
@ -16,6 +16,8 @@
|
||||||
#ifndef _TD_BTREE_H_
|
#ifndef _TD_BTREE_H_
|
||||||
#define _TD_BTREE_H_
|
#define _TD_BTREE_H_
|
||||||
|
|
||||||
|
#include "tdbInt.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,12 +16,21 @@
|
||||||
#ifndef _TD_PAGE_FILE_H_
|
#ifndef _TD_PAGE_FILE_H_
|
||||||
#define _TD_PAGE_FILE_H_
|
#define _TD_PAGE_FILE_H_
|
||||||
|
|
||||||
|
#include "tdbInt.h"
|
||||||
|
|
||||||
|
#include "pgcache.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SPgFile SPgFile;
|
typedef struct SPgFile SPgFile;
|
||||||
|
|
||||||
|
struct SPgFile {
|
||||||
|
char * fname; // backend file name
|
||||||
|
SPgCache *pPgCache; // page cache underline
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "tlist.h"
|
#include "tlist.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
|
|
||||||
|
#include "tdb.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,6 +53,8 @@ typedef int32_t pgsize_t;
|
||||||
// tdb_log
|
// tdb_log
|
||||||
#define tdbError(var)
|
#define tdbError(var)
|
||||||
|
|
||||||
|
#include "pgcache.h"
|
||||||
|
|
||||||
// tdb util
|
// tdb util
|
||||||
int tdbGnrtFileID(const char *fname, uint8_t *fileid);
|
int tdbGnrtFileID(const char *fname, uint8_t *fileid);
|
||||||
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* 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_*/
|
|
Loading…
Reference in New Issue