Helper that prepares the fields of a batch creates for JSON
serialization.

@param Api\MtBatchSmsCreate $batch the batch to serialize

@return [] associative array for JSON serialization
5327
private static function _createBatchHelper(Api\MtBatchSmsCreate &$batch)
    {
        $fields = [
            'from' => $batch->getSender(),
            'to' => $batch->getRecipients()
        ];

        if (null != $batch->getDeliveryReport()) {
            $fields['delivery_report'] = $batch->getDeliveryReport();
        }

        if (null != $batch->getSendAt()) {
            $fields['send_at'] = Serialize::_dateTime($batch->getSendAt());
        }

        if (null != $batch->getExpireAt()) {
            $fields['expire_at'] = Serialize::_dateTime($batch->getExpireAt());
        }

        if (null != $batch->getTags()) {
            $fields['tags'] = $batch->getTags();
        }

        if (null != $batch->getCallbackUrl()) {
            $fields['callback_url'] = $batch->getCallbackUrl();
        }

        return $fields;
    }
971696
public function batchCreate(array $tags) {
        $requests = [];

        $required = ['title'];

        foreach ($tags as $data) {
            foreach ($required as $attribute) {
                if (!array_key_exists($attribute, $data)) {
                    throw new BadMethodCallException(sprintf(
                        'Missing attribute "%s"',
                        $attribute
                    ));
                }
            }

            $requests[] = [
                'method' => 'checkmk.statictag.create',
                'params' => [
                    'data' => $data
                ]
            ];
        }

        $result = $this->api->batchRequest($requests);

        $tagIDs = [];

        foreach ($result as $tag) {
            // Do not check 'id' because in a batch request it is always NULL:
            if (!array_key_exists('success', $tag) ||
                $tag['success'] !== true) {
                if (array_key_exists('message', $tag)) {
                    throw new RuntimeException(sprintf('Bad result: %s', $tag['message']));
                } else {
                    throw new RuntimeException('Bad result');
                }
            }

            $tagIDs[] = $tag['id'];
        }

        return $tagIDs;
    }
94738
@Override
	public int[] executeBatch() throws SQLException {
		Split s = prepare(batchSql);
		try {
			return stmt.executeBatch();
		} finally {
			finish(s);
		}
	}
870974
public static function textBatchUpdate(Api\MtBatchTextSmsUpdate $batch)
    {
        $fields = Serialize::_batchUpdateHelper($batch);

        $fields['type'] = 'mt_text';

        if (null != $batch->getBody()) {
            $fields['body'] = $batch->getBody();
        }

        if (null != $batch->getParameters()) {
            if ($batch->getParameters() === Api\Reset::reset()) {
                $fields['parameters'] = null;
            } else {
                $fields['parameters'] = $batch->getParameters();
            }
        }

        return Serialize::_toJson($fields);
    }
866401
public function toArray()
    {
        return [
            'uuid' => $this->uuid,
            'batch_id' => $this->batchId,
            'type' => $this->type,
            'content' => $this->content,
            'created_at' => $this->recordedAt->toDateTimeString(),
        ];
    }
501809
@Override
    public String prepareBatchQuery(List<String> statements) {

        StringBuilder sb = new StringBuilder("BEGIN BATCH \n");

        for (String statement : statements) {
            sb.append(statement).append("\n");
        }

        sb.append(" APPLY BATCH;");

        return sb.toString();
    }
1277457
def prepare_batch(self, batch: mx.io.DataBatch):
        
        self.module.prepare(batch)
733014
public function executeBatch($batchUid)
    {
        $endpoint = vsprintf('batches/%s', [$batchUid]);
        $requestData = $this->getDefaultRequestData('json', [
          'action' => self::ACTION_EXECUTE,
        ]);

        return $this->sendRequest($endpoint, $requestData, self::HTTP_METHOD_POST);
    }
1061334
private int[] convertBatch(int[] batch) {
        int[] conv = new int[batch.length];
        for (int i=0; i<batch.length; i++) {
            conv[i] = sample[batch[i]];
        }
        return conv;
    }
