flyrain commented on code in PR #14465:
URL: https://github.com/apache/iceberg/pull/14465#discussion_r2535602320


##########
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&lt;Map&lt;String, String&gt;&gt; headers,
+ *       FileIO io,
+ *       TableMetadata current,
+ *       Set&lt;Endpoint&gt; endpoints) {
+ *     return new CustomRESTTableOperations(client, path, headers, io, 
current, endpoints);
+ *   }
+ *
+ *   {@literal @}Override
+ *   public RESTViewOperations createViewOperations(
+ *       RESTClient client,
+ *       String path,
+ *       Supplier&lt;Map&lt;String, String&gt;&gt; headers,
+ *       ViewMetadata current,
+ *       Set&lt;Endpoint&gt; endpoints) {
+ *     return new CustomRESTViewOperations(client, path, headers, current, 
endpoints);
+ *   }
+ * };
+ *
+ * RESTSessionCatalog catalog = new RESTSessionCatalog(clientBuilder, 
ioBuilder, customFactory);
+ * </pre>
+ */
+public interface RESTOperationsFactory {

Review Comment:
   Thanks @amogh-jahagirdar. I think the factory approach does seems a bit 
awkward, most of the state needed to build custom table operation already lives 
inside RESTSessionCatalog. 
   
   The inheritance-based approach (adding protected newTableOps / newViewOps in 
RESTSessionCatalog and allowing RESTCatalog to accept a custom session catalog) 
seems more idiomatic with the rest of the catalog implementations and keeps the 
extensibility point tighter and easier to maintain.
   
   Not strongly opposed to either direction, but the factory pattern does feel 
less natural here.



-- 
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]

Reply via email to