net.sf.saffron.rel
Class SwapJoinRule

java.lang.Object
  |
  +--net.sf.saffron.opt.VolcanoRule
        |
        +--net.sf.saffron.rel.SwapJoinRule

public class SwapJoinRule
extends VolcanoRule

SwapJoinRule permutes the inputs to a join. Outer joins cannot be permuted.

Since:
Nov 26, 2003
Version:
$Id: $
Author:
jhyde

Nested Class Summary
private static class SwapJoinRule.VariableReplacer
          Walks over an expression, replacing references to fields of the left and right inputs.
 
Field Summary
 
Fields inherited from class net.sf.saffron.opt.VolcanoRule
description, planner
 
Constructor Summary
SwapJoinRule()
           
 
Method Summary
private static boolean contains(String[] names, String name, int count)
          Whether names contains name in the first count positions.
private static String[] getFieldNames(SaffronType rowType)
           
private static void makeUnique(String[] names)
          Ensures that every name in an array is distinct.
 void onMatch(VolcanoRuleCall call)
          This method is called every time the rule matches.
static ProjectRel swap(JoinRel join)
          Returns a relational expression with the inputs switched round.
 
Methods inherited from class net.sf.saffron.opt.VolcanoRule
convert, getOutConvention, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SwapJoinRule

public SwapJoinRule()
Method Detail

swap

public static ProjectRel swap(JoinRel join)
Returns a relational expression with the inputs switched round. Does not modify join. Returns null if the join cannot be swapped (for example, because it is an outer join).


getFieldNames

private static String[] getFieldNames(SaffronType rowType)

onMatch

public void onMatch(VolcanoRuleCall call)
Description copied from class: VolcanoRule
This method is called every time the rule matches. At the time that this method is called, call.rels holds the set of relational expressions which match the operands to the rule; call.rels[0] is the root expression.

Typically a rule would check that the nodes are valid matches, creates a new expression, then calls back VolcanoRuleCall.transformTo(net.sf.saffron.rel.SaffronRel) to register the expression.

Specified by:
onMatch in class VolcanoRule

makeUnique

private static void makeUnique(String[] names)
Ensures that every name in an array is distinct.


contains

private static boolean contains(String[] names,
                                String name,
                                int count)
Whether names contains name in the first count positions.


SourceForge.net_Logo