From 1b1bcd6966f47a2568acee011dd4b9f18195d765 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 16 Dec 2009 20:06:29 +0300 Subject: * Implement pre and post classify callbacks for checking specific statfiles for this task TODO: - add properties to get all parameters of input task - add properties to statfile object - add some normalization function for calling from classify process - document changes --- src/classifiers/winnow.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/classifiers') diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c index 4b1bd5549..34e3dc209 100644 --- a/src/classifiers/winnow.c +++ b/src/classifiers/winnow.c @@ -30,6 +30,9 @@ #include "../main.h" #include "../filter.h" #include "../cfg_file.h" +#ifdef WITH_LUA +#include "../lua/lua_common.h" +#endif #define WINNOW_PROMOTION 1.23 #define WINNOW_DEMOTION 0.83 @@ -135,8 +138,20 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp data.count = 0; data.now = time (NULL); data.ctx = ctx; - - cur = ctx->cfg->statfiles; + + if (ctx->cfg->pre_callbacks) { +#ifdef WITH_LUA + cur = call_classifier_pre_callbacks (ctx->cfg, task); + if (cur) { + memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, cur); + } +#else + cur = ctx->cfg->statfiles; +#endif + } + else { + cur = ctx->cfg->statfiles; + } while (cur) { st = cur->data; if ((data.file = statfile_pool_is_open (pool, st->path)) == NULL) { @@ -170,7 +185,10 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp sumbuf = memory_pool_alloc (task->task_pool, 32); snprintf (sumbuf, 32, "%.2f", max); cur = g_list_prepend (NULL, sumbuf); - insert_result (task, ctx->cfg->metric, sel->symbol, 1, cur); +#ifdef WITH_LUA + max = call_classifier_post_callbacks (ctx->cfg, task, max); +#endif + insert_result (task, ctx->cfg->metric, sel->symbol, max, cur); } } -- cgit v1.2.3