update index cache search
This commit is contained in:
parent
d43ad3bed8
commit
9140eb597c
|
@ -31,6 +31,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SIndexStat {
|
||||
int32_t totalAdded; //
|
||||
int32_t totalDeled; //
|
||||
int32_t totalUpdated; //
|
||||
int32_t totalTerms //
|
||||
int32_t distCol; // distinct column
|
||||
} SIndexStat;
|
||||
|
||||
struct SIndex {
|
||||
#ifdef USE_LUCENE
|
||||
index_t *index;
|
||||
|
@ -42,6 +50,8 @@ struct SIndex {
|
|||
int64_t suid; // current super table id, -1 is normal table
|
||||
int colId; // field id allocated to cache
|
||||
int32_t cVersion; // current version allocated to cache
|
||||
|
||||
SIndexStat stat;
|
||||
pthread_mutex_t mtx;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "indexInt.h"
|
||||
#include "tlockfree.h"
|
||||
#include "tskiplist.h"
|
||||
// ----------------- row structure in skiplist ---------------------
|
||||
// ----------------- key structure in skiplist ---------------------
|
||||
|
||||
/* A data row, the format is like below:
|
||||
* content: |<--totalLen-->|<-- fieldid-->|<--field type -->|<-- value len--->|<-- value -->|<-- uid -->|<--version--->|<-- itermType -->|
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
#define MAX_INDEX_KEY_LEN 256// test only, change later
|
||||
|
||||
// ref index_cache.h:22
|
||||
#define CACHE_KEY_LEN(p) (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) + sizeof(p->operType))
|
||||
|
||||
static char* getIndexKey(const void *pData) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -109,7 +112,7 @@ int indexCachePut(void *cache, SIndexTerm *term, int16_t colId, int32_t version,
|
|||
IndexCache *pCache = cache;
|
||||
|
||||
// encode data
|
||||
int32_t total = sizeof(int32_t) + sizeof(colId) + sizeof(term->colType) + sizeof(term->nColVal) + term->nColVal + sizeof(version) + sizeof(uid) + sizeof(term->operType);
|
||||
int32_t total = CACHE_KEY_LEN(term);
|
||||
|
||||
char *buf = calloc(1, total);
|
||||
char *p = buf;
|
||||
|
@ -138,6 +141,7 @@ int indexCachePut(void *cache, SIndexTerm *term, int16_t colId, int32_t version,
|
|||
p += sizeof(term->operType);
|
||||
|
||||
tSkipListPut(pCache->skiplist, (void *)buf);
|
||||
return 0;
|
||||
// encode end
|
||||
|
||||
}
|
||||
|
@ -146,6 +150,24 @@ int indexCacheDel(void *cache, int32_t fieldId, const char *fieldValue, int32_t
|
|||
return 0;
|
||||
}
|
||||
int indexCacheSearch(void *cache, SIndexTermQuery *query, int16_t colId, int32_t version, SArray *result) {
|
||||
if (cache == NULL) { return -1; }
|
||||
IndexCache *pCache = cache;
|
||||
SIndexTerm *term = query->term;
|
||||
EIndexQueryType qtype = query->qType;
|
||||
|
||||
int32_t keyLen = CACHE_KEY_LEN(term);
|
||||
|
||||
char *buf = calloc(1, keyLen);
|
||||
if (qtype == QUERY_TERM) {
|
||||
|
||||
} else if (qtype == QUERY_PREFIX) {
|
||||
|
||||
} else if (qtype == QUERY_SUFFIX) {
|
||||
|
||||
} else if (qtype == QUERY_REGEX) {
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue