You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/08/07 23:01:29 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #5407: Core: Add RESTScanReporter to send scan report to REST endpoint

rdblue commented on code in PR #5407:
URL: https://github.com/apache/iceberg/pull/5407#discussion_r939733771


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -284,7 +280,9 @@ public Table loadTable(SessionContext context, TableIdentifier identifier) {
             tableFileIO(response.config()),
             response.tableMetadata());
 
-    BaseTable table = new BaseTable(ops, fullTableName(loadedIdent), this.scanReporter);
+    BaseTable table =
+        new BaseTable(
+            ops, fullTableName(loadedIdent), new RESTScanReporter(client, paths, headers(context)));

Review Comment:
   Rather than having a separate class that gets passed the `RESTClient`, what about just using lambda that calls a method in `RESTSessionCatalog`?
   
   ```java
     BaseTable table = new BaseTable(ops, fullTableName(loadedIdent), report -> reportScan(report, session::headers));
     ...
   
     private void reportScan(ScanReport report, Supplier<Map<String, String>> headers) {
       client.post(
           paths.scanReport(),
           ScanReportRequest.builder().fromScanReport(report).build(),
           null,
           headers,
           ErrorHandlers.defaultErrorHandler());
     }
   ```
   
   That leaks fewer internals of the catalog (like `ResourcePaths`) to other objects.
   
   I'd also use `session::headers` rather than `headers(context)` because that avoids going through the session cache. We already have the `AuthSession` loaded and we also don't want to worry about session expiration.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org