public static Map<String, String> parseURIQueries(URI uri) {
    if (StringUtils.isBlank(uri.getRawQuery())) {
      return Collections.emptyMap();
    }
    return Splitter.on('&').trimResults().splitToStream(uri.getRawQuery()).map(kv -> {
      int idx = kv.indexOf('=');
      try {
        if (idx > 0) {
          return Pair.newPair(
            URLDecoder.decode(kv.substring(0, idx), StandardCharsets.UTF_8.name()),
            URLDecoder.decode(kv.substring(idx + 1), StandardCharsets.UTF_8.name()));
        } else {
          return Pair.newPair(URLDecoder.decode(kv, StandardCharsets.UTF_8.name()), "");
        }
      } catch (UnsupportedEncodingException e) {
        // should not happen
        throw new AssertionError(e);
      }
    }).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (v1, v2) -> v1));
  }
Parse the query string of an URI to a key value map. If a single key occurred multiple times,
only the first one will take effect.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Strings.java