Rebuild index database from cplusplus.com and cppreference.com.
547455
def rebuild_index(self):
        """"""
        try:
            os.remove(environ.index_db_re)
        except:
            pass

        self.db_conn = sqlite3.connect(environ.index_db_re)
        self.db_cursor = self.db_conn.cursor()
        self.db_cursor.execute('CREATE TABLE "cplusplus.com" '
                               '(name VARCHAR(255), url VARCHAR(255), std VARCHAR(255))')
        self.db_cursor.execute('CREATE TABLE "cppreference.com" '
                               '(name VARCHAR(255), url VARCHAR(255), std VARCHAR(255))')

        try:
            self.add_url_filter('\.(jpg|jpeg|gif|png|js|css|swf|svg)$')
            self.set_follow_mode(Crawler.F_SAME_PATH)

            # cplusplus.com
            self.crawl('http://www.cplusplus.com/reference/')
            for name, url, std in self.results:
                self.insert_index('cplusplus.com', name, url, std)
            self.db_conn.commit()

            # Rename duplicate entries
            duplicates = self.db_cursor.execute('SELECT name, COUNT(name) '
                                                'AS NON '
                                                'FROM "cplusplus.com" '
                                                'GROUP BY NAME '
                                                'HAVING (NON > 1)').fetchall()
            for name, num in duplicates:
                dump = self.db_cursor.execute('SELECT name, url FROM '
                                              '"cplusplus.com" WHERE name="%s"'
                                              % name).fetchall()
                for n, u in dump:
                    if u not in self.name_exceptions:
                        n2 = n[5:] if n.startswith('std::') else n
                        try:
                            group = re.search('/([^/]+)/%s/$' % n2, u).group(1)
                        except Exception:
                            group = re.search('/([^/]+)/[^/]+/$', u).group(1)

                        new_name = '%s (%s)' % (n, group)
                        self.db_cursor.execute('UPDATE "cplusplus.com" '
                                               'SET name="%s", url="%s" '
                                               'WHERE url="%s"' %
                                               (new_name, u, u))
            self.db_conn.commit()

            # cppreference.com
            self.results = set()
            self.crawl('https://en.cppreference.com/w/cpp', '/w/cpp')

            for name, url, std in self.results:
                self.insert_index('cppreference.com', name, url, std)
            self.db_conn.commit()

        except KeyboardInterrupt:
            os.remove(environ.index_db_re)
            raise KeyboardInterrupt
        finally:
            self.db_conn.close()
105774
private function rebuild_index(){
		$this->uindex = array();
		$this->ntindex = array();
		foreach( $this->rules as $i => $rule ){
			list($nt,$rhs) = $rule;
			$sig = self::rule_signature( $nt, $rhs );
			$this->uindex[$sig] = $i;
			$this->ntindex[$nt][] = $i;		
		}
	}
892122
def regenerate_index_and_spaces
      PEROBS.log.warn "Re-generating FlatFileDB index and space files"
      @index.open unless @index.is_open?
      @index.clear
      @space_list.open unless @space_list.is_open?
      @space_list.clear

      @progressmeter.start('Re-generating database index', @f.size) do |pm|
        each_blob_header do |header|
          if header.is_valid?
            if (duplicate_pos = @index.get(header.id))
              PEROBS.log.error "FlatFile contains multiple blobs for ID " +
                "#{header.id}. First blob is at address #{duplicate_pos}. " +
                "Other blob found at address #{header.addr}."
              if header.length > 0
                @space_list.add_space(header.addr, header.length)
              end
              discard_damaged_blob(header)
            else
              @index.insert(header.id, header.addr)
            end
          else
            if header.length > 0
              @space_list.add_space(header.addr, header.length)
            end
          end

          pm.update(header.addr)
        end
      end

      sync
    end
469349
def marvcli_restore(file):
    """"""
    data = json.load(file)
    site = create_app().site
    site.restore_database(**data)
302672
def generateIndex(self, refresh=0, refresh_index=0):
        """"""
        open(self.index_file, "wt").write(self.renderIndex(refresh=refresh, refresh_index=refresh_index))
152911
def rebuildtable(cls):
        """"""
        cls._closure_model.objects.all().delete()
        cls._closure_model.objects.bulk_create([cls._closure_model(
            parent_id=x['pk'],
            child_id=x['pk'],
            depth=0
        ) for x in cls.objects.values("pk")])
        for node in cls.objects.all():
            node._closure_createlink()
226993
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CPDefinition updateCPDefinition(CPDefinition cpDefinition) {
		return cpDefinitionPersistence.update(cpDefinition);
	}
1371318
public void rebuildIndex(String index) throws Exception {

        OpenCms.getSearchManager().rebuildIndex(index, new CmsShellReport(m_cms.getRequestContext().getLocale()));
    }
1244415
private void refreshIndexes(int version) {
        try {
            Collection<Path> paths = new ArrayList<>();
            MemoryFileManager fm = proc.taskFactory.fileManager();

            appendPaths(fm, StandardLocation.PLATFORM_CLASS_PATH, paths);
            appendPaths(fm, StandardLocation.CLASS_PATH, paths);
            appendPaths(fm, StandardLocation.SOURCE_PATH, paths);

            Map<Path, ClassIndex> newIndexes = new HashMap<>();

            //setup existing/last known data:
            for (Path p : paths) {
                ClassIndex index = PATH_TO_INDEX.get(p);
                if (index != null) {
                    newIndexes.put(p, index);
                }
            }

            synchronized (currentIndexes) {
                //temporary setting old data:
                currentIndexes.clear();
                currentIndexes.putAll(newIndexes);
            }

            //update/compute the indexes if needed:
            for (Path p : paths) {
                waitIndexingNotSuspended();

                ClassIndex index = indexForPath(p);
                newIndexes.put(p, index);
            }

            synchronized (currentIndexes) {
                currentIndexes.clear();
                currentIndexes.putAll(newIndexes);
            }
        } catch (Exception ex) {
            proc.debug(ex, "SourceCodeAnalysisImpl.refreshIndexes(" + version + ")");
        } finally {
            synchronized (currentIndexes) {
                indexVersion = version;
            }
        }
    }
