Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/polypheny/Polypheny-DB in…
Browse files Browse the repository at this point in the history
…to proto-interface
  • Loading branch information
datomo committed Apr 9, 2024
2 parents 3872b19 + 250079c commit dc34179
Show file tree
Hide file tree
Showing 302 changed files with 5,550 additions and 3,388 deletions.
12 changes: 0 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ ij_csv_keep_indents_on_empty_lines = true
ij_csv_wrap_long_lines = false

[*.feature]
indent_size = 2
ij_continuation_indent_size = 8
ij_visual_guides = none
ij_gherkin_keep_indents_on_empty_lines = false
Expand Down Expand Up @@ -315,7 +314,6 @@ ij_java_wrap_first_method_in_call_chain = false
ij_java_wrap_long_lines = false

[*.less]
indent_size = 2
ij_continuation_indent_size = 8
ij_visual_guides = none
ij_less_align_closing_brace_with_properties = false
Expand All @@ -340,8 +338,6 @@ ij_less_use_double_quotes = true
ij_less_value_alignment = 0

[*.proto]
indent_size = 2
tab_width = 2
ij_visual_guides = none
ij_protobuf_keep_blank_lines_in_code = 2
ij_protobuf_keep_indents_on_empty_lines = false
Expand All @@ -353,8 +349,6 @@ ij_protobuf_spaces_within_braces = false
ij_protobuf_spaces_within_brackets = false

[*.sass]
indent_size = 2
tab_width = 2
ij_visual_guides = none
ij_sass_align_closing_brace_with_properties = false
ij_sass_blank_lines_around_nested_selector = 1
Expand All @@ -377,8 +371,6 @@ ij_sass_use_double_quotes = true
ij_sass_value_alignment = 0

[*.scss]
indent_size = 2
tab_width = 2
ij_visual_guides = none
ij_scss_align_closing_brace_with_properties = false
ij_scss_blank_lines_around_nested_selector = 1
Expand Down Expand Up @@ -433,8 +425,6 @@ ij_xml_text_wrap = normal
ij_xml_use_custom_settings = false

[{*.bash,*.sh,*.zsh}]
indent_size = 2
tab_width = 2
ij_visual_guides = none
ij_shell_binary_ops_start_line = false
ij_shell_keep_column_alignment_padding = false
Expand Down Expand Up @@ -812,8 +802,6 @@ ij_markdown_wrap_text_if_long = true
ij_markdown_wrap_text_inside_blockquotes = true

