mirror of https://github.com/apache/lucene.git
fix stinky code
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1440739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2504d3266e
commit
d1af262131
|
@ -79,8 +79,7 @@ class SortedDocValuesWriter extends DocValuesWriter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finish(int maxDoc) {
|
public void finish(int maxDoc) {
|
||||||
// nocommit: WTF.. why is this not a while but an if?
|
while(pending.size() < maxDoc) {
|
||||||
if (pending.size() < maxDoc) {
|
|
||||||
addOneValue(EMPTY);
|
addOneValue(EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,18 +111,7 @@ class SortedDocValuesWriter extends DocValuesWriter {
|
||||||
final int maxDoc = state.segmentInfo.getDocCount();
|
final int maxDoc = state.segmentInfo.getDocCount();
|
||||||
|
|
||||||
final int emptyOrd;
|
final int emptyOrd;
|
||||||
if (pending.size() < maxDoc) {
|
assert 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?
|
|
||||||
}
|
|
||||||
|
|
||||||
final int valueCount = hash.size();
|
final int valueCount = hash.size();
|
||||||
|
|
||||||
final int[] sortedValues = hash.sort(BytesRef.getUTF8SortedAsUnicodeComparator());
|
final int[] sortedValues = hash.sort(BytesRef.getUTF8SortedAsUnicodeComparator());
|
||||||
|
@ -147,7 +135,7 @@ class SortedDocValuesWriter extends DocValuesWriter {
|
||||||
new Iterable<Number>() {
|
new Iterable<Number>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Number> iterator() {
|
public Iterator<Number> iterator() {
|
||||||
return new OrdsIterator(ordMap, maxDoc, emptyOrd);
|
return new OrdsIterator(ordMap, maxDoc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -193,15 +181,13 @@ class SortedDocValuesWriter extends DocValuesWriter {
|
||||||
private class OrdsIterator implements Iterator<Number> {
|
private class OrdsIterator implements Iterator<Number> {
|
||||||
final AppendingLongBuffer.Iterator iter = pending.iterator();
|
final AppendingLongBuffer.Iterator iter = pending.iterator();
|
||||||
final int ordMap[];
|
final int ordMap[];
|
||||||
final int size = pending.size();
|
|
||||||
final int maxDoc;
|
final int maxDoc;
|
||||||
final int emptyOrd; // nocommit
|
|
||||||
int docUpto;
|
int docUpto;
|
||||||
|
|
||||||
OrdsIterator(int ordMap[], int maxDoc, int emptyOrd) {
|
OrdsIterator(int ordMap[], int maxDoc) {
|
||||||
this.ordMap = ordMap;
|
this.ordMap = ordMap;
|
||||||
this.maxDoc = maxDoc;
|
this.maxDoc = maxDoc;
|
||||||
this.emptyOrd = emptyOrd;
|
assert pending.size() == maxDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -214,12 +200,7 @@ class SortedDocValuesWriter extends DocValuesWriter {
|
||||||
if (!hasNext()) {
|
if (!hasNext()) {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
int ord;
|
int ord = (int) iter.next();
|
||||||
if (docUpto < size) {
|
|
||||||
ord = (int) iter.next();
|
|
||||||
} else {
|
|
||||||
ord = emptyOrd;
|
|
||||||
}
|
|
||||||
docUpto++;
|
docUpto++;
|
||||||
// TODO: make reusable Number
|
// TODO: make reusable Number
|
||||||
return ordMap[ord];
|
return ordMap[ord];
|
||||||
|
|
Loading…
Reference in New Issue