Merge pull request #11109 from taosdata/feature/fst_update_query
update code style
This commit is contained in:
commit
869ce1e060
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
* 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
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
@ -16,7 +15,7 @@
|
||||||
#define __INDEX_CACHE_H__
|
#define __INDEX_CACHE_H__
|
||||||
|
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_util.h"
|
#include "indexUtil.h"
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
|
|
||||||
// ----------------- key structure in skiplist ---------------------
|
// ----------------- key structure in skiplist ---------------------
|
|
@ -20,12 +20,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "indexFstAutomation.h"
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
|
#include "indexFstNode.h"
|
||||||
|
#include "indexFstRegistry.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst_automation.h"
|
|
||||||
#include "index_fst_counting_writer.h"
|
|
||||||
#include "index_fst_node.h"
|
|
||||||
#include "index_fst_registry.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
|
|
||||||
#define OUTPUT_PREFIX(a, b) ((a) > (b) ? (b) : (a)
|
#define OUTPUT_PREFIX(a, b) ((a) > (b) ? (b) : (a)
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst_util.h"
|
|
||||||
|
|
||||||
typedef struct AutomationCtx AutomationCtx;
|
typedef struct AutomationCtx AutomationCtx;
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst_counting_writer.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
|
|
||||||
#define FST_BUILDER_NODE_IS_FINAL(bn) (bn->isFinal)
|
#define FST_BUILDER_NODE_IS_FINAL(bn) (bn->isFinal)
|
||||||
#define FST_BUILDER_NODE_TRANS_ISEMPTY(bn) (taosArrayGetSize(bn->trans) == 0)
|
#define FST_BUILDER_NODE_TRANS_ISEMPTY(bn) (taosArrayGetSize(bn->trans) == 0)
|
|
@ -19,9 +19,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "indexFstNode.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst_node.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
|
|
||||||
typedef struct FstRegistryCell {
|
typedef struct FstRegistryCell {
|
||||||
CompiledAddr addr;
|
CompiledAddr addr;
|
|
@ -20,8 +20,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "indexFstCommon.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst_common.h"
|
|
||||||
|
|
||||||
typedef uint64_t FstType;
|
typedef uint64_t FstType;
|
||||||
typedef uint64_t CompiledAddr;
|
typedef uint64_t CompiledAddr;
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_INDEX_SPARSE_H_
|
||||||
|
#define _TD_INDEX_SPARSE_H_
|
||||||
|
|
||||||
|
#include "tarray.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct FstSparseSet {
|
||||||
|
SArray *dense;
|
||||||
|
SArray *sparse;
|
||||||
|
int32_t size;
|
||||||
|
} FstSparseSet;
|
||||||
|
|
||||||
|
FstSparseSet *sparSetCreate(int32_t sz);
|
||||||
|
void sparSetDestroy(FstSparseSet *s);
|
||||||
|
uint32_t sparSetLen(FstSparseSet *ss);
|
||||||
|
uint32_t sparSetAdd(FstSparseSet *ss, uint32_t ip);
|
||||||
|
uint32_t sparSetGet(FstSparseSet *ss, uint32_t i);
|
||||||
|
bool sparSetContains(FstSparseSet *ss, uint32_t ip);
|
||||||
|
void sparSetClear(FstSparseSet *ss);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -15,11 +15,11 @@
|
||||||
#ifndef __INDEX_TFILE_H__
|
#ifndef __INDEX_TFILE_H__
|
||||||
#define __INDEX_TFILE_H__
|
#define __INDEX_TFILE_H__
|
||||||
|
|
||||||
|
#include "indexFst.h"
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst.h"
|
#include "indexTfile.h"
|
||||||
#include "index_fst_counting_writer.h"
|
#include "indexUtil.h"
|
||||||
#include "index_tfile.h"
|
|
||||||
#include "index_util.h"
|
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
|
@ -14,11 +14,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
#include "indexCache.h"
|
||||||
|
#include "indexComm.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_cache.h"
|
#include "indexTfile.h"
|
||||||
#include "index_comm.h"
|
#include "indexUtil.h"
|
||||||
#include "index_tfile.h"
|
|
||||||
#include "index_util.h"
|
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
#include "tsched.h"
|
#include "tsched.h"
|
||||||
|
|
||||||
|
@ -236,11 +236,11 @@ int indexDelete(SIndex* index, SIndexMultiTermQuery* query) {
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int indexRebuild(SIndex* index, SIndexOpts* opts){
|
int indexRebuild(SIndex* index, SIndexOpts* opts) {
|
||||||
#ifdef USE_INVERTED_INDEX
|
#ifdef USE_INVERTED_INDEX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIndexOpts* indexOptsCreate() {
|
SIndexOpts* indexOptsCreate() {
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "index_cache.h"
|
#include "indexCache.h"
|
||||||
#include "index_comm.h"
|
#include "indexComm.h"
|
||||||
#include "index_util.h"
|
#include "indexUtil.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
#include "tsched.h"
|
#include "tsched.h"
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "index_fst.h"
|
#include "indexFst.h"
|
||||||
|
#include "indexFstAutomation.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst_automation.h"
|
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
#include "tcoding.h"
|
#include "tcoding.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "index_fst_automation.h"
|
#include "indexFstAutomation.h"
|
||||||
|
|
||||||
StartWithStateValue* startWithStateValueCreate(StartWithStateKind kind, ValueType ty, void* val) {
|
StartWithStateValue* startWithStateValueCreate(StartWithStateKind kind, ValueType ty, void* val) {
|
||||||
StartWithStateValue* sv = taosMemoryCalloc(1, sizeof(StartWithStateValue));
|
StartWithStateValue* sv = taosMemoryCalloc(1, sizeof(StartWithStateValue));
|
|
@ -12,7 +12,7 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "index_fst_common.h"
|
#include "indexFstCommon.h"
|
||||||
|
|
||||||
const uint8_t COMMON_INPUTS[] = {
|
const uint8_t COMMON_INPUTS[] = {
|
||||||
84, // '\x00'
|
84, // '\x00'
|
||||||
|
@ -274,20 +274,23 @@ const uint8_t COMMON_INPUTS[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const char COMMON_INPUTS_INV[] = {
|
const char COMMON_INPUTS_INV[] = {
|
||||||
't', 'e', '/', 'o', 'a', 's', 'r', 'i', 'p', 'c', 'n', 'w', '.', 'h', 'l', 'm',
|
't', 'e', '/', 'o', 'a', 's', 'r', 'i', 'p', 'c', 'n', 'w', '.', 'h',
|
||||||
'-', 'd', 'u', '0', '1', '2', 'g', '=', ':', 'b', 'f', '3', 'y', '5', '&', '_',
|
'l', 'm', '-', 'd', 'u', '0', '1', '2', 'g', '=', ':', 'b', 'f', '3',
|
||||||
'4', 'v', '9', '6', '7', '8', 'k', '%', '?', 'x', 'C', 'D', 'A', 'S', 'F', 'I',
|
'y', '5', '&', '_', '4', 'v', '9', '6', '7', '8', 'k', '%', '?', 'x',
|
||||||
'B', 'E', 'j', 'P', 'T', 'z', 'R', 'N', 'M', '+', 'L', 'O', 'q', 'H', 'G', 'W',
|
'C', 'D', 'A', 'S', 'F', 'I', 'B', 'E', 'j', 'P', 'T', 'z', 'R', 'N',
|
||||||
'U', 'V', ',', 'Y', 'K', 'J', 'Z', 'X', 'Q', ';', ')', '(', '~', '[', ']', '$',
|
'M', '+', 'L', 'O', 'q', 'H', 'G', 'W', 'U', 'V', ',', 'Y', 'K', 'J',
|
||||||
'!', '\'', '*', '@', '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\t', '\n', '\x0b',
|
'Z', 'X', 'Q', ';', ')', '(', '~', '[', ']', '$', '!', '\'', '*', '@',
|
||||||
'\x0c', '\r', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b',
|
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\t', '\n', '\x0b', '\x0c', '\r',
|
||||||
'\x1c', '\x1d', '\x1e', '\x1f', ' ', '"', '#', '<', '>', '\\', '^', '`', '{', '|', '}', '\x7f',
|
'\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b',
|
||||||
'\x80', '\x81', '\x82', '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', '\x89', '\x8a', '\x8b', '\x8c', '\x8d', '\x8e', '\x8f',
|
'\x1c', '\x1d', '\x1e', '\x1f', ' ', '"', '#', '<', '>', '\\', '^', '`', '{', '|',
|
||||||
'\x90', '\x91', '\x92', '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f',
|
'}', '\x7f', '\x80', '\x81', '\x82', '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', '\x89', '\x8a', '\x8b',
|
||||||
'\xa0', '\xa1', '\xa2', '\xa3', '\xa4', '\xa5', '\xa6', '\xa7', '\xa8', '\xa9', '\xaa', '\xab', '\xac', '\xad', '\xae', '\xaf',
|
'\x8c', '\x8d', '\x8e', '\x8f', '\x90', '\x91', '\x92', '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99',
|
||||||
'\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7', '\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf',
|
'\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f', '\xa0', '\xa1', '\xa2', '\xa3', '\xa4', '\xa5', '\xa6', '\xa7',
|
||||||
'\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf',
|
'\xa8', '\xa9', '\xaa', '\xab', '\xac', '\xad', '\xae', '\xaf', '\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5',
|
||||||
'\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf',
|
'\xb6', '\xb7', '\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf', '\xc0', '\xc1', '\xc2', '\xc3',
|
||||||
'\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef',
|
'\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf', '\xd0', '\xd1',
|
||||||
'\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff',
|
'\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf',
|
||||||
|
'\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed',
|
||||||
|
'\xee', '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7', '\xf8', '\xf9', '\xfa', '\xfb',
|
||||||
|
'\xfc', '\xfd', '\xfe', '\xff',
|
||||||
};
|
};
|
|
@ -13,10 +13,10 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "os.h"
|
#include "indexFstCountingWriter.h"
|
||||||
#include "index_fst_counting_writer.h"
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_fst_util.h"
|
#include "os.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
static int writeCtxDoWrite(WriterCtx* ctx, uint8_t* buf, int len) {
|
static int writeCtxDoWrite(WriterCtx* ctx, uint8_t* buf, int len) {
|
||||||
|
@ -82,7 +82,9 @@ static int writeCtxDoFlush(WriterCtx* ctx) {
|
||||||
|
|
||||||
WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int32_t capacity) {
|
WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int32_t capacity) {
|
||||||
WriterCtx* ctx = taosMemoryCalloc(1, sizeof(WriterCtx));
|
WriterCtx* ctx = taosMemoryCalloc(1, sizeof(WriterCtx));
|
||||||
if (ctx == NULL) { return NULL; }
|
if (ctx == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->type = type;
|
ctx->type = type;
|
||||||
if (ctx->type == TFile) {
|
if (ctx->type == TFile) {
|
||||||
|
@ -126,7 +128,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
END:
|
END:
|
||||||
if (ctx->type == TMemory) { taosMemoryFree(ctx->mem.buf); }
|
if (ctx->type == TMemory) {
|
||||||
|
taosMemoryFree(ctx->mem.buf);
|
||||||
|
}
|
||||||
taosMemoryFree(ctx);
|
taosMemoryFree(ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -148,14 +152,18 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
|
||||||
// stat(ctx->file.buf, &fstat);
|
// stat(ctx->file.buf, &fstat);
|
||||||
// indexError("write file size: %d", (int)(fstat.st_size));
|
// indexError("write file size: %d", (int)(fstat.st_size));
|
||||||
}
|
}
|
||||||
if (remove) { unlink(ctx->file.buf); }
|
if (remove) {
|
||||||
|
unlink(ctx->file.buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taosMemoryFree(ctx);
|
taosMemoryFree(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
FstCountingWriter* fstCountingWriterCreate(void* wrt) {
|
FstCountingWriter* fstCountingWriterCreate(void* wrt) {
|
||||||
FstCountingWriter* cw = taosMemoryCalloc(1, sizeof(FstCountingWriter));
|
FstCountingWriter* cw = taosMemoryCalloc(1, sizeof(FstCountingWriter));
|
||||||
if (cw == NULL) { return NULL; }
|
if (cw == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
cw->wrt = wrt;
|
cw->wrt = wrt;
|
||||||
//(void *)(writerCtxCreate(TFile, readOnly));
|
//(void *)(writerCtxCreate(TFile, readOnly));
|
||||||
|
@ -169,7 +177,9 @@ void fstCountingWriterDestroy(FstCountingWriter* cw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int fstCountingWriterWrite(FstCountingWriter* write, uint8_t* buf, uint32_t len) {
|
int fstCountingWriterWrite(FstCountingWriter* write, uint8_t* buf, uint32_t len) {
|
||||||
if (write == NULL) { return 0; }
|
if (write == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// update checksum
|
// update checksum
|
||||||
// write data to file/socket or mem
|
// write data to file/socket or mem
|
||||||
WriterCtx* ctx = write->wrt;
|
WriterCtx* ctx = write->wrt;
|
||||||
|
@ -182,7 +192,9 @@ int fstCountingWriterWrite(FstCountingWriter* write, uint8_t* buf, uint32_t len)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
int fstCountingWriterRead(FstCountingWriter* write, uint8_t* buf, uint32_t len) {
|
int fstCountingWriterRead(FstCountingWriter* write, uint8_t* buf, uint32_t len) {
|
||||||
if (write == NULL) { return 0; }
|
if (write == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
WriterCtx* ctx = write->wrt;
|
WriterCtx* ctx = write->wrt;
|
||||||
int nRead = ctx->read(ctx, buf, len);
|
int nRead = ctx->read(ctx, buf, len);
|
||||||
// assert(nRead == len);
|
// assert(nRead == len);
|
|
@ -12,7 +12,7 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "index_fst_node.h"
|
#include "indexFstNode.h"
|
||||||
|
|
||||||
FstBuilderNode* fstBuilderNodeDefault() {
|
FstBuilderNode* fstBuilderNodeDefault() {
|
||||||
FstBuilderNode* bn = taosMemoryMalloc(sizeof(FstBuilderNode));
|
FstBuilderNode* bn = taosMemoryMalloc(sizeof(FstBuilderNode));
|
||||||
|
@ -22,31 +22,45 @@ FstBuilderNode* fstBuilderNodeDefault() {
|
||||||
return bn;
|
return bn;
|
||||||
}
|
}
|
||||||
void fstBuilderNodeDestroy(FstBuilderNode* node) {
|
void fstBuilderNodeDestroy(FstBuilderNode* node) {
|
||||||
if (node == NULL) { return; }
|
if (node == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
taosArrayDestroy(node->trans);
|
taosArrayDestroy(node->trans);
|
||||||
taosMemoryFree(node);
|
taosMemoryFree(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fstBuilderNodeEqual(FstBuilderNode* n1, FstBuilderNode* n2) {
|
bool fstBuilderNodeEqual(FstBuilderNode* n1, FstBuilderNode* n2) {
|
||||||
if (n1 == n2) { return true; }
|
if (n1 == n2) {
|
||||||
if (n1 == NULL || n2 == NULL) { return false; }
|
return true;
|
||||||
|
}
|
||||||
|
if (n1 == NULL || n2 == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (n1->isFinal != n2->isFinal || n1->finalOutput != n2->finalOutput) { return false; }
|
if (n1->isFinal != n2->isFinal || n1->finalOutput != n2->finalOutput) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
size_t s1 = n1->trans ? taosArrayGetSize(n1->trans) : 0;
|
size_t s1 = n1->trans ? taosArrayGetSize(n1->trans) : 0;
|
||||||
size_t s2 = n2->trans ? taosArrayGetSize(n2->trans) : 0;
|
size_t s2 = n2->trans ? taosArrayGetSize(n2->trans) : 0;
|
||||||
if (s1 != s2) { return false; }
|
if (s1 != s2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
for (size_t i = 0; i < s1; i++) {
|
for (size_t i = 0; i < s1; i++) {
|
||||||
FstTransition* t1 = taosArrayGet(n1->trans, i);
|
FstTransition* t1 = taosArrayGet(n1->trans, i);
|
||||||
FstTransition* t2 = taosArrayGet(n2->trans, i);
|
FstTransition* t2 = taosArrayGet(n2->trans, i);
|
||||||
if (t1->inp != t2->inp || t1->out != t2->out || t1->addr != t2->addr) { return false; }
|
if (t1->inp != t2->inp || t1->out != t2->out || t1->addr != t2->addr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
FstBuilderNode* fstBuilderNodeClone(FstBuilderNode* src) {
|
FstBuilderNode* fstBuilderNodeClone(FstBuilderNode* src) {
|
||||||
FstBuilderNode* node = taosMemoryMalloc(sizeof(FstBuilderNode));
|
FstBuilderNode* node = taosMemoryMalloc(sizeof(FstBuilderNode));
|
||||||
if (node == NULL) { return NULL; }
|
if (node == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
size_t sz = taosArrayGetSize(src->trans);
|
size_t sz = taosArrayGetSize(src->trans);
|
||||||
|
@ -64,7 +78,9 @@ FstBuilderNode* fstBuilderNodeClone(FstBuilderNode* src) {
|
||||||
}
|
}
|
||||||
// not destroy src, User's bussiness
|
// not destroy src, User's bussiness
|
||||||
void fstBuilderNodeCloneFrom(FstBuilderNode* dst, FstBuilderNode* src) {
|
void fstBuilderNodeCloneFrom(FstBuilderNode* dst, FstBuilderNode* src) {
|
||||||
if (dst == NULL || src == NULL) { return; }
|
if (dst == NULL || src == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dst->isFinal = src->isFinal;
|
dst->isFinal = src->isFinal;
|
||||||
dst->finalOutput = src->finalOutput;
|
dst->finalOutput = src->finalOutput;
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "indexFstRegistry.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "index_fst_registry.h"
|
|
||||||
|
|
||||||
uint64_t fstRegistryHash(FstRegistry* registry, FstBuilderNode* bNode) {
|
uint64_t fstRegistryHash(FstRegistry* registry, FstBuilderNode* bNode) {
|
||||||
// TODO(yihaoDeng): refactor later
|
// TODO(yihaoDeng): refactor later
|
||||||
|
@ -35,7 +35,9 @@ uint64_t fstRegistryHash(FstRegistry* registry, FstBuilderNode* bNode) {
|
||||||
}
|
}
|
||||||
static void fstRegistryCellSwap(SArray* arr, uint32_t a, uint32_t b) {
|
static void fstRegistryCellSwap(SArray* arr, uint32_t a, uint32_t b) {
|
||||||
size_t sz = taosArrayGetSize(arr);
|
size_t sz = taosArrayGetSize(arr);
|
||||||
if (a >= sz || b >= sz) { return; }
|
if (a >= sz || b >= sz) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FstRegistryCell* cell1 = (FstRegistryCell*)taosArrayGet(arr, a);
|
FstRegistryCell* cell1 = (FstRegistryCell*)taosArrayGet(arr, a);
|
||||||
FstRegistryCell* cell2 = (FstRegistryCell*)taosArrayGet(arr, b);
|
FstRegistryCell* cell2 = (FstRegistryCell*)taosArrayGet(arr, b);
|
||||||
|
@ -52,7 +54,9 @@ static void fstRegistryCellSwap(SArray* arr, uint32_t a, uint32_t b) {
|
||||||
|
|
||||||
static void fstRegistryCellPromote(SArray* arr, uint32_t start, uint32_t end) {
|
static void fstRegistryCellPromote(SArray* arr, uint32_t start, uint32_t end) {
|
||||||
size_t sz = taosArrayGetSize(arr);
|
size_t sz = taosArrayGetSize(arr);
|
||||||
if (start >= sz && end >= sz) { return; }
|
if (start >= sz && end >= sz) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert(start >= end);
|
assert(start >= end);
|
||||||
|
|
||||||
|
@ -66,7 +70,9 @@ static void fstRegistryCellPromote(SArray* arr, uint32_t start, uint32_t end) {
|
||||||
|
|
||||||
FstRegistry* fstRegistryCreate(uint64_t tableSize, uint64_t mruSize) {
|
FstRegistry* fstRegistryCreate(uint64_t tableSize, uint64_t mruSize) {
|
||||||
FstRegistry* registry = taosMemoryMalloc(sizeof(FstRegistry));
|
FstRegistry* registry = taosMemoryMalloc(sizeof(FstRegistry));
|
||||||
if (registry == NULL) { return NULL; }
|
if (registry == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t nCells = tableSize * mruSize;
|
uint64_t nCells = tableSize * mruSize;
|
||||||
SArray* tb = (SArray*)taosArrayInit(nCells, sizeof(FstRegistryCell));
|
SArray* tb = (SArray*)taosArrayInit(nCells, sizeof(FstRegistryCell));
|
||||||
|
@ -87,7 +93,9 @@ FstRegistry* fstRegistryCreate(uint64_t tableSize, uint64_t mruSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void fstRegistryDestroy(FstRegistry* registry) {
|
void fstRegistryDestroy(FstRegistry* registry) {
|
||||||
if (registry == NULL) { return; }
|
if (registry == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SArray* tb = registry->table;
|
SArray* tb = registry->table;
|
||||||
size_t sz = taosArrayGetSize(tb);
|
size_t sz = taosArrayGetSize(tb);
|
||||||
|
@ -100,7 +108,9 @@ void fstRegistryDestroy(FstRegistry* registry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNode) {
|
FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNode) {
|
||||||
if (taosArrayGetSize(registry->table) <= 0) { return NULL; }
|
if (taosArrayGetSize(registry->table) <= 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
uint64_t bucket = fstRegistryHash(registry, bNode);
|
uint64_t bucket = fstRegistryHash(registry, bNode);
|
||||||
uint64_t start = registry->mruSize * bucket;
|
uint64_t start = registry->mruSize * bucket;
|
||||||
uint64_t end = start + registry->mruSize;
|
uint64_t end = start + registry->mruSize;
|
||||||
|
@ -165,6 +175,4 @@ FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNo
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
void fstRegistryEntryDestroy(FstRegistryEntry* entry) {
|
void fstRegistryEntryDestroy(FstRegistryEntry* entry) { taosMemoryFree(entry); }
|
||||||
taosMemoryFree(entry);
|
|
||||||
}
|
|
|
@ -12,8 +12,8 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "index_fst_util.h"
|
#include "indexFstUtil.h"
|
||||||
#include "index_fst_common.h"
|
#include "indexFstCommon.h"
|
||||||
|
|
||||||
// A sentinel value used to indicate an empty final state
|
// A sentinel value used to indicate an empty final state
|
||||||
const CompiledAddr EMPTY_ADDRESS = 0;
|
const CompiledAddr EMPTY_ADDRESS = 0;
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "indexSparse.h"
|
||||||
|
|
||||||
|
FstSparseSet *sparSetCreate(int32_t sz) {
|
||||||
|
FstSparseSet *ss = taosMemoryCalloc(1, sizeof(FstSparseSet));
|
||||||
|
if (ss = NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ss->dense = taosArrayInit(sz, sizeof(uint32_t));
|
||||||
|
ss->sparse = taosArrayInit(sz, sizeof(uint32_t));
|
||||||
|
ss->size = sz;
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
void sparSetDestroy(FstSparseSet *ss) {
|
||||||
|
if (ss == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
taosArrayDestroy(ss->dense);
|
||||||
|
taosArrayDestroy(ss->sparse);
|
||||||
|
taosMemoryFree(ss);
|
||||||
|
}
|
||||||
|
uint32_t sparSetLen(FstSparseSet *ss) { 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->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;
|
||||||
|
}
|
||||||
|
bool sparSetContains(FstSparseSet *ss, uint32_t ip) {
|
||||||
|
if (ip >= taosArrayGetSize(ss->sparse)) {
|
||||||
|
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) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ss->size = 0;
|
||||||
|
}
|
|
@ -13,12 +13,12 @@ p *
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "index_tfile.h"
|
#include "indexTfile.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "index_comm.h"
|
#include "indexComm.h"
|
||||||
#include "index_fst.h"
|
#include "indexFst.h"
|
||||||
#include "index_fst_counting_writer.h"
|
#include "indexFstCountingWriter.h"
|
||||||
#include "index_util.h"
|
#include "indexUtil.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "tcoding.h"
|
#include "tcoding.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
|
@ -12,7 +12,7 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "index_util.h"
|
#include "indexUtil.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
#include "indexCache.h"
|
||||||
|
#include "indexFst.h"
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_cache.h"
|
#include "indexTfile.h"
|
||||||
#include "index_fst.h"
|
|
||||||
#include "index_fst_counting_writer.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
#include "index_tfile.h"
|
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
void* callback(void* s) { return s; }
|
void* callback(void* s) { return s; }
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
#include "indexCache.h"
|
||||||
|
#include "indexFst.h"
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_cache.h"
|
#include "indexTfile.h"
|
||||||
#include "index_fst.h"
|
|
||||||
#include "index_fst_counting_writer.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
#include "index_tfile.h"
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
#include "indexCache.h"
|
||||||
|
#include "indexFst.h"
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_cache.h"
|
#include "indexTfile.h"
|
||||||
#include "index_fst.h"
|
#include "indexUtil.h"
|
||||||
#include "index_fst_counting_writer.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
#include "index_tfile.h"
|
|
||||||
#include "index_util.h"
|
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
#include "indexCache.h"
|
||||||
|
#include "indexFst.h"
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_cache.h"
|
#include "indexTfile.h"
|
||||||
#include "index_fst.h"
|
#include "indexUtil.h"
|
||||||
#include "index_fst_counting_writer.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
#include "index_tfile.h"
|
|
||||||
#include "index_util.h"
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
#include "indexCache.h"
|
||||||
|
#include "indexFst.h"
|
||||||
|
#include "indexFstCountingWriter.h"
|
||||||
|
#include "indexFstUtil.h"
|
||||||
#include "indexInt.h"
|
#include "indexInt.h"
|
||||||
#include "index_cache.h"
|
#include "indexTfile.h"
|
||||||
#include "index_fst.h"
|
#include "indexUtil.h"
|
||||||
#include "index_fst_counting_writer.h"
|
|
||||||
#include "index_fst_util.h"
|
|
||||||
#include "index_tfile.h"
|
|
||||||
#include "index_util.h"
|
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tskiplist.h"
|
#include "tskiplist.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
Loading…
Reference in New Issue