mirror of https://github.com/apache/lucene.git
LUCENE-3069: remove some nocommits, update hashCode() & equal()
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3069@1503781 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9bc7640fd1
commit
e70b4f394f
|
@ -317,9 +317,8 @@ public class TempFSTTermsReader extends FieldsProducer {
|
|||
public BytesRef next() throws IOException {
|
||||
if (seekPending) { // previously positioned, but termOutputs not fetched
|
||||
seekPending = false;
|
||||
if (seekCeil(term, false) != SeekStatus.FOUND) {
|
||||
return term;
|
||||
}
|
||||
SeekStatus status = seekCeil(term, false);
|
||||
assert status == SeekStatus.FOUND; // must positioned on valid term
|
||||
}
|
||||
updateEnum(fstEnum.next());
|
||||
return term;
|
||||
|
@ -331,7 +330,6 @@ public class TempFSTTermsReader extends FieldsProducer {
|
|||
return term != null;
|
||||
}
|
||||
|
||||
// nocommit: when will we useCache?
|
||||
@Override
|
||||
public SeekStatus seekCeil(final BytesRef target, final boolean useCache) throws IOException {
|
||||
updateEnum(fstEnum.seekCeil(target));
|
||||
|
|
|
@ -64,7 +64,6 @@ public class TempFSTTermsWriter extends FieldsConsumer {
|
|||
this.fieldInfos = state.fieldInfos;
|
||||
this.out = state.directory.createOutput(termsFileName, state.context);
|
||||
|
||||
// nocommit: why try catch here? not catching createOutput?
|
||||
boolean success = false;
|
||||
try {
|
||||
writeHeader(out);
|
||||
|
|
|
@ -29,14 +29,13 @@ import org.apache.lucene.store.DataOutput;
|
|||
import org.apache.lucene.util.fst.Outputs;
|
||||
import org.apache.lucene.util.LongsRef;
|
||||
|
||||
|
||||
// NOTE: outputs should be per-field, since
|
||||
// longsSize is fixed for each field
|
||||
public class TempTermOutputs extends Outputs<TempTermOutputs.TempMetaData> {
|
||||
private final static TempMetaData NO_OUTPUT = new TempMetaData();
|
||||
private static boolean DEBUG = false;
|
||||
private boolean hasPos;
|
||||
private int longsSize;
|
||||
private final boolean hasPos;
|
||||
private final int longsSize;
|
||||
|
||||
public static class TempMetaData {
|
||||
long[] longs;
|
||||
|
@ -55,6 +54,10 @@ public class TempTermOutputs extends Outputs<TempTermOutputs.TempMetaData> {
|
|||
this.docFreq = docFreq;
|
||||
this.totalTermFreq = totalTermFreq;
|
||||
}
|
||||
|
||||
// NOTE: actually, FST nodes are seldom
|
||||
// identical when outputs on their arcs
|
||||
// aren't NO_OUTPUTs.
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
|
@ -71,8 +74,23 @@ public class TempTermOutputs extends Outputs<TempTermOutputs.TempMetaData> {
|
|||
hash += bytes[i];
|
||||
}
|
||||
}
|
||||
hash += docFreq + totalTermFreq;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other_) {
|
||||
if (other_ == this) {
|
||||
return true;
|
||||
} else if (!(other_ instanceof TempTermOutputs.TempMetaData)) {
|
||||
return false;
|
||||
}
|
||||
TempMetaData other = (TempMetaData) other_;
|
||||
return statsEqual(this, other) &&
|
||||
longsEqual(this, other) &&
|
||||
bytesEqual(this, other);
|
||||
|
||||
}
|
||||
public String toString() {
|
||||
if (this == NO_OUTPUT) {
|
||||
return "no_output";
|
||||
|
@ -102,9 +120,6 @@ public class TempTermOutputs extends Outputs<TempTermOutputs.TempMetaData> {
|
|||
}
|
||||
}
|
||||
|
||||
private TempTermOutputs() {
|
||||
}
|
||||
|
||||
protected TempTermOutputs(FieldInfo fieldInfo, int longsSize) {
|
||||
this.hasPos = (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY);
|
||||
this.longsSize = longsSize;
|
||||
|
@ -149,7 +164,7 @@ public class TempTermOutputs extends Outputs<TempTermOutputs.TempMetaData> {
|
|||
ret = new TempMetaData(min, null, 0, -1);
|
||||
}
|
||||
} else { // equal long[]
|
||||
if (statsEqual(t1, t2) && (t1.bytes == null || bytesEqual(t1, t2))) {
|
||||
if (statsEqual(t1, t2) && bytesEqual(t1, t2)) {
|
||||
ret = t1;
|
||||
} else if (allZero(min)) {
|
||||
ret = NO_OUTPUT;
|
||||
|
@ -310,7 +325,16 @@ public class TempTermOutputs extends Outputs<TempTermOutputs.TempMetaData> {
|
|||
return t1.docFreq == t2.docFreq && t1.totalTermFreq == t2.totalTermFreq;
|
||||
}
|
||||
static boolean bytesEqual(final TempMetaData t1, final TempMetaData t2) {
|
||||
return Arrays.equals(t1.bytes, t2.bytes);
|
||||
if (t1.bytes == null && t2.bytes == null) {
|
||||
return true;
|
||||
}
|
||||
return t1.bytes != null && t2.bytes !=null && Arrays.equals(t1.bytes, t2.bytes);
|
||||
}
|
||||
static boolean longsEqual(final TempMetaData t1, final TempMetaData t2) {
|
||||
if (t1.longs == null && t2.longs == null) {
|
||||
return true;
|
||||
}
|
||||
return t1.longs != null && t2.longs !=null && Arrays.equals(t1.longs, t2.longs);
|
||||
}
|
||||
static boolean allZero(final long[] l) {
|
||||
for (int i = 0; i < l.length; i++) {
|
||||
|
|
Loading…
Reference in New Issue