@param array      $iteratables
@param PsiOptions $options

@return \AppendIterator|KeylessAppendIterator

@throws PsiException
10111
protected function createIteratorForMultipleInputs(array $iteratables, PsiOptions $options)
    {
        // when we have multiple inputs we need an option to decide on how to deal with colliding keys
        if ($options->isPreserveKeysOfMultipleInputs()) {
            // this iterator return the original keys of each child iterator
            // -> this leads to conflicts OR means we preserve keys
            $iterator = new \AppendIterator();
        } else {
            // this iterator will create numeric keys from 0 .. n
            $iterator = new KeylessAppendIterator();
        }

        foreach ($iteratables as $iteratable) {
            $iterator->append($this->createSingleIterator($iteratable));
        }

        return $iterator;
    }
123350
public function setOptions(array $options): Options
    {
        foreach ($options as $key => $option) {
            $this->options[$key] = $option;
        }

        return $this;
    }
925188
public function setOptions(array $options)
    {
        foreach ($options as $opt => $val) {
            $this->setOption($opt, $val);
        }

        return $this;
    }
826449
public function setShardKey(array $keys, array $options = []) : void
    {
        if ($this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_COLLECTION && $this->shardKey !== []) {
            throw MappingException::shardKeyInSingleCollInheritanceSubclass($this->getName());
        }

        if ($this->isEmbeddedDocument) {
            throw MappingException::embeddedDocumentCantHaveShardKey($this->getName());
        }

        foreach (array_keys($keys) as $field) {
            if (! isset($this->fieldMappings[$field])) {
                continue;
            }

            if (in_array($this->fieldMappings[$field]['type'], ['many', 'collection'])) {
                throw MappingException::noMultiKeyShardKeys($this->getName(), $field);
            }

            if ($this->fieldMappings[$field]['strategy'] !== static::STORAGE_STRATEGY_SET) {
                throw MappingException::onlySetStrategyAllowedInShardKey($this->getName(), $field);
            }
        }

        $this->shardKey = [
            'keys' => array_map(static function ($value) {
                if ($value === 1 || $value === -1) {
                    return $value;
                }
                if (is_string($value)) {
                    $lower = strtolower($value);
                    if ($lower === 'asc') {
                        return 1;
                    }

                    if ($lower === 'desc') {
                        return -1;
                    }
                }
                return $value;
            }, $keys),
            'options' => $options,
        ];
    }
1273690
private function iteratorFromKeys(array $keys)
    {
        $values = [];
        $key    = ($this->request->qtype === 'eq')
            ? $this->request->key
            : null;

        foreach ($keys as $value) {
            $entry = new IndexEntry();

            $entry->indexKey  = $key;
            $entry->objectKey = $value;

            $values[] = $entry;
        }

        return new ArrayIterator($values);
    }
98973
public function getResults(array $options = []) : ?SavedSearch
    {
        $this->setContainerId($options['entity']);

        $table = TableRegistry::get('Search.SavedSearches');

        /** @var \Search\Model\Entity\SavedSearch|null */
        $savedSearch = $table->find()
            ->where(['id' => $this->widget->get('widget_id')])
            ->enableHydration(true)
            ->first();

        if (null === $savedSearch) {
            $this->errors[] = 'No data found for this entity';

            return null;
        }

        /** @var \Cake\Datasource\RepositoryInterface */
        $table = TableRegistry::get($savedSearch->get('model'));

        $search = new Search($table, $options['user']);
        // keeps backward compatibility
        $entity = $search->reset($savedSearch);
        if (null === $entity) {
            $this->errors[] = 'Failed to reset entity';

            return null;
        }
        $content = $entity->get('content');
        $content['saved'] = Validator::validateData($table, $content['saved'], $options['user']);
        $entity->set('content', $content);

        $this->options['fields'] = Utility::instance()->getSearchableFields($table, $options['user']);
        $this->options['associationLabels'] = Utility::instance()->getAssociationLabels($table);

        $this->data = $entity;

        return $this->data;
    }
