code: private void doUpdateRW(final Collection<String> remove, final Collection<Document> add) throws IOException
     {
        // make sure a reader is available during long updates
        if (add.size() > handler.getBufferSize())
        {
           try
           {
              releaseMultiReader();
           }
           catch (IOException e)
           {
              // do not fail if an exception is thrown here
              LOG.warn("unable to prepare index reader " + "for queries during update", e);
           }
        }
  
        synchronized (updateMonitor)
        {
           //updateInProgress = true;
           indexUpdateMonitor.setUpdateInProgress(true, false);
        }
        boolean flush = false;
        try
        {
           long transactionId = nextTransactionId++;
           executeAndLog(new Start(transactionId));
  
           for (Iterator<String> it = remove.iterator(); it.hasNext();)
           {
              executeAndLog(new DeleteNode(transactionId, it.next()));
           }
           for (Iterator<Document> it = add.iterator(); it.hasNext();)
           {
              Document doc = it.next();
              if (doc != null)
              {
                 executeAndLog(new AddNode(transactionId, doc));
                 // commit volatile index if needed
                 flush |= checkVolatileCommit();
              }
           }
           executeAndLog(new Commit(transactionId));
  
           // flush whole index when volatile index has been commited.
           if (flush)
           {
              // if we are going to flush, need to set persistent update
              synchronized (updateMonitor)
              {
                 indexUpdateMonitor.setUpdateInProgress(true, true);
              }
              flush();
           }
        }
        finally
        {
           synchronized (updateMonitor)
           {
              //updateInProgress = false;
  
              indexUpdateMonitor.setUpdateInProgress(false, flush);
              updateMonitor.notifyAll();
              releaseMultiReader();
           }
        }
     }
docs: For investigation purposes only
  
  @param remove
  @param add
  @throws IOException