Does a batch update of the whole search index table.
428540
public function batchUpdate()
    {
        if ($this->_entityName === null) {
            throw new \Exception('Please call « handleEntity(ClassMetadata $class) » before using this handler');
        }
        if (!$this->truncateTable()) {
            throw new \Exception('Could not truncate table ' . $this->getSearchIndexTable());
        }
        $em = $this->_em;
        $indexClass = $this->getSearchIndexClass();

        $batchSize = 100;
        $offset = 0;
        $query = $this->_em->createQueryBuilder()
            ->select('o')
            ->from($this->_entityName, 'o')
            ->setMaxResults($batchSize);

        do {
            $query->setFirstResult($offset);
            $entities = $query->getQuery()->execute();
            foreach ($entities as $entity) {
                $fields = $this->searchIndexes[$this->_class->getName()]['fields'];
                foreach ($fields as $field) {
                    $keywords = $entity->analyseField($field);
                    foreach ($keywords as $keyword) {
                        $index = new $indexClass();
                        $index->setObject($entity);
                        $index->setField($field);
                        $index->setKeyword($keyword);
                        $em->persist($index);
                    }
                }
            }

            $em->flush();
            $offset += $batchSize;
        } while (count($entities) > 0);
    }
945117
public int[] batchUpdate(String tableName, List<Record> recordList, int batchSize) {
    	return batchUpdate(tableName, config.dialect.getDefaultPrimaryKey(),recordList, batchSize);
    }
1343705
private void updatePage() {
		// retrieve page
		final int retrievalPage = page == LAST_PAGE ? pageCount : page;
		final List<Row> rows;
		try {
			rows = client.getExecutor().retrieveResultPage(resultDescriptor.getResultId(), retrievalPage);
		} catch (SqlExecutionException e) {
			close(e);
			return;
		}

		// convert page
		final List<String[]> stringRows = rows
				.stream()
				.map(CliUtils::rowToString)
				.collect(Collectors.toList());

		// update results
		if (previousResultsPage == retrievalPage) {
			// only use the previous results if the current page number has not changed
			// this allows for updated results when the key space remains constant
			previousResults = results;
		} else {
			previousResults = null;
			previousResultsPage = retrievalPage;
		}

		results = stringRows;

		// check if selected row is still valid
		if (selectedRow != NO_ROW_SELECTED) {
			if (selectedRow >= results.size()) {
				selectedRow = NO_ROW_SELECTED;
			}
		}

		// reset view
		resetAllParts();
	}
1285556
def rebuild_index(options={}, finder_options={})
      logger.info "=== Rebuilding index for: #{self.index_type}" unless options[:silent]

      if options[:drop]
        logger.info "Dropping index for: #{self.index_type}" unless options[:silent]
        index_adapter.drop_index(self)
      end

      finder_options[:batch_size] ||= 100
      finder_options[:view] ||= :all
      finder_options[:bypass_index] = true

      options[:batch_size] ||= 100
      options[:commit] = true unless options.has_key?(:commit)
      options[:optimize] = true unless options.has_key?(:optimize)

      logger.info "Offset: #{finder_options[:offset]}" unless options[:silent]
      logger.info "Stop row: #{finder_options[:stop_row]}" unless options[:silent]

      buffer = []
      items_processed = 0
      loop = 0

      # Depending on whether the model has a scan or find method, use that.
      # scan is from Bigrecord models, and find is from Activerecord.
      if self.respond_to?(:scan)
        self.scan(finder_options) do |r|
          items_processed += 1
          buffer << r
          if buffer.size > options[:batch_size]
            loop += 1
            index_adapter.process_index_batch(buffer, loop, options)
            buffer.clear
          end
        end

        index_adapter.process_index_batch(buffer, loop, options) unless buffer.empty?
      elsif self.respond_to?(:find)
        ar_options = {:limit => finder_options[:batch_size]}

        while
          loop += 1

          buffer = self.find_without_index(:all, ar_options)
          break if buffer.empty?
          items_processed += buffer.size

          index_adapter.process_index_batch(buffer, loop, options)

          break if buffer.size < finder_options[:batch_size]

          buffer.clear
          ar_options[:offset] = (loop * finder_options[:batch_size])+1
        end
      else
        raise "Your model needs at least a scan() or find() method"
      end

      if items_processed > 0
        logger.info "Index for #{self.index_type} has been rebuilt (#{items_processed} records)." unless options[:silent]
      else
        logger.info "Nothing to index for #{self.index_type}." unless options[:silent]
      end

      logger.info "=== Finished rebuilding index for: #{self.index_type}" unless options[:silent]

      return items_processed
    end
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);
            }
         }
      }
   }
1372983
def update_all(engine, table, data, upsert=False):
    
    data = ensure_list(data)

    ins = table.insert()
    upd = table.update()

    # Find all primary key columns
    pk_cols = OrderedDict()
    for column in table._columns:
        if column.primary_key:
            pk_cols[column.name] = column

    data_to_insert = list()

    # Multiple primary key column
    if len(pk_cols) >= 2:
        for row in data:
            result = engine.execute(
                upd.
                where(
                    and_(
                        *[col == row[name] for name, col in pk_cols.items()]
                    )
                ).
                values(**row)
            )
            if result.rowcount == 0:
                data_to_insert.append(row)

    # Single primary key column
    elif len(pk_cols) == 1:
        for row in data:
            result = engine.execute(
                upd.
                where(
                    [col == row[name] for name, col in pk_cols.items()][0]
                ).
                values(**row)
            )
            if result.rowcount == 0:
                data_to_insert.append(row)

    else:  # pragma: no cover
        data_to_insert = data

    # Insert rest of data
    if upsert:
        if len(data_to_insert):
            engine.execute(ins, data_to_insert)
