Merge pull request #1494 from taosdata/feature/2.0tsdb

Feature/2.0tsdb
This commit is contained in:
slguan 2020-04-02 10:08:28 +08:00 committed by GitHub
commit 6e9003b2ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -356,7 +356,7 @@ int tsdbCreateFile(char *dataDir, int fileId, const char *suffix, int maxTables,
return -1; return -1;
} }
if (tsdbOpenFile(pFile, O_WRONLY | O_CREAT) < 0) { if (tsdbOpenFile(pFile, O_RDWR | O_CREAT) < 0) {
// TODO: deal with the ERROR here // TODO: deal with the ERROR here
return -1; return -1;
} }

View File

@ -13,6 +13,7 @@
// #include "taosdef.h" // #include "taosdef.h"
// #include "disk.h" // #include "disk.h"
#include "os.h"
#include "tsdb.h" #include "tsdb.h"
#include "tsdbMain.h" #include "tsdbMain.h"
@ -914,7 +915,8 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
pGroup = tsdbOpenFilesForCommit(pFileH, fid); pGroup = tsdbOpenFilesForCommit(pFileH, fid);
if (pGroup == NULL) { /* TODO */ if (pGroup == NULL) { /* TODO */
} }
tsdbCreateFile(dataDir, fid, ".h", pCfg->maxTables, &hFile, 1, 0); tsdbCreateFile(dataDir, fid, ".h", pCfg->maxTables, &hFile, 1, 1);
tsdbOpenFile(&hFile, O_RDWR);
if (0 /*pGroup->files[TSDB_FILE_TYPE_LAST].size > TSDB_MAX_LAST_FILE_SIZE*/) { if (0 /*pGroup->files[TSDB_FILE_TYPE_LAST].size > TSDB_MAX_LAST_FILE_SIZE*/) {
// TODO: make it not to write the last file every time // TODO: make it not to write the last file every time
tsdbCreateFile(dataDir, fid, ".l", pCfg->maxTables, &lFile, 0, 0); tsdbCreateFile(dataDir, fid, ".l", pCfg->maxTables, &lFile, 0, 0);
@ -1045,7 +1047,11 @@ _table_over:
// Write the SCompBlock part // Write the SCompBlock part
pIdx->offset = lseek(hFile.fd, 0, SEEK_END); pIdx->offset = lseek(hFile.fd, 0, SEEK_END);
if (pIdx->len > 0) { if (pIdx->len > 0) {
sendfile(pGroup->files[TSDB_FILE_TYPE_HEAD].fd, hFile.fd, NULL, pIdx->len); int bytes = tsendfile(hFile.fd, pGroup->files[TSDB_FILE_TYPE_HEAD].fd, NULL, pIdx->len);
if (bytes < pIdx->len) {
printf("Failed to send file, reason: %s\n", strerror(errno));
int d = 1;
}
if (nNewBlocks > 0) { if (nNewBlocks > 0) {
write(hFile.fd, (void *)(pCompInfo->blocks), sizeof(SCompBlock) * nNewBlocks); write(hFile.fd, (void *)(pCompInfo->blocks), sizeof(SCompBlock) * nNewBlocks);
pIdx->len += (sizeof(SCompBlock) * nNewBlocks); pIdx->len += (sizeof(SCompBlock) * nNewBlocks);