Skip to content

Commit

Permalink
fixed graph representation, replaced runtimeException,AvaticaExceptio…
Browse files Browse the repository at this point in the history
…ns, Information serialization, name resolution of tables
  • Loading branch information
datomo committed Nov 4, 2023
1 parent 45f13b4 commit 675cfeb
Show file tree
Hide file tree
Showing 97 changed files with 302 additions and 333 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/org/polypheny/db/adapter/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ protected void validateSettings( Map<String, String> newSettings, boolean initia
if ( s.modifiable || initialSetup ) {
String newValue = newSettings.get( s.name );
if ( !s.canBeNull && newValue == null ) {
throw new RuntimeException( "Setting \"" + s.name + "\" cannot be null." );
throw new GenericRuntimeException( "Setting \"" + s.name + "\" cannot be null." );
}
} else {
throw new RuntimeException( "Setting \"" + s.name + "\" cannot be modified." );
throw new GenericRuntimeException( "Setting \"" + s.name + "\" cannot be modified." );
}
} else if ( s.required && initialSetup ) {
throw new RuntimeException( "Setting \"" + s.name + "\" must be present." );
throw new GenericRuntimeException( "Setting \"" + s.name + "\" must be present." );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static long addAdapterTemplate( Class<? extends Adapter<?>> clazz, String
public static void removeAdapterTemplate( long templateId ) {
AdapterTemplate template = Catalog.snapshot().getAdapterTemplate( templateId ).orElseThrow();
if ( Catalog.getInstance().getSnapshot().getAdapters().stream().anyMatch( a -> a.adapterName.equals( template.adapterName ) && a.type == template.adapterType ) ) {
throw new RuntimeException( "Adapter is still deployed!" );
throw new GenericRuntimeException( "Adapter is still deployed!" );
}
Catalog.getInstance().dropAdapterTemplate( templateId );
}
Expand Down Expand Up @@ -240,7 +240,7 @@ public void restoreAdapters( List<LogicalAdapter> adapters ) {
adapterById.put( instance.getAdapterId(), instance );
}
} catch ( NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e ) {
throw new RuntimeException( "Something went wrong while restoring adapters from the catalog.", e );
throw new GenericRuntimeException( "Something went wrong while restoring adapters from the catalog.", e );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public Type getJavaClass( AlgDataType type ) {
}
}
}
log.warn( "Could not find corresponding class for PolyType" );
log.debug( "Could not find corresponding class for PolyType" );
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ PolyImplementation getImplementation( Statement statement, ExecutableStatement p


public List<String> splitStatements( String statements ) {
throw new RuntimeException( "splitStatements not implemented" );
throw new GenericRuntimeException( "splitStatements not implemented" );
}

}
3 changes: 3 additions & 0 deletions core/src/main/java/org/polypheny/db/util/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
package org.polypheny.db.util;


