{@inheritDoc}

@throws DcGeneralInvalidArgumentException When the index does not exist.
544126
public function getRow($index)
    {
        if (!isset($this->rows[$index])) {
            throw new DcGeneralInvalidArgumentException('Row ' . $index . ' does not exist.');
        }

        return $this->rows[$index];
    }
445649
public void indexDocument(String indexName, String mappingName, String id, XContentBuilder document)
            throws Exception {
        client.prepareIndex(indexName, mappingName, id).setSource(document).get();
    }
762494
protected function _addIndex(Index $indexCandidate)
    {
        $indexName               = $indexCandidate->getName();
        $indexName               = $this->normalizeIdentifier($indexName);
        $replacedImplicitIndexes = [];

        foreach ($this->implicitIndexes as $name => $implicitIndex) {
            if (! $implicitIndex->isFullfilledBy($indexCandidate) || ! isset($this->_indexes[$name])) {
                continue;
            }

            $replacedImplicitIndexes[] = $name;
        }

        if ((isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) ||
            ($this->_primaryKeyName !== false && $indexCandidate->isPrimary())
        ) {
            throw SchemaException::indexAlreadyExists($indexName, $this->_name);
        }

        foreach ($replacedImplicitIndexes as $name) {
            unset($this->_indexes[$name], $this->implicitIndexes[$name]);
        }

        if ($indexCandidate->isPrimary()) {
            $this->_primaryKeyName = $indexName;
        }

        $this->_indexes[$indexName] = $indexCandidate;

        return $this;
    }
852074
@Override public void validate() { 
    if (id == null || id.isEmpty()) {
      throw new IllegalArgumentException("missing or empty id");
    }
    Query.validateId(id);
  }
695321
private function indexOptionsAreMissing(array $mongoIndexOptions, array $documentIndexOptions) : bool
    {
        foreach (self::ALLOWED_MISSING_INDEX_OPTIONS as $option) {
            unset($mongoIndexOptions[$option], $documentIndexOptions[$option]);
        }

        return array_diff_key($mongoIndexOptions, $documentIndexOptions) !== [] || array_diff_key($documentIndexOptions, $mongoIndexOptions) !== [];
    }
765425
public function current()
    {
        if (-1 === $this->index) {
            return $this->first();
        }

        if (!$this->valid()) {
            throw new DcGeneralRuntimeException('FilterBuilder position is invalid.');
        }

        return $this->children[$this->key()];
    }
112297
public function hasElement($instanceOrName)
    {
        if ($instanceOrName instanceof ElementInformationInterface) {
            return \in_array($instanceOrName, $this->elements);
        }

        if (\is_string($instanceOrName)) {
            foreach ($this as $element) {
                /** @var ElementInformationInterface $element */
                if ($instanceOrName === $element->getName()) {
                    return true;
                }
            }

            return false;
        }

        throw new DcGeneralInvalidArgumentException('Invalid value for element name given.');
    }
1026149
private static IndexOptions prepareOptions(MongoDBIndexType indexType, Document options, String indexName, boolean unique) {
		IndexOptions indexOptions = new IndexOptions();
		indexOptions.name( indexName ).unique( unique ).background( options.getBoolean( "background" , false ) );

		if ( unique ) {
			// MongoDB only allows one null value per unique index which is not in line with what we usually consider
			// as the definition of a unique constraint. Thus, we mark the index as sparse to only index values
			// defined and avoid this issue. We do this only if a partialFilterExpression has not been defined
			// as partialFilterExpression and sparse are exclusive.
			indexOptions.sparse( !options.containsKey( "partialFilterExpression" ) );
		}
		else if ( options.containsKey( "partialFilterExpression" ) ) {
			indexOptions.partialFilterExpression( (Bson) options.get( "partialFilterExpression" ) );
		}
		if ( options.containsKey( "expireAfterSeconds" ) ) {
			//@todo is it correct?
			indexOptions.expireAfter( options.getInteger( "expireAfterSeconds" ).longValue() , TimeUnit.SECONDS );

		}

		if ( MongoDBIndexType.TEXT.equals( indexType ) ) {
			// text is an option we take into account to mark an index as a full text index as we cannot put "text" as
			// the order like MongoDB as ORM explicitly checks that the order is either asc or desc.
			// we remove the option from the Document so that we don't pass it to MongoDB
			if ( options.containsKey( "default_language" ) ) {
				indexOptions.defaultLanguage( options.getString( "default_language" ) );
			}
			if ( options.containsKey( "weights" ) ) {
				indexOptions.weights( (Bson) options.get( "weights" ) );
			}

			options.remove( "text" );
		}
		return indexOptions;
	}
763232
public static void atIndex( final int[] array, int index, int value ) {
        final int i = calculateIndex( array, index );

        array[ i ] = value;
    }
277741
protected function undefinedIndexAcces( $index ) {
		if ( $this->errorStrategy == \Pixel418\Iniliq::ERROR_AS_EXCEPTION ) {
			throw new \Exception( 'Undefined index: ' . $index );
		} else if ( $this->errorStrategy == \Pixel418\Iniliq::ERROR_AS_PHPERROR ) {
			trigger_error( 'Undefined index: ' . $index );
		}
	}
901144
public int isNullable( int index ) throws OdaException
	{
		int type =  getColumnType( index );
		if (sqlTypesMayBeNull.containsKey(type)){
			return IResultSetMetaData.columnNullable;
		}else{
			return IResultSetMetaData.columnNoNulls;
		}
	}
