提交 9140eb59 编写于 作者: dengyihao's avatar dengyihao

update index cache search

上级 d43ad3be
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
extern "C" { extern "C" {
#endif #endif
typedef struct SIndexStat {
int32_t totalAdded; //
int32_t totalDeled; //
int32_t totalUpdated; //
int32_t totalTerms //
int32_t distCol; // distinct column
} SIndexStat;
struct SIndex { struct SIndex {
#ifdef USE_LUCENE #ifdef USE_LUCENE
index_t *index; index_t *index;
...@@ -42,6 +50,8 @@ struct SIndex { ...@@ -42,6 +50,8 @@ struct SIndex {
int64_t suid; // current super table id, -1 is normal table int64_t suid; // current super table id, -1 is normal table
int colId; // field id allocated to cache int colId; // field id allocated to cache
int32_t cVersion; // current version allocated to cache int32_t cVersion; // current version allocated to cache
SIndexStat stat;
pthread_mutex_t mtx; pthread_mutex_t mtx;
}; };
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "indexInt.h" #include "indexInt.h"
#include "tlockfree.h" #include "tlockfree.h"
#include "tskiplist.h" #include "tskiplist.h"
// ----------------- row structure in skiplist --------------------- // ----------------- key structure in skiplist ---------------------
/* A data row, the format is like below: /* A data row, the format is like below:
* content: |<--totalLen-->|<-- fieldid-->|<--field type -->|<-- value len--->|<-- value -->|<-- uid -->|<--version--->|<-- itermType -->| * content: |<--totalLen-->|<-- fieldid-->|<--field type -->|<-- value len--->|<-- value -->|<-- uid -->|<--version--->|<-- itermType -->|
......
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
#define MAX_INDEX_KEY_LEN 256// test only, change later #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) { static char* getIndexKey(const void *pData) {
return NULL; return NULL;
} }
...@@ -109,7 +112,7 @@ int indexCachePut(void *cache, SIndexTerm *term, int16_t colId, int32_t version, ...@@ -109,7 +112,7 @@ int indexCachePut(void *cache, SIndexTerm *term, int16_t colId, int32_t version,
IndexCache *pCache = cache; IndexCache *pCache = cache;
// encode data // 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 *buf = calloc(1, total);
char *p = buf; char *p = buf;
...@@ -138,6 +141,7 @@ int indexCachePut(void *cache, SIndexTerm *term, int16_t colId, int32_t version, ...@@ -138,6 +141,7 @@ int indexCachePut(void *cache, SIndexTerm *term, int16_t colId, int32_t version,
p += sizeof(term->operType); p += sizeof(term->operType);
tSkipListPut(pCache->skiplist, (void *)buf); tSkipListPut(pCache->skiplist, (void *)buf);
return 0;
// encode end // encode end
} }
...@@ -146,6 +150,24 @@ int indexCacheDel(void *cache, int32_t fieldId, const char *fieldValue, int32_t ...@@ -146,6 +150,24 @@ int indexCacheDel(void *cache, int32_t fieldId, const char *fieldValue, int32_t
return 0; return 0;
} }
int indexCacheSearch(void *cache, SIndexTermQuery *query, int16_t colId, int32_t version, SArray *result) { 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; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册