amogh-jahagirdar commented on code in PR #14465: URL: https://github.com/apache/iceberg/pull/14465#discussion_r2534971027
########## core/src/main/java/org/apache/iceberg/rest/RESTOperationsFactory.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Supplier; +import org.apache.iceberg.MetadataUpdate; +import org.apache.iceberg.TableMetadata; +import org.apache.iceberg.io.FileIO; +import org.apache.iceberg.view.ViewMetadata; + +/** + * A factory interface for creating {@link RESTTableOperations} and {@link RESTViewOperations} + * instances for REST catalogs. + * + * <p>This interface allows custom implementations of table and view operations to be injected into + * {@link RESTSessionCatalog} and {@link RESTCatalog}, enabling extensibility for specialized use + * cases. + * + * <p>Example usage: + * + * <pre> + * RESTOperationsFactory customFactory = new RESTOperationsFactory() { + * {@literal @}Override + * public RESTTableOperations createTableOperations( + * RESTClient client, + * String path, + * Supplier<Map<String, String>> headers, + * FileIO io, + * TableMetadata current, + * Set<Endpoint> endpoints) { + * return new CustomRESTTableOperations(client, path, headers, io, current, endpoints); + * } + * + * {@literal @}Override + * public RESTViewOperations createViewOperations( + * RESTClient client, + * String path, + * Supplier<Map<String, String>> headers, + * ViewMetadata current, + * Set<Endpoint> endpoints) { + * return new CustomRESTViewOperations(client, path, headers, current, endpoints); + * } + * }; + * + * RESTSessionCatalog catalog = new RESTSessionCatalog(clientBuilder, ioBuilder, customFactory); + * </pre> + */ +public interface RESTOperationsFactory { Review Comment: I've only done a cursory glance on these changes but if we really want to override `RESTTableOperations`, have we thought about just adding a protected API `protected RESTTableOperations newTableOps(TableIdentifier identifier)` on `RESTSessionCatalog` and then implementations would override `newTableOps`. I think in this approach we'd also have to change RESTCatalog to allow passing through a RESTSessionCatalog implementation. I feel like the benefit of this approach is that we don't have to introduce a new factory whose APIs may need to change as people want to pass through new stuff to their table operations. Instead, in the inheritance based approach, anything tied in the state of the RESTSessionCatalog can easily be passed through the custom RESTableOperations. Basically I think I'm trying to make the argument that if you're going to override with custom table operations, you probably want to override RESTSessionCatalog and use that state to create a table ops instance? -- 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]
