more progress
This commit is contained in:
parent
eef8f49af0
commit
36c20ec617
|
@ -1,31 +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_META_INT_H_
|
|
||||||
#define _TD_META_INT_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct {
|
|
||||||
tkv_db_t db;
|
|
||||||
} SMeta;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_META_INT_H_*/
|
|
|
@ -22,10 +22,22 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ------------------------ APIS EXPOSED ------------------------ */
|
||||||
typedef uint64_t tb_uid_t;
|
typedef uint64_t tb_uid_t;
|
||||||
tb_uid_t metaGenerateUid();
|
typedef struct STableUidGenerator STableUidGenerator;
|
||||||
|
|
||||||
|
// tb_uid_t
|
||||||
#define IVLD_TB_UID 0
|
#define IVLD_TB_UID 0
|
||||||
|
tb_uid_t generateUid(STableUidGenerator *);
|
||||||
|
|
||||||
|
// STableUidGenerator
|
||||||
|
void tableUidGeneratorInit(STableUidGenerator *, tb_uid_t suid);
|
||||||
|
#define tableUidGeneratorClear(ug)
|
||||||
|
|
||||||
|
/* ------------------------ FOR TEST AND COMPILE ONLY ------------------------ */
|
||||||
|
struct STableUidGenerator {
|
||||||
|
tb_uid_t nextUid;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tkv.h"
|
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
|
#include "tkv.h"
|
||||||
#include "tlist.h"
|
#include "tlist.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
|
@ -43,7 +43,8 @@ typedef struct STableObj {
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
pthread_rwlock_t rwLock;
|
pthread_rwlock_t rwLock;
|
||||||
|
|
||||||
SHashObj *pTableObjHash; // uid --> STableObj
|
STableUidGenerator uidGenerator;
|
||||||
|
SHashObj * pTableObjHash; // uid --> STableObj
|
||||||
SList * stbList; // super table list
|
SList * stbList; // super table list
|
||||||
STkvDb * tbnameDb; // tbname --> uid
|
STkvDb * tbnameDb; // tbname --> uid
|
||||||
STkvDb * tagDb; // uid --> tag
|
STkvDb * tagDb; // uid --> tag
|
||||||
|
@ -68,6 +69,7 @@ SMeta *metaOpen(SMetaOpts *options) {
|
||||||
|
|
||||||
pthread_rwlock_init(&(pMeta->rwLock), NULL);
|
pthread_rwlock_init(&(pMeta->rwLock), NULL);
|
||||||
|
|
||||||
|
tableUidGeneratorInit(&(pMeta->uidGenerator), IVLD_TB_UID);
|
||||||
pMeta->pTableObjHash = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
pMeta->pTableObjHash = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
pMeta->stbList = tdListNew(sizeof(STableObj *));
|
pMeta->stbList = tdListNew(sizeof(STableObj *));
|
||||||
|
@ -110,7 +112,7 @@ void metaClose(SMeta *pMeta) {
|
||||||
|
|
||||||
int metaCreateTable(SMeta *pMeta, STableOpts *pTableOpts) {
|
int metaCreateTable(SMeta *pMeta, STableOpts *pTableOpts) {
|
||||||
size_t vallen;
|
size_t vallen;
|
||||||
STkvReadOpts *ropt;
|
STkvReadOpts * ropt;
|
||||||
STableObj * pTableObj = NULL;
|
STableObj * pTableObj = NULL;
|
||||||
STkvWriteOpts *wopt;
|
STkvWriteOpts *wopt;
|
||||||
|
|
||||||
|
@ -133,7 +135,8 @@ int metaCreateTable(SMeta *pMeta, STableOpts *pTableOpts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create table object
|
// Create table object
|
||||||
pTableObj->pTable = metaTableNew(metaGenerateUid(), pTableOpts->name, schemaVersion(pTableOpts->pSchema));
|
pTableObj->pTable =
|
||||||
|
metaTableNew(generateUid(&(pMeta->uidGenerator)), pTableOpts->name, schemaVersion(pTableOpts->pSchema));
|
||||||
if (pTableObj->pTable == NULL) {
|
if (pTableObj->pTable == NULL) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,12 @@
|
||||||
|
|
||||||
#include "metaUid.h"
|
#include "metaUid.h"
|
||||||
|
|
||||||
static tb_uid_t nuid = IVLD_TB_UID;
|
tb_uid_t generateUid(STableUidGenerator *pGen) {
|
||||||
|
// Generate a new table UID
|
||||||
tb_uid_t metaGenerateUid() {
|
return ++(pGen->nextUid);
|
||||||
// TODO: need a more complex UID generator
|
}
|
||||||
return ++nuid;
|
|
||||||
|
void tableUidGeneratorInit(STableUidGenerator *pGen, tb_uid_t suid) {
|
||||||
|
// Init a generator
|
||||||
|
pGen->nextUid = suid;
|
||||||
}
|
}
|
Loading…
Reference in New Issue