Search in sources :

Example 1 with HashBasedRouter

use of org.apache.solr.common.cloud.HashBasedRouter in project lucene-solr by apache.

the class ShardSplitTest method getHashRangeIdx.

public static int getHashRangeIdx(DocRouter router, List<DocRouter.Range> ranges, String id) {
    int hash = 0;
    if (router instanceof HashBasedRouter) {
        HashBasedRouter hashBasedRouter = (HashBasedRouter) router;
        hash = hashBasedRouter.sliceHash(id, null, null, null);
    }
    for (int i = 0; i < ranges.size(); i++) {
        DocRouter.Range range = ranges.get(i);
        if (range.includes(hash))
            return i;
    }
    return -1;
}
Also used : DocRouter(org.apache.solr.common.cloud.DocRouter) HashBasedRouter(org.apache.solr.common.cloud.HashBasedRouter)

Aggregations

DocRouter (org.apache.solr.common.cloud.DocRouter)1 HashBasedRouter (org.apache.solr.common.cloud.HashBasedRouter)1