From 7fc46ffab1483240ed59be204b26165e44ccb9a8 Mon Sep 17 00:00:00 2001 From: Michael Busch Date: Wed, 23 Feb 2011 21:02:39 +0000 Subject: [PATCH] LUCENE-2881: fix intermittent failing test by clearing term vectors bits in FieldInfos for segments that had only docs with non-aborting exceptions git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1073947 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/index/DocFieldProcessor.java | 7 +++++++ lucene/src/java/org/apache/lucene/index/FieldInfos.java | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java b/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java index 6416f518983..3a85224462b 100644 --- a/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java +++ b/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java @@ -59,6 +59,13 @@ final class DocFieldProcessor extends DocConsumer { // FreqProxTermsWriter does this with // FieldInfo.storePayload. final String fileName = IndexFileNames.segmentFileName(state.segmentName, "", IndexFileNames.FIELD_INFOS_EXTENSION); + + // If this segment only has docs that hit non-aborting exceptions, + // then no term vectors files will have been written; therefore we + // need to update the fieldInfos and clear the term vectors bits + if (!state.hasVectors) { + state.fieldInfos.clearVectors(); + } state.fieldInfos.write(state.directory, fileName); } diff --git a/lucene/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/src/java/org/apache/lucene/index/FieldInfos.java index d5834bc5cbf..a3417798b20 100644 --- a/lucene/src/java/org/apache/lucene/index/FieldInfos.java +++ b/lucene/src/java/org/apache/lucene/index/FieldInfos.java @@ -403,6 +403,14 @@ public final class FieldInfos implements Iterable { return false; } + void clearVectors() { + for (FieldInfo fi : this) { + fi.storeTermVector = false; + fi.storeOffsetWithTermVector = false; + fi.storePositionWithTermVector = false; + } + } + public boolean hasNorms() { for (FieldInfo fi : this) { if (!fi.omitNorms) {