lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1202161 - in /lucene/dev/branches/lucene2621/lucene/src: java/org/apache/lucene/index/codecs/DefaultTermVectorsReader.java test/org/apache/lucene/index/TestIndexWriter.java test/org/apache/lucene/index/TestTermVectorsReader.java
Date Tue, 15 Nov 2011 12:45:38 GMT
Author: rmuir
Date: Tue Nov 15 12:45:38 2011
New Revision: 1202161

URL: http://svn.apache.org/viewvc?rev=1202161&view=rev
Log:
LUCENE-2621: make default TV impls files pkg-private

Modified:
    lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/DefaultTermVectorsReader.java
    lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java

Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/DefaultTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/DefaultTermVectorsReader.java?rev=1202161&r1=1202160&r2=1202161&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/DefaultTermVectorsReader.java
(original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/DefaultTermVectorsReader.java
Tue Nov 15 12:45:38 2011
@@ -68,16 +68,13 @@ public class DefaultTermVectorsReader ex
   static final byte STORE_OFFSET_WITH_TERMVECTOR = 0x2;
   
   /** Extension of vectors fields file */
-  // TODO: make pkg-private after we remove/refactor fileExists check in SI or drop 3.x support
-  public static final String VECTORS_FIELDS_EXTENSION = "tvf";
+  static final String VECTORS_FIELDS_EXTENSION = "tvf";
 
   /** Extension of vectors documents file */
-  // TODO: make pkg-private after we remove/refactor fileExists check in SI or drop 3.x support
-  public static final String VECTORS_DOCUMENTS_EXTENSION = "tvd";
+  static final String VECTORS_DOCUMENTS_EXTENSION = "tvd";
 
   /** Extension of vectors index file */
-  // TODO: make pkg-private after we remove/refactor fileExists check in SI or drop 3.x support
-  public static final String VECTORS_INDEX_EXTENSION = "tvx";
+  static final String VECTORS_INDEX_EXTENSION = "tvx";
 
   private FieldInfos fieldInfos;
 

Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1202161&r1=1202160&r2=1202161&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
(original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
Tue Nov 15 12:45:38 2011
@@ -25,10 +25,12 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
+import java.util.Set;
 
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -1742,14 +1744,16 @@ public class TestIndexWriter extends Luc
     _TestUtil.checkIndex(dir);
 
     assertNoUnreferencedFiles(dir, "no tv files");
-    String[] files = dir.listAll();
-    // TODO: this check should use codec's files()
-    for(String file : files) {
-      assertTrue(!file.endsWith(DefaultTermVectorsReader.VECTORS_FIELDS_EXTENSION));
-      assertTrue(!file.endsWith(DefaultTermVectorsReader.VECTORS_INDEX_EXTENSION));
-      assertTrue(!file.endsWith(DefaultTermVectorsReader.VECTORS_DOCUMENTS_EXTENSION));
+    IndexReader r0 = IndexReader.open(dir);
+    for (IndexReader r : r0.getSequentialSubReaders()) {
+      SegmentInfo s = ((SegmentReader) r).getSegmentInfo();
+      assertFalse(s.getHasVectors());
+      Set<String> files = new HashSet<String>();
+      s.getCodec().termVectorsFormat().files(dir, s, files);
+      assertTrue(files.isEmpty());
     }
-
+    
+    r0.close();
     dir.close();
   }
 

Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=1202161&r1=1202160&r2=1202161&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
(original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
Tue Nov 15 12:45:38 2011
@@ -20,6 +20,8 @@ package org.apache.lucene.index;
 import java.io.IOException;
 import java.io.Reader;
 import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
@@ -180,10 +182,18 @@ public class TestTermVectorsReader exten
 
   public void test() throws IOException {
     //Check to see the files were created properly in setup
-    // TODO: fix this or at least add 'or' simpletext's extension
-    assumeFalse("test makes assumptions about filenames", Codec.getDefault().getName().equals("SimpleText"));
-    assertTrue(dir.fileExists(IndexFileNames.segmentFileName(seg.name, "", DefaultTermVectorsReader.VECTORS_DOCUMENTS_EXTENSION)));
-    assertTrue(dir.fileExists(IndexFileNames.segmentFileName(seg.name, "", DefaultTermVectorsReader.VECTORS_INDEX_EXTENSION)));
+    IndexReader reader = IndexReader.open(dir);
+    for (IndexReader r : reader.getSequentialSubReaders()) {
+      SegmentInfo s = ((SegmentReader) r).getSegmentInfo();
+      assertTrue(s.getHasVectors());
+      Set<String> files = new HashSet<String>();
+      s.getCodec().termVectorsFormat().files(dir, s, files);
+      assertFalse(files.isEmpty());
+      for (String file : files) {
+        assertTrue(dir.fileExists(file));
+      }
+    }
+    reader.close();
   }
 
   public void testReader() throws IOException {



Mime
View raw message