net.sf.farrago.plannerviz
Class FarragoPlanVisualizer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by net.sf.farrago.plannerviz.FarragoPlanVisualizer
All Implemented Interfaces:
WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, RelOptListener

public class FarragoPlanVisualizer
extends JApplet
implements RelOptListener, WindowListener

FarragoPlanVizualizer uses JGraph to visualize the machinations of the planner.

Version:
$Id: //open/dev/farrago/examples/plannerviz/src/net/sf/farrago/plannerviz/FarragoPlanVisualizer.java#14 $
Author:
John V. Sichi
See Also:
Serialized Form

Nested Class Summary
private static class FarragoPlanVisualizer.VisualEdge
           
private static class FarragoPlanVisualizer.VisualEdgeFactory
           
private static class FarragoPlanVisualizer.VisualVertex
           
 
Nested classes/interfaces inherited from class javax.swing.JApplet
JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Nested classes/interfaces inherited from interface org.eigenbase.relopt.RelOptListener
RelOptListener.RelChosenEvent, RelOptListener.RelDiscardedEvent, RelOptListener.RelEquivalenceEvent, RelOptListener.RelEvent, RelOptListener.RuleAttemptedEvent, RelOptListener.RuleEvent, RelOptListener.RuleProductionEvent
 
Field Summary
private  int currentGenerationNumber
           
private  int detail
           
private static int DETAIL_LOGICAL
           
private static int DETAIL_PHYSICAL
           
private static int DETAIL_PHYSIOLOGICAL
           
private  org.jgraph.graph.AttributeMap finalVertexAttributes
           
private  JFrame frame
           
private  org.jgraph.JGraph graph
           
private  org.jgrapht.ext.JGraphModelAdapter graphAdapter
           
private  org.jgrapht.graph.ListenableDirectedGraph<FarragoPlanVisualizer.VisualVertex,FarragoPlanVisualizer.VisualEdge> graphModel
           
private  org.jgraph.graph.GraphLayoutCache graphView
           
private  List<FarragoPlanVisualizer.VisualVertex> highlightList
           
private  org.jgraph.algebra.UnionFind logicalEquivMap
           
private  org.jgraph.graph.AttributeMap newVertexAttributes
           
private  org.jgraph.graph.AttributeMap normalVertexAttributes
           
private  Map<Object,FarragoPlanVisualizer.VisualVertex> objToVertexMap
           
private  org.jgraph.graph.AttributeMap oldVertexAttributes
           
private  org.jgraph.algebra.UnionFind physicalEquivMap
           
private  Set<RelNode> rels
           
private  String ruleName
           
private  double scale
           
private  JScrollPane scrollPane
           
private  int state
           
private static int STATE_CLOSED
           
private static int STATE_CRAWLING
           
private static int STATE_FLYING
           
private static int STATE_RUNNING
           
private static int STATE_STEPPING
           
private static int STATE_WALKING
           
private  JMenuItem status
           
private  Object stepVar
           
private static Logger tracer
           
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FarragoPlanVisualizer()
           
 
Method Summary
private  void addStateButton(JMenuBar menuBar, String name, int newState)
           
private  void addZoomButton(JMenuBar menuBar, String name, double factor)
           
private  void changeState(int newState)
           
private  void highlightRuleVertices(RelOptListener.RuleProductionEvent event)
           
private  void highlightVertex(FarragoPlanVisualizer.VisualVertex vertex, org.jgraph.graph.AttributeMap attributes)
           
private  boolean includeRel(RelNode rel)
           
 void init()
           
private  boolean isConverterRel(RelNode rel)
           
private  FarragoPlanVisualizer.VisualEdge makeEdge(FarragoPlanVisualizer.VisualVertex v1, FarragoPlanVisualizer.VisualVertex v2, String label)
           
private  FarragoPlanVisualizer.VisualVertex makeVertex(Object obj)
           
