Performs indexing into volatile index in case of Read_Only mode. This ensures that node
was not present in latest persistent index in case of coordinator has just committed the index

@param remove
@param add
@throws IOException
505953
private void doUpdateRO(final Collection<String> remove, final Collection<Document> add) throws IOException
   {
      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
      {
         @SuppressWarnings("resource")
         public Object run() throws Exception
         {
            // 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)
            {
                 ReadOnlyIndexReader[] readers = null;
                 try
                 {
                     for (Iterator<String> it = remove.iterator(); it.hasNext(); )
                     {
                         Term idTerm = new Term(FieldNames.UUID, it.next());
                         int num = volatileIndex.removeDocument(idTerm);
                         if (num == 0)
                         {
                             for (int i = indexes.size() - 1; i >= 0; i--)
                             {
                                 // only look in registered indexes
                                 PersistentIndex idx = indexes.get(i);
                                 if (indexNames.contains(idx.getName()))
                                 {
                                     num = idx.removeDocument(idTerm);
                                     if (num > 0)
                                     {
                                         if (LOG.isDebugEnabled())
                                             LOG.debug(idTerm.text() + " has been found in the persisted index " + i);
                                         break;
                                     }
                                 }
                             }
                         }
                         else if (LOG.isDebugEnabled())
                         {
                             LOG.debug(idTerm.text() + " has been found in the volatile index");
                         }
                     }
                     // try to avoid getting index reader for each doc
                     IndexReader indexReader = null;

                     for (Iterator<Document> it = add.iterator(); it.hasNext(); )
                     {
                         Document doc = it.next();
                         if (doc != null)
                         {
                             // check if this item should be placed in own volatile index
                             // usually it must be indexed, but exception if it exists in persisted index
                             boolean addDoc = true;

                             // make this check safe if something goes wrong
                             String uuid = doc.get(FieldNames.UUID);
                             // if remove contains uuid, node should be re-indexed
                             // if not, than should be checked if node present in the last persisted index
                             if (!remove.contains(uuid))
                             {
                                 // if index list changed, get the reader on the latest index
                                 // or if index reader is not current
                                 if (indexReader == null)
                                 {
                                     try
                                     {
                                         readers = getReadOnlyIndexReaders(false, false);
                                         indexReader = new MultiReader(readers);
                                     }
                                     catch (Throwable e)//NOSONAR
                                     {
                                         // this is safe index reader retrieval. The last index already closed, possibly merged or
                                         // any other exception that occurs here
                                         LOG.warn("Could not create the MultiReader :" + e.getLocalizedMessage());
                                         LOG.debug("Could not create the MultiReader", e);
                                     }
                                 }
                                 if ((indexReader != null && !indexReader.isCurrent()))
                                 {
                                     // safe release reader
                                     if (indexReader != null)
                                     {
                                         for (ReadOnlyIndexReader reader : readers)
                                         {
                                             reader.release();
                                         }
                                     }
                                     try
                                     {
                                         readers = getReadOnlyIndexReaders(false, false);
                                         indexReader = new MultiReader(readers);
                                     }
                                     catch (Throwable e)//NOSONAR
                                     {
                                         // this is safe index reader retrieval. The last index already closed, possibly merged or
                                         // any other exception that occurs here
                                         LOG.warn("Could not create the MultiReader :" + e.getLocalizedMessage());
                                         LOG.debug("Could not create the MultiReader", e);
                                     }
                                 }
                                 // if indexReader exists (it is possible that no persisted indexes exists on start)
                                 if (indexReader != null)
                                 {
                                     TermDocs termDocs = null;
                                     try
                                     {
                                         // reader from resisted index should be
                                         termDocs = indexReader.termDocs(new Term(FieldNames.UUID, uuid));
                                         // node should be indexed if not found in persistent index
                                         addDoc = !termDocs.next();
                                     }
                                     catch (Exception e)
                                     {
                                         LOG.debug("Some exception occured, during index check");
                                     }
                                     finally
                                     {
                                         if (termDocs != null)
                                             termDocs.close();
                                     }
                                 }
                             }
                             if (addDoc)
                             {
                                 volatileIndex.addDocuments(new Document[]{doc});
                             }
                             else if (LOG.isDebugEnabled())
                             {
                                 LOG.debug("Could find the document {} in the last persisted index", uuid);
                             }
                         }
                     }
                 }
                 finally
                 {
                     // don't forget to release a reader anyway
                     if (readers != null)
                     {
                         for (ReadOnlyIndexReader reader : readers)
                         {
                             reader.release();
                         }
                     }
                     releaseMultiReader();
                 }
            }
            return null;
         }
      });
   }
294256
public void remove( int idx ) 
    {
        if ( idx < 0 || idx > size )
            throw new IndexOutOfBoundsException();
        int numMove = size - idx - 1;
        if ( numMove > 0 )
            System.arraycopy(items, idx + 1, items, idx, numMove);
        size--;
    }
589663
public E remove(int index) {
        if (index >= mSize)
            throw new IndexOutOfBoundsException("Index: " + index + ", Size: "
                    + mSize);

        E ret = mElements.remove(index < 0 ? index + mSize : index);
        mSize--;
        return ret;
    }