1326317
protected void refreshIndexes(Set<String> set)
   {
      // do nothing if null is passed
      if (set == null)
      {
         return;
      }
      setNames(set);
      // callback multiIndex to refresh lists
      try
      {
         MultiIndex multiIndex = getMultiIndex();
         if (multiIndex != null)
         {
            multiIndex.refreshIndexList();
         }
      }
      catch (IOException e)
      {
         LOG.error("Failed to update indexes! " + e.getMessage(), e);
      }
   }
881798
def update(database, table, key):
    """"""
    field = random.randrange(10)
    value = ''.join(random.choice(string.printable) for i in range(100))
    with database.batch() as batch:
        batch.update(table=table, columns=('id', 'field%d' % field),
                     values=[(key, value)])
4659
private void updateIndexTermTargetName() {
        if (defaultTitle == null) {
            defaultTitle = targetFile;
        }
        for (final IndexTerm indexterm : indexTermList) {
            updateIndexTermTargetName(indexterm);
        }
    }
1070545
def update(self, **kwargs):
        
        query = self._build_query()
        connection = get_es_connection(self.es_url, self.es_kwargs)
        results = connection.search(query, indices=self.index, doc_types=self.type,
                                             model=self.model, scan=True)
        for item in results:
            item.update(kwargs)
            item.save(bulk=True)
        connection.flush_bulk(True)
        # Clear the result cache, in case this QuerySet gets reused.
        self._result_cache = None
1292528
public static void updateAll(DataStore dataStore, Iterable<Update> updates, Set<String> tags) {
        updateAll(dataStore, updates.iterator(), tags);
    }
183482
def set_batch(self, data):
    
    

    # fetch existing documents to get current revisions
    rows = self.bucket.view("_all_docs", keys=data.keys(), include_docs=True)
    existing = {}
    for row in rows:
      key = row.id
      if key and not data[key].has_key("_rev"):
        data[key]["_rev"] = row.doc["_rev"]

    for id,item in data.items():
      data[id]["_id"] = id

    revs = {}
    for success, docid, rev_or_exc in self.bucket.update(data.values()):
      if not success and self.logger:
        self.logger.error("Document update conflict (batch) '%s', %s" % (docid, rev_or_exc))
      elif success:
        revs[docid] = rev_or_exc

    return revs
733801
def __update_all(self):
		
		self.__next_start = None
		self.__next_sources = []

		for source in self.__sources:
			self.__update(source)
753630
def update(self,records,**kw):
        """"""
        # ignore unknown fields
        kw = dict([(k,v) for (k,v) in kw.iteritems() if k in self.fields])
        if isinstance(records,dict):
            records = [ records ]
        # update indices
        for indx in set(self.indices.keys()) & set (kw.keys()):
            for record in records:
                if record[indx] == kw[indx]:
                    continue
                _id = record["__id__"]
                # remove id for the old value
                old_pos = bisect.bisect(self.indices[indx][record[indx]],_id)-1
                del self.indices[indx][record[indx]][old_pos]
                if not self.indices[indx][record[indx]]:
                    del self.indices[indx][record[indx]]
                # insert new value
                bisect.insort(self.indices[indx].setdefault(kw[indx],[]),_id)
        for record in records:
            # update record values
            record.update(kw)
            # increment version number
            record["__version__"] += 1
910969
private void update(List<LimitOrder> asks, LimitOrder limitOrder) {

    int idx = Collections.binarySearch(asks, limitOrder);
    if (idx >= 0) {
      asks.remove(idx);
      asks.add(idx, limitOrder);
    } else {
      asks.add(-idx - 1, limitOrder);
    }
  }
183833
def batch_upsert_records(session, table, records):
    """"""
    if not records:
        return
    for record_batch in _batch_postgres_query(table, records):
        stmt = insert(table.__table__)
        stmt = stmt.on_conflict_do_update(
            constraint=table.__table__.primary_key,
            set_={
                "keys": stmt.excluded.get("keys"),
                "values": stmt.excluded.get("values"),
            },
        )
        session.execute(stmt, record_batch)
        session.commit()
791973
def update_batches() -> None:
    ""
    batches_data  = requests.get(BATCHES_API_URL).json()
    batches_url   = {i["name"]: i["download_url"] for i in batches_data
                     if i["type"] == "file"}
    order_batches = sorted(batches_url, key=int)

    try:
        existing = set(os.listdir(BATCHES_DIR))
    except FileNotFoundError:
        BATCHES_DIR.mkdir(parents=True)
        existing = set()

    def get_batch(name: str) -> None:
        if name in existing and name != order_batches[-1]:
            return

        answer = requests.get(batches_url[name])
        try:
            answer.raise_for_status()
        except requests.RequestException:
            return

        with AtomicFile(BATCHES_DIR / name, "w") as file:
            file.write(answer.text)

    ThreadPool(8).map(get_batch, order_batches)