rdblue commented on code in PR #7880:
URL: https://github.com/apache/iceberg/pull/7880#discussion_r1337877698
##########
core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java:
##########
@@ -278,15 +300,73 @@ public List<Namespace> listNamespaces(Namespace
namespace) throws NoSuchNamespac
public void close() throws IOException {
namespaces.clear();
tables.clear();
+ views.clear();
+ }
+
+ @Override
+ public List<TableIdentifier> listViews(Namespace namespace) {
+ if (!namespaceExists(namespace) && !namespace.isEmpty()) {
+ throw new NoSuchNamespaceException(
+ "Cannot list views for namespace. Namespace does not exist: %s",
namespace);
+ }
+
+ return views.keySet().stream()
+ .filter(v -> namespace.isEmpty() || v.namespace().equals(namespace))
+ .sorted(Comparator.comparing(TableIdentifier::toString))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ protected InMemoryViewOperations newViewOps(TableIdentifier identifier) {
+ return new InMemoryViewOperations(io, identifier);
+ }
+
+ @Override
+ public boolean dropView(TableIdentifier identifier) {
+ synchronized (this) {
+ return null != views.remove(identifier);
+ }
+ }
+
+ @Override
+ public void renameView(TableIdentifier from, TableIdentifier to) {
+ if (from.equals(to)) {
+ return;
+ }
+
+ synchronized (this) {
Review Comment:
I don't think this works because `this` refers to the inner class instance
not the outer class instance that is used elsewhere. See
https://stackoverflow.com/questions/18910773/locking-and-synchronization-between-outer-and-inner-class-methods
I think to fix this you need to use `synchronized (InMemoryCatalog.this)
{...}`
--
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]