more TDB
This commit is contained in:
parent
54ca6c4e8c
commit
4c43901c44
|
@ -15,55 +15,84 @@
|
||||||
|
|
||||||
#include "tdbInt.h"
|
#include "tdbInt.h"
|
||||||
|
|
||||||
|
#ifndef TDB_FOR_TDENGINE
|
||||||
|
|
||||||
// tdbOsRead
|
// tdbOsRead
|
||||||
i64 tdbOsRead(tdb_fd_t fd, void *pBuf, i64 nBytes) {
|
i64 tdbOsRead(tdb_fd_t fd, void *pData, i64 nBytes) {
|
||||||
// TODO
|
i64 nRead = 0;
|
||||||
ASSERT(0);
|
i64 iRead = 0;
|
||||||
return 0;
|
u8 *pBuf = (u8 *)pData;
|
||||||
|
|
||||||
|
while (nBytes > 0) {
|
||||||
|
iRead = read(fd, pBuf, nBytes);
|
||||||
|
if (iRead < 0) {
|
||||||
|
if (errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (iRead == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
nRead += iRead;
|
||||||
|
pBuf += iRead;
|
||||||
|
nBytes -= iRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tdbOsPRead
|
// tdbOsPRead
|
||||||
i64 tdbOsPRead(tdb_fd_t fd, void *pBuf, i64 nBytes, i64 offset) {
|
i64 tdbOsPRead(tdb_fd_t fd, void *pData, i64 nBytes, i64 offset) {
|
||||||
// TODO
|
i64 nRead = 0;
|
||||||
ASSERT(0);
|
i64 iRead = 0;
|
||||||
return 0;
|
i64 iOffset = offset;
|
||||||
|
u8 *pBuf = (u8 *)pData;
|
||||||
|
|
||||||
|
while (nBytes > 0) {
|
||||||
|
iRead = pread(fd, pBuf, nBytes, iOffset);
|
||||||
|
if (iRead < 0) {
|
||||||
|
if (errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (iRead == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
nRead += iRead;
|
||||||
|
pBuf += iRead;
|
||||||
|
iOffset += iRead;
|
||||||
|
nBytes -= iRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tdbOsWrite
|
// tdbOsWrite
|
||||||
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes) {
|
i64 taosWriteFile(tdb_fd_t fd, const void *pData, i64 nBytes) {
|
||||||
// TODO
|
i64 nWrite = 0;
|
||||||
ASSERT(0);
|
i64 iWrite = 0;
|
||||||
return 0;
|
u8 *pBuf = (u8 *)pData;
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
while (nBytes > 0) {
|
||||||
int tdbPRead(int fd, void *pData, int count, i64 offset) {
|
iWrite = write(fd, pBuf, nBytes);
|
||||||
void *pBuf;
|
if (iWrite < 0) {
|
||||||
int nbytes;
|
if (errno == EINTR) {
|
||||||
i64 ioffset;
|
continue;
|
||||||
int iread;
|
}
|
||||||
|
|
||||||
pBuf = pData;
|
return -1;
|
||||||
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;
|
nWrite += iWrite;
|
||||||
pBuf = (void *)((u8 *)pBuf + iread);
|
pBuf += iWrite;
|
||||||
ioffset += iread;
|
nBytes -= iWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return nWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbWrite(int fd, void *pData, int count) {
|
|
||||||
// TODO
|
|
||||||
return write(fd, pData, count);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: use cmake to control the option
|
// TODO: use cmake to control the option
|
||||||
#define TDB_FOR_TDENGINE
|
// #define TDB_FOR_TDENGINE
|
||||||
|
|
||||||
// For memory -----------------
|
// For memory -----------------
|
||||||
#ifdef TDB_FOR_TDENGINE
|
#ifdef TDB_FOR_TDENGINE
|
||||||
|
@ -67,9 +67,9 @@ typedef int tdb_fd_t;
|
||||||
#define tdbOsOpen open
|
#define tdbOsOpen open
|
||||||
#define tdbOsClose close
|
#define tdbOsClose close
|
||||||
|
|
||||||
i64 tdbOsRead(tdb_fd_t fd, void *pBuf, i64 nBytes);
|
i64 tdbOsRead(tdb_fd_t fd, void *pData, i64 nBytes);
|
||||||
i64 tdbOsPRead(tdb_fd_t fd, void *pBuf, i64 nBytes, i64 offset);
|
i64 tdbOsPRead(tdb_fd_t fd, void *pData, i64 nBytes, i64 offset);
|
||||||
i64 taosWriteFile(tdb_fd_t fd, const void *pBuf, i64 nBytes);
|
i64 taosWriteFile(tdb_fd_t fd, const void *pData, i64 nBytes);
|
||||||
|
|
||||||
#define tdbOsFSync fsync
|
#define tdbOsFSync fsync
|
||||||
#define tdbOsLSeek lseek
|
#define tdbOsLSeek lseek
|
||||||
|
|
Loading…
Reference in New Issue