Assert a key is a unique index.

@param string $key
@param array $indexes
@return void
439722
protected function assertUniqueIndex($key, $indexes)
    {
        $this->context->assertArrayHasKey($key, $indexes, "The {$this->name} column is not indexed.");
        $this->assertTrue($indexes[$key]->isUnique(), "The {$this->name} is not a unique index.");
    }
796315
public function createIndex($name, $columns, $unique=false)
    {
        if (!is_array($columns)) {
            $columns = array($columns);
        }
        foreach ($columns as &$column) {
            $column = $this->_database->prepareIdentifier($column);
        }
        $this->_database->exec(
            sprintf(
                'CREATE %s INDEX %s ON %s (%s)',
                $unique ? 'UNIQUE' : '',
                $this->_database->prepareIdentifier($name),
                $this->_database->prepareIdentifier($this->_name),
                implode(', ', $columns)
            )
        );
        // Reset index cache to force re-read by next getIndexes() invokation
        $this->_indexes = array();
    }
539086
public function addIndex(array $keys, array $options = []) : void
    {
        $this->indexes[] = [
            '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,
        ];
    }
849767
public function get(string $key): IndexInterface
    {
        if (!isset($this->indexes[$key])) {
            throw new IndexServiceException('Unknown index key: '.$key);
        }

        return $this->indexes[$key];
    }
358197
private function rebuildAttrIndex(string $key)
	{
		$this->index[$key] = [];

		foreach ($this->elements as $id => $element) {
			if ($element instanceof $this->elementClassName) {
				$value = $element->getAttr($key);
				$this->index[$key][$value][$id] = $element;
			} else {
				throw new \InvalidArgumentException("Indexed element must be instance of " . $this->elementClassName);
			}
		}
	}
913256
protected function _update_index($key)
	{
		// get the current index information
		list($identifier, $sections, $index) = $this->_get_index();

		// store the key in the index and write the index back
		$index[$identifier] = array($key, $this->created);
		xcache_set($this->config['cache_id'].$sections, array_merge($index, array($identifier => array($key,$this->created))));

		// get the directory index
		$index = xcache_get($this->config['cache_id'].'__DIR__');

		if (is_array($index))
		{
			if (!in_array($this->config['cache_id'].$sections, $index))
			{
				$index[] = $this->config['cache_id'].$sections;
			}
		}
		else
		{
			$index = array($this->config['cache_id'].$sections);
		}

		// update the directory index
		xcache_set($this->config['cache_id'].'__DIR__', $index, 0);
	}
54889
final public static function anyKeysExist(array $array, array $keys) : bool
    {
        foreach ($keys as $key) {
            if (array_key_exists($key, $array)) {
                return true;
            }
        }

        return false;
    }
319406
public function setUniqueKey($uniqueKey)
    {
        if (! is_null($this->uniqueKey)) {
            throw new RuntimeException('The unique key was already set.');
        }
        if (! is_int($uniqueKey) && ! is_string($uniqueKey)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid type of specified unique key; must be an integer or '
                . 'an string, "%s" received.',
                gettype($uniqueKey)
            ));
        }
        $this->uniqueKey = $uniqueKey;
    }
258896
public function dropIndexes($collection, $indexes)
    {
        $this->beginProfile($token = "    > drop indexes '{$indexes}' on " . $this->composeCollectionLogName($collection) . ") ...");
        $this->db->getCollection($collection)->dropIndexes($indexes);
        $this->endProfile($token);
    }
202224
public function createIndex(array $columnNames, $unique = false, $name = null)
    {
        $index = new Index($name, $columnNames, $unique);
        $this->addIndex($index);

        return $index;
    }
13972
public function unique($columns, $name = null, $algorithm = null)
    {
        return $this->indexCommand('unique', $columns, $name, $algorithm);
    }
683553
protected function updateInverseIndex($key, $minutes = null)
    {
        $this->setKeywordsOperation(true);

        $keywordsState = $this->determineKeywordsState($key);

        $inverseIndexKey = $this->generateInverseIndexKey($key);

        if (empty($keywordsState['new'])) {
            parent::forget($inverseIndexKey);
        } elseif ($keywordsState['old'] != $keywordsState['new']) {
            $newInverseIndex = array_values($keywordsState['new']);
            is_null($minutes) ?
                parent::forever($inverseIndexKey, $newInverseIndex) :
                parent::put($inverseIndexKey, $newInverseIndex, $minutes);
        }

        $this->setKeywordsOperation(false);
    }
58444
public function keysExist(array $keys)
    {
        foreach ($keys as $key) {
            if (!$this->keyExists($key)) {
                return false;
            }
        }
        return true;
    }
922775
private function executeStarts(array $indexes): void
    {
        BlockInterpreter::executeStarts(
            $indexes,
            $this->getBlocks(),
            $this->getContext(),
            $this->getErrorAggregator()
        );
    }
428378
public function hasIndex($indexName, $tableName)
    {
        $result = false;

        foreach ($this->getIndices($tableName) as $index) {
            if ($indexName === $index['Column_name']) {
                $result = true;
            }
        }

        return $result;
    }
276115
public function forget($key, $index_name = null)
	{
		list($index_name, $key) = $this->normalizeAccessKey($key, $index_name);

		if ($this->has($key, $index_name)) {
			unset($this->items[$index_name][$key]);
		}
	}
738808
public function isIndex(array $keys)
    {
        if ($this->indices) {
            foreach ($this->indices as $index) {
                if (count($keys) === count($index->getColumns())) {
                    $allAvailable = true;
                    foreach ($keys as $key) {
                        if (!$index->hasColumn($key instanceof Column ? $key->getName() : $key)) {
                            $allAvailable = false;
                            break;
                        }
                    }
                    if ($allAvailable) {
                        return true;
                    }
                }
            }
        }

        return false;
    }