Skip to content

Commit

Permalink
fixed routing catch to even add routed plan, added missing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo authored and gartens committed Jan 7, 2025
1 parent 4461bcf commit 984106e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,13 @@ private void finalizeAccessedPartitions( StatementEvent eventData ) {


private void cacheRouterPlans( List<ProposedRoutingPlan> proposedRoutingPlans, List<AlgOptCost> approximatedCosts, String queryId, Set<Long> partitionIds ) {
List<CachedProposedRoutingPlan> cachedPlans = new ArrayList<>();
List<CachedProposedRoutingPlan> cachedPlans = new ArrayList<>( RoutingPlanCache.INSTANCE.getIfPresent( queryId, partitionIds ) );
for ( int i = 0; i < proposedRoutingPlans.size(); i++ ) {
if ( proposedRoutingPlans.get( i ).isCacheable() && !RoutingPlanCache.INSTANCE.isKeyPresent( queryId, partitionIds ) ) {
cachedPlans.add( new CachedProposedRoutingPlan( proposedRoutingPlans.get( i ), approximatedCosts.get( i ) ) );
if ( proposedRoutingPlans.get( i ).isCacheable() ) {
CachedProposedRoutingPlan plan = new CachedProposedRoutingPlan( proposedRoutingPlans.get( i ), approximatedCosts.get( i ) );
if ( !cachedPlans.contains( plan ) ) {
cachedPlans.add( plan );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.polypheny.db.config.RuntimeConfig;
import org.polypheny.db.information.InformationAction;
import org.polypheny.db.information.InformationGraph;
Expand Down Expand Up @@ -69,6 +70,7 @@ public boolean isKeyPresent( String queryId, Set<Long> partitionIds ) {
}


@NotNull
public List<CachedProposedRoutingPlan> getIfPresent( String queryId, Set<Long> partitionIds ) {
List<CachedProposedRoutingPlan> routingPlans = planCache.getIfPresent( Pair.of( queryId, partitionIds ) );
if ( routingPlans == null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import lombok.Getter;
import lombok.Setter;
import lombok.Value;
import org.polypheny.db.plan.AlgOptCost;
import org.polypheny.db.routing.ColumnDistribution.RoutedDistribution;
import org.polypheny.db.routing.FieldDistribution;
Expand All @@ -31,17 +32,18 @@
*/
@Getter
@Setter
@Value
public class CachedProposedRoutingPlan implements RoutingPlan {

@Getter
public RoutedDistribution routedDistribution; // PartitionId -> List<Pair<PlacementId, ColumnId>>
@Getter
public FieldDistribution fieldDistribution; // PartitionId -> List<AllocationColumn>

protected String queryClass;
protected String physicalQueryClass;
protected AlgOptCost preCosts;
protected Class<? extends Router> router;
String queryClass;
String physicalQueryClass;
AlgOptCost preCosts;
Class<? extends Router> router;


public CachedProposedRoutingPlan( ProposedRoutingPlan routingPlan, AlgOptCost approximatedCosts ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ protected List<RoutedAlgBuilder> handleNonePartitioning( AlgNode node, LogicalTa
List<AllocationEntity> entities = Catalog.snapshot().alloc().getFromLogical( table.id );

List<Long> partitionId = List.of( entities.get( 0 ).partitionId );
context.fieldDistribution = new ColumnDistribution( table.id, table.getColumnIds(), partitionId, partitionId, List.of(), context.getSnapshot() );
ColumnDistribution columnDistribution = new ColumnDistribution( table.id, table.getColumnIds(), partitionId, partitionId, List.of(), context.getSnapshot() );
context.fieldDistribution = columnDistribution;
context.routedDistribution = columnDistribution.route();

// Only one builder available
super.handleRelScan( builders.get( 0 ), context.getStatement(), entities.get( 0 ) );
Expand Down

0 comments on commit 984106e

Please sign in to comment.