Skip to content

Commit

Permalink
fix for MonetdbStore
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Nov 27, 2023
1 parent ef69fde commit b5c21cc
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.polypheny.db.util;

public enum PolyphenyMode {
public enum PolyMode {
PRODUCTION,
DEVELOPMENT,
TEST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class PolyphenyHomeDirManager {
private File root;
private final List<File> dirs = new ArrayList<>();
private final List<File> deleteOnExit = new ArrayList<>();
private static PolyphenyMode mode;
private static PolyMode mode;


public static PolyphenyHomeDirManager getInstance() {
Expand Down Expand Up @@ -77,7 +77,7 @@ private PolyphenyHomeDirManager() {
}


public static PolyphenyHomeDirManager setModeAndGetInstance( PolyphenyMode mode ) {
public static PolyphenyHomeDirManager setModeAndGetInstance( PolyMode mode ) {
if ( PolyphenyHomeDirManager.mode != null ) {
throw new RuntimeException( "Could not set the mode." );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.polypheny.db.schema.types.ScannableEntity;
import org.polypheny.db.schema.types.StreamableEntity;
import org.polypheny.db.util.BuiltInMethod;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;


/**
Expand Down Expand Up @@ -256,7 +256,7 @@ public Result implement( EnumerableAlgImplementor implementor, Prefer pref ) {

@Override
public AlgOptCost computeSelfCost( AlgOptPlanner planner, AlgMetadataQuery mq ) {
if ( Catalog.mode == PolyphenyMode.TEST ) {
if ( Catalog.mode == PolyMode.TEST ) {
// normally this enumerable is not used by Polypheny and is therefore "removed" by an infinite cost,
// but theoretically it is able to handle scans on the application layer
// this is tested by different instances and should then lead to a finite selfCost
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/polypheny/db/catalog/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.polypheny.db.catalog.logistic.DataModel;
import org.polypheny.db.catalog.snapshot.Snapshot;
import org.polypheny.db.iface.QueryInterfaceManager.QueryInterfaceTemplate;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;

public abstract class Catalog implements ExtensionPoint {

Expand All @@ -69,7 +69,7 @@ public abstract class Catalog implements ExtensionPoint {
private static Catalog INSTANCE = null;
public static boolean resetCatalog;
public static boolean memoryCatalog;
public static PolyphenyMode mode;
public static PolyMode mode;

public static final Expression CATALOG_EXPRESSION = Expressions.call( Catalog.class, "getInstance" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.config.RuntimeConfig;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;

/**
* The container is the main interaction instance for calling classes when interacting with Docker.
Expand Down Expand Up @@ -127,7 +127,7 @@ public int execute( List<String> cmd ) throws IOException {
public static String getPhysicalUniqueName( String uniqueName ) {
// while not all Docker containers belong to an adapter we annotate it anyway
String name = "polypheny_" + RuntimeConfig.INSTANCE_UUID.getString() + "_" + uniqueName;
if ( Catalog.mode != PolyphenyMode.TEST ) {
if ( Catalog.mode != PolyMode.TEST ) {
return name;
}
return name + "_test";
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/polypheny/db/docker/DockerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.polypheny.db.config.ConfigDocker;
import org.polypheny.db.config.ConfigManager;
import org.polypheny.db.config.RuntimeConfig;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;

public final class DockerManager {

Expand All @@ -53,7 +53,7 @@ public static DockerManager getInstance() {

public Optional<DockerInstance> getInstanceById( int instanceId ) {
// Tests expect a localhost docker instance with id 0
if ( Catalog.mode == PolyphenyMode.TEST && instanceId == 0 ) {
if ( Catalog.mode == PolyMode.TEST && instanceId == 0 ) {
return dockerInstances.values().stream().filter( d -> d.getHost().equals( "localhost" ) ).findFirst();
}
return Optional.ofNullable( dockerInstances.get( instanceId ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
import org.polypheny.db.type.entity.PolyInteger;
import org.polypheny.db.type.entity.PolyValue;
import org.polypheny.db.util.Pair;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.util.PolyphenyHomeDirManager;
import org.polypheny.db.util.PolyphenyMode;


public class CowHashIndexTest {

@BeforeClass
public static void init() {
PolyphenyHomeDirManager.setModeAndGetInstance( PolyphenyMode.TEST );
PolyphenyHomeDirManager.setModeAndGetInstance( PolyMode.TEST );
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/java/org/polypheny/db/rex/RexBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
import org.polypheny.db.util.Collation;
import org.polypheny.db.util.DateString;
import org.polypheny.db.util.NlsString;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.util.PolyphenyHomeDirManager;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.TimeString;
import org.polypheny.db.util.TimestampString;
import org.polypheny.db.util.TimestampWithTimeZoneString;
Expand All @@ -72,7 +72,7 @@ public class RexBuilderTest {
@BeforeClass
public static void init() {
try {
PolyphenyHomeDirManager.setModeAndGetInstance( PolyphenyMode.TEST );
PolyphenyHomeDirManager.setModeAndGetInstance( PolyMode.TEST );
} catch ( Exception e ) {
// can fail
}
Expand Down
18 changes: 9 additions & 9 deletions dbms/src/main/java/org/polypheny/db/PolyphenyDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
import org.polypheny.db.transaction.TransactionException;
import org.polypheny.db.transaction.TransactionManager;
import org.polypheny.db.transaction.TransactionManagerImpl;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.util.PolyphenyHomeDirManager;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.view.MaterializedViewManager;
import org.polypheny.db.view.MaterializedViewManagerImpl;
import org.polypheny.db.webui.ConfigService;
Expand Down Expand Up @@ -115,7 +115,7 @@ public class PolyphenyDb {
public boolean memoryCatalog = false;

@Option(name = { "-mode" }, description = "Special system configuration for running tests", typeConverterProvider = PolyModesConverter.class)
public PolyphenyMode mode = PolyphenyMode.PRODUCTION;
public PolyMode mode = PolyMode.PRODUCTION;

@Option(name = { "-gui" }, description = "Show splash screen on startup and add taskbar gui")
public boolean desktopMode = false;
Expand Down Expand Up @@ -184,7 +184,7 @@ public void runPolyphenyDb() {
}

// Configuration shall not be persisted
ConfigManager.memoryMode = (mode == PolyphenyMode.TEST || memoryCatalog);
ConfigManager.memoryMode = (mode == PolyMode.TEST || memoryCatalog);
ConfigManager.resetCatalogOnStartup = resetCatalog;

// Select behavior depending on arguments
Expand Down Expand Up @@ -241,7 +241,7 @@ public void runPolyphenyDb() {
}

// Backup content of Polypheny folder
if ( mode == PolyphenyMode.TEST || memoryCatalog ) {
if ( mode == PolyMode.TEST || memoryCatalog ) {
if ( dirManager.checkIfExists( "_test_backup" ) ) {
throw new GenericRuntimeException( "Unable to backup the Polypheny folder since there is already a backup folder." );
}
Expand Down Expand Up @@ -287,7 +287,7 @@ public void runPolyphenyDb() {
}
}

if ( mode == PolyphenyMode.TEST ) {
if ( mode == PolyMode.TEST ) {
uuid = "polypheny-test";
}

Expand Down Expand Up @@ -410,7 +410,7 @@ public void join( final long millis ) throws InterruptedException {
DdlManager.setAndGetInstance( new DdlManagerImpl( catalog ) );

// Add config and monitoring test page for UI testing
if ( mode == PolyphenyMode.TEST ) {
if ( mode == PolyMode.TEST ) {
new UiTestingConfigPage();
new UiTestingMonitoringPage();
}
Expand Down Expand Up @@ -473,12 +473,12 @@ public void join( final long millis ) throws InterruptedException {

private boolean initializeDockerManager() {
if ( AutoDocker.getInstance().isAvailable() ) {
if ( mode == PolyphenyMode.TEST ) {
if ( mode == PolyMode.TEST ) {
resetDocker = true;
Catalog.resetDocker = true;
}
boolean success = AutoDocker.getInstance().doAutoConnect();
if ( mode == PolyphenyMode.TEST && !success ) {
if ( mode == PolyMode.TEST && !success ) {
// AutoDocker does not work in Windows containers
if ( !System.getenv( "RUNNER_OS" ).equals( "Windows" ) ) {
log.error( "Failed to connect to docker instance" );
Expand Down Expand Up @@ -559,7 +559,7 @@ private Catalog startCatalog() {
private void restore( Authenticator authenticator, Catalog catalog ) {
PolyPluginManager.startUp( transactionManager, authenticator );

if ( !resetCatalog && mode != PolyphenyMode.TEST ) {
if ( !resetCatalog && mode != PolyMode.TEST ) {
Catalog.getInstance().restore();
}
Catalog.getInstance().updateSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import com.github.rvesse.airline.types.TypeConverter;
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;

@Slf4j
public class PolyphenyModesConverter extends DefaultTypeConverter {
public class PolyModesConverter extends DefaultTypeConverter {

@Override
public <T> TypeConverter getTypeConverter( OptionMetadata option, ParseState<T> state ) {
Expand All @@ -44,22 +44,22 @@ public <T> TypeConverter getTypeConverter( ArgumentsMetadata arguments, ParseSta
public Object convert( String name, Class<?> type, String value ) {
String adjustedName = value.toUpperCase();

if ( Arrays.stream( PolyphenyMode.values() ).anyMatch( v -> v.name().equals( adjustedName ) ) ) {
return PolyphenyMode.valueOf( adjustedName.toUpperCase() );
if ( Arrays.stream( PolyMode.values() ).anyMatch( v -> v.name().equals( adjustedName ) ) ) {
return PolyMode.valueOf( adjustedName.toUpperCase() );
}

switch ( adjustedName.toLowerCase() ) {
case "t":
return PolyphenyMode.TEST;
return PolyMode.TEST;
case "b":
case "bench":
return PolyphenyMode.BENCHMARK;
return PolyMode.BENCHMARK;
case "d":
case "dev":
return PolyphenyMode.DEVELOPMENT;
return PolyMode.DEVELOPMENT;
}
log.warn( "Could not find the mode: " + adjustedName );
return PolyphenyMode.PRODUCTION;
return PolyMode.PRODUCTION;
}

}
4 changes: 2 additions & 2 deletions dbms/src/test/java/org/polypheny/db/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import org.polypheny.db.type.entity.PolyString;
import org.polypheny.db.type.entity.PolyValue;
import org.polypheny.db.util.Pair;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.webui.HttpServer;
import org.polypheny.db.webui.models.results.DocResult;
import org.polypheny.db.webui.models.results.GraphResult;
Expand Down Expand Up @@ -95,7 +95,7 @@ private TestHelper() {
log.info( "Starting Polypheny-DB..." );

Runnable runnable = () -> {
polyphenyDb.mode = PolyphenyMode.TEST;
polyphenyDb.mode = PolyMode.TEST;
String defaultStoreName = System.getProperty( "storeId.default" );
if ( defaultStoreName != null ) {
polyphenyDb.defaultStoreName = defaultStoreName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ protected String getTypeString( PolyType type ) {

@Override
public String getDefaultPhysicalNamespaceName() {
return "public" + getAdapterId();
return "public";
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
import org.polypheny.db.type.checker.OperandTypes;
import org.polypheny.db.type.inference.ReturnTypes;
import org.polypheny.db.util.Optionality;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.util.Util;


Expand All @@ -125,7 +125,7 @@
public class PlannerTest extends SqlLanguageDependent {

static {
Catalog.mode = PolyphenyMode.TEST;
Catalog.mode = PolyMode.TEST;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.polypheny.db.tools.Program;
import org.polypheny.db.tools.ValidationException;
import org.polypheny.db.util.Conformance;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.util.SourceStringReader;


Expand All @@ -69,7 +69,7 @@
public class PlannerImplMock implements Planner {

static {
Catalog.mode = PolyphenyMode.TEST;
Catalog.mode = PolyMode.TEST;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import org.polypheny.db.type.PolyType;
import org.polypheny.db.type.entity.PolyValue;
import org.polypheny.db.type.entity.graph.PolyGraph;
import org.polypheny.db.util.PolyphenyMode;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.webui.Crud;
import org.polypheny.db.webui.TemporalFileManager;
import org.polypheny.db.webui.models.IndexModel;
Expand Down Expand Up @@ -399,7 +399,7 @@ public static List<String[]> computeResultData( final List<List<PolyValue>> rows
private static String toJson( @Nullable PolyValue src ) {
return src == null
? null
: Catalog.mode == PolyphenyMode.TEST ? src.toTypedJson() : src.toJson();
: Catalog.mode == PolyMode.TEST ? src.toTypedJson() : src.toJson();
}


Expand Down

0 comments on commit b5c21cc

Please sign in to comment.