/// <summary>
 ///     Clones this clause.
 /// </summary>
 /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext" />.</param>
 /// <returns></returns>
 public virtual UseIndexClause Clone(CloneContext cloneContext)
 {
     var clone = new UseIndexClause(IndexName, IndexType);
     return clone;
 }
        /// <summary>
        ///     Clones this clause.
        /// </summary>
        /// <param name="cloneContext">The clones of all query source clauses are registered with this <see cref="CloneContext" />.</param>
        /// <returns></returns>
        public virtual UseIndexClause Clone(CloneContext cloneContext)
        {
            var clone = new UseIndexClause(IndexName, IndexType);

            return(clone);
        }
        public virtual void VisitUseIndexClause(UseIndexClause clause, QueryModel queryModel, int index)
        {
            if (_queryPartsAggregator.UseIndexPart != null)
            {
                throw new NotSupportedException("Only one UseIndex clause is allowed per query.");
            }

            var indexType = clause.IndexType.ToString().ToUpper();
            if (!N1QlHelpers.IsValidKeyword(indexType))
            {
                throw new InvalidOperationException("Invalid index type for the UseIndex clause");
            }

            _queryPartsAggregator.UseIndexPart = new N1QlUseIndexPart()
            {
                IndexName = N1QlHelpers.EscapeIdentifier(clause.IndexName),
                IndexType = indexType
            };
        }