Merge pull request #9642 from taosdata/feature/index_complete
refactor code
This commit is contained in:
commit
77088a5ee7
|
@ -115,7 +115,7 @@ typedef struct TFileCacheKey {
|
|||
int32_t nColName;
|
||||
} ICacheKey;
|
||||
|
||||
int indexFlushCacheTFile(SIndex* sIdx, void*);
|
||||
int indexFlushCacheToTFile(SIndex* sIdx, void*);
|
||||
|
||||
int32_t indexSerialCacheKey(ICacheKey* key, char* buf);
|
||||
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
#include "tskiplist.h"
|
||||
// ----------------- key structure in skiplist ---------------------
|
||||
|
||||
/* A data row, the format is like below:
|
||||
* content: |<--totalLen-->|<-- value len--->|<-- value -->|<--uid -->|<--version--->|<-- itermType -->|
|
||||
* len : |<--int32_t -->|<--- int32_t --->|<--valuelen->|<--uint64_t->|<-- int32_t-->|<-- int8_t --->|
|
||||
/* A data row, the format is like below
|
||||
* content: |<---colVal---->|<-- version--->|<-- uid--->|<-- colType --->|<--operaType--->|
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -384,7 +384,6 @@ static void indexMergeSameKey(SArray* result, TFileValue* tv) {
|
|||
}
|
||||
} else {
|
||||
taosArrayPush(result, &tv);
|
||||
// indexError("merge colVal: %s", tv->colVal);
|
||||
}
|
||||
}
|
||||
static void indexDestroyTempResult(SArray* result) {
|
||||
|
@ -395,7 +394,7 @@ static void indexDestroyTempResult(SArray* result) {
|
|||
}
|
||||
taosArrayDestroy(result);
|
||||
}
|
||||
int indexFlushCacheTFile(SIndex* sIdx, void* cache) {
|
||||
int indexFlushCacheToTFile(SIndex* sIdx, void* cache) {
|
||||
if (sIdx == NULL) { return -1; }
|
||||
indexInfo("suid %" PRIu64 " merge cache into tindex", sIdx->suid);
|
||||
|
||||
|
|
|
@ -45,9 +45,7 @@ IndexCache* indexCacheCreate(SIndex* idx, uint64_t suid, const char* colName, in
|
|||
return NULL;
|
||||
};
|
||||
cache->mem = indexInternalCacheCreate(type);
|
||||
|
||||
cache->colName = calloc(1, strlen(colName) + 1);
|
||||
memcpy(cache->colName, colName, strlen(colName));
|
||||
cache->colName = tstrdup(colName);
|
||||
cache->type = type;
|
||||
cache->index = idx;
|
||||
cache->version = 0;
|
||||
|
@ -187,8 +185,8 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) {
|
|||
break;
|
||||
} else if (cache->imm != NULL) {
|
||||
// TODO: wake up by condition variable
|
||||
// pthread_mutex_unlock(&cache->mtx);
|
||||
pthread_cond_wait(&cache->finished, &cache->mtx);
|
||||
// pthread_mutex_unlock(&cache->mtx);
|
||||
// taosMsleep(50);
|
||||
// pthread_mutex_lock(&cache->mtx);
|
||||
} else {
|
||||
|
@ -353,7 +351,7 @@ static MemTable* indexInternalCacheCreate(int8_t type) {
|
|||
static void doMergeWork(SSchedMsg* msg) {
|
||||
IndexCache* pCache = msg->ahandle;
|
||||
SIndex* sidx = (SIndex*)pCache->index;
|
||||
indexFlushCacheTFile(sidx, pCache);
|
||||
indexFlushCacheToTFile(sidx, pCache);
|
||||
}
|
||||
static bool indexCacheIteratorNext(Iterate* itera) {
|
||||
SSkipListIterator* iter = itera->iter;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "tutil.h"
|
||||
|
||||
static int writeCtxDoWrite(WriterCtx* ctx, uint8_t* buf, int len) {
|
||||
// if (ctx->offset + len > ctx->limit) { return -1; }
|
||||
|
||||
if (ctx->type == TFile) {
|
||||
assert(len == tfWrite(ctx->file.fd, buf, len));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue