Esempio n. 1
0
 public IList <string> PotentialShardsFor(ShardRequestData requestData)
 {
     if (requestData.EntityType == typeof(Company))
     {
         // You can try to limit the potential shards based on the query
     }
     return(null);
 }
Esempio n. 2
0
            public override IList <string> PotentialShardsFor(ShardRequestData requestData, List <string> potentialShardIds)
            {
                if (potentialShardIds == null)
                {
                    return(null);
                }

                return(new[] { potentialShardIds.Last() });
            }
Esempio n. 3
0
        public override IList <string> PotentialShardsFor(ShardRequestData requestData)
        {
            if (requestData.Keys.Contains("Edin/patients/6"))
            {
                return new List <string> {
                           "Ayende"
                }
            }
            ;

            return(base.PotentialShardsFor(requestData));
        }
    }
        /// <summary>
        ///  Selects the shard ids appropriate for the specified data.
        ///  </summary><returns>Return a list of shards ids that will be search. Returning null means search all shards.</returns>
        public virtual IList<string> PotentialShardsFor(ShardRequestData requestData)
        {
            if (requestData.Keys.Count == 0) // we are only optimized for keys
                return null;

            // we are looking for search by key, let us see if we can narrow it down by using the 
            // embedded shard id.
            var list = new List<string>();
            foreach (var key in requestData.Keys)
            {
                var start = key.IndexOf(shardStrategy.Conventions.IdentityPartsSeparator, StringComparison.OrdinalIgnoreCase);
                if (start == -1)
                    return null; // if we couldn't figure it out, select from all

                var maybeShardId = key.Substring(0, start);

                if (ShardIds.Any(x => string.Equals(maybeShardId, x, StringComparison.OrdinalIgnoreCase)))
                    list.Add(maybeShardId);
                else
                    return null; // we couldn't find it there, select from all

            }
            return list.ToArray();
        }
Esempio n. 5
0
        public IList <string> PotentialShardsFor(ShardRequestData requestData)
        {
            if (requestData.EntityType == typeof(User))
            {
                return new[] { "Users" }
            }
            ;
            if (requestData.EntityType == typeof(Blog))
            {
                return new[] { "Blogs" }
            }
            ;
            if (requestData.EntityType == typeof(Post) ||
                requestData.EntityType == typeof(TotalVotesUp.ReduceResult) ||
                requestData.EntityType == typeof(TotalPostsPerDay.ReduceResult)
                )
            {
                return(Enumerable.Range(0, numberOfShardsForPosts).Select(i => "Posts" + (i + 1).ToString("D2")).ToArray());
            }

            throw new ArgumentException("Cannot get shard id for '" + requestData.EntityType + "' because it is not a User, Blog or Post");
        }
    }
}
 public IList <string> PotentialShardsFor(ShardRequestData requestData)
 {
     // for future use
     throw new NotImplementedException();
 }
Esempio n. 7
0
			public IList<string> PotentialShardsFor(ShardRequestData requestData)
			{
				// for future use
				throw new NotImplementedException();
			}
Esempio n. 8
0
 public IList <string> PotentialShardsFor(ShardRequestData requestData)
 {
     return(new[] { "Shard0", "Shard1", "Shard2" });
 }