more TDB
This commit is contained in:
parent
5c9c9695e5
commit
5f90bae8bb
|
@ -31,7 +31,39 @@ i64 tdbOsPRead(tdb_fd_t fd, void *pBuf, i64 nBytes, i64 offset) {
|
|||
|
||||
// tdbOsWrite
|
||||
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes) {
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int tdbPRead(int fd, void *pData, int count, i64 offset) {
|
||||
void *pBuf;
|
||||
int nbytes;
|
||||
i64 ioffset;
|
||||
int iread;
|
||||
|
||||
pBuf = pData;
|
||||
nbytes = count;
|
||||
ioffset = offset;
|
||||
while (nbytes > 0) {
|
||||
iread = pread(fd, pBuf, nbytes, ioffset);
|
||||
if (iread < 0) {
|
||||
/* TODO */
|
||||
} else if (iread == 0) {
|
||||
return (count - iread);
|
||||
}
|
||||
|
||||
nbytes = nbytes - iread;
|
||||
pBuf = (void *)((u8 *)pBuf + iread);
|
||||
ioffset += iread;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int tdbWrite(int fd, void *pData, int count) {
|
||||
// TODO
|
||||
return write(fd, pData, count);
|
||||
}
|
||||
#endif
|
|
@ -209,7 +209,7 @@ int tdbPagerCommit(SPager *pPager) {
|
|||
tdbOsFSync(pPager->fd);
|
||||
|
||||
tdbOsClose(pPager->jfd);
|
||||
remove(pPager->jFileName);
|
||||
tdbOsRemove(pPager->jFileName);
|
||||
// pPager->jfd = -1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -33,28 +33,10 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// int tdbCheckFileAccess(const char *pathname, int mode) {
|
||||
// int flags = 0;
|
||||
|
||||
// if (mode & TDB_F_OK) {
|
||||
// flags |= F_OK;
|
||||
// }
|
||||
|
||||
// if (mode & TDB_R_OK) {
|
||||
// flags |= R_OK;
|
||||
// }
|
||||
|
||||
// if (mode & TDB_W_OK) {
|
||||
// flags |= W_OK;
|
||||
// }
|
||||
|
||||
// return access(pathname, flags);
|
||||
// }
|
||||
|
||||
int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
|
||||
struct stat st;
|
||||
int ret;
|
||||
int64_t file_size = 0;
|
||||
int64_t file_size = 0;
|
||||
ret = taosStatFile(fname, &file_size, NULL);
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
|
@ -64,34 +46,4 @@ int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
|
|||
|
||||
*pSize = file_size / pgSize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdbPRead(int fd, void *pData, int count, i64 offset) {
|
||||
void *pBuf;
|
||||
int nbytes;
|
||||
i64 ioffset;
|
||||
int iread;
|
||||
|
||||
pBuf = pData;
|
||||
nbytes = count;
|
||||
ioffset = offset;
|
||||
while (nbytes > 0) {
|
||||
iread = pread(fd, pBuf, nbytes, ioffset);
|
||||
if (iread < 0) {
|
||||
/* TODO */
|
||||
} else if (iread == 0) {
|
||||
return (count - iread);
|
||||
}
|
||||
|
||||
nbytes = nbytes - iread;
|
||||
pBuf = (void *)((u8 *)pBuf + iread);
|
||||
ioffset += iread;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int tdbWrite(int fd, void *pData, int count) {
|
||||
// TODO
|
||||
return write(fd, pData, count);
|
||||
}
|
|
@ -53,6 +53,7 @@ typedef TdFilePtr tdb_fd_t;
|
|||
#define tdbOsWrite taosWriteFile
|
||||
#define tdbOsFSync taosFsyncFile
|
||||
#define tdbOsLSeek taosLSeekFile
|
||||
#define tdbOsRemove remove
|
||||
|
||||
/* directory */
|
||||
#define tdbOsMkdir taosMkDir
|
||||
|
@ -70,12 +71,13 @@ i64 tdbOsRead(tdb_fd_t fd, void *pBuf, i64 nBytes);
|
|||
i64 tdbOsPRead(tdb_fd_t fd, void *pBuf, i64 nBytes, i64 offset);
|
||||
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes);
|
||||
|
||||
#define tdbOsFSync fsync
|
||||
#define tdbOsLSeek lseek
|
||||
#define tdbOsFSync fsync
|
||||
#define tdbOsLSeek lseek
|
||||
#define tdbOsRemove remove
|
||||
|
||||
/* directory */
|
||||
#define tdbOsMkdir mkdir
|
||||
#define tdbOsRmdir rmdir
|
||||
#define tdbOsMkdir mkdir
|
||||
#define tdbOsRmdir rmdir
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -30,16 +30,8 @@ extern "C" {
|
|||
|
||||
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique);
|
||||
|
||||
// #define TDB_F_OK 0x1
|
||||
// #define TDB_R_OK 0x2
|
||||
// #define TDB_W_OK 0x4
|
||||
// int tdbCheckFileAccess(const char *pathname, int mode);
|
||||
|
||||
int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize);
|
||||
|
||||
int tdbPRead(int fd, void *pData, int count, i64 offset);
|
||||
int tdbWrite(int fd, void *pData, int count);
|
||||
|
||||
#define TDB_REALLOC(PTR, SIZE) \
|
||||
({ \
|
||||
void *nPtr; \
|
||||
|
@ -55,11 +47,11 @@ int tdbWrite(int fd, void *pData, int count);
|
|||
nPtr; \
|
||||
})
|
||||
|
||||
#define TDB_FREE(PTR) \
|
||||
do { \
|
||||
if (PTR) { \
|
||||
#define TDB_FREE(PTR) \
|
||||
do { \
|
||||
if (PTR) { \
|
||||
tdbOsFree((char *)(PTR) - sizeof(int)); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static inline void *tdbDefaultMalloc(void *arg, size_t size) {
|
||||
|
|
Loading…
Reference in New Issue