Author: rooneg
Date: Tue Mar 22 18:25:51 2005
New Revision: 158709

URL: http://svn.apache.org/viewcvs?view=rev&rev=158709
Log:
Continue pushing the scorer related code into the weight object, rather
than the query object.  Also pass the weight into the term scorer create
function, so it can be used for scoring purposes there.

* include/lcn_scorer.h
  (lcn_weight_t): moved here to avoid circular dependencies.
  (lcn_term_scorer_create): add a weight argument, for scoring purposes.

* include/lcn_query.h
  (lcn_weight_t): removed, now in lcn_scorer.h.

* src/search/query.c
  (query_scorer_internal_t): renamed to...
  (weight_scorer_internal_t): this.  also changed the query argument to a
   weight.
  (lcn_query_t): remove scorer_internal field.
  (lcn_weight_t): add scorer_internal field.  change type of value_internal.
  (weight_value_internal): rename to...
  (weight_value_internal_t): this, for consistency.
  (term_scorer_internal): take weight, not a query.
  (term_weight_internal): init scorer_internal.
  (lcn_term_query_create): remove init of scorer_internal.
  (boolean_scorer_internal): change query to weight.
  (boolean_weight_internal): init scorer_internal.
  (lcn_boolean_query_create): remove init of scorer_internal.
  (lcn_weight_scorer): call scorer_internal through weight, not query.

* src/search/scorer.c
  (lcn_term_scorer_create): add weight argument.

Modified:
    incubator/lucene4c/trunk/include/lcn_query.h
    incubator/lucene4c/trunk/include/lcn_scorer.h
    incubator/lucene4c/trunk/src/search/query.c
    incubator/lucene4c/trunk/src/search/scorer.c

Modified: incubator/lucene4c/trunk/include/lcn_query.h
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/include/lcn_query.h?view=diff&r1=158708&r2=158709
==============================================================================
--- incubator/lucene4c/trunk/include/lcn_query.h (original)
+++ incubator/lucene4c/trunk/include/lcn_query.h Tue Mar 22 18:25:51 2005
@@ -67,12 +67,6 @@
                        lcn_query_t *clause,
                        lcn_boolean_clause_occur_t occur);
 
-/** The structure that stores data about a query that must be modified
- * during a search. This allows a given query to be reused for more than
- * one search.
- */
-typedef struct lcn_weight_t lcn_weight_t;
-
 /** Return @a weight's underlying query. */
 lcn_query_t * lcn_weight_query (lcn_weight_t *weight);
 

Modified: incubator/lucene4c/trunk/include/lcn_scorer.h
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/include/lcn_scorer.h?view=diff&r1=158708&r2=158709
==============================================================================
--- incubator/lucene4c/trunk/include/lcn_scorer.h (original)
+++ incubator/lucene4c/trunk/include/lcn_scorer.h Tue Mar 22 18:25:51 2005
@@ -29,14 +29,24 @@
 extern "C" {
 #endif /* __cplusplus */
 
+/** The structure that stores data about a query that must be modified
+ * during a search. This allows a given query to be reused for more than
+ * one search.
+ *
+ * This is declared here rather than in lcn_query.h to avoid circular
+ * dependencies.
+ */
+typedef struct lcn_weight_t lcn_weight_t;
+
 /** Abstract scorer object. */
 typedef struct lcn_scorer_t lcn_scorer_t;
 
 /** Create a @a scorer that returns scores for each document matched
- * in @a iter, allocated in @a pool.
+ * by @a weight in @a iter, allocated in @a pool.
  */
 lcn_error_t *
 lcn_term_scorer_create (lcn_scorer_t **scorer,
+                        lcn_weight_t *weight,
                         lcn_doc_iter_t *iter,
                         apr_pool_t *pool);
 

Modified: incubator/lucene4c/trunk/src/search/query.c
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/search/query.c?view=diff&r1=158708&r2=158709
==============================================================================
--- incubator/lucene4c/trunk/src/search/query.c (original)
+++ incubator/lucene4c/trunk/src/search/query.c Tue Mar 22 18:25:51 2005
@@ -21,11 +21,6 @@
   BOOLEAN_QUERY
 } query_type_t;
 
