Hi,
i'm working on a project using Ferret for indexing it's datas. I'm very
happy with it but i need to code an extension to implement a .to_json
method to TopDocs class, because ruby's json implementation is really
really slow...
It's my second (the first was the tutorial :/ ) ruby C extension, so i'm
not really at ease with ruby C bindings, even with the C experience...
Here is my problem :
I would like to load each document from ids in my TopDoc object, to make
the json string myself from that, but i don't know how to load my
documents from this class... it's really weirdo to me actually :\ hope
somebody can help !
Here is my code, situated in r_search.c :
static VALUE
frt_td_to_json(VALUE self)
{
int i;
VALUE rhits = rb_funcall(self, id_hits, 0);
VALUE rhit;
const int len = RARRAY(rhits)->len;
long pos;
for (i = 0; i < len; i++)
{
rhit = RARRAY(rhits)->ptr[i];
pos = FIX2INT(rb_funcall(rhit, id_doc, 0));
//
// HERE I WOUlD LIKE TO LOAD THE DOCUMENTS, ID IS THE GOOD DOC_ID..
// I WOULD LIKE TO GET THIS IN FACT (ruby):
// doc_id = INDEX.search('query').hits.first
// INDEX[doc_id].load <== THAT'S WHAT I WOULD LIKE TO GET !
//
}
rstr = rb_str_new2(str);
free(str);
return (argv[0]);
}
of course, i've bound the method to the good object etc...
Hope somebody'll help !
Thank you by advance,
Jeremie 'ahFeel' BORDIER
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk