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);
|
FstRegex *regexCreate(const char *str);
|
||||||
|
|
||||||
void regexSetup(FstRegex *regex, uint32_t size, const char *str);
|
uint32_t regexAutomStart(FstRegex *regex);
|
||||||
|
bool regexAutomIsMatch(FstRegex *regex, uint32_t state);
|
||||||
// uint32_t regexStart()
|
bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null);
|
||||||
|
bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct FstSparseSet {
|
typedef struct FstSparseSet {
|
||||||
SArray *dense;
|
uint32_t *dense;
|
||||||
SArray *sparse;
|
uint32_t *sparse;
|
||||||
int32_t size;
|
int32_t size;
|
||||||
} FstSparseSet;
|
} FstSparseSet;
|
||||||
|
|
||||||
FstSparseSet *sparSetCreate(int32_t sz);
|
FstSparseSet *sparSetCreate(int32_t sz);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INDEX_NUM_OF_THREADS 4
|
#define INDEX_NUM_OF_THREADS 4
|
||||||
#define INDEX_QUEUE_SIZE 200
|
#define INDEX_QUEUE_SIZE 200
|
||||||
|
|
||||||
void* indexQhandle = NULL;
|
void* indexQhandle = NULL;
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
#define MAX_INDEX_KEY_LEN 256 // test only, change later
|
#define MAX_INDEX_KEY_LEN 256 // test only, change later
|
||||||
|
|
||||||
#define MEM_TERM_LIMIT 10 * 10000
|
#define MEM_TERM_LIMIT 10 * 10000
|
||||||
#define MEM_THRESHOLD 1024 * 1024
|
#define MEM_THRESHOLD 1024 * 1024
|
||||||
#define MEM_ESTIMATE_RADIO 1.5
|
#define MEM_ESTIMATE_RADIO 1.5
|
||||||
|
|
||||||
static void indexMemRef(MemTable* tbl);
|
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
|
* 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
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "indexFstRegex.h"
|
#include "indexFstRegex.h"
|
||||||
|
#include "indexFstDfa.h"
|
||||||
#include "indexFstSparse.h"
|
#include "indexFstSparse.h"
|
||||||
|
|
||||||
FstRegex *regexCreate(const char *str) {
|
FstRegex *regexCreate(const char *str) {
|
||||||
|
@ -26,9 +27,35 @@ FstRegex *regexCreate(const char *str) {
|
||||||
memcpy(orig, str, sz);
|
memcpy(orig, str, sz);
|
||||||
|
|
||||||
regex->orig = orig;
|
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) {
|
uint32_t regexAutomStart(FstRegex *regex) {
|
||||||
// return
|
///// no nothing
|
||||||
// return;
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ss->dense = taosArrayInit(sz, sizeof(uint32_t));
|
ss->dense = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t));
|
||||||
ss->sparse = taosArrayInit(sz, sizeof(uint32_t));
|
ss->sparse = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t));
|
||||||
ss->size = sz;
|
ss->size = 0;
|
||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
void sparSetDestroy(FstSparseSet *ss) {
|
void sparSetDestroy(FstSparseSet *ss) {
|
||||||
if (ss == NULL) {
|
if (ss == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
taosArrayDestroy(ss->dense);
|
taosMemoryFree(ss->dense);
|
||||||
taosArrayDestroy(ss->sparse);
|
taosMemoryFree(ss->sparse);
|
||||||
taosMemoryFree(ss);
|
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) {
|
uint32_t sparSetAdd(FstSparseSet *ss, uint32_t ip) {
|
||||||
if (ss == NULL) {
|
if (ss == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint32_t i = ss->size;
|
uint32_t i = ss->size;
|
||||||
taosArraySet(ss->dense, i, &ip);
|
ss->dense[i] = ip;
|
||||||
taosArraySet(ss->sparse, ip, &i);
|
ss->sparse[ip] = i;
|
||||||
ss->size += 1;
|
ss->size += 1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
uint32_t sparSetGet(FstSparseSet *ss, uint32_t i) {
|
uint32_t sparSetGet(FstSparseSet *ss, uint32_t i) {
|
||||||
if (i >= taosArrayGetSize(ss->dense)) {
|
// check later
|
||||||
return 0;
|
return ss->dense[i];
|
||||||
}
|
|
||||||
uint32_t *v = taosArrayGet(ss->dense, i);
|
|
||||||
return *v;
|
|
||||||
}
|
}
|
||||||
bool sparSetContains(FstSparseSet *ss, uint32_t ip) {
|
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;
|
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) {
|
void sparSetClear(FstSparseSet *ss) {
|
||||||
if (ss == NULL) {
|
if (ss == NULL) {
|
Loading…
Reference in New Issue