lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: svn commit: r178059 - /lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
Date Tue, 24 May 2005 07:05:17 GMT
Erik,

On Tuesday 24 May 2005 03:35, ehatcher@apache.org wrote:
> Author: ehatcher
> Date: Mon May 23 18:35:13 2005
....
> +  /** Returns true iff <code>o</code> is equal to this. */
> +  public boolean equals(Object o) {
> +    if (this == o) return true;
> +    if (o == null || getClass() != o.getClass()) return false;
> +
> +    final SpanNearQuery spanNearQuery = (SpanNearQuery) o;
> +
> +    if (inOrder != spanNearQuery.inOrder) return false;
> +    if (slop != spanNearQuery.slop) return false;
> +    if (!clauses.equals(spanNearQuery.clauses)) return false;
> +    if (!field.equals(spanNearQuery.field)) return false;
> +
> +    return true;
> +  }
> +  
> +  public int hashCode() {
> +    int result;
> +    result = clauses.hashCode();
> +    result = 29 * result + slop;

How about:
 result += slop * 29;

> +    result = 29 * result + (inOrder ? 1 : 0);

 result +=  (inOrder ? 1 : 0); // or some other constants larger than 1

> +    result = 29 * result + field.hashCode();

 result ^= field.hashCode(); // bitwise exclusive or

> +    return result;
> +  }
>  }

?
The idea is to preserve and use as many of the earlier bits
as possible. Multiplying by a large number by 29 can loose 4-5 
of the original high bits.

Regards,
Paul Elschot


Mime
View raw message