FileDocCategorySizeDatePackage
AddDocTask.javaAPI DocApache Lucene 2.2.03029Sat Jun 16 22:20:58 BST 2007org.apache.lucene.benchmark.byTask.tasks

AddDocTask

public class AddDocTask extends PerfTask
Add a document, optionally with of a certain size.
Other side effects: none.
Relevant properties: doc.add.log.step.
Takes optional param: document size.

Fields Summary
public static final int
DEFAULT_ADD_DOC_LOG_STEP
Default value for property doc.add.log.step - indicating how often an "added N docs" message should be logged.
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",DEFAULT_ADD_DOC_LOG_STEP);
    }
    if (logStep>0 && (count%logStep)==0) {
      System.out.println("--> processed (add) "+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 booleansupportsParams()

    return true;
  
public voidtearDown()

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