Skip to content

Commit

Permalink
rename DatabaseChange to PropertyChange
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-024 committed Dec 16, 2024
1 parent 240c30b commit c0e45e5
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade
protected abstract void dropDatabaseImpl(String name);

@Override
public void alterDatabase(String name, List<DatabaseChange> changes, boolean ignoreIfNotExists)
public void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists)
throws DatabaseNotExistException {
checkNotSystemDatabase(name);
try {
Expand All @@ -243,7 +243,7 @@ public void alterDatabase(String name, List<DatabaseChange> changes, boolean ign
}
}

protected abstract void alterDatabaseImpl(String name, List<DatabaseChange> changes)
protected abstract void alterDatabaseImpl(String name, List<PropertyChange> changes)
throws DatabaseNotExistException;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade
}

@Override
public void alterDatabase(String name, List<DatabaseChange> changes, boolean ignoreIfNotExists)
public void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists)
throws DatabaseNotExistException {
super.alterDatabase(name, changes, ignoreIfNotExists);
databaseCache.invalidate(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade)
* Alter a database.
*
* @param name Name of the database to alter.
* @param changes a collection of changes to apply to the database.
* @param changes the property changes
* @param ignoreIfNotExists Flag to specify behavior when the database does not exist: if set to
* false, throw an exception, if set to true, do nothing.
* @throws DatabaseNotExistException if the given database is not exist and ignoreIfNotExists is
* false
*/
void alterDatabase(String name, List<DatabaseChange> changes, boolean ignoreIfNotExists)
void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists)
throws DatabaseNotExistException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade
}

