update cache search
This commit is contained in:
parent
f074a4b3a5
commit
2375f6c944
|
@ -71,7 +71,6 @@ void indexMultiTermDestroy(SIndexMultiTerm *terms);
|
||||||
SIndexOpts *indexOptsCreate();
|
SIndexOpts *indexOptsCreate();
|
||||||
void indexOptsDestroy(SIndexOpts *opts);
|
void indexOptsDestroy(SIndexOpts *opts);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param:
|
* @param:
|
||||||
* @param:
|
* @param:
|
||||||
|
|
|
@ -48,9 +48,13 @@ struct SIndex {
|
||||||
struct SIndexOpts {
|
struct SIndexOpts {
|
||||||
#ifdef USE_LUCENE
|
#ifdef USE_LUCENE
|
||||||
void *opts;
|
void *opts;
|
||||||
#endif
|
#endif
|
||||||
int32_t numOfItermLimit;
|
|
||||||
int8_t mergeInterval;
|
#ifdef USE_INVERTED_INDEX
|
||||||
|
int32_t cacheSize; // MB
|
||||||
|
// add cache module later
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SIndexMultiTermQuery {
|
struct SIndexMultiTermQuery {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_cache.h"
|
#include "index_cache.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
|
||||||
#ifdef USE_LUCENE
|
#ifdef USE_LUCENE
|
||||||
#include "lucene++/Lucene_c.h"
|
#include "lucene++/Lucene_c.h"
|
||||||
|
@ -30,13 +31,13 @@ typedef struct SIdxColInfo {
|
||||||
static pthread_once_t isInit = PTHREAD_ONCE_INIT;
|
static pthread_once_t isInit = PTHREAD_ONCE_INIT;
|
||||||
static void indexInit();
|
static void indexInit();
|
||||||
|
|
||||||
static int indexMergeCacheIntoTindex(struct SIndex *sIdx) {
|
|
||||||
if (sIdx == NULL) {
|
static int indexTermSearch(SIndex *sIdx, SIndexTermQuery *term, SArray **result);
|
||||||
return -1;
|
static int indexMergeCacheIntoTindex(SIndex *sIdx);
|
||||||
}
|
|
||||||
indexWarn("suid %" PRIu64 " merge cache into tindex", sIdx->suid);
|
static void indexInterResultsDestroy(SArray *results);
|
||||||
return 0;
|
static int indexMergeFinalResults(SArray *interResults, EIndexOperatorType oType, SArray *finalResult);
|
||||||
}
|
|
||||||
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));
|
||||||
|
@ -49,8 +50,8 @@ int indexOpen(SIndexOpts *opts, const char *path, SIndex **index) {
|
||||||
|
|
||||||
sIdx->cache = (void*)indexCacheCreate();
|
sIdx->cache = (void*)indexCacheCreate();
|
||||||
sIdx->tindex = NULL;
|
sIdx->tindex = NULL;
|
||||||
sIdx->colObj = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
sIdx->colObj = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||||
sIdx->colId = 1;
|
sIdx->colId = 1;
|
||||||
sIdx->cVersion = 1;
|
sIdx->cVersion = 1;
|
||||||
pthread_mutex_init(&sIdx->mtx, NULL);
|
pthread_mutex_init(&sIdx->mtx, NULL);
|
||||||
|
|
||||||
|
@ -162,12 +163,25 @@ int indexSearch(SIndex *index, SIndexMultiTermQuery *multiQuerys, SArray *result
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_INVERTED_INDEX
|
#ifdef USE_INVERTED_INDEX
|
||||||
|
EIndexOperatorType opera = multiQuerys->opera; // relation of querys
|
||||||
|
|
||||||
|
SArray *interResults = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
int nQuery = taosArrayGetSize(multiQuerys->query);
|
||||||
|
for (size_t i = 0; i < nQuery; i++) {
|
||||||
|
SIndexTermQuery *qTerm = taosArrayGet(multiQuerys->query, i);
|
||||||
|
SArray *tResult = NULL;
|
||||||
|
indexTermSearch(index, qTerm, &tResult);
|
||||||
|
taosArrayPush(interResults, (void *)&tResult);
|
||||||
|
}
|
||||||
|
indexMergeFinalResults(interResults, opera, result);
|
||||||
|
indexInterResultsDestroy(interResults);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int indexDelete(SIndex *index, SIndexMultiTermQuery *query) {
|
int indexDelete(SIndex *index, SIndexMultiTermQuery *query) {
|
||||||
#ifdef USE_INVERTED_INDEX
|
#ifdef USE_INVERTED_INDEX
|
||||||
#endif
|
#endif
|
||||||
|
@ -259,3 +273,35 @@ void indexMultiTermDestroy(SIndexMultiTerm *terms) {
|
||||||
void indexInit() {
|
void indexInit() {
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
static int indexTermSearch(SIndex *sIdx, SIndexTermQuery *term, SArray **result) {
|
||||||
|
|
||||||
|
}
|
||||||
|
static void indexInterResultsDestroy(SArray *results) {
|
||||||
|
if (results == NULL) { return; }
|
||||||
|
|
||||||
|
size_t sz = taosArrayGetSize(results);
|
||||||
|
for (size_t i = 0; i < sz; i++) {
|
||||||
|
SArray *p = taosArrayGetP(results, i);
|
||||||
|
taosArrayDestroy(p);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(results);
|
||||||
|
|
||||||
|
}
|
||||||
|
static int indexMergeFinalResults(SArray *interResults, EIndexOperatorType oType, SArray *fResults) {
|
||||||
|
if (oType == MUST) {
|
||||||
|
|
||||||
|
// tag1 condition && tag2 condition
|
||||||
|
} else if (oType == SHOULD) {
|
||||||
|
// tag1 condistion || tag2 condition
|
||||||
|
} else if (oType == NOT) {
|
||||||
|
// not use currently
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int indexMergeCacheIntoTindex(SIndex *sIdx) {
|
||||||
|
if (sIdx == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
indexWarn("suid %" PRIu64 " merge cache into tindex", sIdx->suid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue