Empties catalog, then finds all contentish objects (i.e. objects
           with an indexObject method), and reindexes them.
           This may take a long time.
555082
def clearFindAndRebuild(self):
        
        def indexObject(obj, path):
            self.reindexObject(obj)
            self.counter += 1
            if self.counter % 100 == 0:
                logger.info('Progress: {} objects have been cataloged for {}.'
                            .format(self.counter, self.id))

        logger.info('Cleaning and rebuilding %s...' % self.id)
        try:
            at = getToolByName(self, 'archetype_tool')
            types = [k for k, v in at.catalog_map.items()
                     if self.id in v]
            self.counter = 0
            self.manage_catalogClear()
            portal = getToolByName(self, 'portal_url').getPortalObject()
            portal.ZopeFindAndApply(portal,
                                    obj_metatypes=types,
                                    search_sub=True,
                                    apply_func=indexObject)
        except:
            logger.error(traceback.format_exc())
            e = sys.exc_info()
            logger.error(
                "Unable to clean and rebuild %s due to: %s" % (self.id, e))
        logger.info('%s cleaned and rebuilt' % self.id)
1072424
private void removeAllEntries() {
        // A bit unusual, but we want to make sure we do not call this while the index is active.
        Preconditions.checkState(this.closed, "Cannot call removeAllEntries unless the ReadIndex is closed.");
        int count;
        synchronized (this.lock) {
            this.indexEntries.forEach(entry -> {
                if (entry.isDataEntry()) {
                    CacheKey key = getCacheKey(entry);
                    this.cache.remove(key);
                }
            });

            count = this.indexEntries.size();
            this.indexEntries.clear();
        }

        if (count > 0) {
            log.debug("{}: Cleared all cache entries ({}).", this.traceObjectId, count);
        }
    }
1146091
private function reindexResources() {
        if (count($this->resToReindex) == 0) {
            return;
        }

        $this->begin();
        foreach (array_unique($this->resToReindex) as $i) {
            try {
                $res = $this->getResourceByUri($i);
                $res->setMetadata($res->getMetadata());
                $res->updateMetadata();
            } catch (Deleted $e) {
                
            } catch (NotFound $e) {
                
            }
        }
        $this->resToReindex = [];
        $this->commit();
    }
589523
function searchDeletedObjects(baseDN, opts) {
    search.call(self, baseDN, _.defaults({}, opts, { includeDeleted: true }), function onFind(err, results) {
      if (err) {
        if (callback) callback(err);
        return;
      }

      if ((! results) || (results.length === 0)) {
        log.warn('No deleted objects found for query "%s"', truncateLogOutput(opts.filter));
        if (callback) callback();
        self.emit('done');
        return;
      }

      var deletedItems = [];

      // Parse the results in parallel.
      _.forEach(deletedItemss, function(item) {
        var deletedItem = pickAttributes(item, (opts | {}).attributes || []);
        self.emit('entry:deleted', deletedItem);
        deletedItems.push(deletedItem);
      });

      log.info('%d deleted objects found for query "%s". Results: %j',
               deletedItems.length, truncateLogOutput(localOpts.filter), deletedItems);
      self.emit('deleted', deletedItems);
      if (callback) callback(null, deletedItems);
    });
  }
1109407
public function clear()
    {
        if (!($this->_content instanceof ContentSet)) {
            throw new ClassContentException(
                sprintf('Can not clear an content %s.', get_class($this)),
                ClassContentException::UNKNOWN_ERROR
            );
        }

        $this->_data = array();
        $this->_index = 0;
    }
1360961
@Override
    public boolean isEmpty() {
        /*
         * Sum per-segment modCounts to avoid mis-reporting when
         * elements are concurrently added and removed in one segment
         * while checking another, in which case the table was never
         * actually empty at any point. (The sum ensures accuracy up
         * through at least 1<<31 per-segment modifications before
         * recheck.)  Methods size() and containsValue() use similar
         * constructions for stability checks.
         */
        long sum = 0L;
        final Segment<K,V>[] segments = this.segments;
        for (int j = 0; j < segments.length; ++j) {
            Segment<K,V> seg = segmentAt(segments, j);
            if (seg != null) {
                if (seg.count != 0) {
                  return false;
                }
                sum += seg.modCount;
            }
        }
        if (sum != 0L) { // recheck unless no modifications
            for (int j = 0; j < segments.length; ++j) {
                Segment<K,V> seg = segmentAt(segments, j);
                if (seg != null) {
                    if (seg.count != 0) {
                      return false;
                    }
                    sum -= seg.modCount;
                }
            }
            if (sum != 0L) {
              return false;
            }
        }
        return true;
    }
720964
protected void cleanAndReindex( boolean async ) {
        final IndexWriter writer = getIndexWriter();
        scan(async, getIndexWriter(), new Callable<Void>() {
            @SuppressWarnings( "synthetic-access" )
            @Override
            public Void call() throws Exception {
                writer.clearAllIndexes();
                reindexContent(true, writer);
                return null;
            }
        });
    }
593458
private void refreshStash() throws ObjectSourceException {
        if (!stash.isEmpty()) {
            return;
        }
        try {
            if (SEARCH_NOT_STARTED.equals(token)) {
                beginSearch();
            } else if (token != null) {
                resumeSearch();
            }
        } catch (RemoteException e) {
            throw new ObjectSourceException(e);
        }
    }
