From ba54b2c1c06c53eb9e62a23c475f1533322e262f Mon Sep 17 00:00:00 2001 From: Martin Vahlensieck Date: Mon, 4 Dec 2023 17:34:16 +0100 Subject: [PATCH 1/2] Fix typo and remove stray semicolons --- core/src/main/java/org/polypheny/db/functions/MqlFunctions.java | 2 +- core/src/main/java/org/polypheny/db/type/entity/PolyDouble.java | 1 - .../db/adapter/jdbc/alg2sql/AlgToSqlConverterTest.java | 2 -- .../src/main/java/org/polypheny/db/sql/language/SqlUtil.java | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java b/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java index 02dc2fc9d8..0679d72142 100644 --- a/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java +++ b/core/src/main/java/org/polypheny/db/functions/MqlFunctions.java @@ -57,7 +57,7 @@ public class MqlFunctions { private MqlFunctions() { - // empty on purposeD + // empty on purpose } diff --git a/core/src/main/java/org/polypheny/db/type/entity/PolyDouble.java b/core/src/main/java/org/polypheny/db/type/entity/PolyDouble.java index 183be6afee..5cba856ff4 100644 --- a/core/src/main/java/org/polypheny/db/type/entity/PolyDouble.java +++ b/core/src/main/java/org/polypheny/db/type/entity/PolyDouble.java @@ -190,7 +190,6 @@ protected BinarySerializer createSerializer( int version, Compatibil @Override public void encode( BinaryOutput out, PolyDouble item ) { out.writeUTF8Nullable( item.value == null ? null : item.value.toString() ); - ; } diff --git a/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/AlgToSqlConverterTest.java b/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/AlgToSqlConverterTest.java index dccb84190e..76cc6b7e61 100644 --- a/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/AlgToSqlConverterTest.java +++ b/plugins/jdbc-adapter-framework/src/test/java/org/polypheny/db/adapter/jdbc/alg2sql/AlgToSqlConverterTest.java @@ -80,8 +80,6 @@ import org.polypheny.db.tools.RuleSets; import org.polypheny.db.type.PolyType; -; - /** * Tests for {@link AlgToSqlConverter}. 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 10ad926714..1d935c4b53 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 @@ -607,7 +607,6 @@ public static SqlLiteral symbol( Enum o, ParserPos parserPos ) { public static AlgDataType getNamedType( Identifier node, Snapshot snapshot ) { - ; LogicalTable table = snapshot.rel().getTable( node.getNames().get( 0 ), node.getNames().get( 1 ) ).orElse( null ); if ( table != null ) { return table.getRowType(); From fb49c61a9b9dc67150b4732cab24083685d9c68c Mon Sep 17 00:00:00 2001 From: Martin Vahlensieck Date: Tue, 5 Dec 2023 09:23:13 +0100 Subject: [PATCH 2/2] Use of ifPresent/map etc. for some operations on Optionals --- .../java/org/polypheny/db/catalog/impl/PolyCatalog.java | 8 ++------ .../org/polypheny/db/iface/QueryInterfaceManager.java | 3 +-- .../org/polypheny/db/plan/AbstractAlgOptPlanner.java | 4 +--- .../java/org/polypheny/db/type/entity/PolyTimeStamp.java | 2 +- .../org/polypheny/db/routing/routers/BaseRouter.java | 9 ++++----- .../db/adapter/jdbc/rel2sql/SqlImplementor.java | 7 ++----- 6 files changed, 11 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java b/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java index 2686e09719..c8628cf8a6 100644 --- a/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/impl/PolyCatalog.java @@ -115,9 +115,7 @@ public class PolyCatalog extends Catalog implements PolySerializable { private final AtomicBoolean dirty = new AtomicBoolean( false ); @Getter - PropertyChangeListener changeListener = evt -> { - dirty.set( true ); - }; + PropertyChangeListener changeListener = evt -> dirty.set( true ); public PolyCatalog() { @@ -183,9 +181,7 @@ private void addNamespaceIfNecessary( AllocationEntity entity ) { // re-add physical namespace, we could check first, but not necessary - if ( getStoreSnapshot( entity.adapterId ).isPresent() ) { - getStoreSnapshot( entity.adapterId ).get().addNamespace( entity.namespaceId, adapter.getCurrentNamespace() ); - } + getStoreSnapshot( entity.adapterId ).ifPresent( e -> e.addNamespace( entity.namespaceId, adapter.getCurrentNamespace() ) ); } diff --git a/core/src/main/java/org/polypheny/db/iface/QueryInterfaceManager.java b/core/src/main/java/org/polypheny/db/iface/QueryInterfaceManager.java index 809a2238b3..e387e2a108 100644 --- a/core/src/main/java/org/polypheny/db/iface/QueryInterfaceManager.java +++ b/core/src/main/java/org/polypheny/db/iface/QueryInterfaceManager.java @@ -73,8 +73,7 @@ private QueryInterfaceManager( TransactionManager transactionManager, Authentica public QueryInterface getQueryInterface( String uniqueName ) { - uniqueName = uniqueName.toLowerCase(); - return interfaceByName.get( uniqueName ); + return interfaceByName.get( uniqueName.toLowerCase() ); } diff --git a/core/src/main/java/org/polypheny/db/plan/AbstractAlgOptPlanner.java b/core/src/main/java/org/polypheny/db/plan/AbstractAlgOptPlanner.java index 00c989a33d..9c8211ea0e 100644 --- a/core/src/main/java/org/polypheny/db/plan/AbstractAlgOptPlanner.java +++ b/core/src/main/java/org/polypheny/db/plan/AbstractAlgOptPlanner.java @@ -105,9 +105,7 @@ protected AbstractAlgOptPlanner( AlgOptCostFactory costFactory, Context context this.context = context; Optional oCancelFlag = context.unwrap( CancelFlag.class ); - this.cancelFlag = oCancelFlag.isPresent() - ? oCancelFlag.get().atomicBoolean - : new AtomicBoolean(); + this.cancelFlag = oCancelFlag.map( c -> c.atomicBoolean ).orElseGet( AtomicBoolean::new ); // Add abstract {@link AlgNode} classes. No RelNodes will ever be registered with these types, but some operands may use them. classes.add( AlgNode.class ); diff --git a/core/src/main/java/org/polypheny/db/type/entity/PolyTimeStamp.java b/core/src/main/java/org/polypheny/db/type/entity/PolyTimeStamp.java index 7e2322182e..0d9e307780 100644 --- a/core/src/main/java/org/polypheny/db/type/entity/PolyTimeStamp.java +++ b/core/src/main/java/org/polypheny/db/type/entity/PolyTimeStamp.java @@ -42,7 +42,7 @@ public class PolyTimeStamp extends PolyTemporal { public static final DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); - public Long milliSinceEpoch; // normalized to utz + public Long milliSinceEpoch; // normalized to UTC public PolyTimeStamp( Long milliSinceEpoch ) { diff --git a/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java b/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java index 59e292571d..e70a4cf515 100644 --- a/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java +++ b/dbms/src/main/java/org/polypheny/db/routing/routers/BaseRouter.java @@ -195,11 +195,10 @@ protected Map> selectPlacementOld( LogicalTable tab AllocationPlacement longestPlacement = catalog.getSnapshot().alloc().getPlacement( adapterIdWithMostPlacements, table.id ).orElseThrow(); for ( LogicalColumn column : logicalColumns ) { Optional optionalColumn = catalog.getSnapshot().alloc().getColumn( longestPlacement.id, column.id ); - if ( optionalColumn.isPresent() ) { - placementList.add( optionalColumn.get() ); - } else { - missingColumns.add( column ); - } + optionalColumn.ifPresentOrElse( + placementList::add, + () -> missingColumns.add( column ) + ); } Map> placementToColumns = new HashMap<>(); diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java index bd18b06515..103c221189 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/rel2sql/SqlImplementor.java @@ -178,11 +178,8 @@ public Result setOpToSql( SqlSetOperator operator, AlgNode alg ) { for ( Ord input : Ord.zip( alg.getInputs() ) ) { final Result result = visitChild( input.i, input.e ); if ( node == null ) { - if ( input.getValue().unwrap( JdbcScan.class ).isPresent() ) { - node = result.asSelect( input.getValue().unwrap( JdbcScan.class ).get().getEntity().getNodeList() ); - } else { - node = result.asSelect(); - } + node = input.getValue().unwrap( JdbcScan.class ).map( i -> result.asSelect( i.getEntity().getNodeList() ) ) + .orElse( result.asSelect() ); } else { if ( input.getValue().unwrap( JdbcScan.class ).isPresent() ) { node = (SqlNode) operator.createCall( POS, node, result.asSelect( input.getValue().unwrap( JdbcScan.class ).get().getEntity().getNodeList() ) );