209979
public void rebuildIndexes(List<String> indexNames, I_CmsReport report) throws CmsException {

        try {
            SEARCH_MANAGER_LOCK.lock();
            Iterator<String> i = indexNames.iterator();
            while (i.hasNext()) {
                String indexName = i.next();
                // get the search index by name
                I_CmsSearchIndex index = getIndex(indexName);
                if (index != null) {
                    // update the index
                    updateIndex(index, report, null);
                } else {
                    if (LOG.isWarnEnabled()) {
                        LOG.warn(Messages.get().getBundle().key(Messages.LOG_NO_INDEX_WITH_NAME_1, indexName));
                    }
                }
            }
            // clean up the extraction result cache
            cleanExtractionCache();
        } finally {
            SEARCH_MANAGER_LOCK.unlock();
        }
    }
229013
def _reset_build(self, sources):
        """"""
        from ambry.orm.exc import NotFoundError

        for p in self.dataset.partitions:
            if p.type == p.TYPE.SEGMENT:
                self.log("Removing old segment partition: {}".format(p.identity.name))
                try:
                    self.wrap_partition(p).local_datafile.remove()
                    self.session.delete(p)
                except NotFoundError:
                    pass

        for s in sources:

            # Don't delete partitions fro mother bundles!
            if s.reftype == 'partition':
                continue

            p = s.partition
            if p:
                try:
                    self.wrap_partition(p).local_datafile.remove()
                    self.session.delete(p)
                except NotFoundError:
                    pass

            if s.state in (self.STATES.BUILDING, self.STATES.BUILT):
                s.state = self.STATES.INGESTED

        self.commit()
926384
public void rebuildAllIndexes() throws Exception {

        I_CmsReport report = new CmsShellReport(m_cms.getRequestContext().getLocale());
        OpenCms.getSearchManager().rebuildAllIndexes(report);
    }
1201446
def upgrade():
    """"""
    op.create_table(
        'oaiserver_set',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('spec', sa.String(length=255), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('description', sa.Text(), nullable=True),
        sa.Column('search_pattern', sa.Text(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('spec')
    )
    op.create_index(
        op.f('ix_oaiserver_set_name'),
        'oaiserver_set',
        ['name'],
        unique=False
    )
291086
private void rebuildIndex() throws Exception {
      ByteBuffer buf = ByteBuffer.allocate(KEY_POS);
      for (; ; ) {
         // read FileEntry fields from file (size, keyLen etc.)
         buf.clear().limit(KEY_POS);
         channel.read(buf, filePos);
         // return if end of file is reached
         if (buf.remaining() > 0)
            return;
         buf.flip();

         // initialize FileEntry from buffer
         int entrySize = buf.getInt();
         int keyLen = buf.getInt();
         int dataLen = buf.getInt();
         int metadataLen = buf.getInt();
         long expiryTime = buf.getLong();
         FileEntry fe = new FileEntry(filePos, entrySize, keyLen, dataLen, metadataLen, expiryTime);

         // sanity check
         if (fe.size < KEY_POS + fe.keyLen + fe.dataLen + fe.metadataLen) {
            throw log.errorReadingFileStore(file.getPath(), filePos);
         }

         // update file pointer
         filePos += fe.size;

         // check if the entry is used or free
         if (fe.keyLen > 0) {
            // load the key from file
            if (buf.capacity() < fe.keyLen)
               buf = ByteBuffer.allocate(fe.keyLen);

            buf.clear().limit(fe.keyLen);
            channel.read(buf, fe.offset + KEY_POS);

            // deserialize key and add to entries map
            // Marshaller should allow for provided type return for safety
            K key = (K) ctx.getMarshaller().objectFromByteBuffer(buf.array(), 0, fe.keyLen);
            entries.put(key, fe);
         } else {
            // add to free list
            freeList.add(fe);
         }
      }
   }
339085
def flush_to_index(self):
        """"""
        assert self._smref is not None
        # should always have a file here
        assert not isinstance(self._file_or_files, BytesIO)

        sm = self._smref()
        if sm is not None:
            index = self._index
            if index is None:
                index = sm.repo.index
            # END handle index
            index.add([sm.k_modules_file], write=self._auto_write)
            sm._clear_cache()
838204
public function reindex(): void
    {
        $this->index = [];
        $files = $this->scanDirectory($this->sourceDir, LabelIndex::RELATIVE_ROOT);

        foreach ($files as $file) {
            $node = $this->createIndexNode($file);
            $this->index[$node->getKey()] = $node;
        }

        $this->status = IndexInterface::STATUS_REINDEX;
    }
226912
def _build_resource(self):
        """"""
        additions = [
            {
                "name": added.name,
                "type": added.record_type,
                "ttl": str(added.ttl),
                "rrdatas": added.rrdatas,
            }
            for added in self.additions
        ]

        deletions = [
            {
                "name": deleted.name,
                "type": deleted.record_type,
                "ttl": str(deleted.ttl),
                "rrdatas": deleted.rrdatas,
            }
            for deleted in self.deletions
        ]

        return {"additions": additions, "deletions": deletions}