@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { // search across whole collection // TODO: this may need modification in the future when shard splitting could cause an overlap return collection.getActiveSlices(); } String id = shardKey; if (shardKey.indexOf(SEPARATOR) < 0) { // shardKey is a simple id, so don't do a range return Collections.singletonList(hashToSlice(Hash.murmurhash3_x86_32(id, 0, id.length(), 0), collection)); } Range completeRange = new KeyParser(id).getRange(); List<Slice> targetSlices = new ArrayList<>(1); for (Slice slice : collection.getActiveSlices()) { Range range = slice.getRange(); if (range != null && range.overlaps(completeRange)) { targetSlices.add(slice); } } return targetSlices; }
@Override public int sliceHash(String id, SolrInputDocument doc, SolrParams params, DocCollection collection) { String shardFieldName = getRouteField(collection); if (shardFieldName != null && doc != null) { Object o = doc.getFieldValue(shardFieldName); if (o == null) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No value for :" + shardFieldName + ". Unable to identify shard"); id = o.toString(); } if (id.indexOf(SEPARATOR) < 0) { return Hash.murmurhash3_x86_32(id, 0, id.length(), 0); } return new KeyParser(id).getHash(); }
numBits[i] = getNumBits(parts[i], commaIdx); parts[i] = parts[i].substring(0, commaIdx); hashes[i] = Hash.murmurhash3_x86_32(parts[i], 0, parts[i].length(), 0); masks = getMasks();
numBits[i] = getNumBits(parts[i], commaIdx); parts[i] = parts[i].substring(0, commaIdx); hashes[i] = Hash.murmurhash3_x86_32(parts[i], 0, parts[i].length(), 0); masks = getMasks();
@Override public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) { if (shardKey == null) { // search across whole collection // TODO: this may need modification in the future when shard splitting could cause an overlap return collection.getActiveSlices(); } String id = shardKey; if (shardKey.indexOf(SEPARATOR) < 0) { // shardKey is a simple id, so don't do a range return Collections.singletonList(hashToSlice(Hash.murmurhash3_x86_32(id, 0, id.length(), 0), collection)); } Range completeRange = new KeyParser(id).getRange(); List<Slice> targetSlices = new ArrayList<>(1); for (Slice slice : collection.getActiveSlicesArr()) { Range range = slice.getRange(); if (range != null && range.overlaps(completeRange)) { targetSlices.add(slice); } } return targetSlices; }
@Override public int sliceHash(String id, SolrInputDocument doc, SolrParams params, DocCollection collection) { String shardFieldName = getRouteField(collection); if (shardFieldName != null && doc != null) { Object o = doc.getFieldValue(shardFieldName); if (o == null) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No value for :" + shardFieldName + ". Unable to identify shard"); id = o.toString(); } if (id.indexOf(SEPARATOR) < 0) { return Hash.murmurhash3_x86_32(id, 0, id.length(), 0); } return new KeyParser(id).getHash(); }
/** * Get bit masks for routing based on routing level */ private int[] getMasks() { int[] masks; if (triLevel) masks = getBitMasks(numBits[0], numBits[1]); else masks = getBitMasks(numBits[0]); return masks; }
/** * Get Range for a given CompositeId based route key * * @param routeKey to return Range for * @return Range for given routeKey */ public Range keyHashRange(String routeKey) { if (routeKey.indexOf(SEPARATOR) < 0) { int hash = sliceHash(routeKey, null, null, null); return new Range(hash, hash); } return new KeyParser(routeKey).getRange(); }
/** * Get bit masks for routing based on routing level */ private int[] getMasks() { int[] masks; if (triLevel) masks = getBitMasks(numBits[0], numBits[1]); else masks = getBitMasks(numBits[0]); return masks; }
/** * Get Range for a given CompositeId based route key * * @param routeKey to return Range for * @return Range for given routeKey */ public Range keyHashRange(String routeKey) { if (routeKey.indexOf(SEPARATOR) < 0) { int hash = sliceHash(routeKey, null, null, null); return new Range(hash, hash); } return new KeyParser(routeKey).getRange(); }