@Override
public void alterDatabase(String name, List<DatabaseChange> changes, boolean ignoreIfNotExists)
public void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists)
throws DatabaseNotExistException {
wrapped.alterDatabase(name, changes, ignoreIfNotExists);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected void dropDatabaseImpl(String name) {
}

@Override
protected void alterDatabaseImpl(String name, List<DatabaseChange> changes) {
protected void alterDatabaseImpl(String name, List<PropertyChange> changes) {
throw new UnsupportedOperationException("Alter database is not supported.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@
import java.util.Set;

/** define change to the database property. */
public interface DatabaseChange {
public interface PropertyChange {

static DatabaseChange setProperty(String property, String value) {
static PropertyChange setProperty(String property, String value) {
return new SetProperty(property, value);
}

static DatabaseChange removeProperty(String property) {
static PropertyChange removeProperty(String property) {
return new RemoveProperty(property);
}

static Pair<Map<String, String>, Set<String>> getSetPropertiesToRemoveKeys(
List<DatabaseChange> changes) {
List<PropertyChange> changes) {
Map<String, String> setProperties = Maps.newHashMap();
Set<String> removeKeys = Sets.newHashSet();
changes.forEach(
change -> {
if (change instanceof DatabaseChange.SetProperty) {
DatabaseChange.SetProperty setProperty =
(DatabaseChange.SetProperty) change;
if (change instanceof PropertyChange.SetProperty) {
PropertyChange.SetProperty setProperty =
(PropertyChange.SetProperty) change;
setProperties.put(setProperty.property(), setProperty.value());
} else {
removeKeys.add(((DatabaseChange.RemoveProperty) change).property());
removeKeys.add(((PropertyChange.RemoveProperty) change).property());
}
});
return Pair.of(setProperties, removeKeys);
}

/** Set property for database change. */
final class SetProperty implements DatabaseChange {
final class SetProperty implements PropertyChange {

private final String property;
private final String value;
Expand All @@ -76,7 +76,7 @@ public String value() {
}

/** Remove property for database change. */
final class RemoveProperty implements DatabaseChange {
final class RemoveProperty implements PropertyChange {

private final String property;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.paimon.catalog.CatalogLockContext;
import org.apache.paimon.catalog.CatalogLockFactory;
import org.apache.paimon.catalog.Database;
import org.apache.paimon.catalog.DatabaseChange;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.catalog.PropertyChange;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
import org.apache.paimon.operation.Lock;
Expand Down Expand Up @@ -204,9 +204,9 @@ protected void dropDatabaseImpl(String name) {
}

@Override
protected void alterDatabaseImpl(String name, List<DatabaseChange> changes) {
protected void alterDatabaseImpl(String name, List<PropertyChange> changes) {
Pair<Map<String, String>, Set<String>> setPropertiesToRemoveKeys =
DatabaseChange.getSetPropertiesToRemoveKeys(changes);
PropertyChange.getSetPropertiesToRemoveKeys(changes);
Map<String, String> setProperties = setPropertiesToRemoveKeys.getLeft();
Set<String> removeKeys = setPropertiesToRemoveKeys.getRight();
Map<String, String> startingProperties = fetchProperties(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package org.apache.paimon.privilege;

import org.apache.paimon.catalog.Catalog;
import org.apache.paimon.catalog.DatabaseChange;
import org.apache.paimon.catalog.DelegateCatalog;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.catalog.PropertyChange;
import org.apache.paimon.options.ConfigOption;
import org.apache.paimon.options.ConfigOptions;
import org.apache.paimon.options.Options;
Expand Down Expand Up @@ -84,7 +84,7 @@ public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade
}

@Override
public void alterDatabase(String name, List<DatabaseChange> changes, boolean ignoreIfNotExists)
public void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists)
throws DatabaseNotExistException {
privilegeManager.getPrivilegeChecker().assertCanAlterDatabase(name);
super.alterDatabase(name, changes, ignoreIfNotExists);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import org.apache.paimon.catalog.Catalog;
import org.apache.paimon.catalog.Database;
import org.apache.paimon.catalog.DatabaseChange;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.catalog.PropertyChange;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
import org.apache.paimon.manifest.PartitionEntry;
Expand Down Expand Up @@ -180,11 +180,11 @@ public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade
}

@Override
public void alterDatabase(String name, List<DatabaseChange> changes, boolean ignoreIfNotExists)
public void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists)
throws DatabaseNotExistException {
try {
Pair<Map<String, String>, Set<String>> setPropertiesToRemoveKeys =
DatabaseChange.getSetPropertiesToRemoveKeys(changes);
PropertyChange.getSetPropertiesToRemoveKeys(changes);
Map<String, String> updateProperties = setPropertiesToRemoveKeys.getLeft();
Set<String> removeKeys = setPropertiesToRemoveKeys.getRight();
AlterDatabaseRequest request =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,8 @@ protected void alterDatabaseWhenSupportAlter() throws Exception {
catalog.alterDatabase(
databaseName,
Lists.newArrayList(
DatabaseChange.setProperty(key, "value"),
DatabaseChange.setProperty(key2, "value")),
PropertyChange.setProperty(key, "value"),
PropertyChange.setProperty(key2, "value")),
false);
Database db = catalog.getDatabase(databaseName);
assertEquals("value", db.options().get(key));
Expand All @@ -982,8 +982,8 @@ protected void alterDatabaseWhenSupportAlter() throws Exception {
catalog.alterDatabase(
databaseName,
Lists.newArrayList(
DatabaseChange.setProperty(key, "value1"),
DatabaseChange.setProperty(key2, "value1")),
PropertyChange.setProperty(key, "value1"),
PropertyChange.setProperty(key2, "value1")),
false);
db = catalog.getDatabase(databaseName);
assertEquals("value1", db.options().get(key));
Expand All @@ -992,7 +992,7 @@ protected void alterDatabaseWhenSupportAlter() throws Exception {
catalog.alterDatabase(
databaseName,
Lists.newArrayList(
DatabaseChange.removeProperty(key), DatabaseChange.removeProperty(key2)),
PropertyChange.removeProperty(key), PropertyChange.removeProperty(key2)),
false);
db = catalog.getDatabase(databaseName);
assertEquals(false, db.options().containsKey(key));
Expand All @@ -1001,7 +1001,7 @@ protected void alterDatabaseWhenSupportAlter() throws Exception {
catalog.alterDatabase(
databaseName,
Lists.newArrayList(
DatabaseChange.removeProperty(key), DatabaseChange.removeProperty(key2)),
PropertyChange.removeProperty(key), PropertyChange.removeProperty(key2)),
false);
db = catalog.getDatabase(databaseName);
assertEquals(false, db.options().containsKey(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.apache.paimon.catalog.CatalogContext;
import org.apache.paimon.catalog.CatalogLockContext;
import org.apache.paimon.catalog.CatalogLockFactory;
import org.apache.paimon.catalog.DatabaseChange;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.catalog.PropertyChange;
import org.apache.paimon.client.ClientPool;
import org.apache.paimon.data.BinaryRow;
import org.apache.paimon.fs.FileIO;
Expand Down Expand Up @@ -409,13 +409,13 @@ protected void dropDatabaseImpl(String name) {
}

@Override
protected void alterDatabaseImpl(String name, List<DatabaseChange> changes) {
protected void alterDatabaseImpl(String name, List<PropertyChange> changes) {
try {
Database database = clients.run(client -> client.getDatabase(name));
Map<String, String> parameter = Maps.newHashMap();
parameter.putAll(database.getParameters());
Pair<Map<String, String>, Set<String>> setPropertiesToRemoveKeys =
DatabaseChange.getSetPropertiesToRemoveKeys(changes);
PropertyChange.getSetPropertiesToRemoveKeys(changes);
Map<String, String> setProperties = setPropertiesToRemoveKeys.getLeft();
Set<String> removeKeys = setPropertiesToRemoveKeys.getRight();
if (setProperties.size() > 0) {
Expand Down

0 comments on commit c0e45e5

Please sign in to comment.