net.sf.farrago.session
Interface FarragoSessionRuntimeContext

All Superinterfaces:
ClosableAllocation, ClosableAllocationOwner, FarragoAllocation, FarragoAllocationOwner
All Known Implementing Classes:
FarragoRuntimeContext, LucidDbRuntimeContext

public interface FarragoSessionRuntimeContext
extends FarragoAllocationOwner

FarragoSessionRuntimeContext defines runtime support routines needed by generated code.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/session/FarragoSessionRuntimeContext.java#26 $
Author:
John V. Sichi

Method Summary
 void cancel()
          Requests cancellation of this execution (either for asynchronous abort, or because execution has ended).
 void checkCancel()
          Throws an exception if execution has been canceled.
 void detachMdrSession()
          Detaches the current MDR session from the running thread.
 FennelStreamGraph getFennelStreamGraph()
           
 FarragoRepos getRepos()
           
 RelDataType getRowTypeForResultSet(String resultSetName)
          Gets the row type for instantiating a result set.
 FarragoSession getSession()
           
 FennelStreamHandle getStreamHandle(String globalStreamName, boolean isInput)
          Retrieves the FennelStreamHandle corresponding to a stream
 FarragoWarningQueue getWarningQueue()
           
 RuntimeException handleRoutineInvocationException(Throwable ex, String methodName)
          Handles an exception caught by invocation of a routine.
 void loadFennelPlan(String xmiFennelPlan)
          Loads the Fennel portion of an execution plan (either creating a new XO graph or reusing a cached instance).
 void openStreams()
          Opens all streams, including the Fennel portion of the execution plan.
 void popRoutineInvocation()
          Pops a routine invocation from the context stack.
 void pushRoutineInvocation(FarragoSessionUdrContext udrContext, boolean allowSql)
          Pushes a routine invocation onto the context stack.
 void reattachMdrSession()
          Re-attaches a detached MDR session to the currently running thread, if any was previously detached.
 void setCursorState(boolean active)
          Sets the state of the top-level cursor associated with this context.
 void setExecutionHandle(FennelExecutionHandle execHandle)
          Associates an execution handle with the runtime context.
 void setStatementClassLoader(ClassLoader classLoader)
          Configures a custom class loader used to load extra classes that may be needed during statement runtime.
 void waitForCursor()
          Waits for cursor state to be reset to active=false (returns immediately if cursor is not currently active).
 
Methods inherited from interface org.eigenbase.util.ClosableAllocationOwner
addAllocation
 
Methods inherited from interface org.eigenbase.util.ClosableAllocation
closeAllocation
 
Methods inherited from interface org.eigenbase.util.ClosableAllocation
closeAllocation
 

Method Detail

loadFennelPlan

void loadFennelPlan(String xmiFennelPlan)
Loads the Fennel portion of an execution plan (either creating a new XO graph or reusing a cached instance).

Parameters:
xmiFennelPlan - XMI representation of plan definition

openStreams

void openStreams()
Opens all streams, including the Fennel portion of the execution plan. This should only be called after all Java TupleStreams have been created.


cancel

void cancel()
Requests cancellation of this execution (either for asynchronous abort, or because execution has ended).


checkCancel

void checkCancel()
Throws an exception if execution has been canceled.


setExecutionHandle

void setExecutionHandle(FennelExecutionHandle execHandle)
Associates an execution handle with the runtime context.

Parameters:
execHandle - the execution handle

setCursorState

void setCursorState(boolean active)
Sets the state of the top-level cursor associated with this context. checkCancel() is called both before the fetch request (active=true) and after the fetch (active=false). Not called for internal cursors such as UDX inputs and cursors opened via reentrant SQL from UDRs.

Parameters:
active - true if cursor is beginning a fetch request; false if cursor is ending a fetch request

waitForCursor

void waitForCursor()
Waits for cursor state to be reset to active=false (returns immediately if cursor is not currently active).


getFennelStreamGraph

FennelStreamGraph getFennelStreamGraph()
Returns:
FennelStreamGraph pinned by loadFennelPlan

getStreamHandle

FennelStreamHandle getStreamHandle(String globalStreamName,
                                   boolean isInput)
Retrieves the FennelStreamHandle corresponding to a stream

Parameters:
globalStreamName - name of the stream that you are searching for
isInput -
Returns:
FennelStreamHandle corresponding to the stream specified by the name parameter

pushRoutineInvocation

void pushRoutineInvocation(FarragoSessionUdrContext udrContext,
                           boolean allowSql)
Pushes a routine invocation onto the context stack.

Parameters:
udrContext - context holder for routine invocation instance within statement being executed
allowSql - whether SQL execution should be allowed in this routine

popRoutineInvocation

void popRoutineInvocation()
Pops a routine invocation from the context stack.


handleRoutineInvocationException

RuntimeException handleRoutineInvocationException(Throwable ex,
                                                  String methodName)
Handles an exception caught by invocation of a routine.

Parameters:
ex - exception
methodName - name of external Java method
Returns:
exception to be re-thrown

setStatementClassLoader

void setStatementClassLoader(ClassLoader classLoader)
Configures a custom class loader used to load extra classes that may be needed during statement runtime. Specifically, allows Fennel to load implementations of FarragoTransform.


getRowTypeForResultSet

RelDataType getRowTypeForResultSet(String resultSetName)
Gets the row type for instantiating a result set.

Parameters:
resultSetName - name of result set stored by optimizer
Returns:
corresponding row type

getSession

FarragoSession getSession()
Returns:
session on behalf of which this runtime context is executing

getRepos

FarragoRepos getRepos()
Returns:
FarragoRepos for use by extension projects

detachMdrSession

void detachMdrSession()
Detaches the current MDR session from the running thread. The detached session is stored for later re-attachment and is automatically re-attached and closed if when the runtime context is closed.


reattachMdrSession

void reattachMdrSession()
Re-attaches a detached MDR session to the currently running thread, if any was previously detached.


getWarningQueue

FarragoWarningQueue getWarningQueue()
Returns:
queue of warnings posted to this runtime context