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 bfca9a8722..9f7b98232b 100644 --- a/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java +++ b/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java @@ -254,8 +254,8 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy // Initialize result lists. They will all be with in the same ordering. List proposedRoutingPlans = null; - List optimalNodeList = new ArrayList<>(); - List parameterizedRootList = new ArrayList<>(); + List optimalNodes = new ArrayList<>(); + List parameterizedRoots = new ArrayList<>(); List results = new ArrayList<>(); List generatedCodes = new ArrayList<>(); @@ -413,7 +413,7 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy parameterizedRoot = routedRoot; } - parameterizedRootList.add( parameterizedRoot ); + parameterizedRoots.add( parameterizedRoot ); } if ( isAnalyze ) { @@ -429,9 +429,9 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy for ( int i = 0; i < proposedRoutingPlans.size(); i++ ) { AlgRoot routedRoot = proposedRoutingPlans.get( i ).getRoutedRoot(); if ( this.isImplementationCachingActive( statement, routedRoot ) ) { - AlgRoot parameterizedRoot = parameterizedRootList.get( i ); + AlgRoot parameterizedRoot = parameterizedRoots.get( i ); PreparedResult preparedResult = ImplementationCache.INSTANCE.getIfPresent( parameterizedRoot.alg ); - AlgNode optimalNode = QueryPlanCache.INSTANCE.getIfPresent( parameterizedRootList.get( i ).alg ); + AlgNode optimalNode = QueryPlanCache.INSTANCE.getIfPresent( parameterizedRoots.get( i ).alg ); if ( preparedResult != null ) { PolyImplementation result = createPolyImplementation( preparedResult, @@ -443,16 +443,16 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy Objects.requireNonNull( optimalNode.getTraitSet().getTrait( ModelTraitDef.INSTANCE ) ).getDataModel() ); results.add( result ); generatedCodes.add( preparedResult.getCode() ); - optimalNodeList.add( optimalNode ); + optimalNodes.add( optimalNode ); } else { results.add( null ); generatedCodes.add( null ); - optimalNodeList.add( null ); + optimalNodes.add( null ); } } else { results.add( null ); generatedCodes.add( null ); - optimalNodeList.add( null ); + optimalNodes.add( null ); } } @@ -461,16 +461,16 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy } // Can we return earlier? - if ( results.stream().allMatch( Objects::nonNull ) && optimalNodeList.stream().allMatch( Objects::nonNull ) ) { + if ( results.stream().allMatch( Objects::nonNull ) && optimalNodes.stream().allMatch( Objects::nonNull ) ) { return new ProposedImplementations( proposedRoutingPlans, - optimalNodeList.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), + optimalNodes.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), results.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), generatedCodes.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), logicalQueryInformation ); } - optimalNodeList = new ArrayList<>( Collections.nCopies( optimalNodeList.size(), null ) ); + optimalNodes = new ArrayList<>( Collections.nCopies( optimalNodes.size(), null ) ); // // Plan Caching @@ -480,9 +480,9 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy for ( int i = 0; i < proposedRoutingPlans.size(); i++ ) { if ( this.isQueryPlanCachingActive( statement, proposedRoutingPlans.get( i ).getRoutedRoot() ) ) { // Should always be the case - AlgNode cachedElem = QueryPlanCache.INSTANCE.getIfPresent( parameterizedRootList.get( i ).alg ); + AlgNode cachedElem = QueryPlanCache.INSTANCE.getIfPresent( parameterizedRoots.get( i ).alg ); if ( cachedElem != null ) { - optimalNodeList.set( i, cachedElem ); + optimalNodes.set( i, cachedElem ); } } } @@ -495,16 +495,16 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy } // OptimalNode same size as routed, parametrized and result - for ( int i = 0; i < optimalNodeList.size(); i++ ) { - if ( optimalNodeList.get( i ) != null ) { + for ( int i = 0; i < optimalNodes.size(); i++ ) { + if ( optimalNodes.get( i ) != null ) { continue; } - AlgRoot parameterizedRoot = parameterizedRootList.get( i ); + AlgRoot parameterizedRoot = parameterizedRoots.get( i ); AlgRoot routedRoot = proposedRoutingPlans.get( i ).getRoutedRoot(); - optimalNodeList.set( i, optimize( parameterizedRoot, resultConvention ) ); + optimalNodes.set( i, optimize( parameterizedRoot, resultConvention ) ); if ( this.isQueryPlanCachingActive( statement, routedRoot ) ) { - QueryPlanCache.INSTANCE.put( parameterizedRoot.alg, optimalNodeList.get( i ) ); + QueryPlanCache.INSTANCE.put( parameterizedRoot.alg, optimalNodes.get( i ) ); } } @@ -515,13 +515,13 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy statement.getProcessingDuration().start( "Implementation" ); } - for ( int i = 0; i < optimalNodeList.size(); i++ ) { + for ( int i = 0; i < optimalNodes.size(); i++ ) { if ( results.get( i ) != null ) { continue; } - AlgNode optimalNode = optimalNodeList.get( i ); - AlgRoot parameterizedRoot = parameterizedRootList.get( i ); + AlgNode optimalNode = optimalNodes.get( i ); + AlgRoot parameterizedRoot = parameterizedRoots.get( i ); AlgRoot routedRoot = proposedRoutingPlans.get( i ).getRoutedRoot(); final AlgDataType rowType = parameterizedRoot.alg.getRowType(); @@ -549,7 +549,7 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy Objects.requireNonNull( optimalNode.getTraitSet().getTrait( ModelTraitDef.INSTANCE ) ).getDataModel() ); results.set( i, result ); generatedCodes.set( i, preparedResult.getCode() ); - optimalNodeList.set( i, optimalRoot.alg ); + optimalNodes.set( i, optimalRoot.alg ); } if ( isAnalyze ) { statement.getProcessingDuration().stop( "Implementation" ); @@ -563,7 +563,7 @@ private ProposedImplementations prepareQueryList( AlgRoot logicalRoot, AlgDataTy // Finally, all optionals should be of certain values. return new ProposedImplementations( proposedRoutingPlans, - optimalNodeList.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), + optimalNodes.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), results.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), generatedCodes.stream().filter( Objects::nonNull ).collect( Collectors.toList() ), logicalQueryInformation ); diff --git a/information/src/main/java/org/polypheny/db/information/InformationDuration.java b/information/src/main/java/org/polypheny/db/information/InformationDuration.java index de3e22da94..343bd60eb7 100644 --- a/information/src/main/java/org/polypheny/db/information/InformationDuration.java +++ b/information/src/main/java/org/polypheny/db/information/InformationDuration.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -29,7 +30,7 @@ public class InformationDuration extends Information { - @JsonProperty + private final Map children = new HashMap<>(); @@ -56,6 +57,11 @@ public InformationDuration( final InformationGroup group ) { } + @JsonProperty("children") + public Collection getDurationValues() { + return children.values(); + } + public Duration start( final String name ) { Duration d = new Duration( name ); this.children.put( name, d ); @@ -136,9 +142,10 @@ public static class Duration implements Comparable { @JsonProperty private final long sequence; - @JsonProperty - @JsonPropertyOrder("sequence") + private final Map children = new HashMap<>(); + + @JsonProperty private final boolean isChild = true; /** @@ -165,6 +172,12 @@ private Duration( final String name ) { } + @JsonPropertyOrder("sequence") + @JsonProperty("children") + public Collection getDurationValues() { + return children.values(); + } + private Duration( final String name, final long nanoDuration ) { this.sequence = counter++; this.name = name;