Ejemplo n.º 1
0
        public string GetRangeKeyByIndex(string indexName)
        {
            string rangeKeyPropertyName = null;

            // test LSI first
            List <string> rangeProperties;

            if (IndexNameToLSIRangePropertiesMapping.TryGetValue(indexName, out rangeProperties) &&
                rangeProperties != null &&
                rangeProperties.Count == 1)
            {
                rangeKeyPropertyName = rangeProperties[0];
            }

            GSIConfig gsiConfig = GetGSIConfig(indexName);

            if (gsiConfig != null)
            {
                rangeKeyPropertyName = gsiConfig.RangeKeyPropertyName;
            }

            if (string.IsNullOrEmpty(rangeKeyPropertyName))
            {
                throw new InvalidOperationException("Unable to determine range key from index name");
            }

            return(rangeKeyPropertyName);
        }
Ejemplo n.º 2
0
 public string GetCorrectHashKeyProperty(DynamoDBFlatConfig currentConfig, string hashKeyProperty)
 {
     if (currentConfig.IsIndexOperation)
     {
         string    indexName = currentConfig.IndexName;
         GSIConfig gsiConfig = this.GetGSIConfig(indexName);
         // Use GSI hash key if GSI is found AND GSI hash-key is set
         if (gsiConfig != null && !string.IsNullOrEmpty(gsiConfig.HashKeyPropertyName))
         {
             hashKeyProperty = gsiConfig.HashKeyPropertyName;
         }
     }
     return(hashKeyProperty);
 }
Ejemplo n.º 3
0
 private static void AddGSIConfigs(ItemStorageConfig config, string[] gsiIndexNames, string propertyName, bool isHashKey)
 {
     foreach (var index in gsiIndexNames)
     {
         GSIConfig gsiConfig = config.GetGSIConfig(index);
         if (gsiConfig == null)
         {
             gsiConfig = new GSIConfig(index);
             config.IndexNameToGSIMapping[index] = gsiConfig;
         }
         if (isHashKey)
         {
             gsiConfig.HashKeyPropertyName = propertyName;
         }
         else
         {
             gsiConfig.RangeKeyPropertyName = propertyName;
         }
     }
 }
Ejemplo n.º 4
0
 private void AddGSIConfigs(List <string> gsiIndexNames, string propertyName, bool isHashKey)
 {
     foreach (var index in gsiIndexNames)
     {
         GSIConfig gsiConfig = this.GetGSIConfig(index);
         if (gsiConfig == null)
         {
             gsiConfig = new GSIConfig(index);
             this.IndexNameToGSIMapping[index] = gsiConfig;
         }
         if (isHashKey)
         {
             gsiConfig.HashKeyPropertyName = propertyName;
         }
         else
         {
             gsiConfig.RangeKeyPropertyName = propertyName;
         }
     }
 }