From 6bc401aada3cd4e6117ebffb61be4d4ecdf98ada Mon Sep 17 00:00:00 2001 From: datomo Date: Mon, 27 Nov 2023 14:03:22 +0100 Subject: [PATCH] multiple renamings, adjustment to mongodb store --- .../org/polypheny/db/adapter/Modifiable.java | 18 +-- .../db/adapter/java/ReflectiveSchema.java | 151 +----------------- .../polypheny/db/algebra/AbstractAlgNode.java | 4 +- .../org/polypheny/db/algebra/AlgInput.java | 4 +- .../org/polypheny/db/algebra/AlgNode.java | 4 +- .../db/algebra/core/AlgFactories.java | 6 +- .../db/algebra/core/common/Modify.java | 4 +- .../db/algebra/core/common/Scan.java | 4 +- .../algebra/core/document/DocumentModify.java | 4 +- .../algebra/core/document/DocumentScan.java | 4 +- .../algebra/core/document/DocumentValues.java | 4 +- .../db/algebra/core/lpg/LpgModify.java | 4 +- .../db/algebra/core/lpg/LpgScan.java | 4 +- .../db/algebra/core/relational/RelModify.java | 4 +- .../db/algebra/core/relational/RelScan.java | 6 +- .../relational/RelationalTransformable.java | 6 +- .../db/algebra/enumerable/EnumerableScan.java | 6 +- .../db/algebra/externalize/AlgJsonReader.java | 4 +- .../logical/common/LogicalStreamer.java | 4 +- .../document/LogicalDocumentModify.java | 10 +- .../logical/document/LogicalDocumentScan.java | 10 +- .../algebra/logical/lpg/LogicalLpgModify.java | 8 +- .../algebra/logical/lpg/LogicalLpgScan.java | 8 +- .../algebra/logical/lpg/LogicalLpgValues.java | 4 +- .../logical/relational/LogicalRelModify.java | 10 +- .../logical/relational/LogicalRelScan.java | 8 +- .../relational/LogicalRelViewScan.java | 8 +- .../db/algebra/metadata/AlgColumnOrigin.java | 8 +- .../db/algebra/metadata/AlgMdCollation.java | 4 +- .../algebra/metadata/AlgMdColumnOrigins.java | 4 +- .../metadata/AlgMdColumnUniqueness.java | 7 +- .../algebra/metadata/AlgMdDistribution.java | 4 +- .../db/algebra/metadata/AlgMetadataQuery.java | 4 +- .../algebra/mutable/MutableTableModify.java | 8 +- .../algebra/rules/LoptOptimizeJoinRule.java | 16 +- .../algebra/rules/LoptSemiJoinOptimizer.java | 8 +- .../{LogicalEntity.java => Entity.java} | 10 +- .../db/catalog/entity/LogicalAdapter.java | 2 +- .../db/catalog/entity/LogicalDatabase.java | 79 --------- .../catalog/entity/LogicalQueryInterface.java | 2 +- .../db/catalog/entity/LogicalUser.java | 2 +- .../{LogicalObject.java => PolyObject.java} | 2 +- .../entity/allocation/AllocationColumn.java | 4 +- .../entity/allocation/AllocationEntity.java | 4 +- .../allocation/AllocationPartition.java | 4 +- .../allocation/AllocationPartitionGroup.java | 4 +- .../allocation/AllocationPlacement.java | 4 +- .../entity/logical/LogicalCollection.java | 4 +- .../catalog/entity/logical/LogicalColumn.java | 6 +- .../catalog/entity/logical/LogicalEntity.java | 3 +- .../entity/logical/LogicalForeignKey.java | 4 +- .../catalog/entity/logical/LogicalIndex.java | 4 +- .../db/catalog/entity/logical/LogicalKey.java | 4 +- .../entity/logical/LogicalNamespace.java | 6 +- .../entity/logical/LogicalPrimaryKey.java | 4 +- .../entity/physical/PhysicalEntity.java | 4 +- .../entity/physical/PhysicalField.java | 4 +- .../snapshot/impl/LogicalRelSnapshotImpl.java | 8 + .../polypheny/db/interpreter/Bindables.java | 14 +- .../org/polypheny/db/plan/AlgOptUtil.java | 8 +- .../polypheny/db/plan/hep/HepAlgVertex.java | 2 +- .../org/polypheny/db/plan/hep/HepPlanner.java | 64 ++++---- .../processing/LogicalAlgAnalyzeShuttle.java | 14 +- .../polypheny/db/rex/RexTableIndexRef.java | 8 +- .../org/polypheny/db/schema/Namespace.java | 4 +- .../schema/impl/AbstractEntityQueryable.java | 4 +- .../db/schema/impl/AbstractNamespace.java | 6 +- .../db/schema/impl/DelegatingNamespace.java | 4 +- .../db/schema/types/ModifiableCollection.java | 4 +- .../db/schema/types/ModifiableGraph.java | 4 +- .../db/schema/types/ModifiableTable.java | 4 +- .../org/polypheny/db/tools/AlgBuilder.java | 8 +- .../db/util/InitializerExpressionFactory.java | 6 +- .../NullInitializerExpressionFactory.java | 6 +- .../main/java/org/polypheny/db/util/Util.java | 4 +- .../polypheny/db/catalog/CountingFactory.java | 6 +- .../EmpInitializerExpressionFactory.java | 6 +- .../db/schemas/HrClusteredSchema.java | 6 +- .../java/org/polypheny/db/test/JdbcTest.java | 4 +- .../java/org/polypheny/db/PolyphenyDb.java | 2 +- .../db/processing/AbstractQueryProcessor.java | 4 +- .../db/routing/routers/BaseRouter.java | 6 +- .../db/transaction/EntityAccessMap.java | 6 +- .../db/monitoring/statistics/QueryResult.java | 6 +- .../org/polypheny/db/avatica/DbmsMeta.java | 107 ++++++------- ...nHandle.java => PolyConnectionHandle.java} | 27 +--- ...enyDbResultSet.java => PolyResultSet.java} | 6 +- .../db/avatica/PolyStatementHandle.java | 4 +- .../db/avatica/PrimitiveDatabase.java | 28 ++++ .../adapter/cottontail/CottontailEntity.java | 4 +- .../cottontail/CottontailNamespace.java | 4 +- .../db/adapter/file/FileStoreSchema.java | 4 +- .../adapter/file/FileTranslatableEntity.java | 4 +- .../db/adapter/file/algebra/FileScan.java | 4 +- .../polypheny/db/adapter/jdbc/JdbcSchema.java | 4 +- .../polypheny/db/adapter/jdbc/JdbcTable.java | 4 +- .../db/adapter/jdbc/alg2sql/PlannerTest.java | 4 +- .../db/adapter/mongodb/MongoAlg.java | 35 ++-- .../db/adapter/mongodb/MongoEntity.java | 6 +- .../db/adapter/mongodb/MongoNamespace.java | 9 +- .../mongodb/rules/MongoDocumentModify.java | 3 +- .../adapter/mongodb/rules/MongoProject.java | 7 +- .../db/adapter/mongodb/rules/MongoRules.java | 4 +- .../db/adapter/mongodb/rules/MongoScan.java | 4 +- .../mongodb/rules/MongoTableModify.java | 43 +++-- .../rules/MongoToEnumerableConverter.java | 4 +- .../languages/mql2alg/MqlToAlgConverter.java | 16 +- .../polypheny/db/adapter/neo4j/NeoEntity.java | 6 +- .../polypheny/db/adapter/neo4j/NeoGraph.java | 6 +- .../db/adapter/neo4j/NeoNamespace.java | 4 +- .../polypheny/db/sql/language/SqlUtil.java | 4 +- .../language/validate/AbstractNamespace.java | 4 +- .../validate/DelegatingNamespace.java | 4 +- .../language/validate/DelegatingScope.java | 7 +- .../db/sql/language/validate/EmptyScope.java | 4 +- .../language/validate/EntityNamespace.java | 15 +- .../validate/IdentifierNamespace.java | 12 +- .../db/sql/language/validate/ListScope.java | 4 +- .../language/validate/SqlValidatorImpl.java | 33 ++-- .../validate/SqlValidatorNamespace.java | 4 +- .../language/validate/SqlValidatorUtil.java | 15 +- .../language/validate/UnnestNamespace.java | 4 +- .../db/sql/language/validate/WithScope.java | 6 +- .../db/sql/sql2alg/SqlToAlgConverter.java | 33 ++-- .../SqlToRelConverterExtendedTest.java | 4 +- 125 files changed, 524 insertions(+), 732 deletions(-) rename core/src/main/java/org/polypheny/db/catalog/entity/{LogicalEntity.java => Entity.java} (93%) delete mode 100644 core/src/main/java/org/polypheny/db/catalog/entity/LogicalDatabase.java rename core/src/main/java/org/polypheny/db/catalog/entity/{LogicalObject.java => PolyObject.java} (95%) rename plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/{PolyphenyDbConnectionHandle.java => PolyConnectionHandle.java} (73%) rename plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/{PolyphenyDbResultSet.java => PolyResultSet.java} (91%) create mode 100644 plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PrimitiveDatabase.java diff --git a/core/src/main/java/org/polypheny/db/adapter/Modifiable.java b/core/src/main/java/org/polypheny/db/adapter/Modifiable.java index 69134b8b62..90d5ffc526 100644 --- a/core/src/main/java/org/polypheny/db/adapter/Modifiable.java +++ b/core/src/main/java/org/polypheny/db/adapter/Modifiable.java @@ -46,7 +46,7 @@ import org.polypheny.db.algebra.type.DocumentType; import org.polypheny.db.algebra.type.GraphType; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.allocation.AllocationCollection; import org.polypheny.db.catalog.entity.allocation.AllocationGraph; import org.polypheny.db.catalog.entity.allocation.AllocationTable; @@ -73,7 +73,7 @@ public interface Modifiable extends Scannable { - static AlgNode attachRelationalGraphUpdate( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder builder, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable ) { + static AlgNode attachRelationalGraphUpdate( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder builder, Entity nodesTable, Entity nodePropertiesTable, Entity edgesTable, Entity edgePropertiesTable ) { AlgNode project = new LogicalLpgProject( alg.getCluster(), alg.getTraitSet(), alg.getInput(), alg.operations, alg.ids ); List inputs = new ArrayList<>(); @@ -96,7 +96,7 @@ static AlgNode attachRelationalGraphUpdate( Modifiable modifiable, AlgNode provi } - static AlgNode attachRelationalGraphDelete( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable ) { + static AlgNode attachRelationalGraphDelete( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, Entity nodesTable, Entity nodePropertiesTable, Entity edgesTable, Entity edgePropertiesTable ) { AlgNode project = new LogicalLpgProject( alg.getCluster(), alg.getTraitSet(), alg.getInput(), alg.operations, alg.ids ); List inputs = new ArrayList<>(); @@ -117,7 +117,7 @@ static AlgNode attachRelationalGraphDelete( Modifiable modifiable, AlgNode provi } - static List attachPreparedGraphNodeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, AlgBuilder algBuilder ) { + static List attachPreparedGraphNodeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, Entity nodesTable, Entity nodePropertiesTable, AlgBuilder algBuilder ) { RexBuilder rexBuilder = algBuilder.getRexBuilder(); AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory(); @@ -146,7 +146,7 @@ static List attachPreparedGraphNodeModifyDelete( Modifiable modifiable, return inputs; } - static AlgNode attachRelationalRelatedInsert( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable ) { + static AlgNode attachRelationalRelatedInsert( Modifiable modifiable, AlgNode provider, LogicalLpgModify alg, AlgBuilder algBuilder, Entity nodesTable, Entity nodePropertiesTable, Entity edgesTable, Entity edgePropertiesTable ) { List inputs = new ArrayList<>(); List sequence = new ArrayList<>(); @@ -165,7 +165,7 @@ static AlgNode attachRelationalRelatedInsert( Modifiable modifiable, AlgNode pro return new LogicalStreamer( alg.getCluster(), alg.getTraitSet(), provider, transformer ); } - static List attachPreparedGraphNodeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity nodesTable, LogicalEntity nodePropertiesTable, AlgBuilder algBuilder ) { + static List attachPreparedGraphNodeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, Entity nodesTable, Entity nodePropertiesTable, AlgBuilder algBuilder ) { RexBuilder rexBuilder = algBuilder.getRexBuilder(); AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory(); @@ -192,7 +192,7 @@ static List attachPreparedGraphNodeModifyInsert( Modifiable modifiable, return inputs; } - static List attachPreparedGraphEdgeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable, AlgBuilder algBuilder ) { + static List attachPreparedGraphEdgeModifyDelete( Modifiable modifiable, AlgOptCluster cluster, Entity edgesTable, Entity edgePropertiesTable, AlgBuilder algBuilder ) { RexBuilder rexBuilder = algBuilder.getRexBuilder(); AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory(); @@ -218,7 +218,7 @@ static List attachPreparedGraphEdgeModifyDelete( Modifiable modifiable, return inputs; } - static List attachPreparedGraphEdgeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, LogicalEntity edgesTable, LogicalEntity edgePropertiesTable, AlgBuilder algBuilder ) { + static List attachPreparedGraphEdgeModifyInsert( Modifiable modifiable, AlgOptCluster cluster, Entity edgesTable, Entity edgePropertiesTable, AlgBuilder algBuilder ) { RexBuilder rexBuilder = algBuilder.getRexBuilder(); AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory(); @@ -248,7 +248,7 @@ static List attachPreparedGraphEdgeModifyInsert( Modifiable modifiable, } - static Modify getModify( LogicalEntity table, AlgNode input, Operation operation, List updateList, List sourceList ) { + static Modify getModify( Entity table, AlgNode input, Operation operation, List updateList, List sourceList ) { return table.unwrap( ModifiableTable.class ).toModificationTable( input.getCluster(), input.getTraitSet(), table, input, operation, updateList, sourceList ); } diff --git a/core/src/main/java/org/polypheny/db/adapter/java/ReflectiveSchema.java b/core/src/main/java/org/polypheny/db/adapter/java/ReflectiveSchema.java index 8f07b79c29..52533b4a1f 100644 --- a/core/src/main/java/org/polypheny/db/adapter/java/ReflectiveSchema.java +++ b/core/src/main/java/org/polypheny/db/adapter/java/ReflectiveSchema.java @@ -43,31 +43,19 @@ import java.lang.reflect.Type; import java.util.List; import java.util.Map; -import lombok.extern.slf4j.Slf4j; import org.apache.calcite.linq4j.Enumerable; import org.apache.calcite.linq4j.Linq4j; -import org.apache.calcite.linq4j.function.Function1; import org.apache.calcite.linq4j.tree.Primitive; -import org.apache.commons.lang3.NotImplementedException; -import org.polypheny.db.adapter.DataContext; import org.polypheny.db.algebra.AlgReferentialConstraint; -import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.algebra.type.AlgDataTypeFactory; -import org.polypheny.db.catalog.entity.LogicalEntity; -import org.polypheny.db.catalog.entity.logical.LogicalTable; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; -import org.polypheny.db.catalog.logistic.EntityType; import org.polypheny.db.schema.Function; import org.polypheny.db.schema.Namespace; import org.polypheny.db.schema.Namespace.Schema; -import org.polypheny.db.schema.Statistic; -import org.polypheny.db.schema.Statistics; import org.polypheny.db.schema.TableMacro; import org.polypheny.db.schema.impl.AbstractNamespace; import org.polypheny.db.schema.impl.ReflectiveFunctionBase; -import org.polypheny.db.schema.types.ScannableEntity; import org.polypheny.db.schema.types.TranslatableEntity; -import org.polypheny.db.type.entity.PolyValue; /** @@ -77,7 +65,7 @@ public class ReflectiveSchema extends AbstractNamespace implements Schema { private final Class clazz; private Object target; - private Map tableMap; + private Map tableMap; private Multimap functionMap; @@ -111,7 +99,7 @@ public Object getTarget() { @Override - public Map getTables() { + public Map getTables() { if ( tableMap == null ) { tableMap = createTableMap(); } @@ -119,17 +107,17 @@ public Map getTables() { } - private Map createTableMap() { - final ImmutableMap.Builder builder = ImmutableMap.builder(); + private Map createTableMap() { + final ImmutableMap.Builder builder = ImmutableMap.builder(); for ( Field field : clazz.getFields() ) { final String fieldName = field.getName(); - final LogicalEntity entity = fieldRelation( field ); + final Entity entity = fieldRelation( field ); if ( entity == null ) { continue; } builder.put( fieldName, entity ); } - Map tableMap = builder.build(); + Map tableMap = builder.build(); // Unique-Key - Foreign-Key for ( Field field : clazz.getFields() ) { if ( AlgReferentialConstraint.class.isAssignableFrom( field.getType() ) ) { @@ -177,7 +165,7 @@ private Multimap createFunctionMap() { /** * Returns a table based on a particular field of this schema. If the field is not of the right type to be a relation, returns null. */ - private LogicalEntity fieldRelation( final Field field ) { + private Entity fieldRelation( final Field field ) { final Type elementType = getElementType( field.getType() ); if ( elementType == null ) { return null; @@ -223,64 +211,6 @@ private static Enumerable toEnumerable( final Object o ) { } - /** - * Table that is implemented by reading from a Java object. - */ - @Slf4j - private static class ReflectiveEntity extends LogicalTable implements ScannableEntity { - - private final Type elementType; - private final Enumerable enumerable; - - - ReflectiveEntity( Type elementType, Enumerable enumerable, Long id, Long partitionId, Long adapterId ) { - super( id, "test", -1, EntityType.ENTITY, null, false ); - this.elementType = elementType; - this.enumerable = enumerable; - throw new NotImplementedException(); - } - - - @Override - public Statistic getStatistic() { - return Statistics.UNKNOWN; - } - - - @Override - public Enumerable scan( DataContext root ) { - if ( elementType == PolyValue[].class ) { - return enumerable; - } else { - //noinspection unchecked - //return enumerable.select( new FieldSelector( (Class) elementType ) ); - - log.warn( "todo 23f23" ); - return null; - } - } - - - @Override - public AlgDataType getRowType( AlgDataTypeFactory typeFactory ) { - return getRowType(); - } - - - /*@Override - public Queryable asQueryable( DataContext dataContext, Snapshot snapshot, String tableName ) { - return new AbstractTableQueryable( dataContext, snapshot, this, tableName ) { - @Override - @SuppressWarnings("unchecked") - public Enumerator enumerator() { - return (Enumerator) enumerable.enumerator(); - } - }; - }*/ - - } - - /** * Table macro based on a Java method. */ @@ -314,70 +244,5 @@ public TranslatableEntity apply( final List arguments ) { } - /** - * Table based on a Java field. - * - * @param element type - */ - private static class FieldEntity extends ReflectiveEntity { - - private final Field field; - private Statistic statistic; - - - FieldEntity( Field field, Type elementType, Enumerable enumerable, Long id, Long partitionId, Long adapterId ) { - this( field, elementType, enumerable, Statistics.UNKNOWN, id, partitionId, adapterId ); - } - - - FieldEntity( Field field, Type elementType, Enumerable enumerable, Statistic statistic, Long id, Long partitionId, Long adapterId ) { - super( elementType, enumerable, id, partitionId, adapterId ); - this.field = field; - this.statistic = statistic; - } - - - public String toString() { - return "Relation {field=" + field.getName() + "}"; - } - - - @Override - public Statistic getStatistic() { - return statistic; - } - - - } - - - /** - * Function that returns an array of a given object's field values. - */ - private static class FieldSelector implements Function1 { - - private final Field[] fields; - - - FieldSelector( Class elementType ) { - this.fields = elementType.getFields(); - } - - - @Override - public Object[] apply( Object o ) { - try { - final Object[] objects = new Object[fields.length]; - for ( int i = 0; i < fields.length; i++ ) { - objects[i] = fields[i].get( o ); - } - return objects; - } catch ( IllegalAccessException e ) { - throw new RuntimeException( e ); - } - } - - } - } diff --git a/core/src/main/java/org/polypheny/db/algebra/AbstractAlgNode.java b/core/src/main/java/org/polypheny/db/algebra/AbstractAlgNode.java index a6c50aa594..46d7c52d06 100644 --- a/core/src/main/java/org/polypheny/db/algebra/AbstractAlgNode.java +++ b/core/src/main/java/org/polypheny/db/algebra/AbstractAlgNode.java @@ -53,7 +53,7 @@ import org.polypheny.db.algebra.metadata.Metadata; import org.polypheny.db.algebra.metadata.MetadataFactory; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptPlanner; @@ -389,7 +389,7 @@ public final String getDescription() { @Override - public LogicalEntity getEntity() { + public Entity getEntity() { return null; } diff --git a/core/src/main/java/org/polypheny/db/algebra/AlgInput.java b/core/src/main/java/org/polypheny/db/algebra/AlgInput.java index 48477b907f..6a9a0134fc 100644 --- a/core/src/main/java/org/polypheny/db/algebra/AlgInput.java +++ b/core/src/main/java/org/polypheny/db/algebra/AlgInput.java @@ -36,7 +36,7 @@ import java.util.List; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.util.ImmutableBitSet; @@ -51,7 +51,7 @@ public interface AlgInput { AlgTraitSet getTraitSet(); - LogicalEntity getEntity( String entity ); + Entity getEntity( String entity ); /** * Returns the input relational expression. Throws if there is not precisely one input. 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 dbe08bf153..73fd0cd63a 100644 --- a/core/src/main/java/org/polypheny/db/algebra/AlgNode.java +++ b/core/src/main/java/org/polypheny/db/algebra/AlgNode.java @@ -44,7 +44,7 @@ import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.metadata.Metadata; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.plan.AlgImplementor; import org.polypheny.db.plan.AlgOptCluster; @@ -262,7 +262,7 @@ public interface AlgNode extends AlgOptNode, Cloneable { * * @return If this relational expression represents an access to a table, returns that table, otherwise returns null */ - LogicalEntity getEntity(); + Entity getEntity(); /** * Returns the name of this relational expression's class, sans package name, for use in explain. For example, for a diff --git a/core/src/main/java/org/polypheny/db/algebra/core/AlgFactories.java b/core/src/main/java/org/polypheny/db/algebra/core/AlgFactories.java index d02d2db39a..9858a34a4c 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/AlgFactories.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/AlgFactories.java @@ -66,7 +66,7 @@ import org.polypheny.db.algebra.logical.relational.LogicalUnion; import org.polypheny.db.algebra.logical.relational.LogicalValues; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.logistic.EntityType; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.Contexts; @@ -537,7 +537,7 @@ public interface ScanFactory { /** * Creates a {@link RelScan}. */ - AlgNode createScan( AlgOptCluster cluster, LogicalEntity entity ); + AlgNode createScan( AlgOptCluster cluster, Entity entity ); } @@ -548,7 +548,7 @@ public interface ScanFactory { private static class ScanFactoryImpl implements ScanFactory { @Override - public AlgNode createScan( AlgOptCluster cluster, LogicalEntity entity ) { + public AlgNode createScan( AlgOptCluster cluster, Entity entity ) { // Check if RelOptTable contains a View, in this case a LogicalViewScan needs to be created if ( entity.entityType == EntityType.VIEW ) { return LogicalRelViewScan.create( cluster, entity ); diff --git a/core/src/main/java/org/polypheny/db/algebra/core/common/Modify.java b/core/src/main/java/org/polypheny/db/algebra/core/common/Modify.java index 96aae50e34..8abcf77a1f 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/common/Modify.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/common/Modify.java @@ -22,12 +22,12 @@ import lombok.experimental.SuperBuilder; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.SingleAlg; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; @SuperBuilder(toBuilder = true) -public abstract class Modify extends SingleAlg { +public abstract class Modify extends SingleAlg { @Getter public final E entity; diff --git a/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java b/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java index 457d77d05a..54eae3b536 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/common/Scan.java @@ -18,12 +18,12 @@ import lombok.Getter; import org.polypheny.db.algebra.AbstractAlgNode; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; @Getter -public abstract class Scan extends AbstractAlgNode { +public abstract class Scan extends AbstractAlgNode { public final E entity; diff --git a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentModify.java b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentModify.java index ef7a4635c2..ee4023c7cc 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentModify.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentModify.java @@ -30,7 +30,7 @@ import org.polypheny.db.algebra.constant.Kind; import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptUtil; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.rex.RexNode; @@ -40,7 +40,7 @@ @SuperBuilder(toBuilder = true) @Value @NonFinal -public abstract class DocumentModify extends Modify implements DocumentAlg { +public abstract class DocumentModify extends Modify implements DocumentAlg { @NonNull public ImmutableMap updates; diff --git a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java index 2b6579c5dd..eed155f42c 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentScan.java @@ -18,13 +18,13 @@ import org.polypheny.db.algebra.core.common.Scan; import org.polypheny.db.algebra.type.DocumentType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.schema.trait.ModelTrait; -public abstract class DocumentScan extends Scan implements DocumentAlg { +public abstract class DocumentScan extends Scan implements DocumentAlg { /** diff --git a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentValues.java b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentValues.java index 123aaa98b7..108467f6b0 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentValues.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/document/DocumentValues.java @@ -26,7 +26,7 @@ import org.polypheny.db.algebra.logical.relational.LogicalValues; import org.polypheny.db.algebra.type.AlgDataTypeFactory; import org.polypheny.db.algebra.type.DocumentType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.AlgOptCluster; @@ -125,7 +125,7 @@ public LogicalValues getRelationalEquivalent() { } - public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { + public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { return List.of( getRelationalEquivalent() ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgModify.java b/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgModify.java index 29b8678553..1e0a6aa101 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgModify.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgModify.java @@ -21,7 +21,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.rex.RexNode; @@ -29,7 +29,7 @@ import org.polypheny.db.type.entity.PolyString; -public abstract class LpgModify extends Modify implements LpgAlg { +public abstract class LpgModify extends Modify implements LpgAlg { @Getter public final Operation operation; diff --git a/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgScan.java b/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgScan.java index 7fa9858f9c..6ec585fe26 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/lpg/LpgScan.java @@ -18,13 +18,13 @@ import org.polypheny.db.algebra.core.common.Scan; import org.polypheny.db.algebra.type.GraphType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.schema.trait.ModelTrait; -public abstract class LpgScan extends Scan implements LpgAlg { +public abstract class LpgScan extends Scan implements LpgAlg { /** 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 4bfa329c86..c5b7728c56 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 @@ -29,7 +29,7 @@ import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptPlanner; @@ -52,7 +52,7 @@ *
  • for {@code UPDATE}, all old values plus updated new values. * */ -public abstract class RelModify extends Modify implements RelAlg { +public abstract class RelModify extends Modify implements RelAlg { /** diff --git a/core/src/main/java/org/polypheny/db/algebra/core/relational/RelScan.java b/core/src/main/java/org/polypheny/db/algebra/core/relational/RelScan.java index 605928477e..0ba768adc6 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/relational/RelScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/relational/RelScan.java @@ -33,7 +33,7 @@ import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptPlanner; @@ -48,7 +48,7 @@ /** * Relational operator that returns the contents of a table. */ -public abstract class RelScan extends Scan implements RelAlg { +public abstract class RelScan extends Scan implements RelAlg { protected RelScan( AlgOptCluster cluster, AlgTraitSet traitSet, @NonNull E entity ) { super( cluster, traitSet.replace( ModelTrait.RELATIONAL ), entity ); @@ -87,7 +87,7 @@ public AlgDataType deriveRowType() { /** * Returns an identity projection for the given table. */ - public static ImmutableList identity( LogicalEntity entity ) { + public static ImmutableList identity( Entity entity ) { return ImmutableList.copyOf( IntStream.range( 0, entity.getRowType().getFieldCount() ).boxed().collect( Collectors.toList() ) ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/core/relational/RelationalTransformable.java b/core/src/main/java/org/polypheny/db/algebra/core/relational/RelationalTransformable.java index 85346c358d..9ff33fb901 100644 --- a/core/src/main/java/org/polypheny/db/algebra/core/relational/RelationalTransformable.java +++ b/core/src/main/java/org/polypheny/db/algebra/core/relational/RelationalTransformable.java @@ -20,7 +20,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.core.common.Modify.Operation; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.schema.types.ModifiableTable; @@ -31,10 +31,10 @@ public interface RelationalTransformable { - List getRelationalEquivalent( List values, List entities, Snapshot snapshot ); + List getRelationalEquivalent( List values, List entities, Snapshot snapshot ); - static Modify getModify( LogicalEntity entity, AlgNode alg, Operation operation ) { + static Modify getModify( Entity entity, AlgNode alg, Operation operation ) { return entity.unwrap( ModifiableTable.class ).toModificationTable( alg.getCluster(), alg.getTraitSet(), entity, alg, operation, null, null ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableScan.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableScan.java index 7e9a0f8043..806e9e5da2 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableScan.java @@ -38,7 +38,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalTable; import org.polypheny.db.interpreter.Row; import org.polypheny.db.plan.AlgOptCluster; @@ -78,7 +78,7 @@ public EnumerableScan( AlgOptCluster cluster, AlgTraitSet traitSet, PhysicalTabl /** * Creates an EnumerableScan. */ - public static EnumerableScan create( AlgOptCluster cluster, LogicalEntity entity ) { + public static EnumerableScan create( AlgOptCluster cluster, Entity entity ) { PhysicalTable physicalTable = entity.unwrap( PhysicalTable.class ); Class elementType = EnumerableScan.deduceElementType( physicalTable ); final AlgTraitSet traitSet = @@ -105,7 +105,7 @@ public int hashCode() { /** * Returns whether EnumerableScan can generate code to handle a particular variant of the Table SPI. */ - public static boolean canHandle( LogicalEntity entity ) { + public static boolean canHandle( Entity entity ) { // FilterableTable and ProjectableFilterableTable cannot be handled in/ enumerable convention because they might reject filters and those filters would need to be handled dynamically. return entity instanceof QueryableEntity || entity instanceof ScannableEntity; } diff --git a/core/src/main/java/org/polypheny/db/algebra/externalize/AlgJsonReader.java b/core/src/main/java/org/polypheny/db/algebra/externalize/AlgJsonReader.java index aee8aa1264..1f8c3e3eb7 100644 --- a/core/src/main/java/org/polypheny/db/algebra/externalize/AlgJsonReader.java +++ b/core/src/main/java/org/polypheny/db/algebra/externalize/AlgJsonReader.java @@ -53,7 +53,7 @@ import org.polypheny.db.algebra.AlgInput; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptSchema; import org.polypheny.db.plan.AlgTraitSet; @@ -127,7 +127,7 @@ public AlgTraitSet getTraitSet() { @Override - public LogicalEntity getEntity( String entity ) { + public Entity getEntity( String entity ) { final List list; if ( jsonAlg.get( entity ) instanceof String ) { String str = (String) jsonAlg.get( entity ); diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/common/LogicalStreamer.java b/core/src/main/java/org/polypheny/db/algebra/logical/common/LogicalStreamer.java index 5e98e5e641..bbe14c2d6f 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/common/LogicalStreamer.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/common/LogicalStreamer.java @@ -36,7 +36,7 @@ import org.polypheny.db.algebra.logical.relational.LogicalValues; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; @@ -168,7 +168,7 @@ public static void attachFilter( AlgNode modify, AlgBuilder algBuilder, RexBuild } - public static void attachFilter( LogicalEntity entity, AlgBuilder algBuilder, RexBuilder rexBuilder, List indexes ) { + public static void attachFilter( Entity entity, AlgBuilder algBuilder, RexBuilder rexBuilder, List indexes ) { List fields = new ArrayList<>(); int i = 0; for ( AlgDataTypeField field : entity.getRowType().getFields() ) { diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentModify.java b/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentModify.java index 1f38c9e785..56833bdbea 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentModify.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentModify.java @@ -25,7 +25,7 @@ import org.polypheny.db.algebra.AlgShuttle; import org.polypheny.db.algebra.core.document.DocumentModify; import org.polypheny.db.algebra.core.relational.RelationalTransformable; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.rex.RexNode; @@ -33,17 +33,17 @@ @SuperBuilder(toBuilder = true) @EqualsAndHashCode(callSuper = true) @Value -public class LogicalDocumentModify extends DocumentModify implements RelationalTransformable { +public class LogicalDocumentModify extends DocumentModify implements RelationalTransformable { /** * Subclass of {@link DocumentModify} not targeted at any particular engine or calling convention. */ - public LogicalDocumentModify( AlgTraitSet traits, LogicalEntity entity, AlgNode input, Operation operation, Map updates, List removes, Map renames ) { + public LogicalDocumentModify( AlgTraitSet traits, Entity entity, AlgNode input, Operation operation, Map updates, List removes, Map renames ) { super( traits, entity, input, operation, updates, removes, renames ); } - public static LogicalDocumentModify create( LogicalEntity entity, AlgNode input, Operation operation, Map updates, List removes, Map renames ) { + public static LogicalDocumentModify create( Entity entity, AlgNode input, Operation operation, Map updates, List removes, Map renames ) { return new LogicalDocumentModify( input.getTraitSet(), entity, input, operation, updates, removes, renames ); } @@ -55,7 +55,7 @@ public AlgNode copy( AlgTraitSet traitSet, List inputs ) { @Override - public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { + public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { return List.of( RelationalTransformable.getModify( entities.get( 0 ), values.get( 0 ), operation ) ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentScan.java b/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentScan.java index e0937fea86..a5e297fd6b 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentScan.java @@ -22,7 +22,7 @@ import org.polypheny.db.algebra.core.document.DocumentScan; import org.polypheny.db.algebra.core.relational.RelationalTransformable; import org.polypheny.db.algebra.logical.relational.LogicalRelScan; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptRule; @@ -30,23 +30,23 @@ import org.polypheny.db.schema.trait.ModelTrait; -public class LogicalDocumentScan extends DocumentScan implements RelationalTransformable { +public class LogicalDocumentScan extends DocumentScan implements RelationalTransformable { /** * Subclass of {@link DocumentScan} not targeted at any particular engine or calling convention. */ - public LogicalDocumentScan( AlgOptCluster cluster, AlgTraitSet traitSet, LogicalEntity document ) { + public LogicalDocumentScan( AlgOptCluster cluster, AlgTraitSet traitSet, Entity document ) { super( cluster, traitSet.replace( ModelTrait.DOCUMENT ), document ); } - public static AlgNode create( AlgOptCluster cluster, LogicalEntity collection ) { + public static AlgNode create( AlgOptCluster cluster, Entity collection ) { return new LogicalDocumentScan( cluster, cluster.traitSet(), collection ); } @Override - public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { + public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { return List.of( AlgOptRule.convert( LogicalRelScan.create( getCluster(), entities.get( 0 ) ), ModelTrait.RELATIONAL ) ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgModify.java b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgModify.java index ea0611931d..9d658dc0a1 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgModify.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgModify.java @@ -24,7 +24,7 @@ import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.core.lpg.LpgModify; import org.polypheny.db.algebra.core.relational.RelationalTransformable; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptUtil; @@ -33,13 +33,13 @@ import org.polypheny.db.type.entity.PolyString; -public class LogicalLpgModify extends LpgModify implements RelationalTransformable { +public class LogicalLpgModify extends LpgModify implements RelationalTransformable { /** * Subclass of {@link LpgModify} not targeted at any particular engine or calling convention. */ - public LogicalLpgModify( AlgOptCluster cluster, AlgTraitSet traits, LogicalEntity entity, AlgNode input, Operation operation, List ids, List operations ) { + public LogicalLpgModify( AlgOptCluster cluster, AlgTraitSet traits, Entity entity, AlgNode input, Operation operation, List ids, List operations ) { super( cluster, traits, entity, input, operation, ids, operations, AlgOptUtil.createDmlRowType( Kind.INSERT, cluster.getTypeFactory() ) ); } @@ -51,7 +51,7 @@ public AlgNode copy( AlgTraitSet traitSet, List inputs ) { @Override - public List getRelationalEquivalent( List inputs, List entities, Snapshot snapshot ) { + public List getRelationalEquivalent( List inputs, List entities, Snapshot snapshot ) { List modifies = new ArrayList<>(); // modify of nodes diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgScan.java b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgScan.java index 42c066dd9d..e6943091a6 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgScan.java @@ -28,7 +28,7 @@ import org.polypheny.db.algebra.logical.relational.LogicalRelScan; import org.polypheny.db.algebra.operators.OperatorName; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.languages.OperatorRegistry; import org.polypheny.db.plan.AlgOptCluster; @@ -38,19 +38,19 @@ import org.polypheny.db.schema.trait.ModelTrait; -public class LogicalLpgScan extends LpgScan implements RelationalTransformable { +public class LogicalLpgScan extends LpgScan implements RelationalTransformable { /** * Subclass of {@link LpgScan} not targeted at any particular engine or calling convention. */ - public LogicalLpgScan( AlgOptCluster cluster, AlgTraitSet traitSet, LogicalEntity graph, AlgDataType rowType ) { + public LogicalLpgScan( AlgOptCluster cluster, AlgTraitSet traitSet, Entity graph, AlgDataType rowType ) { super( cluster, traitSet.replace( ModelTrait.GRAPH ), graph ); this.rowType = rowType; } @Override - public List getRelationalEquivalent( List inputs, List entities, Snapshot snapshot ) { + public List getRelationalEquivalent( List inputs, List entities, Snapshot snapshot ) { assert !entities.isEmpty(); AlgTraitSet out = getTraitSet().replace( ModelTrait.RELATIONAL ); LogicalRelScan nodes = new LogicalRelScan( getCluster(), out, entities.get( 0 ) ); diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgValues.java b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgValues.java index dfa3e2c8f5..0a6c4e2b02 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgValues.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgValues.java @@ -36,7 +36,7 @@ import org.polypheny.db.algebra.type.AlgDataTypeFieldImpl; import org.polypheny.db.algebra.type.AlgDataTypeSystem; import org.polypheny.db.algebra.type.AlgRecordType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; @@ -118,7 +118,7 @@ public static LogicalLpgValues create( @Override - public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { + public List getRelationalEquivalent( List values, List entities, Snapshot snapshot ) { AlgTraitSet out = traitSet.replace( ModelTrait.RELATIONAL ); AlgOptCluster cluster = AlgOptCluster.create( getCluster().getPlanner(), getCluster().getRexBuilder(), out, snapshot ); diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelModify.java b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelModify.java index 0a34f34164..39a361e789 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelModify.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelModify.java @@ -20,7 +20,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.AlgShuttle; import org.polypheny.db.algebra.core.relational.RelModify; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.plan.Convention; @@ -31,7 +31,7 @@ /** * Sub-class of {@link RelModify} not targeted at any particular engine or calling convention. */ -public final class LogicalRelModify extends RelModify { +public final class LogicalRelModify extends RelModify { /** @@ -42,7 +42,7 @@ public final class LogicalRelModify extends RelModify { public LogicalRelModify( AlgOptCluster cluster, AlgTraitSet traitSet, - LogicalEntity table, + Entity table, AlgNode input, Operation operation, List updateColumns, @@ -54,7 +54,7 @@ public LogicalRelModify( public LogicalRelModify( AlgTraitSet traits, - LogicalEntity table, + Entity table, AlgNode child, Operation operation, List targets, @@ -67,7 +67,7 @@ public LogicalRelModify( * Creates a LogicalModify. */ public static LogicalRelModify create( - LogicalEntity table, + Entity table, AlgNode input, Operation operation, List updateColumns, diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelScan.java b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelScan.java index 889bef4fe0..cd34a7ffcf 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelScan.java @@ -41,7 +41,7 @@ import org.polypheny.db.algebra.AlgInput; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.relational.RelScan; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalMaterializedView; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.logistic.EntityType; @@ -73,7 +73,7 @@ * * can. It is the optimizer's responsibility to find these ways, by applying transformation rules. */ -public final class LogicalRelScan extends RelScan { +public final class LogicalRelScan extends RelScan { /** @@ -81,7 +81,7 @@ public final class LogicalRelScan extends RelScan { * * Use {@link #create} unless you know what you're doing. */ - public LogicalRelScan( AlgOptCluster cluster, AlgTraitSet traitSet, LogicalEntity table ) { + public LogicalRelScan( AlgOptCluster cluster, AlgTraitSet traitSet, Entity table ) { super( cluster, traitSet, table ); } @@ -107,7 +107,7 @@ public AlgNode copy( AlgTraitSet traitSet, List inputs ) { * * @param cluster Cluster */ - public static LogicalRelScan create( AlgOptCluster cluster, final LogicalEntity entity ) { + public static LogicalRelScan create( AlgOptCluster cluster, final Entity entity ) { final AlgTraitSet traitSet = cluster.traitSetOf( Convention.NONE ) diff --git a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelViewScan.java b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelViewScan.java index fe04c49f3e..1bc8c4b362 100644 --- a/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelViewScan.java +++ b/core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelViewScan.java @@ -26,7 +26,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.relational.RelScan; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalView; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; @@ -36,20 +36,20 @@ @Getter -public class LogicalRelViewScan extends RelScan { +public class LogicalRelViewScan extends RelScan { private final AlgNode algNode; private final AlgCollation algCollation; - public LogicalRelViewScan( AlgOptCluster cluster, AlgTraitSet traitSet, LogicalEntity table, AlgNode algNode, AlgCollation algCollation ) { + public LogicalRelViewScan( AlgOptCluster cluster, AlgTraitSet traitSet, Entity table, AlgNode algNode, AlgCollation algCollation ) { super( cluster, traitSet, table ); this.algNode = algNode; this.algCollation = algCollation; } - public static AlgNode create( AlgOptCluster cluster, final LogicalEntity entity ) { + public static AlgNode create( AlgOptCluster cluster, final Entity entity ) { final AlgTraitSet traitSet = cluster.traitSetOf( Convention.NONE ) diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgColumnOrigin.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgColumnOrigin.java index dcfb5ed227..bb77ad9abc 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgColumnOrigin.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgColumnOrigin.java @@ -34,7 +34,7 @@ package org.polypheny.db.algebra.metadata; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; /** @@ -42,14 +42,14 @@ */ public class AlgColumnOrigin { - private final LogicalEntity originTable; + private final Entity originTable; private final int iOriginColumn; private final boolean isDerived; - public AlgColumnOrigin( LogicalEntity origin, int iOriginColumn, boolean isDerived ) { + public AlgColumnOrigin( Entity origin, int iOriginColumn, boolean isDerived ) { this.originTable = origin; this.iOriginColumn = iOriginColumn; this.isDerived = isDerived; @@ -59,7 +59,7 @@ public AlgColumnOrigin( LogicalEntity origin, int iOriginColumn, boolean isDeriv /** * @return table of origin */ - public LogicalEntity getOriginTable() { + public Entity getOriginTable() { return originTable; } diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdCollation.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdCollation.java index 6c01384242..9f98966b63 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdCollation.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdCollation.java @@ -73,7 +73,7 @@ import org.polypheny.db.algebra.enumerable.EnumerableSemiJoin; import org.polypheny.db.algebra.enumerable.EnumerableThetaJoin; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.hep.HepAlgVertex; import org.polypheny.db.plan.volcano.AlgSubset; import org.polypheny.db.rex.RexCall; @@ -203,7 +203,7 @@ public ImmutableList collations( AlgSubset alg, AlgMetadataQuery m /** * Helper method to determine a {@link RelScan}'s collation. */ - public static List table( LogicalEntity table ) { + public static List table( Entity table ) { return table.getCollations(); } diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnOrigins.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnOrigins.java index 8cd2afb462..49670d88a3 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnOrigins.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnOrigins.java @@ -47,7 +47,7 @@ import org.polypheny.db.algebra.core.SetOp; import org.polypheny.db.algebra.core.Sort; import org.polypheny.db.algebra.core.TableFunctionScan; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.rex.RexIndexRef; import org.polypheny.db.rex.RexNode; import org.polypheny.db.rex.RexVisitor; @@ -222,7 +222,7 @@ public Set getColumnOrigins( AlgNode alg, AlgMetadataQuery mq, final Set set = new HashSet<>(); - LogicalEntity entity = alg.getEntity(); + Entity entity = alg.getEntity(); if ( entity == null ) { // Somebody is making column values up out of thin air, like a VALUES clause, so we return an empty set. return set; diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnUniqueness.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnUniqueness.java index c43605bc03..37b533b60e 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnUniqueness.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdColumnUniqueness.java @@ -71,7 +71,7 @@ /** - * RelMdColumnUniqueness supplies a default implementation of {@link AlgMetadataQuery#areColumnsUnique} for the standard logical algebra. + * {@link AlgMdColumnUniqueness} supplies a default implementation of {@link AlgMetadataQuery#areColumnsUnique} for the standard logical algebra. */ public class AlgMdColumnUniqueness implements MetadataHandler { @@ -212,10 +212,9 @@ public Boolean areColumnsUnique( Project alg, AlgMetadataQuery mq, ImmutableBitS if ( castType.equals( origType ) ) { childColumns.set( ((RexIndexRef) castOperand).getIndex() ); } - } else { - // If the expression will not influence uniqueness of the projection, then skip it. - continue; } + // If the expression does not influence uniqueness of the projection, then skip it. + continue; } // If no columns can affect uniqueness, then return unknown diff --git a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistribution.java b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistribution.java index 0bffb59b7f..df1f16b9cd 100644 --- a/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistribution.java +++ b/core/src/main/java/org/polypheny/db/algebra/metadata/AlgMdDistribution.java @@ -49,7 +49,7 @@ import org.polypheny.db.algebra.core.Values; import org.polypheny.db.algebra.core.relational.RelScan; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.hep.HepAlgVertex; import org.polypheny.db.rex.RexLiteral; import org.polypheny.db.rex.RexNode; @@ -130,7 +130,7 @@ public AlgDistribution distribution( HepAlgVertex alg, AlgMetadataQuery mq ) { /** * Helper method to determine a {@link RelScan}'s distribution. */ - public static AlgDistribution table( LogicalEntity table ) { + public static AlgDistribution table( Entity table ) { return table.getDistribution(); } 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 7cb4bc21f5..ceb01897e5 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 @@ -48,7 +48,7 @@ import org.polypheny.db.algebra.AlgDistribution; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.constant.ExplainLevel; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptPredicateList; import org.polypheny.db.rex.RexNode; @@ -392,7 +392,7 @@ public Set getTableReferences( AlgNode alg ) { * @param alg the AlgNode * @return the table, if the {@link AlgNode} is a simple table; otherwise null */ - public LogicalEntity getTableOrigin( AlgNode alg ) { + public Entity getTableOrigin( AlgNode alg ) { // Determine the simple origin of the first column in the/ AlgNode. If it's simple, then that means that the underlying table is also simple, even if the column itself is derived. if ( alg.getRowType().getFieldCount() == 0 ) { return null; diff --git a/core/src/main/java/org/polypheny/db/algebra/mutable/MutableTableModify.java b/core/src/main/java/org/polypheny/db/algebra/mutable/MutableTableModify.java index 3da0233032..73e1a3b68a 100644 --- a/core/src/main/java/org/polypheny/db/algebra/mutable/MutableTableModify.java +++ b/core/src/main/java/org/polypheny/db/algebra/mutable/MutableTableModify.java @@ -39,7 +39,7 @@ import org.polypheny.db.algebra.core.common.Modify.Operation; import org.polypheny.db.algebra.core.relational.RelModify; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.rex.RexNode; @@ -48,14 +48,14 @@ */ public class MutableTableModify extends MutableSingleAlg { - public final LogicalEntity table; + public final Entity table; public final Operation operation; public final List updateColumnList; public final List sourceExpressionList; public final boolean flattened; - private MutableTableModify( AlgDataType rowType, MutableAlg input, LogicalEntity table, Operation operation, List updateColumnList, List sourceExpressionList, boolean flattened ) { + private MutableTableModify( AlgDataType rowType, MutableAlg input, Entity table, Operation operation, List updateColumnList, List sourceExpressionList, boolean flattened ) { super( MutableAlgType.TABLE_MODIFY, rowType, input ); this.table = table; this.operation = operation; @@ -76,7 +76,7 @@ private MutableTableModify( AlgDataType rowType, MutableAlg input, LogicalEntity * @param sourceExpressionList List of value expressions to be set (e.g. exp1, exp2); null if not UPDATE * @param flattened Whether set flattens the input row type */ - public static MutableTableModify of( AlgDataType rowType, MutableAlg input, LogicalEntity table, Operation operation, List updateColumnList, List sourceExpressionList, boolean flattened ) { + public static MutableTableModify of( AlgDataType rowType, MutableAlg input, Entity table, Operation operation, List updateColumnList, List sourceExpressionList, boolean flattened ) { return new MutableTableModify( rowType, input, table, operation, updateColumnList, sourceExpressionList, flattened ); } diff --git a/core/src/main/java/org/polypheny/db/algebra/rules/LoptOptimizeJoinRule.java b/core/src/main/java/org/polypheny/db/algebra/rules/LoptOptimizeJoinRule.java index 9cc1f77291..3e78cdfb25 100644 --- a/core/src/main/java/org/polypheny/db/algebra/rules/LoptOptimizeJoinRule.java +++ b/core/src/main/java/org/polypheny/db/algebra/rules/LoptOptimizeJoinRule.java @@ -58,7 +58,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.languages.OperatorRegistry; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptRule; @@ -252,10 +252,10 @@ private void setJoinKey( ImmutableBitSet.Builder joinKeys, ImmutableBitSet.Build */ private void findRemovableSelfJoins( AlgMetadataQuery mq, LoptMultiJoin multiJoin ) { // Candidates for self-joins must be simple factors - Map simpleFactors = getSimpleFactors( mq, multiJoin ); + Map simpleFactors = getSimpleFactors( mq, multiJoin ); // See if a simple factor is repeated and therefore potentially is part of a self-join. Restrict each factor to at most one self-join. - final List repeatedTables = new ArrayList<>(); + final List repeatedTables = new ArrayList<>(); final TreeSet sortedFactors = new TreeSet<>(); sortedFactors.addAll( simpleFactors.keySet() ); final Map selfJoinPairs = new HashMap<>(); @@ -298,8 +298,8 @@ private void findRemovableSelfJoins( AlgMetadataQuery mq, LoptMultiJoin multiJoi * @param multiJoin join factors being optimized * @return map consisting of the simple factors and the tables they correspond */ - private Map getSimpleFactors( AlgMetadataQuery mq, LoptMultiJoin multiJoin ) { - final Map returnList = new HashMap<>(); + private Map getSimpleFactors( AlgMetadataQuery mq, LoptMultiJoin multiJoin ) { + final Map returnList = new HashMap<>(); // Loop through all join factors and locate the ones where each column referenced from the factor is not derived and originates from the same underlying table. Also, discard factors that // are null-generating or will be removed because of semijoins. @@ -311,7 +311,7 @@ private Map getSimpleFactors( AlgMetadataQuery mq, LoptM continue; } final AlgNode alg = multiJoin.getJoinFactor( factIdx ); - final LogicalEntity table = mq.getTableOrigin( alg ); + final Entity table = mq.getTableOrigin( alg ); if ( table != null ) { returnList.put( factIdx, table ); } @@ -1509,11 +1509,11 @@ public static boolean isRemovableSelfJoin( Join joinRel ) { // Make sure the join is between the same simple factor final AlgMetadataQuery mq = joinRel.getCluster().getMetadataQuery(); - final LogicalEntity leftTable = mq.getTableOrigin( left ); + final Entity leftTable = mq.getTableOrigin( left ); if ( leftTable == null ) { return false; } - final LogicalEntity rightTable = mq.getTableOrigin( right ); + final Entity rightTable = mq.getTableOrigin( right ); if ( rightTable == null ) { return false; } diff --git a/core/src/main/java/org/polypheny/db/algebra/rules/LoptSemiJoinOptimizer.java b/core/src/main/java/org/polypheny/db/algebra/rules/LoptSemiJoinOptimizer.java index e07eec7b82..cd5f358526 100644 --- a/core/src/main/java/org/polypheny/db/algebra/rules/LoptSemiJoinOptimizer.java +++ b/core/src/main/java/org/polypheny/db/algebra/rules/LoptSemiJoinOptimizer.java @@ -52,7 +52,7 @@ import org.polypheny.db.algebra.metadata.AlgMdUtil; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.operators.OperatorName; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.catalog.logistic.EntityType; import org.polypheny.db.languages.OperatorRegistry; @@ -342,7 +342,7 @@ private RexNode adjustSemiJoinCondition( LoptMultiJoin multiJoin, int leftAdjust */ private LcsEntity validateKeys( AlgNode factRel, List leftKeys, List rightKeys, List actualLeftKeys ) { int keyIdx = 0; - LogicalEntity theTable = null; + Entity theTable = null; ListIterator keyIter = leftKeys.listIterator(); while ( keyIter.hasNext() ) { boolean removeKey = false; @@ -352,7 +352,7 @@ private LcsEntity validateKeys( AlgNode factRel, List leftKeys, List { +public abstract class Entity implements PolyObject, Wrapper, Serializable, CatalogType, Expressible, Typed, Comparable { @Serialize public long id; @@ -59,6 +60,7 @@ public abstract class LogicalEntity implements LogicalObject, Wrapper, Serializa @Serialize @SerializeNullable + @Nullable public String name; @Serialize @@ -68,9 +70,9 @@ public abstract class LogicalEntity implements LogicalObject, Wrapper, Serializa public boolean modifiable; - public LogicalEntity( + public Entity( long id, - String name, + @Nullable String name, long namespaceId, EntityType type, DataModel dataModel, @@ -150,7 +152,7 @@ public String getNamespaceName() { @Override - public int compareTo( @NotNull LogicalEntity o ) { + public int compareTo( @NotNull Entity o ) { if ( !this.getClass().getSimpleName().equals( o.getClass().getSimpleName() ) ) { return -1; } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java index 1805d5b299..3a0ff404a8 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalAdapter.java @@ -32,7 +32,7 @@ @EqualsAndHashCode @Value @SuperBuilder(toBuilder = true) -public class LogicalAdapter implements LogicalObject { +public class LogicalAdapter implements PolyObject { private static final long serialVersionUID = -6140489767408917639L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalDatabase.java b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalDatabase.java deleted file mode 100644 index 94b575cd4c..0000000000 --- a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalDatabase.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2019-2022 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.polypheny.db.catalog.entity; - -import java.io.Serializable; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - - -@EqualsAndHashCode -public final class LogicalDatabase implements LogicalObject, Comparable { - - private static final long serialVersionUID = -4529369849606480011L; - - public final long id; - public final String name; - public final int ownerId; - public final String ownerName; - public final Long defaultNamespaceId; // can be null - public final String defaultNamespaceName; // can be null - - - public LogicalDatabase( - final long id, - @NonNull final String name, - final int ownerId, - @NonNull final String ownerName, - final Long defaultNamespaceId, - final String defaultNamespaceName ) { - this.id = id; - this.name = name; - this.ownerId = ownerId; - this.ownerName = ownerName; - this.defaultNamespaceId = defaultNamespaceId; - this.defaultNamespaceName = defaultNamespaceName; - } - - - // Used for creating ResultSets - @Override - public Serializable[] getParameterArray() { - return new Serializable[]{ name, ownerName, defaultNamespaceName }; - } - - - @Override - public int compareTo( LogicalDatabase o ) { - if ( o != null ) { - return (int) (this.id - o.id); - } - return -1; - } - - - @RequiredArgsConstructor - public static class PrimitiveCatalogDatabase { - - public final String tableCat; - public final String owner; - public final String defaultSchema; - - } - -} diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalQueryInterface.java b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalQueryInterface.java index 16b9f6ee8b..3f63b1e0fa 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalQueryInterface.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalQueryInterface.java @@ -31,7 +31,7 @@ @EqualsAndHashCode @Value @SuperBuilder(toBuilder = true) -public class LogicalQueryInterface implements LogicalObject { +public class LogicalQueryInterface implements PolyObject { private static final long serialVersionUID = 7212289724539530050L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalUser.java b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalUser.java index 9d81be4009..3defae3b69 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalUser.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/LogicalUser.java @@ -26,7 +26,7 @@ @EqualsAndHashCode @Value -public class LogicalUser implements LogicalObject, Comparable { +public class LogicalUser implements PolyObject, Comparable { private static final long serialVersionUID = 5022567585804699491L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalObject.java b/core/src/main/java/org/polypheny/db/catalog/entity/PolyObject.java similarity index 95% rename from core/src/main/java/org/polypheny/db/catalog/entity/LogicalObject.java rename to core/src/main/java/org/polypheny/db/catalog/entity/PolyObject.java index 4fb78adb4e..a7e251c2f0 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/LogicalObject.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/PolyObject.java @@ -23,7 +23,7 @@ /** * */ -public interface LogicalObject extends Serializable { +public interface PolyObject extends Serializable { Serializable[] getParameterArray(); diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationColumn.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationColumn.java index f950c010c8..488c7beb60 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationColumn.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationColumn.java @@ -26,14 +26,14 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.logistic.PlacementType; @EqualsAndHashCode @Value @SuperBuilder(toBuilder = true) -public class AllocationColumn implements LogicalObject { +public class AllocationColumn implements PolyObject { private static final long serialVersionUID = -1909757888176291095L; 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 fac6d95b99..20d65bc09e 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 @@ -24,7 +24,7 @@ import lombok.experimental.NonFinal; import lombok.experimental.SuperBuilder; import lombok.extern.slf4j.Slf4j; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.catalog.logistic.EntityType; import org.polypheny.db.catalog.logistic.PartitionType; @@ -35,7 +35,7 @@ @Slf4j @SuperBuilder @SerializeClass(subclasses = { AllocationTable.class, AllocationGraph.class, AllocationCollection.class }) -public abstract class AllocationEntity extends LogicalEntity { +public abstract class AllocationEntity extends Entity { @Serialize public long adapterId; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java index ecf181935c..b491e1d2c4 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartition.java @@ -27,7 +27,7 @@ import lombok.Getter; import lombok.Value; import org.jetbrains.annotations.NotNull; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.logistic.DataPlacementRole; import org.polypheny.db.catalog.logistic.PartitionType; import org.polypheny.db.catalog.logistic.PlacementType; @@ -37,7 +37,7 @@ * This class is considered the logical representation of a physical table on a specific store. */ @Value -public class AllocationPartition implements LogicalObject { +public class AllocationPartition implements PolyObject { private static final long serialVersionUID = 8835793248417591036L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java index aaf7988bc5..6b170e0acc 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPartitionGroup.java @@ -23,12 +23,12 @@ import lombok.EqualsAndHashCode; import lombok.Value; import org.jetbrains.annotations.Nullable; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; @EqualsAndHashCode @Value -public class AllocationPartitionGroup implements LogicalObject { +public class AllocationPartitionGroup implements PolyObject { private static final long serialVersionUID = 6229244317971622972L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPlacement.java b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPlacement.java index c82e74ee0b..8eab351537 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPlacement.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/allocation/AllocationPlacement.java @@ -20,10 +20,10 @@ import io.activej.serializer.annotations.Serialize; import java.io.Serializable; import lombok.Value; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; @Value -public class AllocationPlacement implements LogicalObject { +public class AllocationPlacement implements PolyObject { @Serialize public long id; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalCollection.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalCollection.java index 8780447c2e..893ffe552b 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalCollection.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalCollection.java @@ -24,14 +24,14 @@ import org.apache.calcite.linq4j.tree.Expression; import org.apache.calcite.linq4j.tree.Expressions; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.catalog.logistic.EntityType; @EqualsAndHashCode(callSuper = true) @Value @SuperBuilder(toBuilder = true) -public class LogicalCollection extends LogicalEntity implements LogicalObject { +public class LogicalCollection extends LogicalEntity implements PolyObject { private static final long serialVersionUID = -6490762948368178584L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalColumn.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalColumn.java index 437367a6cc..d2edfcaecc 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalColumn.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalColumn.java @@ -30,7 +30,7 @@ import org.polypheny.db.algebra.type.AlgDataTypeFactory; import org.polypheny.db.catalog.Catalog; import org.polypheny.db.catalog.entity.LogicalDefaultValue; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.logistic.Collation; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.type.PolyType; @@ -40,7 +40,7 @@ @Value @SuperBuilder(toBuilder = true) @NonFinal -public class LogicalColumn implements LogicalObject, Comparable { +public class LogicalColumn implements PolyObject, Comparable { private static final long serialVersionUID = -4792846455300897399L; @@ -175,7 +175,7 @@ public Serializable[] getParameterArray() { null, position, nullable ? "YES" : "NO", - LogicalObject.getEnumNameOrNull( collation ) }; + PolyObject.getEnumNameOrNull( collation ) }; } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalEntity.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalEntity.java index c165d48b6d..aa3672ecc0 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalEntity.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalEntity.java @@ -20,6 +20,7 @@ import lombok.Value; import lombok.experimental.NonFinal; import lombok.experimental.SuperBuilder; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.catalog.logistic.EntityType; @@ -27,7 +28,7 @@ @SuperBuilder(toBuilder = true) @Value @NonFinal -public abstract class LogicalEntity extends org.polypheny.db.catalog.entity.LogicalEntity { +public abstract class LogicalEntity extends Entity { public LogicalEntity( diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java index 4455a48323..73ca9d9c7a 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalForeignKey.java @@ -29,7 +29,7 @@ import lombok.SneakyThrows; import lombok.Value; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.logistic.ForeignKeyOption; import org.polypheny.db.catalog.snapshot.Snapshot; @@ -136,7 +136,7 @@ public Serializable[] getParameterArray( String referencedKeyColumnName, String // Used for creating ResultSets @RequiredArgsConstructor - public static class LogicalForeignKeyColumn implements LogicalObject { + public static class LogicalForeignKeyColumn implements PolyObject { private static final long serialVersionUID = 3287177728197412000L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalIndex.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalIndex.java index 078ee67b8e..83e481063b 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalIndex.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalIndex.java @@ -29,7 +29,7 @@ import lombok.Value; import lombok.experimental.SuperBuilder; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.logistic.IndexType; @@ -121,7 +121,7 @@ public Serializable[] getParameterArray( int ordinalPosition, String columnName // Used for creating ResultSets @RequiredArgsConstructor @Value - public static class LogicalIndexColumn implements LogicalObject { + public static class LogicalIndexColumn implements PolyObject { private static final long serialVersionUID = -5596459769680478780L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalKey.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalKey.java index da1e825128..2e42afb9b6 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalKey.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalKey.java @@ -27,7 +27,7 @@ import lombok.experimental.NonFinal; import org.jetbrains.annotations.NotNull; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.snapshot.Snapshot; @@ -35,7 +35,7 @@ @Value @NonFinal @SerializeClass(subclasses = { LogicalGenericKey.class, LogicalPrimaryKey.class, LogicalForeignKey.class }) -public abstract class LogicalKey implements LogicalObject, Comparable { +public abstract class LogicalKey implements PolyObject, Comparable { private static final long serialVersionUID = -5803762884192662540L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalNamespace.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalNamespace.java index f9b99f60e8..644f2b9d87 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalNamespace.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalNamespace.java @@ -27,14 +27,14 @@ import lombok.Value; import lombok.With; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.logistic.DataModel; @EqualsAndHashCode(callSuper = false) @With @Value -public class LogicalNamespace implements LogicalObject, Comparable { +public class LogicalNamespace implements PolyObject, Comparable { private static final long serialVersionUID = 3090632164988970558L; @@ -66,7 +66,7 @@ public LogicalNamespace( // Used for creating ResultSets @Override public Serializable[] getParameterArray() { - return new Serializable[]{ name, Catalog.DATABASE_NAME, Catalog.USER_NAME, LogicalObject.getEnumNameOrNull( dataModel ) }; + return new Serializable[]{ name, Catalog.DATABASE_NAME, Catalog.USER_NAME, PolyObject.getEnumNameOrNull( dataModel ) }; } diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java index 5d8462aaed..5be3518e48 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalPrimaryKey.java @@ -27,7 +27,7 @@ import lombok.RequiredArgsConstructor; import lombok.Value; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalObject; +import org.polypheny.db.catalog.entity.PolyObject; @Value @@ -68,7 +68,7 @@ public Serializable[] getParameterArray( String columnName, int keySeq ) { // Used for creating ResultSets @RequiredArgsConstructor - public static class LogicalPrimaryKeyColumn implements LogicalObject { + public static class LogicalPrimaryKeyColumn implements PolyObject { private static final long serialVersionUID = -2669773639977732201L; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalEntity.java b/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalEntity.java index 3a023a2238..f2e4bf57c9 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalEntity.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalEntity.java @@ -22,7 +22,7 @@ import lombok.Value; import lombok.experimental.NonFinal; import lombok.experimental.SuperBuilder; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.catalog.logistic.EntityType; @@ -31,7 +31,7 @@ @NonFinal @SuperBuilder(toBuilder = true) @SerializeClass(subclasses = { PhysicalTable.class, PhysicalGraph.class, PhysicalCollection.class }) -public abstract class PhysicalEntity extends LogicalEntity { +public abstract class PhysicalEntity extends Entity { @Serialize public String namespaceName; diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalField.java b/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalField.java index ea7afc1a59..3d27bed400 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalField.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/physical/PhysicalField.java @@ -24,7 +24,7 @@ import lombok.experimental.NonFinal; import lombok.experimental.SuperBuilder; import org.apache.calcite.linq4j.tree.Expression; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.catalog.logistic.EntityType; @@ -33,7 +33,7 @@ @SuperBuilder(toBuilder = true) @NonFinal @SerializeClass(subclasses = PhysicalColumn.class) -public abstract class PhysicalField extends LogicalEntity { +public abstract class PhysicalField extends Entity { @Serialize public long adapterId; diff --git a/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/LogicalRelSnapshotImpl.java b/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/LogicalRelSnapshotImpl.java index 3485d5d738..24f811bd4c 100644 --- a/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/LogicalRelSnapshotImpl.java +++ b/core/src/main/java/org/polypheny/db/catalog/snapshot/impl/LogicalRelSnapshotImpl.java @@ -53,6 +53,7 @@ public class LogicalRelSnapshotImpl implements LogicalRelSnapshot { ImmutableMap namespaces; ImmutableMap namespaceNames; + ImmutableMap namespaceCaseSensitive; ImmutableMap tables; @@ -64,6 +65,7 @@ public class LogicalRelSnapshotImpl implements LogicalRelSnapshot { ImmutableMap> tablesNamespace; ImmutableMap> tableColumns; + ImmutableMap columns; ImmutableMap, LogicalColumn> columnNames; @@ -71,6 +73,7 @@ public class LogicalRelSnapshotImpl implements LogicalRelSnapshot { ImmutableMap keys; ImmutableMap> tableKeys; + ImmutableMap columnsKey; ImmutableMap index; @@ -78,6 +81,7 @@ public class LogicalRelSnapshotImpl implements LogicalRelSnapshot { ImmutableMap constraints; ImmutableMap foreignKeys; + ImmutableMap primaryKeys; ImmutableMap> keyToIndexes; @@ -87,9 +91,13 @@ public class LogicalRelSnapshotImpl implements LogicalRelSnapshot { ImmutableMap>, LogicalColumn> tableColumnNameColumn; ImmutableMap, LogicalColumn> tableIdColumnNameColumn; + ImmutableMap> tableConstraints; + ImmutableMap> tableForeignKeys; + ImmutableMap nodes; + ImmutableMap> connectedViews; diff --git a/core/src/main/java/org/polypheny/db/interpreter/Bindables.java b/core/src/main/java/org/polypheny/db/interpreter/Bindables.java index f352cce4d9..03cc698e5e 100644 --- a/core/src/main/java/org/polypheny/db/interpreter/Bindables.java +++ b/core/src/main/java/org/polypheny/db/interpreter/Bindables.java @@ -77,7 +77,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptPlanner; @@ -168,7 +168,7 @@ public BindableScanRule( AlgBuilderFactory algBuilderFactory ) { @Override public void onMatch( AlgOptRuleCall call ) { final LogicalRelScan scan = call.alg( 0 ); - final LogicalEntity table = scan.entity; + final Entity table = scan.entity; if ( BindableScan.canHandle( table ) ) { call.transformTo( BindableScan.create( scan.getCluster(), scan.entity ) ); } @@ -180,7 +180,7 @@ public void onMatch( AlgOptRuleCall call ) { /** * Scan of a table that implements {@link ScannableEntity} and therefore can be converted into an {@link Enumerable}. */ - public static class BindableScan extends RelScan implements BindableAlg { + public static class BindableScan extends RelScan implements BindableAlg { public final ImmutableList filters; public final ImmutableList projects; @@ -191,7 +191,7 @@ public static class BindableScan extends RelScan implements Binda * * Use {@link #create} unless you know what you are doing. */ - BindableScan( AlgOptCluster cluster, AlgTraitSet traitSet, LogicalEntity entity, ImmutableList filters, ImmutableList projects ) { + BindableScan( AlgOptCluster cluster, AlgTraitSet traitSet, Entity entity, ImmutableList filters, ImmutableList projects ) { super( cluster, traitSet, entity ); this.filters = Objects.requireNonNull( filters ); this.projects = Objects.requireNonNull( projects ); @@ -202,7 +202,7 @@ public static class BindableScan extends RelScan implements Binda /** * Creates a BindableScan. */ - public static BindableScan create( AlgOptCluster cluster, LogicalEntity entity ) { + public static BindableScan create( AlgOptCluster cluster, Entity entity ) { return create( cluster, entity, ImmutableList.of(), identity( entity ) ); } @@ -210,7 +210,7 @@ public static BindableScan create( AlgOptCluster cluster, LogicalEntity entity ) /** * Creates a BindableScan. */ - public static BindableScan create( AlgOptCluster cluster, LogicalEntity entity, List filters, List projects ) { + public static BindableScan create( AlgOptCluster cluster, Entity entity, List filters, List projects ) { final AlgTraitSet traitSet = cluster.traitSetOf( BindableConvention.INSTANCE ) .replace( entity.dataModel.getModelTrait() ) @@ -267,7 +267,7 @@ public String algCompareString() { } - public static boolean canHandle( LogicalEntity entity ) { + public static boolean canHandle( Entity entity ) { return entity.unwrap( ScannableEntity.class ) != null || entity.unwrap( FilterableEntity.class ) != null || entity.unwrap( ProjectableFilterableEntity.class ) != null; diff --git a/core/src/main/java/org/polypheny/db/plan/AlgOptUtil.java b/core/src/main/java/org/polypheny/db/plan/AlgOptUtil.java index 655126c9be..df4517739d 100644 --- a/core/src/main/java/org/polypheny/db/plan/AlgOptUtil.java +++ b/core/src/main/java/org/polypheny/db/plan/AlgOptUtil.java @@ -102,7 +102,7 @@ import org.polypheny.db.algebra.type.AlgDataTypeFieldImpl; import org.polypheny.db.algebra.type.AlgDataTypeSystem; import org.polypheny.db.algebra.type.DocumentType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.languages.OperatorRegistry; import org.polypheny.db.nodes.Operator; @@ -191,7 +191,7 @@ public static boolean isOrder( AlgNode alg ) { /** * Returns a set of tables used by this expression or its children */ - public static Set findTables( AlgNode alg ) { + public static Set findTables( AlgNode alg ) { return new LinkedHashSet<>( findAllTables( alg ) ); } @@ -199,9 +199,9 @@ public static Set findTables( AlgNode alg ) { /** * Returns a list of all tables used by this expression or its children */ - public static List findAllTables( AlgNode alg ) { + public static List findAllTables( AlgNode alg ) { final Multimap, AlgNode> nodes = AlgMetadataQuery.instance().getNodeTypes( alg ); - final List usedTables = new ArrayList<>(); + final List usedTables = new ArrayList<>(); for ( Entry, Collection> e : nodes.asMap().entrySet() ) { if ( RelScan.class.isAssignableFrom( e.getKey() ) ) { for ( AlgNode node : e.getValue() ) { diff --git a/core/src/main/java/org/polypheny/db/plan/hep/HepAlgVertex.java b/core/src/main/java/org/polypheny/db/plan/hep/HepAlgVertex.java index 807ea8cd75..2ea75915a6 100644 --- a/core/src/main/java/org/polypheny/db/plan/hep/HepAlgVertex.java +++ b/core/src/main/java/org/polypheny/db/plan/hep/HepAlgVertex.java @@ -113,7 +113,7 @@ protected String computeDigest() { * * @param newRel new expression */ - void replaceRel( AlgNode newRel ) { + void replaceAlg( AlgNode newRel ) { currentAlg = newRel; } diff --git a/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java b/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java index ec1e8cb99a..53ebce7670 100644 --- a/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java +++ b/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java @@ -597,7 +597,7 @@ private boolean matchOperands( AlgOptRuleOperand operand, AlgNode alg, List childRels = (List) alg.getInputs(); + List childAlgs = (List) alg.getInputs(); switch ( operand.childPolicy ) { case ANY: return true; @@ -605,8 +605,8 @@ private boolean matchOperands( AlgOptRuleOperand operand, AlgNode alg, List children = new ArrayList<>( childRels.size() ); - for ( HepAlgVertex childRel : childRels ) { - children.add( childRel.getCurrentAlg() ); + final List children = new ArrayList<>( childAlgs.size() ); + for ( HepAlgVertex childAlg : childAlgs ) { + children.add( childAlg.getCurrentAlg() ); } nodeChildren.put( alg, children ); return true; default: int n = operand.getChildOperands().size(); - if ( childRels.size() < n ) { + if ( childAlgs.size() < n ) { return false; } - for ( Pair pair : Pair.zip( childRels, operand.getChildOperands() ) ) { + for ( Pair pair : Pair.zip( childAlgs, operand.getChildOperands() ) ) { boolean match = matchOperands( pair.right, pair.left.getCurrentAlg(), bindings, nodeChildren ); if ( !match ) { return false; @@ -637,16 +637,16 @@ private boolean matchOperands( AlgOptRuleOperand operand, AlgNode alg, List parentTrait ) { // TODO jvs 5-Apr-2006: Take the one that gives the best global cost rather than the best local cost. That requires "tentative" graph edits. assert !call.getResults().isEmpty(); - AlgNode bestRel = null; + AlgNode bestAlg = null; if ( call.getResults().size() == 1 ) { // No costing required; skip it to minimize the chance of hitting rels without cost information. - bestRel = call.getResults().get( 0 ); + bestAlg = call.getResults().get( 0 ); } else { AlgOptCost bestCost = null; final AlgMetadataQuery mq = call.getMetadataQuery(); @@ -656,15 +656,15 @@ private HepAlgVertex applyTransformationResults( HepAlgVertex vertex, HepRuleCal // Keep in the isTraceEnabled for the getRowCount method call LOGGER.trace( "considering {} with cumulative cost={} and rowcount={}", alg, thisCost, mq.getRowCount( alg ) ); } - if ( (bestRel == null) || thisCost.isLt( bestCost ) ) { - bestRel = alg; + if ( (bestAlg == null) || thisCost.isLt( bestCost ) ) { + bestAlg = alg; bestCost = thisCost; } } } ++nTransformations; - notifyTransformation( call, bestRel, true ); + notifyTransformation( call, bestAlg, true ); // Before we add the result, make a copy of the list of vertex's parents. We'll need this later during contraction so that we only update the existing parents, not the new parents (otherwise loops can result). // Also take care of filtering out parents by traits in case we're dealing with a converter rule. @@ -672,13 +672,13 @@ private HepAlgVertex applyTransformationResults( HepAlgVertex vertex, HepRuleCal final List parents = new ArrayList<>(); for ( HepAlgVertex parent : allParents ) { if ( parentTrait != null ) { - AlgNode parentRel = parent.getCurrentAlg(); - if ( parentRel instanceof Converter ) { + AlgNode parentAlg = parent.getCurrentAlg(); + if ( parentAlg instanceof Converter ) { // We don't support automatically chaining conversions. Treating a converter as a candidate parent here can cause the "iParentMatch" check below to // throw away a new converter needed in the multi-parent DAG case. continue; } - if ( !parentRel.getTraitSet().contains( parentTrait ) ) { + if ( !parentAlg.getTraitSet().contains( parentTrait ) ) { // This parent does not want the converted result. continue; } @@ -686,7 +686,7 @@ private HepAlgVertex applyTransformationResults( HepAlgVertex vertex, HepRuleCal parents.add( parent ); } - HepAlgVertex newVertex = addAlgToGraph( bestRel ); + HepAlgVertex newVertex = addAlgToGraph( bestAlg ); // There's a chance that newVertex is the same as one of the parents due to common subexpression recognition (e.g. the LogicalProject added by JoinCommuteRule). In that // case, treat the transformation as a nop to avoid creating a loop. @@ -700,13 +700,13 @@ private HepAlgVertex applyTransformationResults( HepAlgVertex vertex, HepRuleCal // Assume listener doesn't want to see garbage. collectGarbage(); } - notifyTransformation( call, bestRel, false ); + notifyTransformation( call, bestAlg, false ); dumpGraph(); return newVertex; } - // implement RelOptPlanner + // implement AlgOptPlanner @Override public AlgNode register( AlgNode alg, AlgNode equivAlg ) { // Ignore; this call is mostly to tell Volcano how to avoid infinite loops. @@ -720,14 +720,14 @@ public void onCopy( AlgNode alg, AlgNode newAlg ) { } - // implement RelOptPlanner + // implement AlgOptPlanner @Override public AlgNode ensureRegistered( AlgNode alg, AlgNode equivAlg ) { return alg; } - // implement RelOptPlanner + // implement AlgOptPlanner @Override public boolean isRegistered( AlgNode alg ) { return true; @@ -740,7 +740,7 @@ private HepAlgVertex addAlgToGraph( AlgNode alg ) { return (HepAlgVertex) alg; } - // Recursively add children, replacing this rel's inputs with corresponding child vertices. + // Recursively add children, replacing this algs inputs with corresponding child vertices. final List inputs = alg.getInputs(); final List newInputs = new ArrayList<>(); for ( AlgNode input1 : inputs ) { @@ -749,9 +749,9 @@ private HepAlgVertex addAlgToGraph( AlgNode alg ) { } if ( !Util.equalShallow( inputs, newInputs ) ) { - AlgNode oldRel = alg; + AlgNode oldAlg = alg; alg = alg.copy( alg.getTraitSet(), newInputs ); - onCopy( oldRel, alg ); + onCopy( oldAlg, alg ); } // Compute digest first time we add to DAG, otherwise can't get equivVertex for common sub-expression alg.recomputeDigest(); @@ -792,18 +792,18 @@ private void contractVertices( HepAlgVertex preservedVertex, HepAlgVertex discar // Update specified parents of discardedVertex. for ( HepAlgVertex parent : parents ) { - AlgNode parentRel = parent.getCurrentAlg(); - List inputs = parentRel.getInputs(); + AlgNode parentAlg = parent.getCurrentAlg(); + List inputs = parentAlg.getInputs(); for ( int i = 0; i < inputs.size(); ++i ) { AlgNode child = inputs.get( i ); if ( child != discardedVertex ) { continue; } - parentRel.replaceInput( i, preservedVertex ); + parentAlg.replaceInput( i, preservedVertex ); } graph.removeEdge( parent, discardedVertex ); graph.addEdge( parent, preservedVertex ); - updateVertex( parent, parentRel ); + updateVertex( parent, parentAlg ); } // NOTE: we don't actually do graph.removeVertex(discardedVertex), because it might still be reachable from preservedVertex. Leave that job for garbage collection. @@ -828,7 +828,7 @@ private void updateVertex( HepAlgVertex vertex, AlgNode alg ) { // otherwise the digest will be removed wrongly in the mapDigestToVertex when collectGC so it must update the digest that map to vertex mapDigestToVertex.put( newDigest, vertex ); if ( alg != vertex.getCurrentAlg() ) { - vertex.replaceRel( alg ); + vertex.replaceAlg( alg ); } notifyEquivalence( alg, vertex, false ); } @@ -936,14 +936,14 @@ private void dumpGraph() { } - // implement RelOptPlanner + // implement AlgOptPlanner @Override public void registerMetadataProviders( List list ) { list.add( 0, new HepAlgMetadataProvider() ); } - // implement RelOptPlanner + // implement AlgOptPlanner @Override public long getAlgMetadataTimestamp( AlgNode alg ) { // TODO jvs 20-Apr-2006: This is overly conservative. Better would be to keep a timestamp per HepAlgVertex, and update only affected vertices and all ancestors on each transformation. diff --git a/core/src/main/java/org/polypheny/db/processing/LogicalAlgAnalyzeShuttle.java b/core/src/main/java/org/polypheny/db/processing/LogicalAlgAnalyzeShuttle.java index 7a90a7aaf0..3711ea191e 100644 --- a/core/src/main/java/org/polypheny/db/processing/LogicalAlgAnalyzeShuttle.java +++ b/core/src/main/java/org/polypheny/db/processing/LogicalAlgAnalyzeShuttle.java @@ -64,7 +64,7 @@ import org.polypheny.db.algebra.logical.relational.LogicalSort; import org.polypheny.db.algebra.logical.relational.LogicalUnion; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.allocation.AllocationEntity; import org.polypheny.db.catalog.entity.logical.LogicalColumn; import org.polypheny.db.catalog.entity.logical.LogicalTable; @@ -459,7 +459,7 @@ private void getAvailableColumns( AlgNode scan ) { private void getPartitioningInfo( LogicalFilter filter ) { - LogicalEntity table = filter.getInput().getEntity(); + Entity table = filter.getInput().getEntity(); if ( table == null ) { return; } @@ -468,7 +468,7 @@ private void getPartitioningInfo( LogicalFilter filter ) { } - private void handleIfPartitioned( AlgNode node, LogicalEntity logicalEntity ) { + private void handleIfPartitioned( AlgNode node, Entity logicalEntity ) { // Only if table is partitioned if ( Catalog.snapshot().alloc().getPlacementsFromLogical( logicalEntity.id ).size() > 1 || Catalog.snapshot().alloc().getPartitionsFromLogical( logicalEntity.id ).size() > 1 ) { @@ -495,22 +495,22 @@ private void handleIfPartitioned( AlgNode node, LogicalEntity logicalEntity ) { private void getPartitioningInfo( LogicalDocumentFilter filter ) { - LogicalEntity entity = filter.getInput().getEntity(); + Entity entity = filter.getInput().getEntity(); if ( entity == null ) { return; } - handleIfPartitioned( filter, entity.unwrap( LogicalEntity.class ) ); + handleIfPartitioned( filter, entity.unwrap( Entity.class ) ); } private void getPartitioningInfo( LogicalLpgFilter filter ) { - LogicalEntity entity = filter.getInput().getEntity(); + Entity entity = filter.getInput().getEntity(); if ( entity == null ) { return; } - handleIfPartitioned( filter, entity.unwrap( LogicalEntity.class ) ); + handleIfPartitioned( filter, entity.unwrap( Entity.class ) ); } diff --git a/core/src/main/java/org/polypheny/db/rex/RexTableIndexRef.java b/core/src/main/java/org/polypheny/db/rex/RexTableIndexRef.java index aa941a1395..def6b1c3af 100644 --- a/core/src/main/java/org/polypheny/db/rex/RexTableIndexRef.java +++ b/core/src/main/java/org/polypheny/db/rex/RexTableIndexRef.java @@ -41,7 +41,7 @@ import org.polypheny.db.algebra.metadata.BuiltInMetadata.ExpressionLineage; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; /** @@ -132,12 +132,12 @@ public Kind getKind() { @Getter public static class AlgTableRef implements Comparable { - private final LogicalEntity table; + private final Entity table; private final int entityNumber; private final String digest; - private AlgTableRef( LogicalEntity table, int entityNumber ) { + private AlgTableRef( Entity table, int entityNumber ) { this.table = table; this.entityNumber = entityNumber; this.digest = table.id + ".#" + entityNumber; @@ -170,7 +170,7 @@ public String toString() { } - public static AlgTableRef of( LogicalEntity table, int entityNumber ) { + public static AlgTableRef of( Entity table, int entityNumber ) { return new AlgTableRef( table, entityNumber ); } diff --git a/core/src/main/java/org/polypheny/db/schema/Namespace.java b/core/src/main/java/org/polypheny/db/schema/Namespace.java index 5c965f3fb4..9dff48645b 100644 --- a/core/src/main/java/org/polypheny/db/schema/Namespace.java +++ b/core/src/main/java/org/polypheny/db/schema/Namespace.java @@ -38,7 +38,7 @@ import java.util.Set; import org.apache.calcite.linq4j.tree.Expression; import org.polypheny.db.algebra.type.AlgProtoDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.Convention; import org.polypheny.db.util.Wrapper; @@ -95,7 +95,7 @@ default Long getAdapterId() { * @param name Table name * @return Table, or null */ - LogicalEntity getEntity( String name ); + Entity getEntity( String name ); /** * Returns the names of the tables in this schema. diff --git a/core/src/main/java/org/polypheny/db/schema/impl/AbstractEntityQueryable.java b/core/src/main/java/org/polypheny/db/schema/impl/AbstractEntityQueryable.java index 2d8cc9986f..d0c02e1efc 100644 --- a/core/src/main/java/org/polypheny/db/schema/impl/AbstractEntityQueryable.java +++ b/core/src/main/java/org/polypheny/db/schema/impl/AbstractEntityQueryable.java @@ -43,7 +43,7 @@ import org.jetbrains.annotations.NotNull; import org.polypheny.db.adapter.DataContext; import org.polypheny.db.adapter.java.AbstractQueryableEntity; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.schema.types.QueryableEntity; @@ -55,7 +55,7 @@ * * @param element type */ -public abstract class AbstractEntityQueryable extends AbstractQueryable { +public abstract class AbstractEntityQueryable extends AbstractQueryable { public final DataContext dataContext; public final Snapshot snapshot; diff --git a/core/src/main/java/org/polypheny/db/schema/impl/AbstractNamespace.java b/core/src/main/java/org/polypheny/db/schema/impl/AbstractNamespace.java index 96219bcf11..4ce2f667a9 100644 --- a/core/src/main/java/org/polypheny/db/schema/impl/AbstractNamespace.java +++ b/core/src/main/java/org/polypheny/db/schema/impl/AbstractNamespace.java @@ -43,7 +43,7 @@ import lombok.Getter; import org.apache.calcite.linq4j.tree.Expression; import org.polypheny.db.algebra.type.AlgProtoDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.Convention; import org.polypheny.db.schema.Function; @@ -108,7 +108,7 @@ public Expression getExpression( Snapshot snapshot, long id ) { * * @return Map of tables in this schema by name */ - protected Map getTables() { + protected Map getTables() { return ImmutableMap.of(); } @@ -120,7 +120,7 @@ public final Set getEntityNames() { @Override - public final LogicalEntity getEntity( String name ) { + public final Entity getEntity( String name ) { return getTables().get( name ); } diff --git a/core/src/main/java/org/polypheny/db/schema/impl/DelegatingNamespace.java b/core/src/main/java/org/polypheny/db/schema/impl/DelegatingNamespace.java index ee88a94cb3..fb0bdd928f 100644 --- a/core/src/main/java/org/polypheny/db/schema/impl/DelegatingNamespace.java +++ b/core/src/main/java/org/polypheny/db/schema/impl/DelegatingNamespace.java @@ -38,7 +38,7 @@ import java.util.Set; import org.apache.calcite.linq4j.tree.Expression; import org.polypheny.db.algebra.type.AlgProtoDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.Convention; import org.polypheny.db.schema.Function; @@ -95,7 +95,7 @@ public Expression getExpression( Snapshot snapshot, long id ) { @Override - public LogicalEntity getEntity( String name ) { + public Entity getEntity( String name ) { return namespace.getEntity( name ); } diff --git a/core/src/main/java/org/polypheny/db/schema/types/ModifiableCollection.java b/core/src/main/java/org/polypheny/db/schema/types/ModifiableCollection.java index 41b03a5528..16f6d1926d 100644 --- a/core/src/main/java/org/polypheny/db/schema/types/ModifiableCollection.java +++ b/core/src/main/java/org/polypheny/db/schema/types/ModifiableCollection.java @@ -21,7 +21,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.core.common.Modify.Operation; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.rex.RexNode; @@ -31,7 +31,7 @@ public interface ModifiableCollection extends Typed { Modify toModificationCollection( AlgOptCluster cluster, AlgTraitSet traits, - LogicalEntity collection, + Entity collection, AlgNode child, Operation operation, Map updates, diff --git a/core/src/main/java/org/polypheny/db/schema/types/ModifiableGraph.java b/core/src/main/java/org/polypheny/db/schema/types/ModifiableGraph.java index fc8cc1626b..2a317fd94e 100644 --- a/core/src/main/java/org/polypheny/db/schema/types/ModifiableGraph.java +++ b/core/src/main/java/org/polypheny/db/schema/types/ModifiableGraph.java @@ -20,7 +20,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.core.common.Modify.Operation; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.rex.RexNode; @@ -31,7 +31,7 @@ public interface ModifiableGraph extends Typed { Modify toModificationGraph( AlgOptCluster cluster, AlgTraitSet traits, - LogicalEntity entity, + Entity entity, AlgNode child, Operation operation, List targets, diff --git a/core/src/main/java/org/polypheny/db/schema/types/ModifiableTable.java b/core/src/main/java/org/polypheny/db/schema/types/ModifiableTable.java index 9874b0de57..e35ec313c8 100644 --- a/core/src/main/java/org/polypheny/db/schema/types/ModifiableTable.java +++ b/core/src/main/java/org/polypheny/db/schema/types/ModifiableTable.java @@ -20,7 +20,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.core.common.Modify.Operation; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.rex.RexNode; @@ -30,7 +30,7 @@ public interface ModifiableTable extends Typed { Modify toModificationTable( AlgOptCluster cluster, AlgTraitSet traits, - LogicalEntity physicalEntity, + Entity physicalEntity, AlgNode child, Operation operation, List targets, 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 c0f22784fc..da74890328 100644 --- a/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java +++ b/core/src/main/java/org/polypheny/db/tools/AlgBuilder.java @@ -105,7 +105,7 @@ import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.algebra.type.AlgDataTypeFieldImpl; import org.polypheny.db.algebra.type.StructKind; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalGraph; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.entity.physical.PhysicalEntity; @@ -1371,7 +1371,7 @@ public AlgBuilder scan( List tableNames ) { } - public AlgBuilder scan( @Nonnull LogicalEntity entity ) { + public AlgBuilder scan( @Nonnull Entity entity ) { final AlgNode scan = scanFactory.createScan( cluster, entity ); push( scan ); rename( entity.getRowType().getFieldNames() ); @@ -1412,7 +1412,7 @@ public AlgBuilder scan( String... tableNames ) { } - public AlgBuilder documentScan( LogicalEntity collection ) { + public AlgBuilder documentScan( Entity collection ) { stack.add( new Frame( new LogicalDocumentScan( cluster, cluster.traitSet().replace( ModelTrait.DOCUMENT ), collection ) ) ); return this; } @@ -1437,7 +1437,7 @@ public AlgBuilder lpgScan( long logicalId ) { } - public AlgBuilder lpgScan( LogicalEntity entity ) { + public AlgBuilder lpgScan( Entity entity ) { stack.add( new Frame( new LogicalLpgScan( cluster, cluster.traitSet().replace( ModelTrait.GRAPH ), entity, entity.getRowType() ) ) ); return this; } diff --git a/core/src/main/java/org/polypheny/db/util/InitializerExpressionFactory.java b/core/src/main/java/org/polypheny/db/util/InitializerExpressionFactory.java index 664c0fe7cb..91b0ea96fb 100644 --- a/core/src/main/java/org/polypheny/db/util/InitializerExpressionFactory.java +++ b/core/src/main/java/org/polypheny/db/util/InitializerExpressionFactory.java @@ -19,7 +19,7 @@ import java.util.List; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.nodes.Operator; import org.polypheny.db.rex.RexNode; import org.polypheny.db.schema.ColumnStrategy; @@ -37,7 +37,7 @@ public interface InitializerExpressionFactory { * @param iColumn the 0-based offset of the column in the table * @return generation strategy, never null */ - ColumnStrategy generationStrategy( LogicalEntity table, int iColumn ); + ColumnStrategy generationStrategy( Entity table, int iColumn ); /** * Creates an expression which evaluates to the default value for a particular column. @@ -47,7 +47,7 @@ public interface InitializerExpressionFactory { * @param context Context for creating the expression * @return default value expression */ - RexNode newColumnDefaultValue( LogicalEntity table, int iColumn, InitializerContext context ); + RexNode newColumnDefaultValue( Entity table, int iColumn, InitializerContext context ); /** * Creates an expression which evaluates to the initializer expression for a particular attribute of a structured type. diff --git a/core/src/main/java/org/polypheny/db/util/NullInitializerExpressionFactory.java b/core/src/main/java/org/polypheny/db/util/NullInitializerExpressionFactory.java index c200c913db..06bc097496 100644 --- a/core/src/main/java/org/polypheny/db/util/NullInitializerExpressionFactory.java +++ b/core/src/main/java/org/polypheny/db/util/NullInitializerExpressionFactory.java @@ -19,7 +19,7 @@ import java.util.List; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.nodes.Operator; import org.polypheny.db.rex.RexNode; import org.polypheny.db.schema.ColumnStrategy; @@ -38,7 +38,7 @@ public NullInitializerExpressionFactory() { @Override - public ColumnStrategy generationStrategy( LogicalEntity table, int iColumn ) { + public ColumnStrategy generationStrategy( Entity table, int iColumn ) { return table.getRowType().getFields().get( iColumn ).getType().isNullable() ? ColumnStrategy.NULLABLE : ColumnStrategy.NOT_NULLABLE; @@ -46,7 +46,7 @@ public ColumnStrategy generationStrategy( LogicalEntity table, int iColumn ) { @Override - public RexNode newColumnDefaultValue( LogicalEntity table, int iColumn, InitializerContext context ) { + public RexNode newColumnDefaultValue( Entity table, int iColumn, InitializerContext context ) { return context.getRexBuilder().constantNull(); } diff --git a/core/src/main/java/org/polypheny/db/util/Util.java b/core/src/main/java/org/polypheny/db/util/Util.java index ff3ef193b2..9063a0e2c9 100644 --- a/core/src/main/java/org/polypheny/db/util/Util.java +++ b/core/src/main/java/org/polypheny/db/util/Util.java @@ -102,7 +102,7 @@ import org.polypheny.db.algebra.constant.Kind; import org.polypheny.db.algebra.constant.Monotonicity; import org.polypheny.db.algebra.fun.AggFunction; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.nodes.BasicNodeVisitor; @@ -2022,7 +2022,7 @@ public static Iterator filter( Iterator iterator, Predicate predica } - public static Monotonicity getMonotonicity( LogicalEntity entity, String columnName ) { + public static Monotonicity getMonotonicity( Entity entity, String columnName ) { if ( entity.dataModel != DataModel.RELATIONAL ) { return Monotonicity.NOT_MONOTONIC; } diff --git a/core/src/test/java/org/polypheny/db/catalog/CountingFactory.java b/core/src/test/java/org/polypheny/db/catalog/CountingFactory.java index bf991241b4..3bb804a4c8 100644 --- a/core/src/test/java/org/polypheny/db/catalog/CountingFactory.java +++ b/core/src/test/java/org/polypheny/db/catalog/CountingFactory.java @@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.nodes.Operator; import org.polypheny.db.rex.RexBuilder; import org.polypheny.db.rex.RexNode; @@ -51,7 +51,7 @@ public class CountingFactory extends NullInitializerExpressionFactory { @Override - public ColumnStrategy generationStrategy( LogicalEntity table, int iColumn ) { + public ColumnStrategy generationStrategy( Entity table, int iColumn ) { final AlgDataTypeField field = table.getRowType().getFields().get( iColumn ); if ( defaultColumns.contains( field.getName() ) ) { return ColumnStrategy.DEFAULT; @@ -61,7 +61,7 @@ public ColumnStrategy generationStrategy( LogicalEntity table, int iColumn ) { @Override - public RexNode newColumnDefaultValue( LogicalEntity table, int iColumn, InitializerContext context ) { + public RexNode newColumnDefaultValue( Entity table, int iColumn, InitializerContext context ) { THREAD_CALL_COUNT.get().incrementAndGet(); final AlgDataTypeField field = table.getRowType().getFields().get( iColumn ); if ( defaultColumns.contains( field.getName() ) ) { diff --git a/core/src/test/java/org/polypheny/db/catalog/EmpInitializerExpressionFactory.java b/core/src/test/java/org/polypheny/db/catalog/EmpInitializerExpressionFactory.java index e8e8ee679a..d19b6931a8 100644 --- a/core/src/test/java/org/polypheny/db/catalog/EmpInitializerExpressionFactory.java +++ b/core/src/test/java/org/polypheny/db/catalog/EmpInitializerExpressionFactory.java @@ -19,7 +19,7 @@ import java.math.BigDecimal; import org.polypheny.db.algebra.type.AlgDataTypeFactory; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.rex.RexBuilder; import org.polypheny.db.rex.RexNode; import org.polypheny.db.schema.ColumnStrategy; @@ -34,7 +34,7 @@ class EmpInitializerExpressionFactory extends NullInitializerExpressionFactory { @Override - public ColumnStrategy generationStrategy( LogicalEntity table, int iColumn ) { + public ColumnStrategy generationStrategy( Entity table, int iColumn ) { switch ( iColumn ) { case 0: case 1: @@ -47,7 +47,7 @@ public ColumnStrategy generationStrategy( LogicalEntity table, int iColumn ) { @Override - public RexNode newColumnDefaultValue( LogicalEntity table, int iColumn, InitializerContext context ) { + public RexNode newColumnDefaultValue( Entity table, int iColumn, InitializerContext context ) { final RexBuilder rexBuilder = context.getRexBuilder(); final AlgDataTypeFactory typeFactory = rexBuilder.getTypeFactory(); switch ( iColumn ) { diff --git a/core/src/test/java/org/polypheny/db/schemas/HrClusteredSchema.java b/core/src/test/java/org/polypheny/db/schemas/HrClusteredSchema.java index d4c79945bf..f084b590f4 100644 --- a/core/src/test/java/org/polypheny/db/schemas/HrClusteredSchema.java +++ b/core/src/test/java/org/polypheny/db/schemas/HrClusteredSchema.java @@ -47,7 +47,7 @@ import org.polypheny.db.algebra.AlgFieldCollation; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.logistic.EntityType; import org.polypheny.db.schema.Namespace.Schema; @@ -64,7 +64,7 @@ */ public final class HrClusteredSchema extends AbstractNamespace implements Schema { - private final ImmutableMap tables; + private final ImmutableMap tables; public HrClusteredSchema( long id ) { @@ -106,7 +106,7 @@ public HrClusteredSchema( long id ) { @Override - protected Map getTables() { + protected Map getTables() { return tables; } diff --git a/core/src/test/java/org/polypheny/db/test/JdbcTest.java b/core/src/test/java/org/polypheny/db/test/JdbcTest.java index 1290e6e031..cb50718b84 100644 --- a/core/src/test/java/org/polypheny/db/test/JdbcTest.java +++ b/core/src/test/java/org/polypheny/db/test/JdbcTest.java @@ -21,7 +21,7 @@ import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.relational.RelModify; import org.polypheny.db.algebra.logical.relational.LogicalRelModify; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.rex.RexNode; import org.polypheny.db.schema.impl.AbstractEntity; @@ -46,7 +46,7 @@ protected AbstractModifiableTable( String tableName ) { //@Override public RelModify toModificationAlg( AlgOptCluster cluster, - LogicalEntity entity, + Entity entity, AlgNode child, RelModify.Operation operation, List updateColumnList, diff --git a/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java b/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java index f820cb2d53..af42d9d428 100644 --- a/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java +++ b/dbms/src/main/java/org/polypheny/db/PolyphenyDb.java @@ -124,7 +124,7 @@ public class PolyphenyDb { public boolean daemonMode = false; @Option(name = { "-defaultStore" }, description = "Type of default storeId") - public String defaultStoreName = "monetdb"; + public String defaultStoreName = "mongodb"; @Option(name = { "-defaultSource" }, description = "Type of default source") public String defaultSourceName = "csv"; diff --git a/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java b/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java index ea2bc5b02f..a9ac3b2c98 100644 --- a/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java +++ b/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java @@ -77,7 +77,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalNamespace; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; @@ -1285,7 +1285,7 @@ private Map> getAccessedPartitionsPerScan( AlgNode alg, Map handleDocScan( + public DocumentScan handleDocScan( DocumentScan scan, Statement statement, @Nullable List excludedPlacements ) { diff --git a/dbms/src/main/java/org/polypheny/db/transaction/EntityAccessMap.java b/dbms/src/main/java/org/polypheny/db/transaction/EntityAccessMap.java index 43e402bc13..37776eea57 100644 --- a/dbms/src/main/java/org/polypheny/db/transaction/EntityAccessMap.java +++ b/dbms/src/main/java/org/polypheny/db/transaction/EntityAccessMap.java @@ -42,7 +42,7 @@ import org.polypheny.db.algebra.core.lpg.LpgScan; import org.polypheny.db.algebra.core.relational.RelModify; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.allocation.AllocationEntity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; @@ -228,7 +228,7 @@ public Mode getEntityAccessMode( @NonNull EntityAccessMap.EntityIdentifier entit * @param table table of interest * @return qualified name */ - public EntityIdentifier getQualifiedName( LogicalEntity table, long partitionId ) { + public EntityIdentifier getQualifiedName( Entity table, long partitionId ) { return new EntityIdentifier( table.id, partitionId, NamespaceLevel.ENTITY_LEVEL ); } @@ -242,7 +242,7 @@ private class TableRelVisitor extends AlgVisitor { @Override public void visit( AlgNode p, int ordinal, AlgNode parent ) { super.visit( p, ordinal, parent ); - LogicalEntity table = p.getEntity(); + Entity table = p.getEntity(); if ( table == null ) { return; } diff --git a/monitoring/src/main/java/org/polypheny/db/monitoring/statistics/QueryResult.java b/monitoring/src/main/java/org/polypheny/db/monitoring/statistics/QueryResult.java index 5349fa78be..7fe5dcd5c8 100644 --- a/monitoring/src/main/java/org/polypheny/db/monitoring/statistics/QueryResult.java +++ b/monitoring/src/main/java/org/polypheny/db/monitoring/statistics/QueryResult.java @@ -19,7 +19,7 @@ import lombok.Data; import lombok.Getter; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalColumn; @@ -30,11 +30,11 @@ @Data class QueryResult { - private final LogicalEntity entity; + private final Entity entity; private final LogicalColumn column; - QueryResult( LogicalEntity entity, LogicalColumn column ) { + QueryResult( Entity entity, LogicalColumn column ) { this.entity = entity; this.column = column; } diff --git a/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/DbmsMeta.java b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/DbmsMeta.java index 7e8f48a2ca..259c686766 100644 --- a/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/DbmsMeta.java +++ b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/DbmsMeta.java @@ -77,9 +77,8 @@ import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.algebra.type.AlgDataTypeSystem; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalDatabase.PrimitiveCatalogDatabase; -import org.polypheny.db.catalog.entity.LogicalObject; import org.polypheny.db.catalog.entity.LogicalUser; +import org.polypheny.db.catalog.entity.PolyObject; import org.polypheny.db.catalog.entity.logical.LogicalColumn; import org.polypheny.db.catalog.entity.logical.LogicalColumn.PrimitiveCatalogColumn; import org.polypheny.db.catalog.entity.logical.LogicalForeignKey; @@ -146,7 +145,7 @@ public class DbmsMeta implements ProtobufMeta { public static final boolean SEND_FIRST_FRAME_WITH_RESPONSE = false; - private final ConcurrentMap openConnections = new ConcurrentHashMap<>(); + private final ConcurrentMap openConnections = new ConcurrentHashMap<>(); private final ConcurrentMap openStatements = new ConcurrentHashMap<>(); final Calendar calendar = Unsafe.localCalendar(); @@ -252,9 +251,9 @@ private MetaResultSet createMetaResultSet( final ConnectionHandle ch, final } - private Enumerable toEnumerable( final List entities ) { + private Enumerable toEnumerable( final List entities ) { final List objects = new LinkedList<>(); - for ( LogicalObject entity : entities ) { + for ( PolyObject entity : entities ) { objects.add( entity.getParameterArray() ); } return Linq4j.asEnumerable( objects ); @@ -268,7 +267,7 @@ private Enumerable toEnumerable( final List ent */ @Override public Map getDatabaseProperties( ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getDatabaseProperties( ConnectionHandle {} )", ch ); @@ -286,7 +285,7 @@ public Map getDatabaseProperties( ConnectionHandle ch // TODO: typeList is ignored @Override public MetaResultSet getTables( final ConnectionHandle ch, final String database, final Pat schemaPattern, final Pat tablePattern, final List typeList ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getTables( ConnectionHandle {}, String {}, Pat {}, Pat {}, List {} )", ch, database, schemaPattern, tablePattern, typeList ); @@ -334,7 +333,7 @@ private List getLogicalTables( Pattern schemaPattern, Pattern tabl @Override public MetaResultSet getColumns( final ConnectionHandle ch, final String database, final Pat schemaPattern, final Pat tablePattern, final Pat columnPattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getAllocColumns( ConnectionHandle {}, String {}, Pat {}, Pat {}, Pat {} )", ch, database, schemaPattern, tablePattern, columnPattern ); @@ -377,7 +376,7 @@ public MetaResultSet getColumns( final ConnectionHandle ch, final String databas @Override public MetaResultSet getSchemas( final ConnectionHandle ch, final String database, final Pat schemaPattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getNamespaces( ConnectionHandle {}, String {}, Pat {} )", ch, database, schemaPattern ); @@ -404,7 +403,7 @@ public MetaResultSet getSchemas( final ConnectionHandle ch, final String databas @Override public MetaResultSet getCatalogs( final ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getCatalogs( ConnectionHandle {} )", ch ); @@ -416,7 +415,7 @@ public MetaResultSet getCatalogs( final ConnectionHandle ch ) { ch, statementHandle, Linq4j.asEnumerable( databases ), - PrimitiveCatalogDatabase.class, + PrimitiveDatabase.class, // According to JDBC standard: "TABLE_CAT", // Polypheny-DB specific extensions: @@ -429,7 +428,7 @@ public MetaResultSet getCatalogs( final ConnectionHandle ch ) { @Override public MetaResultSet getTableTypes( final ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getTableTypes( ConnectionHandle {} )", ch ); @@ -453,7 +452,7 @@ public MetaResultSet getTableTypes( final ConnectionHandle ch ) { @Override public MetaResultSet getProcedures( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat procedureNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getProcedures( ConnectionHandle {}, String {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, procedureNamePattern ); @@ -467,7 +466,7 @@ public MetaResultSet getProcedures( final ConnectionHandle ch, final String cata @Override public MetaResultSet getProcedureColumns( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat procedureNamePattern, final Pat columnNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getProcedureColumns( ConnectionHandle {}, String {}, Pat {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, procedureNamePattern, columnNamePattern ); @@ -481,7 +480,7 @@ public MetaResultSet getProcedureColumns( final ConnectionHandle ch, final Strin @Override public MetaResultSet getColumnPrivileges( final ConnectionHandle ch, final String catalog, final String schema, final String table, final Pat columnNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getColumnPrivileges( ConnectionHandle {}, String {}, String {}, String {}, Pat {} )", ch, catalog, schema, table, columnNamePattern ); @@ -497,7 +496,7 @@ public MetaResultSet getColumnPrivileges( final ConnectionHandle ch, final Strin @Override public MetaResultSet getTablePrivileges( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat tableNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getTablePrivileges( ConnectionHandle {}, String {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, tableNamePattern ); @@ -513,7 +512,7 @@ public MetaResultSet getTablePrivileges( final ConnectionHandle ch, final String @Override public MetaResultSet getBestRowIdentifier( final ConnectionHandle ch, final String catalog, final String schema, final String table, final int scope, final boolean nullable ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getBestRowIdentifier( ConnectionHandle {}, String {}, String {}, String {}, int {}, boolean {} )", ch, catalog, schema, table, scope, nullable ); @@ -527,7 +526,7 @@ public MetaResultSet getBestRowIdentifier( final ConnectionHandle ch, final Stri @Override public MetaResultSet getVersionColumns( final ConnectionHandle ch, final String catalog, final String schema, final String table ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getVersionColumns( ConnectionHandle {}, String {}, String {}, String {} )", ch, catalog, schema, table ); @@ -541,7 +540,7 @@ public MetaResultSet getVersionColumns( final ConnectionHandle ch, final String @Override public MetaResultSet getPrimaryKeys( final ConnectionHandle ch, final String database, final String schema, final String table ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getPrimaryKeys( ConnectionHandle {}, String {}, String {}, String {} )", ch, database, schema, table ); @@ -578,7 +577,7 @@ public MetaResultSet getPrimaryKeys( final ConnectionHandle ch, final String dat @SuppressWarnings("Duplicates") @Override public MetaResultSet getImportedKeys( final ConnectionHandle ch, final String database, final String schema, final String table ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getImportedKeys( ConnectionHandle {}, String {}, String {}, String {} )", ch, database, schema, table ); @@ -621,7 +620,7 @@ public MetaResultSet getImportedKeys( final ConnectionHandle ch, final String da @SuppressWarnings("Duplicates") @Override public MetaResultSet getExportedKeys( final ConnectionHandle ch, final String database, final String schema, final String table ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getExportedKeys( ConnectionHandle {}, String {}, String {}, String {} )", ch, database, schema, table ); @@ -663,7 +662,7 @@ public MetaResultSet getExportedKeys( final ConnectionHandle ch, final String da @Override public MetaResultSet getCrossReference( final ConnectionHandle ch, final String parentCatalog, final String parentSchema, final String parentTable, final String foreignCatalog, final String foreignSchema, final String foreignTable ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getCrossReference( ConnectionHandle {}, String {}, String {}, String {}, String {}, String {}, String {} )", ch, parentCatalog, parentSchema, parentTable, foreignCatalog, foreignSchema, foreignTable ); @@ -679,7 +678,7 @@ public MetaResultSet getCrossReference( final ConnectionHandle ch, final String @Override public MetaResultSet getTypeInfo( final ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getTypeInfo( ConnectionHandle {} )", ch ); @@ -738,7 +737,7 @@ public MetaResultSet getTypeInfo( final ConnectionHandle ch ) { @Override public MetaResultSet getIndexInfo( final ConnectionHandle ch, final String database, final String schema, final String table, final boolean unique, final boolean approximate ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getIndexInfo( ConnectionHandle {}, String {}, String {}, String {}, boolean {}, boolean {} )", ch, database, schema, table, unique, approximate ); @@ -781,7 +780,7 @@ public MetaResultSet getIndexInfo( final ConnectionHandle ch, final String datab @Override public MetaResultSet getUDTs( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat typeNamePattern, final int[] types ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getUDTs( ConnectionHandle {}, String {}, Pat {}, Pat {}, int[] {} )", ch, catalog, schemaPattern, typeNamePattern, types ); @@ -795,7 +794,7 @@ public MetaResultSet getUDTs( final ConnectionHandle ch, final String catalog, f @Override public MetaResultSet getSuperTypes( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat typeNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getSuperTypes( ConnectionHandle {}, String {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, typeNamePattern ); @@ -809,7 +808,7 @@ public MetaResultSet getSuperTypes( final ConnectionHandle ch, final String cata @Override public MetaResultSet getSuperTables( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat tableNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getSuperTables( ConnectionHandle {}, String {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, tableNamePattern ); @@ -823,7 +822,7 @@ public MetaResultSet getSuperTables( final ConnectionHandle ch, final String cat @Override public MetaResultSet getAttributes( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat typeNamePattern, final Pat attributeNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getAttributes( ConnectionHandle {}, String {}, Pat {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, typeNamePattern, attributeNamePattern ); @@ -837,7 +836,7 @@ public MetaResultSet getAttributes( final ConnectionHandle ch, final String cata @Override public MetaResultSet getClientInfoProperties( final ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getClientInfoProperties( ConnectionHandle {} )", ch ); @@ -851,7 +850,7 @@ public MetaResultSet getClientInfoProperties( final ConnectionHandle ch ) { @Override public MetaResultSet getFunctions( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat functionNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getFunctions( ConnectionHandle {}, String {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, functionNamePattern ); @@ -865,7 +864,7 @@ public MetaResultSet getFunctions( final ConnectionHandle ch, final String catal @Override public MetaResultSet getFunctionColumns( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat functionNamePattern, final Pat columnNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getFunctionColumns( ConnectionHandle {}, String {}, Pat {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, functionNamePattern, columnNamePattern ); @@ -879,7 +878,7 @@ public MetaResultSet getFunctionColumns( final ConnectionHandle ch, final String @Override public MetaResultSet getPseudoColumns( final ConnectionHandle ch, final String catalog, final Pat schemaPattern, final Pat tableNamePattern, final Pat columnNamePattern ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "getPseudoColumns( ConnectionHandle {}, String {}, Pat {}, Pat {}, Pat {} )", ch, catalog, schemaPattern, tableNamePattern, columnNamePattern ); @@ -900,7 +899,7 @@ public MetaResultSet getPseudoColumns( final ConnectionHandle ch, final String c */ @Override public ExecuteBatchResult executeBatchProtobuf( final StatementHandle h, final List parameterValues ) throws NoSuchStatementException { - final PolyphenyDbConnectionHandle connection = openConnections.get( h.connectionId ); + final PolyConnectionHandle connection = openConnections.get( h.connectionId ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "executeBatchProtobuf( StatementHandle {}, List {} )", h, parameterValues ); @@ -959,7 +958,7 @@ public ExecuteBatchResult executeBatchProtobuf( final StatementHandle h, final L */ @Override public Iterable createIterable( final StatementHandle h, final QueryState state, final Signature signature, final List parameters, final Frame firstFrame ) { - final PolyphenyDbConnectionHandle connection = openConnections.get( h.connectionId ); + final PolyConnectionHandle connection = openConnections.get( h.connectionId ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "createExternalIterable( StatementHandle {}, QueryState {}, Signature {}, List {}, Frame {} )", h, state, signature, parameters, firstFrame ); @@ -981,7 +980,7 @@ public Iterable createIterable( final StatementHandle h, final QueryStat */ @Override public StatementHandle prepare( final ConnectionHandle ch, final String sql, final long maxRowCount ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "prepare( ConnectionHandle {}, String {}, long {} )", ch, sql, maxRowCount ); @@ -1061,7 +1060,7 @@ public ExecuteResult prepareAndExecute( final StatementHandle h, final String sq */ @Override public ExecuteResult prepareAndExecute( final StatementHandle h, final String sql, final long maxRowCount, final int maxRowsInFirstFrame, final PrepareCallback callback ) throws NoSuchStatementException { - final PolyphenyDbConnectionHandle connection = openConnections.get( h.connectionId ); + final PolyConnectionHandle connection = openConnections.get( h.connectionId ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "prepareAndExecute( StatementHandle {}, String {}, long {}, int {}, PrepareCallback {} )", h, sql, maxRowCount, maxRowsInFirstFrame, callback ); @@ -1084,7 +1083,7 @@ public ExecuteResult prepareAndExecute( final StatementHandle h, final String sq */ @Override public ExecuteBatchResult prepareAndExecuteBatch( final StatementHandle h, final List sqlCommands ) throws NoSuchStatementException { - final PolyphenyDbConnectionHandle connection = openConnections.get( h.connectionId ); + final PolyConnectionHandle connection = openConnections.get( h.connectionId ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "prepareAndExecuteBatch( StatementHandle {}, List {} )", h, sqlCommands ); @@ -1105,7 +1104,7 @@ public ExecuteBatchResult prepareAndExecuteBatch( final StatementHandle h, final */ @Override public ExecuteBatchResult executeBatch( final StatementHandle h, final List> parameterValues ) throws NoSuchStatementException { - final PolyphenyDbConnectionHandle connection = openConnections.get( h.connectionId ); + final PolyConnectionHandle connection = openConnections.get( h.connectionId ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "executeBatch( StatementHandle {}, List> {} )", h, parameterValues ); @@ -1129,7 +1128,7 @@ public ExecuteBatchResult executeBatch( final StatementHandle h, final List pa */ @Override public ExecuteResult execute( final StatementHandle h, final List parameterValues, final int maxRowsInFirstFrame ) throws NoSuchStatementException { - final PolyphenyDbConnectionHandle connection = openConnections.get( h.connectionId ); + final PolyConnectionHandle connection = openConnections.get( h.connectionId ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "execute( StatementHandle {}, List {}, int {} )", h, parameterValues, maxRowsInFirstFrame ); @@ -1216,7 +1215,7 @@ public ExecuteResult execute( final StatementHandle h, final List pa } - private ExecuteResult execute( StatementHandle h, List parameterValues, int maxRowsInFirstFrame, PolyphenyDbConnectionHandle connection ) throws NoSuchStatementException { + private ExecuteResult execute( StatementHandle h, List parameterValues, int maxRowsInFirstFrame, PolyConnectionHandle connection ) throws NoSuchStatementException { final PolyStatementHandle statementHandle = getPolyphenyDbStatementHandle( h ); long index = 0; @@ -1394,7 +1393,7 @@ public Enumerator enumerator() { } - private List execute( StatementHandle h, PolyphenyDbConnectionHandle connection, PolyStatementHandle statementHandle, int maxRowsInFirstFrame ) { + private List execute( StatementHandle h, PolyConnectionHandle connection, PolyStatementHandle statementHandle, int maxRowsInFirstFrame ) { List resultSets; if ( statementHandle.getSignature().statementType == StatementType.OTHER_DDL ) { MetaResultSet resultSet = MetaResultSet.count( statementHandle.getConnection().getConnectionId().toString(), h.id, 1 ); @@ -1441,7 +1440,7 @@ private List execute( StatementHandle h, PolyphenyDbConnectionHan */ @Override public StatementHandle createStatement( ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "createStatement( ConnectionHandle {} )", ch ); @@ -1469,7 +1468,7 @@ public StatementHandle createStatement( ConnectionHandle ch ) { */ @Override public void closeStatement( final StatementHandle statementHandle ) { - final PolyphenyDbConnectionHandle connection = openConnections.get( statementHandle.connectionId ); + final PolyConnectionHandle connection = openConnections.get( statementHandle.connectionId ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "closeStatement( StatementHandle {} )", statementHandle ); @@ -1551,7 +1550,7 @@ public void openConnection( final ConnectionHandle ch, final Map throw new GenericRuntimeException( e.getLocalizedMessage(), -1, "", AvaticaSeverity.ERROR ); } - openConnections.put( ch.id, new PolyphenyDbConnectionHandle( ch, user, ch.id, null, namespace, transactionManager ) ); + openConnections.put( ch.id, new PolyConnectionHandle( ch, user, ch.id, namespace, transactionManager ) ); } @@ -1560,13 +1559,13 @@ public void openConnection( final ConnectionHandle ch, final Map */ @Override public void closeConnection( ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "closeConnection( ConnectionHandle {} )", ch ); } - final PolyphenyDbConnectionHandle connectionToClose = openConnections.remove( ch.id ); + final PolyConnectionHandle connectionToClose = openConnections.remove( ch.id ); if ( connectionToClose == null ) { if ( log.isDebugEnabled() ) { log.debug( "Connection {} already closed.", ch.id ); @@ -1598,7 +1597,7 @@ public void closeConnection( ConnectionHandle ch ) { } - private PolyphenyDbConnectionHandle getPolyphenyDbConnectionHandle( String connectionId ) { + private PolyConnectionHandle getPolyphenyDbConnectionHandle( String connectionId ) { if ( openConnections.containsKey( connectionId ) ) { return openConnections.get( connectionId ); } else { @@ -1639,7 +1638,7 @@ public boolean syncResults( final StatementHandle sh, final QueryState state, fi */ @Override public void commit( final ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "commit( ConnectionHandle {} )", ch ); @@ -1669,7 +1668,7 @@ public void commit( final ConnectionHandle ch ) { */ @Override public void rollback( final ConnectionHandle ch ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "rollback( ConnectionHandle {} )", ch ); @@ -1702,13 +1701,13 @@ public void rollback( final ConnectionHandle ch ) { */ @Override public ConnectionProperties connectionSync( ConnectionHandle ch, ConnectionProperties connProps ) { - final PolyphenyDbConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); + final PolyConnectionHandle connection = getPolyphenyDbConnectionHandle( ch.id ); synchronized ( connection ) { if ( log.isTraceEnabled() ) { log.trace( "connectionSync( ConnectionHandle {}, ConnectionProperties {} )", ch, connProps ); } - final PolyphenyDbConnectionHandle connectionToSync = openConnections.get( ch.id ); + final PolyConnectionHandle connectionToSync = openConnections.get( ch.id ); if ( connectionToSync == null ) { if ( log.isDebugEnabled() ) { log.debug( "Connection {} is not execute.", ch.id ); @@ -1801,9 +1800,9 @@ public void updateConnectionNumberTable() { public void updateConnectionListTable() { connectionListTable.reset(); - for ( Entry entry : openConnections.entrySet() ) { + for ( Entry entry : openConnections.entrySet() ) { String connectionId = entry.getKey(); - PolyphenyDbConnectionHandle connectionHandle = entry.getValue(); + PolyConnectionHandle connectionHandle = entry.getValue(); Transaction currentTx = connectionHandle.getCurrentTransaction(); String txId = "-"; if ( currentTx != null ) { diff --git a/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyphenyDbConnectionHandle.java b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyConnectionHandle.java similarity index 73% rename from plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyphenyDbConnectionHandle.java rename to plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyConnectionHandle.java index cffaaa75ee..c3102fee5c 100644 --- a/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyphenyDbConnectionHandle.java +++ b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyConnectionHandle.java @@ -24,7 +24,6 @@ import org.apache.calcite.avatica.Meta.ConnectionHandle; import org.apache.calcite.avatica.Meta.ConnectionProperties; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalDatabase; import org.polypheny.db.catalog.entity.LogicalUser; import org.polypheny.db.catalog.entity.logical.LogicalNamespace; import org.polypheny.db.transaction.PUID.ConnectionId; @@ -36,7 +35,7 @@ /** * */ -public class PolyphenyDbConnectionHandle { +public class PolyConnectionHandle { private final Meta.ConnectionHandle handle; @@ -44,38 +43,24 @@ public class PolyphenyDbConnectionHandle { @Getter private final LogicalUser user; - private final LogicalDatabase database; private final LogicalNamespace namespace; @Getter private final ConnectionId connectionId; private Transaction currentTransaction; - private PolyphenyDbResultSet currentOpenResultSet; + private PolyResultSet currentOpenResultSet; private final TransactionManager transactionManager; private final ConnectionProperties connectionProperties = new ConnectionPropertiesImpl( true, false, java.sql.Connection.TRANSACTION_SERIALIZABLE, Catalog.DATABASE_NAME, Catalog.defaultNamespaceName ); - public PolyphenyDbConnectionHandle( final Meta.ConnectionHandle handle, final LogicalUser logicalUser, final ConnectionId connectionId, final LogicalDatabase database, final LogicalNamespace namespace, final TransactionManager transactionManager ) { + public PolyConnectionHandle( final ConnectionHandle handle, final LogicalUser logicalUser, final String connectionId, final LogicalNamespace namespace, final TransactionManager transactionManager ) { this.handle = handle; - this.userId = UserId.fromString( logicalUser.name ); // TODO: refactor CatalogUser - this.user = logicalUser; - this.connectionId = connectionId; - this.database = database; - this.namespace = namespace; - this.transactionManager = transactionManager; - } - - - public PolyphenyDbConnectionHandle( final ConnectionHandle handle, final LogicalUser logicalUser, final String connectionId, final LogicalDatabase database, final LogicalNamespace namespace, final TransactionManager transactionManager ) { - this.handle = handle; - - this.userId = UserId.fromString( logicalUser.name ); // TODO: refactor CatalogUser + this.userId = UserId.fromString( logicalUser.name ); this.user = logicalUser; this.connectionId = ConnectionId.fromString( connectionId ); - this.database = database; this.namespace = namespace; this.transactionManager = transactionManager; } @@ -107,7 +92,7 @@ public Transaction getCurrentOrCreateNewTransaction() { } - public void setCurrentOpenResultSet( PolyphenyDbResultSet resultSet ) { + public void setCurrentOpenResultSet( PolyResultSet resultSet ) { this.currentOpenResultSet = resultSet; } @@ -135,7 +120,7 @@ public boolean equals( Object o ) { if ( o == null || getClass() != o.getClass() ) { return false; } - PolyphenyDbConnectionHandle that = (PolyphenyDbConnectionHandle) o; + PolyConnectionHandle that = (PolyConnectionHandle) o; return Objects.equals( connectionId, that.connectionId ); } diff --git a/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyphenyDbResultSet.java b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyResultSet.java similarity index 91% rename from plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyphenyDbResultSet.java rename to plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyResultSet.java index 5e50660315..30ea8374e7 100644 --- a/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyphenyDbResultSet.java +++ b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PolyResultSet.java @@ -57,12 +57,12 @@ /** * Implementation of {@link ResultSet} for the Polypheny-DB engine. */ -public class PolyphenyDbResultSet extends AvaticaResultSet { +public class PolyResultSet extends AvaticaResultSet { /** * Creates a PolyphenyDbResultSet. */ - public PolyphenyDbResultSet( AvaticaStatement statement, PolySignature polySignature, ResultSetMetaData resultSetMetaData, TimeZone timeZone, Meta.Frame firstFrame ) throws SQLException { + public PolyResultSet( AvaticaStatement statement, PolySignature polySignature, ResultSetMetaData resultSetMetaData, TimeZone timeZone, Meta.Frame firstFrame ) throws SQLException { super( statement, null, polySignature, resultSetMetaData, timeZone, firstFrame ); } @@ -92,7 +92,7 @@ public ResultSet create( ColumnMetaData.AvaticaType elementType, Iterable { - private final PolyphenyDbConnectionHandle connection; + private final PolyConnectionHandle connection; private final int statementId; private volatile transient Iterator openResultSet; private volatile transient PolySignature signature; @@ -45,7 +45,7 @@ public class PolyStatementHandle { private final StopWatch executionStopWatch = new StopWatch(); - public PolyStatementHandle( final PolyphenyDbConnectionHandle connection, final int statementId ) { + public PolyStatementHandle( final PolyConnectionHandle connection, final int statementId ) { this.connection = connection; this.statementId = statementId; } diff --git a/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PrimitiveDatabase.java b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PrimitiveDatabase.java new file mode 100644 index 0000000000..a32c135c6a --- /dev/null +++ b/plugins/avatica-interface/src/main/java/org/polypheny/db/avatica/PrimitiveDatabase.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019-2023 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.polypheny.db.avatica; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public class PrimitiveDatabase { + + public final String tableCat; + public final String owner; + public final String defaultSchema; + +} diff --git a/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailEntity.java b/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailEntity.java index 4e889e22b9..10ef784e69 100644 --- a/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailEntity.java +++ b/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailEntity.java @@ -30,7 +30,7 @@ import org.polypheny.db.algebra.core.common.Modify.Operation; import org.polypheny.db.algebra.logical.relational.LogicalRelModify; import org.polypheny.db.algebra.type.AlgProtoDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalTable; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.AlgOptCluster; @@ -109,7 +109,7 @@ public String toString() { public Modify toModificationTable( AlgOptCluster cluster, AlgTraitSet algTraits, - LogicalEntity table, + Entity table, AlgNode input, Operation operation, List updateColumnList, diff --git a/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailNamespace.java b/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailNamespace.java index 842a4be0b4..e1c0fc4d97 100644 --- a/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailNamespace.java +++ b/plugins/cottontail-adapter/src/main/java/org/polypheny/db/adapter/cottontail/CottontailNamespace.java @@ -25,7 +25,7 @@ import org.apache.calcite.linq4j.tree.Expression; import org.polypheny.db.adapter.DataContext; import org.polypheny.db.adapter.cottontail.CottontailPlugin.CottontailStore; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.schema.Namespace; import org.polypheny.db.schema.Namespace.Schema; @@ -131,7 +131,7 @@ public Expression getExpression( Snapshot snapshot, long id ) { @Override - protected Map getTables() { + protected Map getTables() { return ImmutableMap.copyOf( this.tableMap ); } diff --git a/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileStoreSchema.java b/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileStoreSchema.java index c3a0690c8b..f98d09c51c 100644 --- a/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileStoreSchema.java +++ b/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileStoreSchema.java @@ -32,7 +32,7 @@ import org.polypheny.db.adapter.file.FileAlg.FileImplementor.Operation; import org.polypheny.db.adapter.file.FilePlugin.FileStore; import org.polypheny.db.adapter.file.util.FileUtil; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalTable; import org.polypheny.db.schema.Namespace.Schema; import org.polypheny.db.schema.impl.AbstractNamespace; @@ -44,7 +44,7 @@ public class FileStoreSchema extends AbstractNamespace implements FileSchema, Schema { private final String schemaName; - private final Map tables = new HashMap<>(); + private final Map tables = new HashMap<>(); private final FileStore store; private final FileConvention convention; diff --git a/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileTranslatableEntity.java b/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileTranslatableEntity.java index 18eeb8ac59..2d98405ddf 100644 --- a/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileTranslatableEntity.java +++ b/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/FileTranslatableEntity.java @@ -27,7 +27,7 @@ import org.polypheny.db.algebra.core.common.Modify; import org.polypheny.db.algebra.core.common.Modify.Operation; import org.polypheny.db.algebra.logical.relational.LogicalRelModify; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalTable; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgTraitSet; @@ -89,7 +89,7 @@ public AlgNode toAlg( AlgOptCluster cluster, AlgTraitSet traitSet ) { public Modify toModificationTable( AlgOptCluster cluster, AlgTraitSet algTraits, - LogicalEntity table, + Entity table, AlgNode input, Operation operation, List updateColumnList, diff --git a/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/algebra/FileScan.java b/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/algebra/FileScan.java index 5bd3f2c5bf..6a0860ef97 100644 --- a/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/algebra/FileScan.java +++ b/plugins/file-adapter/src/main/java/org/polypheny/db/adapter/file/algebra/FileScan.java @@ -25,7 +25,7 @@ import org.polypheny.db.algebra.core.relational.RelScan; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptPlanner; @@ -38,7 +38,7 @@ public class FileScan extends RelScan implements FileAlg private final FileTranslatableEntity fileTable; - public FileScan( AlgOptCluster cluster, LogicalEntity table, FileTranslatableEntity fileTable ) { + public FileScan( AlgOptCluster cluster, Entity table, FileTranslatableEntity fileTable ) { //convention was: EnumerableConvention.INSTANCE super( cluster, cluster.traitSetOf( fileTable.getFileSchema().getConvention() ).replace( ModelTrait.RELATIONAL ), fileTable ); this.fileTable = fileTable; diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcSchema.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcSchema.java index e6e374ffef..2c893c355f 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcSchema.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcSchema.java @@ -56,7 +56,7 @@ import org.polypheny.db.algebra.type.AlgProtoDataType; import org.polypheny.db.catalog.catalogs.RelStoreCatalog; import org.polypheny.db.catalog.catalogs.StoreCatalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.catalog.snapshot.Snapshot; @@ -224,7 +224,7 @@ public final Set getFunctionNames() { @Override - public LogicalEntity getEntity( String name ) { + public Entity getEntity( String name ) { return getTableMap().get( name ); } diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java index e0aac5b7f4..c7508169aa 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcTable.java @@ -53,7 +53,7 @@ import org.polypheny.db.algebra.logical.relational.LogicalRelModify; import org.polypheny.db.algebra.operators.OperatorName; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalColumn; import org.polypheny.db.catalog.entity.physical.PhysicalTable; import org.polypheny.db.catalog.snapshot.Snapshot; @@ -202,7 +202,7 @@ public Enumerable scan( DataContext root ) { public Modify toModificationTable( AlgOptCluster cluster, AlgTraitSet algTraits, - LogicalEntity table, + Entity table, AlgNode input, Operation operation, List updateColumnList, diff --git a/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/PlannerTest.java b/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/PlannerTest.java index 46f3c6c21c..d47a078435 100644 --- a/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/PlannerTest.java +++ b/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/PlannerTest.java @@ -35,7 +35,7 @@ import org.polypheny.db.algebra.enumerable.EnumerableRules; import org.polypheny.db.algebra.enumerable.EnumerableScan; import org.polypheny.db.algebra.rules.FilterMergeRule; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.languages.Parser; import org.polypheny.db.languages.Parser.ParserConfig; import org.polypheny.db.nodes.Node; @@ -155,7 +155,7 @@ public AlgNode convert( AlgNode alg ) { */ private static class MockJdbcScan extends RelScan implements JdbcAlg { - MockJdbcScan( AlgOptCluster cluster, LogicalEntity table, JdbcConvention jdbcConvention ) { + MockJdbcScan( AlgOptCluster cluster, Entity table, JdbcConvention jdbcConvention ) { super( cluster, cluster.traitSetOf( jdbcConvention ), table ); } diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoAlg.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoAlg.java index a42401cf5c..f67d545148 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoAlg.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoAlg.java @@ -53,8 +53,7 @@ import org.polypheny.db.algebra.core.common.Modify.Operation; import org.polypheny.db.algebra.core.relational.RelScan; import org.polypheny.db.algebra.logical.relational.LogicalProject; -import org.polypheny.db.algebra.type.AlgRecordType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.catalog.entity.physical.PhysicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.plan.Convention; @@ -71,7 +70,7 @@ public interface MongoAlg extends AlgNode { /** * Calling convention for relational operations that occur in MongoDB. */ - Convention CONVENTION = MongoConvention.INSTANCE;//new Convention.Impl( "MONGO", MongoRel.class ); + Convention CONVENTION = MongoConvention.INSTANCE;//new Convention.Impl( "MONGO", MongoAlg.class ); /** @@ -81,6 +80,7 @@ class Implementor extends AlgShuttleImpl implements Serializable { public final List> list = new ArrayList<>(); public List operations = new ArrayList<>(); + public BsonArray filter = new BsonArray(); @Getter @Setter @@ -93,7 +93,13 @@ class Implementor extends AlgShuttleImpl implements Serializable { public boolean onlyOne = false; public boolean isDocumentUpdate = false; - public LogicalEntity entity; + @Getter + private MongoEntity entity; + + @Getter + @Setter + private AlgDataType rowType; + @Setter @Getter public boolean hasProject = false; @@ -107,9 +113,6 @@ class Implementor extends AlgShuttleImpl implements Serializable { @Setter private Operation operation; - @Getter - private AlgRecordType staticRowType; - public Implementor() { isDML = false; @@ -132,18 +135,6 @@ public void visitChild( int ordinal, AlgNode input ) { } - public void setStaticRowType( AlgRecordType staticRowType ) { - if ( this.staticRowType != null ) { - return; - } - if ( mongoEntity != null ) { - this.staticRowType = MongoRowType.fromRecordType( staticRowType, mongoEntity ); - } else { - this.staticRowType = staticRowType; - } - } - - public String getPhysicalName( String name ) { int index = mongoEntity.physical.unwrap( PhysicalTable.class ).columns.stream().map( c -> c.name ).collect( Collectors.toList() ).indexOf( name ); if ( index != -1 ) { @@ -153,6 +144,12 @@ public String getPhysicalName( String name ) { } + public void setEntity( MongoEntity entity ) { + this.entity = entity; + this.rowType = entity.getRowType(); + } + + public BsonDocument getFilter() { BsonDocument filter; if ( this.filter.size() == 1 ) { diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoEntity.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoEntity.java index 426ec29375..3e31ce0c0a 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoEntity.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoEntity.java @@ -86,7 +86,7 @@ import org.polypheny.db.algebra.type.AlgDataTypeImpl; import org.polypheny.db.algebra.type.AlgProtoDataType; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalCollection; import org.polypheny.db.catalog.entity.physical.PhysicalColumn; import org.polypheny.db.catalog.entity.physical.PhysicalEntity; @@ -315,7 +315,7 @@ private static Integer parseIntString( String valueString ) { public Modify toModificationTable( AlgOptCluster cluster, AlgTraitSet traitSet, - LogicalEntity table, + Entity table, AlgNode child, Operation operation, List updateColumnList, @@ -335,7 +335,7 @@ public Modify toModificationTable( public Modify toModificationCollection( AlgOptCluster cluster, AlgTraitSet traits, - LogicalEntity collection, + Entity collection, AlgNode child, Operation operation, Map updates, diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoNamespace.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoNamespace.java index 99586040d7..7357c825c3 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoNamespace.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/MongoNamespace.java @@ -48,13 +48,12 @@ import org.apache.calcite.linq4j.tree.Expression; import org.polypheny.db.adapter.mongodb.MongoPlugin.MongoStore; import org.polypheny.db.algebra.type.AlgProtoDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalEntity; import org.polypheny.db.catalog.entity.physical.PhysicalField; import org.polypheny.db.catalog.impl.Expressible; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.plan.Convention; -import org.polypheny.db.schema.Entity; import org.polypheny.db.schema.Function; import org.polypheny.db.schema.Namespace; import org.polypheny.db.schema.Namespace.Schema; @@ -73,10 +72,10 @@ public class MongoNamespace implements Namespace, Schema, Expressible { private final Convention convention = MongoAlg.CONVENTION; @Getter - private final Map tableMap = new HashMap<>(); + private final Map tableMap = new HashMap<>(); @Getter - private final Map collectionMap = new HashMap<>(); + private final Map collectionMap = new HashMap<>(); private final MongoClient connection; private final TransactionProvider transactionProvider; @Getter @@ -122,7 +121,7 @@ public Set getSubNamespaceNames() { @Override - public LogicalEntity getEntity( String name ) { + public Entity getEntity( String name ) { return null; } diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoDocumentModify.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoDocumentModify.java index fa9f3195e3..b4a0b7b550 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoDocumentModify.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoDocumentModify.java @@ -37,6 +37,7 @@ public class MongoDocumentModify extends DocumentModify implements private final GridFSBucket bucket; private Implementor implementor; + protected MongoDocumentModify( AlgTraitSet traits, MongoEntity collection, @@ -55,7 +56,7 @@ public void implement( Implementor implementor ) { implementor.setDML( true ); this.implementor = implementor; - implementor.entity = entity; + implementor.setEntity( entity ); implementor.setOperation( this.getOperation() ); switch ( this.getOperation() ) { diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoProject.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoProject.java index 40dada2f19..8f15108be6 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoProject.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoProject.java @@ -27,7 +27,6 @@ import org.bson.json.JsonMode; import org.bson.json.JsonWriterSettings; import org.polypheny.db.adapter.mongodb.MongoAlg; -import org.polypheny.db.adapter.mongodb.MongoRowType; import org.polypheny.db.adapter.mongodb.bson.BsonFunctionHelper; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.constant.Kind; @@ -78,10 +77,10 @@ public void implement( Implementor implementor ) { final List excludes = new ArrayList<>(); final List unwinds = new ArrayList<>(); // We use our specialized rowType to derive the mapped underlying column identifiers - MongoRowType mongoRowType = null; - if ( implementor.getStaticRowType() instanceof MongoRowType ) { + AlgDataType mongoRowType = implementor.getRowType(); + /*if ( implementor.getStaticRowType() instanceof MongoRowType ) { mongoRowType = ((MongoRowType) implementor.getStaticRowType()); - } + }*/ BsonDocument documents = new BsonDocument(); diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoRules.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoRules.java index feaddc00dd..98bd411b30 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoRules.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoRules.java @@ -443,7 +443,7 @@ public String handleSpecialCases( RexCall call ) { array.addAll( translateList( call.operands ).stream().map( BsonString::new ).collect( Collectors.toList() ) ); return array.toString(); } else if ( call.isA( Kind.MQL_QUERY_VALUE ) ) { - return translateDocValueAsKey( implementor.getStaticRowType(), call, "$" ); + return translateDocValueAsKey( implementor.getRowType(), call, "$" ); } else if ( call.isA( Kind.MQL_ITEM ) ) { RexNode leftPre = call.operands.get( 0 ); String left = leftPre.accept( this ); @@ -459,7 +459,7 @@ public String handleSpecialCases( RexCall call ) { return "{\"$slice\":[ " + left + "," + skip + "," + return_ + "]}"; } else if ( call.isA( Kind.MQL_EXCLUDE ) ) { String parent = implementor - .getStaticRowType() + .getRowType() .getFieldNames() .get( ((RexIndexRef) call.operands.get( 0 )).getIndex() ); diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoScan.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoScan.java index 0bc9601723..bf131f7219 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoScan.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoScan.java @@ -28,7 +28,6 @@ import org.polypheny.db.algebra.core.relational.RelScan; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.algebra.type.AlgRecordType; import org.polypheny.db.plan.AlgOptCluster; import org.polypheny.db.plan.AlgOptCost; import org.polypheny.db.plan.AlgOptPlanner; @@ -91,12 +90,11 @@ public void register( AlgOptPlanner planner ) { @Override public void implement( Implementor implementor ) { - implementor.entity = entity; + implementor.setEntity( entity ); //implementor.setStaticRowType( (AlgRecordType) rowType ); //implementor.physicalMapper.addAll( rowType.getFieldNames() ); if ( implementor.isDML() ) { - implementor.setStaticRowType( (AlgRecordType) rowType ); return; } implementor.list.add( Pair.of( null, new BsonDocument( "$project", new BsonDocument( rowType.getFields().stream().map( p -> new BsonElement( p.getName(), new BsonString( "$" + p.getPhysicalName() ) ) ).collect( Collectors.toList() ) ) ).toJson() ) ); diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoTableModify.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoTableModify.java index 683bfac69d..0adcff4bf4 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoTableModify.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoTableModify.java @@ -32,7 +32,6 @@ import org.polypheny.db.adapter.mongodb.MongoAlg; import org.polypheny.db.adapter.mongodb.MongoEntity; import org.polypheny.db.adapter.mongodb.MongoPlugin.MongoStore; -import org.polypheny.db.adapter.mongodb.MongoRowType; import org.polypheny.db.adapter.mongodb.bson.BsonDynamic; import org.polypheny.db.adapter.mongodb.rules.MongoRules.MongoDocuments; import org.polypheny.db.algebra.AbstractAlgNode; @@ -42,8 +41,6 @@ import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.algebra.type.AlgRecordType; -import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.entity.physical.PhysicalCollection; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.plan.AlgOptCluster; @@ -107,7 +104,7 @@ public void implement( Implementor implementor ) { implementor.setDML( true ); this.implementor = implementor; - implementor.entity = entity; + implementor.setEntity( entity ); implementor.setOperation( this.getOperation() ); switch ( this.getOperation() ) { @@ -136,7 +133,7 @@ public void implement( Implementor implementor ) { private void handleDelete( Implementor implementor ) { Implementor filterCollector = new Implementor( true ); - filterCollector.setStaticRowType( implementor.getStaticRowType() ); + filterCollector.setEntity( entity ); ((MongoAlg) input).implement( filterCollector ); implementor.filter = filterCollector.filter; if ( Pair.right( filterCollector.list ).contains( "{$limit: 1}" ) ) { @@ -147,11 +144,11 @@ private void handleDelete( Implementor implementor ) { private void handleUpdate( Implementor implementor ) { Implementor condImplementor = new Implementor( true ); - condImplementor.setStaticRowType( implementor.getStaticRowType() ); + condImplementor.setEntity( entity ); ((MongoAlg) input).implement( condImplementor ); implementor.filter = condImplementor.filter; //assert condImplementor.getStaticRowType() instanceof MongoRowType; - MongoRowType rowType = (MongoRowType) condImplementor.getStaticRowType(); + AlgDataType rowType = condImplementor.getRowType(); int pos = 0; BsonDocument doc = new BsonDocument(); List docDocs = new ArrayList<>(); @@ -159,31 +156,30 @@ private void handleUpdate( Implementor implementor ) { for ( RexNode el : getSourceExpressions() ) { if ( el.isA( Kind.LITERAL ) ) { doc.append( - rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), + rowType.getFields().get( pos ).getPhysicalName(),//getPhysicalName( getUpdateColumns().get( pos ), implementor ), BsonUtil.getAsBson( (RexLiteral) el, bucket ) ); } else if ( el instanceof RexCall ) { RexCall call = ((RexCall) el); if ( Arrays.asList( Kind.PLUS, Kind.PLUS, Kind.TIMES, Kind.DIVIDE ).contains( call.op.getKind() ) ) { doc.append( - rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), + rowType.getFields().get( pos ).getPhysicalName(),//rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), visitCall( implementor, (RexCall) el, call.op.getKind(), el.getType().getPolyType() ) ); } else if ( call.op.getKind().belongsTo( Kind.MQL_KIND ) ) { docDocs.add( handleDocumentUpdate( (RexCall) el, bucket, rowType ) ); } else { doc.append( - rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), + rowType.getFields().get( pos ).getPhysicalName(),//rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), BsonUtil.getBsonArray( call, bucket ) ); } } else if ( el.isA( Kind.DYNAMIC_PARAM ) ) { doc.append( - rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), + rowType.getFields().get( pos ).getPhysicalName(),//rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), new BsonDynamic( (RexDynamicParam) el ) ); } else if ( el.isA( Kind.FIELD_ACCESS ) ) { doc.append( - rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), + rowType.getFields().get( pos ).getPhysicalName(),//rowType.getPhysicalName( getUpdateColumns().get( pos ), implementor ), new BsonString( - "$" + rowType.getPhysicalName( - ((RexFieldAccess) el).getField().getName(), implementor ) ) ); + "$" + rowType.getFields().get( pos ).getPhysicalName() ) );//rowType.getPhysicalName( ((RexFieldAccess) el).getField().getName(), implementor ) ) ); } pos++; } @@ -201,7 +197,7 @@ private void handleUpdate( Implementor implementor ) { } - private BsonDocument handleDocumentUpdate( RexCall el, GridFSBucket bucket, MongoRowType rowType ) { + private BsonDocument handleDocumentUpdate( RexCall el, GridFSBucket bucket, AlgDataType rowType ) { if ( el.op.getKind() == Kind.MQL_JSONIFY ) { assert el.getOperands().size() == 1; return handleDocumentUpdate( (RexCall) el.getOperands().get( 0 ), bucket, rowType ); @@ -218,7 +214,7 @@ private BsonDocument handleDocumentUpdate( RexCall el, GridFSBucket bucket, Mong } - private void attachUpdateStep( BsonDocument doc, RexCall el, MongoRowType rowType, String key ) { + private void attachUpdateStep( BsonDocument doc, RexCall el, AlgDataType rowType, String key ) { List keys = getDocUpdateKey( (RexIndexRef) el.operands.get( 0 ), (RexCall) el.operands.get( 1 ), rowType ); switch ( el.op.getKind() ) { case MQL_UPDATE_REPLACE: @@ -250,7 +246,7 @@ private void attachUpdateStep( BsonDocument doc, RexCall el, MongoRowType rowTyp } - private String getDocParentKey( RexIndexRef rexInputRef, MongoRowType rowType ) { + private String getDocParentKey( RexIndexRef rexInputRef, AlgDataType rowType ) { return rowType.getFieldNames().get( rexInputRef.getIndex() ); } @@ -324,7 +320,7 @@ public static BsonDocument getReplaceUpdate( List keys, RexCall call, Im } - private List getDocUpdateKey( RexIndexRef row, RexCall subfield, MongoRowType rowType ) { + private List getDocUpdateKey( RexIndexRef row, RexCall subfield, AlgDataType rowType ) { String name = rowType.getFieldNames().get( row.getIndex() ); return subfield .operands @@ -389,7 +385,7 @@ private void handlePreparedInsert( Implementor implementor, MongoProject input ) } BsonDocument doc = new BsonDocument(); - MongoEntity entity = implementor.entity.unwrap( MongoEntity.class ); + MongoEntity entity = implementor.getEntity().unwrap( MongoEntity.class ); GridFSBucket bucket = implementor.getBucket(); //noinspection AssertWithSideEffects assert input.getRowType().getFieldCount() == this.getEntity().getRowType().getFieldCount(); @@ -401,8 +397,7 @@ private void handlePreparedInsert( Implementor implementor, MongoProject input ) } else { throw new GenericRuntimeException( "Mapping for physical mongo fields not found" ); }*/ - - implementor.setStaticRowType( (AlgRecordType) input.getRowType() ); + implementor.setEntity( entity ); int pos = 0; for ( RexNode rexNode : input.getChildExps() ) { @@ -461,7 +456,7 @@ private BsonValue getBsonArray( RexCall el, PolyType type, GridFSBucket bucket ) private void handleDirectInsert( Implementor implementor, MongoValues values ) { List docs = new ArrayList<>(); - LogicalTable catalogTable = implementor.entity.unwrap( LogicalTable.class ); + MongoEntity entity = implementor.getEntity(); GridFSBucket bucket = implementor.bucket; AlgDataType valRowType = rowType; @@ -470,8 +465,8 @@ private void handleDirectInsert( Implementor implementor, MongoValues values ) { valRowType = values.getRowType(); } - List columnNames = catalogTable.getColumnNames(); - List columnIds = catalogTable.getColumnIds(); + List columnNames = entity.getRowType().getFieldNames(); + List columnIds = entity.getRowType().getFieldIds(); for ( ImmutableList literals : values.tuples ) { BsonDocument doc = new BsonDocument(); int pos = 0; diff --git a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoToEnumerableConverter.java b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoToEnumerableConverter.java index cbde383df0..376acdf9fc 100644 --- a/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoToEnumerableConverter.java +++ b/plugins/mongodb-adapter/src/main/java/org/polypheny/db/adapter/mongodb/rules/MongoToEnumerableConverter.java @@ -81,13 +81,13 @@ public Result implement( EnumerableAlgImplementor implementor, Prefer pref ) { final AlgDataType rowType = getRowType(); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), rowType, pref.prefer( JavaRowFormat.ARRAY ) ); - if ( mongoImplementor.entity == null ) { + if ( mongoImplementor.getEntity() == null ) { return implementor.result( physType, new BlockBuilder().toBlock() ); } final Expression tupleTypes = MongoTupleType.from( rowType ).asExpression(); - final Expression table = list.append( "table", mongoImplementor.entity.asExpression()/*.getExpression( MongoEntity.MongoQueryable.class )*/ ); + final Expression table = list.append( "table", mongoImplementor.getEntity().asExpression()/*.getExpression( MongoEntity.MongoQueryable.class )*/ ); List opList = Pair.right( mongoImplementor.list ); diff --git a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java index ccb35381fe..9cdd345706 100644 --- a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java +++ b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql2alg/MqlToAlgConverter.java @@ -63,7 +63,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.algebra.type.DocumentType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalCollection; import org.polypheny.db.catalog.entity.logical.LogicalGraph; import org.polypheny.db.catalog.entity.logical.LogicalNamespace; @@ -209,7 +209,7 @@ public class MqlToAlgConverter { private long namespaceId; private boolean notActive = false; private boolean usesDocumentModel; - private LogicalEntity entity; + private Entity entity; public MqlToAlgConverter( Snapshot snapshot, AlgOptCluster cluster ) { @@ -307,7 +307,7 @@ public AlgRoot convert( MqlCollectionStatement query ) { } - private LogicalEntity getEntity( MqlCollectionStatement query, long namespaceId ) { + private Entity getEntity( MqlCollectionStatement query, long namespaceId ) { LogicalNamespace namespace = snapshot.getNamespace( namespaceId ).orElseThrow(); Optional optionalDoc = snapshot.doc().getCollection( namespace.id, query.getCollection() ); @@ -329,7 +329,7 @@ private LogicalEntity getEntity( MqlCollectionStatement query, long namespaceId /** * Starts converting a db.collection.update(); */ - private AlgNode convertUpdate( MqlUpdate query, LogicalEntity entity, AlgNode node ) { + private AlgNode convertUpdate( MqlUpdate query, Entity entity, AlgNode node ) { if ( !query.getQuery().isEmpty() ) { node = convertQuery( query, entity.getRowType(), node ); if ( query.isOnlyOne() ) { @@ -352,7 +352,7 @@ private AlgNode convertUpdate( MqlUpdate query, LogicalEntity entity, AlgNode no * this method is implemented like the reduced update pipeline, * but in fact could be combined and therefore optimized a lot more */ - private AlgNode translateUpdate( MqlUpdate query, AlgDataType rowType, AlgNode node, LogicalEntity entity ) { + private AlgNode translateUpdate( MqlUpdate query, AlgDataType rowType, AlgNode node, Entity entity ) { Map> updates = new HashMap<>(); Map removes = new HashMap<>(); Map renames = new HashMap<>(); @@ -637,7 +637,7 @@ private Map translateCurrentDate( BsonDocument value, AlgDataTy /** * Starts translating an update pipeline */ - private AlgNode convertReducedPipeline( MqlUpdate query, AlgDataType rowType, AlgNode node, LogicalEntity entity ) { + private AlgNode convertReducedPipeline( MqlUpdate query, AlgDataType rowType, AlgNode node, Entity entity ) { Map updates = new HashMap<>(); Map>> mergedUpdates = new HashMap<>(); mergedUpdates.put( UpdateOperation.REMOVE, new ArrayList<>() ); @@ -688,7 +688,7 @@ private AlgNode convertReducedPipeline( MqlUpdate query, AlgDataType rowType, Al /** * Translates a delete operation from its MqlNode format to the {@link AlgNode} form */ - private AlgNode convertDelete( MqlDelete query, LogicalEntity table, AlgNode node ) { + private AlgNode convertDelete( MqlDelete query, Entity table, AlgNode node ) { if ( !query.getQuery().isEmpty() ) { node = convertQuery( query, table.getRowType(), node ); } @@ -713,7 +713,7 @@ private AlgNode convertDelete( MqlDelete query, LogicalEntity table, AlgNode nod * @param entity the table/collection into which the values are inserted * @return the modified AlgNode */ - private AlgNode convertInsert( MqlInsert query, LogicalEntity entity ) { + private AlgNode convertInsert( MqlInsert query, Entity entity ) { return LogicalDocumentModify.create( entity, convertMultipleValues( query.getValues(), entity.getRowType() ), diff --git a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoEntity.java b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoEntity.java index c867d7e2c5..6e1f4cd442 100644 --- a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoEntity.java +++ b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoEntity.java @@ -42,7 +42,7 @@ import org.polypheny.db.algebra.logical.relational.LogicalRelModify; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalEntity; import org.polypheny.db.catalog.entity.physical.PhysicalField; import org.polypheny.db.catalog.entity.physical.PhysicalGraph; @@ -89,10 +89,10 @@ public AlgNode toAlg( AlgOptCluster cluster, AlgTraitSet traitSet ) { * @param operation the operation type */ @Override - public Modify toModificationTable( + public Modify toModificationTable( AlgOptCluster cluster, AlgTraitSet traits, - LogicalEntity physical, + Entity physical, AlgNode child, Operation operation, List targets, diff --git a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoGraph.java b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoGraph.java index 63cb156641..86f76f7ba2 100644 --- a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoGraph.java +++ b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoGraph.java @@ -48,7 +48,7 @@ import org.polypheny.db.algebra.logical.lpg.LogicalLpgModify; import org.polypheny.db.algebra.logical.relational.LogicalRelModify; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.physical.PhysicalEntity; import org.polypheny.db.catalog.entity.physical.PhysicalField; import org.polypheny.db.catalog.entity.physical.PhysicalGraph; @@ -107,7 +107,7 @@ public NeoGraph( PhysicalEntity physical, List fields, public Modify toModificationTable( AlgOptCluster cluster, AlgTraitSet traits, - LogicalEntity table, + Entity table, AlgNode child, Operation operation, List targets, @@ -129,7 +129,7 @@ public Modify toModificationTable( public Modify toModificationGraph( AlgOptCluster cluster, AlgTraitSet traits, - LogicalEntity graph, + Entity graph, AlgNode child, Operation operation, List targets, diff --git a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoNamespace.java b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoNamespace.java index 9ef6a318b7..e36d884b35 100644 --- a/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoNamespace.java +++ b/plugins/neo4j-adapter/src/main/java/org/polypheny/db/adapter/neo4j/NeoNamespace.java @@ -25,7 +25,7 @@ import org.neo4j.driver.Session; import org.polypheny.db.adapter.neo4j.Neo4jPlugin.Neo4jStore; import org.polypheny.db.algebra.type.AlgProtoDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.entity.physical.PhysicalEntity; import org.polypheny.db.catalog.entity.physical.PhysicalField; @@ -96,7 +96,7 @@ public Set getSubNamespaceNames() { @Override - public LogicalEntity getEntity( String name ) { + public Entity getEntity( String name ) { return null; } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlUtil.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlUtil.java index bbe0575e79..10ad926714 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlUtil.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/SqlUtil.java @@ -42,7 +42,7 @@ import org.polypheny.db.algebra.operators.OperatorTable; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypePrecedenceList; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.catalog.snapshot.Snapshot; @@ -617,7 +617,7 @@ public static AlgDataType getNamedType( Identifier node, Snapshot snapshot ) { } - public static boolean supportsModality( Modality modality, LogicalEntity entity ) { + public static boolean supportsModality( Modality modality, Entity entity ) { if ( Objects.requireNonNull( modality ) == Modality.STREAM ) { return entity instanceof StreamableEntity; diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/AbstractNamespace.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/AbstractNamespace.java index e99d00d259..4f3d34fe8e 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/AbstractNamespace.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/AbstractNamespace.java @@ -24,7 +24,7 @@ import org.polypheny.db.algebra.constant.Monotonicity; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.sql.language.SqlNode; import org.polypheny.db.util.Pair; import org.polypheny.db.util.Util; @@ -147,7 +147,7 @@ public SqlNode getEnclosingNode() { @Override - public LogicalEntity getTable() { + public Entity getTable() { return null; } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingNamespace.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingNamespace.java index 327b6ec6d9..cbe71391b2 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingNamespace.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingNamespace.java @@ -20,7 +20,7 @@ import java.util.List; import org.polypheny.db.algebra.constant.Monotonicity; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.sql.language.SqlNode; import org.polypheny.db.util.Pair; @@ -50,7 +50,7 @@ public SqlValidator getValidator() { @Override - public LogicalEntity getTable() { + public Entity getTable() { return namespace.getTable(); } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingScope.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingScope.java index e9796145ac..3091d06d89 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingScope.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/DelegatingScope.java @@ -31,12 +31,11 @@ import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.algebra.type.DynamicRecordType; import org.polypheny.db.algebra.type.StructKind; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.snapshot.Snapshot; import org.polypheny.db.languages.ParserPos; import org.polypheny.db.prepare.Prepare.PreparingEntity; import org.polypheny.db.schema.CustomColumnResolvingEntity; -import org.polypheny.db.schema.Entity; import org.polypheny.db.sql.language.SqlCall; import org.polypheny.db.sql.language.SqlIdentifier; import org.polypheny.db.sql.language.SqlNode; @@ -102,9 +101,9 @@ void resolveInNamespace( SqlValidatorNamespace ns, boolean nullable, List>> entries = ((CustomColumnResolvingEntity) t).resolveColumn( rowType, validator.getTypeFactory(), names ); for ( Pair> entry : entries ) { diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EmptyScope.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EmptyScope.java index b3aa3cbd88..16262119f1 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EmptyScope.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EmptyScope.java @@ -26,7 +26,7 @@ import org.polypheny.db.algebra.constant.Monotonicity; import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.schema.PolyphenyDbSchema; @@ -84,7 +84,7 @@ public void resolve( List names, NameMatcher nameMatcher, boolean deep, @Override public SqlValidatorNamespace getTableNamespace( List names ) { - LogicalEntity table = validator.snapshot.rel().getTable( names.get( 0 ), names.get( 1 ) ).orElse( null ); + Entity table = validator.snapshot.rel().getTable( names.get( 0 ), names.get( 1 ) ).orElse( null ); return table != null ? new EntityNamespace( validator, table ) : null; diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EntityNamespace.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EntityNamespace.java index 845096bed9..7977eaf6ba 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EntityNamespace.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/EntityNamespace.java @@ -25,8 +25,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory.Builder; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.catalog.entity.LogicalEntity; -import org.polypheny.db.schema.Entity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.schema.types.ExtensibleEntity; import org.polypheny.db.sql.language.SqlIdentifier; import org.polypheny.db.sql.language.SqlNode; @@ -42,21 +41,21 @@ class EntityNamespace extends AbstractNamespace { @Getter - private final LogicalEntity table; + private final Entity table; public final ImmutableList extendedFields; /** * Creates a TableNamespace. */ - private EntityNamespace( SqlValidatorImpl validator, LogicalEntity entity, List fields ) { + private EntityNamespace( SqlValidatorImpl validator, Entity entity, List fields ) { super( validator, null ); this.table = entity; this.extendedFields = ImmutableList.copyOf( fields ); } - EntityNamespace( SqlValidatorImpl validator, LogicalEntity table ) { + EntityNamespace( SqlValidatorImpl validator, Entity table ) { this( validator, table, ImmutableList.of() ); } @@ -83,7 +82,7 @@ public SqlNode getNode() { @Override public Monotonicity getMonotonicity( String columnName ) { - final LogicalEntity table = getTable(); + final Entity table = getTable(); return Util.getMonotonicity( table, columnName ); } @@ -100,7 +99,7 @@ public EntityNamespace extend( SqlNodeList extendList ) { builder.addAll( this.extendedFields ); builder.addAll( SqlValidatorUtil.getExtendedColumns( validator.getTypeFactory(), getTable(), extendList ) ); final List extendedFields = builder.build(); - final Entity schemaEntity = table.unwrap( Entity.class ); + final org.polypheny.db.schema.Entity schemaEntity = table.unwrap( org.polypheny.db.schema.Entity.class ); if ( schemaEntity != null && schemaEntity instanceof ExtensibleEntity ) { checkExtendedColumnTypes( extendList ); //final AlgOptEntity algOptEntity = ((AlgOptEntity) table).extend( extendedFields ); @@ -115,7 +114,7 @@ public EntityNamespace extend( SqlNodeList extendList ) { * Gets the data-type of all columns in a table (for a view table: including columns of the underlying table) */ private AlgDataType getBaseRowType() { - final Entity schemaEntity = table.unwrap( Entity.class ); + final org.polypheny.db.schema.Entity schemaEntity = table.unwrap( org.polypheny.db.schema.Entity.class ); return schemaEntity.getRowType( validator.typeFactory ); } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/IdentifierNamespace.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/IdentifierNamespace.java index b94c957cdf..d212b4e3e5 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/IdentifierNamespace.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/IdentifierNamespace.java @@ -29,7 +29,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalNamespace; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; @@ -169,7 +169,7 @@ private SqlValidatorNamespace resolveImpl( SqlIdentifier id ) { } } else if ( ns.size() == 2 ) { LogicalNamespace namespace = validator.snapshot.getNamespace( ns.get( 0 ) ).orElseThrow(); - LogicalEntity entity = null; + Entity entity = null; if ( namespace.dataModel == DataModel.RELATIONAL ) { entity = validator.snapshot.rel().getTable( namespace.id, ns.get( 1 ) ).orElse( null ); } else if ( namespace.dataModel == DataModel.DOCUMENT ) { @@ -188,7 +188,7 @@ private SqlValidatorNamespace resolveImpl( SqlIdentifier id ) { public AlgDataType validateImpl( AlgDataType targetRowType ) { resolvedNamespace = Objects.requireNonNull( resolveImpl( id ) ); if ( resolvedNamespace instanceof EntityNamespace ) { - LogicalEntity table = resolvedNamespace.getTable(); + Entity table = resolvedNamespace.getTable(); if ( validator.shouldExpandIdentifiers() ) { // TODO: expand qualifiers for column references also List qualifiedNames = List.of( table.name ); @@ -254,7 +254,7 @@ public SqlValidatorNamespace resolve() { @Override - public LogicalEntity getTable() { + public Entity getTable() { return resolvedNamespace == null ? null : resolve().getTable(); } @@ -267,14 +267,14 @@ public List> getMonotonicExprs() { @Override public Monotonicity getMonotonicity( String columnName ) { - final LogicalEntity table = getTable(); + final Entity table = getTable(); return Util.getMonotonicity( table, columnName ); } @Override public boolean supportsModality( Modality modality ) { - final LogicalEntity table = getTable(); + final Entity table = getTable(); if ( table == null ) { return modality == Modality.RELATION; } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/ListScope.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/ListScope.java index c95f43481a..1b30ac2500 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/ListScope.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/ListScope.java @@ -31,7 +31,7 @@ import org.polypheny.db.algebra.type.AlgDataTypeField; import org.polypheny.db.algebra.type.StructKind; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.sql.language.SqlNode; import org.polypheny.db.util.Moniker; @@ -100,7 +100,7 @@ private ScopeChild findChild( List names, NameMatcher nameMatcher ) { } // Look up the 2 tables independently, in case one is qualified with catalog & schema and the other is not. - final LogicalEntity table = child.namespace.getTable(); + final Entity table = child.namespace.getTable(); if ( table != null ) { Optional optionalEntity = getEntity( names ); if ( optionalEntity.isPresent() diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorImpl.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorImpl.java index 6b2d19d11a..0b15cdf22f 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorImpl.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorImpl.java @@ -72,7 +72,7 @@ import org.polypheny.db.algebra.type.AlgRecordType; import org.polypheny.db.algebra.type.DynamicRecordType; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.catalog.logistic.DataModel; @@ -105,7 +105,6 @@ import org.polypheny.db.runtime.Resources; import org.polypheny.db.runtime.Resources.ExInst; import org.polypheny.db.schema.ColumnStrategy; -import org.polypheny.db.schema.Entity; import org.polypheny.db.schema.document.DocumentUtil; import org.polypheny.db.sql.language.SqlAggFunction; import org.polypheny.db.sql.language.SqlBasicCall; @@ -2999,7 +2998,7 @@ private void checkRollUpInUsing( SqlIdentifier identifier, SqlNode leftOrRight ) // if it's not a SqlIdentifier then that's fine, it'll be validated somewhere else. if ( leftOrRight instanceof SqlIdentifier ) { SqlIdentifier from = (SqlIdentifier) leftOrRight; - LogicalEntity entity = findTable( + Entity entity = findTable( Util.last( from.names ), snapshot.nameMatcher.isCaseSensitive() ); String name = Util.last( identifier.names ); @@ -3365,7 +3364,7 @@ private boolean isRolledUpColumnAllowedInAgg( SqlIdentifier identifier, SqlValid String tableAlias = pair.left; - LogicalEntity entity = findTable( tableAlias ); + Entity entity = findTable( tableAlias ); if ( entity != null ) { return entity.rolledUpColumnValidInsideAgg(); } @@ -3384,7 +3383,7 @@ private boolean isRolledUpColumn( SqlIdentifier identifier, SqlValidatorScope sc String tableAlias = pair.left; String columnName = pair.right; - LogicalEntity entity = findTable( tableAlias ); + Entity entity = findTable( tableAlias ); if ( entity != null ) { return entity.isRolledUp( columnName ); } @@ -3393,15 +3392,15 @@ private boolean isRolledUpColumn( SqlIdentifier identifier, SqlValidatorScope sc @Nullable - private LogicalEntity findTable( String tableName, boolean caseSensitive ) { + private Entity findTable( String tableName, boolean caseSensitive ) { return snapshot.rel().getTable( Catalog.defaultNamespaceId, tableName ).orElse( null ); } /** - * Given a table alias, find the corresponding {@link Entity} associated with it + * Given a table alias, find the corresponding {@link org.polypheny.db.schema.Entity} associated with it */ - private LogicalEntity findTable( String alias ) { + private Entity findTable( String alias ) { return findTable( alias, snapshot.nameMatcher.isCaseSensitive() ); } @@ -3998,7 +3997,7 @@ private void handleScalarSubQuery( SqlSelect parentSelect, SqlSelect selectItem, } - protected AlgDataType createTargetRowType( LogicalEntity table, SqlNodeList targetColumnList, boolean append ) { + protected AlgDataType createTargetRowType( Entity table, SqlNodeList targetColumnList, boolean append ) { return createTargetRowType( table, targetColumnList, append, false ); } @@ -4011,7 +4010,7 @@ protected AlgDataType createTargetRowType( LogicalEntity table, SqlNodeList targ * @param append Whether to append fields to those in baseRowType * @return Rowtype */ - protected AlgDataType createTargetRowType( LogicalEntity table, SqlNodeList targetColumnList, boolean append, boolean allowDynamic ) { + protected AlgDataType createTargetRowType( Entity table, SqlNodeList targetColumnList, boolean append, boolean allowDynamic ) { AlgDataType baseRowType = table.getRowType(); if ( targetColumnList == null ) { return baseRowType; @@ -4054,7 +4053,7 @@ protected AlgDataType createTargetRowType( LogicalEntity table, SqlNodeList targ public void validateInsert( SqlInsert insert ) { final SqlValidatorNamespace targetNamespace = getSqlNamespace( insert ); validateNamespace( targetNamespace, unknownType ); - final LogicalEntity table = + final Entity table = SqlValidatorUtil.getLogicalEntity( targetNamespace, snapshot, @@ -4101,7 +4100,7 @@ public void validateInsert( SqlInsert insert ) { } - private void checkFieldCount( SqlNode node, LogicalEntity table, SqlNode source, AlgDataType logicalSourceRowType, AlgDataType logicalTargetRowType ) { + private void checkFieldCount( SqlNode node, Entity table, SqlNode source, AlgDataType logicalSourceRowType, AlgDataType logicalTargetRowType ) { final int sourceFieldCount = logicalSourceRowType.getFieldCount(); final int targetFieldCount = logicalTargetRowType.getFieldCount(); if ( sourceFieldCount != targetFieldCount ) { @@ -4321,7 +4320,7 @@ public void validateDelete( SqlDelete call ) { final SqlValidatorNamespace targetNamespace = getSqlNamespace( call ); validateNamespace( targetNamespace, unknownType ); - final LogicalEntity table = targetNamespace.getTable(); + final Entity table = targetNamespace.getTable(); validateAccess( call.getTargetTable(), table, AccessEnum.DELETE ); } @@ -4331,7 +4330,7 @@ public void validateDelete( SqlDelete call ) { public void validateUpdate( SqlUpdate call ) { final SqlValidatorNamespace targetNamespace = getSqlNamespace( call ); validateNamespace( targetNamespace, unknownType ); - final LogicalEntity table = + final Entity table = SqlValidatorUtil.getLogicalEntity( targetNamespace, snapshot, @@ -4366,7 +4365,7 @@ public void validateMerge( SqlMerge call ) { IdentifierNamespace targetNamespace = (IdentifierNamespace) getSqlNamespace( call.getTargetTable() ); validateNamespace( targetNamespace, unknownType ); - LogicalEntity table = targetNamespace.getTable(); + Entity table = targetNamespace.getTable(); validateAccess( call.getTargetTable(), table, AccessEnum.UPDATE ); AlgDataType targetRowType = unknownType; @@ -4403,7 +4402,7 @@ public void validateMerge( SqlMerge call ) { * @param table Table * @param requiredAccess Access requested on table */ - private void validateAccess( SqlNode node, LogicalEntity table, AccessEnum requiredAccess ) { + private void validateAccess( SqlNode node, Entity table, AccessEnum requiredAccess ) { if ( table != null ) { AccessType access = AccessType.ALL; if ( !access.allowsAccess( requiredAccess ) ) { @@ -5064,7 +5063,7 @@ private List getFieldOrigin( SqlNode sqlQuery, int i ) { if ( selectItem instanceof SqlIdentifier ) { final SqlQualified qualified = scope.fullyQualify( (SqlIdentifier) selectItem ); SqlValidatorNamespace namespace = qualified.namespace; - final LogicalEntity table = namespace.getTable(); + final Entity table = namespace.getTable(); if ( table == null ) { return null; } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorNamespace.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorNamespace.java index acbd89ebb7..d2de5bfa2d 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorNamespace.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorNamespace.java @@ -21,7 +21,7 @@ import org.polypheny.db.algebra.constant.Modality; import org.polypheny.db.algebra.constant.Monotonicity; import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.nodes.validate.ValidatorNamespace; import org.polypheny.db.sql.language.SqlIdentifier; import org.polypheny.db.sql.language.SqlNode; @@ -54,7 +54,7 @@ public interface SqlValidatorNamespace extends ValidatorNamespace { /** * Returns the underlying table, or null if there is none. */ - LogicalEntity getTable(); + Entity getTable(); /** * Returns the type of this namespace. diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorUtil.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorUtil.java index b36e7e32b2..2f2aaf4e9b 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorUtil.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/SqlValidatorUtil.java @@ -39,7 +39,7 @@ import org.polypheny.db.algebra.type.AlgDataTypeFieldImpl; import org.polypheny.db.algebra.type.AlgDataTypeSystem; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.logistic.DataModel; import org.polypheny.db.catalog.snapshot.Snapshot; @@ -47,7 +47,6 @@ import org.polypheny.db.languages.ParserPos; import org.polypheny.db.nodes.Node; import org.polypheny.db.schema.CustomColumnResolvingEntity; -import org.polypheny.db.schema.Entity; import org.polypheny.db.schema.types.ExtensibleEntity; import org.polypheny.db.sql.language.SqlCall; import org.polypheny.db.sql.language.SqlDataTypeSpec; @@ -78,14 +77,14 @@ private SqlValidatorUtil() { /** - * Converts a {@link SqlValidatorScope} into a {@link LogicalEntity}. This is only possible if the scope represents an identifier, such as "sales.emp". + * Converts a {@link SqlValidatorScope} into a {@link Entity}. This is only possible if the scope represents an identifier, such as "sales.emp". * Otherwise, returns null. * * @param namespace Namespace * @param datasetName Name of sample dataset to substitute, or null to use the regular table * @param usedDataset Output parameter which is set to true if a sample dataset is found; may be null */ - public static LogicalEntity getLogicalEntity( SqlValidatorNamespace namespace, Snapshot snapshot, String datasetName, boolean[] usedDataset ) { + public static Entity getLogicalEntity( SqlValidatorNamespace namespace, Snapshot snapshot, String datasetName, boolean[] usedDataset ) { if ( namespace.isWrapperFor( SqlValidatorImpl.DmlNamespace.class ) ) { final SqlValidatorImpl.DmlNamespace dmlNamespace = namespace.unwrap( SqlValidatorImpl.DmlNamespace.class ); @@ -128,7 +127,7 @@ private static LogicalTable getLogicalEntity( EntityNamespace entityNamespace, S /** * Gets a list of extended columns with field indices to the underlying table. */ - public static List getExtendedColumns( AlgDataTypeFactory typeFactory, LogicalEntity table, SqlNodeList extendedColumns ) { + public static List getExtendedColumns( AlgDataTypeFactory typeFactory, Entity table, SqlNodeList extendedColumns ) { final ImmutableList.Builder extendedFields = ImmutableList.builder(); final ExtensibleEntity extTable = table.unwrap( ExtensibleEntity.class ); int extendedFieldOffset = @@ -264,7 +263,7 @@ public static SqlValidatorWithHints newValidator( OperatorTable opTab, Snapshot } - public static AlgDataTypeField getTargetField( AlgDataType rowType, AlgDataTypeFactory typeFactory, SqlIdentifier id, Snapshot snapshot, LogicalEntity table ) { + public static AlgDataTypeField getTargetField( AlgDataType rowType, AlgDataTypeFactory typeFactory, SqlIdentifier id, Snapshot snapshot, Entity table ) { return getTargetField( rowType, typeFactory, id, snapshot, table, false ); } @@ -277,8 +276,8 @@ public static AlgDataTypeField getTargetField( AlgDataType rowType, AlgDataTypeF * @param table the target table or null if it is not a RelOptTable instance * @return the target field or null if the name cannot be resolved */ - public static AlgDataTypeField getTargetField( AlgDataType rowType, AlgDataTypeFactory typeFactory, SqlIdentifier id, Snapshot snapshot, LogicalEntity table, boolean isDocument ) { - final Entity t = table == null ? null : table.unwrap( Entity.class ); + public static AlgDataTypeField getTargetField( AlgDataType rowType, AlgDataTypeFactory typeFactory, SqlIdentifier id, Snapshot snapshot, Entity table, boolean isDocument ) { + final org.polypheny.db.schema.Entity t = table == null ? null : table.unwrap( org.polypheny.db.schema.Entity.class ); if ( !(t instanceof CustomColumnResolvingEntity) ) { final NameMatcher nameMatcher = snapshot.nameMatcher; diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/UnnestNamespace.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/UnnestNamespace.java index be5084aa5d..c872ddfe0f 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/UnnestNamespace.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/UnnestNamespace.java @@ -18,7 +18,7 @@ import org.polypheny.db.algebra.type.AlgDataType; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.sql.language.SqlCall; import org.polypheny.db.sql.language.SqlIdentifier; import org.polypheny.db.sql.language.SqlNode; @@ -45,7 +45,7 @@ class UnnestNamespace extends AbstractNamespace { @Override - public LogicalEntity getTable() { + public Entity getTable() { final SqlNode toUnnest = unnest.operand( 0 ); if ( toUnnest instanceof SqlIdentifier ) { // When operand of SqlIdentifier type does not have struct, fake a table for UnnestNamespace diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/WithScope.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/WithScope.java index 23647a30aa..3f19c89270 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/WithScope.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/validate/WithScope.java @@ -19,7 +19,7 @@ import java.util.List; import org.polypheny.db.algebra.type.StructKind; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalNamespace; import org.polypheny.db.sql.language.SqlNode; import org.polypheny.db.sql.language.SqlWithItem; @@ -71,7 +71,7 @@ public void resolveTable( List names, NameMatcher nameMatcher, Path path final SqlValidatorNamespace ns = validator.getSqlNamespace( withItem ); final Step path2 = path.plus( ns.getRowType(), 0, names.get( 0 ), StructKind.FULLY_QUALIFIED ); LogicalNamespace namespace = validator.snapshot.getNamespace( names.get( 0 ) ).orElseThrow(); - LogicalEntity entity = validator.snapshot.rel().getTable( names.get( 0 ), names.get( 1 ) ).orElseThrow(); + Entity entity = validator.snapshot.rel().getTable( names.get( 0 ), names.get( 1 ) ).orElseThrow(); resolved.found( ns, false, null, path2, null ); return; } @@ -84,7 +84,7 @@ public void resolve( List names, NameMatcher nameMatcher, boolean deep, if ( names.size() == 1 && names.equals( withItem.name.names ) ) { final SqlValidatorNamespace ns = validator.getSqlNamespace( withItem ); final Step path = Path.EMPTY.plus( ns.getRowType(), 0, names.get( 0 ), StructKind.FULLY_QUALIFIED ); - LogicalEntity entity = validator.snapshot.rel().getTable( names.get( 0 ), names.get( 1 ) ).orElseThrow(); + Entity entity = validator.snapshot.rel().getTable( names.get( 0 ), names.get( 1 ) ).orElseThrow(); resolved.found( ns, false, null, path, null ); return; } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/sql2alg/SqlToAlgConverter.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/sql2alg/SqlToAlgConverter.java index c172f1fcb0..55b173800c 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/sql2alg/SqlToAlgConverter.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/sql2alg/SqlToAlgConverter.java @@ -124,7 +124,7 @@ import org.polypheny.db.algebra.type.AlgDataType; import org.polypheny.db.algebra.type.AlgDataTypeFactory; import org.polypheny.db.algebra.type.AlgDataTypeField; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.catalog.logistic.DataModel; @@ -167,7 +167,6 @@ import org.polypheny.db.rex.RexUtil; import org.polypheny.db.rex.RexWindowBound; import org.polypheny.db.schema.ColumnStrategy; -import org.polypheny.db.schema.Entity; import org.polypheny.db.schema.types.ModifiableTable; import org.polypheny.db.schema.types.TranslatableEntity; import org.polypheny.db.sql.language.SqlAggFunction; @@ -2109,7 +2108,7 @@ private void convertIdentifier( Blackboard bb, SqlIdentifier id, SqlNodeList ext } final String datasetName = datasetStack.isEmpty() ? null : datasetStack.peek(); final boolean[] usedDataset = { false }; - LogicalEntity table = SqlValidatorUtil.getLogicalEntity( fromNamespace, snapshot, datasetName, usedDataset ); + Entity table = SqlValidatorUtil.getLogicalEntity( fromNamespace, snapshot, datasetName, usedDataset ); if ( extendedColumns != null && extendedColumns.size() > 0 ) { assert table != null; final ValidatorTable validatorTable = table.unwrap( ValidatorTable.class ); @@ -2853,7 +2852,7 @@ private boolean all( SqlCall call ) { protected AlgNode convertInsert( SqlInsert call ) { - LogicalEntity targetTable = getTargetTable( call ); + Entity targetTable = getTargetTable( call ); final AlgDataType targetRowType = validator.getValidatedNodeType( call ); assert targetRowType != null; @@ -2867,9 +2866,9 @@ protected AlgNode convertInsert( SqlInsert call ) { /** * Creates a relational expression to modify a table or modifiable view. */ - private AlgNode createModify( LogicalEntity targetTable, AlgNode source ) { + private AlgNode createModify( Entity targetTable, AlgNode source ) { final ModifiableTable modifiableTable = targetTable.unwrap( ModifiableTable.class ); - if ( modifiableTable != null && modifiableTable == targetTable.unwrap( Entity.class ) ) { + if ( modifiableTable != null && modifiableTable == targetTable.unwrap( org.polypheny.db.schema.Entity.class ) ) { return modifiableTable.toModificationTable( cluster, source.getTraitSet(), @@ -2887,9 +2886,9 @@ private AlgNode createModify( LogicalEntity targetTable, AlgNode source ) { null, false ); } - - public AlgNode toAlg( final LogicalEntity table ) { + + public AlgNode toAlg( final Entity table ) { final AlgNode scan = table.unwrap( TranslatableEntity.class ).toAlg( cluster, cluster.traitSet() ); final InitializerExpressionFactory ief = @@ -2925,7 +2924,7 @@ public AlgNode toAlg( final LogicalEntity table ) { } - protected LogicalEntity getTargetTable( SqlNode call ) { + protected Entity getTargetTable( SqlNode call ) { final SqlValidatorNamespace targetNs = validator.getSqlNamespace( call ); if ( targetNs.isWrapperFor( SqlValidatorImpl.DmlNamespace.class ) ) { final SqlValidatorImpl.DmlNamespace dmlNamespace = targetNs.unwrap( SqlValidatorImpl.DmlNamespace.class ); @@ -2956,7 +2955,7 @@ protected AlgNode convertColumnList( final SqlInsert call, AlgNode source ) { final List columnExprs = new ArrayList<>(); collectInsertTargets( call, sourceRef, targetColumnNames, columnExprs ); - final LogicalEntity targetTable = getTargetTable( call ); + final Entity targetTable = getTargetTable( call ); final AlgDataType targetRowType = targetTable.getRowType();//AlgOptEntityImpl.realRowType( targetTable ); final List targetFields = targetRowType.getFields(); boolean isDocument = call.getSchemaType() == DataModel.DOCUMENT; @@ -3007,7 +3006,7 @@ protected AlgNode convertColumnList( final SqlInsert call, AlgNode source ) { /** * Creates a blackboard for translating the expressions of generated columns in an INSERT statement. */ - private Blackboard createInsertBlackboard( LogicalEntity targetTable, RexNode sourceRef, List targetColumnNames ) { + private Blackboard createInsertBlackboard( Entity targetTable, RexNode sourceRef, List targetColumnNames ) { final Map nameToNodeMap = new HashMap<>(); int j = 0; @@ -3028,9 +3027,9 @@ private Blackboard createInsertBlackboard( LogicalEntity targetTable, RexNode so } - private InitializerExpressionFactory getInitializerFactory( LogicalEntity validatorTable ) { + private InitializerExpressionFactory getInitializerFactory( Entity validatorTable ) { // We might unwrap a null instead of a InitializerExpressionFactory. - final Entity entity = unwrap( validatorTable, Entity.class ); + final org.polypheny.db.schema.Entity entity = unwrap( validatorTable, org.polypheny.db.schema.Entity.class ); if ( entity != null ) { InitializerExpressionFactory f = unwrap( entity, InitializerExpressionFactory.class ); if ( f != null ) { @@ -3066,7 +3065,7 @@ private RexNode castNullLiteralIfNeeded( RexNode node, AlgDataType type ) { * @param columnExprs List of expressions, to be populated */ protected void collectInsertTargets( SqlInsert call, final RexNode sourceRef, final List targetColumnNames, List columnExprs ) { - final LogicalEntity targetTable = getTargetTable( call ); + final Entity targetTable = getTargetTable( call ); final AlgDataType tableRowType = targetTable.getRowType(); SqlNodeList targetColumnList = call.getTargetColumnList(); if ( targetColumnList == null ) { @@ -3139,7 +3138,7 @@ protected void collectInsertTargets( SqlInsert call, final RexNode sourceRef, fi private AlgNode convertDelete( SqlDelete call ) { - LogicalEntity targetTable = getTargetTable( call ); + Entity targetTable = getTargetTable( call ); AlgNode sourceRel = convertSelect( call.getSourceSelect(), false ); return LogicalRelModify.create( targetTable, @@ -3161,7 +3160,7 @@ private AlgNode convertUpdate( SqlUpdate call ) { rexNodeSourceExpressionListBuilder.add( rn ); } - LogicalEntity targetTable = getTargetTable( call ); + Entity targetTable = getTargetTable( call ); // convert update column list from SqlIdentifier to String final List targetColumnNameList = new ArrayList<>(); @@ -3186,7 +3185,7 @@ private AlgNode convertUpdate( SqlUpdate call ) { private AlgNode convertMerge( SqlMerge call ) { - LogicalEntity targetTable = getTargetTable( call ); + Entity targetTable = getTargetTable( call ); // convert update column list from SqlIdentifier to String final List targetColumnNameList = new ArrayList<>(); diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/SqlToRelConverterExtendedTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/SqlToRelConverterExtendedTest.java index cd27b90a48..6011e556d3 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/SqlToRelConverterExtendedTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/SqlToRelConverterExtendedTest.java @@ -23,7 +23,7 @@ import org.polypheny.db.algebra.AlgShuttleImpl; import org.polypheny.db.algebra.core.relational.RelScan; import org.polypheny.db.algebra.externalize.AlgJsonWriter; -import org.polypheny.db.catalog.entity.LogicalEntity; +import org.polypheny.db.catalog.entity.Entity; import org.polypheny.db.runtime.Hook; import org.polypheny.db.runtime.Hook.Closeable; @@ -58,7 +58,7 @@ public static void foo( AlgNode alg ) { final String json = writer.asString(); // Find the schema. If there are no tables in the plan, we won't need one. - final LogicalEntity[] entities = { null }; + final Entity[] entities = { null }; alg.accept( new AlgShuttleImpl() { @Override public AlgNode visit( RelScan scan ) {