未验证 提交 f7a446f2 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #9681 from taosdata/feature/index_complete

index integrated into vnode meta
...@@ -76,25 +76,20 @@ void indexOptsDestroy(SIndexOpts* opts); ...@@ -76,25 +76,20 @@ void indexOptsDestroy(SIndexOpts* opts);
* @param: * @param:
*/ */
SIndexTerm* indexTermCreate(int64_t suid, SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn operType, uint8_t colType, const char* colName,
SIndexOperOnColumn operType, int32_t nColName, const char* colVal, int32_t nColVal);
uint8_t colType,
const char* colName,
int32_t nColName,
const char* colVal,
int32_t nColVal);
void indexTermDestroy(SIndexTerm* p); void indexTermDestroy(SIndexTerm* p);
/* /*
* init index * init index env
* *
*/ */
int32_t indexInit(); void indexInit();
/* /*
* destory index * destory index env
* *
*/ */
void indexCleanUp(); void indexCleanUp();
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -19,11 +19,13 @@ add_library(meta STATIC ${META_SRC}) ...@@ -19,11 +19,13 @@ add_library(meta STATIC ${META_SRC})
target_include_directories( target_include_directories(
meta meta
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/vnode/meta" PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/vnode/meta"
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/index"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
) )
target_link_libraries( target_link_libraries(
meta meta
PUBLIC common PUBLIC common
PUBLIC index
) )
if(${META_DB_IMPL} STREQUAL "BDB") if(${META_DB_IMPL} STREQUAL "BDB")
......
...@@ -13,9 +13,13 @@ ...@@ -13,9 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "index.h"
#include "metaDef.h" #include "metaDef.h"
struct SMetaIdx { struct SMetaIdx {
#ifdef USE_INVERTED_INDEX
SIndex *pIdx;
#endif
/* data */ /* data */
}; };
...@@ -43,6 +47,13 @@ int metaOpenIdx(SMeta *pMeta) { ...@@ -43,6 +47,13 @@ int metaOpenIdx(SMeta *pMeta) {
rocksdb_options_destroy(options); rocksdb_options_destroy(options);
#endif #endif
#ifdef USE_INVERTED_INDEX
SIndexOpts opts;
if (indexOpen(&opts, pMeta->path, &pMeta->pIdx->pIdx) != 0) {
return -1;
}
#endif
return 0; return 0;
} }
...@@ -53,14 +64,47 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */ ...@@ -53,14 +64,47 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
pMeta->pIdx = NULL; pMeta->pIdx = NULL;
} }
#endif #endif
#ifdef USE_INVERTED_INDEX
SIndexOpts opts;
if (indexClose(pMeta->pIdx->pIdx) != 0) {
return -1;
}
#endif
} }
int metaSaveTableToIdx(SMeta *pMeta, const STbCfg *pTbOptions) { int metaSaveTableToIdx(SMeta *pMeta, const STbCfg *pTbCfg) {
#ifdef USE_INVERTED_INDEX
if (pTbCfgs - type == META_CHILD_TABLE) {
char buf[8] = {0};
int16_t colId = (kvRowColIdx(pTbCfg->ctbCfg.pTag))[0].colId;
sprintf(buf, "%d", colId); // colname
char *pTagVal = (char *)tdGetKVRowValOfCol(pTbCfg->ctbCfg.pTag, (kvRowColIdx(pTbCfg->ctbCfg.pTag))[0].colId);
tb_uid_t suid = pTbCfg->ctbCfg.suid; // super id
tb_uid_t tuid = 0; // child table uid
SIndexMultiTerm *terms = indexMultiTermCreate();
SIndexTerm * term =
indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_BINARY, buf, strlen(buf), pTagVal, strlen(pTagVal), tuid);
indexMultiTermAdd(terms, term);
int ret = indexPut(pMeta->pIdx->pIdx, terms);
indexMultiTermDestroy(terms);
return ret;
} else {
return DB_DONOTINDEX;
}
#endif
// TODO // TODO
return 0; return 0;
} }
int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid) { int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid) {
#ifdef USE_INVERTED_INDEX
#endif
// TODO // TODO
return 0; return 0;
} }
\ No newline at end of file
...@@ -22,9 +22,10 @@ int metaOpenUidGnrt(SMeta *pMeta) { ...@@ -22,9 +22,10 @@ int metaOpenUidGnrt(SMeta *pMeta) {
return 0; return 0;
} }
void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */ } void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */
}
tb_uid_t metaGenerateUid(SMeta *pMeta) { tb_uid_t metaGenerateUid(SMeta *pMeta) {
// Generate a new table UID // Generate a new table UID
return ++(pMeta->uidGnrt.nextUid); return ++(pMeta->uidGnrt.nextUid);
} }
\ No newline at end of file
...@@ -30,21 +30,17 @@ ...@@ -30,21 +30,17 @@
void* indexQhandle = NULL; void* indexQhandle = NULL;
int32_t indexInit() { void indexInit() {
// refactor later
indexQhandle = taosInitScheduler(INDEX_QUEUE_SIZE, INDEX_NUM_OF_THREADS, "index"); indexQhandle = taosInitScheduler(INDEX_QUEUE_SIZE, INDEX_NUM_OF_THREADS, "index");
return indexQhandle == NULL ? -1 : 0;
// do nothing
} }
void indexCleanUp() { taosCleanUpScheduler(indexQhandle); } void indexCleanUp() { taosCleanUpScheduler(indexQhandle); }
static int uidCompare(const void* a, const void* b) { static int uidCompare(const void* a, const void* b) {
// add more version compare
uint64_t u1 = *(uint64_t*)a; uint64_t u1 = *(uint64_t*)a;
uint64_t u2 = *(uint64_t*)b; uint64_t u2 = *(uint64_t*)b;
if (u1 == u2) { return u1 - u2;
return 0;
} else {
return u1 < u2 ? -1 : 1;
}
} }
typedef struct SIdxColInfo { typedef struct SIdxColInfo {
int colId; // generated by index internal int colId; // generated by index internal
...@@ -61,7 +57,7 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp ...@@ -61,7 +57,7 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp
static int indexGenTFile(SIndex* index, IndexCache* cache, SArray* batch); static int indexGenTFile(SIndex* index, IndexCache* cache, SArray* batch);
int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
// pthread_once(&isInit, indexInit); pthread_once(&isInit, indexInit);
SIndex* sIdx = calloc(1, sizeof(SIndex)); SIndex* sIdx = calloc(1, sizeof(SIndex));
if (sIdx == NULL) { return -1; } if (sIdx == NULL) { return -1; }
......
...@@ -71,7 +71,10 @@ TFileCache* tfileCacheCreate(const char* path) { ...@@ -71,7 +71,10 @@ TFileCache* tfileCacheCreate(const char* path) {
} }
TFileReader* reader = tfileReaderCreate(wc); TFileReader* reader = tfileReaderCreate(wc);
if (reader == NULL) { goto End; } if (reader == NULL) {
indexInfo("skip invalid file: %s", file);
continue;
}
TFileHeader* header = &reader->header; TFileHeader* header = &reader->header;
ICacheKey key = {.suid = header->suid, .colName = header->colName, .nColName = strlen(header->colName)}; ICacheKey key = {.suid = header->suid, .colName = header->colName, .nColName = strlen(header->colName)};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册