Mercurial Hosting > luan
changeset 292:e8a2153f6ce1
minor
git-svn-id: https://luan-java.googlecode.com/svn/trunk@293 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 10 Dec 2014 21:44:19 +0000 |
parents | a35d1177bbf0 |
children | a50e88d3547c |
files | lucene/src/luan/modules/lucene/Ab_testing.luan |
diffstat | 1 files changed, 2 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
diff -r a35d1177bbf0 -r e8a2153f6ce1 lucene/src/luan/modules/lucene/Ab_testing.luan --- a/lucene/src/luan/modules/lucene/Ab_testing.luan Tue Dec 09 23:24:07 2014 +0000 +++ b/lucene/src/luan/modules/lucene/Ab_testing.luan Wed Dec 10 21:44:19 2014 +0000 @@ -9,7 +9,6 @@ local ab_testing = {} ab_testing.test_map = {} - ab_testing.test_list = {} function ab_testing.test(test) test.name or error "name not defined" @@ -92,9 +91,7 @@ return fancy end - ab_testing.test_map[test.name] = test - ab_testing.test_list[#ab_testing.test_list + 1] = test return test end @@ -105,16 +102,15 @@ -- returns map from test name to value function ab_testing.from_doc(doc) - local tests = ab_testing.test_list local values = {} - for _, test in ipairs(tests) do + for _, test in pairs(ab_testing.test_map) do values[test.name] = doc[test.field] end return values end function ab_testing.to_doc(doc,values,tests) - tests = tests or ab_testing.test_list + tests = tests or ab_testing.test_map if values == nil then for _, test in ipairs(tests) do doc[test.field] = test.values[Math.random(#test.values)]