mirror of https://github.com/apache/lucene.git
LUCENE-5339: renames
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5339@1543161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
18117c0b04
commit
f6cd7fda74
1
TODO
1
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?
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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;
|
Loading…
Reference in New Issue