private  void paintVertex(FarragoPlanVisualizer.VisualVertex vertex, org.jgraph.graph.AttributeMap map)
           
 void relChosen(RelOptListener.RelChosenEvent event)
          Notifies this listener that a relational expression has been chosen as part of the final implementation of the query plan.
 void relDiscarded(RelOptListener.RelDiscardedEvent event)
          Notifies this listener that a relational expression is no longer of interest to the planner.
 void relEquivalenceFound(RelOptListener.RelEquivalenceEvent event)
          Notifies this listener that a relational expression has been registered with a particular equivalence class after an equivalence has been either detected or asserted.
 void ruleAttempted(RelOptListener.RuleAttemptedEvent event)
          Notifies this listener that an optimizer rule is being applied to a particular relational expression.
 void ruleProductionSucceeded(RelOptListener.RuleProductionEvent event)
          Notifies this listener that an optimizer rule has been successfully applied to a particular relational expression, resulting in a new equivalent expression (relEquivalenceFound will also be called unless the new expression is identical to an existing one).
private  void setStatus(String text)
           
private  void updateGraph()
           
private  void waitForInput()
           
 void windowActivated(WindowEvent e)
           
 void windowClosed(WindowEvent e)
           
 void windowClosing(WindowEvent e)
           
 void windowDeactivated(WindowEvent e)
           
 void windowDeiconified(WindowEvent e)
           
 void windowIconified(WindowEvent e)
           
 void windowOpened(WindowEvent e)
           
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tracer

private static final Logger tracer

STATE_CRAWLING

private static final int STATE_CRAWLING
See Also:
Constant Field Values

STATE_STEPPING

private static final int STATE_STEPPING
See Also:
Constant Field Values

STATE_WALKING

private static final int STATE_WALKING
See Also:
Constant Field Values

STATE_RUNNING

private static final int STATE_RUNNING
See Also:
Constant Field Values

STATE_FLYING

private static final int STATE_FLYING
See Also:
Constant Field Values

STATE_CLOSED

private static final int STATE_CLOSED
See Also:
Constant Field Values

DETAIL_LOGICAL

private static final int DETAIL_LOGICAL
See Also:
Constant Field Values

DETAIL_PHYSICAL

private static final int DETAIL_PHYSICAL
See Also:
Constant Field Values

DETAIL_PHYSIOLOGICAL

private static final int DETAIL_PHYSIOLOGICAL
See Also:
Constant Field Values

state

private int state

detail

private int detail

currentGenerationNumber

private int currentGenerationNumber

stepVar

private Object stepVar

frame

private JFrame frame

scrollPane

private JScrollPane scrollPane

graph

private org.jgraph.JGraph graph

graphView

private org.jgraph.graph.GraphLayoutCache graphView

graphAdapter

private org.jgrapht.ext.JGraphModelAdapter graphAdapter

graphModel

private org.jgrapht.graph.ListenableDirectedGraph<FarragoPlanVisualizer.VisualVertex,FarragoPlanVisualizer.VisualEdge> graphModel

status

private JMenuItem status

physicalEquivMap

private org.jgraph.algebra.UnionFind physicalEquivMap

logicalEquivMap

private org.jgraph.algebra.UnionFind logicalEquivMap

scale

private double scale

rels

private Set<RelNode> rels

objToVertexMap

private Map<Object,FarragoPlanVisualizer.VisualVertex> objToVertexMap

normalVertexAttributes

private org.jgraph.graph.AttributeMap normalVertexAttributes

newVertexAttributes

private org.jgraph.graph.AttributeMap newVertexAttributes

oldVertexAttributes

private org.jgraph.graph.AttributeMap oldVertexAttributes

finalVertexAttributes

private org.jgraph.graph.AttributeMap finalVertexAttributes

highlightList

private List<FarragoPlanVisualizer.VisualVertex> highlightList

ruleName

private String ruleName
Constructor Detail

FarragoPlanVisualizer

public FarragoPlanVisualizer()
Method Detail

addStateButton

private void addStateButton(JMenuBar menuBar,
                            String name,
                            int newState)

addZoomButton

