Merge branch '3.0' into feature/3.0_liaohj
This commit is contained in:
commit
778dd8a1cc
|
@ -43,35 +43,33 @@ typedef struct TqMetaList {
|
||||||
|
|
||||||
typedef struct TqMetaStore {
|
typedef struct TqMetaStore {
|
||||||
TqMetaList* inUse[TQ_INUSE_SIZE];
|
TqMetaList* inUse[TQ_INUSE_SIZE];
|
||||||
|
//a table head, key is empty
|
||||||
TqMetaList* unpersistHead;
|
TqMetaList* unpersistHead;
|
||||||
//deserializer
|
int fileFd; //TODO:temporaral use
|
||||||
//serializer
|
int idxFd; //TODO:temporaral use
|
||||||
//deleter
|
void* (*serializer)(void*);
|
||||||
|
void* (*deserializer)(void*);
|
||||||
|
void (*deleter)(void*);
|
||||||
} TqMetaStore;
|
} TqMetaStore;
|
||||||
|
|
||||||
typedef struct TqMetaPageBuf {
|
TqMetaStore* tqStoreOpen(const char* path, void* serializer(void* ), void* deserializer(void*), void deleter(void*));
|
||||||
int16_t offset;
|
int32_t tqStoreClose(TqMetaStore*);
|
||||||
char buffer[TQ_PAGE_SIZE];
|
int32_t tqStoreDelete(TqMetaStore*);
|
||||||
} TqMetaPageBuf;
|
//int32_t TqStoreCommitAll(TqMetaStore*);
|
||||||
|
int32_t tqStorePersist(TqMetaStore*);
|
||||||
|
|
||||||
TqMetaStore* TqStoreOpen(const char* path, void* serializer(void* ), void* deserializer(void*));
|
TqMetaHandle* tqHandleGetInUse(TqMetaStore*, int64_t key);
|
||||||
int32_t TqStoreClose(TqMetaStore*);
|
int32_t tqHandlePutInUse(TqMetaStore*, TqMetaHandle* handle);
|
||||||
int32_t TqStoreDelete(TqMetaStore*);
|
TqMetaHandle* tqHandleGetInTxn(TqMetaStore*, int64_t key);
|
||||||
int32_t TqStoreCommitAll(TqMetaStore*);
|
int32_t tqHandlePutInTxn(TqMetaStore*, TqMetaHandle* handle);
|
||||||
int32_t TqStorePersist(TqMetaStore*);
|
|
||||||
|
|
||||||
TqMetaHandle* TqHandleGetInUse(TqMetaStore*, int64_t key);
|
|
||||||
int32_t TqHandlePutInUse(TqMetaStore*, TqMetaHandle* handle);
|
|
||||||
TqMetaHandle* TqHandleGetInTxn(TqMetaStore*, int64_t key);
|
|
||||||
int32_t TqHandlePutInTxn(TqMetaStore*, TqMetaHandle* handle);
|
|
||||||
//delete in-use-handle, make in-txn-handle in use
|
//delete in-use-handle, make in-txn-handle in use
|
||||||
int32_t TqHandleCommit(TqMetaStore*, int64_t key);
|
int32_t tqHandleCommit(TqMetaStore*, int64_t key);
|
||||||
//delete in-txn-handle
|
//delete in-txn-handle
|
||||||
int32_t TqHandleAbort(TqMetaStore*, int64_t key);
|
int32_t tqHandleAbort(TqMetaStore*, int64_t key);
|
||||||
//delete in-use-handle
|
//delete in-use-handle
|
||||||
int32_t TqHandleDel(TqMetaStore*, int64_t key);
|
int32_t tqHandleDel(TqMetaStore*, int64_t key);
|
||||||
//delete in-use-handle and in-txn-handle
|
//delete in-use-handle and in-txn-handle
|
||||||
int32_t TqHandleClear(TqMetaStore*, int64_t key);
|
int32_t tqHandleClear(TqMetaStore*, int64_t key);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,3 +12,101 @@
|
||||||
* 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 "tqMetaStore.h"
|
||||||
|
//TODO:replace by a abstract file layer
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
typedef struct TqMetaPageBuf {
|
||||||
|
int16_t offset;
|
||||||
|
char buffer[TQ_PAGE_SIZE];
|
||||||
|
} TqMetaPageBuf;
|
||||||
|
|
||||||
|
TqMetaStore* tqStoreOpen(const char* path, void* serializer(void*),
|
||||||
|
void* deserializer(void*), void deleter(void*)) {
|
||||||
|
//concat data file name and index file name
|
||||||
|
int fileFd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0755);
|
||||||
|
if(fileFd < 0) return NULL;
|
||||||
|
TqMetaStore* pMeta = malloc(sizeof(TqMetaStore));
|
||||||
|
if(pMeta == NULL) {
|
||||||
|
//close
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memset(pMeta, 0, sizeof(TqMetaStore));
|
||||||
|
pMeta->fileFd = fileFd;
|
||||||
|
|
||||||
|
int idxFd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0755);
|
||||||
|
if(idxFd < 0) {
|
||||||
|
//close file
|
||||||
|
//free memory
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pMeta->idxFd = idxFd;
|
||||||
|
pMeta->unpersistHead = malloc(sizeof(TqMetaList));
|
||||||
|
if(pMeta->unpersistHead == NULL) {
|
||||||
|
//close file
|
||||||
|
//free memory
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pMeta->serializer = serializer;
|
||||||
|
pMeta->deserializer = deserializer;
|
||||||
|
pMeta->deleter = deleter;
|
||||||
|
return pMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqStoreClose(TqMetaStore* pMeta) {
|
||||||
|
//commit data and idx
|
||||||
|
//close file
|
||||||
|
//free memory
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqStoreDelete(TqMetaStore* pMeta) {
|
||||||
|
//close file
|
||||||
|
//delete file
|
||||||
|
//free memory
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqStorePersist(TqMetaStore* pMeta) {
|
||||||
|
TqMetaList *node = pMeta->unpersistHead;
|
||||||
|
while(node->unpersistNext) {
|
||||||
|
//serialize
|
||||||
|
//append data
|
||||||
|
//write offset and idx
|
||||||
|
//remove from unpersist list
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqHandlePutInUse(TqMetaStore* pMeta, TqMetaHandle* handle) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TqMetaHandle* tqHandleGetInUse(TqMetaStore* pMeta, int64_t key) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqHandlePutInTxn(TqMetaStore* pMeta, TqMetaHandle* handle) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TqMetaHandle* tqHandleGetInTxn(TqMetaStore* pMeta, int64_t key) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqHandleCommit(TqMetaStore* pMeta, int64_t key) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqHandleAbort(TqMetaStore* pMeta, int64_t key) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqHandleDel(TqMetaStore* pMeta, int64_t key) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqHandleClear(TqMetaStore* pMeta, int64_t key) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue