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

DeleteDocTask

public class DeleteDocTask extends PerfTask
Delete a document by docid.
Other side effects: none.
Relevant properties: doc.delete.log.step , doc.delete.step.
If no docid param is supplied, deletes doc with id = last-deleted-doc + doc.delete.step.
Takes optional param: document id.

Fields Summary
public static final int
DEFAULT_DOC_DELETE_STEP
Gap between ids of deleted docs, applies when no docid param is provided.
public static final int
DEFAULT_DELETE_DOC_LOG_STEP
Default value for property doc.delete.log.step - indicating how often an "deleted N docs" message should be logged.
private static int
logStep
private static int
deleteStep
private static int
numDeleted
private static int
lastDeleted
private int
docid
private boolean
byStep
Constructors Summary
public DeleteDocTask(org.apache.lucene.benchmark.byTask.PerfRunData runData)

  
     
    super(runData);
  
Methods Summary
public intdoLogic()

  
       
    getRunData().getIndexReader().deleteDocument(docid);
    lastDeleted = docid;
    return 1; // one work item done here
  
private voidlog(int count)

    if (logStep>0 && (count%logStep)==0) {
      System.out.println("--> processed (delete) "+count+" docs, last deleted: "+lastDeleted);
    }
  
public voidsetParams(java.lang.String params)
Set the params (docid only)

param
params docid to delete, or -1 for deleting by delete gap settings.

    super.setParams(params);
    docid = (int) Float.parseFloat(params);
    byStep = (docid < 0);
  
public voidsetup()

    super.setup();
    // one time static initializations
    if (logStep<0) {
      logStep = getRunData().getConfig().get("doc.delete.log.step",DEFAULT_DELETE_DOC_LOG_STEP);
    }
    if (deleteStep<0) {
      deleteStep = getRunData().getConfig().get("doc.delete.step",DEFAULT_DOC_DELETE_STEP);
    }
    // set the docid to be deleted
    docid = (byStep ? lastDeleted + deleteStep : docid);
  
public booleansupportsParams()

    return true;
  
public voidtearDown()

    log(++numDeleted);
    super.tearDown();