private void addZoomButton(JMenuBar menuBar,
                           String name,
                           double factor)

changeState

private void changeState(int newState)

windowClosing

public void windowClosing(WindowEvent e)
Specified by:
windowClosing in interface WindowListener

windowClosed

public void windowClosed(WindowEvent e)
Specified by:
windowClosed in interface WindowListener

windowOpened

public void windowOpened(WindowEvent e)
Specified by:
windowOpened in interface WindowListener

windowIconified

public void windowIconified(WindowEvent e)
Specified by:
windowIconified in interface WindowListener

windowDeiconified

public void windowDeiconified(WindowEvent e)
Specified by:
windowDeiconified in interface WindowListener

windowActivated

public void windowActivated(WindowEvent e)
Specified by:
windowActivated in interface WindowListener

windowDeactivated

public void windowDeactivated(WindowEvent e)
Specified by:
windowDeactivated in interface WindowListener

relChosen

public void relChosen(RelOptListener.RelChosenEvent event)
Description copied from interface: RelOptListener
Notifies this listener that a relational expression has been chosen as part of the final implementation of the query plan. After the plan is copmlete, this is called one more time with null for the rel.

Specified by:
relChosen in interface RelOptListener
Parameters:
event - details about the event

relDiscarded

public void relDiscarded(RelOptListener.RelDiscardedEvent event)
Description copied from interface: RelOptListener
Notifies this listener that a relational expression is no longer of interest to the planner.

Specified by:
relDiscarded in interface RelOptListener
Parameters:
event - details about the event

relEquivalenceFound

public void relEquivalenceFound(RelOptListener.RelEquivalenceEvent event)
Description copied from interface: RelOptListener
Notifies this listener that a relational expression has been registered with a particular equivalence class after an equivalence has been either detected or asserted. Equivalence classes may be either logical (all expressions which yield the same result set) or physical (all expressions which yield the same result set with a particular calling convention).

Specified by:
relEquivalenceFound in interface RelOptListener
Parameters:
event - details about the event

ruleAttempted

public void ruleAttempted(RelOptListener.RuleAttemptedEvent event)
Description copied from interface: RelOptListener
Notifies this listener that an optimizer rule is being applied to a particular relational expression. This rule is called twice; once before the rule is invoked, and once after. Note that the rel attribute of the event is always the old expression.

Specified by:
ruleAttempted in interface RelOptListener
Parameters:
event - details about the event

ruleProductionSucceeded

public void ruleProductionSucceeded(RelOptListener.RuleProductionEvent event)
Description copied from interface: RelOptListener
Notifies this listener that an optimizer rule has been successfully applied to a particular relational expression, resulting in a new equivalent expression (relEquivalenceFound will also be called unless the new expression is identical to an existing one). This rule is called twice; once before registration of the new rel, and once after. Note that the rel attribute of the event is always the new expression; to get the old expression, use event.getRuleCall().rels[0].

Specified by:
ruleProductionSucceeded in interface RelOptListener
Parameters:
event - details about the event

setStatus

private void setStatus(String text)

highlightRuleVertices

private void highlightRuleVertices(RelOptListener.RuleProductionEvent event)

includeRel

private boolean includeRel(RelNode rel)

isConverterRel

private boolean isConverterRel(RelNode rel)

highlightVertex

private void highlightVertex(FarragoPlanVisualizer.VisualVertex vertex,
                             org.jgraph.graph.AttributeMap attributes)

paintVertex

private void paintVertex(FarragoPlanVisualizer.VisualVertex vertex,
                         org.jgraph.graph.AttributeMap map)

updateGraph

private void updateGraph()

waitForInput

private void waitForInput()

makeVertex

private FarragoPlanVisualizer.VisualVertex makeVertex(Object obj)

makeEdge

private FarragoPlanVisualizer.VisualEdge makeEdge(FarragoPlanVisualizer.VisualVertex v1,
                                                  FarragoPlanVisualizer.VisualVertex v2,
                                                  String label)

init

public void init()
Overrides:
init in class Applet