Merge pull request #11156 from taosdata/feature/fst_update_query
Feature/fst update query
This commit is contained in:
commit
5b67534460
|
@ -63,9 +63,10 @@ typedef struct {
|
|||
|
||||
FstRegex *regexCreate(const char *str);
|
||||
|
||||
void regexSetup(FstRegex *regex, uint32_t size, const char *str);
|
||||
|
||||
// uint32_t regexStart()
|
||||
uint32_t regexAutomStart(FstRegex *regex);
|
||||
bool regexAutomIsMatch(FstRegex *regex, uint32_t state);
|
||||
bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null);
|
||||
bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct FstSparseSet {
|
||||
SArray *dense;
|
||||
SArray *sparse;
|
||||
int32_t size;
|
||||
uint32_t *dense;
|
||||
uint32_t *sparse;
|
||||
int32_t size;
|
||||
} FstSparseSet;
|
||||
|
||||
FstSparseSet *sparSetCreate(int32_t sz);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#endif
|
||||
|
||||
#define INDEX_NUM_OF_THREADS 4
|
||||
#define INDEX_QUEUE_SIZE 200
|
||||
#define INDEX_QUEUE_SIZE 200
|
||||
|
||||
void* indexQhandle = NULL;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#define MAX_INDEX_KEY_LEN 256 // test only, change later
|
||||
|
||||
#define MEM_TERM_LIMIT 10 * 10000
|
||||
#define MEM_THRESHOLD 1024 * 1024
|
||||
#define MEM_TERM_LIMIT 10 * 10000
|
||||
#define MEM_THRESHOLD 1024 * 1024
|
||||
#define MEM_ESTIMATE_RADIO 1.5
|
||||
|
||||
static void indexMemRef(MemTable* tbl);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
YAML:9:25: error: unknown key 'AlignConsecutiveMacros' * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "indexFstRegex.h"
|
||||
#include "indexFstDfa.h"
|
||||
#include "indexFstSparse.h"
|
||||
|
||||
FstRegex *regexCreate(const char *str) {
|
||||
|
@ -26,9 +27,35 @@ FstRegex *regexCreate(const char *str) {
|
|||
memcpy(orig, str, sz);
|
||||
|
||||
regex->orig = orig;
|
||||
|
||||
// construct insts based on str
|
||||
SArray *insts = NULL;
|
||||
|
||||
FstDfaBuilder *builder = dfaBuilderCreate(insts);
|
||||
regex->dfa = dfaBuilderBuild(builder);
|
||||
return regex;
|
||||
}
|
||||
|
||||
void regexSetup(FstRegex *regex, uint32_t size, const char *str) {
|
||||
// return
|
||||
// return;
|
||||
uint32_t regexAutomStart(FstRegex *regex) {
|
||||
///// no nothing
|
||||
return 0;
|
||||
}
|
||||
bool regexAutomIsMatch(FstRegex *regex, uint32_t state) {
|
||||
if (regex->dfa != NULL && dfaIsMatch(regex->dfa, state)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null) {
|
||||
// make frame happy
|
||||
return null;
|
||||
}
|
||||
|
||||
bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result) {
|
||||
if (regex->dfa == NULL) {
|
||||
return false;
|
||||
}
|
||||
return dfaAccept(regex->dfa, state, byte, result);
|
||||
}
|
||||
|
|
|
@ -21,47 +21,44 @@ FstSparseSet *sparSetCreate(int32_t sz) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ss->dense = taosArrayInit(sz, sizeof(uint32_t));
|
||||
ss->sparse = taosArrayInit(sz, sizeof(uint32_t));
|
||||
ss->size = sz;
|
||||
ss->dense = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t));
|
||||
ss->sparse = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t));
|
||||
ss->size = 0;
|
||||
return ss;
|
||||
}
|
||||
void sparSetDestroy(FstSparseSet *ss) {
|
||||
if (ss == NULL) {
|
||||
return;
|
||||
}
|
||||
taosArrayDestroy(ss->dense);
|
||||
taosArrayDestroy(ss->sparse);
|
||||
taosMemoryFree(ss->dense);
|
||||
taosMemoryFree(ss->sparse);
|
||||
taosMemoryFree(ss);
|
||||
}
|
||||
uint32_t sparSetLen(FstSparseSet *ss) { return ss == NULL ? 0 : ss->size; }
|
||||
uint32_t sparSetLen(FstSparseSet *ss) {
|
||||
// Get occupied size
|
||||
return ss == NULL ? 0 : ss->size;
|
||||
}
|
||||
uint32_t sparSetAdd(FstSparseSet *ss, uint32_t ip) {
|
||||
if (ss == NULL) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t i = ss->size;
|
||||
taosArraySet(ss->dense, i, &ip);
|
||||
taosArraySet(ss->sparse, ip, &i);
|
||||
ss->dense[i] = ip;
|
||||
ss->sparse[ip] = i;
|
||||
ss->size += 1;
|
||||
return i;
|
||||
}
|
||||
uint32_t sparSetGet(FstSparseSet *ss, uint32_t i) {
|
||||
if (i >= taosArrayGetSize(ss->dense)) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t *v = taosArrayGet(ss->dense, i);
|
||||
return *v;
|
||||
// check later
|
||||
return ss->dense[i];
|
||||
}
|
||||
bool sparSetContains(FstSparseSet *ss, uint32_t ip) {
|
||||
if (ip >= taosArrayGetSize(ss->sparse)) {
|
||||
uint32_t i = ss->sparse[ip];
|
||||
if (i < ss->size && ss->dense[i] == ip) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
uint32_t i = *(uint32_t *)taosArrayGet(ss->sparse, ip);
|
||||
if (i >= taosArrayGetSize(ss->dense)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t v = *(uint32_t *)taosArrayGet(ss->dense, i);
|
||||
return v == ip;
|
||||
}
|
||||
void sparSetClear(FstSparseSet *ss) {
|
||||
if (ss == NULL) {
|
Loading…
Reference in New Issue