lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r917175 - in /lucene/java/branches/flex_1458: ./ contrib/ contrib/highlighter/src/test/ contrib/instantiated/src/test/org/apache/lucene/store/instantiated/ src/java/org/apache/lucene/analysis/ src/java/org/apache/lucene/index/ src/java/org/...
Date Sun, 28 Feb 2010 13:03:47 GMT
Author: mikemccand
Date: Sun Feb 28 13:03:46 2010
New Revision: 917175

URL: http://svn.apache.org/viewvc?rev=917175&view=rev
Log:
LUCENE-2282: merge to flex branch (making IndexFileNames public but internal)

Modified:
    lucene/java/branches/flex_1458/   (props changed)
    lucene/java/branches/flex_1458/CHANGES.txt
    lucene/java/branches/flex_1458/build.xml   (props changed)
    lucene/java/branches/flex_1458/contrib/   (props changed)
    lucene/java/branches/flex_1458/contrib/CHANGES.txt   (props changed)
    lucene/java/branches/flex_1458/contrib/highlighter/src/test/   (props changed)
    lucene/java/branches/flex_1458/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java   (props changed)
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Tokenizer.java   (props changed)
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldProcessor.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNameFilter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/NormsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentMerger.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentWriteState.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/StoredFieldsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsTermsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsWriter.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java   (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java   (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestDateTools.java   (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestNumberTools.java   (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java   (props changed)
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermVectorsReader.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java   (props changed)

Propchange: lucene/java/branches/flex_1458/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9:817269-818600,829134,829881,831036,896850,909334
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336
 /lucene/java/branches/lucene_3_0:880793,896906
-/lucene/java/trunk:824912-825292,827043-833960,880727-886190,889185,889614-916543,916596,916685,916769,917019
+/lucene/java/trunk:824912-825292,827043-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019

Modified: lucene/java/branches/flex_1458/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/CHANGES.txt?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/CHANGES.txt (original)
+++ lucene/java/branches/flex_1458/CHANGES.txt Sun Feb 28 13:03:46 2010
@@ -87,6 +87,11 @@
   operations before flush starts. Also exposed doAfterFlush as protected instead
   of package-private. (Shai Erera via Mike McCandless)
 
+* LUCENE-2282: IndexFileNames is exposed as a public class allowing for easier 
+  use by external code. In addition it offers a matchExtension method which 
+  callers can use to query whether a certain file matches a certain extension.
+  (Shai Erera via Mike McCandless)  
+
 Bug fixes
 
 * LUCENE-2119: Don't throw NegativeArraySizeException if you pass

Propchange: lucene/java/branches/flex_1458/build.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_9/build.xml:909334
-/lucene/java/trunk/build.xml:916596,916685,916769,917019
+/lucene/java/trunk/build.xml:916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/contrib:817269-818600,825998,829134,829816,829881,831036,896850,909334
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib:818601-821336
 /lucene/java/branches/lucene_3_0/contrib:880793,896906
-/lucene/java/trunk/contrib:824912-825292,827043-833960,880727-886190,889185,889614-916543,916596,916685,916769,917019
+/lucene/java/trunk/contrib:824912-825292,827043-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/contrib/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/contrib/CHANGES.txt:817269-818600,825998,826775,829134,829816,829881,831036,896850
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/CHANGES.txt:818601-821336
 /lucene/java/branches/lucene_3_0/contrib/CHANGES.txt:880793,896906
-/lucene/java/trunk/contrib/CHANGES.txt:829439-833960,880727-886190,889185,889622,889667,889866-899001,916596,916685,916769,917019
+/lucene/java/trunk/contrib/CHANGES.txt:829439-833960,880727-886190,889185,889622,889667,889866-899001,916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/contrib/highlighter/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/contrib/highlighter/src/test:817269-818600,825998,826775,829134,829816,829881,831036,896850,909334
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/highlighter/src/test:818601-821336
 /lucene/java/branches/lucene_3_0/contrib/highlighter/src/test:880793,896906
-/lucene/java/trunk/contrib/highlighter/src/test:829439-833960,880727-886190,889185,889614-916543,916596,916685,916769,917019
+/lucene/java/trunk/contrib/highlighter/src/test:829439-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_9/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:909334
-/lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:916596,916685,916769,917019
+/lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Tokenizer.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/Tokenizer.java:909334
-/lucene/java/trunk/src/java/org/apache/lucene/analysis/Tokenizer.java:916596,916685,916769,917019
+/lucene/java/trunk/src/java/org/apache/lucene/analysis/Tokenizer.java:916596,916685,916755,916769,917019

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldProcessor.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldProcessor.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldProcessor.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldProcessor.java Sun Feb 28 13:03:46 2010
@@ -67,7 +67,7 @@
     // consumer can alter the FieldInfo* if necessary.  EG,
     // FreqProxTermsWriter does this with
     // FieldInfo.storePayload.
-    final String fileName = state.segmentFileName(IndexFileNames.FIELD_INFOS_EXTENSION);
+    final String fileName = IndexFileNames.segmentFileName(state.segmentName, IndexFileNames.FIELD_INFOS_EXTENSION);
     fieldInfos.write(state.directory, fileName);
     state.flushedFiles.add(fileName);
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocumentsWriter.java Sun Feb 28 13:03:46 2010
@@ -623,7 +623,8 @@
   /** Build compound file for the segment we just flushed */
   void createCompoundFile(String segment) throws IOException {
     
-    CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, segment + "." + IndexFileNames.COMPOUND_FILE_EXTENSION);
+    CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, 
+        IndexFileNames.segmentFileName(segment, IndexFileNames.COMPOUND_FILE_EXTENSION));
     for(String fileName : flushState.flushedFiles) {
       if (Codec.DEBUG) {
         System.out.println("make cfs " + fileName);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsReader.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsReader.java Sun Feb 28 13:03:46 2010
@@ -105,8 +105,8 @@
     try {
       fieldInfos = fn;
 
-      cloneableFieldsStream = d.openInput(segment + "." + IndexFileNames.FIELDS_EXTENSION, readBufferSize);
-      cloneableIndexStream = d.openInput(segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION, readBufferSize);
+      cloneableFieldsStream = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_EXTENSION), readBufferSize);
+      cloneableIndexStream = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_INDEX_EXTENSION), readBufferSize);
       
       // First version of fdx did not include a format
       // header, but, the first int will always be 0 in that

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsWriter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/FieldsWriter.java Sun Feb 28 13:03:46 2010
@@ -61,7 +61,7 @@
         fieldInfos = fn;
 
         boolean success = false;
-        final String fieldsName = segment + "." + IndexFileNames.FIELDS_EXTENSION;
+        final String fieldsName = IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_EXTENSION);
         try {
           fieldsStream = d.createOutput(fieldsName);
           fieldsStream.writeInt(FORMAT_CURRENT);
@@ -82,7 +82,7 @@
         }
 
         success = false;
-        final String indexName = segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION;
+        final String indexName = IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_INDEX_EXTENSION);
         try {
           indexStream = d.createOutput(indexName);
           indexStream.writeInt(FORMAT_CURRENT);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNameFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNameFilter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNameFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNameFilter.java Sun Feb 28 13:03:46 2010
@@ -35,8 +35,8 @@
 
   public IndexFileNameFilter(Codecs codecs) {
     extensions = new HashSet<String>();
-    for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.length; i++) {
-      extensions.add(IndexFileNames.INDEX_EXTENSIONS[i]);
+    for (String ext : IndexFileNames.INDEX_EXTENSIONS) {
+      extensions.add(ext);
     }
     if (codecs != null) {
       for(String ext : codecs.getAllExtensions()) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexFileNames.java Sun Feb 28 13:03:46 2010
@@ -17,11 +17,16 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.index.codecs.Codec;  // for javadocs
 
 /**
- * Useful constants representing filenames and extensions
- * used by lucene.
+ * This class contains useful constants representing filenames and extensions
+ * used by lucene, as well as convenience methods for querying whether a file
+ * name matches an extension ({@link #matchesExtension(String, String)
+ * matchesExtension}), as well as generating file names from a segment name,
+ * generation and extension (
+ * {@link #fileNameFromGeneration(String, String, long) fileNameFromGeneration},
+ * {@link #segmentFileName(String, String) segmentFileName}).
  *
  * <p><b>NOTE</b>: extensions used by codecs are not
  * listed here.  You must interact with the {@link Codec}
@@ -33,53 +38,53 @@
 public final class IndexFileNames {
 
   /** Name of the index segment file */
-  static final String SEGMENTS = "segments";
+  public static final String SEGMENTS = "segments";
 
   /** Name of the generation reference file name */
-  static final String SEGMENTS_GEN = "segments.gen";
+  public static final String SEGMENTS_GEN = "segments.gen";
   
   /** Name of the index deletable file (only used in
    * pre-lockless indices) */
-  static final String DELETABLE = "deletable";
+  public static final String DELETABLE = "deletable";
    
   /** Extension of norms file */
-  static final String NORMS_EXTENSION = "nrm";
+  public static final String NORMS_EXTENSION = "nrm";
 
   /** Extension of stored fields index file */
-  static final String FIELDS_INDEX_EXTENSION = "fdx";
+  public static final String FIELDS_INDEX_EXTENSION = "fdx";
 
   /** Extension of stored fields file */
-  static final String FIELDS_EXTENSION = "fdt";
+  public static final String FIELDS_EXTENSION = "fdt";
 
   /** Extension of vectors fields file */
-  static final String VECTORS_FIELDS_EXTENSION = "tvf";
+  public static final String VECTORS_FIELDS_EXTENSION = "tvf";
 
   /** Extension of vectors documents file */
-  static final String VECTORS_DOCUMENTS_EXTENSION = "tvd";
+  public static final String VECTORS_DOCUMENTS_EXTENSION = "tvd";
 
   /** Extension of vectors index file */
-  static final String VECTORS_INDEX_EXTENSION = "tvx";
+  public static final String VECTORS_INDEX_EXTENSION = "tvx";
 
   /** Extension of compound file */
   public static final String COMPOUND_FILE_EXTENSION = "cfs";
 
   /** Extension of compound file for doc store files*/
-  static final String COMPOUND_FILE_STORE_EXTENSION = "cfx";
+  public static final String COMPOUND_FILE_STORE_EXTENSION = "cfx";
 
   /** Extension of deletes */
-  static final String DELETES_EXTENSION = "del";
+  public static final String DELETES_EXTENSION = "del";
 
   /** Extension of field infos */
-  static final String FIELD_INFOS_EXTENSION = "fnm";
+  public static final String FIELD_INFOS_EXTENSION = "fnm";
 
   /** Extension of plain norms */
-  static final String PLAIN_NORMS_EXTENSION = "f";
+  public static final String PLAIN_NORMS_EXTENSION = "f";
 
   /** Extension of separate norms */
-  static final String SEPARATE_NORMS_EXTENSION = "s";
+  public static final String SEPARATE_NORMS_EXTENSION = "s";
 
   /** Extension of gen file */
-  static final String GEN_EXTENSION = "gen";
+  public static final String GEN_EXTENSION = "gen";
 
   // nocommit -- more cleanup needed -- do we really use all
   // these arrays below?
@@ -92,7 +97,7 @@
    * Lucene's <code>segments_N</code> files do not have any
    * filename extension.
    */
-  static final String INDEX_EXTENSIONS[] = new String[] {
+  public static final String INDEX_EXTENSIONS[] = new String[] {
     COMPOUND_FILE_EXTENSION,
     FIELD_INFOS_EXTENSION,
     FIELDS_INDEX_EXTENSION,
@@ -108,7 +113,7 @@
 
   /** File extensions that are added to a compound file
    * (same as above, minus "del", "gen", "cfs"). */
-  static final String[] INDEX_EXTENSIONS_IN_COMPOUND_FILE = new String[] {
+  public static final String[] INDEX_EXTENSIONS_IN_COMPOUND_FILE = new String[] {
     FIELD_INFOS_EXTENSION,
     FIELDS_INDEX_EXTENSION,
     FIELDS_EXTENSION,
@@ -118,7 +123,7 @@
     NORMS_EXTENSION
   };
 
-  static final String[] STORE_INDEX_EXTENSIONS = new String[] {
+  public static final String[] STORE_INDEX_EXTENSIONS = new String[] {
     VECTORS_INDEX_EXTENSION,
     VECTORS_FIELDS_EXTENSION,
     VECTORS_DOCUMENTS_EXTENSION,
@@ -126,13 +131,13 @@
     FIELDS_EXTENSION
   };
 
-  static final String[] NON_STORE_INDEX_EXTENSIONS = new String[] {
+  public static final String[] NON_STORE_INDEX_EXTENSIONS = new String[] {
     FIELD_INFOS_EXTENSION,
     NORMS_EXTENSION
   };
   
   /** File extensions of old-style index files */
-  static final String COMPOUND_EXTENSIONS[] = new String[] {
+  public static final String COMPOUND_EXTENSIONS[] = new String[] {
     FIELD_INFOS_EXTENSION,
     FIELDS_INDEX_EXTENSION,
     FIELDS_EXTENSION,
@@ -145,48 +150,82 @@
   };
   
   /** File extensions for term vector support */
-  static final String VECTOR_EXTENSIONS[] = new String[] {
+  public static final String VECTOR_EXTENSIONS[] = new String[] {
     VECTORS_INDEX_EXTENSION,
     VECTORS_DOCUMENTS_EXTENSION,
     VECTORS_FIELDS_EXTENSION
   };
 
   /**
-   * Computes the full file name from base, extension and
-   * generation.  If the generation is -1, the file name is
-   * null.  If it's 0, the file name is <base><extension>.
-   * If it's > 0, the file name is <base>_<generation><extension>.
-   *
-   * @param base -- main part of the file name
-   * @param extension -- extension of the filename (including .)
-   * @param gen -- generation
+   * Computes the full file name from base, extension and generation. If the
+   * generation is -1, the file name is null. If it's 0, the file name is
+   * &lt;base&gt;.&lt;ext&gt;. If it's > 0, the file name is
+   * &lt;base&gt;_&lt;gen&gt;.&lt;ext&gt;.<br>
+   * <b>NOTE:</b> .&lt;ext&gt; is added to the name only if <code>ext</code> is
+   * not an empty string.
+   * 
+   * @param base main part of the file name
+   * @param ext extension of the filename
+   * @param gen generation
    */
-  static final String fileNameFromGeneration(String base, String extension, long gen) {
+  public static final String fileNameFromGeneration(String base, String ext, long gen) {
     if (gen == SegmentInfo.NO) {
       return null;
     } else if (gen == SegmentInfo.WITHOUT_GEN) {
-      return base + extension;
+      return segmentFileName(base, ext);
     } else {
-      return base + "_" + Long.toString(gen, Character.MAX_RADIX) + extension;
+      // The '6' part in the length is: 1 for '.', 1 for '_' and 4 as estimate
+      // to the gen length as string (hopefully an upper limit so SB won't
+      // expand in the middle.
+      StringBuilder res = new StringBuilder(base.length() + 6 + ext.length())
+          .append(base).append('_').append(Long.toString(gen, Character.MAX_RADIX));
+      if (ext.length() > 0) {
+        res.append('.').append(ext);
+      }
+      return res.toString();
     }
   }
 
   /**
-   * Returns true if the provided filename is one of the doc
-   * store files (ends with an extension in
-   * STORE_INDEX_EXTENSIONS).
+   * Returns true if the provided filename is one of the doc store files (ends
+   * with an extension in {@link #STORE_INDEX_EXTENSIONS}).
    */
-  static final boolean isDocStoreFile(String fileName) {
+  public static final boolean isDocStoreFile(String fileName) {
     if (fileName.endsWith(COMPOUND_FILE_STORE_EXTENSION))
       return true;
-    for(int i=0;i<STORE_INDEX_EXTENSIONS.length;i++)
-      if (fileName.endsWith(STORE_INDEX_EXTENSIONS[i]))
+    for (String ext : STORE_INDEX_EXTENSIONS) {
+      if (fileName.endsWith(ext))
         return true;
+    }
     return false;
   }
 
-  // nocommit -- made public
-  public static String segmentFileName(String segmentName, String ext) {
-    return segmentName + "." + ext;
+  /**
+   * Returns the file name that matches the given segment name and extension.
+   * This method takes care to return the full file name in the form
+   * &lt;segmentName&gt;.&lt;ext&gt;, therefore you don't need to prefix the
+   * extension with a '.'.<br>
+   * <b>NOTE:</b> .&lt;ext&gt; is added to the result file name only if
+   * <code>ext</code> is not empty.
+   */
+  public static final String segmentFileName(String segmentName, String ext) {
+    if (ext.length() > 0) {
+      assert !ext.startsWith(".");
+      return new StringBuilder(segmentName.length() + 1 + ext.length()).append(
+          segmentName).append('.').append(ext).toString();
+    } else {
+      return segmentName;
+    }
   }
+  
+  /**
+   * Returns true if the given filename ends with the given extension. One
+   * should provide a <i>pure</i> extension, withouth '.'.
+   */
+  public static final boolean matchesExtension(String filename, String ext) {
+    // It doesn't make a difference whether we allocate a StringBuilder ourself
+    // or not, since there's only 1 '+' operator.
+    return filename.endsWith("." + ext);
+  }
+  
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/IndexWriter.java Sun Feb 28 13:03:46 2010
@@ -1756,13 +1756,13 @@
       // Now build compound doc store file
 
       if (infoStream != null) {
-        message("create compound file " + docStoreSegment + "." + IndexFileNames.COMPOUND_FILE_STORE_EXTENSION);
+        message("create compound file " + IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.COMPOUND_FILE_STORE_EXTENSION));
       }
 
       success = false;
 
       final int numSegments = segmentInfos.size();
-      final String compoundFileName = docStoreSegment + "." + IndexFileNames.COMPOUND_FILE_STORE_EXTENSION;
+      final String compoundFileName = IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.COMPOUND_FILE_STORE_EXTENSION);
 
       try {
         CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, compoundFileName);
@@ -3673,7 +3673,7 @@
           if (!success) {
             if (infoStream != null)
               message("hit exception creating compound file for newly flushed segment " + segment);
-            deleter.deleteFile(segment + "." + IndexFileNames.COMPOUND_FILE_EXTENSION);
+            deleter.deleteFile(IndexFileNames.segmentFileName(segment, IndexFileNames.COMPOUND_FILE_EXTENSION));
           }
         }
 
@@ -4407,7 +4407,7 @@
     if (merge.useCompoundFile) {
 
       success = false;
-      final String compoundFileName = mergedName + "." + IndexFileNames.COMPOUND_FILE_EXTENSION;
+      final String compoundFileName = IndexFileNames.segmentFileName(mergedName, IndexFileNames.COMPOUND_FILE_EXTENSION);
 
       try {
         merger.createCompoundFile(compoundFileName, merge.info);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/NormsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/NormsWriter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/NormsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/NormsWriter.java Sun Feb 28 13:03:46 2010
@@ -90,7 +90,7 @@
       }
     }
 
-    final String normsFileName = state.segmentName + "." + IndexFileNames.NORMS_EXTENSION;
+    final String normsFileName = IndexFileNames.segmentFileName(state.segmentName, IndexFileNames.NORMS_EXTENSION);
     state.flushedFiles.add(normsFileName);
     IndexOutput normsOut = state.directory.createOutput(normsFileName);
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentInfo.java Sun Feb 28 13:03:46 2010
@@ -359,7 +359,7 @@
       return null;
     } else {
       // If delGen is CHECK_DIR, it's the pre-lockless-commit file format
-      return IndexFileNames.fileNameFromGeneration(name, "." + IndexFileNames.DELETES_EXTENSION, delGen); 
+      return IndexFileNames.fileNameFromGeneration(name, IndexFileNames.DELETES_EXTENSION, delGen); 
     }
   }
 
@@ -452,8 +452,6 @@
    * @param number field index
    */
   public String getNormFileName(int number) throws IOException {
-    String prefix;
-
     long gen;
     if (normGen == null) {
       gen = CHECK_DIR;
@@ -463,19 +461,16 @@
     
     if (hasSeparateNorms(number)) {
       // case 1: separate norm
-      prefix = ".s";
-      return IndexFileNames.fileNameFromGeneration(name, prefix + number, gen);
+      return IndexFileNames.fileNameFromGeneration(name, "s" + number, gen);
     }
 
     if (hasSingleNormFile) {
       // case 2: lockless (or nrm file exists) - single file for all norms 
-      prefix = "." + IndexFileNames.NORMS_EXTENSION;
-      return IndexFileNames.fileNameFromGeneration(name, prefix, WITHOUT_GEN);
+      return IndexFileNames.fileNameFromGeneration(name, IndexFileNames.NORMS_EXTENSION, WITHOUT_GEN);
     }
       
     // case 3: norm file for each field
-    prefix = ".f";
-    return IndexFileNames.fileNameFromGeneration(name, prefix + number, WITHOUT_GEN);
+    return IndexFileNames.fileNameFromGeneration(name, "f" + number, WITHOUT_GEN);
   }
 
   /**
@@ -503,7 +498,7 @@
     } else if (isCompoundFile == YES) {
       return true;
     } else {
-      return dir.fileExists(name + "." + IndexFileNames.COMPOUND_FILE_EXTENSION);
+      return dir.fileExists(IndexFileNames.segmentFileName(name, IndexFileNames.COMPOUND_FILE_EXTENSION));
     }
   }
 
@@ -630,13 +625,11 @@
     boolean useCompoundFile = getUseCompoundFile();
 
     if (useCompoundFile) {
-      files.add(name + "." + IndexFileNames.COMPOUND_FILE_EXTENSION);
+      files.add(IndexFileNames.segmentFileName(name, IndexFileNames.COMPOUND_FILE_EXTENSION));
     } else {
       final String[] exts = IndexFileNames.NON_STORE_INDEX_EXTENSIONS;
-      for(int i=0;i<exts.length;i++) {
-        // nocommit -- skip checking frq, prx, tii, tis if
-        // flex postings
-        addIfExists(files, name + "." + exts[i]);
+      for(String ext : IndexFileNames.NON_STORE_INDEX_EXTENSIONS) {
+        addIfExists(files, IndexFileNames.segmentFileName(name, ext));
       }
       // nocommit -- only does ifExists on prx for standard codec
       codec.files(dir, this, files);
@@ -647,21 +640,17 @@
       // vectors) with other segments
       assert docStoreSegment != null;
       if (docStoreIsCompoundFile) {
-        files.add(docStoreSegment + "." + IndexFileNames.COMPOUND_FILE_STORE_EXTENSION);
+        files.add(IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.COMPOUND_FILE_STORE_EXTENSION));
       } else {
-        final String[] exts = IndexFileNames.STORE_INDEX_EXTENSIONS;
-        for(int i=0;i<exts.length;i++)
-          addIfExists(files, docStoreSegment + "." + exts[i]);
+        for (String ext : IndexFileNames.STORE_INDEX_EXTENSIONS)
+          addIfExists(files, IndexFileNames.segmentFileName(docStoreSegment, ext));
       }
     } else if (!useCompoundFile) {
-      // We are not sharing, and, these files were not
-      // included in the compound file
-      final String[] exts = IndexFileNames.STORE_INDEX_EXTENSIONS;
-      for(int i=0;i<exts.length;i++)
-        addIfExists(files, name + "." + exts[i]);
+      for (String ext : IndexFileNames.STORE_INDEX_EXTENSIONS)
+        addIfExists(files, IndexFileNames.segmentFileName(name, ext));
     }
 
-    String delFileName = IndexFileNames.fileNameFromGeneration(name, "." + IndexFileNames.DELETES_EXTENSION, delGen);
+    String delFileName = IndexFileNames.fileNameFromGeneration(name, IndexFileNames.DELETES_EXTENSION, delGen);
     if (delFileName != null && (delGen >= YES || dir.fileExists(delFileName))) {
       files.add(delFileName);
     }
@@ -672,12 +661,12 @@
         long gen = normGen[i];
         if (gen >= YES) {
           // Definitely a separate norm file, with generation:
-          files.add(IndexFileNames.fileNameFromGeneration(name, "." + IndexFileNames.SEPARATE_NORMS_EXTENSION + i, gen));
+          files.add(IndexFileNames.fileNameFromGeneration(name, IndexFileNames.SEPARATE_NORMS_EXTENSION + i, gen));
         } else if (NO == gen) {
           // No separate norms but maybe plain norms
           // in the non compound file case:
           if (!hasSingleNormFile && !useCompoundFile) {
-            String fileName = name + "." + IndexFileNames.PLAIN_NORMS_EXTENSION + i;
+            String fileName = IndexFileNames.segmentFileName(name, IndexFileNames.PLAIN_NORMS_EXTENSION + i);
             if (dir.fileExists(fileName)) {
               files.add(fileName);
             }
@@ -686,9 +675,9 @@
           // Pre-2.1: we have to check file existence
           String fileName = null;
           if (useCompoundFile) {
-            fileName = name + "." + IndexFileNames.SEPARATE_NORMS_EXTENSION + i;
+            fileName = IndexFileNames.segmentFileName(name, IndexFileNames.SEPARATE_NORMS_EXTENSION + i);
           } else if (!hasSingleNormFile) {
-            fileName = name + "." + IndexFileNames.PLAIN_NORMS_EXTENSION + i;
+            fileName = IndexFileNames.segmentFileName(name, IndexFileNames.PLAIN_NORMS_EXTENSION + i);
           }
           if (fileName != null && dir.fileExists(fileName)) {
             files.add(fileName);
@@ -700,9 +689,9 @@
       // matching _X.sN/_X.fN files for our segment:
       String prefix;
       if (useCompoundFile) {
-        prefix = name + "." + IndexFileNames.SEPARATE_NORMS_EXTENSION;
+        prefix = IndexFileNames.segmentFileName(name, IndexFileNames.SEPARATE_NORMS_EXTENSION);
       } else {
-        prefix = name + "." + IndexFileNames.PLAIN_NORMS_EXTENSION;
+        prefix = IndexFileNames.segmentFileName(name, IndexFileNames.PLAIN_NORMS_EXTENSION);
       }
       final String pattern = prefix + "\\d+";
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentMerger.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentMerger.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentMerger.java Sun Feb 28 13:03:46 2010
@@ -174,8 +174,7 @@
     List<String> files = new ArrayList<String>();
 
     // Basic files
-    for (int i = 0; i < IndexFileNames.COMPOUND_EXTENSIONS_NOT_CODEC.length; i++) {
-      String ext = IndexFileNames.COMPOUND_EXTENSIONS_NOT_CODEC[i];
+    for (String ext : IndexFileNames.COMPOUND_EXTENSIONS_NOT_CODEC) {
        
       // nocommit
       /*
@@ -186,24 +185,25 @@
 
       if (mergeDocStores || (!ext.equals(IndexFileNames.FIELDS_EXTENSION) &&
                              !ext.equals(IndexFileNames.FIELDS_INDEX_EXTENSION)))
-        files.add(segment + "." + ext);
+        files.add(IndexFileNames.segmentFileName(segment, ext));
     }
 
     codec.files(directory, info, files);
     
     // Fieldable norm files
-    for (int i = 0; i < fieldInfos.size(); i++) {
+    int numFIs = fieldInfos.size();
+    for (int i = 0; i < numFIs; i++) {
       FieldInfo fi = fieldInfos.fieldInfo(i);
       if (fi.isIndexed && !fi.omitNorms) {
-        files.add(segment + "." + IndexFileNames.NORMS_EXTENSION);
+        files.add(IndexFileNames.segmentFileName(segment, IndexFileNames.NORMS_EXTENSION));
         break;
       }
     }
 
     // Vector files
     if (fieldInfos.hasVectors() && mergeDocStores) {
-      for (int i = 0; i < IndexFileNames.VECTOR_EXTENSIONS.length; i++) {
-        files.add(segment + "." + IndexFileNames.VECTOR_EXTENSIONS[i]);
+      for (String ext : IndexFileNames.VECTOR_EXTENSIONS) {
+        files.add(IndexFileNames.segmentFileName(segment, ext));
       }
     }
 
@@ -341,7 +341,7 @@
         fieldsWriter.close();
       }
 
-      final String fileName = segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION;
+      final String fileName = IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_INDEX_EXTENSION);
       final long fdxFileLength = directory.fileLength(fileName);
 
       if (4+((long) docCount)*8 != fdxFileLength)
@@ -472,7 +472,7 @@
       termVectorsWriter.close();
     }
 
-    final String fileName = segment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION;
+    final String fileName = IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_INDEX_EXTENSION);
     final long tvxSize = directory.fileLength(fileName);
 
     if (4+((long) mergedDocs)*16 != tvxSize)
@@ -657,7 +657,7 @@
         FieldInfo fi = fieldInfos.fieldInfo(i);
         if (fi.isIndexed && !fi.omitNorms) {
           if (output == null) { 
-            output = directory.createOutput(segment + "." + IndexFileNames.NORMS_EXTENSION);
+            output = directory.createOutput(IndexFileNames.segmentFileName(segment, IndexFileNames.NORMS_EXTENSION));
             output.writeBytes(NORMS_HEADER,NORMS_HEADER.length);
           }
           for ( IndexReader reader : readers) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentReader.java Sun Feb 28 13:03:46 2010
@@ -132,12 +132,12 @@
       try {
         Directory dir0 = dir;
         if (si.getUseCompoundFile()) {
-          cfsReader = new CompoundFileReader(dir, segment + "." + IndexFileNames.COMPOUND_FILE_EXTENSION, readBufferSize);
+          cfsReader = new CompoundFileReader(dir, IndexFileNames.segmentFileName(segment, IndexFileNames.COMPOUND_FILE_EXTENSION), readBufferSize);
           dir0 = cfsReader;
         }
         cfsDir = dir0;
 
-        fieldInfos = new FieldInfos(cfsDir, segment + "." + IndexFileNames.FIELD_INFOS_EXTENSION);
+        fieldInfos = new FieldInfos(cfsDir, IndexFileNames.segmentFileName(segment, IndexFileNames.FIELD_INFOS_EXTENSION));
 
         this.termsIndexDivisor = termsIndexDivisor;
 
@@ -224,7 +224,7 @@
           if (si.getDocStoreIsCompoundFile()) {
             assert storeCFSReader == null;
             storeCFSReader = new CompoundFileReader(dir,
-                                                    si.getDocStoreSegment() + "." + IndexFileNames.COMPOUND_FILE_STORE_EXTENSION,
+                IndexFileNames.segmentFileName(si.getDocStoreSegment(), IndexFileNames.COMPOUND_FILE_STORE_EXTENSION),
                                                     readBufferSize);
             storeDir = storeCFSReader;
             assert storeDir != null;
@@ -237,7 +237,7 @@
           // was not used, but then we are asked to open doc
           // stores after the segment has switched to CFS
           if (cfsReader == null) {
-            cfsReader = new CompoundFileReader(dir, segment + "." + IndexFileNames.COMPOUND_FILE_EXTENSION, readBufferSize);
+            cfsReader = new CompoundFileReader(dir, IndexFileNames.segmentFileName(segment, IndexFileNames.COMPOUND_FILE_EXTENSION), readBufferSize);
           }
           storeDir = cfsReader;
           assert storeDir != null;
@@ -1091,7 +1091,7 @@
         }
         
         // singleNormFile means multiple norms share this file
-        boolean singleNormFile = fileName.endsWith("." + IndexFileNames.NORMS_EXTENSION);
+        boolean singleNormFile = IndexFileNames.matchesExtension(fileName, IndexFileNames.NORMS_EXTENSION);
         IndexInput normInput = null;
         long normSeek;
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentWriteState.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentWriteState.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentWriteState.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/SegmentWriteState.java Sun Feb 28 13:03:46 2010
@@ -77,8 +77,4 @@
     this.codec = codecs.getWriter(this);
     flushedFiles = new HashSet<String>();
   }
-
-  public String segmentFileName(String ext) {
-    return segmentName + "." + ext;
-  }
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/StoredFieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/StoredFieldsWriter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/StoredFieldsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/StoredFieldsWriter.java Sun Feb 28 13:03:46 2010
@@ -66,8 +66,8 @@
         fieldsWriter = new FieldsWriter(docWriter.directory,
                                         docStoreSegment,
                                         fieldInfos);
-        docWriter.addOpenFile(docStoreSegment + "." + IndexFileNames.FIELDS_EXTENSION);
-        docWriter.addOpenFile(docStoreSegment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION);
+        docWriter.addOpenFile(IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.FIELDS_EXTENSION));
+        docWriter.addOpenFile(IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.FIELDS_INDEX_EXTENSION));
         lastDocID = 0;
       }
     }
@@ -85,16 +85,16 @@
       fieldsWriter = null;
       lastDocID = 0;
       assert state.docStoreSegmentName != null;
-      state.flushedFiles.add(state.docStoreSegmentName + "." + IndexFileNames.FIELDS_EXTENSION);
-      state.flushedFiles.add(state.docStoreSegmentName + "." + IndexFileNames.FIELDS_INDEX_EXTENSION);
+      String fieldsName = IndexFileNames.segmentFileName(state.docStoreSegmentName, IndexFileNames.FIELDS_EXTENSION);
+      String fieldsIdxName = IndexFileNames.segmentFileName(state.docStoreSegmentName, IndexFileNames.FIELDS_INDEX_EXTENSION);
+      state.flushedFiles.add(fieldsName);
+      state.flushedFiles.add(fieldsIdxName);
 
-      state.docWriter.removeOpenFile(state.docStoreSegmentName + "." + IndexFileNames.FIELDS_EXTENSION);
-      state.docWriter.removeOpenFile(state.docStoreSegmentName + "." + IndexFileNames.FIELDS_INDEX_EXTENSION);
+      state.docWriter.removeOpenFile(fieldsName);
+      state.docWriter.removeOpenFile(fieldsIdxName);
 
-      final String fileName = state.docStoreSegmentName + "." + IndexFileNames.FIELDS_INDEX_EXTENSION;
-
-      if (4+((long) state.numDocsInStore)*8 != state.directory.fileLength(fileName))
-        throw new RuntimeException("after flush: fdx size mismatch: " + state.numDocsInStore + " docs vs " + state.directory.fileLength(fileName) + " length in bytes of " + fileName + " file exists?=" + state.directory.fileExists(fileName));
+      if (4+((long) state.numDocsInStore)*8 != state.directory.fileLength(fieldsIdxName))
+        throw new RuntimeException("after flush: fdx size mismatch: " + state.numDocsInStore + " docs vs " + state.directory.fileLength(fieldsIdxName) + " length in bytes of " + fieldsIdxName + " file exists?=" + state.directory.fileExists(fieldsIdxName));
     }
   }
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsReader.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsReader.java Sun Feb 28 13:03:46 2010
@@ -75,12 +75,13 @@
     boolean success = false;
 
     try {
-      if (d.fileExists(segment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION)) {
-        tvx = d.openInput(segment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION, readBufferSize);
+      String idxName = IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_INDEX_EXTENSION);
+      if (d.fileExists(idxName)) {
+        tvx = d.openInput(idxName, readBufferSize);
         format = checkValidFormat(tvx);
-        tvd = d.openInput(segment + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION, readBufferSize);
+        tvd = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_DOCUMENTS_EXTENSION), readBufferSize);
         final int tvdFormat = checkValidFormat(tvd);
-        tvf = d.openInput(segment + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION, readBufferSize);
+        tvf = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_FIELDS_EXTENSION), readBufferSize);
         final int tvfFormat = checkValidFormat(tvf);
 
         assert format == tvdFormat;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsTermsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsTermsWriter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsTermsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsTermsWriter.java Sun Feb 28 13:03:46 2010
@@ -92,17 +92,19 @@
       tvd.close();
       tvx = null;
       assert state.docStoreSegmentName != null;
-      final String fileName = state.docStoreSegmentName + "." + IndexFileNames.VECTORS_INDEX_EXTENSION;
-      if (4+((long) state.numDocsInStore)*16 != state.directory.fileLength(fileName))
-        throw new RuntimeException("after flush: tvx size mismatch: " + state.numDocsInStore + " docs vs " + state.directory.fileLength(fileName) + " length in bytes of " + fileName + " file exists?=" + state.directory.fileExists(fileName));
-
-      state.flushedFiles.add(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
-      state.flushedFiles.add(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
-      state.flushedFiles.add(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
-
-      docWriter.removeOpenFile(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
-      docWriter.removeOpenFile(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
-      docWriter.removeOpenFile(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
+      String idxName = IndexFileNames.segmentFileName(state.docStoreSegmentName, IndexFileNames.VECTORS_INDEX_EXTENSION);
+      if (4+((long) state.numDocsInStore)*16 != state.directory.fileLength(idxName))
+        throw new RuntimeException("after flush: tvx size mismatch: " + state.numDocsInStore + " docs vs " + state.directory.fileLength(idxName) + " length in bytes of " + idxName + " file exists?=" + state.directory.fileExists(idxName));
+
+      String fldName = IndexFileNames.segmentFileName(state.docStoreSegmentName, IndexFileNames.VECTORS_FIELDS_EXTENSION);
+      String docName = IndexFileNames.segmentFileName(state.docStoreSegmentName, IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
+      state.flushedFiles.add(idxName);
+      state.flushedFiles.add(fldName);
+      state.flushedFiles.add(docName);
+
+      docWriter.removeOpenFile(idxName);
+      docWriter.removeOpenFile(fldName);
+      docWriter.removeOpenFile(docName);
 
       lastDocID = 0;
     }    
@@ -153,17 +155,20 @@
       // vector output files, we must abort this segment
       // because those files will be in an unknown
       // state:
-      tvx = docWriter.directory.createOutput(docStoreSegment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
-      tvd = docWriter.directory.createOutput(docStoreSegment +  "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
-      tvf = docWriter.directory.createOutput(docStoreSegment +  "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
+      String idxName = IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.VECTORS_INDEX_EXTENSION);
+      String docName = IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
+      String fldName = IndexFileNames.segmentFileName(docStoreSegment, IndexFileNames.VECTORS_FIELDS_EXTENSION);
+      tvx = docWriter.directory.createOutput(idxName);
+      tvd = docWriter.directory.createOutput(docName);
+      tvf = docWriter.directory.createOutput(fldName);
       
       tvx.writeInt(TermVectorsReader.FORMAT_CURRENT);
       tvd.writeInt(TermVectorsReader.FORMAT_CURRENT);
       tvf.writeInt(TermVectorsReader.FORMAT_CURRENT);
 
-      docWriter.addOpenFile(docStoreSegment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
-      docWriter.addOpenFile(docStoreSegment + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
-      docWriter.addOpenFile(docStoreSegment + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
+      docWriter.addOpenFile(idxName);
+      docWriter.addOpenFile(fldName);
+      docWriter.addOpenFile(docName);
 
       lastDocID = 0;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsWriter.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermVectorsWriter.java Sun Feb 28 13:03:46 2010
@@ -35,11 +35,11 @@
                            FieldInfos fieldInfos)
     throws IOException {
     // Open files for TermVector storage
-    tvx = directory.createOutput(segment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
+    tvx = directory.createOutput(IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_INDEX_EXTENSION));
     tvx.writeInt(TermVectorsReader.FORMAT_CURRENT);
-    tvd = directory.createOutput(segment + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
+    tvd = directory.createOutput(IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_DOCUMENTS_EXTENSION));
     tvd.writeInt(TermVectorsReader.FORMAT_CURRENT);
-    tvf = directory.createOutput(segment + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
+    tvf = directory.createOutput(IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_FIELDS_EXTENSION));
     tvf.writeInt(TermVectorsReader.FORMAT_CURRENT);
 
     this.fieldInfos = fieldInfos;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java Sun Feb 28 13:03:46 2010
@@ -149,7 +149,7 @@
         // nocommit -- not clean that I open my own CFS
         // reader here; caller should pass it in?
         if (!(dir instanceof CompoundFileReader)) {
-          dir0 = cfsReader = new CompoundFileReader(dir, si.name + "." + IndexFileNames.COMPOUND_FILE_EXTENSION, readBufferSize);
+          dir0 = cfsReader = new CompoundFileReader(dir, IndexFileNames.segmentFileName(si.name, IndexFileNames.COMPOUND_FILE_EXTENSION), readBufferSize);
         } else {
           dir0 = dir;
         }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReader.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReader.java Sun Feb 28 13:03:46 2010
@@ -22,6 +22,7 @@
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.CloseableThreadLocal;
 import org.apache.lucene.util.cache.Cache;
@@ -75,15 +76,15 @@
       segment = seg;
       fieldInfos = fis;
 
-      origEnum = new SegmentTermEnum(directory.openInput(segment + "." + PreFlexCodec.TERMS_EXTENSION,
-          readBufferSize), fieldInfos, false);
+      origEnum = new SegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment, PreFlexCodec.TERMS_EXTENSION),
+                                                         readBufferSize), fieldInfos, false);
       size = origEnum.size;
 
 
       if (indexDivisor != -1) {
         // Load terms index
         totalIndexInterval = origEnum.indexInterval * indexDivisor;
-        final SegmentTermEnum indexEnum = new SegmentTermEnum(directory.openInput(segment + "." + PreFlexCodec.TERMS_INDEX_EXTENSION,
+        final SegmentTermEnum indexEnum = new SegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment, PreFlexCodec.TERMS_INDEX_EXTENSION),
                                                                                   readBufferSize), fieldInfos, true);
 
         try {

Propchange: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:909334
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:916596,916685,916769,917019
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:829134,829881,831036,896850,909334
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916769,917019
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:829134,829881,831036,896850,909334
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916769,917019
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:829134,829881,831036,896850,909334
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916769,917019
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:829134,829881,831036,896850,909334
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:880793,896906
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916769,917019
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292,826213-833960,880727-886190,889185,889614-916543,916596,916685,916755,916769,917019

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTermVectorsReader.java Sun Feb 28 13:03:46 2010
@@ -116,7 +116,7 @@
     seg = writer.newestSegment().name;
     writer.close();
 
-    fieldInfos = new FieldInfos(dir, seg + "." + IndexFileNames.FIELD_INFOS_EXTENSION);
+    fieldInfos = new FieldInfos(dir, IndexFileNames.segmentFileName(seg, IndexFileNames.FIELD_INFOS_EXTENSION));
   }
 
   private class MyTokenStream extends TokenStream {
@@ -160,8 +160,8 @@
 
   public void test() {
     //Check to see the files were created properly in setup
-    assertTrue(dir.fileExists(seg + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION));
-    assertTrue(dir.fileExists(seg + "." + IndexFileNames.VECTORS_INDEX_EXTENSION));
+    assertTrue(dir.fileExists(IndexFileNames.segmentFileName(seg, IndexFileNames.VECTORS_DOCUMENTS_EXTENSION)));
+    assertTrue(dir.fileExists(IndexFileNames.segmentFileName(seg, IndexFileNames.VECTORS_INDEX_EXTENSION)));
   }
 
   public void testReader() throws IOException {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java?rev=917175&r1=917174&r2=917175&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java Sun Feb 28 13:03:46 2010
@@ -22,6 +22,7 @@
 import java.util.Set;
 
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
+import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.TestIndexWriterReader;
@@ -34,8 +35,8 @@
    */
   public void testBasic() throws IOException {
     Set<String> fileExtensions = new HashSet<String>();
-    fileExtensions.add("fdt");
-    fileExtensions.add("fdx");
+    fileExtensions.add(IndexFileNames.FIELDS_EXTENSION);
+    fileExtensions.add(IndexFileNames.FIELDS_INDEX_EXTENSION);
     
     Directory primaryDir = new MockRAMDirectory();
     RAMDirectory secondaryDir = new MockRAMDirectory();

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 28 13:03:46 2010
@@ -1,2 +1,2 @@
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:909334
-/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:916596,916685,916769,917019
+/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:916596,916685,916755,916769,917019



Mime
View raw message