Mailing List Archive

r3842 - in trunk: c_src/KinoSearch/Index perl/xs/KinoSearch/Index
Author: creamyg
Date: 2008-09-08 12:25:25 -0700 (Mon, 08 Sep 2008)
New Revision: 3842

Modified:
trunk/c_src/KinoSearch/Index/Inverter.bp
trunk/c_src/KinoSearch/Index/Inverter.c
trunk/perl/xs/KinoSearch/Index/SegWriter.c
Log:
Change Inverter_Add_Field to take CharBuf arguments rather than ptr/size
combos.


Modified: trunk/c_src/KinoSearch/Index/Inverter.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/Inverter.bp 2008-09-07 20:58:42 UTC (rev 3841)
+++ trunk/c_src/KinoSearch/Index/Inverter.bp 2008-09-08 19:25:25 UTC (rev 3842)
@@ -24,8 +24,8 @@
* invert it.
*/
void
- Add_Field(Inverter *self, FieldSpec *fspec, char *field_name,
- size_t field_name_len, char *value, size_t value_len);
+ Add_Field(Inverter *self, FieldSpec *fspec, const CharBuf *field,
+ Obj *value);

/** Grow internal allocations if necessary to handle the specified number
* of fields.

Modified: trunk/c_src/KinoSearch/Index/Inverter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/Inverter.c 2008-09-07 20:58:42 UTC (rev 3841)
+++ trunk/c_src/KinoSearch/Index/Inverter.c 2008-09-08 19:25:25 UTC (rev 3842)
@@ -100,12 +100,10 @@
{ return (Inversion*)maybe_get_obj(self, (Obj**)self->inversions); }

void
-Inverter_add_field(Inverter *self, FieldSpec *fspec,
- char *field_name, size_t field_name_len,
- char *value, size_t value_len)
+Inverter_add_field(Inverter *self, FieldSpec *fspec, const CharBuf *field,
+ Obj *value)
{
Schema *schema = self->schema;
- ViewCharBuf *field_vcb;
ViewCharBuf *value_vcb;
Similarity *sim;
Analyzer *analyzer;
@@ -115,20 +113,20 @@
self->max_fields);
}

- ViewCB_Assign_Str(self->fields[self->num_fields], field_name,
- field_name_len);
- ViewCB_Assign_Str(self->values[self->num_fields], value, value_len);
+ ViewCB_Assign(self->fields[self->num_fields], field);
+ if (!OBJ_IS_A(value, CHARBUF))
+ CONFESS("Can't handle non-string value for field '%o'", field);
+ ViewCB_Assign(self->values[self->num_fields], value);

- field_vcb = self->fields[self->num_fields];
value_vcb = self->values[self->num_fields];
fspec = self->specs[self->num_fields]
- = Schema_Fetch_FSpec(schema, (CharBuf*)field_vcb);
+ = Schema_Fetch_FSpec(schema, field);
analyzer = self->analyzers[self->num_fields]
- = Schema_Fetch_Analyzer(schema, (CharBuf*)field_vcb);
+ = Schema_Fetch_Analyzer(schema, field);
sim = self->sims[self->num_fields]
- = Schema_Fetch_Sim(schema, (CharBuf*)field_vcb);
+ = Schema_Fetch_Sim(schema, field);

- if (!fspec) CONFESS("Unknown field: '%s'", field_name);
+ if (!fspec) CONFESS("Unknown field: '%o'", field);

/* Get an Inversion, going through analyzer if appropriate. */
if (fspec->analyzed) {

Modified: trunk/perl/xs/KinoSearch/Index/SegWriter.c
===================================================================
--- trunk/perl/xs/KinoSearch/Index/SegWriter.c 2008-09-07 20:58:42 UTC (rev 3841)
+++ trunk/perl/xs/KinoSearch/Index/SegWriter.c 2008-09-08 19:25:25 UTC (rev 3842)
@@ -15,6 +15,7 @@
HV *fields = doc->fields;
I32 num_keys = hv_iterinit(fields);
kino_ZombieCharBuf field = KINO_ZCB_BLANK;
+ kino_ZombieCharBuf value = KINO_ZCB_BLANK;

/* Init the Inverter with the freshly acquired doc. */
Kino_Inverter_Clear(inverter);
@@ -33,7 +34,7 @@
: ((key_len = HeKLEN(entry)), HeKEY(entry));
SV *value_sv = HeVAL(entry);
STRLEN value_len;
- char *value;
+ char *value_ptr;

/* Find the FieldSpec for this field. */
Kino_ZCB_Assign_Str(&field, key, key_len);
@@ -57,14 +58,15 @@

/* Get the field value, forcing text fields to UTF-8. */
if (fspec->binary) {
- value = SvPV(value_sv, value_len);
+ value_ptr = SvPV(value_sv, value_len);
}
else {
- value = SvPVutf8(value_sv, value_len);
+ value_ptr = SvPVutf8(value_sv, value_len);
}
+ Kino_ZCB_Assign_Str(&value, value_ptr, value_len);

- Kino_Inverter_Add_Field(inverter, fspec, key, key_len,
- value, value_len);
+ Kino_Inverter_Add_Field(inverter, fspec, (kino_CharBuf*)&field,
+ (kino_Obj*)&value);
}

/* Feed the doc to the segment. */


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits