tdb/write: new tdbPWriteFile api for commit and prep async to maindb
This commit is contained in:
parent
2c771153ef
commit
7a7d7f7d00
|
@ -88,6 +88,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
|
|||
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
||||
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
||||
int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t offset);
|
||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
||||
|
||||
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf);
|
||||
|
|
|
@ -52,6 +52,7 @@ typedef TdFilePtr tdb_fd_t;
|
|||
#define tdbOsRead taosReadFile
|
||||
#define tdbOsPRead taosPReadFile
|
||||
#define tdbOsWrite taosWriteFile
|
||||
#define tdbOsPWrite taosPWriteFile
|
||||
#define tdbOsFSync taosFsyncFile
|
||||
#define tdbOsLSeek taosLSeekFile
|
||||
#define tdbOsRemove remove
|
||||
|
|
|
@ -491,6 +491,28 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
|
|||
return count;
|
||||
}
|
||||
|
||||
int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t offset) {
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockWrlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
#ifdef WINDOWS
|
||||
size_t pos = _lseeki64(pFile->fd, 0, SEEK_CUR);
|
||||
_lseeki64(pFile->fd, offset, SEEK_SET);
|
||||
int64_t ret = _write(pFile->fd, buf, count);
|
||||
_lseeki64(pFile->fd, pos, SEEK_SET);
|
||||
#else
|
||||
int64_t ret = pwrite(pFile->fd, buf, count, offset);
|
||||
#endif
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
|
|
Loading…
Reference in New Issue