FileDocCategorySizeDatePackage
PerfRunData.javaAPI DocApache Lucene 2.2.06855Sat Jun 16 22:21:00 BST 2007org.apache.lucene.benchmark.byTask

PerfRunData

public class PerfRunData extends Object
Data maintained by a performance test run.

Data includes:

  • Configuration.
  • Directory, Writer, Reader.
  • Docmaker and a few instances of QueryMaker.
  • Analyzer.
  • Statistics data which updated during the run.

Fields Summary
private org.apache.lucene.benchmark.byTask.stats.Points
points
private Directory
directory
private Analyzer
analyzer
private org.apache.lucene.benchmark.byTask.feeds.DocMaker
docMaker
private org.apache.lucene.benchmark.byTask.feeds.HTMLParser
htmlParser
private HashMap
readTaskQueryMaker
private Class
qmkrClass
private IndexReader
indexReader
private IndexWriter
indexWriter
private org.apache.lucene.benchmark.byTask.utils.Config
config
Constructors Summary
public PerfRunData(org.apache.lucene.benchmark.byTask.utils.Config config)

    this.config = config;
    // analyzer (default is standard analyzer)
    analyzer = (Analyzer) Class.forName(config.get("analyzer",
        "org.apache.lucene.analysis.standard.StandardAnalyzer")).newInstance();
    // doc maker
    docMaker = (DocMaker) Class.forName(config.get("doc.maker",
        "org.apache.lucene.benchmark.byTask.feeds.SimpleDocMaker")).newInstance();
    docMaker.setConfig(config);
    // query makers
    readTaskQueryMaker = new HashMap();
    qmkrClass = Class.forName(config.get("query.maker","org.apache.lucene.benchmark.byTask.feeds.SimpleQueryMaker"));
    // html parser, used for some doc makers
    htmlParser = (HTMLParser) Class.forName(config.get("html.parser","org.apache.lucene.benchmark.byTask.feeds.DemoHTMLParser")).newInstance();
    docMaker.setHTMLParser(htmlParser);

    // index stuff
    reinit(false);
    
    // statistic points
    points = new Points(config);
    
    if (Boolean.valueOf(config.get("log.queries","false")).booleanValue()) {
      System.out.println("------------> queries:");
      System.out.println(getQueryMaker(new SearchTask(this)).printQueries());
    }

  
Methods Summary
public org.apache.lucene.analysis.AnalyzergetAnalyzer()

return
Returns the anlyzer.

    return analyzer;
  
public org.apache.lucene.benchmark.byTask.utils.ConfiggetConfig()

return
Returns the config.

    return config;
  
public org.apache.lucene.store.DirectorygetDirectory()

return
Returns the directory.

    return directory;
  
public org.apache.lucene.benchmark.byTask.feeds.DocMakergetDocMaker()

return
Returns the docMaker.

    return docMaker;
  
public org.apache.lucene.benchmark.byTask.feeds.HTMLParsergetHtmlParser()

return
Returns the htmlParser.

    return htmlParser;
  
public org.apache.lucene.index.IndexReadergetIndexReader()

return
Returns the indexReader.

    return indexReader;
  
public org.apache.lucene.index.IndexWritergetIndexWriter()

return
Returns the indexWriter.

    return indexWriter;
  
public org.apache.lucene.benchmark.byTask.stats.PointsgetPoints()

return
Returns the points.

    return points;
  
public org.apache.lucene.benchmark.byTask.feeds.QueryMakergetQueryMaker(org.apache.lucene.benchmark.byTask.tasks.ReadTask readTask)

return
Returns the queryMaker by read task type (class)

    // mapping the query maker by task class allows extending/adding new search/read tasks
    // without needing to modify this class.
    Class readTaskClass = readTask.getClass();
    QueryMaker qm = (QueryMaker) readTaskQueryMaker.get(readTaskClass);
    if (qm == null) {
      try {
        qm = (QueryMaker) qmkrClass.newInstance();
        qm.setConfig(config);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
      readTaskQueryMaker.put(readTaskClass,qm);
    }
    return qm;
  
public voidreinit(boolean eraseIndex)


    // cleanup index
    if (indexWriter!=null) {
      indexWriter.close();
      indexWriter = null;
    }
    if (indexReader!=null) {
      indexReader.close();
      indexReader = null;
    }
    if (directory!=null) {
      directory.close();
    }
    
    // directory (default is ram-dir).
    if ("FSDirectory".equals(config.get("directory","RAMDirectory"))) {
      File workDir = new File("work");
      File indexDir = new File(workDir,"index");
      if (eraseIndex && indexDir.exists()) {
        FileUtils.fullyDelete(indexDir);
      }
      indexDir.mkdirs();
      directory = FSDirectory.getDirectory(indexDir);
    } else {
      directory = new RAMDirectory();
    }

    // inputs
    resetInputs();
    
    // release unused stuff
    System.runFinalization();
    System.gc();
  
public voidresetInputs()

    docMaker.resetInputs();
    Iterator it = readTaskQueryMaker.values().iterator();
    while (it.hasNext()) {
      ((QueryMaker) it.next()).resetInputs();
    }
  
public voidsetDirectory(org.apache.lucene.store.Directory directory)

param
directory The directory to set.

    this.directory = directory;
  
public voidsetIndexReader(org.apache.lucene.index.IndexReader indexReader)

param
indexReader The indexReader to set.

    this.indexReader = indexReader;
  
public voidsetIndexWriter(org.apache.lucene.index.IndexWriter indexWriter)

param
indexWriter The indexWriter to set.

    this.indexWriter = indexWriter;