lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r830408 - in /lucene/java/trunk/src/java/org/apache/lucene: index/ConcurrentMergeScheduler.java search/Sort.java search/function/CustomScoreQuery.java
Date Wed, 28 Oct 2009 00:07:22 GMT
Author: uschindler
Date: Wed Oct 28 00:07:22 2009
New Revision: 830408

URL: http://svn.apache.org/viewvc?rev=830408&view=rev
Log:
More Java 5 cleanup (Arrays.hashCode, Arrays.deepEquals, Arrays.deepHashCode)
Also added the commented out "assert !Thread.holdsLock(writer);" in CMS

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java
    lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java
    lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java?rev=830408&r1=830407&r2=830408&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java Wed Oct
28 00:07:22 2009
@@ -149,8 +149,7 @@
   public void merge(IndexWriter writer)
     throws CorruptIndexException, IOException {
 
-    // TODO: enable this once we are on JRE 1.5
-    // assert !Thread.holdsLock(writer);
+    assert !Thread.holdsLock(writer);
 
     this.writer = writer;
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java?rev=830408&r1=830407&r2=830408&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java Wed Oct 28 00:07:22 2009
@@ -173,9 +173,6 @@
 
   /** Returns a hash code value for this object. */
   public int hashCode() {
-    // TODO in Java 1.5: switch to Arrays.hashCode().  The 
-    // Java 1.4 workaround below calculates the same hashCode
-    // as Java 1.5's new Arrays.hashCode()
-    return 0x45aaf665 + Arrays.asList(fields).hashCode();
+    return 0x45aaf665 + Arrays.hashCode(fields);
   }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java?rev=830408&r1=830407&r2=830408&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java Wed
Oct 28 00:07:22 2009
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.util.Set;
+import java.util.Arrays;
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
@@ -145,22 +146,14 @@
         this.valSrcQueries.length != other.valSrcQueries.length) {
       return false;
     }
-    for (int i=0; i<valSrcQueries.length; i++) { //TODO simplify with Arrays.deepEquals()
once moving to Java 1.5
-      if (!valSrcQueries[i].equals(other.valSrcQueries[i])) {
-        return false;
-      }
-    }
-    return true;
+    return Arrays.deepEquals(valSrcQueries, other.valSrcQueries);
   }
 
   /** Returns a hash code value for this object. */
   @Override
   public int hashCode() {
-    int valSrcHash = 0;
-    for (int i=0; i<valSrcQueries.length; i++) { //TODO simplify with Arrays.deepHashcode()
once moving to Java 1.5
-      valSrcHash += valSrcQueries[i].hashCode();
-    }
-    return (getClass().hashCode() + subQuery.hashCode() + valSrcHash) ^ Float.floatToIntBits(getBoost());
+    return (getClass().hashCode() + subQuery.hashCode() + Arrays.deepHashCode(valSrcQueries))
+      ^ Float.floatToIntBits(getBoost());
   }  
   
   /**



Mime
View raw message