[ 
https://issues.apache.org/jira/browse/SOLR-122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Coda Hale updated SOLR-122:
---------------------------

    Attachment: solrb_libxml_support.diff

Okay, so here it is, with full test support.

I was wondering how we should refactor out the XML generation and so forth to a 
common interface, when I realized we had a common interface -- REXML::Element. 
With a few minor changes, we can make XML::Node act exactly like REXML::Element.

So the XML generation class has been moved to Solr::XML::Element.

If we can load libxml-ruby, we do so, and make the minor changes to get 
XML::Node acting like REXML::Element. We then set Solr::XML::Element to 
XML::Node.

If we can't load libmxl-ruby, we load rexml/document, and set 
Solr::XML::Element to REXML::Element.

I've also gone through and changed some of the unit tests -- results are 
matched against regular expressions to smooth out the difference between 
libxml2 and REXML's output.

I think this approach is a lot nicer than the drop-in monkey patching -- this 
allows us to toggle between libxml-ruby and REXML for testing purposes, and we 
don't need to maintain/develop two versions of code generation.

I think the same approach should be taken with XML parsing, but since it 
doesn't seem like we're doing a lot of that, I've put that off.

As always, all tests pass, and I'm interested in any feedback.

> Add optional support for Ruby-libxml2 (vs. REXML)
> -------------------------------------------------
>
>                 Key: SOLR-122
>                 URL: https://issues.apache.org/jira/browse/SOLR-122
>             Project: Solr
>          Issue Type: Improvement
>          Components: clients - ruby - flare
>            Reporter: Coda Hale
>         Attachments: libxml.rb, libxml.rb, solrb_libxml_support.diff
>
>
> This file adds drop-in support for the ruby-libxml2, which is a wrapper for 
> the libxml2 library, which is an order of magnitude or so faster than REXML.
> This depends on my SOLR-121 patch for multi-document adds, since the behavior 
> of Solr::Request::AddDocument#to_s is different.
> Requiring this makes some tests fail, but for trivial reasons: some tests are 
> directly tied to REXML, others fail due to interelement whitespace added by 
> libxml2 (which you can't disable via the Ruby interface). Functionally, it's 
> identical, and passes all functional tests.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to