LUCENE-3069: setField now expose per-field info to term dict

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3069@1493517 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Han Jiang 2013-06-16 14:44:33 +00:00
parent 8609b1d2f8
commit 48df915f8d
2 changed files with 13 additions and 16 deletions

View File

@ -496,6 +496,7 @@ public class TempBlockTermsWriter extends FieldsConsumer {
class TermsWriter extends TermsConsumer {
private final FieldInfo fieldInfo;
private final int longsSize;
private long numTerms;
long sumTotalTermFreq;
long sumDocFreq;
@ -856,8 +857,7 @@ public class TempBlockTermsWriter extends FieldsConsumer {
int termCount;
final int size = postingsWriter.longsSize();
long[] lastLongs = new long[size];
long[] lastLongs = new long[longsSize];
Arrays.fill(lastLongs, 0);
if (isLeafBlock) {
@ -884,7 +884,7 @@ public class TempBlockTermsWriter extends FieldsConsumer {
}
// Write term meta data
for (int pos = 0; pos < size; pos++) {
for (int pos = 0; pos < longsSize; pos++) {
assert term.longs[pos] >= 0;
metaWriter.writeVLong(term.longs[pos] - lastLongs[pos]);
}
@ -926,7 +926,7 @@ public class TempBlockTermsWriter extends FieldsConsumer {
// separate anymore:
// Write term meta data
for (int pos = 0; pos < size; pos++) {
for (int pos = 0; pos < longsSize; pos++) {
assert term.longs[pos] >= 0;
metaWriter.writeVLong(term.longs[pos] - lastLongs[pos]);
}
@ -1014,7 +1014,7 @@ public class TempBlockTermsWriter extends FieldsConsumer {
PackedInts.COMPACT,
true, 15);
postingsWriter.setField(fieldInfo);
this.longsSize = postingsWriter.setField(fieldInfo);
}
@Override
@ -1046,7 +1046,7 @@ public class TempBlockTermsWriter extends FieldsConsumer {
blockBuilder.add(Util.toIntsRef(text, scratchIntsRef), noOutputs.getNoOutput());
long[] longs = new long[postingsWriter.longsSize()];
long[] longs = new long[longsSize];
postingsWriter.finishTerm(longs, metaWriter, stats);
byte[] bytes = new byte[(int)metaWriter.getFilePointer()];
metaWriter.writeTo(bytes, 0);
@ -1093,7 +1093,7 @@ public class TempBlockTermsWriter extends FieldsConsumer {
sumTotalTermFreq,
sumDocFreq,
docCount,
postingsWriter.longsSize()));
longsSize));
} else {
assert sumTotalTermFreq == 0 || fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY && sumTotalTermFreq == -1;
assert sumDocFreq == 0;

View File

@ -198,13 +198,18 @@ public final class TempPostingsWriter extends TempPostingsWriterBase {
// nocommit better name?
@Override
public void setField(FieldInfo fieldInfo) {
public int setField(FieldInfo fieldInfo) {
IndexOptions indexOptions = fieldInfo.getIndexOptions();
fieldHasFreqs = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
fieldHasPositions = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
fieldHasOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
fieldHasPayloads = fieldInfo.hasPayloads();
skipWriter.setField(fieldHasPositions, fieldHasOffsets, fieldHasPayloads);
if (fieldHasPositions) {
return 3; // doc + pos + pay FP
} else {
return 1; // docFP
}
}
@Override
@ -350,14 +355,6 @@ public final class TempPostingsWriter extends TempPostingsWriterBase {
}
}
public int longsSize() {
if (fieldHasPositions) {
return 3; // doc + pos + pay FP
} else {
return 1; // docFP
}
}
// nocommit explain about the "don't care" values
/** Called when we are done adding docs to this term */