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); }
public override IList <string> PotentialShardsFor(ShardRequestData requestData, List <string> potentialShardIds) { if (potentialShardIds == null) { return(null); } return(new[] { potentialShardIds.Last() }); }
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(); }
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(); }
public IList<string> PotentialShardsFor(ShardRequestData requestData) { // for future use throw new NotImplementedException(); }
public IList <string> PotentialShardsFor(ShardRequestData requestData) { return(new[] { "Shard0", "Shard1", "Shard2" }); }