未验证 提交 71f6bb65 编写于 作者: dengyihao's avatar dengyihao 提交者: GitHub

Merge pull request #8756 from taosdata/origin/3.0/fst

add core struct
......@@ -33,6 +33,8 @@ typedef struct FstBuilderNode {
FstBuilderNode *fstBuilderNodeDefault();
FstBuilderNode *fstBuilderNodeClone(FstBuilderNode *src);
void fstBuilderNodeCloneFrom(FstBuilderNode *dst, FstBuilderNode *src);
#endif
......@@ -54,5 +54,4 @@ FstRegistry* fstRegistryCreate(uint64_t tableSize, uint64_t mruSize);
FstRegistryEntry* fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNode);
uint64_t fstRegistryHash(FstRegistry *registry, FstBuilderNode *node);
#endif
......@@ -22,6 +22,26 @@ FstBuilderNode *fstBuilderNodeDefault() {
return bn;
}
FstBuilderNode *fstBuilderNodeClone(FstBuilderNode *src) {
FstBuilderNode *node = malloc(sizeof(FstBuilderNode));
if (node == NULL) { return NULL; }
size_t sz = taosArrayGetSize(src->trans);
SArray *trans = taosArrayInit(sz, sizeof(FstTransition));
for (size_t i = 0; i < sz; i++) {
FstTransition *tran = taosArrayGet(src->trans, i);
FstTransition t = *tran;
taosArrayPush(trans, &t);
}
node->trans = trans;
node->isFinal = src->isFinal;
node->finalOutput = src->finalOutput;
return node;
}
// not destroy src, User's bussiness
void fstBuilderNodeCloneFrom(FstBuilderNode *dst, FstBuilderNode *src) {
if (dst == NULL || src == NULL) { return; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册