more tdb
This commit is contained in:
parent
cb9ca05b03
commit
065f3d9682
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include "tdb_mpool.h"
|
||||
|
||||
static int tdbGnrtFileID(const char *fname, uint8_t *fileid);
|
||||
static void tdbMPoolRegFile(TDB_MPOOL *mp, TDB_MPFILE *mpf);
|
||||
static void tdbMPoolUnregFile(TDB_MPOOL *mp, TDB_MPFILE *mpf);
|
||||
static TDB_MPFILE *tdbMPoolGetFile(TDB_MPOOL *mp, uint8_t *fileid);
|
||||
|
@ -230,22 +229,6 @@ int tdbMPoolFilePutPage(TDB_MPFILE *mpf, pgno_t pgno, void *addr) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int tdbGnrtFileID(const char *fname, uint8_t *fileid) {
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat(fname, &statbuf) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(fileid, 0, TDB_FILE_ID_LEN);
|
||||
|
||||
((uint64_t *)fileid)[0] = (uint64_t)statbuf.st_ino;
|
||||
((uint64_t *)fileid)[1] = (uint64_t)statbuf.st_dev;
|
||||
((uint64_t *)fileid)[2] = rand();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define MPF_GET_BUCKETID(fileid) \
|
||||
({ \
|
||||
uint64_t *tmp = (uint64_t *)fileid; \
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 "tdb_inc.h"
|
||||
|
||||
int tdbGnrtFileID(const char *fname, uint8_t *fileid) {
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat(fname, &statbuf) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(fileid, 0, TDB_FILE_ID_LEN);
|
||||
|
||||
((uint64_t *)fileid)[0] = (uint64_t)statbuf.st_ino;
|
||||
((uint64_t *)fileid)[1] = (uint64_t)statbuf.st_dev;
|
||||
((uint64_t *)fileid)[2] = rand();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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_BTREE_H_
|
||||
#define _TDB_BTREE_H_
|
||||
|
||||
#include "tdb_inc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct SBTree {
|
||||
pgno_t root; // root page number
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TDB_BTREE_H_*/
|
|
@ -51,6 +51,9 @@ typedef int32_t pgsize_t;
|
|||
// tdb_log
|
||||
#define tdbError(var)
|
||||
|
||||
// tdb util
|
||||
int tdbGnrtFileID(const char *fname, uint8_t *fileid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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_PAGE_H_
|
||||
#define _TDB_PAGE_H_
|
||||
|
||||
#include "tdb_inc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Page header
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
pgno_t pgno; // current page number
|
||||
pgno_t npgno; // next page number
|
||||
pgno_t ppgno; // prev page number
|
||||
} SPgHdr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TDB_PAGE_H_*/
|
Loading…
Reference in New Issue