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
|
// tdbOsWrite
|
||||||
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes) {
|
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes) {
|
||||||
// TODO
|
// TODO
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return 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);
|
tdbOsFSync(pPager->fd);
|
||||||
|
|
||||||
tdbOsClose(pPager->jfd);
|
tdbOsClose(pPager->jfd);
|
||||||
remove(pPager->jFileName);
|
tdbOsRemove(pPager->jFileName);
|
||||||
// pPager->jfd = -1;
|
// pPager->jfd = -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -33,28 +33,10 @@ int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique) {
|
||||||
return 0;
|
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) {
|
int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int ret;
|
int ret;
|
||||||
int64_t file_size = 0;
|
int64_t file_size = 0;
|
||||||
ret = taosStatFile(fname, &file_size, NULL);
|
ret = taosStatFile(fname, &file_size, NULL);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -64,34 +46,4 @@ int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize) {
|
||||||
|
|
||||||
*pSize = file_size / pgSize;
|
*pSize = file_size / pgSize;
|
||||||
return 0;
|
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 tdbOsWrite taosWriteFile
|
||||||
#define tdbOsFSync taosFsyncFile
|
#define tdbOsFSync taosFsyncFile
|
||||||
#define tdbOsLSeek taosLSeekFile
|
#define tdbOsLSeek taosLSeekFile
|
||||||
|
#define tdbOsRemove remove
|
||||||
|
|
||||||
/* directory */
|
/* directory */
|
||||||
#define tdbOsMkdir taosMkDir
|
#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 tdbOsPRead(tdb_fd_t fd, void *pBuf, i64 nBytes, i64 offset);
|
||||||
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes);
|
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes);
|
||||||
|
|
||||||
#define tdbOsFSync fsync
|
#define tdbOsFSync fsync
|
||||||
#define tdbOsLSeek lseek
|
#define tdbOsLSeek lseek
|
||||||
|
#define tdbOsRemove remove
|
||||||
|
|
||||||
/* directory */
|
/* directory */
|
||||||
#define tdbOsMkdir mkdir
|
#define tdbOsMkdir mkdir
|
||||||
#define tdbOsRmdir rmdir
|
#define tdbOsRmdir rmdir
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -30,16 +30,8 @@ extern "C" {
|
||||||
|
|
||||||
int tdbGnrtFileID(const char *fname, uint8_t *fileid, bool unique);
|
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 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) \
|
#define TDB_REALLOC(PTR, SIZE) \
|
||||||
({ \
|
({ \
|
||||||
void *nPtr; \
|
void *nPtr; \
|
||||||
|
@ -55,11 +47,11 @@ int tdbWrite(int fd, void *pData, int count);
|
||||||
nPtr; \
|
nPtr; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define TDB_FREE(PTR) \
|
#define TDB_FREE(PTR) \
|
||||||
do { \
|
do { \
|
||||||
if (PTR) { \
|
if (PTR) { \
|
||||||
tdbOsFree((char *)(PTR) - sizeof(int)); \
|
tdbOsFree((char *)(PTR) - sizeof(int)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static inline void *tdbDefaultMalloc(void *arg, size_t size) {
|
static inline void *tdbDefaultMalloc(void *arg, size_t size) {
|
||||||
|
|
Loading…
Reference in New Issue