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