update index cache
This commit is contained in:
parent
10a7547b61
commit
653665641d
|
@ -9,6 +9,7 @@ target_link_libraries(
|
||||||
index
|
index
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
|
PUBLIC common
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${BUILD_WITH_LUCENE})
|
if (${BUILD_WITH_LUCENE})
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
|
#include "tskiplist.h"
|
||||||
// ----------------- row structure in skiplist ---------------------
|
// ----------------- row structure in skiplist ---------------------
|
||||||
|
|
||||||
/* A data row, the format is like below:
|
/* A data row, the format is like below:
|
||||||
|
@ -30,6 +31,7 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct IndexCache {
|
typedef struct IndexCache {
|
||||||
T_REF_DECLARE()
|
T_REF_DECLARE()
|
||||||
|
SSkipList *skiplist;
|
||||||
} IndexCache;
|
} IndexCache;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,6 @@ typedef struct StreamWithStateResult {
|
||||||
FstSlice data;
|
FstSlice data;
|
||||||
FstOutput out;
|
FstOutput out;
|
||||||
void *state;
|
void *state;
|
||||||
|
|
||||||
} StreamWithStateResult;
|
} StreamWithStateResult;
|
||||||
|
|
||||||
StreamWithStateResult *swsResultCreate(FstSlice *data, FstOutput fOut, void *state);
|
StreamWithStateResult *swsResultCreate(FstSlice *data, FstOutput fOut, void *state);
|
||||||
|
|
|
@ -14,7 +14,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "index_cache.h"
|
#include "index_cache.h"
|
||||||
|
#include "tcompare.h"
|
||||||
|
|
||||||
|
#define MAX_INDEX_KEY_LEN 128 // test only, change later
|
||||||
|
|
||||||
|
static char* getIndexKey(const void *pData) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
static int32_t compareKey(const void *l, const void *r) {
|
static int32_t compareKey(const void *l, const void *r) {
|
||||||
char *lp = (char *)l;
|
char *lp = (char *)l;
|
||||||
char *rp = (char *)r;
|
char *rp = (char *)r;
|
||||||
|
@ -85,10 +91,14 @@ static int32_t compareKey(const void *l, const void *r) {
|
||||||
}
|
}
|
||||||
IndexCache *indexCacheCreate() {
|
IndexCache *indexCacheCreate() {
|
||||||
IndexCache *cache = calloc(1, sizeof(IndexCache));
|
IndexCache *cache = calloc(1, sizeof(IndexCache));
|
||||||
|
cache->skiplist = tSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_BINARY, MAX_INDEX_KEY_LEN, compareKey, SL_ALLOW_DUP_KEY, getIndexKey);
|
||||||
return cache;
|
return cache;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void indexCacheDestroy(IndexCache *cache) {
|
void indexCacheDestroy(IndexCache *cache) {
|
||||||
|
if (cache == NULL) { return; }
|
||||||
|
tSkipListDestroy(cache->skiplist);
|
||||||
free(cache);
|
free(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +106,7 @@ int indexCachePut(IndexCache *cache, int16_t fieldId, int16_t fieldType, const c
|
||||||
uint32_t version, uint64_t uid, int8_t operType) {
|
uint32_t version, uint64_t uid, int8_t operType) {
|
||||||
if (cache == NULL) { return -1;}
|
if (cache == NULL) { return -1;}
|
||||||
|
|
||||||
|
// encode data
|
||||||
int32_t total = sizeof(int32_t) + sizeof(fieldId) + sizeof(fieldType) + sizeof(fvLen) + fvLen + sizeof(version) + sizeof(uid) + sizeof(operType);
|
int32_t total = sizeof(int32_t) + sizeof(fieldId) + sizeof(fieldType) + sizeof(fvLen) + fvLen + sizeof(version) + sizeof(uid) + sizeof(operType);
|
||||||
|
|
||||||
char *buf = calloc(1, total);
|
char *buf = calloc(1, total);
|
||||||
|
@ -123,6 +134,10 @@ int indexCachePut(IndexCache *cache, int16_t fieldId, int16_t fieldType, const c
|
||||||
|
|
||||||
memcpy(p, &operType, sizeof(operType));
|
memcpy(p, &operType, sizeof(operType));
|
||||||
p += sizeof(operType);
|
p += sizeof(operType);
|
||||||
|
|
||||||
|
tSkipListPut(cache->skiplist, (void *)buf);
|
||||||
|
// encode end
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
int indexCacheDel(IndexCache *cache, int32_t fieldId, const char *fieldValue, int32_t fvlen, uint64_t uid, int8_t operType) {
|
int indexCacheDel(IndexCache *cache, int32_t fieldId, const char *fieldValue, int32_t fvlen, uint64_t uid, int8_t operType) {
|
||||||
|
|
Loading…
Reference in New Issue