[{*.pb,*.textproto}]
indent_size = 2
tab_width = 2
ij_visual_guides = none
ij_prototext_keep_blank_lines_in_code = 2
ij_prototext_keep_indents_on_empty_lines = false
Expand Down
5 changes: 2 additions & 3 deletions config/src/main/java/org/polypheny/db/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 The Polypheny Project
* Copyright 2019-2024 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -959,8 +959,7 @@ protected void notifyConfigListeners() {
boolean validate( final Object i ) {
if ( this.validationMethod != null ) {
return this.validationMethod.validate( i );
} //else if (this.validationMethod == null ) {
else {
} else {
return true;
}
}
Expand Down
8 changes: 5 additions & 3 deletions config/src/main/java/org/polypheny/db/config/Feedback.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 The Polypheny Project
* Copyright 2019-2024 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,12 +17,14 @@
package org.polypheny.db.config;

import lombok.AllArgsConstructor;
import lombok.Value;

@AllArgsConstructor
@Value
public class Feedback {

public final boolean successful;
public final String message;
public boolean successful;
public String message;


public static Feedback of( boolean successful ) {
Expand Down
184 changes: 101 additions & 83 deletions config/src/main/java/org/polypheny/db/webui/ConfigService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.javalin.Javalin;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -78,102 +79,119 @@ private void configRoutes( final Javalin http ) {
// Save changes from WebUi
http.post( PREFIX + "/updateConfigs", ctx -> {
log.trace( ctx.body() );
TypeReference<Map<String, Object>> typeRef = new TypeReference<>() {
};
Map<String, Object> changes = mapper.convertValue( ctx.body(), typeRef );
HashMap<String, Object> changes = mapper.readValue( ctx.body(), new TypeReference<>() { // we need explicit typing to force the correct map type
} );
StringBuilder feedback = new StringBuilder();
boolean allValid = true;
for ( Map.Entry<String, Object> entry : changes.entrySet() ) {
Config c = cm.getConfig( entry.getKey() );
switch ( c.getConfigType() ) {
case "ConfigInteger":
Double d = (Double) entry.getValue();
if ( !c.setInt( d.intValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigDouble":
if ( !c.setDouble( (double) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigDecimal":
if ( !c.setDecimal( (BigDecimal) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigLong":
if ( !c.setLong( (long) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
case "ConfigString":
if ( !c.setString( (String) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigBoolean":
if ( !c.setBoolean( (boolean) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigClazz":
case "ConfigEnum":
if ( !c.parseStringAndSetValue( (String) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigClazzList":
case "ConfigEnumList":
try {
if ( !c.parseStringAndSetValue( mapper.writeValueAsString( entry.getValue() ) ) ) {
allValid = false;
appendError( feedback, entry, c );
}
} catch ( JsonProcessingException e ) {
allValid = false;
appendError( feedback, entry, c );
}

break;
case "ConfigList":
Feedback res = c.setConfigObjectList( (List<Object>) entry.getValue(), c.getTemplateClass() );
if ( !res.successful ) {
allValid = false;
if ( res.message.trim().isEmpty() ) {
appendError( feedback, entry, c );
} else {
feedback.append( "Could not set " )
.append( c.getKey() )
.append( " due to: " )
.append( res.message )
.append( " " );
}

}
break;
default:
allValid = false;
feedback.append( "Config with type " ).append( c.getConfigType() ).append( " is not supported yet." );
log.error( "Config with type {} is not supported yet.", c.getConfigType() );
try {
allValid = trySetConfig( entry, cm, allValid, feedback );
} catch ( Exception e ) {
allValid = false;
feedback.append( "Could not set " )
.append( entry.getKey() )
.append( " to " )
.append( entry.getValue() )
.append( " because of: " )
.append( e.getMessage() )
.append( " " );
}

}
if ( allValid ) {
ctx.result( "{\"success\":1}" );
ctx.json( new Feedback( true, "All values were saved." ) );
} else {
feedback.append( "All other values were saved." );
ctx.result( "{\"warning\": \"" + feedback + "\"}" );
ctx.json( new Feedback( false, feedback.toString() ) );
}
} );
}


private boolean trySetConfig( Entry<String, Object> entry, ConfigManager cm, boolean allValid, StringBuilder feedback ) {
Config c = cm.getConfig( entry.getKey() );
switch ( c.getConfigType() ) {
case "ConfigInteger":
Double d = (Double) entry.getValue();
if ( !c.setInt( d.intValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigDouble":
if ( !c.setDouble( (double) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigDecimal":
if ( !c.setDecimal( (BigDecimal) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigLong":
if ( !c.setLong( (long) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
case "ConfigString":
if ( !c.setString( (String) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigBoolean":
if ( !c.setBoolean( (boolean) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigClazz":
case "ConfigEnum":
if ( !c.parseStringAndSetValue( (String) entry.getValue() ) ) {
allValid = false;
appendError( feedback, entry, c );
}
break;
case "ConfigClazzList":
case "ConfigEnumList":
try {
if ( !c.parseStringAndSetValue( mapper.writeValueAsString( entry.getValue() ) ) ) {
allValid = false;
appendError( feedback, entry, c );
}
} catch ( JsonProcessingException e ) {
allValid = false;
appendError( feedback, entry, c );
}

break;
case "ConfigList":
Feedback res = c.setConfigObjectList( (List<Object>) entry.getValue(), c.getTemplateClass() );
if ( !res.successful ) {
allValid = false;
if ( res.message.trim().isEmpty() ) {
appendError( feedback, entry, c );
} else {
feedback.append( "Could not set " )
.append( c.getKey() )
.append( " due to: " )
.append( res.message )
.append( " " );
}

}
break;
default:
allValid = false;
feedback.append( "Config with type " ).append( c.getConfigType() ).append( " is not supported yet." );
log.error( "Config with type {} is not supported yet.", c.getConfigType() );
}
return allValid;
}


private static void appendError( StringBuilder feedback, Entry<String, Object> entry, Config c ) {
feedback.append( "Could not set " )
.append( c.getKey() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public abstract class AbstractAdapterSetting {
@Getter
public List<DeploySetting> appliesTo;

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 ) {
this.type = type;
Expand All @@ -79,7 +81,7 @@ public AbstractAdapterSetting( final AdapterSettingType type, final String name,
*
* @param annotations collection of annotations
* @param properties which are defined by the corresponding Adapter
* @return a map containing the available modes and the corresponding collections of AdapterSettings
* @return a collection containing the available modes and the corresponding collections of AdapterSettings
*/
public static List<AbstractAdapterSetting> fromAnnotations( Annotation[] annotations, AdapterProperties properties ) {
List<AbstractAdapterSetting> settings = new ArrayList<>();
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/polypheny/db/adapter/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public abstract class Adapter<ACatalog extends AdapterCatalog> implements Scanna
private final AdapterProperties properties;
protected final DeployMode deployMode;
protected String deploymentId;
@Getter
private final String adapterName;
public final String adapterName;
public final ACatalog adapterCatalog;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ public ImmutableMap<String, DataSource<?>> getSources() {
}





public Adapter<?> addAdapter( String adapterName, String uniqueName, AdapterType adapterType, DeployMode mode, Map<String, String> settings ) {
uniqueName = uniqueName.toLowerCase();
if ( getAdapters().containsKey( uniqueName ) ) {
Expand Down Expand Up @@ -209,7 +206,9 @@ public void removeAdapter( long adapterId ) {
// Check if the store has any placements
List<AllocationEntity> placements = Catalog.getInstance().getSnapshot().alloc().getEntitiesOnAdapter( logicalAdapter.id ).orElseThrow( () -> new GenericRuntimeException( "There is still data placed on this data store" ) );
if ( !placements.isEmpty() ) {
throw new GenericRuntimeException( "There is still data placed on this data store" );
if ( adapterInstance instanceof DataStore<?> ) {
throw new GenericRuntimeException( "There is still data placed on this data store" );
}
}

// Shutdown store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ public List<PhysicalEntity> createTable( Context context, LogicalTableWrapper lo


@Override
public void restoreTable( AllocationTable alloc, List<PhysicalEntity> entities ) {
scannable.restoreTable( alloc, entities );
public void restoreTable( AllocationTable alloc, List<PhysicalEntity> entities, Context context ) {
scannable.restoreTable( alloc, entities, context );
}


@Override
public void restoreGraph( AllocationGraph alloc, List<PhysicalEntity> entities ) {
Scannable.restoreGraphSubstitute( scannable, alloc, entities );
public void restoreGraph( AllocationGraph alloc, List<PhysicalEntity> entities, Context context ) {
Scannable.restoreGraphSubstitute( scannable, alloc, entities, context );
}



@Override
public void restoreCollection( AllocationCollection alloc, List<PhysicalEntity> entities ) {
scannable.restoreCollection( alloc, entities );
public void restoreCollection( AllocationCollection alloc, List<PhysicalEntity> entities, Context context ) {
scannable.restoreCollection( alloc, entities, context );
}


Expand All @@ -93,6 +92,7 @@ public AlgNode getGraphScan( long allocId, AlgBuilder builder ) {
return Scannable.getGraphScanSubstitute( scannable, allocId, builder );
}


@Override
public List<PhysicalEntity> createCollection( Context context, LogicalCollection logical, AllocationCollection allocation ) {
return scannable.createCollection( context, logical, allocation );
Expand Down
Loading

0 comments on commit dc34179

Please sign in to comment.