rdblue commented on a change in pull request #4244: URL: https://github.com/apache/iceberg/pull/4244#discussion_r821133329
########## File path: core/src/main/java/org/apache/iceberg/rest/RESTUtil.java ########## @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.rest; + +import java.io.UncheckedIOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.relocated.com.google.common.base.Joiner; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.base.Splitter; +import org.apache.iceberg.relocated.com.google.common.collect.Maps; +import org.apache.iceberg.relocated.com.google.common.collect.Streams; + +class RESTUtil { + private static final Joiner NULL_JOINER = Joiner.on('\u0000'); + private static final Splitter NULL_SPLITTER = Splitter.on('\u0000'); + + private RESTUtil() { + } + + public static String stripTrailingSlash(String path) { + if (path == null) { + return null; + } + + return path.endsWith("/") ? path.substring(0, path.length() - 1) : path; + } + + /** + * Takes in a map, and returns a copy with entries with keys beginning with the designated prefix + * with the prefix removed. Any entries whose keys don't begin with the prefix are not returned. + * <p> + * This can be used to get a subset of the configuration related to the REST catalog, such as all + * properties from a prefix of `spark.sql.catalog.my_catalog.rest.` to get REST catalog specific properties + * from the spark configuration. + */ + public static Map<String, String> filterByPrefix(Map<String, String> properties, String prefix) { Review comment: This name is okay, but it doesn't quite describe what's happening because it is not just filtering by a key prefix, it is also removing the prefix. I wonder if something like `extractPrefixMap` or something would describe it better. I don't really have a good name for it, so it's probably okay as it is. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
