Commits

Jan Lahoda committed e057033

Using a guaranteed unique field names for the duplicates index.

Comments (0)

Files changed (2)

duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/ComputeDuplicates.java

 
         MultiReader r = new MultiReader(readers2Roots.keySet().toArray(new IndexReader[0]));
 
-        List<String> dd = new ArrayList<String>(getDuplicatedValues(r, "generalized", cancel));
+        List<String> dd = new ArrayList<String>(getDuplicatedValues(r, "duplicatesGeneralized", cancel));
 
         sortHashes(dd);
 
             String longest = duplicateCandidates.next();
             List<Span> foundDuplicates = new LinkedList<Span>();
 
-            Query query = new TermQuery(new Term("generalized", longest));
+            Query query = new TermQuery(new Term("duplicatesGeneralized", longest));
 
             for (Entry<IndexReader, FileObject> e : readers2Roots.entrySet()) {
                 Searcher s = new IndexSearcher(e.getKey());
 
                 for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
                     final Document doc = e.getKey().document(docNum);
-                    int pos = Arrays.binarySearch(doc.getValues("generalized"), longest);
+                    int pos = Arrays.binarySearch(doc.getValues("duplicatesGeneralized"), longest);
 
                     if (pos < 0) {
-                        System.err.println("FOOBAR=" + pos);
                         continue;
                     }
                     
-                    String spanSpec = doc.getValues("positions")[pos];
-                    String relPath = doc.getField("path").stringValue();
+                    String spanSpec = doc.getValues("duplicatesPositions")[pos];
+                    String relPath = doc.getField("duplicatesPath").stringValue();
 
                     for (String spanPart : spanSpec.split(";")) {
                         Span span = Span.of(e.getValue().getFileObject(relPath), spanPart);

duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DuplicatesIndex.java

 import org.netbeans.api.java.source.CompilationInfo;
 import org.netbeans.modules.jackpot30.common.api.IndexAccess;
 import org.netbeans.modules.jackpot30.impl.duplicates.ComputeDuplicates;
-import org.netbeans.modules.java.source.JavaSourceAccessor;
 import org.netbeans.modules.parsing.spi.indexing.Indexable;
 import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
 import org.openide.util.Lookup;
 
 /**
         try {
             final Document doc = new Document();
 
-            doc.add(new Field("path", relative, Field.Store.YES, Field.Index.NOT_ANALYZED));
+            doc.add(new Field("duplicatesPath", relative, Field.Store.YES, Field.Index.NOT_ANALYZED));
 
             final Map<String, long[]> positions = ComputeDuplicates.encodeGeneralized(trees, cut);
 
             for (Entry<String, long[]> e : positions.entrySet()) {
-                doc.add(new Field("generalized", e.getKey(), Store.YES, Index.NOT_ANALYZED));
+                doc.add(new Field("duplicatesGeneralized", e.getKey(), Store.YES, Index.NOT_ANALYZED));
 
                 StringBuilder positionsSpec = new StringBuilder();
 
                     positionsSpec.append(e.getValue()[i]).append(':').append(e.getValue()[i + 1] - e.getValue()[i]);
                 }
 
-                doc.add(new Field("positions", positionsSpec.toString(), Store.YES, Index.NO));
+                doc.add(new Field("duplicatesPositions", positionsSpec.toString(), Store.YES, Index.NO));
             }
 
             luceneWriter.addDocument(doc);
     }
 
     public void remove(String relativePath) throws IOException {
-        luceneWriter.deleteDocuments(new Term("path", relativePath));
+        luceneWriter.deleteDocuments(new Term("duplicatesPath", relativePath));
     }
 
     public void close() throws IOException {