Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private void configRoutes( final Javalin http ) {

http.get( PREFIX + "/getPageList", ctx -> ctx.result( cm.getWebUiPageList() ) );

http.post( PREFIX + "/getConfig", ctx -> ctx.result( cm.getConfig( ctx.body() ).toJson() ) );

// get Ui of certain page
http.post( PREFIX + "/getPage", ctx -> {
//input: req: {pageId: 123}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class AbstractAdapterSetting {
public List<String> filenames = new ArrayList<>();


public AbstractAdapterSetting( final AdapterSettingType type, final String name, final boolean canBeNull, final String subOf, final boolean required, final boolean modifiable, List<DeploySetting> appliesTo, String defaultValue, int position ) {
public AbstractAdapterSetting( final AdapterSettingType type, final String name, final boolean canBeNull, final String subOf, final boolean required, final boolean modifiable, List<DeploySetting> appliesTo, String defaultValue, int position, String description ) {
this.type = type;
this.name = name;
this.canBeNull = canBeNull;
Expand All @@ -68,6 +68,7 @@ public AbstractAdapterSetting( final AdapterSettingType type, final String name,
this.position = position;
this.appliesTo = appliesTo;
this.defaultValue = defaultValue;
this.description = (description == null || description.isEmpty()) ? null : description;
assert this.subOf == null || this.subOf.split( "_" ).length == 2
: "SubOf needs to be null or has to be separated by \"_\" and requires link and value due to limitation in Java";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
public class AbstractAdapterSettingBoolean extends AbstractAdapterSetting {


public AbstractAdapterSettingBoolean( String name, boolean canBeNull, String subOf, boolean required, boolean modifiable, boolean defaultValue, List<DeploySetting> modes, int position ) {
super( AdapterSettingType.BOOLEAN, name, canBeNull, subOf, required, modifiable, modes, String.valueOf( defaultValue ), position );
public AbstractAdapterSettingBoolean( String name, boolean canBeNull, String subOf, boolean required, boolean modifiable, boolean defaultValue, List<DeploySetting> modes, int position, String description ) {
super( AdapterSettingType.BOOLEAN, name, canBeNull, subOf, required, modifiable, modes, String.valueOf( defaultValue ), position, description );
}


Expand All @@ -38,7 +38,9 @@ public static AbstractAdapterSettingBoolean fromAnnotation( AdapterSettingBoolea
annotation.modifiable(),
annotation.defaultValue(),
Arrays.asList( annotation.appliesTo() ),
annotation.position() );
annotation.position(),
annotation.description()
);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class AbstractAdapterSettingDirectory extends AbstractAdapterSetting {
public transient final Map<String, InputStream> inputStreams;


public AbstractAdapterSettingDirectory( String name, String defaultValue, boolean canBeNull, String subOf, boolean required, boolean modifiable, List<DeploySetting> modes, int position ) {
super( AdapterSettingType.DIRECTORY, name, canBeNull, subOf, required, modifiable, modes, defaultValue, position );
public AbstractAdapterSettingDirectory( String name, String defaultValue, boolean canBeNull, String subOf, boolean required, boolean modifiable, List<DeploySetting> modes, int position, String description ) {
super( AdapterSettingType.DIRECTORY, name, canBeNull, subOf, required, modifiable, modes, defaultValue, position, description );
//so it will be serialized
this.directory = "";
this.inputStreams = new HashMap<>();
Expand All @@ -54,7 +54,8 @@ public static AbstractAdapterSetting fromAnnotation( AdapterSettingDirectory ann
annotation.required(),
annotation.modifiable(),
Arrays.asList( annotation.appliesTo() ),
annotation.position()
annotation.position(),
annotation.description()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

public class AbstractAdapterSettingInteger extends AbstractAdapterSetting {

public AbstractAdapterSettingInteger( String name, boolean canBeNull, String subOf, boolean required, boolean modifiable, Integer defaultValue, List<DeploySetting> modes, int position ) {
super( AdapterSettingType.INTEGER, name, canBeNull, subOf, required, modifiable, modes, defaultValue.toString(), position );
public AbstractAdapterSettingInteger( String name, boolean canBeNull, String subOf, boolean required, boolean modifiable, Integer defaultValue, List<DeploySetting> modes, int position, String description ) {
super( AdapterSettingType.INTEGER, name, canBeNull, subOf, required, modifiable, modes, defaultValue.toString(), position, description );
}


Expand All @@ -37,7 +37,9 @@ public static AbstractAdapterSetting fromAnnotation( AdapterSettingInteger annot
annotation.modifiable(),
annotation.defaultValue(),
Arrays.asList( annotation.appliesTo() ),
annotation.position() );
annotation.position(),
annotation.description()
);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class AbstractAdapterSettingList extends AbstractAdapterSetting {
public boolean dynamic = false;


public AbstractAdapterSettingList( String name, boolean canBeNull, final String subOf, boolean required, boolean modifiable, List<String> options, List<DeploySetting> appliesTo, String defaultValue, int position ) {
super( AdapterSettingType.LIST, name, canBeNull, subOf, required, modifiable, appliesTo, defaultValue, position );
public AbstractAdapterSettingList( String name, boolean canBeNull, final String subOf, boolean required, boolean modifiable, List<String> options, List<DeploySetting> appliesTo, String defaultValue, int position, String description ) {
super( AdapterSettingType.LIST, name, canBeNull, subOf, required, modifiable, appliesTo, defaultValue, position, description );
this.options = options;
}

Expand All @@ -45,7 +45,9 @@ public static AbstractAdapterSetting fromAnnotation( AdapterSettingList annotati
Arrays.asList( annotation.options() ),
Arrays.asList( annotation.appliesTo() ),
annotation.defaultValue(),
annotation.position() );
annotation.position(),
annotation.description()
);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
public class AbstractAdapterSettingString extends AbstractAdapterSetting {


public AbstractAdapterSettingString( String name, boolean canBeNull, String subOf, boolean required, boolean modifiable, String defaultValue, List<DeploySetting> modes, int position ) {
super( AdapterSettingType.STRING, name, canBeNull, subOf, required, modifiable, modes, defaultValue, position );
public AbstractAdapterSettingString( String name, boolean canBeNull, String subOf, boolean required, boolean modifiable, String defaultValue, List<DeploySetting> modes, int position, String description ) {
super( AdapterSettingType.STRING, name, canBeNull, subOf, required, modifiable, modes, defaultValue, position, description );
}


Expand All @@ -38,7 +38,9 @@ public static AbstractAdapterSetting fromAnnotation( AdapterSettingString annota
annotation.modifiable(),
annotation.defaultValue(),
Arrays.asList( annotation.appliesTo() ),
annotation.position() );
annotation.position(),
annotation.description()
);
}


Expand Down
11 changes: 5 additions & 6 deletions core/src/main/java/org/polypheny/db/adapter/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,18 @@ protected void validateSettings( Map<String, String> newSettings, boolean initia
.toList().contains( deployMode ) ) {
continue;
}
if ( !initialSetup && settings.containsKey( s.name ) && settings.get( s.name ).equals( s.getValue() ) ) {
// we can leave the setting as it is
return;
}

if ( newSettings.containsKey( s.name ) ) {
String newValue = newSettings.get( s.name );
if ( s.modifiable || initialSetup ) {
String newValue = newSettings.get( s.name );
if ( !s.canBeNull && newValue == null ) {
throw new GenericRuntimeException( "Setting \"" + s.name + "\" cannot be null." );
}
} else {
throw new GenericRuntimeException( "Setting \"" + s.name + "\" cannot be modified." );
assert settings != null;
if ( !newValue.equals( settings.get( s.name ) ) ) {
throw new GenericRuntimeException( "Setting \"" + s.name + "\" cannot be modified." );
}
}
} else if ( s.required && initialSetup ) {
throw new GenericRuntimeException( "Setting \"" + s.name + "\" must be present." );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class BindableAbstractAdapterSettingsList<T extends ConfigObject> extends


public BindableAbstractAdapterSettingsList( String name, String nameAlias, boolean canBeNull, String subOf, boolean required, boolean modifiable, List<T> options, List<DeploySetting> appliesTo, Function<T, String> mapper, Class<T> clazz ) {
super( name, canBeNull, subOf, required, modifiable, options.stream().map( el -> String.valueOf( el.getId() ) ).toList(), appliesTo, null, 1000 );
super( name, canBeNull, subOf, required, modifiable, options.stream().map( el -> String.valueOf( el.getId() ) ).toList(), appliesTo, null, 1000, null );
this.mapper = mapper;
this.clazz = clazz;
this.dynamic = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void rebuild( final Transaction transaction ) {
final PolyImplementation implementation = processor.prepareQuery( AlgRoot.of( scan, Kind.SELECT ), false );
// Execute query

ResultIterator iterator = implementation.execute( statement, 1, true, false, true );
ResultIterator iterator = implementation.execute( statement, 1, statement.isAnalyze(), false, true );
final List<List<PolyValue>> rows = iterator.getAllRowsAndClose();

final List<Pair<List<PolyValue>, List<PolyValue>>> kv = new ArrayList<>( rows.size() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static List<AbstractAdapterSetting> getAllSettings( Class<? extends Adapt
if ( Arrays.stream( properties.usedModes() ).anyMatch( m -> m == DeployMode.DOCKER ) ) {
String instanceId = DockerManager.getInstance().getDockerInstances().keySet().stream().findFirst().orElse( 0 ).toString();
List<String> ids = DockerManager.getInstance().getDockerInstances().keySet().stream().map( Object::toString ).toList();
settings.add( new AbstractAdapterSettingList( "instanceId", false, null, true, false, ids, List.of( DeploySetting.DOCKER ), instanceId, 0 ) );
settings.add( new AbstractAdapterSettingList( "instanceId", false, null, true, false, ids, List.of( DeploySetting.DOCKER ), instanceId, 0, null ) );
}
return settings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.catalog.logistic.Pattern;
import org.polypheny.db.catalog.snapshot.LogicalDocSnapshot;
import org.polypheny.db.util.Pair;

@Slf4j
@EqualsAndHashCode
public class LogicalDocSnapshotImpl implements LogicalDocSnapshot {

private final ImmutableMap<Long, LogicalNamespace> namespaces;
private final ImmutableMap<Long, LogicalCollection> collections;
private final ImmutableMap<String, LogicalCollection> collectionNames;
private final ImmutableMap<Pair<Long, String>, LogicalCollection> collectionNames;
private final ImmutableMap<Long, List<LogicalCollection>> namespaceCollections;


Expand All @@ -48,7 +49,7 @@ public LogicalDocSnapshotImpl( Map<Long, LogicalDocumentCatalog> catalogs ) {
this.collections = ImmutableMap.copyOf( catalogs.values().stream().flatMap( c -> c.getCollections().values().stream() ).collect( Collectors.toMap( c -> c.id, c -> c ) ) );
this.collectionNames = ImmutableMap.copyOf( this.collections.values().stream().collect(
Collectors.toMap(
c -> c.name,
c -> Pair.of( c.namespaceId, c.name ),
c -> c,
( existing, replacement ) -> {
throw new GenericRuntimeException( "A collection of documents called '" + existing.name + "' already exists." );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
import org.polypheny.db.algebra.enumerable.RexToLixTranslator.InputGetterImpl;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.config.RuntimeConfig;
import org.polypheny.db.information.InformationCode;
import org.polypheny.db.information.InformationGroup;
import org.polypheny.db.information.InformationManager;
import org.polypheny.db.information.InformationPage;
import org.polypheny.db.prepare.JavaTypeFactoryImpl;
import org.polypheny.db.rex.RexBuilder;
import org.polypheny.db.rex.RexNode;
Expand Down Expand Up @@ -148,15 +144,8 @@ static Scalar baz( ParameterExpression context_, ParameterExpression outputValue
if ( RuntimeConfig.DEBUG.getBoolean() ) {
Util.debugCode( System.out, s );
}
if ( dataContext != null && dataContext.getStatement() != null && dataContext.getStatement().getTransaction().isAnalyze() ) {
InformationManager queryAnalyzer = dataContext.getStatement().getTransaction().getQueryAnalyzer();
InformationPage page = new InformationPage( "Generated Code" );
page.fullWidth();
InformationGroup group = new InformationGroup( page, "Generated Code" );
queryAnalyzer.addPage( page );
queryAnalyzer.addGroup( group );
InformationCode informationCode = new InformationCode( group, s );
queryAnalyzer.registerInformation( informationCode );
if ( dataContext != null && dataContext.getStatement() != null && dataContext.getStatement().isAnalyze() ) {
dataContext.getStatement().getAnalyzer().registerGeneratedCode( s );
}
try {
return getScalar( classDeclaration, s );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public List<ImplementationContext> anyPrepareQuery( QueryContext context, Transa
public List<ImplementationContext> anyPrepareQuery( QueryContext context, Statement statement ) {
Transaction transaction = statement.getTransaction();
if ( transaction.isAnalyze() ) {
context.getInformationTarget().accept( statement.getTransaction().getQueryAnalyzer() );
transaction.getQueryAnalyzer().visitInformationTarget( context.getInformationTarget() );
}

List<ParsedQueryContext> parsedQueries;
Expand All @@ -119,7 +119,7 @@ public List<ImplementationContext> anyPrepareQuery( QueryContext context, Statem
parsedQueries = context.getLanguage().parser().apply( context );
} catch ( Throwable e ) {
if ( transaction.isAnalyze() ) {
transaction.getQueryAnalyzer().attachStacktrace( e );
statement.getAnalyzer().registerException( e );
}
cancelTransaction( transaction, String.format( "Error on preparing query: %s", e.getMessage() ) );
context.removeTransaction( transaction );
Expand All @@ -145,7 +145,8 @@ public List<ImplementationContext> anyPrepareQuery( QueryContext context, Statem
if ( i != 0 ) {
// as long as we directly commit the transaction, we cannot reuse the same transaction
if ( previousDdl && !transaction.isActive() ) {
transaction = parsed.getTransactionManager().startTransaction( transaction.getUser().id, transaction.getDefaultNamespace().id, transaction.isAnalyze(), transaction.getOrigin() );
// Use the query analyzer of the old transaction
transaction = parsed.getTransactionManager().startTransaction( transaction.getUser().id, transaction.getDefaultNamespace().id, transaction.getQueryAnalyzer(), transaction.getOrigin() );
parsed.addTransaction( transaction );
}
statement = transaction.createStatement();
Expand Down Expand Up @@ -219,7 +220,7 @@ public List<ImplementationContext> anyPrepareQuery( QueryContext context, Statem
}

if ( transaction.isAnalyze() ) {
transaction.getQueryAnalyzer().attachStacktrace( e );
statement.getAnalyzer().registerException( e );
}
if ( e instanceof DeadlockException ) {
cancelTransaction( transaction, null );
Expand All @@ -238,7 +239,7 @@ public List<ImplementationContext> anyPrepareQuery( QueryContext context, Statem
@NotNull
private static List<ImplementationContext> handleParseException( Statement statement, ParsedQueryContext parsed, Transaction transaction, Exception e, List<ImplementationContext> implementationContexts ) {
if ( transaction.isAnalyze() ) {
transaction.getQueryAnalyzer().attachStacktrace( e );
statement.getAnalyzer().registerException( e );
}
implementationContexts.add( ImplementationContext.ofError( e, parsed, statement ) );
return implementationContexts;
Expand Down Expand Up @@ -270,7 +271,7 @@ public List<ExecutedContext> anyQuery( QueryContext context ) {
} catch ( Throwable e ) {
Transaction transaction = implementation.getStatement().getTransaction();
if ( transaction.isAnalyze() && implementation.getException().isEmpty() ) {
transaction.getQueryAnalyzer().attachStacktrace( e );
implementation.getStatement().getAnalyzer().registerException( e );
}
cancelTransaction( transaction, e.getMessage() );

Expand Down Expand Up @@ -301,7 +302,7 @@ private List<ImplementationContext> implementTranslatedQuery( Statement statemen
return List.of( new ImplementationContext( implementation, translated, statement, null ) );
} catch ( Throwable e ) {
if ( transaction.isAnalyze() ) {
transaction.getQueryAnalyzer().attachStacktrace( e );
statement.getAnalyzer().registerException( e );
}
if ( !(e instanceof DeadlockException) ) {
// we only log unexpected cases with stacktrace
Expand Down
Loading
Loading