680851
public function pluckBatchIds(): array
    {
        $ids = [];

        /** @var Store $store */
        foreach ($this->paginator() as $store) {
            $ids[] = $store->get($this->batchIdName);
        }

        return $ids;
    }
367781
public function has(Batch $batch)
    {
        foreach ($this->batches as $batchItem) {
            if ($batchItem === $batch) {
                return true;
            }
        }
        return false;
    }
85874
protected function batchFactory()
    {
        return new WriteBatch(
            $this->connection,
            $this->valueMapper,
            $this->databaseFromName($this->name)
        );
    }
418666
public JSONObject batch(List<JSONObject> actions) throws AlgoliaException {
    return postBatch(actions, RequestOptions.empty);
  }
228139
private function loadPerformedMigrations($batch)
    {
        $migrations = [];

        $pluginMigrations = $this->pluginMigrations();

        /** @noinspection SqlDialectInspection */
        $rows = $this->db->table('_migrations')->select('name')->whereCondition('batch = ?', [$batch])->all();
        foreach ($rows as $row) {
            $name = $row['name'];
            $migrations[$name] = isset($pluginMigrations[$name]) ? $pluginMigrations[$name] : $this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php';
        }

        return $migrations;
    }
797447
public function buildEntityFields($fields)
    {
        $aliases = [];
        $dottedFields = [];

        if (!$this->isArray($fields)) {
            $cacheKey = $fields;
            if (array_key_exists($cacheKey, self::$cache)) {
                return self::$cache[$cacheKey];
            }

            $fields = $this->str($fields);

            if ($fields->contains('[')) {
                $fields = $this->parseGroupedNestedFields($fields);
            }

            $fields = $fields->explode(',')->filter()->map('trim')->val();
        } else {
            $cacheKey = serialize($fields);
            if (array_key_exists($cacheKey, self::$cache)) {
                return self::$cache[$cacheKey];
            }

            // Check if asterisk is present and replace it with actual attribute names
            if ($this->arr($fields)->keyExists('*')) {
                unset($fields['*']);
                $defaultFields = $this->str($this->getDefaultAttributes())->explode(',')->filter()->map('trim')->flip()->val();
                $fields = $this->arr($fields)->merge($defaultFields)->val();
            }

            return self::$cache[$cacheKey] = [
                'fields'       => $fields,
                'aliases'      => $aliases,
                'dottedFields' => $dottedFields
            ];
        }

        $parsedFields = $this->arr(['id' => true]);
        $unsetFields = [];

        foreach ($fields as $f) {
            $f = $this->str($f);

            if ($f->contains('@')) {
                list($f, $alias) = $f->explode('@')->val();
                $aliases[$f] = $alias;
                $f = $this->str($f);
            }

            $dottedFields[] = $f->val();

            if ($f->startsWith('!')) {
                $unsetFields[] = $f->trimLeft('!')->val();
                continue;
            }

            if ($f->val() == '*') {
                $defaultFields = $this->str($this->getDefaultAttributes())->explode(',')->filter()->map('trim')->val();
                foreach ($defaultFields as $df) {
                    $this->buildFields($parsedFields, $this->str($df));
                }
                continue;
            }
            $this->buildFields($parsedFields, $f);
        }

        foreach ($unsetFields as $field) {
            $parsedFields->removeKey($field);
        }

        return self::$cache[$cacheKey] = [
            'fields'       => $parsedFields->val(),
            'aliases'      => $aliases,
            'dottedFields' => $dottedFields
        ];
    }
648922
public function fetchBatchTags($batchId)
    {
        $result = $this->_get($this->_batchUrl($batchId, '/tags'));
        return Deserialize::tags($result);
    }
1304648
public function updateTextBatch(
        $batchId, Api\MtBatchTextSmsUpdate $batch
    ) {
        $json = Serialize::textBatchUpdate($batch);
        $result = $this->_post($this->_batchUrl($batchId), $json);
        return Deserialize::batchResponse($result);
    }