Apache Lucene open-source search software
LUCENE-5339: renames
Michael McCandlessf6cd7fda747a
diff --git a/TODO b/TODOindex 828e1b4bacd..9034b0c4127 100644--- a/TODO+++ b/TODO@@ -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?diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.javaindex 9d17653e213..e5b13171b78 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/FastTaxonomyFacetCounts.java@@ -146,26 +146,26 @@ public class FastTaxonomyFacetCounts extends Facets {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 extends Facets {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);diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.javaindex 1efd51e5d84..d00fc0382c3 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/SortedSetDocValuesFacetCounts.java@@ -85,13 +85,13 @@ public class SortedSetDocValuesFacetCounts extends Facets {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 SortedSetDocValuesFacetCounts extends Facets {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 SortedSetDocValuesFacetCounts extends Facets {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);diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.javaindex 8c79fe53a61..05debd44e71 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/SumFloatAssociationFacets.java@@ -151,20 +151,20 @@ public class SumFloatAssociationFacets extends Facets {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 extends Facets {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);}diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.javaindex 73131c8df4c..12373ae11b3 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/SumIntAssociationFacets.java@@ -151,26 +151,26 @@ public class SumIntAssociationFacets extends Facets {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 extends Facets {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);diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.javaindex d4f1a94f7fc..024d6e8e1f3 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetCounts.java@@ -129,26 +129,26 @@ public class TaxonomyFacetCounts extends Facets {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 Facets {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);diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.javaindex 64858e879fc..a9dc9c4cdc8 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/TaxonomyFacetSumValueSource.java@@ -156,20 +156,20 @@ public class TaxonomyFacetSumValueSource extends Facets {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 extends Facets {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);}diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.javasimilarity index 85%rename from lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.javarename to lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.javaindex 85cb62636df..c76a9519363 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdValueQueue.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndFloatQueue.java@@ -21,15 +21,16 @@ import org.apache.lucene.util.PriorityQueue;// 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);}diff --git a/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.java b/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.javasimilarity index 72%rename from lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.javarename to lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.javaindex 4b625ef2b0e..9bb812d8ee8 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdCountQueue.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/simple/TopOrdAndIntQueue.java@@ -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;