lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1440739 - /lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java
Date Thu, 31 Jan 2013 00:05:39 GMT
Author: mikemccand
Date: Thu Jan 31 00:05:38 2013
New Revision: 1440739

URL: http://svn.apache.org/viewvc?rev=1440739&view=rev
Log:
fix stinky code

Modified:
    lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java

Modified: lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java?rev=1440739&r1=1440738&r2=1440739&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesWriter.java
Thu Jan 31 00:05:38 2013
@@ -79,8 +79,7 @@ class SortedDocValuesWriter extends DocV
 
   @Override
   public void finish(int maxDoc) {
-    // nocommit: WTF.. why is this not a while but an if?
-    if (pending.size() < maxDoc) {
+    while(pending.size() < maxDoc) {
       addOneValue(EMPTY);
     }
   }
@@ -112,18 +111,7 @@ class SortedDocValuesWriter extends DocV
     final int maxDoc = state.segmentInfo.getDocCount();
 
     final int emptyOrd;
-    if (pending.size() < maxDoc) {
-      // Make sure we added EMPTY value before sorting:
-      int ord = hash.add(EMPTY);
-      if (ord < 0) {
-        emptyOrd = -ord-1;
-      } else {
-        emptyOrd = ord;
-      }
-    } else {
-      emptyOrd = -1; // nocommit: HUH? how can this possibly work?
-    }
-
+    assert pending.size() == maxDoc;
     final int valueCount = hash.size();
 
     final int[] sortedValues = hash.sort(BytesRef.getUTF8SortedAsUnicodeComparator());
@@ -147,7 +135,7 @@ class SortedDocValuesWriter extends DocV
                               new Iterable<Number>() {
                                 @Override
                                 public Iterator<Number> iterator() {
-                                  return new OrdsIterator(ordMap, maxDoc, emptyOrd);
+                                  return new OrdsIterator(ordMap, maxDoc);
                                 }
                               });
   }
@@ -193,15 +181,13 @@ class SortedDocValuesWriter extends DocV
   private class OrdsIterator implements Iterator<Number> {
     final AppendingLongBuffer.Iterator iter = pending.iterator();
     final int ordMap[];
-    final int size = pending.size();
     final int maxDoc;
-    final int emptyOrd; // nocommit
     int docUpto;
     
-    OrdsIterator(int ordMap[], int maxDoc, int emptyOrd) {
+    OrdsIterator(int ordMap[], int maxDoc) {
       this.ordMap = ordMap;
       this.maxDoc = maxDoc;
-      this.emptyOrd = emptyOrd;
+      assert pending.size() == maxDoc;
     }
     
     @Override
@@ -214,12 +200,7 @@ class SortedDocValuesWriter extends DocV
       if (!hasNext()) {
         throw new NoSuchElementException();
       }
-      int ord;
-      if (docUpto < size) {
-        ord = (int) iter.next();
-      } else {
-        ord = emptyOrd;
-      }
+      int ord = (int) iter.next();
       docUpto++;
       // TODO: make reusable Number
       return ordMap[ord];



Mime
View raw message