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


##########
core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java:
##########
@@ -337,4 +394,67 @@ protected String tableName() {
       return tableIdentifier.toString();
     }
   }
+
+  private class InMemoryViewOperations extends BaseViewOperations {
+    private final FileIO fileIO;
+    private final TableIdentifier identifier;
+
+    InMemoryViewOperations(FileIO fileIO, TableIdentifier identifier) {
+      this.fileIO = fileIO;
+      this.identifier = identifier;
+    }
+
+    @Override
+    public void doRefresh() {
+      String latestLocation = views.get(identifier);
+      if (latestLocation == null) {
+        disableRefresh();
+      } else {
+        refreshFromMetadataLocation(latestLocation);
+      }
+    }
+
+    @Override
+    public void doCommit(ViewMetadata base, ViewMetadata metadata) {
+      String newLocation = writeNewMetadata(metadata, currentVersion() + 1);
+      String oldLocation = base == null ? null : currentMetadataLocation();
+
+      if (null == base && !namespaceExists(identifier.namespace())) {
+        throw new NoSuchNamespaceException(
+            "Cannot create view %s. Namespace does not exist: %s",
+            identifier, identifier.namespace());
+      }
+
+      if (tables.containsKey(identifier)) {
+        throw new AlreadyExistsException("Table with same name already exists: 
%s", viewName());

Review Comment:
   There is no equivalent check in `TableOperations` above. I think that's 
needed.
   
   Also, using two maps (`tables` and `views`) introduces a race condition 
between this check and the `views.compute` below. In order for this class to be 
thread safe (and I think it needs to be) this should have a `synchronized` 
block when checking and modifying catalog state.



-- 
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-unsubscr...@iceberg.apache.org

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


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

Reply via email to