org.apache.solr.update
Class DirectUpdateHandler2

java.lang.Object
  extended by org.apache.solr.update.UpdateHandler
      extended by org.apache.solr.update.DirectUpdateHandler2
All Implemented Interfaces:
SolrInfoMBean

public class DirectUpdateHandler2
extends UpdateHandler

DirectUpdateHandler2 implements an UpdateHandler where documents are added directly to the main Lucene index as opposed to adding to a separate smaller index. For this reason, not all combinations to/from pending and committed are supported. This version supports efficient removal of duplicates on a commit. It works by maintaining a related count for every document being added or deleted. At commit time, for every id with a count, all but the last "count" docs with that id are deleted.

Supported add command parameters:

allowDups overwritePending overwriteCommitted efficiency
false false true fast
true or false true true fast
true false false fastest

Supported delete commands:

command fromPending fromCommitted efficiency
delete true true fast
deleteByQuery true true very slow*

* deleteByQuery causes a commit to happen (close current index writer, open new index reader) before it can be processed. If deleteByQuery functionality is needed, it's best if they can be batched and executed together so they may share the same index reader.

Since:
solr 0.9
Version:
$Id: DirectUpdateHandler2.java 542679 2007-05-29 22:28:21Z ryan $
Author:
yonik

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoMBean
SolrInfoMBean.Category
 
Field Summary
protected  java.util.concurrent.locks.Lock iwAccess
           
protected  java.util.concurrent.locks.Lock iwCommit
           
protected static java.lang.Integer ONE
           
protected  java.util.Map<java.lang.String,java.lang.Integer> pset
           
protected  SolrIndexSearcher searcher
           
protected  org.apache.solr.update.DirectUpdateHandler2.CommitTracker tracker
           
protected  org.apache.lucene.index.IndexWriter writer
           
protected static java.lang.Integer ZERO
           
 
Fields inherited from class org.apache.solr.update.UpdateHandler
commitCallbacks, core, idField, idFieldType, log, optimizeCallbacks, schema
 
Constructor Summary
DirectUpdateHandler2(SolrCore core)
           
 
Method Summary
protected  int addConditionally(AddUpdateCommand cmd)
           
 int addDoc(AddUpdateCommand cmd)
           
protected  int allowDups(AddUpdateCommand cmd)
           
 void close()
           
protected  void closeSearcher()
           
protected  void closeWriter()
           
 void commit(CommitUpdateCommand cmd)
           
 void delete(DeleteUpdateCommand cmd)
           
 void deleteByQuery(DeleteUpdateCommand cmd)
           
protected  void doDeletions()
           
 SolrInfoMBean.Category getCategory()
          Purpose of this Class
 java.lang.String getDescription()
          Simple one or two line description
 java.net.URL[] getDocs()
          Documentation URL list.
 java.lang.String getName()
          Simple common usage name, e.g.
 java.lang.String getSource()
          CVS Source, SVN Source, etc
 java.lang.String getSourceId()
          CVS Id, SVN Id, etc
 NamedList getStatistics()
          Any statistics this instance would like to be publicly available via the Solr Administration interface.
 java.lang.String getVersion()
          Simple common usage version, e.g.
protected  void openSearcher()
           
protected  void openWriter()
           
protected  int overwriteBoth(AddUpdateCommand cmd)
           
 java.lang.String toString()
           
 
Methods inherited from class org.apache.solr.update.UpdateHandler
callPostCommitCallbacks, callPostOptimizeCallbacks, createMainIndexWriter, getIndexedId, getIndexedIdOptional, idTerm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tracker

protected final org.apache.solr.update.DirectUpdateHandler2.CommitTracker tracker

pset

protected final java.util.Map<java.lang.String,java.lang.Integer> pset

ZERO

protected static final java.lang.Integer ZERO

ONE

protected static final java.lang.Integer ONE

iwAccess

protected final java.util.concurrent.locks.Lock iwAccess

iwCommit

protected final java.util.concurrent.locks.Lock iwCommit

writer

protected org.apache.lucene.index.IndexWriter writer

searcher

protected SolrIndexSearcher searcher
Constructor Detail

DirectUpdateHandler2

public DirectUpdateHandler2(SolrCore core)
                     throws java.io.IOException
Throws:
java.io.IOException
Method Detail

openWriter

protected void openWriter()
                   throws java.io.IOException
Throws:
java.io.IOException

closeWriter

protected void closeWriter()
                    throws java.io.IOException
Throws:
java.io.IOException

openSearcher

protected void openSearcher()
                     throws java.io.IOException
Throws:
java.io.IOException

closeSearcher

protected void closeSearcher()
                      throws java.io.IOException
Throws:
java.io.IOException

addDoc

public int addDoc(AddUpdateCommand cmd)
           throws java.io.IOException
Specified by:
addDoc in class UpdateHandler
Throws:
java.io.IOException

delete

public void delete(DeleteUpdateCommand cmd)
            throws java.io.IOException
Specified by:
delete in class UpdateHandler
Throws:
java.io.IOException

deleteByQuery

public void deleteByQuery(DeleteUpdateCommand cmd)
                   throws java.io.IOException
Specified by:
deleteByQuery in class UpdateHandler
Throws:
java.io.IOException

addConditionally

protected int addConditionally(AddUpdateCommand cmd)
                        throws java.io.IOException
Throws:
java.io.IOException

overwriteBoth

protected int overwriteBoth(AddUpdateCommand cmd)
                     throws java.io.IOException
Throws:
java.io.IOException

allowDups

protected int allowDups(AddUpdateCommand cmd)
                 throws java.io.IOException
Throws:
java.io.IOException

doDeletions

protected void doDeletions()
                    throws java.io.IOException
Throws:
java.io.IOException

commit

public void commit(CommitUpdateCommand cmd)
            throws java.io.IOException
Specified by:
commit in class UpdateHandler
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in class UpdateHandler
Throws:
java.io.IOException

getName

public java.lang.String getName()
Description copied from interface: SolrInfoMBean
Simple common usage name, e.g. BasicQueryHandler, or fully qualified clas name.


getVersion

public java.lang.String getVersion()
Description copied from interface: SolrInfoMBean
Simple common usage version, e.g. 2.0


getDescription

public java.lang.String getDescription()
Description copied from interface: SolrInfoMBean
Simple one or two line description


getCategory

public SolrInfoMBean.Category getCategory()
Description copied from interface: SolrInfoMBean
Purpose of this Class


getSourceId

public java.lang.String getSourceId()
Description copied from interface: SolrInfoMBean
CVS Id, SVN Id, etc


getSource

public java.lang.String getSource()
Description copied from interface: SolrInfoMBean
CVS Source, SVN Source, etc


getDocs

public java.net.URL[] getDocs()
Description copied from interface: SolrInfoMBean
Documentation URL list.

Suggested documentation URLs: Homepage for sponsoring project, FAQ on class usage, Design doc for class, Wiki, bug reporting URL, etc...


getStatistics

public NamedList getStatistics()
Description copied from interface: SolrInfoMBean
Any statistics this instance would like to be publicly available via the Solr Administration interface.

Any Object type may be stored in the list, but only the toString() representation will be used.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2006 - 2009 The Apache Software Foundation