Apache Lucene open-source search software
LUCENE-3728: tidy up copySegmentAsIs/sharedDocStore logic
Robert Muir7487fb30f3e0
diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.javaindex 15ec66f4609..25efb9eb557 100644--- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java+++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java@@ -2545,23 +2545,21 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {// only relevant for segments that share doc store with others,// because the DS might have been copied already, in which case we// just want to update the DS name of this SegmentInfo.- // NOTE: pre-3x segments include a null DSName if they don't share doc- // store. The following code ensures we don't accidentally insert- // 'null' to the map.String dsName = info.getDocStoreSegment();+ assert dsName != null;final String newDsName;- if (dsName != null) {- if (dsNames.containsKey(dsName)) {- newDsName = dsNames.get(dsName);- } else {- dsNames.put(dsName, segName);- newDsName = segName;- }+ if (dsNames.containsKey(dsName)) {+ newDsName = dsNames.get(dsName);} else {+ dsNames.put(dsName, segName);newDsName = segName;}- Set<String> codecDocStoreFiles = info.codecDocStoreFiles();+ // nocommit: remove this+ Set<String> codecDocStoreFiles = new HashSet<String>();+ codec.storedFieldsFormat().files(info, codecDocStoreFiles);+ codec.termVectorsFormat().files(info, codecDocStoreFiles);+// Copy the segment filesfor (String file: info.files()) {final String newFileName;diff --git a/lucene/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/src/java/org/apache/lucene/index/SegmentInfo.javaindex b68d965109f..8db91f2c443 100644--- a/lucene/src/java/org/apache/lucene/index/SegmentInfo.java+++ b/lucene/src/java/org/apache/lucene/index/SegmentInfo.java@@ -218,15 +218,6 @@ public final class SegmentInfo implements Cloneable {sizeInBytes = sum;return sizeInBytes;}-- // nocommit: wrong to call this if (compoundFile)- // wrong to call this at all... nuke it- Set<String> codecDocStoreFiles() throws IOException {- Set<String> docStoreFiles = new HashSet<String>();- codec.storedFieldsFormat().files(this, docStoreFiles);- codec.termVectorsFormat().files(this, docStoreFiles);- return docStoreFiles;- }public boolean getHasVectors() throws IOException {return hasVectors == CHECK_FIELDINFO ? getFieldInfos().hasVectors() : hasVectors == YES;