From ebc0d18f9ba993148d8d9b636e53ce162bf13eff Mon Sep 17 00:00:00 2001 From: l00584793 Date: Fri, 17 Jun 2022 15:42:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E5=AD=98=E5=87=BD=E6=95=B0=E5=93=88?= =?UTF-8?q?=E5=B8=8C=E8=A1=A8=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/threadpool/knl_instance.cpp | 7 +++++++ .../runtime/vecexecutor/vecexpression.cpp | 10 +++++++++- src/include/knl/knl_instance.h | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/gausskernel/process/threadpool/knl_instance.cpp b/src/gausskernel/process/threadpool/knl_instance.cpp index a2d5768fd..efa1979ab 100755 --- a/src/gausskernel/process/threadpool/knl_instance.cpp +++ b/src/gausskernel/process/threadpool/knl_instance.cpp @@ -740,6 +740,12 @@ static void knl_g_audit_init(knl_g_audit_context *audit_cxt) } } +void knl_plugin_vec_func_init(knl_g_plugin_vec_func_context* func_cxt) { + for (int i = 0; i < PLUGIN_VEC_FUNC_HATB_COUNT; i++) { + func_cxt->vec_func_plugin[i] = NULL; + } +} + void knl_instance_init() { g_instance.binaryupgrade = false; @@ -831,6 +837,7 @@ void knl_instance_init() knl_g_streaming_dr_init(&g_instance.streaming_dr_cxt); knl_g_csn_barrier_init(&g_instance.csn_barrier_cxt); knl_g_audit_init(&g_instance.audit_cxt); + knl_plugin_vec_func_init(&g_instance.plugin_vec_func_cxt); } void add_numa_alloc_info(void* numaAddr, size_t length) diff --git a/src/gausskernel/runtime/vecexecutor/vecexpression.cpp b/src/gausskernel/runtime/vecexecutor/vecexpression.cpp index 8c536458e..d1fcbc6a5 100644 --- a/src/gausskernel/runtime/vecexecutor/vecexpression.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecexpression.cpp @@ -1990,7 +1990,15 @@ void InitVectorFunction(FunctionCallInfo finfo, MemoryContext fcacheCxt) Oid foid = finfo->flinfo->fn_oid; - entry = (VecFuncCacheEntry*)hash_search(g_instance.vec_func_hash, &foid, HASH_FIND, &found); + struct HTAB* vec_func_hash = NULL; + if (u_sess->attr.attr_sql.dolphin && + g_instance.plugin_vec_func_cxt.vec_func_plugin[DOLPHIN_VEC] != NULL) { + vec_func_hash = g_instance.plugin_vec_func_cxt.vec_func_plugin[DOLPHIN_VEC]; + } else { + vec_func_hash = g_instance.vec_func_hash; + } + + entry = (VecFuncCacheEntry*)hash_search(vec_func_hash, &foid, HASH_FIND, &found); if (found && entry->vec_fn_cache[0] != NULL) { finfo->flinfo->vec_fn_cache = &entry->vec_fn_cache[0]; diff --git a/src/include/knl/knl_instance.h b/src/include/knl/knl_instance.h index f9637ac0e..30afb1d99 100755 --- a/src/include/knl/knl_instance.h +++ b/src/include/knl/knl_instance.h @@ -146,6 +146,20 @@ typedef struct knl_g_cost_context { } knl_g_cost_context; +enum plugin_vecfunc_type { + DOLPHIN_VEC = 0, + + /* + * This is the number of vecfunc hash tables. + * If you are adding a new plugin hash table, do not place an enumeration after it. + */ + PLUGIN_VEC_FUNC_HATB_COUNT, +}; + +typedef struct knl_g_plugin_vec_func_context { + struct HTAB* vec_func_plugin[PLUGIN_VEC_FUNC_HATB_COUNT]; +} knl_g_plugin_vec_func_context; + typedef struct knl_g_pid_context { ThreadId StartupPID; ThreadId TwoPhaseCleanerPID; @@ -1148,6 +1162,7 @@ typedef struct knl_instance_context { uint64 global_session_seq; struct HTAB* vec_func_hash; + knl_g_plugin_vec_func_context plugin_vec_func_cxt; MemoryContext instance_context; MemoryContext error_context;