return false;
}
@Override
public void transform(OperatorPlan matched) throws FrontendException {
LogicalRelationalOperator op = (LogicalRelationalOperator)matched.getSources().get(0);
LogicalSchema s = op.getSchema();
LogicalSchema determinedSchema = determineSchema(op);
if (currentPlan.getSuccessors(op) == null) {
// the output of this LOAD's not going anywhere, so we don't need
// to bother about tidying up the output
return;
}
if(!atLeastOneCastNeeded(determinedSchema, s) && op instanceof LOLoad) {
// we're not going to insert any casts, but we might reduce or increase
// the number of columns coming out of the LOAD. If the loader supports
// it we'll use the 'requiredColumns' functionality rather than bolting
// on a FOREACH
Set<Integer> required = new TreeSet<Integer>();
for(int i = 0; i < s.size(); ++i) {
// if we know the data source's schema, pick out the columns we need,
// otherwise take the first n
int index = determinedSchema == null ? i : determinedSchema.findField(s.getField(i).uid);
if(index >= 0)
required.add(index);
}
// pass the indices of the fields we need to a pruner, and fire it off
// so it configures the LOLoad (and the LoadFunc it contains)
Map<LOLoad, Pair<Map<Integer, Set<String>>, Set<Integer>>> requiredMap =
new HashMap<LOLoad, Pair<Map<Integer,Set<String>>,Set<Integer>>>(1);
Pair<Map<Integer, Set<String>>, Set<Integer>> pair =
new Pair<Map<Integer,Set<String>>, Set<Integer>>(null, required);
requiredMap.put((LOLoad) op, pair);
new ColumnPruneVisitor(currentPlan, requiredMap , true).visit((LOLoad) op);
// we only want to process this node once, so mark it:
markCastNoNeed(op);
return;
}
// For every field, build a logical plan. If the field has a type
// other than byte array, then the plan will be cast(project). Else
// it will just be project.
LogicalPlan innerPlan = new LogicalPlan();
LOForEach foreach = new LOForEach(currentPlan);
foreach.setInnerPlan(innerPlan);
foreach.setAlias(op.getAlias());
// Insert the foreach into the plan and patch up the plan.
Operator next = currentPlan.getSuccessors(op).get(0);
currentPlan.insertBetween(op, foreach, next);
List<LogicalExpressionPlan> exps = new ArrayList<LogicalExpressionPlan>();