import com.fasterxml.jackson.annotation.JsonProperty;
import io.activej.serializer.annotations.Deserialize;
import io.activej.serializer.annotations.Serialize;
import java.io.Serializable;
Expand Down Expand Up @@ -62,8 +63,10 @@
public class Pair<T1, T2> implements Comparable<Pair<T1, T2>>, Map.Entry<T1, T2>, Serializable {

@Serialize
@JsonProperty
public T1 left;
@Serialize
@JsonProperty
public T2 right;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public JavaInformation() {
GraphType.DOUGHNUT,
new String[]{ "Current", "Maximum", "Free" }
);
heapInfoGraph.colorList( List.of( GraphColor.PASTEL_RED, GraphColor.BATTERY_CHARGED_BLUE, GraphColor.LIME ) );
heapInfoGraph.colors( List.of( GraphColor.PASTEL_RED, GraphColor.BATTERY_CHARGED_BLUE, GraphColor.LIME ) );
im.registerInformation( heapInfoGraph );

InformationTable heapInfoTable = new InformationTable(
Expand Down Expand Up @@ -92,7 +92,7 @@ public JavaInformation() {
groupHeapOverTime,
GraphType.LINE,
null,
new GraphData<Long>( "Total", new Long[]{ Runtime.getRuntime().totalMemory() / 1000000 }, 20 )
new GraphData<>( "Total", new Long[]{ Runtime.getRuntime().totalMemory() / 1000000 }, 20 )
);
heapOverTimeGraph.minY( 1 );
im.registerInformation( heapOverTimeGraph );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.polypheny.db.algebra.logical.relational.LogicalValues;
import org.polypheny.db.algebra.operators.OperatorName;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.config.RuntimeConfig;
import org.polypheny.db.rex.RexCall;
import org.polypheny.db.rex.RexCorrelVariable;
Expand Down Expand Up @@ -493,7 +494,7 @@ private PolyList<PolyValue> createListForArrays( List<RexNode> operands ) {
} else if ( node instanceof RexCall ) {
list.add( createListForArrays( ((RexCall) node).operands ) );
} else {
throw new RuntimeException( "Invalid array" );
throw new GenericRuntimeException( "Invalid array" );
}
}
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public AlgNode handleConstraintEnforcer( AlgNode alg, Statement statement, Logic
constraint.getExceptionClasses(),
constraint.getExceptionMessages() );
} else {
throw new RuntimeException( "The provided modify query for the ConstraintEnforcer was not recognized!" );
throw new GenericRuntimeException( "The provided modify query for the ConstraintEnforcer was not recognized!" );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ public class InformationGraph extends Information {
private final Map<String, GraphData<? extends Number>> data = new HashMap<>();
@JsonProperty("labels")
private String[] xLabels;
/**
* -- GETTER --
* Get the GraphType
*
* @return graphType enum
*/

@Getter
@JsonProperty
private GraphType graphType;
Expand All @@ -66,9 +61,10 @@ public class InformationGraph extends Information {
@JsonProperty("max")
private int maxY;

@SuppressWarnings("unused")
@Setter
@JsonProperty
private List<GraphColor> colorList = List.of( GraphColor.PASTEL_RED, GraphColor.BATTERY_CHARGED_BLUE, GraphColor.MIKADO_YELLOW, GraphColor.POLICE_BLUE, GraphColor.TUSCAN_RED, GraphColor.DARK_SEE_GREEN, GraphColor.JELLY_BEAN_BLUE, GraphColor.TWILIGHT_LAVENDER, GraphColor.SILVER_PINK, GraphColor.LIME );
private List<GraphColor> colors = List.of( GraphColor.PASTEL_RED, GraphColor.BATTERY_CHARGED_BLUE, GraphColor.MIKADO_YELLOW, GraphColor.POLICE_BLUE, GraphColor.TUSCAN_RED, GraphColor.DARK_SEE_GREEN, GraphColor.JELLY_BEAN_BLUE, GraphColor.TWILIGHT_LAVENDER, GraphColor.SILVER_PINK, GraphColor.LIME );


/**
Expand Down Expand Up @@ -214,6 +210,7 @@ public static class GraphData<T extends Number> {
*/
// Choice of CircularFifoQueue: https://stackoverflow.com/questions/5498865/size-limited-queue-that-holds-last-n-elements-in-java
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
@JsonProperty
private final CircularFifoQueue<T> data;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,28 @@
import org.polypheny.db.util.Pair;


@Getter
public class DashboardInformation {

@Setter
@Getter
private int numberOfCommits;

@Setter
@Getter
private int numberOfRollbacks;

@Setter
@Getter
private int numberOfQueries;

@Setter
@Getter
private int numberOfWorkloads;

@Setter
@Getter
private long numberOfPendingEvents;

@Getter
private final Map<String, Pair<String, AdapterType>> availableAdapter = new HashMap<>();

@Getter
private final Map<Long, Pair<String, NamespaceType>> availableSchemas = new HashMap<>();

@Getter
private boolean catalogPersistent;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void initializeStatisticSettings() {
registerIsFullTracking();

if ( RuntimeConfig.STATISTICS_ON_STARTUP.getBoolean() ) {
// this.asyncReevaluateAllStatistics();
this.asyncReevaluateAllStatistics();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.apache.calcite.avatica.QueryState;
import org.apache.calcite.avatica.proto.Common;
import org.apache.calcite.avatica.proto.Requests.UpdateBatch;
import org.apache.calcite.avatica.remote.AvaticaRuntimeException;
import org.apache.calcite.avatica.remote.ProtobufMeta;
import org.apache.calcite.avatica.remote.TypedValue;
import org.apache.calcite.avatica.util.Unsafe;
Expand Down Expand Up @@ -946,7 +945,7 @@ public ExecuteBatchResult executeBatchProtobuf( final StatementHandle h, final L
} catch ( Throwable e ) {
log.error( "Exception while preparing query", e );
String message = e.getLocalizedMessage();
throw new AvaticaRuntimeException( message == null ? "null" : message, -1, "", AvaticaSeverity.ERROR );
throw new GenericRuntimeException( message == null ? "null" : message, -1, "", AvaticaSeverity.ERROR );
}

return new ExecuteBatchResult( updateCounts );
Expand Down Expand Up @@ -1246,7 +1245,7 @@ private ExecuteResult execute( StatementHandle h, List<TypedValue> parameterValu
} catch ( Throwable e ) {
log.error( "Exception while preparing query", e );
String message = e.getLocalizedMessage();
throw new AvaticaRuntimeException( message == null ? "null" : message, -1, "", AvaticaSeverity.ERROR );
throw new GenericRuntimeException( message == null ? "null" : message, -1, "", AvaticaSeverity.ERROR );
}
}

Expand Down Expand Up @@ -1439,7 +1438,7 @@ private List<MetaResultSet> execute( StatementHandle h, PolyphenyDbConnectionHan
) );
} catch ( NoSuchStatementException e ) {
String message = e.getLocalizedMessage();
throw new AvaticaRuntimeException( message == null ? "null" : message, -1, "", AvaticaSeverity.ERROR );
throw new GenericRuntimeException( message == null ? "null" : message, -1, "", AvaticaSeverity.ERROR );
}
}
return resultSets;
Expand Down Expand Up @@ -1533,7 +1532,7 @@ public void openConnection( final ConnectionHandle ch, final Map<String, String>
connectionParameters.getOrDefault( "username", connectionParameters.get( "user" ) ),
connectionParameters.getOrDefault( "password", "" ) );
} catch ( AuthenticationException e ) {
throw new AvaticaRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
throw new GenericRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
}
// assert user != null;

Expand All @@ -1560,7 +1559,7 @@ public void openConnection( final ConnectionHandle ch, final Map<String, String>
try {
transaction.commit();
} catch ( TransactionException e ) {
throw new AvaticaRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
throw new GenericRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
}

openConnections.put( ch.id, new PolyphenyDbConnectionHandle( ch, user, ch.id, null, namespace, transactionManager ) );
Expand Down Expand Up @@ -1668,7 +1667,7 @@ public void commit( final ConnectionHandle ch ) {
try {
transaction.commit();
} catch ( TransactionException e ) {
throw new AvaticaRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
throw new GenericRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
} finally {
connection.endCurrentTransaction();
}
Expand Down Expand Up @@ -1698,7 +1697,7 @@ public void rollback( final ConnectionHandle ch ) {
try {
transaction.rollback();
} catch ( TransactionException e ) {
throw new AvaticaRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
throw new GenericRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR );
} finally {
connection.endCurrentTransaction();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public PolyValue[] convertNormalRow( String[] strings ) {
final PolyValue[] objects = new PolyValue[fields.length];
for ( int i = 0; i < fields.length; i++ ) {
int field = fields[i];
objects[i] = convert( fieldTypes[i], strings[field - 1] );
objects[i] = convert( fieldTypes[i], strings[field] );
}
return objects;
}
Expand All @@ -386,7 +386,7 @@ public PolyValue[] convertStreamRow( String[] strings ) {
objects[0] = PolyLong.of( System.currentTimeMillis() );
for ( int i = 0; i < fields.length; i++ ) {
int field = fields[i];
objects[i + 1] = convert( fieldTypes[i], strings[field - 1] );
objects[i + 1] = convert( fieldTypes[i], strings[field] );
}
return objects;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public List<CypherStatement> parse( String query ) {

@Override
public Pair<Node, AlgDataType> validate( Transaction transaction, Node parsed, boolean addDefaultValues ) {
throw new RuntimeException( "The MQL implementation does not support validation." );
throw new GenericRuntimeException( "The Cypher implementation does not support validation." );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package org.polypheny.db.cypher;

import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.cypher.parser.ParseException;

public class CypherSyntaxException extends RuntimeException {

public CypherSyntaxException( ParseException e, int beginOffset, int beginLine, int beginColumn ) {
throw new RuntimeException( e.getMessage() );
throw new GenericRuntimeException( e.getMessage() );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import lombok.Getter;
import org.polypheny.db.catalog.entity.logical.LogicalNamespace;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.catalog.logistic.Pattern;
import org.polypheny.db.cypher.CypherParameter;
import org.polypheny.db.cypher.CypherSimpleEither;
Expand Down Expand Up @@ -57,7 +58,7 @@ public CypherCreateDatabaseAlias(
public void execute( Context context, Statement statement, QueryParameters parameters ) {
List<LogicalNamespace> graphs = statement.getTransaction().getSnapshot().getNamespaces( new Pattern( targetName ) );
if ( graphs.size() != 1 ) {
throw new RuntimeException( "Error while creating a new graph database alias." );
throw new GenericRuntimeException( "Error while creating a new graph database alias." );
}
DdlManager.getInstance().createGraphAlias( graphs.get( 0 ).id, aliasName, ifNotExists );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import lombok.Getter;
import org.polypheny.db.catalog.entity.logical.LogicalNamespace;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.catalog.logistic.Pattern;
import org.polypheny.db.cypher.CypherParameter;
import org.polypheny.db.cypher.CypherSimpleEither;
Expand Down Expand Up @@ -48,7 +49,7 @@ public CypherDropAlias( ParserPos pos, CypherSimpleEither<String, CypherParamete
public void execute( Context context, Statement statement, QueryParameters parameters ) {
List<LogicalNamespace> graphs = statement.getTransaction().getSnapshot().getNamespaces( new Pattern( aliasName ) );
if ( graphs.size() != 1 ) {
throw new RuntimeException( "Error while dropping a graph database alias." );
throw new GenericRuntimeException( "Error while dropping a graph database alias." );
}
DdlManager.getInstance().dropGraphAlias( graphs.get( 0 ).id, aliasName, ifExists );
}
Expand Down
Loading

0 comments on commit 675cfeb

Please sign in to comment.