Update many objects with a single toa

        :param str bulk_id: The bulk id for the job you want to delete
541293
def delete(self, bulk_id):
        

        collection_name = self.request.headers.get("collection")

        if not collection_name:
            self.raise_error(400, "Missing a collection name header")

        self.revisions = BaseAsyncMotorDocument("%s_revisions" % collection_name)

        self.logger.info("Deleting revisions with bulk_id %s" % (bulk_id))

        result = yield self.revisions.collection.remove({"meta.bulk_id": bulk_id})

        self.write(result)
1068596
def upserted_ids(self):
        """"""
        self._raise_if_unacknowledged("upserted_ids")
        if self.__bulk_api_result:
            return dict((upsert["index"], upsert["_id"])
                        for upsert in self.bulk_api_result["upserted"])
75684
def bulk_update_resourcedata(scenario_ids, resource_scenarios,**kwargs):
    
    user_id = kwargs.get('user_id')
    res = None

    res = {}

    net_ids = db.DBSession.query(Scenario.network_id).filter(Scenario.id.in_(scenario_ids)).all()

    if len(set(net_ids)) != 1:
        raise HydraError("Scenario IDS are not in the same network")

    for scenario_id in scenario_ids:
        _check_can_edit_scenario(scenario_id, kwargs['user_id'])

        scen_i = _get_scenario(scenario_id, user_id)
        res[scenario_id] = []

        for rs in resource_scenarios:
            if rs.dataset is not None:
                updated_rs = _update_resourcescenario(scen_i, rs, user_id=user_id, source=kwargs.get('app_name'))
                res[scenario_id].append(updated_rs)
            else:
                _delete_resourcescenario(scenario_id, rs.resource_attr_id)

        db.DBSession.flush()

    return res
1030753
def bulk_update_batches(aggregations)
      en = Enumerator.new do |e|
        i = 1
        batch = []
        aggregations.each do |agg|
          batch << agg
          if i % @bulk_update_size == 0
            e.yield batch
            batch = []
          end
          i += 1
        end
        e.yield batch if batch.count > 0  # last one
      end
      en.lazy
    end
351403
def bulk_delete(ids, strict = false)
      min_snowflake = IDObject.synthesise(Time.now - TWO_WEEKS)

      ids.reject! do |e|
        next unless e < min_snowflake

        message = "Attempted to bulk_delete message #{e} which is too old (min = #{min_snowflake})"
        raise ArgumentError, message if strict

        Discordrb::LOGGER.warn(message)
        true
      end

      API::Channel.bulk_delete_messages(@bot.token, @id, ids)
      ids.size
    end
810965
def bulk_cursor_execute(self, bulk_cursor):
        
        try:
            result = bulk_cursor.execute()
        except BulkWriteError as bwe:
            msg = "bulk_cursor_execute: Exception in executing Bulk cursor to mongo with {error}".format(
                error=str(bwe))
            raise Exception(msg)
        except Exception as e:
            msg = "Mongo Bulk cursor could not be fetched, Error: {error}".format(
                error=str(e))
            raise Exception(msg)
450647
def _process_bulk_chunk(self, bulk_actions, raise_on_exception=True, raise_on_error=True, **kwargs):
        
        # if raise on error is set, we need to collect errors per chunk before
        # raising them

        resp = None
        try:
            # send the actual request
            actions = "{}\n".format('\n'.join(bulk_actions))
            resp = yield self.client.bulk(actions, **kwargs)
        except ConnectionTimeout as e:
            # default behavior - just propagate exception
            if raise_on_exception:
                raise

            self._handle_transport_error(bulk_actions, e, raise_on_error)
            returnValue([])

        # go through request-response pairs and detect failures
        errors = []
        results = []
        for op_type, item in map(methodcaller('popitem'), resp['items']):
            ok = 200 <= item.get('status', 500) < 300
            if not ok and raise_on_error:
                errors.append({op_type: item})

            if ok or not errors:
                # if we are not just recording all errors to be able to raise
                # them all at once, yield items individually
                results.append((ok, {op_type: item}))

        if errors:
            msg_fmt = '{num} document(s) failed to index.'
            raise BulkIndexError(msg_fmt.format(num=len(errors)), errors)
        else:
            returnValue(results)
