internal DynamoDbGlobalSecondaryIndexThroughput(string tableName, GlobalSecondaryIndexDescription indexDescription)
     : base(tableName, indexDescription.ProvisionedThroughput)
 {
     IndexName = indexDescription.IndexName;
 }
        /// <summary>
        /// Tries to make up a query request from the list of conditions using a global secondary index
        /// </summary>
        internal static bool TryGetQueryFilterForGlobalSeconaryIndex(this TranslationResult translationResult, GlobalSecondaryIndexDescription indexDescription, out QueryFilter resultFilter)
        {
            resultFilter = null;

            string hashKeyFieldName = indexDescription.KeySchema.Single(ks => ks.KeyType == "HASH").AttributeName;

            Primitive hashKeyValue;
            if (!translationResult.Conditions.TryGetValueForKey(hashKeyFieldName, out hashKeyValue))
            {
                return false;
            }
            if (hashKeyValue == null)
            {
                throw new NotSupportedException("Hash key value should not be null");
            }

            resultFilter = new QueryFilter(hashKeyFieldName, QueryOperator.Equal, hashKeyValue);

            // Copying the list of conditions. without HashKey condition, which is already matched.
            var conditions = translationResult.Conditions.ExcludeField(hashKeyFieldName);

            if (conditions.Count <= 0)
            {
                return true;
            }

            var rangeKeyElement = indexDescription.KeySchema.SingleOrDefault(ks => ks.KeyType == "RANGE");
            if (rangeKeyElement == null)
            {
                return false;
            }

            // first trying to search by range key
            if(TryMatchFieldWithCondition(rangeKeyElement.AttributeName, resultFilter, conditions))
            {
                return TryPutRemainingConditionsToQueryFilter(resultFilter, conditions);
            }

            return false;
        }
 internal DynamoDbGlobalSecondaryIndexThroughput(
     TableDescription tableDescription,
     GlobalSecondaryIndexDescription indexDescription)
     : this(tableDescription.TableName, indexDescription)
 {
 }