提交 4c43901c 编写于 作者: H Hongze Cheng

more TDB

上级 54ca6c4e
...@@ -15,55 +15,84 @@ ...@@ -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;
}
while (nBytes > 0) {
iWrite = write(fd, pBuf, nBytes);
if (iWrite < 0) {
if (errno == EINTR) {
continue;
}
#if 0 return -1;
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; 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
\ No newline at end of file
...@@ -21,7 +21,7 @@ extern "C" { ...@@ -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; ...@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册