lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "julien" <j.ger...@noos.fr>
Subject RE : RE : Test issue with new version of .tis file
Date Wed, 21 Jan 2004 20:32:32 GMT
I didn't have an account to bug database, here is the code :


##################################

import java.io.File;
import java.io.IOException;
import java.util.Random;

import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;

/**
 * TestIndexTiiIssue.java description :
 * This class generate a :
 * java.io.IOException: read past EOF
	at
org.apache.lucene.store.InputStream.refill(InputStream.java(Compiled
Code))
	at
org.apache.lucene.index.SegmentTermEnum.next(SegmentTermEnum.java(Compil
ed Code))
	at
org.apache.lucene.index.SegmentTermEnum.next(SegmentTermEnum.java(Compil
ed Code))
	at
org.apache.lucene.index.SegmentTermEnum.next(SegmentTermEnum.java(Compil
ed Code))
	at
org.apache.lucene.index.SegmentTermEnum.next(SegmentTermEnum.java(Compil
ed Code))
	at
org.apache.lucene.index.SegmentMerger.mergeTermInfos(SegmentMerger.java(
Compiled Code))
	at
org.apache.lucene.index.SegmentMerger.mergeTermInfos(SegmentMerger.java(
Compiled Code))
	at
org.apache.lucene.index.SegmentMerger.mergeTerms(SegmentMerger.java:192)
	at
org.apache.lucene.index.SegmentMerger.merge(SegmentMerger.java:99)
	at
org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:430)
	at
org.apache.lucene.index.IndexWriter.flushRamSegments(IndexWriter.java:38
3)
	at
org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:303)
	at TestIndexTiiIssue.main(TestIndexTiiIssue.java(Compiled Code))
 *
 * at every execution with latest classes on CVS Lucene repository (
19/01/2004 ).
 *
 *
 * @author Julien GERARD
 * @version 1.0, 21 janv. 04
 */
public class TestIndexTiiIssue {
	private static char[] char_table = { 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L'
		, 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z'};

	private static final Random RANDOM = new Random();

	/**
	 * Random method
	 * @param i the max range value
	 * @return the random number generated
	 */
	private static int random(int i) {		  // for JDK 1.1
compatibility
    	int r = RANDOM.nextInt();
		if (r < 0)
			r = -r;
		return r % i;
	}


	/**
	 * No args needed
	 */
	public static void main(String[] args) {
		int nb_doc = 1000;

		try {
			IndexWriter iw = new IndexWriter(new
File("/index/"), new WhitespaceAnalyzer(), true);
			for (int i = 0 ; i < nb_doc ; i++) { // Doc loop

			//		iw.optimize();

				int nb_words = random(4)+1;
				StringBuffer word_list = new
StringBuffer(50);
				for ( int j = 0 ; j < nb_words ; j++ ) {
// Word loop
					int nb_letters = random(12)+1;
					StringBuffer word = new
StringBuffer(13);
					for ( int k = 0; k < nb_letters
; k++ ) { // Letters loop
	
word.append(char_table[random(char_table.length-1)]); // word
construction
					}
					word_list.append(word).append('
'); // word_list construction
				}

				Document doc = new Document();
				doc.add(Field.Text("TOKEN",
word_list.toString()));

				StringBuffer word = new
StringBuffer(13);
				int nb_letters = random(12)+1;
				for ( int k = 0; k < nb_letters ; k++ )
{ // Letters loop
	
word.append(char_table[random(char_table.length-1)]); // word
construction
				}
	
doc.add(Field.Keyword("FIELD_DISCRIMINATOR", word.toString()));


				StringBuffer word2 = new
StringBuffer(13);
				nb_letters = random(12)+1;
				for ( int k = 0; k < nb_letters ; k++ )
{ // Letters loop
	
word2.append(char_table[random(char_table.length-1)]); // word
construction
				}
	
doc.add(Field.Keyword("FIELD_DISCRIMINATOR2", word2.toString()));
				iw.addDocument(doc);

			}
			iw.optimize();
		} catch (IOException ioe ) {
			ioe.printStackTrace();
		}



	}
}

##################################################


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message