Author: rooneg
Date: Sun Mar 20 06:49:09 2005
New Revision: 158329
URL: http://svn.apache.org/viewcvs?view=rev&rev=158329
Log:
Implement the weight's value function, which is rather useless at the
moment, since nothing is actually calculating the values, but hey, it's
a step...
* include/lcn_query.h
(lcn_weight_value): add doxygen docs, unifdef.
(lcn_weight_sum_of_squared_weights,
lcn_weight_normalize): add doxygen docs.
* src/search/query.c
(weight_value_internal): new typedef.
(lcn_weight_query): add a value_internal callback.
(term_weight_baton): new baton, for term weights.
(term_value_internal): term weight's impl of the value callback.
(term_weight_internal): set up the callback and baton.
(boolean_value_internal): dummy impl of callback.
(boolean_weight_internal): set up callback.
(lcn_weight_value): wrapper function.
Modified:
incubator/lucene4c/trunk/include/lcn_query.h
incubator/lucene4c/trunk/src/search/query.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=158328&r2=158329
==============================================================================
--- incubator/lucene4c/trunk/include/lcn_query.h (original)
+++ incubator/lucene4c/trunk/include/lcn_query.h Sun Mar 20 06:49:09 2005
@@ -76,12 +76,15 @@
/** Return @a weight's underlying query. */
lcn_query_t * lcn_weight_query (lcn_weight_t *weight);
-#if NOTYET
+/** Return the value of @a weight. */
float lcn_weight_value (lcn_weight_t *weight);
+#if NOTYET
+/** Return the sum of the squared weight sof contained query clauses. */
lcn_error_t *
lcn_weight_sum_of_squared_weights (float *sum, lcn_weight_t *weight);
+/** Assign a query normalization factor @a norm to this @a weight. */
lcn_error_t * lcn_weight_normalize (lcn_weight_t *weight, float norm);
/* XXX leaving out lcn_weight_explain for now... */
Modified: incubator/lucene4c/trunk/src/search/query.c
URL:
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/search/query.c?view=diff&r1=158328&r2=158329
==============================================================================
--- incubator/lucene4c/trunk/src/search/query.c (original)
+++ incubator/lucene4c/trunk/src/search/query.c Sun Mar 20 06:49:09 2005
@@ -40,9 +40,13 @@
void *baton;
};
+typedef float (*weight_value_internal) (lcn_weight_t *weight);
+
struct lcn_weight_t {
lcn_query_t *query;
+ weight_value_internal value_internal;
+
void *baton;
};
@@ -62,6 +66,21 @@
return LCN_NO_ERROR;
}
+struct term_weight_baton {
+ float value;
+ float idf;
+ float query_norm;
+ float query_weight;
+};
+
+static float
+term_value_internal (lcn_weight_t *weight)
+{
+ struct term_weight_baton *twb = weight->baton;
+
+ return twb->value;
+}
+
static lcn_error_t *
term_weight_internal (lcn_weight_t **weight,
lcn_query_t *query,
@@ -71,6 +90,10 @@
w->query = query;
+ w->value_internal = term_value_internal;
+
+ w->baton = apr_pcalloc (pool, sizeof (struct term_weight_baton));
+
*weight = w;
return LCN_NO_ERROR;
@@ -115,6 +138,12 @@
return LCN_NO_ERROR;
}
+static float
+boolean_value_internal (lcn_weight_t *weight)
+{
+ return 1.0f; /* XXX java impl returns getBoost() here... */
+}
+
static lcn_error_t *
boolean_weight_internal (lcn_weight_t **weight,
lcn_query_t *query,
@@ -124,6 +153,8 @@
w->query = query;
+ w->value_internal = boolean_value_internal;
+
*weight = w;
return LCN_NO_ERROR;
@@ -185,6 +216,12 @@
lcn_weight_query (lcn_weight_t *weight)
{
return weight->query;
+}
+
+float
+lcn_weight_value (lcn_weight_t *weight)
+{
+ return weight->value_internal (weight);
}
lcn_error_t *