diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml index 1636a3d13a..1330307909 100644 --- a/.github/workflows/matrix.yml +++ b/.github/workflows/matrix.yml @@ -37,4 +37,4 @@ jobs: run: ./gradlew assemblePlugins -PwithoutpullingUi=true - name: Execute tests timeout-minutes: 30 - run: ./gradlew check -PwithoutpullingUi=true -i + run: ./gradlew check -PwithoutpullingUi=true diff --git a/core/src/main/java/org/polypheny/db/algebra/AlgNode.java b/core/src/main/java/org/polypheny/db/algebra/AlgNode.java index f453fe5464..9b9024777a 100644 --- a/core/src/main/java/org/polypheny/db/algebra/AlgNode.java +++ b/core/src/main/java/org/polypheny/db/algebra/AlgNode.java @@ -256,9 +256,9 @@ default void buildPolyAlgebra( StringBuilder sb ) { buildPolyAlgebra( sb, null ); } - default String buildPolyAlgebra(String prefix) { + default String buildPolyAlgebra( String prefix ) { StringBuilder sb = new StringBuilder(); - buildPolyAlgebra(sb, prefix); + buildPolyAlgebra( sb, prefix ); return sb.toString(); } @@ -273,10 +273,11 @@ default String buildPolyAlgebra(String prefix) { /** * Serialize this node without generating metadata. + * * @param mapper the ObjectMapper used for creating JsonNodes. * @return a ObjectNode representing the AlgNode tree rooted at this node. */ - default ObjectNode serializePolyAlgebra( ObjectMapper mapper) { + default ObjectNode serializePolyAlgebra( ObjectMapper mapper ) { return serializePolyAlgebra( mapper, null ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/convert/ConverterImpl.java b/core/src/main/java/org/polypheny/db/algebra/convert/ConverterImpl.java index 49feed2919..e23abdba2b 100644 --- a/core/src/main/java/org/polypheny/db/algebra/convert/ConverterImpl.java +++ b/core/src/main/java/org/polypheny/db/algebra/convert/ConverterImpl.java @@ -34,6 +34,7 @@ package org.polypheny.db.algebra.convert; +import java.util.Optional; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.SingleAlg; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; @@ -42,7 +43,6 @@ import org.polypheny.db.plan.AlgPlanner; import org.polypheny.db.plan.AlgTraitDef; import org.polypheny.db.plan.AlgTraitSet; -import java.util.Optional; /** diff --git a/core/src/main/java/org/polypheny/db/algebra/core/Aggregate.java b/core/src/main/java/org/polypheny/db/algebra/core/Aggregate.java index 01cdb8d914..6f1a73e44b 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/Aggregate.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/Aggregate.java @@ -385,7 +385,7 @@ private boolean typeMatchesInferred( final AggregateCall aggCall, final Litmus l AggCallBinding callBinding = aggCall.createBinding( this ); AlgDataType type = aggFunction.inferReturnType( callBinding ); AlgDataType expectedType = aggCall.type; - if (type.isNullable() != expectedType.isNullable()) { + if ( type.isNullable() != expectedType.isNullable() ) { // During PolyAlgebra parsing, the type might become non-nullable. We do not want to throw an error in this case. AlgDataTypeFactory factory = AlgDataTypeFactory.DEFAULT; expectedType = factory.createTypeWithNullability( expectedType, type.isNullable() ); diff --git a/core/src/main/java/org/polypheny/db/algebra/core/Calc.java b/core/src/main/java/org/polypheny/db/algebra/core/Calc.java index a29b91aed8..8f4ed4f34f 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/Calc.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/Calc.java @@ -182,7 +182,7 @@ public static RexProgram getProgramFromArgs( PolyAlgArgs args, AlgNode input, Re if ( condition != null ) { builder.addCondition( condition ); } - return builder.getProgram(false); + return builder.getProgram( false ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/core/Filter.java b/core/src/main/java/org/polypheny/db/algebra/core/Filter.java index 4dc7fd8129..d80f510f93 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/Filter.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/Filter.java @@ -134,7 +134,7 @@ public AlgOptCost computeSelfCost( AlgPlanner planner, AlgMetadataQuery mq ) { Optional dRows = mq.getTupleCount( this ); Optional dCpu = mq.getTupleCount( getInput() ); double dIo = 0; - if(dRows.isEmpty() || dCpu.isEmpty()) { + if ( dRows.isEmpty() || dCpu.isEmpty() ) { return planner.getCostFactory().makeInfiniteCost(); } return planner.getCostFactory().makeCost( dRows.get(), dCpu.get(), dIo ); @@ -160,6 +160,7 @@ public String algCompareString() { (condition != null ? condition.hashCode() : "") + "&"; } + @Override public PolyAlgArgs bindArguments() { PolyAlgArgs args = new PolyAlgArgs( getPolyAlgDeclaration() ); diff --git a/core/src/main/java/org/polypheny/db/algebra/core/Join.java b/core/src/main/java/org/polypheny/db/algebra/core/Join.java index 8f3b957a6b..31eb7fe4c7 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/Join.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/Join.java @@ -258,6 +258,7 @@ public String algCompareString() { (joinType != null ? joinType.name() : "") + "&"; } + protected static Triple, JoinAlgType> extractArgs( PolyAlgArgs args ) { RexArg condition = args.getArg( "condition", RexArg.class ); EnumArg type = args.getEnumArg( "type", JoinAlgType.class ); @@ -265,6 +266,7 @@ protected static Triple, JoinAlgType> extractArgs( P return Triple.of( condition.getNode(), new HashSet<>( variables ), type.getArg() ); } + @Override public PolyAlgArgs bindArguments() { PolyAlgArgs args = new PolyAlgArgs( getPolyAlgDeclaration() ); diff --git a/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgAggregate.java b/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgAggregate.java index 719faf0324..2aad911cb0 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgAggregate.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgAggregate.java @@ -81,13 +81,14 @@ public NodeType getNodeType() { return NodeType.AGGREGATE; } - public static AlgDataType deriveTupleType(AlgCluster cluster, AlgDataType inputType, List groups, List aggCalls) { + + public static AlgDataType deriveTupleType( AlgCluster cluster, AlgDataType inputType, List groups, List aggCalls ) { final AlgDataTypeFactory.Builder builder = cluster.getTypeFactory().builder(); for ( LaxAggregateCall aggCall : aggCalls ) { - builder.add( aggCall.name, null, aggCall.getType( cluster )); + builder.add( aggCall.name, null, aggCall.getType( cluster ) ); } List fields = inputType.getFields(); - for (RexNameRef group : groups) { + for ( RexNameRef group : groups ) { int idx = group.getIndex().orElseThrow(); builder.add( fields.get( idx ) ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/core/relational/RelModify.java b/core/src/main/java/org/polypheny/db/algebra/core/relational/RelModify.java index 113db85e06..cbbbfd7d7b 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/relational/RelModify.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/relational/RelModify.java @@ -202,7 +202,8 @@ public String algCompareString() { isFlattened() + "&"; } - protected static Quadruple, List, Boolean> extractArgs(PolyAlgArgs args) { + + protected static Quadruple, List, Boolean> extractArgs( PolyAlgArgs args ) { EnumArg op = args.getEnumArg( "operation", Operation.class ); List updateColumns = args.getListArg( "targets", StringArg.class ).map( StringArg::getArg ); List sourceExpressions = args.getListArg( "sources", RexArg.class ).map( RexArg::getNode ); @@ -213,6 +214,7 @@ protected static Quadruple, List, Boo return Quadruple.of( op.getArg(), updateColumns, sourceExpressions, flattened.toBool() ); } + @Override public PolyAlgArgs bindArguments() { PolyAlgArgs args = new PolyAlgArgs( getPolyAlgDeclaration() ); diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableIntersect.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableIntersect.java index b374c1a487..9cc945921e 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableIntersect.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableIntersect.java @@ -58,6 +58,7 @@ public EnumerableIntersect( AlgCluster cluster, AlgTraitSet traitSet, List children, AlgCluster cluster ) { return new EnumerableIntersect( cluster, cluster.traitSet(), children, args.getArg( "all", BooleanArg.class ).toBool() ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableProject.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableProject.java index e75ae31cac..5b2ca7ddb2 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableProject.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableProject.java @@ -38,7 +38,6 @@ import org.polypheny.db.algebra.AlgCollationTraitDef; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.Project; -import org.polypheny.db.algebra.logical.relational.LogicalRelProject; import org.polypheny.db.algebra.metadata.AlgMdCollation; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.polyalg.arguments.ListArg; diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/JavaTupleFormat.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/JavaTupleFormat.java index 41090dfa0a..a3b1a8c51f 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/JavaTupleFormat.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/JavaTupleFormat.java @@ -43,7 +43,6 @@ import org.apache.calcite.linq4j.tree.MethodCallExpression; import org.apache.calcite.linq4j.tree.Types; import org.polypheny.db.adapter.java.JavaTypeFactory; -import org.polypheny.db.algebra.metadata.CyclicMetadataException; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.interpreter.Row; import org.polypheny.db.runtime.Unit; diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgAggregate.java b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgAggregate.java index 53d514aaf8..4c9e7f4661 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgAggregate.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgAggregate.java @@ -43,8 +43,8 @@ public LogicalLpgAggregate( AlgCluster cluster, AlgTraitSet traits, AlgNode chil public static LogicalLpgAggregate create( final AlgNode input, @NotNull List groups, List aggCalls ) { AlgCluster cluster = input.getCluster(); AlgTraitSet traitSet = input.getTraitSet(); - AlgDataType type = deriveTupleType(cluster, input.getTupleType(), groups, aggCalls); - return new LogicalLpgAggregate( cluster, traitSet, input, groups, aggCalls, type); + AlgDataType type = deriveTupleType( cluster, input.getTupleType(), groups, aggCalls ); + return new LogicalLpgAggregate( cluster, traitSet, input, groups, aggCalls, type ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgFilter.java b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgFilter.java index 93437dd1a3..ab7ca33d6b 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgFilter.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgFilter.java @@ -37,11 +37,13 @@ public LogicalLpgFilter( AlgCluster cluster, AlgTraitSet traits, AlgNode input, super( cluster, traits, input, condition ); } + public static LogicalLpgFilter create( AlgNode input, RexNode condition ) { // TODO: modify traitset return new LogicalLpgFilter( input.getCluster(), input.getTraitSet(), input, condition ); } + public static LogicalLpgFilter create( PolyAlgArgs args, List children, AlgCluster cluster ) { RexArg condition = args.getArg( "condition", RexArg.class ); return create( children.get( 0 ), condition.getNode() ); diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelProject.java b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelProject.java index d836f068b5..a9863e7cec 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelProject.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelProject.java @@ -44,7 +44,6 @@ import org.polypheny.db.algebra.metadata.AlgMdCollation; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.polyalg.arguments.ListArg; -import org.polypheny.db.algebra.polyalg.arguments.PolyAlgArg; import org.polypheny.db.algebra.polyalg.arguments.PolyAlgArgs; import org.polypheny.db.algebra.polyalg.arguments.RexArg; import org.polypheny.db.algebra.type.AlgDataType; diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistinctRowCount.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistinctRowCount.java index b82aa5cf3c..69547c0f8a 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistinctRowCount.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistinctRowCount.java @@ -90,6 +90,7 @@ public Double getDistinctRowCount( AlgNode alg, AlgMetadataQuery mq, ImmutableBi return null; } + @SuppressWarnings("unused")//used by codegen public Double getDistinctRowCount( Union alg, AlgMetadataQuery mq, ImmutableBitSet groupKey, RexNode predicate ) { double rowCount = 0.0; diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdTupleCount.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdTupleCount.java index e528cc0c07..a805c23285 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdTupleCount.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdTupleCount.java @@ -34,6 +34,7 @@ package org.polypheny.db.algebra.metadata; +import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.SingleAlg; @@ -59,7 +60,6 @@ import org.polypheny.db.util.ImmutableBitSet; import org.polypheny.db.util.NumberUtil; import org.polypheny.db.util.Util; -import java.util.Optional; /** @@ -132,7 +132,7 @@ public Double getTupleCount( Project alg, AlgMetadataQuery mq ) { public Double getTupleCount( Sort alg, AlgMetadataQuery mq ) { Optional count = mq.getTupleCount( alg.getInput() ); - if ( count.isEmpty()) { + if ( count.isEmpty() ) { return null; } double rowCount = count.get(); diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMetadataQuery.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMetadataQuery.java index 9351315737..6ed80e678f 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMetadataQuery.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMetadataQuery.java @@ -243,6 +243,7 @@ public Optional getTupleCount( AlgNode alg ) { } } + /** * Returns the {@link BuiltInMetadata.MaxRowCount#getMaxRowCount()} statistic. * diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/ReflectiveAlgMetadataProvider.java b/core/src/main/java/org/polypheny/db/algebra/metadata/ReflectiveAlgMetadataProvider.java index 0de05867fd..f9f506d913 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/ReflectiveAlgMetadataProvider.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/ReflectiveAlgMetadataProvider.java @@ -176,7 +176,7 @@ private static AlgMetadataProvider reflectiveSource( final MetadataHandler ta } Object value = mq.map.put( key1, NullSentinel.INSTANCE ); if ( value != null ) { - throw new CyclicMetadataException( String.format("Already found key %s with value %s", key1, value ) ); + throw new CyclicMetadataException( String.format( "Already found key %s with value %s", key1, value ) ); } try { return handlerMethod.invoke( target, args1 ); diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/PolyAlgDeclaration.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/PolyAlgDeclaration.java index ade0048b46..7a8ca5f869 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/PolyAlgDeclaration.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/PolyAlgDeclaration.java @@ -213,6 +213,7 @@ public boolean supportsNumberOfChildren( int n ) { return numInputs == -1 || numInputs == n; } + public boolean mightRequireAuxiliaryProject() { return (numInputs == -1 || numInputs > 1) && !opTags.contains( OperatorTag.PHYSICAL ) && @@ -262,7 +263,7 @@ public ObjectNode serialize( ObjectMapper mapper ) { } node.set( "kwParams", kwArr ); - if (isNotFullyImplemented) { + if ( isNotFullyImplemented ) { node.put( "notRegistered", true ); // disables editing for this node in the UI } @@ -437,7 +438,7 @@ public enum ParamType { /** * Window.Group */ - WINDOW_GROUP( WindowGroupArg.class); + WINDOW_GROUP( WindowGroupArg.class ); private final Class argClass; private final Class> enumClass; diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/AnyArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/AnyArg.java index 09f1f687a5..398c051027 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/AnyArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/AnyArg.java @@ -32,10 +32,12 @@ public class AnyArg implements PolyAlgArg { private final Object arg; - public AnyArg(Object arg) { + + public AnyArg( Object arg ) { this.arg = arg; } + @Override public ParamType getType() { return ParamType.ANY; @@ -47,6 +49,7 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames return arg.toString(); } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { return mapper.createObjectNode().put( "arg", arg.toString() ); diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/BooleanArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/BooleanArg.java index 5a9f09ec11..3d2d64bcac 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/BooleanArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/BooleanArg.java @@ -52,8 +52,10 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames return Boolean.toString( bool ); } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { return mapper.createObjectNode().put( "arg", bool ); } + } diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CollationArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CollationArg.java index 4541cd5c2d..ae2180a784 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CollationArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CollationArg.java @@ -61,18 +61,20 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames return str; } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { return serialize( coll, inputFieldNames, mapper ); } + public static ObjectNode serialize( AlgFieldCollation coll, @NonNull List inputFieldNames, ObjectMapper mapper ) { ObjectNode node = mapper.createObjectNode(); - if (coll != null) { + if ( coll != null ) { int idx = coll.getFieldIndex(); - node.put("field", inputFieldNames.size() > idx ? inputFieldNames.get( idx ) : Integer.toString( idx )); - node.put("direction", coll.direction.shortString); - node.put("nullDirection", coll.nullDirection.toString()); + node.put( "field", inputFieldNames.size() > idx ? inputFieldNames.get( idx ) : Integer.toString( idx ) ); + node.put( "direction", coll.direction.shortString ); + node.put( "nullDirection", coll.nullDirection.toString() ); } return node; } diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CorrelationArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CorrelationArg.java index 395b6754f9..5cf9560efd 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CorrelationArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/CorrelationArg.java @@ -47,6 +47,7 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames return String.valueOf( corrId.getId() ); } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { return mapper.createObjectNode().put( "arg", corrId.getId() ); diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/DoubleArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/DoubleArg.java index 69849e8b3f..ceebcce091 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/DoubleArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/DoubleArg.java @@ -52,6 +52,7 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames return Double.toString( arg ); } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { return mapper.createObjectNode().put( "arg", arg ); diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/EntityArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/EntityArg.java index 40fa41e57a..214231b04a 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/EntityArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/EntityArg.java @@ -67,7 +67,7 @@ public EntityArg( Entity entity, Snapshot snapshot, DataModel model ) { if ( entity instanceof AllocationEntity e ) { if ( e.dataModel != DataModel.GRAPH ) { this.entityName = snapshot.getLogicalEntity( e.logicalId ).orElseThrow().name; - } else if (!e.name.startsWith( AllocationEntity.PREFIX )) { + } else if ( !e.name.startsWith( AllocationEntity.PREFIX ) ) { this.entityName = e.name; } this.partitionName = snapshot.alloc().getPartition( e.partitionId ).orElseThrow().name; diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/FieldArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/FieldArg.java index 5f175e023c..4dbbdd498b 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/FieldArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/FieldArg.java @@ -49,6 +49,7 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames return Integer.toString( field ); } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { return mapper.createObjectNode().put( "arg", toPolyAlg( context, inputFieldNames ) ); diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/IntArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/IntArg.java index a1ae9510c4..e568fa6ca5 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/IntArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/IntArg.java @@ -52,6 +52,7 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames return Integer.toString( arg ); } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { return mapper.createObjectNode().put( "arg", arg ); diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/LaxAggArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/LaxAggArg.java index d5856da115..c1a9d7c4e3 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/LaxAggArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/LaxAggArg.java @@ -26,7 +26,7 @@ import org.polypheny.db.algebra.polyalg.PolyAlgDeclaration.ParamType; import org.polypheny.db.algebra.polyalg.PolyAlgUtils; -public class LaxAggArg implements PolyAlgArg{ +public class LaxAggArg implements PolyAlgArg { @Getter private final LaxAggregateCall agg; @@ -53,19 +53,20 @@ public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames private String aggToString( List inputFieldNames ) { StringBuilder sb = new StringBuilder( agg.function.toString() ); sb.append( "(" ); - if (agg.getInput().isPresent()) { + if ( agg.getInput().isPresent() ) { sb.append( PolyAlgUtils.digestWithNames( agg.getInput().get(), inputFieldNames ) ); } sb.append( ")" ); return sb.toString(); } + @Override public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNames, ObjectMapper mapper ) { ObjectNode node = mapper.createObjectNode(); - node.put("function", agg.function.toString()); - if (agg.getInput().isPresent()) { - node.put("input", PolyAlgUtils.digestWithNames( agg.getInput().get(), inputFieldNames )); + node.put( "function", agg.function.toString() ); + if ( agg.getInput().isPresent() ) { + node.put( "input", PolyAlgUtils.digestWithNames( agg.getInput().get(), inputFieldNames ) ); } node.put( "alias", agg.name ); return node; diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/RexArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/RexArg.java index 5d12cf016f..b23dddfade 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/RexArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/RexArg.java @@ -64,7 +64,7 @@ public RexArg( RexNode node ) { * @param inputFieldNames the list of names to be used for serialization */ public RexArg( RexNode node, @NonNull List inputFieldNames ) { - this(node); + this( node ); this.inputFieldNames = inputFieldNames; } @@ -86,7 +86,7 @@ private String rexAsString( @NonNull List inputFieldNames ) { if ( node == null ) { return str; } - return PolyAlgUtils.digestWithNames( node, this.inputFieldNames == null ? inputFieldNames : this.inputFieldNames); + return PolyAlgUtils.digestWithNames( node, this.inputFieldNames == null ? inputFieldNames : this.inputFieldNames ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/WindowGroupArg.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/WindowGroupArg.java index 135e041740..9a411ae7da 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/WindowGroupArg.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/arguments/WindowGroupArg.java @@ -31,6 +31,7 @@ import org.polypheny.db.algebra.polyalg.PolyAlgUtils; public class WindowGroupArg implements PolyAlgArg { + @Getter private final Group group; @@ -48,7 +49,7 @@ public ParamType getType() { @Override public String toPolyAlg( AlgNode context, @NonNull List inputFieldNames ) { - throw new NotImplementedException("WindowGroupArg can not yet be serialized to PolyAlgebra"); + throw new NotImplementedException( "WindowGroupArg can not yet be serialized to PolyAlgebra" ); } @@ -57,13 +58,12 @@ public ObjectNode serialize( AlgNode context, @NonNull List inputFieldNa ObjectNode node = mapper.createObjectNode(); node.put( "isRows", group.isRows ); - node.put( "lowerBound", group.lowerBound.toString()); - node.put( "upperBound", group.upperBound.toString()); - + node.put( "lowerBound", group.lowerBound.toString() ); + node.put( "upperBound", group.upperBound.toString() ); ArrayNode aggCalls = mapper.createArrayNode(); for ( RexWinAggCall call : group.aggCalls ) { - aggCalls.add( PolyAlgUtils.digestWithNames( call, inputFieldNames) ); + aggCalls.add( PolyAlgUtils.digestWithNames( call, inputFieldNames ) ); } node.set( "aggCalls", aggCalls ); diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgNodeList.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgNodeList.java index e9ab5be5de..79cad96225 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgNodeList.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgNodeList.java @@ -82,7 +82,7 @@ public int size() { @Override public Node[] toArray() { - return list.toArray( new Node[0]); + return list.toArray( new Node[0] ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgOperator.java b/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgOperator.java index a72870f373..fc93894964 100644 --- a/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgOperator.java +++ b/core/src/main/java/org/polypheny/db/algebra/polyalg/parser/nodes/PolyAlgOperator.java @@ -18,7 +18,6 @@ import java.util.List; import lombok.Getter; -import lombok.NonNull; import org.polypheny.db.languages.ParserPos; @Getter diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java index 389b849c07..ba38eb3b85 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationEntity.java @@ -40,6 +40,7 @@ @SerializeClass(subclasses = { AllocationTable.class, AllocationGraph.class, AllocationCollection.class }) @JsonTypeInfo(use = Id.CLASS) public abstract class AllocationEntity extends Entity { + public static String PREFIX = "$alloc$"; @Serialize diff --git a/core/src/main/java/org/polypheny/db/languages/LanguageManager.java b/core/src/main/java/org/polypheny/db/languages/LanguageManager.java index c93b8976e3..89e34adee3 100644 --- a/core/src/main/java/org/polypheny/db/languages/LanguageManager.java +++ b/core/src/main/java/org/polypheny/db/languages/LanguageManager.java @@ -101,7 +101,6 @@ public List anyPrepareQuery( QueryContext context, Statem context.getInformationTarget().accept( statement.getTransaction().getQueryAnalyzer() ); } - List parsedQueries; if ( context instanceof ParsedQueryContext ) { diff --git a/core/src/main/java/org/polypheny/db/nodes/LangFunctionOperator.java b/core/src/main/java/org/polypheny/db/nodes/LangFunctionOperator.java index cf1a4cd2d6..27a8344fab 100644 --- a/core/src/main/java/org/polypheny/db/nodes/LangFunctionOperator.java +++ b/core/src/main/java/org/polypheny/db/nodes/LangFunctionOperator.java @@ -59,6 +59,7 @@ private static AlgDataType fromFixedTyped( PolyType returnType, @Nullable PolyTy }; } + public LangFunctionOperator( String name, Kind kind, PolyType returnType ) { this( name, kind, returnType, null ); } diff --git a/core/src/main/java/org/polypheny/db/rex/RexLocalRef.java b/core/src/main/java/org/polypheny/db/rex/RexLocalRef.java index bdf2e910de..8a45a8fa85 100644 --- a/core/src/main/java/org/polypheny/db/rex/RexLocalRef.java +++ b/core/src/main/java/org/polypheny/db/rex/RexLocalRef.java @@ -49,6 +49,7 @@ * Variables are immutable. */ public class RexLocalRef extends RexSlot { + public static final String PREFIX = "$t"; // array of common names, to reduce memory allocations diff --git a/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java b/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java index ab58e0fab0..73b5170120 100644 --- a/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java +++ b/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java @@ -432,7 +432,8 @@ public RexNode literal( Object value ) { return literal( value, rexBuilder ); } - public static RexNode literal( Object value, RexBuilder rexBuilder) { + + public static RexNode literal( Object value, RexBuilder rexBuilder ) { if ( value == null ) { return rexBuilder.constantNull(); } else if ( value instanceof Boolean ) { diff --git a/core/src/main/java/org/polypheny/db/transaction/Statement.java b/core/src/main/java/org/polypheny/db/transaction/Statement.java index 5f327f5adb..0c655ef26e 100644 --- a/core/src/main/java/org/polypheny/db/transaction/Statement.java +++ b/core/src/main/java/org/polypheny/db/transaction/Statement.java @@ -43,6 +43,7 @@ public interface Statement { /** * Get the index of this statement in the list of statements for that transaction + * * @return the index this statement has in the statements list of the transaction */ long getIndex(); diff --git a/core/src/main/java/org/polypheny/db/util/Quadruple.java b/core/src/main/java/org/polypheny/db/util/Quadruple.java index 11e87ac310..8b1bc8d747 100644 --- a/core/src/main/java/org/polypheny/db/util/Quadruple.java +++ b/core/src/main/java/org/polypheny/db/util/Quadruple.java @@ -30,39 +30,43 @@ public class Quadruple implements Comparable> public C c; public D d; - public Quadruple(A a, B b, C c, D d) { + + public Quadruple( A a, B b, C c, D d ) { this.a = a; this.b = b; this.c = c; this.d = d; } + @Override - public int compareTo(Quadruple o) { + public int compareTo( Quadruple o ) { //noinspection unchecked - int cmp = compare((Comparable) this.a, (Comparable) o.a); - if (cmp == 0) { + int cmp = compare( (Comparable) this.a, (Comparable) o.a ); + if ( cmp == 0 ) { //noinspection unchecked - cmp = compare((Comparable) this.b, (Comparable) o.b); - if (cmp == 0) { + cmp = compare( (Comparable) this.b, (Comparable) o.b ); + if ( cmp == 0 ) { //noinspection unchecked - cmp = compare((Comparable) this.c, (Comparable) o.c); - if (cmp == 0) { + cmp = compare( (Comparable) this.c, (Comparable) o.c ); + if ( cmp == 0 ) { //noinspection unchecked - cmp = compare((Comparable) this.d, (Comparable) o.d); + cmp = compare( (Comparable) this.d, (Comparable) o.d ); } } } return cmp; } - private static > int compare(C c1, C c2) { - if (c1 == null) { + + private static > int compare( C c1, C c2 ) { + if ( c1 == null ) { return (c2 == null) ? 0 : -1; - } else if (c2 == null) { + } else if ( c2 == null ) { return 1; } else { - return c1.compareTo(c2); + return c1.compareTo( c2 ); } } + } diff --git a/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java b/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java index 4f93fbd9da..042998097d 100644 --- a/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java +++ b/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java @@ -57,6 +57,7 @@ public class UiRoutingPageUtil { private static final ExecutorService executorService = Executors.newFixedThreadPool( RUNNERS ); private static final AtomicInteger counter = new AtomicInteger( 0 ); + public static int runningTasks() { return counter.get(); } @@ -97,12 +98,11 @@ private static void addRoutedPolyPlanPage( AlgNode routedNode, InformationManage ObjectNode objectNode = routedNode.serializePolyAlgebra( objectMapper, gs ); String jsonString; try { - jsonString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString( objectNode ); - }catch ( JsonProcessingException e ){ + jsonString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString( objectNode ); + } catch ( JsonProcessingException e ) { throw new GenericRuntimeException( e ); } - InformationPage page = new InformationPage( prefix + " Query Plan" ).setStmtLabel( stmtIdx ); page.fullWidth(); InformationGroup group = new InformationGroup( page, prefix + " Query Plan" ); diff --git a/information/src/main/java/org/polypheny/db/information/InformationPage.java b/information/src/main/java/org/polypheny/db/information/InformationPage.java index 20e581be70..688936b57a 100644 --- a/information/src/main/java/org/polypheny/db/information/InformationPage.java +++ b/information/src/main/java/org/polypheny/db/information/InformationPage.java @@ -171,7 +171,8 @@ public void overrideWith( final InformationPage page ) { this.implicit = false; } - public InformationPage setStmtLabel(long stmtIdx) { + + public InformationPage setStmtLabel( long stmtIdx ) { this.label = "Query " + (stmtIdx + 1); return this; } diff --git a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherFromPathUtil.java b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherFromPathUtil.java index f09a9de549..a3059291d2 100644 --- a/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherFromPathUtil.java +++ b/plugins/cypher-language/src/main/java/org/polypheny/db/cypher/CypherFromPathUtil.java @@ -31,6 +31,7 @@ public static AlgDataType inferReturnType( OperatorBinding opBinding ) { return inferReturnType( opBinding.collectOperandTypes(), opBinding ); } + public static AlgDataType inferReturnType( List operandTypes ) { if ( operandTypes.size() < 2 || !(operandTypes.get( 0 ) instanceof PathType pathType) ) { throw new GenericRuntimeException( "Could not get element to derive type for extract from path" ); diff --git a/webui/src/main/java/org/polypheny/db/webui/HttpServer.java b/webui/src/main/java/org/polypheny/db/webui/HttpServer.java index 066a589692..be6f126f9e 100644 --- a/webui/src/main/java/org/polypheny/db/webui/HttpServer.java +++ b/webui/src/main/java/org/polypheny/db/webui/HttpServer.java @@ -353,9 +353,9 @@ private void attachRoutes( Javalin webuiServer, Crud crud ) { webuiServer.get( "/product", ctx -> ctx.result( "Polypheny-DB" ) ); - webuiServer.get( "/getPolyAlgRegistry", crud::getPolyAlgRegistry); + webuiServer.get( "/getPolyAlgRegistry", crud::getPolyAlgRegistry ); - webuiServer.post( "/buildPolyPlan", crud::buildPlanFromPolyAlg); + webuiServer.post( "/buildPolyPlan", crud::buildPlanFromPolyAlg ); webuiServer.get( "/isReady", ctx -> ctx.result( String.valueOf( isReady ) ) ); diff --git a/webui/src/main/java/org/polypheny/db/webui/PolyPlanBuilder.java b/webui/src/main/java/org/polypheny/db/webui/PolyPlanBuilder.java index dfad8bdf47..134380a30d 100644 --- a/webui/src/main/java/org/polypheny/db/webui/PolyPlanBuilder.java +++ b/webui/src/main/java/org/polypheny/db/webui/PolyPlanBuilder.java @@ -108,7 +108,7 @@ public static Pair, List> translateDynamicParams( L List translatedTypes = new ArrayList<>(); for ( int i = 0; i < vals.size(); i++ ) { String s = vals.get( i ); - AlgDataType t = convertType( types.get( i ), factory); + AlgDataType t = convertType( types.get( i ), factory ); PolyValue value = switch ( t.getPolyType() ) { case BOOLEAN -> PolyBoolean.of( Boolean.parseBoolean( s ) ); @@ -117,8 +117,8 @@ public static Pair, List> translateDynamicParams( L case DECIMAL -> PolyBigDecimal.of( s ); case FLOAT, REAL -> PolyFloat.of( Float.parseFloat( s ) ); case DOUBLE -> PolyDouble.of( Double.parseDouble( s ) ); - case DATE -> PolyDate.of(Long.parseLong( s )); - case TIME -> PolyTime.of(Long.parseLong( s )); + case DATE -> PolyDate.of( Long.parseLong( s ) ); + case TIME -> PolyTime.of( Long.parseLong( s ) ); case TIMESTAMP -> PolyTimestamp.of( Long.parseLong( s ) ); case CHAR, VARCHAR -> PolyString.of( s ); default -> throw new NotImplementedException(); @@ -131,18 +131,19 @@ public static Pair, List> translateDynamicParams( L return Pair.of( translatedVals, translatedTypes ); } - private static AlgDataType convertType(String t, AlgDataTypeFactory factory) { + + private static AlgDataType convertType( String t, AlgDataTypeFactory factory ) { //e.g. t = "CHAR(5)" String[] parts = t.split( "\\(" ); PolyType type = PolyType.valueOf( parts[0] ); - if (parts.length == 1) { + if ( parts.length == 1 ) { return factory.createPolyType( type ); } - String[] args = parts[1].substring( 0, parts[1].length()-1 ).split( "," ); + String[] args = parts[1].substring( 0, parts[1].length() - 1 ).split( "," ); return switch ( args.length ) { - case 1 -> factory.createPolyType( type, Integer.parseInt( args[0].trim()) ); - case 2 -> factory.createPolyType( type, Integer.parseInt( args[0].trim()), Integer.parseInt( args[1].trim()) ); + case 1 -> factory.createPolyType( type, Integer.parseInt( args[0].trim() ) ); + case 2 -> factory.createPolyType( type, Integer.parseInt( args[0].trim() ), Integer.parseInt( args[1].trim() ) ); default -> throw new GenericRuntimeException( "Unexpected number of type arguments: " + args.length ); };