Code example for SortedMap

Methods: firstKey, get, isEmpty

        return resources.get(getShardInfo(key));
    public S getShardInfo(byte[] key) {
        SortedMap<Long, S> tail = nodes.tailMap(algo.hash(key));
        if (tail.isEmpty()) {
            return nodes.get(nodes.firstKey());
        return tail.get(tail.firstKey());
    public S getShardInfo(String key) {
        return getShardInfo(SafeEncoder.encode(getKeyTag(key)));
     * A key tag is a special pattern inside a key that, if preset, is the only 
     * part of the key hashed in order to select the server for this key. 
     * @see 
     *      'm_using_some_form_of_key_hashing_for_partitioning,_but_wh