lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [10/16] lucy git commit: Sanity check MockMatcher ctor args.
Date Fri, 11 Sep 2015 22:00:35 GMT
Sanity check MockMatcher ctor args.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/456a8253
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/456a8253
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/456a8253

Branch: refs/heads/master
Commit: 456a82532432ac314f7c06a3d9f27e90aacf2384
Parents: b76fe6a
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Wed Aug 12 16:55:46 2015 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Wed Sep 9 18:25:23 2015 -0700

----------------------------------------------------------------------
 core/LucyX/Search/MockMatcher.c | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/456a8253/core/LucyX/Search/MockMatcher.c
----------------------------------------------------------------------
diff --git a/core/LucyX/Search/MockMatcher.c b/core/LucyX/Search/MockMatcher.c
index 73a1b8d..1cce741 100644
--- a/core/LucyX/Search/MockMatcher.c
+++ b/core/LucyX/Search/MockMatcher.c
@@ -30,6 +30,12 @@ MockMatcher*
 MockMatcher_init(MockMatcher *self, I32Array *doc_ids, Blob *scores) {
     Matcher_init((Matcher*)self);
     MockMatcherIVARS *const ivars = MockMatcher_IVARS(self);
+    size_t num_doc_ids = I32Arr_Get_Size(doc_ids);
+    size_t num_scores = scores ? Blob_Get_Size(scores) / sizeof(float) : 0;
+    if (scores != NULL && num_scores != num_doc_ids) {
+        THROW(ERR, "Num doc IDs != num scores (%u64, %u64)",
+              (uint64_t)num_doc_ids, (uint64_t)num_scores);
+    }
     ivars->tick    = -1;
     ivars->size    = I32Arr_Get_Size(doc_ids);
     ivars->doc_ids = (I32Array*)INCREF(doc_ids);


Mime
View raw message