static lucy_InverterEntry* S_fetch_entry(pTHX_ lucy_Inverter *self, HE *hash_entry) { lucy_InverterIVARS *const ivars = lucy_Inverter_IVARS(self); lucy_Schema *const schema = ivars->schema; STRLEN key_size; const char *key = XSBind_hash_key_to_utf8(aTHX_ hash_entry, &key_size); cfish_String *field = CFISH_SSTR_WRAP_UTF8(key, key_size); int32_t field_num = LUCY_Seg_Field_Num(ivars->segment, field); if (!field_num) { // This field seems not to be in the segment yet. Try to find it in // the Schema. if (LUCY_Schema_Fetch_Type(schema, field)) { // The field is in the Schema. Get a field num from the Segment. field_num = LUCY_Seg_Add_Field(ivars->segment, field); } else { // We've truly failed to find the field. The user must // not have spec'd it. THROW(CFISH_ERR, "Unknown field name: '%s'", key); } } lucy_InverterEntry *entry = (lucy_InverterEntry*)CFISH_Vec_Fetch(ivars->entry_pool, field_num); if (!entry) { entry = lucy_InvEntry_new(schema, field, field_num); CFISH_Vec_Store(ivars->entry_pool, field_num, (cfish_Obj*)entry); } return entry; }
cfish_Vector* LUCY_Doc_Field_Names_IMP(lucy_Doc *self) { dTHX; lucy_DocIVARS *const ivars = lucy_Doc_IVARS(self); HV *fields = (HV*)ivars->fields; I32 num_fields = hv_iterinit(fields); cfish_Vector *retval = cfish_Vec_new(num_fields); while (num_fields--) { HE *entry = hv_iternext(fields); STRLEN key_size; const char *key = XSBind_hash_key_to_utf8(aTHX_ entry, &key_size); cfish_String *key_str = cfish_Str_new_from_trusted_utf8(key, key_size); CFISH_Vec_Push(retval, (cfish_Obj*)key_str); } return retval; }