297455
protected void setIndexedProperty(Object bean, String name, int[] indexes, Object value, FormMappingOption option) { // e.g. sea[0]
        final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
        if (!beanDesc.hasPropertyDesc(name)) {
            return;
        }
        final PropertyDesc pd = beanDesc.getPropertyDesc(name);
        if (!pd.isWritable()) {
            return;
        }
        if (value.getClass().isArray() && Array.getLength(value) > 0) {
            value = Array.get(value, 0);
        }
        final Class<?> propertyType = pd.getPropertyType();
        if (propertyType.isArray()) {
            Object array = pd.getValue(bean);
            final Class<?> elementType = getArrayElementType(propertyType, indexes.length);
            if (array == null) {
                int[] newIndexes = new int[indexes.length];
                newIndexes[0] = indexes[0] + 1;
                array = Array.newInstance(elementType, newIndexes);
            }
            array = expand(array, indexes, elementType);
            pd.setValue(bean, array);
            setArrayValue(array, indexes, value);
        } else { // e.g. List, ImmutableList, MutableList
            // process of your collections should be first because MutableList is java.util.List 
            final Optional<FormYourCollectionResource> yourCollection = findListableYourCollection(pd, option);
            if (yourCollection.isPresent()) { // e.g. ImmutableList, MutableList
                doSetIndexedPropertyListable(bean, name, indexes, value, beanDesc, pd, option, newList -> {
                    @SuppressWarnings("unchecked")
                    final List<Object> filtered = (List<Object>) yourCollection.get().getYourCollectionCreator().apply(newList);
                    return filtered;
                });
            } else if (List.class.isAssignableFrom(propertyType)) {
                doSetIndexedPropertyListable(bean, name, indexes, value, beanDesc, pd, option, Function.identity());
            } else {
                throwIndexedPropertyNotListArrayException(beanDesc, pd);
            }
        }
    }
939453
private function _createIndex(array $columnNames, $indexName, $isUnique, $isPrimary, array $flags = [], array $options = [])
    {
        if (preg_match('(([^a-zA-Z0-9_]+))', $this->normalizeIdentifier($indexName))) {
            throw SchemaException::indexNameInvalid($indexName);
        }

        foreach ($columnNames as $columnName) {
            if (! $this->hasColumn($columnName)) {
                throw SchemaException::columnDoesNotExist($columnName, $this->_name);
            }
        }

        return new Index($indexName, $columnNames, $isUnique, $isPrimary, $flags, $options);
    }
289142
private void ensureIndex(DS session, EntityTypeMetadata<NodeMetadata<L>> entityTypeMetadata,
            IndexedPropertyMethodMetadata<IndexedPropertyMetadata> indexedProperty) {
        if (indexedProperty != null) {
            IndexedPropertyMetadata datastoreMetadata = indexedProperty.getDatastoreMetadata();
            if (datastoreMetadata.isCreate()) {
                L label = entityTypeMetadata.getDatastoreMetadata().getDiscriminator();
                PrimitivePropertyMethodMetadata<PropertyMetadata> propertyMethodMetadata = indexedProperty.getPropertyMethodMetadata();
                if (label != null && propertyMethodMetadata != null) {
                    ensureIndex(session, label, propertyMethodMetadata, datastoreMetadata.isUnique());
                }
            }
        }
    }
565104
public function deleteDuplicateDocumentNotMatchingType(Index $index, string $documentIdentifier, NodeType $nodeType): void
    {
        $result = $index->request('GET', '/_search?scroll=1m', [], json_encode([
            'sort' => ['_doc'],
            'query' => [
                'bool' => [
                    'must' => [
                        'ids' => [
                            'values' => [$documentIdentifier]
                        ]
                    ],
                    'must_not' => [
                        'term' => [
                            '_type' => $this->nodeTypeMappingBuilder->convertNodeTypeNameToMappingName($nodeType->getName())
                        ]
                    ]
                ]
            ]
        ]));
        $treatedContent = $result->getTreatedContent();
        $scrollId = $treatedContent['_scroll_id'];
        $mapHitToDeleteRequest = function ($hit) {
            return json_encode([
                'delete' => [
                    '_type' => $hit['_type'],
                    '_id' => $hit['_id']
                ]
            ]);
        };
        $bulkRequest = [];
        while (isset($treatedContent['hits']['hits']) && $treatedContent['hits']['hits'] !== []) {
            $hits = $treatedContent['hits']['hits'];
            $bulkRequest = array_merge($bulkRequest, array_map($mapHitToDeleteRequest, $hits));
            $result = $index->request('GET', '/_search/scroll?scroll=1m', [], $scrollId, false);
            $treatedContent = $result->getTreatedContent();
        }
        $this->logger->log(sprintf('NodeIndexer: Check duplicate nodes for %s (%s), found %d document(s)', $documentIdentifier, $nodeType->getName(), count($bulkRequest)), LOG_DEBUG, null, 'ElasticSearch (CR)');
        if ($bulkRequest !== []) {
            $index->request('POST', '/_bulk', [], implode("\n", $bulkRequest) . "\n");
        }
        $this->searchClient->request('DELETE', '/_search/scroll', [], json_encode([
            'scroll_id' => [
                $scrollId
            ]
        ]));
    }
239957
public function onSchemaIndexDefinition(SchemaIndexDefinitionEventArgs $event): void
    {
        $event->preventDefault();
        $data = $event->getTableIndex();

        $name = str_replace('.', '__', $data['name']);
        $event->setIndex(new Index($name, $data['columns'], $data['unique'], $data['primary'], $data['flags'], $data['options']));
    }
780542
public void invalidate(InternalIndex index) {
        String[] components = index.getComponents();
        if (components == null) {
            cache.remove(index.getName());
            return;
        }

        for (String component : components) {
            TypeConverter converter = cache.get(component);
            if (converter instanceof UnresolvedConverter) {
                cache.remove(component);
            }
        }
    }