Skip to content

Commit

Permalink
refactor remove portal or prepared statement
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal committed Jan 31, 2024
1 parent f8a538f commit 17c925e
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,14 @@ public void close(byte type, String name)
});
break;
case 'S':
PreparedStatement preparedStatement = preparedStatements.remove(name);
if (preparedStatement != null) {
Optional.ofNullable(preparedStatements.get(name)).ifPresent(preparedStatement -> {
preparedStatements.remove(name);
List<String> removedNames = portals.entrySet().stream()
.filter(entry -> entry.getValue().getPreparedStatement().getName().equals(preparedStatement.getName()))
.map(Map.Entry::getKey).collect(toImmutableList());
removedNames.forEach(portals::remove);
removedNames.forEach(portalName -> metadataQueries.remove(preparedStmtPortalName(name, portalName)));
}
});
break;
default:
throw new AccioException(INVALID_PARAMETER_USAGE, format("Type %s is invalid. We only support 'P' and 'S'", type));
Expand All @@ -522,12 +522,12 @@ public PreparedStatement put(String key, PreparedStatement value)
return delegate.put(key, value);
}

public PreparedStatement remove(String key)
public void remove(String key)
{
if (key.isEmpty()) {
return delegate.remove(PreparedStatement.RESERVED_PREPARE_NAME);
delegate.remove(PreparedStatement.RESERVED_PREPARE_NAME);
}
return delegate.remove(key);
delegate.remove(key);
}

public boolean containsKey(String key)
Expand Down Expand Up @@ -564,10 +564,10 @@ public Portal put(String key, Portal value)
return delegate.put(key, value);
}

public Portal remove(String key)
public void remove(String key)
{
close(key);
return delegate.remove(key);
delegate.remove(key);
}

public boolean containsKey(String key)
Expand Down

0 comments on commit 17c925e

Please sign in to comment.