From fac8ac88b9962a263849548d78aaa9f0b8899b9c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 12 Dec 2021 23:22:26 +0800 Subject: [PATCH] update fst search frame --- source/libs/index/inc/index_fst_automation.h | 10 +++++++++ source/libs/index/src/index_fst_automation.c | 23 ++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/source/libs/index/inc/index_fst_automation.h b/source/libs/index/inc/index_fst_automation.h index 6deeb1878a..c2ab61bf5f 100644 --- a/source/libs/index/inc/index_fst_automation.h +++ b/source/libs/index/inc/index_fst_automation.h @@ -38,8 +38,18 @@ typedef struct Complement { // automation typedef struct AutomationCtx { AutomationType type; + void *data; } AutomationCtx; + + +typedef enum StartWithStateKind { Done, Running } StartWithStateKind; + +typedef struct StartWithStateValue { + StartWithStateKind kind; + void *value; +} StartWithStateValue; + typedef struct AutomationFunc { void* (*start)(AutomationCtx *ctx) ; bool (*isMatch)(AutomationCtx *ctx, void *); diff --git a/source/libs/index/src/index_fst_automation.c b/source/libs/index/src/index_fst_automation.c index 392d8e6e8d..6a08b41b12 100644 --- a/source/libs/index/src/index_fst_automation.c +++ b/source/libs/index/src/index_fst_automation.c @@ -17,8 +17,9 @@ // prefix query, impl later -static void* prefixStart(AutomationCtx *ctx) { - return NULL; +static void* prefixStart(AutomationCtx *ctx) { + StartWithStateValue *data = (StartWithStateValue *)(ctx->data); + return data; }; static bool prefixIsMatch(AutomationCtx *ctx, void *data) { return true; @@ -82,16 +83,24 @@ AutomationCtx* automCtxCreate(void *data, AutomationType type) { AutomationCtx *ctx = calloc(1, sizeof(AutomationCtx)); if (ctx == NULL) { return NULL; } - ctx->type = type; - if (ctx->type == AUTOMATION_PREFIX) { - - } else if (ctx->type == AUTMMATION_MATCH) { - + if (type == AUTOMATION_PREFIX) { + StartWithStateValue *swsv = (StartWithStateValue *)calloc(1, sizeof(StartWithStateValue)); + swsv->kind = Done; + swsv->value = NULL; + ctx->data = (void *)swsv; + } else if (type == AUTMMATION_MATCH) { + } else { // add more search type } + + ctx->type = type; return ctx; } void automCtxDestroy(AutomationCtx *ctx) { + if (ctx->type == AUTOMATION_PREFIX) { + free(ctx->data); + } else if (ctx->type == AUTMMATION_MATCH) { + } free(ctx); }