637631
private void remove(int index) {
        int lastIndex = --size;
        Reference<E> removed = storage.array[index];
        Reference<E> lastElem = storage.array[lastIndex];
        storage.array[index] = lastElem;
        lastElem.index = index;
        removed.index = -1;
        storage.array[lastIndex] = null;
    }
294487
@Override
    protected void indexNode(Node node, EntityMetadata entityMetadata)
    {
        // Do nothing as
        if (this.indexManager.getIndexer() != null
                && !this.indexManager.getIndexer().getClass().getSimpleName().equals("RedisIndexer"))
        {
            super.indexNode(node, entityMetadata);
        }
    }
209295
public long remove(long addr, long posToRemove) {
        long posToShift = posToRemove;
        while (true) {
            posToShift = step(posToShift);
            // volatile read not needed because removed is performed under exclusive lock
            long entryToShift = readEntry(addr, posToShift);
            if (empty(entryToShift))
                break;
            long insertPos = hlPos(key(entryToShift));
            // the following condition essentially means circular permutations
            // of three (r = posToRemove, s = posToShift, i = insertPos)
            // positions are accepted:
            // [...i..r...s.] or
            // [...r..s...i.] or
            // [...s..i...r.]
            boolean cond1 = insertPos <= posToRemove;
            boolean cond2 = posToRemove <= posToShift;
            if ((cond1 && cond2) ||
                    // chain wrapped around capacity
                    (posToShift < insertPos && (cond1 || cond2))) {
                writeEntry(addr, posToRemove, entryToShift);
                posToRemove = posToShift;
            }
        }
        clearEntry(addr, posToRemove);
        return posToRemove;
    }
421487
public void insertOperation(final MemcachedNode node, final Operation o) {
    o.setHandlingNode(node);
    o.initialize();
    node.insertOp(o);
    addedQueue.offer(node);
    metrics.markMeter(OVERALL_REQUEST_METRIC);

    Selector s = selector.wakeup();
    assert s == selector : "Wakeup returned the wrong selector.";
    getLogger().debug("Added %s to %s", o, node);
  }
1224103
public synchronized void remove()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "remove");

    if(removable != null)
    {
      index.remove(removable);
    }
    else
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "remove", "IllegalStateException");
      throw new IllegalStateException(
        nls.getFormattedMessage(
          "NO_ELEMENTS_ERROR_CWSIP0602",
          null,
          null));
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "remove");
  }
1337364
public final void remove(EntityMetadata metadata, Object entity, Object key)
    {
        if (indexer != null)
        {
            if (indexer.getClass().getName().equals(IndexingConstants.LUCENE_INDEXER))
            {
                ((com.impetus.kundera.index.lucene.Indexer) indexer).unindex(metadata, key, kunderaMetadata, null);
            }
            else
            {
                indexer.unIndex(metadata.getEntityClazz(), entity, metadata, (MetamodelImpl) kunderaMetadata
                        .getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit()));
            }
        }
    }
1170099
private void removeNode(ItemState item, int indexItem)
   {

      items.remove(indexItem);
      index.remove(item.getData().getIdentifier());
      index.remove(item.getData().getQPath());
      index.remove(new ParentIDQPathBasedKey(item));
      index.remove(new IDStateBasedKey(item.getData().getIdentifier(), item.getState()));
      childNodesInfo.remove(item.getData().getIdentifier());
      lastChildNodeStates.remove(item.getData().getIdentifier());
      childNodeStates.remove(item.getData().getIdentifier());
      if (allPathsChanged != null && item.isPathChanged())
      {
         allPathsChanged.remove(item);
         if (allPathsChanged.isEmpty())
            allPathsChanged = null;
      }

      if (item.isPersisted())
      {

         int childInfo[] = childNodesInfo.get(item.getData().getParentIdentifier());

         if (childInfo != null)
         {
            if (item.isDeleted())
            {
               ++childInfo[CHILD_NODES_COUNT];
            }
            else if (item.isAdded())
            {
               --childInfo[CHILD_NODES_COUNT];
            }

            childNodesInfo.put(item.getData().getParentIdentifier(), childInfo);
         }
      }

      Map<String, ItemState> children = lastChildNodeStates.get(item.getData().getParentIdentifier());
      if (children != null)
      {
         children.remove(item.getData().getIdentifier());
         if (children.isEmpty())
         {
            lastChildNodeStates.remove(item.getData().getParentIdentifier());
         }
      }

      List<ItemState> listItemStates = childNodeStates.get(item.getData().getParentIdentifier());
      if (listItemStates != null)
      {
         listItemStates.remove(item);
         if (listItemStates.isEmpty())
         {
            childNodeStates.remove(item.getData().getParentIdentifier());
         }
      }
      if ((children == null || children.isEmpty()) && (listItemStates == null || listItemStates.isEmpty()))
      {
         childNodesInfo.remove(item.getData().getParentIdentifier());
      }
   }
