assert postings != null;
int base = smi.base;
int[] docMap = smi.getDocMap();
postings.seek(smi.termEnum);
PayloadProcessor payloadProcessor = null;
if (smi.dirPayloadProcessor != null) {
payloadProcessor = smi.dirPayloadProcessor.getProcessor(smi.term);
}
while (postings.next()) {
df++;
int doc = postings.doc();
if (docMap != null)
{
doc = docMap[doc]; // map around deletions
}
doc += base;
final int freq = postings.freq();
FormatPostingsPositionsConsumer posConsumer=null;
try{
posConsumer=docConsumer.addDoc(doc, freq);
}
catch(CorruptIndexException e)
{
StringBuffer doclist=new StringBuffer();
StringBuffer debug=new StringBuffer();
debug.append("doc2=").append(doc).append(",");
debug.append("df=").append(df).append(",");
debug.append("base=").append(base).append(",");
debug.append("n=").append(n).append(",");
debug.append("term=").append(smis[0].term.toString()).append(",");
debug.append("sigterm=").append(smi.term.toString()).append(",");
for (int j = 0; j < n; j++) {
debug.append(j+"=").append(smis[j].base).append(",");
}
for (int j = 0; j < n; j++) {
debug.append(j+"=").append(smis[j].term.toString()).append(",");
}
for (int j = 0; j < n; j++) {
debug.append(j+"=").append(smis[j].reader.numDocs()).append(",");
}
debug.append("\r\n");
for (int j = 0; j < n; j++) {
debug.append(j+"=").append(smis[j].reader.directory().dir_uuid).append(",");
}
for (int j = 0; j < n; j++) {
debug.append(j+"=").append(smis[j].reader.toString()).append(",");
}
debug.append("\r\n");
while (postings.next()) {
int doc2 = postings.doc();
doclist.append(doc2+":"+postings.freq()).append(",");
}
postings.debug(doclist);
doclist.append(",outdf=").append(smi.termEnum.docFreq());
debug.append(doclist);
LOG.error(debug.toString(),e);
throw e;
}
if (indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
for (int j = 0; j < freq; j++) {
final int position = postings.nextPosition();
int payloadLength = postings.getPayloadLength();
if (payloadLength > 0) {
if (payloadBuffer == null || payloadBuffer.length < payloadLength)
payloadBuffer = new byte[payloadLength];
postings.getPayload(payloadBuffer, 0);
if (payloadProcessor != null) {
payloadBuffer = payloadProcessor.processPayload(payloadBuffer, 0, payloadLength);
payloadLength = payloadProcessor.payloadLength();
}
}
posConsumer.addPosition(position, payloadBuffer, 0, payloadLength);
}
posConsumer.finish();