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 <uw...@thetaphi.de> on 2011/01/11 19:36:20 UTC

RE: svn commit: r1057454 - in /lucene/dev/branches/branch_3x/lucene/contrib: ./ queryparser/src/java/org/apache/lucene/queryParser/core/builders/ queryparser/src/test/org/apache/lucene/queryParser/core/builders/

Will you commit this also to trunk? In general, issues should be fixed first on trunk and then backported.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: adrianocrestani@apache.org [mailto:adrianocrestani@apache.org]
> Sent: Tuesday, January 11, 2011 3:42 AM
> To: commits@lucene.apache.org
> Subject: svn commit: r1057454 - in
> /lucene/dev/branches/branch_3x/lucene/contrib: ./
> queryparser/src/java/org/apache/lucene/queryParser/core/builders/
> queryparser/src/test/org/apache/lucene/queryParser/core/builders/
> 
> Author: adrianocrestani
> Date: Tue Jan 11 02:41:44 2011
> New Revision: 1057454
> 
> URL: http://svn.apache.org/viewvc?rev=1057454&view=rev
> Log:
> committing fix for LUCENE-2855
> 
> Added:
> 
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/test/org/
> apache/lucene/queryParser/core/builders/
> 
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/test/org/
> apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java
> (with props)
> Modified:
>     lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt
> 
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/java/org/
> apache/lucene/queryParser/core/builders/QueryTreeBuilder.java
> 
> Modified: lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt
> URL:
> http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/con
> trib/CHANGES.txt?rev=1057454&r1=1057453&r2=1057454&view=diff
> ==========================================================
> ====================
> --- lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt (original)
> +++ lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt Tue Jan
> 11 02:41:44 2011
> @@ -48,6 +48,11 @@ Changes in runtime behavior
> 
>  Bug fixes
> 
> + * LUCENE-2855: contrib queryparser was using CharSequence as key in
> some internal
> +   Map instances, which was leading to incorrect behaviour, since some
> CharSequence
> +   implementors do not override hashcode and equals methods. Now the
> internal Maps
> +   are using String instead. (Adriano Crestani)
> +
>   * LUCENE-2068: Fixed ReverseStringFilter which was not aware of
> supplementary
>     characters. During reverse the filter created unpaired surrogates, which
>     will be replaced by U+FFFD by the indexer, but not at query time. The filter
> 
> Modified:
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/java/org/
> apache/lucene/queryParser/core/builders/QueryTreeBuilder.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/con
> trib/queryparser/src/java/org/apache/lucene/queryParser/core/builders/Q
> ueryTreeBuilder.java?rev=1057454&r1=1057453&r2=1057454&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/java/org/
> apache/lucene/queryParser/core/builders/QueryTreeBuilder.java (original)
> +++
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/java/org/
> apache/lucene/queryParser/core/builders/QueryTreeBuilder.java Tue Jan 11
> 02:41:44 2011
> @@ -61,7 +61,7 @@ public class QueryTreeBuilder implements
> 
>    private HashMap<Class<? extends QueryNode>, QueryBuilder>
> queryNodeBuilders;
> 
> -  private HashMap<CharSequence, QueryBuilder> fieldNameBuilders;
> +  private HashMap<String, QueryBuilder> fieldNameBuilders;
> 
>    /**
>     * {@link QueryTreeBuilder} constructor.
> @@ -73,28 +73,25 @@ public class QueryTreeBuilder implements
>    /**
>     * Associates a field name with a builder.
>     *
> -   * @param fieldName
> -   *          the field name
> -   * @param builder
> -   *          the builder to be associated
> +   * @param fieldName the field name
> +   * @param builder the builder to be associated
>     */
>    public void setBuilder(CharSequence fieldName, QueryBuilder builder) {
> 
>      if (this.fieldNameBuilders == null) {
> -      this.fieldNameBuilders = new HashMap<CharSequence,
> QueryBuilder>();
> +      this.fieldNameBuilders = new HashMap<String, QueryBuilder>();
>      }
> 
> -    this.fieldNameBuilders.put(fieldName, builder);
> +    this.fieldNameBuilders.put(fieldName.toString(), builder);
> +
> 
>    }
> 
>    /**
>     * Associates a class with a builder
>     *
> -   * @param queryNodeClass
> -   *          the class
> -   * @param builder
> -   *          the builder to be associated
> +   * @param queryNodeClass the class
> +   * @param builder the builder to be associated
>     */
>    public void setBuilder(Class<? extends QueryNode> queryNodeClass,
>        QueryBuilder builder) {
> @@ -135,8 +132,13 @@ public class QueryTreeBuilder implements
>      QueryBuilder builder = null;
> 
>      if (this.fieldNameBuilders != null && node instanceof FieldableNode) {
> +      CharSequence field = ((FieldableNode) node).getField();
> +
> +      if (field != null) {
> +        field = field.toString();
> +      }
> 
> -      builder = this.fieldNameBuilders.get(((FieldableNode) node).getField());
> +      builder = this.fieldNameBuilders.get(field);
> 
>      }
> 
> @@ -203,14 +205,13 @@ public class QueryTreeBuilder implements
>     * Builds some kind of object from a query tree. Each node in the query tree
>     * is built using an specific builder associated to it.
>     *
> -   * @param queryNode
> -   *          the query tree root node
> +   * @param queryNode the query tree root node
>     *
>     * @return the built object
>     *
> -   * @throws QueryNodeException
> -   *           if some node builder throws a {@link QueryNodeException} or if
> -   *           there is a node which had no builder associated to it
> +   * @throws QueryNodeException if some node builder throws a
> +   *         {@link QueryNodeException} or if there is a node which had no
> +   *         builder associated to it
>     */
>    public Object build(QueryNode queryNode) throws QueryNodeException {
>      process(queryNode);
> 
> Added:
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/test/org/
> apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/con
> trib/queryparser/src/test/org/apache/lucene/queryParser/core/builders/Te
> stQueryTreeBuilder.java?rev=1057454&view=auto
> ==========================================================
> ====================
> ---
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/test/org/
> apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java
> (added)
> +++
> lucene/dev/branches/branch_3x/lucene/contrib/queryparser/src/test/org/
> apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java Tue
> Jan 11 02:41:44 2011
> @@ -0,0 +1,31 @@
> +package org.apache.lucene.queryParser.core.builders;
> +
> +import junit.framework.Assert;
> +
> +import org.apache.lucene.queryParser.core.QueryNodeException;
> +import org.apache.lucene.queryParser.core.nodes.FieldQueryNode;
> +import org.apache.lucene.queryParser.core.nodes.QueryNode;
> +import org.apache.lucene.queryParser.core.util.UnescapedCharSequence;
> +import org.apache.lucene.util.LuceneTestCase;
> +import org.junit.Test;
> +
> +public class TestQueryTreeBuilder extends LuceneTestCase {
> +
> +  @Test
> +  public void testSetFieldBuilder() throws QueryNodeException {
> +    QueryTreeBuilder qtb = new QueryTreeBuilder();
> +    qtb.setBuilder("field", new DummyBuilder());
> +    Object result = qtb.build(new FieldQueryNode(new
> UnescapedCharSequence("field"), "foo", 0, 0));
> +    Assert.assertEquals("OK", result);
> +
> +  }
> +
> +  private static class DummyBuilder implements QueryBuilder {
> +
> +    public Object build(QueryNode queryNode) throws QueryNodeException
> {
> +      return "OK";
> +    }
> +
> +  }
> +
> +}
> 



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