1246523
public void updateIndex(Set<String> addedNodes, Set<String> removedNodes, Set<String> parentAddedNodes,
      Set<String> parentRemovedNodes)
   {
      // pass lists to search manager 
      if (searchManager != null && (addedNodes.size() > 0 || removedNodes.size() > 0))
      {
         try
         {
            searchManager.updateIndex(removedNodes, addedNodes);
         }
         catch (RepositoryException e)
         {
            log.error("Error indexing changes " + e, e);
         }
         catch (IOException e)
         {
            log.error("Error indexing changes " + e, e);
            try
            {
               handler.logErrorChanges(removedNodes, addedNodes);
            }
            catch (IOException ioe)
            {
               log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
            }
         }
      }
      // pass lists to parent search manager 
      if (parentSearchManager != null && (parentAddedNodes.size() > 0 || parentRemovedNodes.size() > 0))
      {
         try
         {
            parentSearchManager.updateIndex(parentRemovedNodes, parentAddedNodes);
         }
         catch (RepositoryException e)
         {
            log.error("Error indexing changes " + e, e);
         }
         catch (IOException e)
         {
            log.error("Error indexing changes " + e, e);
            try
            {
               parentHandler.logErrorChanges(parentRemovedNodes, parentAddedNodes);
            }
            catch (IOException ioe)
            {
               log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
            }
         }
      }
   }
160292
protected void addOperation(final MemcachedNode node, final Operation o) {
    if (!node.isAuthenticated()) {
      retryOperation(o);
      return;
    }
    o.setHandlingNode(node);
    o.initialize();
    node.addOp(o);
    addedQueue.offer(node);
    metrics.markMeter(OVERALL_REQUEST_METRIC);

    Selector s = selector.wakeup();
    assert s == selector : "Wakeup returned the wrong selector.";
    getLogger().debug("Added %s to %s", o, node);
  }
82937
@Override
    public void add(int index, E element) {
        final ReentrantLock lock = this.lock;
        lock.lock();
        try {
            Object[] elements = getArray();
            int len = elements.length;
            if (index > len || index < 0)
                throw new IndexOutOfBoundsException("Index: " + index +
                                                    ", Size: " + len);
            Object[] newElements;
            int numMoved = len - index;
            if (numMoved == 0)
                newElements = Arrays.copyOf(elements, len + 1);
            else {
                newElements = new Object[len + 1];
                System.arraycopy(elements, 0, newElements, 0, index);
                System.arraycopy(elements, index, newElements, index + 1,
                                 numMoved);
            }
            newElements[index] = element;
            setArray(newElements);
        } finally {
            lock.unlock();
        }
    }
373545
@Override
    public void remove(int idx) {
		int i = Arrays.binarySearch(indices, 0, used, idx);
		if (i < 0) {
			throw new IllegalArgumentException("This map does not contain the key: " + idx);
		}		
		// Shift the values over.
		System.arraycopy(indices, i+1, indices, i, used - i - 1);
		System.arraycopy(values, i+1, values, i, used - i - 1);
		used--;
	}
1156276
void unlinkNode(int index, int lastLookup, int lookup) {

        // A VoltDB extension to diagnose ArrayOutOfBounds.
        voltDBhistory[voltDBhistoryDepth++ % voltDBhistoryCapacity] = -index-1;
        // End of VoltDB extension
        // unlink the node
        if (lastLookup == -1) {
            hashTable[index] = linkTable[lookup];
        } else {
            linkTable[lastLookup] = linkTable[lookup];
        }

        // add to reclaimed list
        linkTable[lookup]    = reclaimedNodePointer;
        reclaimedNodePointer = lookup;

        elementCount--;
    }
715495
public void remove(int index) {
    ensureMutableMessageList();
    messages.remove(index);
    if (builders != null) {
      SingleFieldBuilder<MType, BType, IType> entry =
          builders.remove(index);
      if (entry != null) {
        entry.dispose();
      }
    }
    onChanged();
    incrementModCounts();
  }
1254129
synchronized int removeAllDocuments(String uuid) throws IOException
   {
      synchronized (updateMonitor)
      {
         //updateInProgress = true;
         indexUpdateMonitor.setUpdateInProgress(true, false);
      }
      int num;
      try
      {
         Term idTerm = new Term(FieldNames.UUID, uuid.toString());
         executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
         num = volatileIndex.removeDocument(idTerm);
         if (num > 0)
         {
            redoLog.append(new DeleteNode(getTransactionId(), uuid));
         }
         for (int i = 0; i < indexes.size(); i++)
         {
            PersistentIndex index = indexes.get(i);
            // only remove documents from registered indexes
            if (indexNames.contains(index.getName()))
            {
               int removed = index.removeDocument(idTerm);
               if (removed > 0)
               {
                  redoLog.append(new DeleteNode(getTransactionId(), uuid));
               }
               num += removed;
            }
         }
         executeAndLog(new Commit(getTransactionId()));
      }
      finally
      {
         synchronized (updateMonitor)
         {
            //updateInProgress = false;
            indexUpdateMonitor.setUpdateInProgress(false, false);
            updateMonitor.notifyAll();
            releaseMultiReader();
         }
      }
      return num;
   }