lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r640741 - in /lucene/java/trunk/src: java/org/apache/lucene/analysis/Token.java java/org/apache/lucene/document/Document.java test/org/apache/lucene/AnalysisTest.java
Date Tue, 25 Mar 2008 08:35:54 GMT
Author: mikemccand
Date: Tue Mar 25 01:35:51 2008
New Revision: 640741

URL: http://svn.apache.org/viewvc?rev=640741&view=rev
Log:
LUCENE-1244: don't use hard-coded path in AnalysisTest

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/analysis/Token.java
    lucene/java/trunk/src/java/org/apache/lucene/document/Document.java
    lucene/java/trunk/src/test/org/apache/lucene/AnalysisTest.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/Token.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/Token.java?rev=640741&r1=640740&r2=640741&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/Token.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/Token.java Tue Mar 25 01:35:51 2008
@@ -18,7 +18,7 @@
  */
 
 import org.apache.lucene.index.Payload;
-import org.apache.lucene.index.TermPositions;
+import org.apache.lucene.index.TermPositions;     // for javadoc
 
 /** A Token is an occurence of a term from the text of a field.  It consists of
   a term's text, the start and end offset of the term in the text of the field,
@@ -226,8 +226,12 @@
 
   /** Returns the Token's term text.
    * 
-   * @deprecated Use {@link #termBuffer()} and {@link
-   * #termLength()} instead. */
+   * @deprecated This method now has a performance penalty
+   * because the text is stored internally in a char[].  If
+   * possible, use {@link #termBuffer()} and {@link
+   * #termLength()} directly instead.  If you really need a
+   * String, use <b>new String(token.termBuffer(), 0, token.termLength())</b>
+   */
   public final String termText() {
     if (termText == null && termBuffer != null)
       termText = new String(termBuffer, 0, termLength);

Modified: lucene/java/trunk/src/java/org/apache/lucene/document/Document.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/document/Document.java?rev=640741&r1=640740&r2=640741&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/document/Document.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/document/Document.java Tue Mar 25 01:35:51
2008
@@ -18,6 +18,9 @@
  */
 
 import java.util.*;             // for javadoc
+import org.apache.lucene.search.Hits; // for javadoc
+import org.apache.lucene.search.Searcher; // for javadoc
+import org.apache.lucene.index.IndexReader; // for javadoc
 
 /** Documents are the unit of indexing and search.
  *

Modified: lucene/java/trunk/src/test/org/apache/lucene/AnalysisTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/AnalysisTest.java?rev=640741&r1=640740&r2=640741&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/AnalysisTest.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/AnalysisTest.java Tue Mar 25 01:35:51 2008
@@ -31,15 +31,17 @@
 import java.util.Date;
 
 class AnalysisTest {
+  static File tmpFile;
   public static void main(String[] args) {
     try {
       test("This is a test", true);
-      // FIXME: OG: what's with this hard-coded file name??
-      test(new File("words.txt"), false);
+      tmpFile = File.createTempFile("words", ".txt");
+      test(tmpFile, false);
     } catch (Exception e) {
       System.out.println(" caught a " + e.getClass() +
 			 "\n with message: " + e.getMessage());
     }
+    tmpFile.deleteOnExit();
   }
 
   static void test(File file, boolean verbose)
@@ -70,7 +72,7 @@
     int count = 0;
     for (Token t = stream.next(); t!=null; t = stream.next()) {
       if (verbose) {
-	System.out.println("Text=" + t.termText()
+	System.out.println("Text=" + new String(t.termBuffer(), 0, t.termLength())
 			   + " start=" + t.startOffset()
 			   + " end=" + t.endOffset());
       }



Mime
View raw message