-typedef lcn_error_t * (*query_scorer_internal_t) (lcn_scorer_t **scorer,
-                                                  lcn_query_t *query,
-                                                  lcn_index_t *index,
-                                                  apr_pool_t *pool);
-
 typedef lcn_error_t * (*query_weight_internal_t) (lcn_weight_t **weight,
                                                   lcn_query_t *query,
                                                   apr_pool_t *pool);
@@ -33,35 +28,40 @@
 struct lcn_query_t {
   query_type_t type;
 
-  query_scorer_internal_t scorer_internal;
-
   query_weight_internal_t weight_internal;
 
   void *baton;
 };
 
-typedef float (*weight_value_internal) (lcn_weight_t *weight);
+typedef float (*weight_value_internal_t) (lcn_weight_t *weight);
+
+typedef lcn_error_t * (*weight_scorer_internal_t) (lcn_scorer_t **scorer,
+                                                   lcn_weight_t *query,
+                                                   lcn_index_t *index,
+                                                   apr_pool_t *pool);
+
 
 struct lcn_weight_t {
   lcn_query_t *query;
 
-  weight_value_internal value_internal;
+  weight_scorer_internal_t scorer_internal;
+  weight_value_internal_t value_internal;
 
   void *baton;
 };
 
 static lcn_error_t *
 term_scorer_internal (lcn_scorer_t **scorer,
-                      lcn_query_t *query,
+                      lcn_weight_t *weight,
                       lcn_index_t *index,
                       apr_pool_t *pool)
 {
-  lcn_term_t *term = query->baton;
+  lcn_term_t *term = lcn_weight_query (weight)->baton;
   lcn_doc_iter_t *iter;
 
   LCN_ERR (lcn_index_term_docs (&iter, index, term, pool));
 
-  LCN_ERR (lcn_term_scorer_create (scorer, iter, pool));
+  LCN_ERR (lcn_term_scorer_create (scorer, weight, iter, pool));
 
   return LCN_NO_ERROR;
 }
@@ -90,6 +90,7 @@
 
   w->query = query;
 
+  w->scorer_internal = term_scorer_internal;
   w->value_internal = term_value_internal;
 
   w->baton = apr_pcalloc (pool, sizeof (struct term_weight_baton));
@@ -107,7 +108,6 @@
   *q  = apr_pcalloc (pool, sizeof (**q));
 
   (*q)->type = TERM_QUERY;
-  (*q)->scorer_internal = term_scorer_internal;
   (*q)->weight_internal = term_weight_internal;
   (*q)->baton = t;
 
@@ -122,11 +122,11 @@
 
 static lcn_error_t *
 boolean_scorer_internal (lcn_scorer_t **scorer,
-                         lcn_query_t *query,
+                         lcn_weight_t *weight,
                          lcn_index_t *index,
                          apr_pool_t *pool)
 {
-  boolean_query_baton_t *bqb = query->baton;
+  boolean_query_baton_t *bqb = lcn_weight_query (weight)->baton;
 
   LCN_ERR (lcn_boolean_scorer_create (scorer,
                                       bqb->must,
@@ -153,6 +153,7 @@
 
   w->query = query;
 
+  w->scorer_internal = boolean_scorer_internal;
   w->value_internal = boolean_value_internal;
 
   *weight = w;
@@ -172,7 +173,6 @@
   *q  = apr_pcalloc (pool, sizeof (**q));
 
   (*q)->type = BOOLEAN_QUERY;
-  (*q)->scorer_internal = boolean_scorer_internal;
   (*q)->weight_internal = boolean_weight_internal;
   (*q)->baton = bqb;
  
@@ -236,7 +236,5 @@
                    lcn_index_t *index,
                    apr_pool_t *pool)
 {
-  lcn_query_t *query = lcn_weight_query (weight);
-
-  return query->scorer_internal (scorer, query, index, pool);
+  return weight->scorer_internal (scorer, weight, index, pool);
 }

Modified: incubator/lucene4c/trunk/src/search/scorer.c
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/search/scorer.c?view=diff&r1=158708&r2=158709
==============================================================================
--- incubator/lucene4c/trunk/src/search/scorer.c (original)
+++ incubator/lucene4c/trunk/src/search/scorer.c Tue Mar 22 18:25:51 2005
@@ -48,6 +48,7 @@
 
 lcn_error_t *
 lcn_term_scorer_create (lcn_scorer_t **scorer,
+                        lcn_weight_t *weight,
                         lcn_doc_iter_t *iter,
                         apr_pool_t *pool)
 {


Reply via email to