001/* 002 * Copyright (c) 2016 Chris K Wensel <chris@wensel.net>. All Rights Reserved. 003 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved. 004 * 005 * Project and contact information: http://www.cascading.org/ 006 * 007 * This file is part of the Cascading project. 008 * 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 */ 021 022package cascading.flow.planner.rule.partitioner; 023 024import cascading.flow.planner.iso.ElementAnnotation; 025import cascading.flow.planner.iso.expression.ExpressionGraph; 026import cascading.flow.planner.iso.subgraph.GraphPartitioner; 027import cascading.flow.planner.iso.subgraph.partitioner.ExpressionGraphPartitioner; 028import cascading.flow.planner.iso.subgraph.partitioner.UniquePathGraphPartitioner; 029import cascading.flow.planner.rule.PlanPhase; 030import cascading.flow.planner.rule.RuleExpression; 031import cascading.flow.planner.rule.util.LogLevel; 032 033/** 034 * Class UniquePathRulePartitioner relies on a {@link cascading.flow.planner.rule.RuleExpression} to identify 035 * sub-graphs as initial partitions, then will partition the resulting graph into a unique sub-graph for each 036 * unique path between the head and tail of the graph. 037 * <p/> 038 * This partitioner currently requires the matched sub-graph (per the RuleExpression) to have a single head and single 039 * tail. All paths will between the matched head and tail. 040 * <p> 041 * Any remaining elements from the original graph will be included in the final path sub-graph. 042 */ 043public class UniquePathRulePartitioner extends ExpressionRulePartitioner 044 { 045 public UniquePathRulePartitioner( PlanPhase phase, RuleExpression ruleExpression ) 046 { 047 super( phase, ruleExpression ); 048 } 049 050 public UniquePathRulePartitioner( PlanPhase phase, RuleExpression ruleExpression, ElementAnnotation... annotations ) 051 { 052 super( phase, ruleExpression, annotations ); 053 } 054 055 public UniquePathRulePartitioner( PlanPhase phase, RuleExpression ruleExpression, Enum... annotationExcludes ) 056 { 057 super( phase, ruleExpression, annotationExcludes ); 058 } 059 060 public UniquePathRulePartitioner( PlanPhase phase, PartitionSource partitionSource, RuleExpression ruleExpression ) 061 { 062 super( phase, partitionSource, ruleExpression ); 063 } 064 065 public UniquePathRulePartitioner( PlanPhase phase, PartitionSource partitionSource, RuleExpression ruleExpression, ElementAnnotation... annotations ) 066 { 067 super( phase, partitionSource, ruleExpression, annotations ); 068 } 069 070 public UniquePathRulePartitioner( PlanPhase phase, PartitionSource partitionSource, RuleExpression ruleExpression, Enum... annotationExcludes ) 071 { 072 super( phase, partitionSource, ruleExpression, annotationExcludes ); 073 } 074 075 public UniquePathRulePartitioner( LogLevel logLevel, PlanPhase phase, RuleExpression ruleExpression ) 076 { 077 super( logLevel, phase, ruleExpression ); 078 } 079 080 public UniquePathRulePartitioner( LogLevel logLevel, PlanPhase phase, RuleExpression ruleExpression, ElementAnnotation... annotations ) 081 { 082 super( logLevel, phase, ruleExpression, annotations ); 083 } 084 085 public UniquePathRulePartitioner( LogLevel logLevel, PlanPhase phase, RuleExpression ruleExpression, Enum... annotationExcludes ) 086 { 087 super( logLevel, phase, ruleExpression, annotationExcludes ); 088 } 089 090 public UniquePathRulePartitioner( LogLevel logLevel, PlanPhase phase, PartitionSource partitionSource, RuleExpression ruleExpression ) 091 { 092 super( logLevel, phase, partitionSource, ruleExpression ); 093 } 094 095 public UniquePathRulePartitioner( LogLevel logLevel, PlanPhase phase, PartitionSource partitionSource, RuleExpression ruleExpression, ElementAnnotation... annotations ) 096 { 097 super( logLevel, phase, partitionSource, ruleExpression, annotations ); 098 } 099 100 public UniquePathRulePartitioner( LogLevel logLevel, PlanPhase phase, PartitionSource partitionSource, RuleExpression ruleExpression, Enum... annotationExcludes ) 101 { 102 super( logLevel, phase, partitionSource, ruleExpression, annotationExcludes ); 103 } 104 105 protected UniquePathRulePartitioner( PlanPhase phase, GraphPartitioner graphPartitioner ) 106 { 107 super( phase, graphPartitioner ); 108 } 109 110 protected UniquePathRulePartitioner( LogLevel logLevel, PlanPhase phase, GraphPartitioner graphPartitioner ) 111 { 112 super( logLevel, phase, graphPartitioner ); 113 } 114 115 protected UniquePathRulePartitioner( PlanPhase phase ) 116 { 117 super( phase ); 118 } 119 120 protected UniquePathRulePartitioner() 121 { 122 } 123 124 @Override 125 protected ExpressionGraphPartitioner createExpressionGraphPartitioner( ExpressionGraph contractionGraph, ExpressionGraph expressionGraph, ElementAnnotation[] annotations ) 126 { 127 // include remainders by default 128 return new UniquePathGraphPartitioner( contractionGraph, expressionGraph, true, annotations ); 129 } 130 }