You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2013/10/24 19:43:09 UTC

[jira] [Commented] (LUCENE-3041) Support Query Visting / Walking

    [ https://issues.apache.org/jira/browse/LUCENE-3041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13804446#comment-13804446 ] 

Uwe Schindler commented on LUCENE-3041:
---------------------------------------

Hi I found a bug in the InvocationDispatcher when used with Java 7: the manual ordering of methods to visit is broken, because Class#getDeclaredMethods() returns the methods in random order (on same JVM, too). The ordering is not enough to prevent choosing the wrong method, so AmbiguousMethodException occurs ("Multiple methods resolved for parameter type, cannot disambiguate"). In the current code, because older JVMs return methods in declaration order and as Collections.sort() is stable, the methods declared earlier take precendence. But this does no longer work with Java 7.

If I have time, I will upload a fix I found for that (I have one locally in another package, because this visitor was used for some internal code). The new approach groups the visit(*) methods by parameter types with same superclass and also sorts by class hierarchy distance (more far superclasses get lower score than direct superclasses). The approch uses the lowest distance from parameter type to method type.

This makes InvocationDispatcher randomization proof (just add Collections.sort() in the InvocationDispatcher ctor to test...)

> Support Query Visting / Walking
> -------------------------------
>
>                 Key: LUCENE-3041
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3041
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/search
>    Affects Versions: 4.0-ALPHA
>            Reporter: Chris Male
>            Assignee: Simon Willnauer
>            Priority: Minor
>             Fix For: 4.6
>
>         Attachments: LUCENE-3041.patch, LUCENE-3041.patch, LUCENE-3041.patch, LUCENE-3041.patch, LUCENE-3041.patch
>
>
> Out of the discussion in LUCENE-2868, it could be useful to add a generic Query Visitor / Walker that could be used for more advanced rewriting, optimizations or anything that requires state to be stored as each Query is visited.
> We could keep the interface very simple:
> {code}
> public interface QueryVisitor {
>   Query visit(Query query);
> }
> {code}
> and then use a reflection based visitor like Earwin suggested, which would allow implementators to provide visit methods for just Querys that they are interested in.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org