You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/01/03 18:44:12 UTC
svn commit: r1226894 - in /lucene/dev/branches/branch_3x: ./ lucene/
lucene/backwards/src/test-framework/java/org/apache/lucene/util/
lucene/contrib/ lucene/contrib/benchmark/
lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/
...
Author: mikemccand
Date: Tue Jan 3 17:44:11 2012
New Revision: 1226894
URL: http://svn.apache.org/viewvc?rev=1226894&view=rev
Log:
LUCENE-3634: remove some old static main methods and other dead code
Added:
lucene/dev/branches/branch_3x/lucene/backwards/src/test-framework/java/org/apache/lucene/util/English.java
- copied unchanged from r1226871, lucene/dev/trunk/lucene/src/test-framework/java/org/apache/lucene/util/English.java
lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java
- copied, changed from r1226871, lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java
lucene/dev/branches/branch_3x/lucene/src/test-framework/java/org/apache/lucene/util/English.java
- copied unchanged from r1226871, lucene/dev/trunk/lucene/src/test-framework/java/org/apache/lucene/util/English.java
Removed:
lucene/dev/branches/branch_3x/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/DistanceCheck.java
lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/util/English.java
Modified:
lucene/dev/branches/branch_3x/ (props changed)
lucene/dev/branches/branch_3x/lucene/ (props changed)
lucene/dev/branches/branch_3x/lucene/CHANGES.txt
lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt
lucene/dev/branches/branch_3x/lucene/contrib/benchmark/build.xml
lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishContentSource.java
lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishQueryMaker.java
lucene/dev/branches/branch_3x/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java
lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexReader.java
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearch.java
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestDoc.java
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSortedVIntList.java
Modified: lucene/dev/branches/branch_3x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/CHANGES.txt?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/lucene/CHANGES.txt Tue Jan 3 17:44:11 2012
@@ -71,6 +71,10 @@ New Features
* LUCENE-3586: CheckIndex and IndexUpgrader allow you to specify the
specific FSDirectory implementation to use (with the new -dir-impl
command-line option). (Luca Cavanna via Mike McCandless)
+
+* LUCENE-3634: IndexReader's static main method was moved to a new
+ tool, CompoundFileExtractor, in contrib/misc. (Robert Muir, Mike
+ McCandless)
Bug fixes
Modified: lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt Tue Jan 3 17:44:11 2012
@@ -25,6 +25,9 @@ New Features
bigrams are formed for each of Han/Hiragana/Katakana/Hangul independently. Deprecates
CJKTokenizer. (Tom Burton-West, Robert Muir)
+* LUCENE-3634: IndexReader's static main method was moved to a new
+ tool, CompoundFileExtractor, in contrib/misc. (Mike McCandless)
+
API Changes
* LUCENE-3596: DirectoryTaxonomyWriter.openIndexWriter() now takes an
Modified: lucene/dev/branches/branch_3x/lucene/contrib/benchmark/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/benchmark/build.xml?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/benchmark/build.xml (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/benchmark/build.xml Tue Jan 3 17:44:11 2012
@@ -131,6 +131,7 @@
<pathelement path="${highlighter.jar}"/>
<pathelement path="${analyzers-common.jar}"/>
<pathelement path="${facet.jar}"/>
+ <fileset dir="${common.dir}/contrib/icu/lib" includes="icu4j*.jar"/>
<path refid="base.classpath"/>
<fileset dir="lib">
<include name="**/*.jar"/>
Modified: lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishContentSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishContentSource.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishContentSource.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishContentSource.java Tue Jan 3 17:44:11 2012
@@ -17,10 +17,11 @@ package org.apache.lucene.benchmark.byTa
* limitations under the License.
*/
-import org.apache.lucene.util.English;
-
import java.io.IOException;
import java.util.Date;
+import java.util.Locale;
+
+import com.ibm.icu.text.RuleBasedNumberFormat;
/**
* Creates documents whose content is a <code>long</code> number starting from
@@ -32,7 +33,10 @@ public class LongToEnglishContentSource
@Override
public void close() throws IOException {
}
-
+
+ // TODO: we could take param to specify locale...
+ private final RuleBasedNumberFormat rnbf = new RuleBasedNumberFormat(Locale.ENGLISH,
+ RuleBasedNumberFormat.SPELLOUT);
@Override
public synchronized DocData getNextDocData(DocData docData) throws NoMoreDataException, IOException {
docData.clear();
@@ -46,7 +50,8 @@ public class LongToEnglishContentSource
++counter;
}
}
- docData.setBody(English.longToEnglish(curCounter));
+
+ docData.setBody(rnbf.format(curCounter));
docData.setName("doc_" + String.valueOf(curCounter));
docData.setTitle("title_" + String.valueOf(curCounter));
docData.setDate(new Date());
Modified: lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishQueryMaker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishQueryMaker.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishQueryMaker.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LongToEnglishQueryMaker.java Tue Jan 3 17:44:11 2012
@@ -17,26 +17,31 @@ package org.apache.lucene.benchmark.byTa
* limitations under the License.
*/
+import java.util.Locale;
+
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
import org.apache.lucene.benchmark.byTask.utils.Config;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
-import org.apache.lucene.util.English;
import org.apache.lucene.util.Version;
+import com.ibm.icu.text.RuleBasedNumberFormat;
public class LongToEnglishQueryMaker implements QueryMaker {
long counter = Long.MIN_VALUE + 10;
protected QueryParser parser;
+ // TODO: we could take param to specify locale...
+ private final RuleBasedNumberFormat rnbf = new RuleBasedNumberFormat(Locale.ENGLISH,
+ RuleBasedNumberFormat.SPELLOUT);
+
public Query makeQuery(int size) throws Exception {
throw new UnsupportedOperationException();
}
public synchronized Query makeQuery() throws Exception {
-
- return parser.parse("" + English.longToEnglish(getNextCounter()) + "");
+ return parser.parse("" + rnbf.format(getNextCounter()) + "");
}
private synchronized long getNextCounter() {
Copied: lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java (from r1226871, lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java?p2=lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java&p1=lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java&r1=1226871&r2=1226894&rev=1226894&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/CompoundFileExtractor.java Tue Jan 3 17:44:11 2012
@@ -1,3 +1,5 @@
+package org.apache.lucene.index;
+
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.lucene.index;
-
/**
* Prints the filename and size of each file within a given compound file.
* Add the -extract flag to extract files to the current working directory.
@@ -29,10 +29,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import org.apache.lucene.store.CompoundFileDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
-import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.CommandLineUtil;
@@ -68,8 +66,7 @@ public class CompoundFileExtractor {
}
Directory dir = null;
- CompoundFileDirectory cfr = null;
- IOContext context = IOContext.READ;
+ CompoundFileReader cfr = null;
try {
File file = new File(filename);
@@ -81,7 +78,7 @@ public class CompoundFileExtractor {
dir = CommandLineUtil.newFSDirectory(dirImpl, new File(dirname));
}
- cfr = new CompoundFileDirectory(dir, filename, IOContext.DEFAULT, false);
+ cfr = new CompoundFileReader(dir, filename);
String [] files = cfr.listAll();
ArrayUtil.mergeSort(files); // sort the array of filename so that the output is more readable
@@ -91,7 +88,7 @@ public class CompoundFileExtractor {
if (extract) {
System.out.println("extract " + files[i] + " with " + len + " bytes to local directory...");
- IndexInput ii = cfr.openInput(files[i], context);
+ IndexInput ii = cfr.openInput(files[i]);
FileOutputStream f = new FileOutputStream(files[i]);
Modified: lucene/dev/branches/branch_3x/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java Tue Jan 3 17:44:11 2012
@@ -19,7 +19,6 @@ package org.apache.lucene.spatial.tier;
import org.apache.lucene.spatial.DistanceUtils;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -97,10 +96,4 @@ public class DistanceHandler {
//all else fails calculate the distances
return DistanceUtils.getDistanceMi(centerLat, centerLng, lat, lng);
}
-
-
- public static void main(String args[]){
- DistanceHandler db = new DistanceHandler(new HashMap<Integer,Double>(), new HashMap<String,Double>(), Precision.TWOHUNDREDFEET);
- System.out.println(DistanceHandler.getPrecision(-1234.123456789, db.getPrecision()));
- }
}
Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexReader.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/index/IndexReader.java Tue Jan 3 17:44:11 2012
@@ -18,13 +18,10 @@ package org.apache.lucene.index;
*/
import java.io.Closeable;
-import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -34,9 +31,6 @@ import org.apache.lucene.document.FieldS
import org.apache.lucene.search.SearcherManager; // javadocs
import org.apache.lucene.search.Similarity;
import org.apache.lucene.store.*;
-import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.MapBackedSet;
-import org.apache.lucene.util.CommandLineUtil;
import org.apache.lucene.util.VirtualMethod;
/** IndexReader is an abstract class, providing an interface for accessing an
@@ -1600,100 +1594,6 @@ public abstract class IndexReader implem
throw new UnsupportedOperationException("This reader does not support this method.");
}
- /**
- * Prints the filename and size of each file within a given compound file.
- * Add the -extract flag to extract files to the current working directory.
- * In order to make the extracted version of the index work, you have to copy
- * the segments file from the compound index into the directory where the extracted files are stored.
- * @param args Usage: org.apache.lucene.index.IndexReader [-extract] <cfsfile>
- */
- public static void main(String [] args) {
- String filename = null;
- boolean extract = false;
- String dirImpl = null;
-
- int j = 0;
- while(j < args.length) {
- String arg = args[j];
- if ("-extract".equals(arg)) {
- extract = true;
- } else if ("-dir-impl".equals(arg)) {
- if (j == args.length - 1) {
- System.out.println("ERROR: missing value for -dir-impl option");
- System.exit(1);
- }
- j++;
- dirImpl = args[j];
- } else if (filename == null) {
- filename = arg;
- }
- j++;
- }
-
- if (filename == null) {
- System.out.println("Usage: org.apache.lucene.index.IndexReader [-extract] [-dir-impl X] <cfsfile>");
- return;
- }
-
- Directory dir = null;
- CompoundFileReader cfr = null;
-
- try {
- File file = new File(filename);
- String dirname = file.getAbsoluteFile().getParent();
- filename = file.getName();
- if (dirImpl == null) {
- dir = FSDirectory.open(new File(dirname));
- } else {
- dir = CommandLineUtil.newFSDirectory(dirImpl, new File(dirname));
- }
-
- cfr = new CompoundFileReader(dir, filename);
-
- String [] files = cfr.listAll();
- ArrayUtil.mergeSort(files); // sort the array of filename so that the output is more readable
-
- for (int i = 0; i < files.length; ++i) {
- long len = cfr.fileLength(files[i]);
-
- if (extract) {
- System.out.println("extract " + files[i] + " with " + len + " bytes to local directory...");
- IndexInput ii = cfr.openInput(files[i]);
-
- FileOutputStream f = new FileOutputStream(files[i]);
-
- // read and write with a small buffer, which is more effective than reading byte by byte
- byte[] buffer = new byte[1024];
- int chunk = buffer.length;
- while(len > 0) {
- final int bufLen = (int) Math.min(chunk, len);
- ii.readBytes(buffer, 0, bufLen);
- f.write(buffer, 0, bufLen);
- len -= bufLen;
- }
-
- f.close();
- ii.close();
- }
- else
- System.out.println(files[i] + ": " + len + " bytes");
- }
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- finally {
- try {
- if (dir != null)
- dir.close();
- if (cfr != null)
- cfr.close();
- }
- catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
- }
-
/** Returns all commit points that exist in the Directory.
* Normally, because the default is {@link
* KeepOnlyLastCommitDeletionPolicy}, there would be only
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearch.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearch.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearch.java Tue Jan 3 17:44:11 2012
@@ -23,8 +23,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.lucene.util.LuceneTestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.apache.lucene.store.*;
import org.apache.lucene.document.*;
@@ -36,11 +34,6 @@ import org.apache.lucene.queryParser.*;
/** JUnit adaptation of an older test case SearchTest. */
public class TestSearch extends LuceneTestCase {
- /** Main for running test case by itself. */
- public static void main(String args[]) {
- TestRunner.run (new TestSuite(TestSearch.class));
- }
-
/** This test performs a number of searches. It also compares output
* of searches using multi-file index segments with single-file
* index segments.
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java Tue Jan 3 17:44:11 2012
@@ -29,18 +29,9 @@ import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
import org.apache.lucene.queryParser.*;
import org.apache.lucene.util.LuceneTestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
public class TestSearchForDuplicates extends LuceneTestCase {
- /** Main for running test case by itself. */
- public static void main(String args[]) {
- TestRunner.run (new TestSuite(TestSearchForDuplicates.class));
- }
-
-
-
static final String PRIORITY_FIELD ="priority";
static final String ID_FIELD ="id";
static final String HIGH_PRIORITY ="high";
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestDoc.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestDoc.java Tue Jan 3 17:44:11 2012
@@ -26,8 +26,6 @@ import java.io.StringWriter;
import java.util.LinkedList;
import java.util.Collection;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
@@ -40,11 +38,6 @@ import org.apache.lucene.util._TestUtil;
/** JUnit adaptation of an older test case DocTest. */
public class TestDoc extends LuceneTestCase {
- /** Main for running test case by itself. */
- public static void main(String args[]) {
- TestRunner.run (new TestSuite(TestDoc.class));
- }
-
private File workDir;
private File indexDir;
private LinkedList<File> files;
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSortedVIntList.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSortedVIntList.java?rev=1226894&r1=1226893&r2=1226894&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSortedVIntList.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSortedVIntList.java Tue Jan 3 17:44:11 2012
@@ -20,16 +20,10 @@ package org.apache.lucene.util;
import java.io.IOException;
import java.util.BitSet;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.apache.lucene.search.DocIdSetIterator;
public class TestSortedVIntList extends LuceneTestCase {
- /** Main for running test case by itself. */
- public static void main(String args[]) {
- TestRunner.run(new TestSuite(TestSortedVIntList.class));
- }
void tstIterator (
SortedVIntList vintList,