534593
public function queryTableGenerator($query, $options = [])
    {
        $statement = $this->_runQuery($query, $options);
        while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
            yield $row;
        }
    }
891500
public static function ensureIndex($keys, $options = array()){

        $result = self::connection()->ensureIndex(self::collectionName(), $keys, $options);

        return $result;

    }
859976
public function save($table, $data, $keys, $options = []) {
		return $this->object->save($table, $data, $keys, $options);
	}
37294
protected function parseTable($tables, $options = [])
    {
        $item = [];
        foreach ((array)$tables as $key => $table) {
            if (!is_numeric($key)) {
                if (strpos($key, '@think')) {
                    $key = strstr($key, '@think', true);
                }
                $key    = $this->parseSqlTable($key);
                $item[] = $this->parseKey($key) . ' ' . $this->parseKey($table);
            } else {
                $table = $this->parseSqlTable($table);
                if (isset($options['alias'][$table])) {
                    $item[] = $this->parseKey($table) . ' ' . $this->parseKey($options['alias'][$table]);
                } else {
                    $item[] = $this->parseKey($table);
                }
            }
        }
        return implode(',', $item);
    }
176845
function setProcessorsFromOptions($options)
    {
        $processors = [];
        foreach (Util::get($options, 'processors', self::getDefaultProcessors()) as $processor) {
            $new_processor = new $processor($this);

            if (isset($options['processorOptions']) && is_array($options['processorOptions'])) {
                if (isset($options['processorOptions'][$processor]) && method_exists($processor, 'setProcessorOptions')) {
                    $new_processor->setProcessorOptions($options['processorOptions'][$processor]);
                }
            }
            $processors[] = $new_processor;
        }
        return $processors;
    }
1248891
public function getPk($options = '')
    {
        if (!empty($this->pk)) {
            $pk = $this->pk;
        } else {
            $pk = $this->getTableInfo(is_array($options) ? $options['table'] : $options, 'pk');
        }
        return $pk;
    }
934614
public function render(TableView $table, array $options = [])
    {
        $options = array_merge($this->defaults, $options);

        $template = $options['template'];
        if ($template instanceof \Twig_TemplateWrapper) {
            $this->template = $template;
        } else {
            $this->template = $this->environment->load($template);
        }

        return $this->template->renderBlock('table', ['table' => $table, 'options' => $options]);
    }
209627
public function options($options)
    {
        foreach ($this->queries as $query) {
            $query->options($options);
        }

        return $this;
    }
399519
private function exportTableOptions(array $options)
    {
        $optionsStr = array();

        foreach($options as $name => $option) {
            if (is_array($option)) {
                $optionsStr[] = '"' . $name . '"={' . $this->exportTableOptions($option) . '}';
            } else {
                $optionsStr[] = '"' . $name . '"="' . (string) $option . '"';
            }
        }

        return implode(',', $optionsStr);
    }
24811
public static function createPagination(array $tokens, array $options) {
        if(!isset($options['pagination_as_query']) || !$options['pagination_as_query']) return '';

        $perPageParam = isset($options['per_page_param']) ? $options['per_page_param'] : PaginationQuery::DEFAULT_PER_PAGE_PARAM;
        $pageParam    = isset($options['page_param']) ? $options['page_param'] : PaginationQuery::DEFAULT_PAGE_PARAM;

        $paginationParameters = PaginationQuery::create($tokens, $perPageParam, $pageParam);

        return $paginationParameters ? http_build_query($paginationParameters) : '';
    }
638049
function IteratorOptions(options) {
  this.gte = null;
  this.lte = null;
  this.keys = true;
  this.values = false;
  this.fillCache = false;
  this.keyAsBuffer = true;
  this.valueAsBuffer = true;
  this.reverse = false;
  this.highWaterMark = 16 * 1024;

  // Note: do not add this property.
  // this.limit = null;

  if (options)
    this.fromOptions(options);
}