109212
def update(self, puts, deletes):
        
        with self._lmdb.begin(write=True, buffers=True) as txn:
            cursor = txn.cursor(self._main_db)
            # Process deletes first, to handle the case of new items replacing
            # old index locations
            for key in deletes:
                if not cursor.set_key(key.encode()):
                    # value doesn't exist
                    continue

                value = self._deserializer(bytes(cursor.value()))
                cursor.delete()

                for (index_db, index_key_fn) in self._indexes.values():
                    index_keys = index_key_fn(value)
                    index_cursor = txn.cursor(index_db)
                    for idx_key in index_keys:
                        if index_cursor.set_key(idx_key):
                            index_cursor.delete()

            # process all the inserts
            for key, value in puts:
                packed = self._serializer(value)

                cursor.put(key.encode(), packed, overwrite=True)

                for (index_db, index_key_fn) in self._indexes.values():
                    index_keys = index_key_fn(value)
                    index_cursor = txn.cursor(index_db)
                    for idx_key in index_keys:
                        index_cursor.put(idx_key, key.encode())

        self.sync()
1349035
def bulk_get(cls, files, api=None):
        
        api = api or cls._API
        file_ids = [Transform.to_file(file_) for file_ in files]
        data = {'file_ids': file_ids}

        logger.info('Getting files in bulk.')
        response = api.post(url=cls._URL['bulk_get'], data=data)
        return FileBulkRecord.parse_records(response=response, api=api)
348310
def bulk_copy(self, ids):
        
        schema = DeviceSchema()
        return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema)
1111246
def bulk_save(docs = nil, opts = {})
      opts = { :use_uuids => true, :all_or_nothing => false }.update(opts)
      if docs.nil?
        docs = @bulk_save_cache
        @bulk_save_cache = []
      end
      if opts[:use_uuids]
        ids, noids = docs.partition{|d|d['_id']}
        uuid_count = [noids.length, @server.uuid_batch_count].max
        noids.each do |doc|
          nextid = server.next_uuid(uuid_count) rescue nil
          doc['_id'] = nextid if nextid
        end
      end
      request_body = {:docs => docs}
      if opts[:all_or_nothing]
        request_body[:all_or_nothing] = true
      end
      results = connection.post "#{path}/_bulk_docs", request_body
      docs_by_id = Hash[docs.map { |doc| [doc['_id'], doc] }] unless docs.nil?
      results.each { |r| docs_by_id[r['id']]['_rev'] = r['rev'] if r['ok'] } unless results.nil?
      results
    end
682639
def destroy(bulk=false)
      caught = catch(:halt)  do
        _run_destroy_callbacks do
          result = database.delete_doc(self, bulk)
          if result['ok']
            self.delete('_rev')
            self.delete('_id')
          end
          result['ok']
        end
      end
    end
286537
def update(self, job):
        
        self.cur.execute('''UPDATE jobs
            SET last_run=?,next_run=?,last_run_result=? WHERE hash=?''', (
            job["last-run"], job["next-run"], job["last-run-result"], job["id"]))
258330
def run_bulk(t, first, last, incr = 1)
                retry_until { DRMAA.run_bulk_jobs(t.ptr, first, last, incr) }
            end
483940
def _decode_response_bulk(response_bulk):
    
    resp = []
    for response in response_bulk:
      if ("status" in response) and (response.get("status") == 201):
        agent = {"id": response["id"],
                 "message": response["message"]}
        resp.append(agent)
      elif "status" in response:
        status_code = response["status"]
        message = response["message"]
        agent = {"error": CraftAIClient._get_error_from_status(status_code, message)}
        try:
          agent["id"] = response["id"]
        except KeyError:
          pass
        resp.append(agent)

      else:
        resp.append(response)

    return resp
935998
def put(self, id=None):
        

        toa = self.request.headers.get("Caesium-TOA")

        if not toa:
            self.raise_error(400, "Caesium-TOA header is required, none found")
            self.finish(self.request.headers.get("Caesium-TOA"))

        meta = self._get_meta_data()
        meta["bulk_id"] = uuid.uuid4().get_hex()
        ids = self.get_json_argument("ids")
        patch = self.get_json_argument("patch")

        self.get_json_argument("ids", [])
        for id in ids:
            stack = AsyncSchedulableDocumentRevisionStack(self.client.collection_name, self.settings, master_id=id)
            stack.push(patch, toa=toa, meta=meta)

        self.write({
            "count": len(ids),
            "result": {
                "ids": ids,
                "toa": toa,
                "patch": patch,
            }
        })
        self.finish()
482638
def move_bulk(self, from_statuses, to_status):
        

        for status in from_statuses:
            from_status_items = self.__get_var("items_" + status)
            self.__set_var("items_" + status, OrderedDict())

            to_status_items = self.__get_var("items_" + to_status)
            to_status_items.update(from_status_items)