610228
public void clear()
    {
        Class collClass = getCollectionClass();

        // ECER: assure we notify all objects being removed, 
        // necessary for RemovalAwareCollections...
        if (IRemovalAwareCollection.class.isAssignableFrom(collClass))
        {
            getData().clear();
        }
        else
        {
            Collection coll;
            // BRJ: use an empty collection so isLoaded will return true
            // for non RemovalAwareCollections only !! 
            try
            {
                coll = (Collection) collClass.newInstance();
            }
            catch (Exception e)
            {
                coll = new ArrayList();
            }

            setData(coll);
        }
        _size = 0;
    }
434374
def cleanup(self):
        
        empty_keys = [k for k, v in self.items() if not v]

        for k in empty_keys:
            del self[k]
380965
@Override
    protected void cleanUp() {

        m_pageStorage = null;
        m_folderStorage = null;
        m_webAppNames = null;
        m_webappUrl = null;
        super.cleanUp();
    }
735432
@SuppressWarnings("unchecked")
   void dispose()
   {
      log.debug("dispose IndexMerger");
      // get mutex for index replacements
      try
      {
         indexReplacement.acquire();
      }
      catch (InterruptedException e)
      {
         log.warn("Interrupted while acquiring index replacement sync: " + e);
         // try to stop IndexMerger without the sync
      }

      // clear task queue
      mergeTasks.clear();

      // send quit
      mergeTasks.add(QUIT);
      log.debug("quit sent");

      try
      {
         // give the merger thread some time to quit,
         // it is possible that the merger is busy working on a large index.
         // if that is the case we will just ignore it and the daemon will
         // die without being able to finish the merge.
         // at this point it is not possible anymore to replace indexes
         // on the MultiIndex because we hold the indexReplacement Sync.
         this.join(500);
         if (isAlive())
         {
            log.info("Unable to stop IndexMerger. Daemon is busy.");
         }
         else
         {
            log.debug("IndexMerger thread stopped");
         }
         log.debug("merge queue size: " + mergeTasks.size());
      }
      catch (InterruptedException e)
      {
         log.warn("Interrupted while waiting for IndexMerger thread to terminate.");
      }
   }
284699
def _reindex_with_indexers(self, reindexers, fill_value=None, copy=False,
                               allow_dups=False):
        

        # reindex doing multiple operations on different axes if indicated
        new_data = self._data
        for axis in sorted(reindexers.keys()):
            index, indexer = reindexers[axis]
            baxis = self._get_block_manager_axis(axis)

            if index is None:
                continue

            index = ensure_index(index)
            if indexer is not None:
                indexer = ensure_int64(indexer)

            # TODO: speed up on homogeneous DataFrame objects
            new_data = new_data.reindex_indexer(index, indexer, axis=baxis,
                                                fill_value=fill_value,
                                                allow_dups=allow_dups,
                                                copy=copy)

        if copy and new_data is self._data:
            new_data = new_data.copy()

        return self._constructor(new_data).__finalize__(self)
514459
public boolean hasDeletions() throws CorruptIndexException, IOException
   {
      boolean result = false;

      for (PersistentIndex index : indexes)
      {
         IndexWriter writer = index.getIndexWriter();
         result |= writer.hasDeletions();
      }

      return result;
   }
243462
public long cleanup() {
		int garbageSize = 0;
		if (isCachingEnabled()) {
			System.out.println(new LogEntry(Level.VERBOSE, "Identifying expired objects"));
			ArrayList<K> garbage = getExpiredObjects();
			garbageSize = garbage.size();
			System.out.println(new LogEntry("cache cleanup: expired objects: " + garbageSize));
			for (K key : garbage) {
				clear(key);
			}
		}
		return garbageSize;
	}
21553
public static function cleanupRemovedItems()
    {
        $db = eZDB::instance();
        // Find items that have been moved to trash or deleted
        $itemArray = array();
        $offset = 0;
        $limit = 50;
        do
        {
            $items = $db->arrayQuery( 'SELECT node_id FROM ezm_pool', array( 'offset' => $offset, 'limit' => $limit ) );
            if ( empty( $items ) )
                break;

            foreach( $items as $item )
            {
                $rows = $db->arrayQuery( 'SELECT node_id FROM ezcontentobject_tree WHERE node_id = ' . $item['node_id'] );
                if ( empty( $rows ) )
                    $itemArray[] = $item['node_id'];
            }

            $offset += $limit;
        } while ( true );

        // Remove them all from the flow
        $itemArrayCount = count( $itemArray );
        if ( $itemArrayCount > 0 )
        {
            $db->begin();
            $db->query( 'DELETE FROM ezm_pool WHERE ' . $db->generateSQLINStatement( $itemArray, 'node_id' ) );
            $db->commit();
        }

        return $itemArrayCount;
    }
852490
public void clear()
    {
        if (this.removedItems == null)
        {
            this.removedItems = new FastList(this.size());
        }
        for(int i=0;i < this.size(); i++)
        {
            MithraTransactionalObject result = (MithraTransactionalObject) this.get(i);
            this.addRemovedItem(result);
        }
        super.clear();
    }