提交 3dc82d1b 编写于 作者: H Hongze Cheng

more TDB

上级 5831222f
......@@ -29,8 +29,7 @@ typedef struct STDbEnv TENV;
// TDB
int tdbCreate(TDB **ppDb);
int tdbDestroy(TDB *pDb);
int tdbOpen(TDB **pDb, const char *fname, const char *dbname);
int tdbOpen(TDB **ppDb, const char *fname, const char *dbname, TENV *pEnv);
int tdbClose(TDB *pDb);
#ifdef __cplusplus
......
......@@ -34,20 +34,39 @@ int tdbCreate(TDB **ppDb) {
return 0;
}
int tdbDestroy(TDB *pDb) {
static int tdbDestroy(TDB *pDb) {
if (pDb) {
free(pDb);
}
/* TODO */
return 0;
}
int tdbOpen(TDB **pDb, const char *fname, const char *dbname) {
// TODO
int tdbOpen(TDB **ppDb, const char *fname, const char *dbname, TENV *pEnv) {
TDB *pDb;
int ret;
// Create DB if DB handle is not created yet
if (ppDb == NULL) {
if ((ret = tdbCreate(ppDb)) != 0) {
return -1;
}
}
pDb = *ppDb;
// Create a default ENV if pEnv is not set
if (pEnv == NULL) {
// if ((ret = tenvOpen(&pEnv)) != 0) {
// return -1;
// }
}
/* TODO */
return 0;
}
int tdbClose(TDB *pDb) {
// TODO
return 0;
if (pDb == NULL) return 0;
return tdbDestroy(pDb);
}
\ No newline at end of file
......@@ -18,5 +18,7 @@
struct STDbEnv {
TDB * dbList; // TDB list
SPgFile *pgFileList; // SPgFile list
SPgCache pgc; // page cache
struct {
} pgfht; // page file hash table;
SPgCache pgc; // page cache
};
\ No newline at end of file
......@@ -80,9 +80,7 @@ typedef int32_t pgsize_t;
#include "pgcache.h"
#include "pgfile.h"
#include "tdbEnv.h"
// tdb util
int tdbGnrtFileID(const char *fname, uint8_t *fileid);
#include "tdbUtil.h"
#ifdef __cplusplus
}
......
/*
* 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 _TDB_UTIL_H_
#define _TDB_UTIL_H_
#ifdef __cplusplus
extern "C" {
#endif
int tdbGnrtFileID(const char *fname, uint8_t *fileid);
#ifdef __cplusplus
}
#endif
#endif /*_TDB_UTIL_H_*/
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册