Skip to content

Commit

Permalink
Filter settings irrelevant to the current mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Dec 18, 2024
1 parent 3bc470a commit 68e1480
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.linq4j.tree.Expressions;
import org.jetbrains.annotations.NotNull;
import org.polypheny.db.adapter.DeployMode.DeploySetting;
import org.polypheny.db.adapter.annotations.AdapterProperties;
import org.polypheny.db.adapter.java.AdapterTemplate;
import org.polypheny.db.catalog.Catalog;
Expand Down Expand Up @@ -176,6 +177,13 @@ public Adapter<?> addAdapter( String adapterName, String uniqueName, AdapterType

AdapterTemplate adapterTemplate = AdapterTemplate.fromString( adapterName, adapterType );


for ( AbstractAdapterSetting setting : adapterTemplate.settings ) {
if ( setting.appliesTo.stream().noneMatch( s -> s.appliesTo( mode ) ) ) {
settings.remove( setting.name );
}
}

long adapterId = Catalog.getInstance().createAdapter( uniqueName, adapterName, adapterType, settings, mode );
try {
Adapter<?> adapter = adapterTemplate.getDeployer().get( adapterId, uniqueName, settings, mode );
Expand Down
18 changes: 6 additions & 12 deletions core/src/main/java/org/polypheny/db/adapter/DeployMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ public enum DeployMode {
}


public static DeployMode fromString( String mode ) {
if ( mode.equals( "remote" ) ) {
return REMOTE;
} else if ( mode.equals( "docker" ) ) {
return DOCKER;
} else {
return EMBEDDED;
}
}


public enum DeploySetting {
REMOTE( DeployMode.REMOTE ),
DOCKER( DeployMode.DOCKER ),
Expand Down Expand Up @@ -83,5 +72,10 @@ List<DeployMode> getModes( List<DeployMode> availableModes ) {
}
}


boolean appliesTo( DeployMode mode ) {
return usedByAll || this.mode.equals( mode );
}

}
}
}

0 comments on commit 68e1480

Please sign in to comment.