From 3aacbf9f9100c213f00fd525f606a6cc82d95c68 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Wed, 16 Oct 2013 19:16:17 +0000 Subject: [PATCH] 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 --- .../org/apache/solr/cloud/OverseerCollectionProcessor.java | 5 +++++ .../java/org/apache/solr/common/cloud/CompositeIdRouter.java | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java index f6ae9128692..72787457178 100644 --- a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java +++ b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java @@ -561,6 +561,11 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { throw new SolrException(ErrorCode.BAD_REQUEST, "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); rangesStr = ""; for (int i = 0; i < subRanges.size(); i++) { diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java b/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java index 3f3b9af9edf..ab94a261cf4 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java @@ -96,7 +96,8 @@ public class CompositeIdRouter extends HashBasedRouter { public Range keyHashRange(String routeKey) { int idx = routeKey.indexOf(separator); 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); int commaIdx = part1.indexOf(bitsSeparator);