diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-10 12:01:36 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-10 12:01:36 +0100 |
commit | b2c129a84c630371b1a16372be8a0f81b9a7a70d (patch) | |
tree | f9bbd10608f0a2b01dc55c1c32cbad1219b6865e | |
parent | a42b9c7da0647e47712ee53819563a8b96ebf0e5 (diff) | |
download | rspamd-b2c129a84c630371b1a16372be8a0f81b9a7a70d.tar.gz rspamd-b2c129a84c630371b1a16372be8a0f81b9a7a70d.zip |
[Feature] Compress neural net in redis
-rw-r--r-- | src/plugins/lua/fann_scores.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua index 82b0d658c..8123a92bb 100644 --- a/src/plugins/lua/fann_scores.lua +++ b/src/plugins/lua/fann_scores.lua @@ -584,8 +584,14 @@ local function maybe_load_fann(task, continue_cb, call_if_fail) local function redis_fann_load_cb(task, err, data) if not err and type(data) == 'table' and type(data[2]) == 'string' then local version = tonumber(data[1]) - local ann_data = data[2] - local ann = rspamd_fann.load_data(ann_data) + local err,ann_data = rspamd_util.zstd_decompress(data[2]) + local ann + + if err or not ann_data then + rspamd_logger.errx(task, 'cannot decompress ann: %s', err) + else + ann = rspamd_fann.load_data(ann_data) + end if ann then current_classify_ann.loaded = true @@ -716,7 +722,7 @@ local function save_fann(task, is_spam) { key, 'version', tostring(current_classify_ann.version), - 'data', tostring(data), + 'data', rspamd_util.zstd_compress(data), 'spam', tostring(current_classify_ann.spam_learned), 'ham', tostring(current_classify_ann.ham_learned), } -- arguments |