SOLR-5338: CompositeIdRouter.keyHashRange should not throw exception if route key is not composite

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1532867 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2013-10-16 19:16:17 +00:00
parent 245be8652d
commit 3aacbf9f91
2 changed files with 7 additions and 1 deletions

View File

@ -561,6 +561,11 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
throw new SolrException(ErrorCode.BAD_REQUEST, throw new SolrException(ErrorCode.BAD_REQUEST,
"The split.key: " + splitKey + " has a hash range that is exactly equal to hash range of shard: " + slice); "The split.key: " + splitKey + " has a hash range that is exactly equal to hash range of shard: " + slice);
} }
for (DocRouter.Range subRange : subRanges) {
if (subRange.min == subRange.max) {
throw new SolrException(ErrorCode.BAD_REQUEST, "The split.key: " + splitKey + " must be a compositeId");
}
}
log.info("Partitioning parent shard " + slice + " range: " + parentSlice.getRange() + " yields: " + subRanges); log.info("Partitioning parent shard " + slice + " range: " + parentSlice.getRange() + " yields: " + subRanges);
rangesStr = ""; rangesStr = "";
for (int i = 0; i < subRanges.size(); i++) { for (int i = 0; i < subRanges.size(); i++) {

View File

@ -96,7 +96,8 @@ public class CompositeIdRouter extends HashBasedRouter {
public Range keyHashRange(String routeKey) { public Range keyHashRange(String routeKey) {
int idx = routeKey.indexOf(separator); int idx = routeKey.indexOf(separator);
if (idx < 0) { if (idx < 0) {
throw new IllegalArgumentException("Route key must be a composite id"); int hash = sliceHash(routeKey, null, null, null);
return new Range(hash, hash);
} }
String part1 = routeKey.substring(0, idx); String part1 = routeKey.substring(0, idx);
int commaIdx = part1.indexOf(bitsSeparator); int commaIdx = part1.indexOf(bitsSeparator);