You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/11/18 22:10:46 UTC

svn commit: r1543161 - in /lucene/dev/branches/lucene5339: ./ lucene/facet/src/java/org/apache/lucene/facet/simple/

Author: mikemccand
Date: Mon Nov 18 21:10:45 2013
New Revision: 1543161

URL: http://svn.apache.org/r1543161
Log:
LUCENE-5339: renames

Added:
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.java
      - copied, changed from r1542066, lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.java
      - copied, changed from r1543047, lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.java
Removed:
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.java
Modified:
    lucene/dev/branches/lucene5339/TODO
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java
    lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java

Modified: lucene/dev/branches/lucene5339/TODO
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/TODO?rev=1543161&r1=1543160&r2=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/TODO (original)
+++ lucene/dev/branches/lucene5339/TODO Mon Nov 18 21:10:45 2013
@@ -2,7 +2,6 @@ nocommit this!
 
 TODO
   - associations
-    - make SumFloat too
   - cutover taxo writer/reader to pathToString/stringToPath
   - wrap an IW instead of extending one?  or, FacetDocument?
   - re-enable ALL_BUT_DIM somehow?

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java?rev=1543161&r1=1543160&r2=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java Mon Nov 18 21:10:45 2013
@@ -146,26 +146,26 @@ public class FastTaxonomyFacetCounts ext
 
   private SimpleFacetResult getTopChildren(FacetLabel path, int dimOrd, int topN) throws IOException {
 
-    TopOrdCountQueue q = new TopOrdCountQueue(topN);
+    TopOrdAndIntQueue q = new TopOrdAndIntQueue(topN);
     
     int bottomCount = 0;
 
     int ord = children[dimOrd];
     int totCount = 0;
 
-    TopOrdCountQueue.OrdAndCount reuse = null;
+    TopOrdAndIntQueue.OrdAndValue reuse = null;
     while(ord != TaxonomyReader.INVALID_ORDINAL) {
       if (counts[ord] > 0) {
         totCount += counts[ord];
         if (counts[ord] > bottomCount) {
           if (reuse == null) {
-            reuse = new TopOrdCountQueue.OrdAndCount();
+            reuse = new TopOrdAndIntQueue.OrdAndValue();
           }
           reuse.ord = ord;
-          reuse.count = counts[ord];
+          reuse.value = counts[ord];
           reuse = q.insertWithOverflow(reuse);
           if (q.size() == topN) {
-            bottomCount = q.top().count;
+            bottomCount = q.top().value;
           }
         }
       }
@@ -187,9 +187,9 @@ public class FastTaxonomyFacetCounts ext
 
     LabelAndValue[] labelValues = new LabelAndValue[q.size()];
     for(int i=labelValues.length-1;i>=0;i--) {
-      TopOrdCountQueue.OrdAndCount ordAndCount = q.pop();
-      FacetLabel child = taxoReader.getPath(ordAndCount.ord);
-      labelValues[i] = new LabelAndValue(child.components[path.length], ordAndCount.count);
+      TopOrdAndIntQueue.OrdAndValue ordAndValue = q.pop();
+      FacetLabel child = taxoReader.getPath(ordAndValue.ord);
+      labelValues[i] = new LabelAndValue(child.components[path.length], ordAndValue.value);
     }
 
     return new SimpleFacetResult(path, totCount, labelValues);

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java?rev=1543161&r1=1543160&r2=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java Mon Nov 18 21:10:45 2013
@@ -85,13 +85,13 @@ public class SortedSetDocValuesFacetCoun
 
   private final SimpleFacetResult getDim(String dim, OrdRange ordRange, int topN) {
 
-    TopOrdCountQueue q = null;
+    TopOrdAndIntQueue q = null;
 
     int bottomCount = 0;
 
     int dimCount = 0;
 
-    TopOrdCountQueue.OrdAndCount reuse = null;
+    TopOrdAndIntQueue.OrdAndValue reuse = null;
     //System.out.println("getDim : " + ordRange.start + " - " + ordRange.end);
     for(int ord=ordRange.start; ord<=ordRange.end; ord++) {
       //System.out.println("  ord=" + ord + " count=" + counts[ord]);
@@ -99,18 +99,18 @@ public class SortedSetDocValuesFacetCoun
         dimCount += counts[ord];
         if (counts[ord] > bottomCount) {
           if (reuse == null) {
-            reuse = new TopOrdCountQueue.OrdAndCount();
+            reuse = new TopOrdAndIntQueue.OrdAndValue();
           }
           reuse.ord = ord;
-          reuse.count = counts[ord];
+          reuse.value = counts[ord];
           if (q == null) {
             // Lazy init, so we don't create this for the
             // sparse case unnecessarily
-            q = new TopOrdCountQueue(topN);
+            q = new TopOrdAndIntQueue(topN);
           }
           reuse = q.insertWithOverflow(reuse);
           if (q.size() == topN) {
-            bottomCount = q.top().count;
+            bottomCount = q.top().value;
           }
         }
       }
@@ -124,10 +124,10 @@ public class SortedSetDocValuesFacetCoun
 
     LabelAndValue[] labelValues = new LabelAndValue[q.size()];
     for(int i=labelValues.length-1;i>=0;i--) {
-      TopOrdCountQueue.OrdAndCount ordAndCount = q.pop();
-      dv.lookupOrd(ordAndCount.ord, scratch);
+      TopOrdAndIntQueue.OrdAndValue ordAndValue = q.pop();
+      dv.lookupOrd(ordAndValue.ord, scratch);
       String s = scratch.utf8ToString();
-      labelValues[i] = new LabelAndValue(s.substring(dim.length()+1, s.length()), ordAndCount.count);
+      labelValues[i] = new LabelAndValue(s.substring(dim.length()+1, s.length()), ordAndValue.value);
     }
 
     return new SimpleFacetResult(new FacetLabel(dim), dimCount, labelValues);

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java?rev=1543161&r1=1543160&r2=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java Mon Nov 18 21:10:45 2013
@@ -151,20 +151,20 @@ public class SumFloatAssociationFacets e
 
   private SimpleFacetResult getTopChildren(FacetLabel path, int dimOrd, int topN) throws IOException {
 
-    TopOrdValueQueue q = new TopOrdValueQueue(topN);
+    TopOrdAndFloatQueue q = new TopOrdAndFloatQueue(topN);
     
     float bottomValue = 0;
 
     int ord = children[dimOrd];
     float sumValue = 0;
 
-    TopOrdValueQueue.OrdAndValue reuse = null;
+    TopOrdAndFloatQueue.OrdAndValue reuse = null;
     while(ord != TaxonomyReader.INVALID_ORDINAL) {
       if (values[ord] > 0) {
         sumValue += values[ord];
         if (values[ord] > bottomValue) {
           if (reuse == null) {
-            reuse = new TopOrdValueQueue.OrdAndValue();
+            reuse = new TopOrdAndFloatQueue.OrdAndValue();
           }
           reuse.ord = ord;
           reuse.value = values[ord];
@@ -194,7 +194,7 @@ public class SumFloatAssociationFacets e
 
     LabelAndValue[] labelValues = new LabelAndValue[q.size()];
     for(int i=labelValues.length-1;i>=0;i--) {
-      TopOrdValueQueue.OrdAndValue ordAndValue = q.pop();
+      TopOrdAndFloatQueue.OrdAndValue ordAndValue = q.pop();
       FacetLabel child = taxoReader.getPath(ordAndValue.ord);
       labelValues[i] = new LabelAndValue(child.components[path.length], ordAndValue.value);
     }

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java?rev=1543161&r1=1543160&r2=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java Mon Nov 18 21:10:45 2013
@@ -151,26 +151,26 @@ public class SumIntAssociationFacets ext
 
   private SimpleFacetResult getTopChildren(FacetLabel path, int dimOrd, int topN) throws IOException {
 
-    TopOrdCountQueue q = new TopOrdCountQueue(topN);
+    TopOrdAndIntQueue q = new TopOrdAndIntQueue(topN);
     
     int bottomValue = 0;
 
     int ord = children[dimOrd];
     long sumValue = 0;
 
-    TopOrdCountQueue.OrdAndCount reuse = null;
+    TopOrdAndIntQueue.OrdAndValue reuse = null;
     while(ord != TaxonomyReader.INVALID_ORDINAL) {
       if (values[ord] > 0) {
         sumValue += values[ord];
         if (values[ord] > bottomValue) {
           if (reuse == null) {
-            reuse = new TopOrdCountQueue.OrdAndCount();
+            reuse = new TopOrdAndIntQueue.OrdAndValue();
           }
           reuse.ord = ord;
-          reuse.count = values[ord];
+          reuse.value = values[ord];
           reuse = q.insertWithOverflow(reuse);
           if (q.size() == topN) {
-            bottomValue = q.top().count;
+            bottomValue = q.top().value;
           }
         }
       }
@@ -194,9 +194,9 @@ public class SumIntAssociationFacets ext
 
     LabelAndValue[] labelValues = new LabelAndValue[q.size()];
     for(int i=labelValues.length-1;i>=0;i--) {
-      TopOrdCountQueue.OrdAndCount ordAndCount = q.pop();
-      FacetLabel child = taxoReader.getPath(ordAndCount.ord);
-      labelValues[i] = new LabelAndValue(child.components[path.length], ordAndCount.count);
+      TopOrdAndIntQueue.OrdAndValue ordAndValue = q.pop();
+      FacetLabel child = taxoReader.getPath(ordAndValue.ord);
+      labelValues[i] = new LabelAndValue(child.components[path.length], ordAndValue.value);
     }
 
     return new SimpleFacetResult(path, sumValue, labelValues);

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java?rev=1543161&r1=1543160&r2=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java Mon Nov 18 21:10:45 2013
@@ -129,26 +129,26 @@ public class TaxonomyFacetCounts extends
 
   private SimpleFacetResult getTopChildren(FacetLabel path, int dimOrd, int topN) throws IOException {
 
-    TopOrdCountQueue q = new TopOrdCountQueue(topN);
+    TopOrdAndIntQueue q = new TopOrdAndIntQueue(topN);
     
     int bottomCount = 0;
 
     int ord = children[dimOrd];
     int totCount = 0;
 
-    TopOrdCountQueue.OrdAndCount reuse = null;
+    TopOrdAndIntQueue.OrdAndValue reuse = null;
     while(ord != TaxonomyReader.INVALID_ORDINAL) {
       if (counts[ord] > 0) {
         totCount += counts[ord];
         if (counts[ord] > bottomCount) {
           if (reuse == null) {
-            reuse = new TopOrdCountQueue.OrdAndCount();
+            reuse = new TopOrdAndIntQueue.OrdAndValue();
           }
           reuse.ord = ord;
-          reuse.count = counts[ord];
+          reuse.value = counts[ord];
           reuse = q.insertWithOverflow(reuse);
           if (q.size() == topN) {
-            bottomCount = q.top().count;
+            bottomCount = q.top().value;
           }
         }
       }
@@ -170,9 +170,9 @@ public class TaxonomyFacetCounts extends
 
     LabelAndValue[] labelValues = new LabelAndValue[q.size()];
     for(int i=labelValues.length-1;i>=0;i--) {
-      TopOrdCountQueue.OrdAndCount ordAndCount = q.pop();
-      FacetLabel child = taxoReader.getPath(ordAndCount.ord);
-      labelValues[i] = new LabelAndValue(child.components[path.length], ordAndCount.count);
+      TopOrdAndIntQueue.OrdAndValue ordAndValue = q.pop();
+      FacetLabel child = taxoReader.getPath(ordAndValue.ord);
+      labelValues[i] = new LabelAndValue(child.components[path.length], ordAndValue.value);
     }
 
     return new SimpleFacetResult(path, totCount, labelValues);

Modified: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java?rev=1543161&r1=1543160&r2=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java Mon Nov 18 21:10:45 2013
@@ -156,20 +156,20 @@ public class TaxonomyFacetSumValueSource
 
   private SimpleFacetResult getTopChildren(FacetLabel path, int dimOrd, int topN) throws IOException {
 
-    TopOrdValueQueue q = new TopOrdValueQueue(topN);
+    TopOrdAndFloatQueue q = new TopOrdAndFloatQueue(topN);
     
     float bottomValue = 0;
 
     int ord = children[dimOrd];
     float sumValues = 0;
 
-    TopOrdValueQueue.OrdAndValue reuse = null;
+    TopOrdAndFloatQueue.OrdAndValue reuse = null;
     while(ord != TaxonomyReader.INVALID_ORDINAL) {
       if (values[ord] > 0) {
         sumValues += values[ord];
         if (values[ord] > bottomValue) {
           if (reuse == null) {
-            reuse = new TopOrdValueQueue.OrdAndValue();
+            reuse = new TopOrdAndFloatQueue.OrdAndValue();
           }
           reuse.ord = ord;
           reuse.value = values[ord];
@@ -194,7 +194,7 @@ public class TaxonomyFacetSumValueSource
 
     LabelAndValue[] labelValues = new LabelAndValue[q.size()];
     for(int i=labelValues.length-1;i>=0;i--) {
-      TopOrdValueQueue.OrdAndValue ordAndValue = q.pop();
+      TopOrdAndFloatQueue.OrdAndValue ordAndValue = q.pop();
       FacetLabel child = taxoReader.getPath(ordAndValue.ord);
       labelValues[i] = new LabelAndValue(child.components[path.length], ordAndValue.value);
     }

Copied: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.java (from r1542066, lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.java?p2=lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.java&p1=lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.java&r1=1542066&r2=1543161&rev=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.java Mon Nov 18 21:10:45 2013
@@ -21,15 +21,16 @@ import org.apache.lucene.util.PriorityQu
 
 // nocommit make value a double and merge with TopOrdCountValueQueue?
 
-/** Keeps highest results. */
-class TopOrdValueQueue extends PriorityQueue<TopOrdValueQueue.OrdAndValue> {
+/** Keeps highest results, first by largest float value,
+ *  then tie break by smallest ord. */
+class TopOrdAndFloatQueue extends PriorityQueue<TopOrdAndFloatQueue.OrdAndValue> {
 
   public static final class OrdAndValue {
     int ord;
     float value;
   }
 
-  public TopOrdValueQueue(int topN) {
+  public TopOrdAndFloatQueue(int topN) {
     super(topN, false);
   }
 

Copied: lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.java (from r1543047, lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.java?p2=lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.java&p1=lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.java&r1=1543047&r2=1543161&rev=1543161&view=diff
==============================================================================
--- lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.java (original)
+++ lucene/dev/branches/lucene5339/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.java Mon Nov 18 21:10:45 2013
@@ -19,25 +19,24 @@ package org.apache.lucene.facet.simple;
 
 import org.apache.lucene.util.PriorityQueue;
 
-// nocommit rename to TopOrdIntQueue?
+/** Keeps highest results, first by largest int value,
+ *  then tie break by smallest ord. */
+class TopOrdAndIntQueue extends PriorityQueue<TopOrdAndIntQueue.OrdAndValue> {
 
-/** Keeps highest count results. */
-class TopOrdCountQueue extends PriorityQueue<TopOrdCountQueue.OrdAndCount> {
-
-  public static final class OrdAndCount {
+  public static final class OrdAndValue {
     int ord;
-    int count;
+    int value;
   }
 
-  public TopOrdCountQueue(int topN) {
+  public TopOrdAndIntQueue(int topN) {
     super(topN, false);
   }
 
   @Override
-  protected boolean lessThan(OrdAndCount a, OrdAndCount b) {
-    if (a.count < b.count) {
+  protected boolean lessThan(OrdAndValue a, OrdAndValue b) {
+    if (a.value < b.value) {
       return true;
-    } else if (a.count > b.count) {
+    } else if (a.value > b.value) {
       return false;
     } else {
       return a.ord > b.ord;