FileDocCategorySizeDatePackage
AddDocTask.javaAPI DocApache Lucene 2.1.02612Wed Feb 14 10:46:14 GMT 2007org.apache.lucene.benchmark.byTask.tasks

AddDocTask

public class AddDocTask extends PerfTask
Add a document, optionally with of a cetrain size. Other side effects: none.

Fields Summary
private static int
logStep
private int
docSize
private Document
doc
Constructors Summary
public AddDocTask(org.apache.lucene.benchmark.byTask.PerfRunData runData)

    super(runData);
  
Methods Summary
public intdoLogic()

    getRunData().getIndexWriter().addDocument(doc);
    return 1;
  
private voidlog(int count)

    if (logStep<0) {
      // avoid sync although race possible here
      logStep = getRunData().getConfig().get("doc.add.log.step",500);
    }
    if (logStep>0 && (count%logStep)==0) {
      System.out.println("--> processed "+count+" docs");
    }
  
public voidsetParams(java.lang.String params)
Set the params (docSize only)

param
params docSize, or 0 for no limit.

    super.setParams(params);
    docSize = (int) Float.parseFloat(params); 
  
public voidsetup()

  
  /*
   *  (non-Javadoc)
   * @see PerfTask#setup()
   */
       
    super.setup();
    DocMaker docMaker = getRunData().getDocMaker();
    if (docSize > 0) {
      doc = docMaker.makeDocument(docSize);
    } else {
      doc = docMaker.makeDocument();
    }
  
public voidtearDown()

    DocMaker docMaker = getRunData().getDocMaker();
    log(docMaker.getCount());
    doc = null;
    super.tearDown();