lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r156324 - incubator/lucene4c/trunk/test/index/index_test.c
Date Sun, 06 Mar 2005 16:30:11 GMT
Author: rooneg
Date: Sun Mar  6 08:30:09 2005
New Revision: 156324

URL: http://svn.apache.org/viewcvs?view=rev&rev=156324
Log:
Add a test that points out a current problem with unoptimized indices,
for some reason we're getting duplicate results for some queries.

Amazing the kind of things you find when you actually try to use this
stuff ;-)

* test/index/index_test.c
  (add_to_results): helper function that adds a doc to a hash, so we can
   use it as a set.
  (test_index_term_docs_unopt): add another case, this time testing that
   we aren't returning the same doc number more than once.

Modified:
    incubator/lucene4c/trunk/test/index/index_test.c

Modified: incubator/lucene4c/trunk/test/index/index_test.c
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/test/index/index_test.c?view=diff&r1=156323&r2=156324
==============================================================================
--- incubator/lucene4c/trunk/test/index/index_test.c (original)
+++ incubator/lucene4c/trunk/test/index/index_test.c Sun Mar  6 08:30:09 2005
@@ -18,6 +18,8 @@
 
 #include "lcn_tests.h"
 
+#include "apr_hash.h"
+
 #include "abts.h"
 
 static void
@@ -114,6 +116,16 @@
 }
 
 static void
+add_to_results (apr_hash_t *results, apr_uint32_t doc)
+{
+  apr_uint32_t *pdoc = apr_pcalloc (p, sizeof (apr_uint32_t));
+
+  *pdoc = doc;
+
+  apr_hash_set (results, pdoc, sizeof (apr_uint32_t), pdoc);
+}
+
+static void
 test_index_term_docs_unopt (abts_case *tc, void *data)
 {
   lcn_term_t *term = lcn_term_create_cstring ("erik", "contents", p);
@@ -167,6 +179,26 @@
   ABTS_INT_EQUAL (tc, 7, count);
 
   lcn_error_clear (err);
+
+  term = lcn_term_create_cstring ("cutting", "contents", p);
+
+  CHK_ERR (lcn_index_term_docs (&itr, idx, term, p));
+
+  {
+    apr_hash_t *results = apr_hash_make (p);
+
+    add_to_results (results, lcn_doc_iter_doc (itr));
+
+    count = 1;
+
+    while ((err = lcn_doc_iter_next (&next, itr)) == LCN_NO_ERROR && next)
+      {
+        add_to_results (results, lcn_doc_iter_doc (itr));
+        ++count;
+      }
+
+    ABTS_INT_EQUAL (tc, count, apr_hash_count (results));
+  }
 
   apr_pool_clear (p);
 }



Mime
View raw message